Viewer Class Reference

Before directly using any of the classes in this file, you should consider reading text_windows. More...

#include <viewer.h>

Inheritance diagram for Viewer:
Inheritance graph
[legend]
Collaboration diagram for Viewer:
Collaboration graph
[legend]

List of all members.

Public Types

enum  cmd_constant {
  activate,
  deactivate,
  resize
}
 

values that will be passed to the function call operator method.

More...
typedef CursorWindow::input_event input_event
 typename alias
typedef std::list< std::string > paste_buffer_type
 The data type of the paste buffer.
typedef CursorWindow::row_col row_col
 typename alias
typedef CursorWindow::viewport viewport
 Returns true if there are unsaved edit changes in this viewer. the default return value is false. Override this function if your viewer has the ability to have unsaved edit changes -- most don't.

Public Member Functions

virtual std::string const & application_name () const =0
 Return a const references to a string which defines the name of the application being implemented in the viewer. This function must always return the same address and the string at that address must never change;.
void commitPasteBuffer () const
 write the paste buffer to the os clipboard.
virtual std::string description () const =0
 Get a description of this viewer. Typically, this just returns the name of the directory or the name of the file the viewer is being applied to. However, with FTP viewers, POP3 viewers, etc this may not refer to any real file.
virtual bool fetchAllLines (std::list< std::string > &output)
 An optional method that fetches all the lines in this viewer object into a caller supplied list of strings.
void fetchPasteBuffer ()
 read the paste buffer from the os clipboard
virtual bool handle_event (CursorWindow::input_event const *e, CursorWindow::viewport *vp)=0
 Handle input events -- and return true if the event is meant to terminate the viewer -- and make it go away. When handling key events -- either FunctionKey or DataKey, you will want to consult the CursorWindow::func mapping to figure out if the key corresponds to 'system wide' edit function. For example,.
virtual void help ()
 Present the user with help information that is specific to this viewer's operation and contains information about system keep bindings, etc. Note that there is a default implementation of this function, but it should be overridden.
virtual bool is_dirty () const
ViewerManagermanager ()
virtual void operator() (CursorWindow::viewport *vp, int cmd)=0
 Handle screen repaint commands.
paste_buffer_typepaste_buffer ()
 Get a pointer to the viewer manager's paste buffer.
virtual void set_row_col_hint (size_t line, size_t column, bool repaint=false)
 The set_row_col_hint() method lets you specify the location where the cursor should be positioned. It is called a 'hint' because mistakes in the calling parameters are silently ignored. Also, obedience to the hint is optional. The 'repaint' parameter indicates that the screen should be immediately updated to reflect the change.
 Viewer (ViewerManager *man)

Protected Attributes

ViewerManagermanager_

Detailed Description

Before directly using any of the classes in this file, you should consider reading text_windows.

A Viewer is a cursor text interface to _something_. The something is not defined because this is an abstract interface. A Viewer is meant to be associated with a CursorWindow::viewport. That is, to use a Viewer you must do the following:

Create a command processing loop that uses CursorWindow::read_input to get CursorWindow::input_event's and pass them to your viewer class object using member handle_event. This is done automatically by the ViewerManager::run()

Note that there are some derived Viewers which may be more easy to use than Viewer. Below, you will find ListViewer which is designed to present and allow editing of a list of strings.

Maintenance note: a viewer should not store a pointer to its viewport because the viewport associated with a viewer will change over time. A viewer has the responsibility of completely repainting the viewport it given when asked to do so. This means, you can't store the size of the viewport either -- but must inquire it from the viewport passed during resizes and handle_event() calls.

A convention you should follow: when drawing the bottom line of your viewport, always make sure that it is highlighed in some fashion -- such as making it underlined. When drawing the left most column of your viewerport, if the origin.col_ for your viewport is not 0, draw a vertical bar. That is, do something like this when painting:

      row_col origin = viewport->origin();
  
      int left_column_bias = 0;
  
      if(origin.col_ != 0)
      {
        left_column_bias = 1;
  
        for each row of your viewport, draw '|' in column 0.
  
        if this is the last row, make sure you have it underlined
        or inverted from the other rows in some fashion.
      }
  
      In all subsequent drawing, don't draw in column 0.

Definition at line 47 of file viewer.h.


Member Typedef Documentation

typename alias

Definition at line 192 of file viewer.h.

typedef std::list<std::string> paste_buffer_type

The data type of the paste buffer.

Definition at line 194 of file viewer.h.

typename alias

Definition at line 191 of file viewer.h.

Returns true if there are unsaved edit changes in this viewer. the default return value is false. Override this function if your viewer has the ability to have unsaved edit changes -- most don't.

typename alias

Definition at line 190 of file viewer.h.


Member Enumeration Documentation

enum cmd_constant [inherited]

values that will be passed to the function call operator method.

Enumerator:
activate 

means you have been activated

deactivate 

some other viewport has taken focus

resize 

