ListViewer Class Reference

A ListViewer is a simplified version of the generic Viewer interface. It only handles the viewing/editing of lists of strings. Each string is presented in vertical list form -- one string per line. More...

#include <viewer.h>

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

List of all members.

Classes

struct  policies
 An abstract base class definining the list of strings to to be displayed/edited and a command handler. The command handler must not do any displaying of its own. More...

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

std::string const & application_name () const
 For ListViewers, the application name command is just passed through to the policy object for implementation.
void commitPasteBuffer () const
 write the paste buffer to the os clipboard.
std::string description () const
 For ListViewers, the description() method is just passed through to the policy object for implementation.
virtual bool fetchAllLines (std::list< std::string > &output)
void fetchPasteBuffer ()
 read the paste buffer from the os clipboard
int find_string (size_t index)
 Repeats the find operation started by find_string(index,vm), above. The user will not be prompted for a new string -- the old one will be used for this new search.
int find_string (size_t index, ViewerManager *vm)
 Prompt the user for a string which will then be used to initiate a search starting at the current line. The cursor will be left on the line, below the current line, which contains the string -- if a match was found.
bool handle_event (input_event const *e, viewport *vp)
 (not virtual)
virtual void help ()
 See ListViewer::policies::help_text for comments.
virtual bool is_dirty () const
int line_attribute (bool selected, size_t index, bool is_bottom)
 Compute text attributes of lines given some information about the line.
 ListViewer (policies *comtable, ViewerManager *man)
ViewerManagermanager ()
void operator() (viewport *vp, int cmd)
 Handle screen repaint policies (not virtual).
void output_row_text (viewport *vp, int i)
 output one row of the viewed text
paste_buffer_typepaste_buffer ()
 Get a pointer to the viewer manager's paste buffer.
void repaint (viewport *vp)
 wrapper around the function call operator that makes it easier to invoke a repaint.
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.

Protected Attributes

ViewerManagermanager_

Private Attributes

bool active_
std::auto_ptr< policiescom_
size_t cur_row_
size_t display_top_
int first_row_
std::string search_string_

Detailed Description

A ListViewer is a simplified version of the generic Viewer interface. It only handles the viewing/editing of lists of strings. Each string is presented in vertical list form -- one string per line.

A ListViewer is not meant for handling wide strings like files might have. It is meant rather for the display of strings where horizontal scrolling isn't really necessary. That is, you might need to compress your strings to fit in the space available rather than relying on horizontal scroll bars. See DirectoryViewer's implementation. The directory viewer chooses the text to be displayed based on the amount of horizontal space available -- and it provides a command, 'i', which toggles the display of certain less important text.

To construct a ListViewer, you must supply a ListViewer::policies object which will provide the list of strings and also a command handler for events not processed by the ListViewer itself. That is, the ListViewer will handle display, paging, etc. All other commands must be processed -- one string at a time.

Note that the policies object will be deleted by the ListViewer upon its destruction!

Here's how to use a ListViewer:

Note that there are two ways to give a ListViewer to the viewer manager. One way is to manually create the ListViewer and use one of

    ViewerManager::add
    ViewerManager::vsplit
    ViewerManager::hsplit

The other way is to let the ViewerManager create the viewer in the first place. To accomplish this, you use the ViewerManager::add_app function to provide the viewer manager with a function that will create the ListViewer for you. That is, you write a function that will prompt the user for parameters to the constructor to your ListViewer, then you give that function to the viewer manager. The viewer manager will then be able to present the user with a list of 'application' functions and let him choose which function to call -- and thus which kind of application viewer to create. A nice way to create this function is to make it a static member of the policies class, and you could also make the application name a static member of policies as well. In this way you don't have any extraneous free functions and variables laying around.

Definition at line 230 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 [inherited]

The data type of the paste buffer.

Definition at line 194 of file viewer.h.

typedef CursorWindow::row_col row_col [inherited]

typename alias

Definition at line 191 of file viewer.h.

typedef CursorWindow::viewport viewport [inherited]

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

ListViewer ( policies comtable,
ViewerManager man 
)

Contruct a ListViewer given a pointer to a ListViewer::policies object and a pointer to the ViewerManager which will own this list viewer. The ViewerManager will orchestrate the destruction of this list viewer and that destruction will also cause the destruction of the policies object. Do not manually delete either.

Definition at line 401 of file viewer.h.


Member Function Documentation

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

For ListViewers, the application name command is just passed through to the policy object for implementation.

Implements Viewer.

Definition at line 458 of file viewer.h.

void commitPasteBuffer (  )  const [inherited]

write the paste buffer to the os clipboard.

Definition at line 625 of file viewer.cxx.

Here is the caller graph for this function:

std::string description (  )  const [virtual]

For ListViewers, the description() method is just passed through to the policy object for implementation.

Implements Viewer.

Definition at line 465 of file viewer.h.

bool fetchAllLines ( std::list< std::string > &  output  )  [virtual]
See also:
cxxtls::Viewer::fetchAllLines().

Reimplemented from Viewer.

Definition at line 712 of file viewer.cxx.

void fetchPasteBuffer (  )  [inherited]

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:

int find_string ( size_t  index  ) 

Repeats the find operation started by find_string(index,vm), above. The user will not be prompted for a new string -- the old one will be used for this new search.

Definition at line 552 of file viewer.cxx.

Here is the call graph for this function:

int find_string ( size_t  index,
ViewerManager vm 
)

Prompt the user for a string which will then be used to initiate a search starting at the current line. The cursor will be left on the line, below the current line, which contains the string -- if a match was found.

Definition at line 528 of file viewer.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

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

(not virtual)

Implements Viewer.

Definition at line 238 of file viewer.cxx.

Here is the call graph for this function:

void help (  )  [virtual]

See ListViewer::policies::help_text for comments.

Reimplemented from Viewer.

Definition at line 590 of file viewer.cxx.

Here is the call graph for this function:

bool is_dirty (  )  const [virtual, inherited]

Reimplemented in TableViewer.

Definition at line 611 of file viewer.cxx.

Here is the caller graph for this function:

int line_attribute ( bool  selected,
size_t  index,
bool  is_bottom 
)

Compute text attributes of lines given some information about the line.

determine text color/attributes given info about how the text will be used.

Definition at line 50 of file viewer.cxx.

Here is the caller graph for this function:

ViewerManager* manager (  )  [inherited]

Definition at line 126 of file viewer.h.

Here is the caller graph for this function:

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

Handle screen repaint policies (not virtual).

Implements Viewer.

Definition at line 107 of file viewer.cxx.

Here is the call graph for this function:

void output_row_text ( viewport vp,
int  i 
)

output one row of the viewed text

Definition at line 429 of file viewer.h.

Here is the caller graph for this function:

Viewer::paste_buffer_type * paste_buffer (  )  [inherited]

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:

void repaint ( viewport vp  ) 

wrapper around the function call operator that makes it easier to invoke a repaint.

Definition at line 423 of file viewer.h.

Here is the caller graph for this function:

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

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

bool active_ [private]

Definition at line 395 of file viewer.h.

std::auto_ptr<policies> com_ [private]

Definition at line 389 of file viewer.h.

size_t cur_row_ [private]

Definition at line 392 of file viewer.h.

size_t display_top_ [private]

Definition at line 391 of file viewer.h.

int first_row_ [private]

Definition at line 393 of file viewer.h.

ViewerManager* manager_ [protected, inherited]

Definition at line 117 of file viewer.h.

std::string search_string_ [private]

Definition at line 397 of file viewer.h.


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