policies Struct Reference

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...

#include <viewer.h>

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

List of all members.

Public Member Functions

virtual std::string const & application_name () const =0
 name of this application
virtual std::string description () const =0
 A description of the active session. Might be the name of the directory or file being viewed -- might be something else.
virtual bool fetchAllLines (std::list< std::string > &output)
virtual int handle_event (input_event const *e, size_t index, ViewerManager *vm)=0
 The handle_event method is invoked to handle events not otherwise processed by the ListViewer itself. The return code is interpreted as follows:
virtual void handle_resize (CursorWindow::row_col const &new_size)
 This method is optional -- it will be invoked to tell you what the current viewport size is. If you dont' care, don't implement this method. If you do care, you'll want to save the size for later use. You might want to define this function if want to re-architect the strings_ array based on available screen space.
virtual std::auto_ptr
< std::list< std::string > > 
help_text ()=0
 return true if this item should be displayed bold
virtual bool is_marked (size_t index)=0
 returns true if the specified string index is 'marked'. It will be displayed in a special way. Do not delete or add strings_ in this method
virtual bool is_special (size_t index)
virtual ~policies ()
 Even policies have to destructed.

Public Attributes

std::vector< std::string > strings_
 items to display in the ListViewer
std::string title_
 title of list display viewer

Detailed Description

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.

Policies are virtual methods of this class which are invoked to accomplish certain tasks. Review the documentation on the various methods below for more details.

In general, you should also create your 'add_application' function that will be used by the ViewerManager as a static method of this class as well.

Definition at line 292 of file viewer.h.


Constructor & Destructor Documentation

~policies (  )  [virtual]

Even policies have to destructed.

Definition at line 92 of file viewer.cxx.


Member Function Documentation

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

name of this application

Implemented in KeyViewer, and DirectoryViewer.

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

A description of the active session. Might be the name of the directory or file being viewed -- might be something else.

Implemented in KeyViewer, and DirectoryViewer.

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

Reimplemented in DirectoryViewer.

Definition at line 723 of file viewer.cxx.

virtual int handle_event ( input_event const *  e,
size_t  index,
ViewerManager vm 
) [pure virtual]

The handle_event method is invoked to handle events not otherwise processed by the ListViewer itself. The return code is interpreted as follows:

          0  -- the strings_ list has not been changed
          1  -- the list has changed, repaint the window
          2  -- done -- close the window

The 'index' parameter is the index into the strings_ array of the item under the cursor.

Note that you can get the window from vm->window().

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! So for example, if you call a ViewerManager function to create a viewer or split an existing one, you must be careful about doing any drawing in the current viewport. The ListViewer itself protects against this, but if you do drawing in the policies::handle_event() routine you'll need to do your own protection.

You can delete and add strings_ in this method -- just make sure that return 1 if you do -- or 2.

Implemented in KeyViewer, and DirectoryViewer.

void handle_resize ( CursorWindow::row_col const &  new_size  )  [virtual]

This method is optional -- it will be invoked to tell you what the current viewport size is. If you dont' care, don't implement this method. If you do care, you'll want to save the size for later use. You might want to define this function if want to re-architect the strings_ array based on available screen space.

Note -- do not delete or add strings_ in this method.

Reimplemented in KeyViewer, and DirectoryViewer.

Definition at line 99 of file viewer.cxx.

virtual std::auto_ptr< std::list<std::string> > help_text (  )  [pure virtual]

return true if this item should be displayed bold

This function returns the help text specific to this application. The ListViewer help method will first present the user with the return values from this function then it will present ListViewer specific help, then it will present ViewerManager specific help.

Implemented in KeyViewer, and DirectoryViewer.

virtual bool is_marked ( size_t  index  )  [pure virtual]

returns true if the specified string index is 'marked'. It will be displayed in a special way. Do not delete or add strings_ in this method

Implemented in KeyViewer, and DirectoryViewer.

bool is_special ( size_t  index  )  [virtual]

Reimplemented in DirectoryViewer.

Definition at line 42 of file viewer.cxx.


Member Data Documentation

std::vector<std::string> strings_

items to display in the ListViewer

Definition at line 309 of file viewer.h.

std::string title_

title of list display viewer

Definition at line 310 of file viewer.h.


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