only the size has changed

Definition at line 793 of file cursorwindow.h.


Constructor & Destructor Documentation

Viewer ( ViewerManager man  ) 

Definition at line 121 of file viewer.h.


Member Function Documentation

virtual std::string const& application_name (  )  const [pure virtual]

Return a const references to a string which defines the name of the application being implemented in the viewer. This function must always return the same address and the string at that address must never change;.

Implemented in ViewerSelector, appChooser, ListViewer, CsvViewer, TreeViewer, TableViewer, ScriptTableViewer, TextViewer, and FTPviewer.

void commitPasteBuffer (  )  const

write the paste buffer to the os clipboard.

Definition at line 625 of file viewer.cxx.

Here is the caller graph for this function:

virtual std::string description (  )  const [pure virtual]

Get a description of this viewer. Typically, this just returns the name of the directory or the name of the file the viewer is being applied to. However, with FTP viewers, POP3 viewers, etc this may not refer to any real file.

Implemented in ViewerSelector, appChooser, ListViewer, CsvViewer, TreeViewer, TableViewer, ScriptTableViewer, TextViewer, and FTPviewer.

Here is the caller graph for this function:

bool fetchAllLines ( std::list< std::string > &  output  )  [virtual]

An optional method that fetches all the lines in this viewer object into a caller supplied list of strings.

Warning:
This is an optional feature, many viewers do not support it.
Parameters:
[out] output The location to store all the lines from this viewer.
Returns:
true to indicate that the data was extracted and false to indicate that this viewer does not support this feature.

Reimplemented in ListViewer.

Definition at line 705 of file viewer.cxx.

Here is the caller graph for this function:

void fetchPasteBuffer (  ) 

read the paste buffer from the os clipboard

Definition at line 661 of file viewer.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool handle_event ( CursorWindow::input_event const *  e,
CursorWindow::viewport vp 
) [pure virtual]

Handle input events -- and return true if the event is meant to terminate the viewer -- and make it go away. When handling key events -- either FunctionKey or DataKey, you will want to consult the CursorWindow::func mapping to figure out if the key corresponds to 'system wide' edit function. For example,.

         int edit_func = vp->window()->func[e->value_];
         switch(edit_func)
         {
            case CursorWindow::func_up:    // the up arrow key

Choose this approach instead of looking at the key values directly to allow for consistence in system wide input remapping that occurs when the application modifies the CursorWindow::func map. Note that the CursorWindow::func_data is returned for all keys not mapped into one of the other named func_* keys.

Usage note: If your handle event creates a new viewport that covers this viewport, make sure that your current viewport doesn't draw anything until the next repaint request. Otherwise, your screen will get very jumbled up!

Implemented in ViewerSelector, appChooser, ListViewer, CsvViewer, TreeViewer, TableViewer, ScriptTableViewer, TextViewer, TableEditor, and FTPviewer.

Here is the caller graph for this function:

void help (  )  [virtual]

Present the user with help information that is specific to this viewer's operation and contains information about system keep bindings, etc. Note that there is a default implementation of this function, but it should be overridden.

Reimplemented in ListViewer, CsvViewer, TreeViewer, TableViewer, ScriptTableViewer, TextViewer, and FTPviewer.

Definition at line 583 of file viewer.cxx.

Here is the caller graph for this function:

bool is_dirty (  )  const [virtual]

Reimplemented in TableViewer.

Definition at line 611 of file viewer.cxx.

Here is the caller graph for this function:

ViewerManager* manager (  ) 

Definition at line 126 of file viewer.h.

Here is the caller graph for this function:

virtual void operator() ( CursorWindow::viewport vp,
int  cmd 
) [pure virtual]

Handle screen repaint commands.

Note:
The vp parameter gets deleted regularly, don't save it!

Implements repaint_handler.

Implemented in ViewerSelector, appChooser, ListViewer, TreeViewer, TableViewer, TextViewer, and FTPviewer.

Viewer::paste_buffer_type * paste_buffer (  ) 

Get a pointer to the viewer manager's paste buffer.

Definition at line 601 of file viewer.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void set_row_col_hint ( size_t  line,
size_t  column,
bool  repaint = false 
) [virtual]

The set_row_col_hint() method lets you specify the location where the cursor should be positioned. It is called a 'hint' because mistakes in the calling parameters are silently ignored. Also, obedience to the hint is optional. The 'repaint' parameter indicates that the screen should be immediately updated to reflect the change.

Again, obedience to this function is entirely optional and most viewers will ignore it.

The line and column numbers are 0 base! Contrary to normal user's expectations, so account for this in any input calculations you make.

Definition at line 202 of file viewer.h.

Here is the caller graph for this function:


Member Data Documentation

ViewerManager* manager_ [protected]

Definition at line 117 of file viewer.h.


The documentation for this class was generated from the following files:
Generated on Wed Feb 29 22:57:51 2012 for CXXUtilities by  doxygen 1.6.3