cwidget 0.5.16
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions

cwidget::widgets::pager Class Reference

A widget that displays text. More...

#include <pager.h>

Inheritance diagram for cwidget::widgets::pager:
cwidget::widgets::widget trackable cwidget::widgets::file_pager

List of all members.

Public Types

typedef std::vector
< std::wstring >::size_type 
line_count
typedef int col_count

Public Member Functions

virtual ~pager ()
 Destroy this pager.
virtual void set_text (const char *text, std::string::size_type len, const char *encoding=NULL)
 Set the text to the given memory region.
virtual void set_text (const std::string &s, const char *encoding=NULL)
 Change the displayed text.
virtual void set_text (const std::wstring &s)
 Change the displayed text.
void scroll_up (line_count nlines)
 Scroll the screen up by the given number of lines.
void scroll_down (line_count nlines)
 Scroll the screen down by the given number of lines.
void scroll_right (col_count ncols)
 Scroll the screen right by the given number of columns.
void scroll_left (col_count ncols)
 Scroll the screen left by the given number of columns.
void scroll_top ()
 Scroll to the top of the screen.
void scroll_bottom ()
 Scroll to the bottom of the screen.
void scroll_page (bool dir)
 Scroll by a page in the given direction.
void search_for (const std::wstring &s)
 Find the next line containing the given string.
void search_back_for (const std::wstring &s)
 Find the previous line containing the given string.
std::wstring get_last_search ()
 Return the last string which the user searched for.
line_count get_first_line ()
line_count get_num_lines ()
col_count get_first_column ()
col_count get_num_columns ()
void do_line_signal ()
 Emits a signal describing the verical location of the display within the text.
void do_column_signal ()
 Emits a signal describing the horizontal location of the display within the text.
virtual bool handle_key (const config::key &k)
 Handles a keypress in this widget.
virtual void dispatch_mouse (short id, int x, int y, int z, mmask_t bstate)
virtual bool focus_me ()
virtual void paint (const style &st)
 Display this widget.
int width_request ()
int height_request (int w)
 Calculate the desired height of the widget, given its width.
bool get_cursorvisible ()
point get_cursorloc ()

Static Public Member Functions

static util::ref_ptr< pagercreate (const char *text, int len, const char *encoding=NULL)
 Create a pager from the given memory region.
static util::ref_ptr< pagercreate (const std::string &s, const char *encoding=NULL)
 Create a pager from a string.
static util::ref_ptr< pagercreate (const std::wstring &s)
 Create a pager from a wide character string.
static void init_bindings ()

Public Attributes

sigc::signal2< void, int, int > line_changed
 Announces that the user has scrolled vertically.
sigc::signal2< void, int, int > column_changed
 Announces that the user has scrolled horizontally.

Static Public Attributes

static config::keybindingsbindings = NULL

Protected Member Functions

 pager (const char *text, int len, const char *encoding=NULL)
 pager (const std::string &s, const char *encoding=NULL)
 pager (const std::wstring &s)

Detailed Description

A widget that displays text.

The text is displayed as-is, without wrapping or formatting. Tab stops are placed at 8-character intervals. The user can scroll up, down, left and right using the standard keybindings.


Constructor & Destructor Documentation

cwidget::widgets::pager::~pager ( ) [virtual]

Destroy this pager.


Member Function Documentation

static util::ref_ptr<pager> cwidget::widgets::pager::create ( const char *  text,
int  len,
const char *  encoding = NULL 
) [inline, static]

Create a pager from the given memory region.

Parameters:
textthe text to display
lenthe length of the buffer
encodingthe encoding of text, or NULL to use LC_CTYPE

Reimplemented in cwidget::widgets::file_pager.

static util::ref_ptr<pager> cwidget::widgets::pager::create ( const std::string &  s,
const char *  encoding = NULL 
) [inline, static]

Create a pager from a string.

Parameters:
sthe text to display
encodingthe encoding of s, or NULL to use LC_CTYPE

Reimplemented in cwidget::widgets::file_pager.

