GG::MultiEdit Class Reference

This is a multi-line text input and display control. More...

#include <MultiEdit.h>

Inheritance diagram for GG::MultiEdit:

GG::Edit GG::TextControl GG::Control GG::Wnd List of all members.

Structors

 MultiEdit (int x, int y, int w, int h, const std::string &str, const boost::shared_ptr< Font > &font, Clr color, Flags< MultiEditStyle > style=MULTI_LINEWRAP, Clr text_color=CLR_BLACK, Clr interior=CLR_ZERO, Flags< WndFlag > flags=CLICKABLE)
virtual ~MultiEdit ()

Accessors

virtual Pt MinUsableSize () const
virtual Pt ClientLowerRight () const
Flags< MultiEditStyle > Style () const
int MaxLinesOfHistory () const

Mutators

virtual void Render ()
virtual void LButtonDown (const Pt &pt, Flags< ModKey > mod_keys)
virtual void LDrag (const Pt &pt, const Pt &move, Flags< ModKey > mod_keys)
virtual void MouseWheel (const Pt &pt, int move, Flags< ModKey > mod_keys)
virtual void KeyPress (Key key, Flags< ModKey > mod_keys)
virtual void SizeMove (const Pt &ul, const Pt &lr)
virtual void SelectAll ()
virtual void SetText (const std::string &str)
void SetStyle (Flags< MultiEditStyle > style)
void SetMaxLinesOfHistory (int max)
virtual void DefineAttributes (WndEditor *editor)

Structors

 MultiEdit ()

Accessors

virtual bool MultiSelected () const
int RightMargin () const
int BottomMargin () const
std::pair< int, int > CharAt (const Pt &pt) const
std::pair< int, int > CharAt (int string_idx) const
Pt ScrollPosition () const
int StringIndexOf (int row, int char_idx, const std::vector< Font::LineData > *line_data=0) const
int RowStartX (int row) const
int CharXOffset (int row, int idx) const
int RowAt (int y) const
int CharAt (int row, int x) const
int FirstVisibleRow () const
int LastVisibleRow () const
int FirstFullyVisibleRow () const
int LastFullyVisibleRow () const
int FirstVisibleChar (int row) const
int LastVisibleChar (int row) const
std::pair< int, int > HighCursorPos () const
std::pair< int, int > LowCursorPos () const

Mutators

void RecreateScrolls ()
void PreserveTextPositionOnNextSetText ()

Static Protected Attributes

static const int SCROLL_WIDTH
static const int BORDER_THICK

Detailed Description

This is a multi-line text input and display control.

MultiEdit is designed to be used as a basic text-input control for text longer than one line, or to display large amounts of formatted or unformatted text. MultiEdit supports text formatting tags. See GG::Font for details. Several style flags are available. If the MULTI_TERMINAL_STYLE flag is in use, lines that exceed the history limit will be removed from the beginning of the text; otherwise, they are removed from the end. If either MULTI_LINEWRAP of MULTI_WORDBREAK are in use, MULTI_NO_HSCROLL must be in use as well. MULTI_VCENTER is not an allowed style; if it is specified, MULTI_TOP will be used in its place. The justification introduced by text formatting tags is very different from that introduced by the TF_* styles. The former justifies lines within the space taken up by the text. The latter justifies the entire block of text within the client area of the control. So if you specify MULTI_LEFT and use <right> formatting tags on the entire text, the text will appear to be right-justified, but you will probably only see the extreme left of the text area without scrolling. If none of the no-scroll style flags are in use, the scrolls are created and destroyed automatically, as needed.

Definition at line 70 of file MultiEdit.h.


Constructor & Destructor Documentation

GG::MultiEdit::MultiEdit ( int  x,
int  y,
int  w,
int  h,
const std::string &  str,
const boost::shared_ptr< Font > &  font,
Clr  color,
Flags< MultiEditStyle >  style = MULTI_LINEWRAP,
Clr  text_color = CLR_BLACK,
Clr  interior = CLR_ZERO,
Flags< WndFlag >  flags = CLICKABLE 
)

ctor

virtual GG::MultiEdit::~MultiEdit (  )  [virtual]

dtor

GG::MultiEdit::MultiEdit (  )  [protected]

defalt ctor


