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.

Static Protected Attributes

static const unsigned int SCROLL_WIDTH
static const unsigned int BORDER_THICK

Structors



 MultiEdit (X x, Y y, X w, Y 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=INTERACTIVE)
virtual ~MultiEdit ()

Accessors



virtual Pt MinUsableSize () const
virtual Pt ClientLowerRight () const
Flags< MultiEditStyle > Style () const
std::size_t MaxLinesOfHistory () const

Mutators



virtual void Render ()
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 (std::size_t max)
virtual void DefineAttributes (WndEditor *editor)

Structors



 MultiEdit ()

Accessors



virtual bool MultiSelected () const
X RightMargin () const
Y BottomMargin () const
std::pair< std::size_t, CPSizeCharAt (const Pt &pt) const
std::pair< std::size_t, CPSizeCharAt (CPSize idx) const
Pt ScrollPosition () const
CPSize CharIndexOf (std::size_t row, CPSize char_idx, const std::vector< Font::LineData > *line_data=0) const
X RowStartX (std::size_t row) const
X CharXOffset (std::size_t row, CPSize idx) const
std::size_t RowAt (Y y) const
CPSize CharAt (std::size_t row, X x) const
std::size_t FirstVisibleRow () const
std::size_t LastVisibleRow () const
std::size_t FirstFullyVisibleRow () const
std::size_t LastFullyVisibleRow () const
CPSize FirstVisibleChar (std::size_t row) const
CPSize LastVisibleChar (std::size_t row) const
std::pair< std::size_t, CPSizeHighCursorPos () const
std::pair< std::size_t, CPSizeLowCursorPos () const

Mutators



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, boost::uint32_t key_code_point, Flags< ModKey > mod_keys)
void RecreateScrolls ()
void PreserveTextPositionOnNextSetText ()


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 60 of file MultiEdit.h.


Constructor & Destructor Documentation

GG::MultiEdit::MultiEdit ( X  x,
Y  y,
X  w,
Y  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 = INTERACTIVE 
)

Ctor.

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

Dtor.

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

Default 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 MinUsableSize() 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.

std::size_t 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 of ALL_LINES 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::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 displayed in this control to str. May resize the window. If FitToText() returns true (i.e. if the second ctor 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 ( std::size_t  max  ) 

Sets the maximum number of rows of text that the control will keep. ALL_LINES indicates no limit.

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.

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

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

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

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

std::pair<std::size_t, CPSize> 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<std::size_t, CPSize> GG::MultiEdit::CharAt ( CPSize  idx  )  const [protected]

Returns row and character index of char at idx, or (0, 0) if idx falls outside the text, or if idx refers to a non-visible character.

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

Returns the positions of the scrollbars.

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

Returns the code point index of the start of the UTF-8 sequence for the code point at char_idx in row row, using line_data instead of the current line data, if it is supplied. If row, char_idx refers to a character preceeded by formatting tags, the index of the first chracter of the first formatting tag is returned instead. Not range-checked.

X GG::MultiEdit::RowStartX ( std::size_t  row  )  const [protected]

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

X GG::MultiEdit::CharXOffset ( std::size_t  row,
CPSize  idx 
) const [protected]

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

std::size_t GG::MultiEdit::RowAt ( Y  y  )  const [protected]

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

CPSize GG::MultiEdit::CharAt ( std::size_t  row,
X  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.

std::size_t GG::MultiEdit::FirstVisibleRow (  )  const [protected]

Returns the index of the first visible row, or 0 if none.

std::size_t GG::MultiEdit::LastVisibleRow (  )  const [protected]

Returns the index of the last visible row, or 0 if none.

std::size_t GG::MultiEdit::FirstFullyVisibleRow (  )  const [protected]

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

std::size_t GG::MultiEdit::LastFullyVisibleRow (  )  const [protected]

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

CPSize GG::MultiEdit::FirstVisibleChar ( std::size_t  row  )  const [protected]

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

CPSize GG::MultiEdit::LastVisibleChar ( std::size_t  row  )  const [protected]

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

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

Returns the greater of m_cursor_begin and m_cursor_end.

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

Returns the lesser of m_cursor_begin and m_cursor_end.

virtual void GG::MultiEdit::LButtonDown ( const Pt pt,
Flags< ModKey >  mod_keys 
) [protected, 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 
) [protected, 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 
) [protected, 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,
boost::uint32_t  key_code_point,
Flags< ModKey >  mod_keys 
) [protected, 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.

key_code_point will be zero if Unicode support is unavailable.

Reimplemented from GG::Edit.

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 unsigned int GG::MultiEdit::SCROLL_WIDTH [static, protected]

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

Definition at line 208 of file MultiEdit.h.

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

The thickness with which to render the border of the control.

Definition at line 211 of file MultiEdit.h.


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

Generated on Sat Mar 26 07:08:38 2011 for GG by  doxygen 1.5.9