GG: GG::MultiEdit Class Reference

GG

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Static Public Attributes | Static Protected Attributes | List of all members
GG::MultiEdit Class Reference

`#include <MultiEdit.h>`

Inheritance diagram for GG::MultiEdit:

## Static Public Attributes
static const std::size_t | ALL_LINES
static const unsigned int | BORDER_THICK

## Static Protected Attributes
static const unsigned int | SCROLL_WIDTH
Static Protected Attributes inherited from GG::Edit
static const int | PIXEL_MARGIN

## 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 ()
| MultiEdit ()

## Accessors
virtual Pt | MinUsableSize () const
virtual Pt | ClientLowerRight () const
Flags< MultiEditStyle > | Style () const
std::size_t | MaxLinesOfHistory () const
virtual bool | MultiSelected () const
X | RightMargin () const
Y | BottomMargin () const
std::pair< std::size_t, CPSize > | CharAt (const Pt &pt) const
std::pair< std::size_t, CPSize > | CharAt (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, CPSize > | HighCursorPos () const
std::pair< std::size_t, CPSize > | LowCursorPos () 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 | 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 ()

## Additional Inherited Members
Public Types inherited from GG::Edit
typedef boost::signal< void(const std::string &)> | EditedSignalType
typedef boost::signal< void(const std::string &)> | FocusUpdateSignalType
Public Types inherited from GG::Wnd
enum | ChildClippingMode { DontClip, ClipToClient, ClipToWindow, ClipToClientAndWindowSeparately }
typedef std::map< const Wnd *, bool >::iterator | DropsAcceptableIter
Public Member Functions inherited from GG::Edit
| Edit (X x, Y y, X w, const std::string &str, const boost::shared_ptr< Font > &font, Clr color, Clr text_color=CLR_BLACK, Clr interior=CLR_ZERO, Flags< WndFlag > flags=INTERACTIVE)
virtual Pt | ClientUpperLeft () const
const std::pair< CPSize, CPSize > & | CursorPosn () const
Clr | InteriorColor () const
Clr | HiliteColor () const
Clr | SelectedTextColor () const
virtual void | SetColor (Clr c)
void | SetInteriorColor (Clr c)
void | SetHiliteColor (Clr c)
void | SetSelectedTextColor (Clr c)
virtual void | SelectRange (CPSize from, CPSize to)
Public Member Functions inherited from GG::TextControl
| TextControl (X x, Y y, X w, Y h, const std::string &str, const boost::shared_ptr< Font > &font, Clr color=CLR_BLACK, Flags< TextFormat > format=FORMAT_NONE, Flags< WndFlag > flags=Flags< WndFlag >())
| TextControl (X x, Y y, const std::string &str, const boost::shared_ptr< Font > &font, Clr color=CLR_BLACK, Flags< TextFormat > format=FORMAT_NONE, Flags< WndFlag > flags=Flags< WndFlag >())
const std::string & | Text () const
Flags< TextFormat > | GetTextFormat () const
Clr | TextColor () const
bool | ClipText () const
bool | SetMinSize () const
template<class T >
void | operator>> (T &t) const
template<class T >
T | GetValue () const
| operator const std::string & () const
bool | Empty () const
CPSize | Length () const
Pt | TextUpperLeft () const
Pt | TextLowerRight () const
void | SetTextFormat (Flags< TextFormat > format)
void | SetTextColor (Clr color)
void | ClipText (bool b)
void | SetMinSize (bool b)
template<class T >
void | operator<< (T t)
void | operator+= (const std::string &s)
void | operator+= (char c)
void | Clear ()
void | Insert (CPSize pos, char c)
void | Insert (CPSize pos, const std::string &s)
void | Erase (CPSize pos, CPSize num=CP1)
void | Insert (std::size_t line, CPSize pos, char c)
void | Insert (std::size_t line, CPSize pos, const std::string &s)
void | Erase (std::size_t line, CPSize pos, CPSize num=CP1)
Public Member Functions inherited from GG::Control
virtual void | DropsAcceptable (DropsAcceptableIter first, DropsAcceptableIter last, const Pt &pt) const
Clr | Color () const
bool | Disabled () const
virtual void | AcceptDrops (const std::vector< Wnd * > &wnds, const Pt &pt)
virtual void | Disable (bool b=true)
Public Member Functions inherited from GG::Wnd
virtual | ~Wnd ()
bool | Interactive () const
bool | RepeatButtonDown () const
bool | Dragable () const
bool | Resizable () const
bool | OnTop () const
bool | Modal () const
ChildClippingMode | GetChildClippingMode () const
bool | NonClientChild () const
bool | Visible () const
const std::string & | Name () const
const std::string & | DragDropDataType () const
Pt | UpperLeft () const
Pt | LowerRight () const
Pt | RelativeUpperLeft () const
Pt | RelativeLowerRight () const
X | Width () const
Y | Height () const
int | ZOrder () const
Pt | Size () const
Pt | MinSize () const
Pt | MaxSize () const
Pt | ClientSize () const
X | ClientWidth () const
Y | ClientHeight () const
Pt | ScreenToWindow (const Pt &pt) const
Pt | ScreenToClient (const Pt &pt) const
virtual bool | InWindow (const Pt &pt) const
virtual bool | InClient (const Pt &pt) const
const std::list< Wnd * > & | Children () const
Wnd * | Parent () const
Wnd * | RootParent () const
Layout * | GetLayout () const
Layout * | ContainingLayout () const
const std::vector < BrowseInfoMode > & | BrowseModes () const
const std::string & | BrowseInfoText (std::size_t mode) const
const boost::shared_ptr < StyleFactory > & | GetStyleFactory () const
virtual WndRegion | WindowRegion (const Pt &pt) const
void | SetDragDropDataType (const std::string &data_type)
virtual void | StartingChildDragDrop (const Wnd *wnd, const Pt &offset)
virtual void | CancellingChildDragDrop (const std::vector< const Wnd * > &wnds)
virtual void | ChildrenDraggedAway (const std::vector< Wnd * > &wnds, const Wnd *destination)
void | SetName (const std::string &name)
void | Hide (bool children=true)
void | Show (bool children=true)
virtual void | ModalInit ()
void | SetChildClippingMode (ChildClippingMode mode)
void | NonClientChild (bool b)
void | MoveTo (const Pt &pt)
void | OffsetMove (const Pt &pt)
void | Resize (const Pt &sz)
void | SetMinSize (const Pt &sz)
void | SetMaxSize (const Pt &sz)
void | AttachChild (Wnd *wnd)
void | MoveChildUp (Wnd *wnd)
void | MoveChildDown (Wnd *wnd)
void | DetachChild (Wnd *wnd)
void | DetachChildren ()
void | DeleteChild (Wnd *wnd)
void | DeleteChildren ()
void | InstallEventFilter (Wnd *wnd)
void | RemoveEventFilter (Wnd *wnd)
void | HorizontalLayout ()
void | VerticalLayout ()
void | GridLayout ()
void | SetLayout (Layout *layout)
void | RemoveLayout ()
Layout * | DetachLayout ()
void | SetLayoutBorderMargin (unsigned int margin)
void | SetLayoutCellMargin (unsigned int margin)
virtual bool | Run ()
void | EndRun ()
void | SetBrowseModeTime (unsigned int time, std::size_t mode=0)
void | SetBrowseInfoWnd (const boost::shared_ptr< BrowseInfoWnd > &wnd, std::size_t mode=0)
void | ClearBrowseInfoWnd (std::size_t mode=0)
void | SetBrowseText (const std::string &text, std::size_t mode=0)
void | SetBrowseModes (const std::vector< BrowseInfoMode > &modes)
void | SetStyleFactory (const boost::shared_ptr< StyleFactory > &factory)
| GG_ABSTRACT_EXCEPTION (Exception)
| GG_CONCRETE_EXCEPTION (BadLayout, GG::Wnd, Exception)
Static Public Member Functions inherited from GG::Wnd
static unsigned int | DefaultBrowseTime ()
static void | SetDefaultBrowseTime (unsigned int time)
static const boost::shared_ptr < BrowseInfoWnd > & | DefaultBrowseInfoWnd ()
static void | SetDefaultBrowseInfoWnd (const boost::shared_ptr< BrowseInfoWnd > &browse_info_wnd)
Public Attributes inherited from GG::Edit
EditedSignalType | EditedSignal
FocusUpdateSignalType | FocusUpdateSignal
Protected Types inherited from GG::Wnd
enum | DragDropRenderingState { NOT_DRAGGED, IN_PLACE_COPY, DRAGGED_OVER_UNACCEPTING_DROP_TARGET, DRAGGED_OVER_ACCEPTING_DROP_TARGET }
Protected Member Functions inherited from GG::Edit
| Edit ()
CPSize | FirstCharShown () const
bool | RecentlyEdited () const
CPSize | CharIndexOf (X x) const
X | FirstCharOffset () const
X | ScreenPosOfChar (CPSize idx) const
CPSize | LastVisibleChar () const
unsigned int | LastButtonDownTime () const
bool | InDoubleButtonDownMode () const
std::pair< CPSize, CPSize > | DoubleButtonDownCursorPos () const
virtual void | LButtonUp (const Pt &pt, Flags< ModKey > mod_keys)
virtual void | LClick (const Pt &pt, Flags< ModKey > mod_keys)
virtual void | GainingFocus ()
virtual void | LosingFocus ()
std::pair< CPSize, CPSize > | GetDoubleButtonDownWordIndices (CPSize char_index)
std::pair< CPSize, CPSize > | GetDoubleButtonDownDragWordIndices (CPSize char_index)
void | ClearDoubleButtonDownMode ()
Protected Member Functions inherited from GG::TextControl
| TextControl ()
const std::vector < Font::LineData > & | GetLineData () const
const boost::shared_ptr< Font > & | GetFont () const
bool | FitToText () const
Protected Member Functions inherited from GG::Control
virtual void | KeyRelease (Key key, boost::uint32_t key_code_point, Flags< ModKey > mod_keys)
| Control ()
| Control (X x, Y y, X w, Y h, Flags< WndFlag > flags=INTERACTIVE)
Protected Attributes inherited from GG::Control
Clr | m_color
bool | m_disabled

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

## 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 bool GG::MultiEdit::MultiSelected | ( |  | ) | const
| protectedvirtual

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 character 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
| ) |  |
| protectedvirtual

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
| ) |  |
| protectedvirtual

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
| ) |  |
| protectedvirtual

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
| ) |  |
| protectedvirtual

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 std::size_t GG::MultiEdit::ALL_LINES
| static

A sentinel value that indicates that there is no limit on the number of lines of history are to be stored.

See Also
  MaxLinesOfHistory()
  SetMaxLinesOfHistory()

Definition at line 105 of file MultiEdit.h.

const unsigned int GG::MultiEdit::BORDER_THICK
| static

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

Definition at line 108 of file MultiEdit.h.

const unsigned int GG::MultiEdit::SCROLL_WIDTH
| staticprotected

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

Definition at line 212 of file MultiEdit.h.

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

- MultiEdit.h