Member Function Documentation

virtual Pt GG::MultiEdit::MinUsableSize (  )  const [virtual]

returns the size of the minimum bounding box that can enclose the Wnd and still show all of its elements, plus enough room for interaction with those elements (if applicable).

For example, a TextControl's MinUsableSize() is just the area of its text, and a Scroll's RenderableMinSize() is the combined sizes of its up-button, down-button, and tab (plus a bit of room in which to drag the tab).

Reimplemented from GG::Edit.

virtual Pt GG::MultiEdit::ClientLowerRight (  )  const [virtual]

returns (one pixel past) lower-right corner of window's client area in screen coordinates (or of the entire area, if no client area is specified).

Virtual because different windows have different shapes (and so ways of calculating client area)

Reimplemented from GG::Edit.

Flags<MultiEditStyle> GG::MultiEdit::Style (  )  const

returns the style flags for this MultiEdit to style

int GG::MultiEdit::MaxLinesOfHistory (  )  const

returns the maximum number of lines of text that the control keeps.

This number includes the lines that are visible in the control. A value <= 0 indicates that there is no limit.

virtual void GG::MultiEdit::Render (  )  [virtual]

draws this Wnd.

Note that Wnds being dragged for a drag-and-drop operation are rendered twice -- once in-place as normal, once in the location of the drag operation, attached to the cursor. Such Wnds may wish to render themselves differently in those two cases. To determine which render is being performed, they can call GUI::GetGUI()->RenderingDragDropWnds().

Reimplemented from GG::Edit.

virtual void GG::MultiEdit::LButtonDown ( const Pt pt,
Flags< ModKey >  mod_keys 
) [virtual]

respond to left button down msg.

A window receives this whenever any input device button changes from up to down while over the window.

Note:
If this Wnd was created with the REPEAT_BUTTON_DOWN flag, this method may be called multiple times during a single button press-release cycle.
See also:
GG::GUI

Reimplemented from GG::Edit.

virtual void GG::MultiEdit::LDrag ( const Pt pt,
const Pt move,
Flags< ModKey >  mod_keys 
) [virtual]

respond to left button drag msg (even if this Wnd is not dragable).

Drag messages are only sent to the window over which the button was pressed at the beginning of the drag. A window receives this whenever any input device button is down and the cursor is moving while over the window. The window will also receive drag messages when the mouse is being dragged outside the window's area.

Reimplemented from GG::Edit.

virtual void GG::MultiEdit::MouseWheel ( const Pt pt,
int  move,
Flags< ModKey >  mod_keys 
) [virtual]

respond to movement of the mouse wheel (move > 0 indicates the wheel is rolled up, < 0 indicates down)

Reimplemented from GG::Control.

virtual void GG::MultiEdit::KeyPress ( Key  key,
Flags< ModKey >  mod_keys 
) [virtual]

respond to down-keystrokes (focus window only).

A window may receive KeyPress() messages passed up to it from its children. For instance, Control-derived classes pass KeyPress() messages to their Parent() windows by default.

Note:
Though mouse clicks consist of a press and a release, all Control classes by default respond immediately to KeyPress(), not KeyRelease(); in fact, by default no Wnd class does anything at all on a KeyRelease event.

Reimplemented from GG::Edit.

virtual void GG::MultiEdit::SizeMove ( const Pt ul,
const Pt lr 
) [virtual]

resizes and/or moves window to new upper-left and lower right boundaries

Reimplemented from GG::TextControl.

virtual void GG::MultiEdit::SelectAll (  )  [virtual]

selects all text in the entire control.

This function leaves the beginning of the text in view; see SelectRange().

Reimplemented from GG::Edit.

virtual void GG::MultiEdit::SetText ( const std::string &  str  )  [virtual]

sets the text to str; may resize the window.

If the private member m_fit_to_text is true (i.e. if the second ctor type was used), calls to this function cause the window to be resized to whatever space the newly rendered text occupies.

Reimplemented from GG::Edit.

void GG::MultiEdit::SetStyle ( Flags< MultiEditStyle >  style  ) 

sets the style flags for this MultiEdit to style

void GG::MultiEdit::SetMaxLinesOfHistory ( int  max  ) 

sets the maximum number of rows of text that the control will keep

virtual void GG::MultiEdit::DefineAttributes ( WndEditor *  editor  )  [virtual]

provides the attributes of this object that are appropriate for a user to edit in a WndEditor; see WndEditor for details.

Reimplemented from GG::Edit.

virtual bool GG::MultiEdit::MultiSelected (  )  const [protected, virtual]

returns true if >= 1 characters are selected

Reimplemented from GG::Edit.

int GG::MultiEdit::RightMargin (  )  const [protected]

returns the width of the scrollbar on the right side of the control (0 if none)

int GG::MultiEdit::BottomMargin (  )  const [protected]

returns the width of the scrollbar at the bottom of the control (0 if none)

std::pair<int, int> GG::MultiEdit::CharAt ( const Pt pt  )  const [protected]

returns row and character index of pt, or (0, 0) if pt falls outside the text. pt is in client-space coordinates

std::pair<int, int> GG::MultiEdit::CharAt ( int  string_idx  )  const [protected]

returns row and character index of char at string index, or (0, 0) if string_idx falls outside the text, or if string_idx refers to a non-visible character

Pt GG::MultiEdit::ScrollPosition (  )  const [protected]

returns the positions of the scrollbars, in pixels

int GG::MultiEdit::StringIndexOf ( int  row,
int  char_idx,
const std::vector< Font::LineData > *  line_data = 0 
) const [protected]

returns index into WindowText() of position char_idx in row row, using line_data instead of the current line data, if it is supplied.

Not range-checked.

int GG::MultiEdit::RowStartX ( int  row  )  const [protected]

returns the the x-coordinate of the beginning of row row, in cleint-space coordinates. Not range-checked.

int GG::MultiEdit::CharXOffset ( int  row,
int  idx 
) const [protected]

returns the distance in pixels from the start of row row to the character at index idx. Not range-checked.

int GG::MultiEdit::RowAt ( int  y  )  const [protected]

returns the line that falls under y coordinate y. y must be in client-space coordinates.

int GG::MultiEdit::CharAt ( int  row,
int  x 
) const [protected]

returns the index of the character in row row that falls under x coordinate x. x must be in client-space coordinates.

int GG::MultiEdit::FirstVisibleRow (  )  const [protected]

returns the index of the first visible row, or 0 if none

int GG::MultiEdit::LastVisibleRow (  )  const [protected]

returns the index of the last visible row, or 0 if none

int GG::MultiEdit::FirstFullyVisibleRow (  )  const [protected]

returns the index of the first fully visible row, or 0 if none

int GG::MultiEdit::LastFullyVisibleRow (  )  const [protected]

returns the index of the last fully visible row, or 0 if none

int GG::MultiEdit::FirstVisibleChar ( int  row  )  const [protected]

returns the index of the first visible character of row row, or 0 if none

int GG::MultiEdit::LastVisibleChar ( int  row  )  const [protected]

returns the index of the last visible character of row row, or 0 if none

std::pair<int, int> GG::MultiEdit::HighCursorPos (  )  const [protected]

returns the greater of m_cursor_begin and m_cursor_end

std::pair<int, int> GG::MultiEdit::LowCursorPos (  )  const [protected]

returns the lesser of m_cursor_begin and m_cursor_end

void GG::MultiEdit::RecreateScrolls (  )  [protected]

recreates the vertical and horizontal scrolls as needed.

void GG::MultiEdit::PreserveTextPositionOnNextSetText (  )  [protected]

ensures that the next call to SetText() preserves the positioning of the text.

This should only be called if it is known that the call to SetText() will not put the text-position in an illegal state. For instance, if creating a MultiEdit that contains hyperlink text then coloring or underlining a link may require a call to SetText(), but may be guaranteed not to change the text layout. Without a call to this function, the scroll positions will be reset.


Member Data Documentation

const int GG::MultiEdit::SCROLL_WIDTH [static, protected]

the width used to create the control's vertical and horizontal Scrolls

Definition at line 158 of file MultiEdit.h.

const int GG::MultiEdit::BORDER_THICK [static, protected]

the thickness with which to render the border of the control

Definition at line 159 of file MultiEdit.h.


The documentation for this class was generated from the following file:
Generated on Wed Mar 26 14:35:42 2008 for GG by  doxygen 1.5.2