static util::ref_ptr<pager> cwidget::widgets::pager::create ( const std::wstring &  s) [inline, static]

Create a pager from a wide character string.

Parameters:
sthe text to display
std::wstring cwidget::widgets::pager::get_last_search ( ) [inline]

Return the last string which the user searched for.

bool cwidget::widgets::pager::handle_key ( const config::key k) [virtual]

Handles a keypress in this widget.

Parameters:
kthe key that was pressed (see keybindings.h).
Returns:
true if the key was consumed; if false is returned, further processing of the key will be performed.

Reimplemented from cwidget::widgets::widget.

References cwidget::config::keybindings::key_matches(), scroll_bottom(), scroll_down(), scroll_left(), scroll_right(), scroll_top(), and scroll_up().

int cwidget::widgets::pager::height_request ( int  width) [virtual]

Calculate the desired height of the widget, given its width.

Parameters:
widththe width of this widget
Returns:
the desired height

Implements cwidget::widgets::widget.

void cwidget::widgets::pager::paint ( const style st) [virtual]

Display this widget.

Parameters:
stthe style environment in which the widget is to be displayed.

Implements cwidget::widgets::widget.

void cwidget::widgets::pager::scroll_bottom ( )

Scroll to the bottom of the screen.

References do_line_signal(), and cwidget::toplevel::update().

Referenced by handle_key().

void cwidget::widgets::pager::scroll_down ( line_count  nlines)

Scroll the screen down by the given number of lines.

References do_line_signal(), and cwidget::toplevel::update().

Referenced by handle_key(), and scroll_page().

void cwidget::widgets::pager::scroll_left ( col_count  ncols)

Scroll the screen left by the given number of columns.

References do_column_signal(), and cwidget::toplevel::update().

Referenced by handle_key().

void cwidget::widgets::pager::scroll_page ( bool  dir)

Scroll by a page in the given direction.

Parameters:
dirif true, scroll a page up; otherwise, scroll a page down.

References scroll_down(), and scroll_up().

void cwidget::widgets::pager::scroll_right ( col_count  ncols)

Scroll the screen right by the given number of columns.

References do_column_signal(), and cwidget::toplevel::update().

Referenced by handle_key().

void cwidget::widgets::pager::scroll_top ( )

Scroll to the top of the screen.

References do_line_signal(), and cwidget::toplevel::update().

Referenced by handle_key().

void cwidget::widgets::pager::scroll_up ( line_count  nlines)

Scroll the screen up by the given number of lines.

References do_line_signal(), and cwidget::toplevel::update().

Referenced by handle_key(), and scroll_page().

void cwidget::widgets::pager::search_back_for ( const std::wstring &  s) [inline]

Find the previous line containing the given string.

Parameters:
sthe string to search for
void cwidget::widgets::pager::search_for ( const std::wstring &  s) [inline]

Find the next line containing the given string.

Parameters:
sthe string to search for
virtual void cwidget::widgets::pager::set_text ( const char *  text,
std::string::size_type  len,
const char *  encoding = NULL 
) [virtual]

Set the text to the given memory region.

Parameters:
textthe text to display
lenthe length of the buffer
encodingthe encoding of text, or NULL to use LC_CTYPE
virtual void cwidget::widgets::pager::set_text ( const std::string &  s,
const char *  encoding = NULL 
) [virtual]

Change the displayed text.

Parameters:
sthe text to display
encodingthe encoding of s, or NULL to use LC_CTYPE
virtual void cwidget::widgets::pager::set_text ( const std::wstring &  s) [virtual]

Change the displayed text.

Parameters:
sthe text to display
int cwidget::widgets::pager::width_request ( ) [virtual]
Returns:
the desired width of the widget.

Implements cwidget::widgets::widget.


Member Data Documentation

sigc::signal2<void, int, int> cwidget::widgets::pager::column_changed

Announces that the user has scrolled horizontally.

Referenced by do_column_signal().

sigc::signal2<void, int, int> cwidget::widgets::pager::line_changed

Announces that the user has scrolled vertically.

Referenced by do_line_signal().


The documentation for this class was generated from the following files: