cwidget::widgets::text_layout Class Reference

Code to display formatted text. More...

#include <text_layout.h>

Inheritance diagram for cwidget::widgets::text_layout:

cwidget::widgets::widget List of all members.

Public Member Functions

bool handle_key (const config::key &k)
 Handle the given keypress.
void dispatch_mouse (short id, int x, int y, int z, mmask_t bstate)
void set_fragment (fragment *f)
 Change the fragment being displayed in this layout widget.
void append_fragment (fragment *f)
 Append the given fragment to the current fragment.
int width_request ()
 Return the requested width of this widget.
int height_request (int w)
 Return the requested height of this widget given its width, by running the fragment-layout algorithm.
bool get_cursorvisible ()
 Return true iff the cursor is visible in this widget.
point get_cursorloc ()
 The cursor is always located in the upper-left-hand corner.
bool focus_me ()
 This widget can get focus if it can scroll: ie, if its contents take up more lines than it was allocated.
void paint (const style &st)
 Paint by refreshing the contents [if necessary], then drawing, starting from the current line.
void line_down ()
 Move the view one line down.
void line_up ()
 Move the view one line up.
void move_to_top ()
 Move the view to the top of the widget.
void move_to_bottom ()
 Move the view to the bottom of the widget.
void page_down ()
 Move a page forward.
void page_up ()
 Move a page back.
void search_for (const std::wstring &s, bool search_forwards)
 Search either forwards or backwards for the string s.
void scroll (bool dir)
 Page based on a scrollbar signal.
 ~text_layout ()
 Delete the root fragment.

Static Public Member Functions

static util::ref_ptr< text_layoutcreate ()
 Create an empty text_layout.
static util::ref_ptr< text_layoutcreate (fragment *f)
 Create a text_layout with the given root fragment.
static void init_bindings ()

Public Attributes

sigc::signal2< void, int,
int > 
location_changed
 A signal that is called whenever the "location" of the view within the text changes.

Static Public Attributes

static config::keybindings * bindings

Protected Member Functions

 text_layout (fragment *f)

Detailed Description

Code to display formatted text.

The text to display is composed of a tree of "fragments". A fragment stores some amount of text; at any time, it can be formatted to a particular width. The main layout mechanisms provided are flowboxes and clipboxes: flowboxes word-wrap their contents to a particular width, while clipboxes clip their contents to a particular width. These boxes can be nested, if the user feels like it for some reason or other, although some nestings are non-sensical (for instance, placing a flowbox inside a smaller flowbox is likely to lead to really ugly text).

This provides some primitive layout mechanisms; higher-level layouts can be expressed in terms of these.


Member Function Documentation

void cwidget::widgets::text_layout::append_fragment fragment f  ) 
 

Append the given fragment to the current fragment.

Note:
this is slightly less efficient than placing the two fragments into the text_layout up-front via a single sequence_fragment. Normally this isn't a problem, but if you want to append hundreds of fragments this way, it might be.
Todo:
this is only needed for memory-management reasons (otherwise I could safely extract the current fragment and create my own sequence). Would refcounting help?
Todo:
if this becomes very useful, it would be better to just explicitly store a sequence of fragments in the layout.

static util::ref_ptr<text_layout> cwidget::widgets::text_layout::create fragment f  )  [inline, static]
 

Create a text_layout with the given root fragment.

All fragments are implicitly placed within a clipbox of width equal to the width of this widget.

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

Handle the given keypress.

Returns true if the keystroke was "consumed" by this widget.

Reimplemented from cwidget::widgets::widget.

void cwidget::widgets::text_layout::scroll bool  dir  ) 
 

Page based on a scrollbar signal.

Parameters:
dir the direction to page: if true, call page_up(); else call page_down().

void cwidget::widgets::text_layout::search_for const std::wstring &  s,
bool  search_forwards
 

Search either forwards or backwards for the string s.

The search will start on either the next or the previous line from the top of the screen.

int cwidget::widgets::text_layout::width_request  )  [virtual]
 

Return the requested width of this widget.

The requested width will be the largest possible width of any line.

Implements cwidget::widgets::widget.


The documentation for this class was generated from the following files:
Generated on Mon Feb 16 01:16:31 2009 for cwidget by  doxygen 1.4.6