GG
Static Protected Attributes
GG::Edit Class Reference

#include <Edit.h>

Inheritance diagram for GG::Edit:
GG::TextControl GG::Control GG::Wnd GG::MultiEdit

List of all members.

 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 >
GetValue () const
 operator const std::string & () const
bool Empty () const
CPSize Length () const
Pt TextUpperLeft () const
Pt TextLowerRight () const
virtual void SizeMove (const Pt &ul, const Pt &lr)
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)
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)
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
WndParent () const
WndRootParent () const
LayoutGetLayout () const
LayoutContainingLayout () 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 ()
LayoutDetachLayout ()
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)
 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 MouseWheel (const Pt &pt, int move, Flags< ModKey > mod_keys)
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)
 Wnd ()
 Wnd (X x, Y y, X w, Y h, Flags< WndFlag > flags=INTERACTIVE|DRAGABLE)
DragDropRenderingState GetDragDropRenderingState () const
virtual void LDoubleClick (const Pt &pt, Flags< ModKey > mod_keys)
virtual void MButtonDown (const Pt &pt, Flags< ModKey > mod_keys)
virtual void MDrag (const Pt &pt, const Pt &move, Flags< ModKey > mod_keys)
virtual void MButtonUp (const Pt &pt, Flags< ModKey > mod_keys)
virtual void MClick (const Pt &pt, Flags< ModKey > mod_keys)
virtual void MDoubleClick (const Pt &pt, Flags< ModKey > mod_keys)
virtual void RButtonDown (const Pt &pt, Flags< ModKey > mod_keys)
virtual void RDrag (const Pt &pt, const Pt &move, Flags< ModKey > mod_keys)
virtual void RButtonUp (const Pt &pt, Flags< ModKey > mod_keys)
virtual void RClick (const Pt &pt, Flags< ModKey > mod_keys)
virtual void RDoubleClick (const Pt &pt, Flags< ModKey > mod_keys)
virtual void MouseEnter (const Pt &pt, Flags< ModKey > mod_keys)
virtual void MouseHere (const Pt &pt, Flags< ModKey > mod_keys)
virtual void MouseLeave ()
virtual void DragDropEnter (const Pt &pt, const std::map< Wnd *, Pt > &drag_drop_wnds, Flags< ModKey > mod_keys)
virtual void DragDropHere (const Pt &pt, const std::map< Wnd *, Pt > &drag_drop_wnds, Flags< ModKey > mod_keys)
virtual void DragDropLeave ()
virtual void TimerFiring (unsigned int ticks, Timer *timer)
virtual bool EventFilter (Wnd *w, const WndEvent &event)
void HandleEvent (const WndEvent &event)
void ForwardEventToParent ()
void BeginClipping ()
void EndClipping ()
void BeginNonclientClipping ()
void EndNonclientClipping ()

Static Protected Attributes

static const int PIXEL_MARGIN

Signal Types

typedef boost::signal< void(const
std::string &)> 
EditedSignalType
typedef boost::signal< void(const
std::string &)> 
FocusUpdateSignalType

Structors

 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)
 Edit ()

Accessors

EditedSignalType EditedSignal
FocusUpdateSignalType FocusUpdateSignal
virtual Pt MinUsableSize () const
virtual Pt ClientUpperLeft () const
virtual Pt ClientLowerRight () const
const std::pair< CPSize, CPSize > & CursorPosn () const
Clr InteriorColor () const
Clr HiliteColor () const
Clr SelectedTextColor () const
virtual bool MultiSelected () const
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, CPSizeDoubleButtonDownCursorPos () const

Mutators

virtual void Render ()
virtual void SetColor (Clr c)
void SetInteriorColor (Clr c)
void SetHiliteColor (Clr c)
void SetSelectedTextColor (Clr c)
virtual void SelectRange (CPSize from, CPSize to)
virtual void SelectAll ()
virtual void SetText (const std::string &str)
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 LButtonUp (const Pt &pt, Flags< ModKey > mod_keys)
virtual void LClick (const Pt &pt, Flags< ModKey > mod_keys)
virtual void KeyPress (Key key, boost::uint32_t key_code_point, Flags< ModKey > mod_keys)
virtual void GainingFocus ()
virtual void LosingFocus ()
std::pair< CPSize, CPSizeGetDoubleButtonDownWordIndices (CPSize char_index)
std::pair< CPSize, CPSizeGetDoubleButtonDownDragWordIndices (CPSize char_index)
void ClearDoubleButtonDownMode ()

Additional Inherited Members


Detailed Description

This is a single-line edit box control.

Note that the constructor determines the height of the control based on the height of the font used and the value of the constant PIXEL_MARGIN. There are two types of signals emitted by an Edit control. The first is EditedSignal; this is emitted every time the contents of the Edit change. Sometimes, however, you don't want that. For instance, say you want to keep the value of the text in the Edit to between (numerical values) 100 and 300. If the Edit currently reads "200", the user may decide to highlight the "2", hit delete, then type a "1". If updates are immediate, you will receive notification that the Edit says "00" (an invalid value), when that is just a temporary value you don't care about. In such situations, the other signal, FocusUpdateSignal, should be useful. It is only emitted when the Edit has changed and is losing focus, or one of enter or return is pressed. So you would only receive a single update, namely "100", which is a valid number for that control, and you would receive it only when it is certain that the user is finished editing the text (when the focus changes). Note that both signals may be used at the same time, if desired.

Definition at line 57 of file Edit.h.


Member Typedef Documentation

typedef boost::signal<void (const std::string&)> GG::Edit::EditedSignalType

Emitted whenever the text of the Edit are altered (keypresses, deletes, etc.); provides the new text of the Edit.

Definition at line 63 of file Edit.h.

typedef boost::signal<void (const std::string&)> GG::Edit::FocusUpdateSignalType

Emitted whenever the Edit has changed and has lost the input focus, or one of enter or return has been pressed; provides the new text of the Edit.

Definition at line 68 of file Edit.h.


Constructor & Destructor Documentation

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 
)

Ctor. Height is determined from the font and point size used.


Member Function Documentation

virtual Pt GG::Edit::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::TextControl.

Reimplemented in GG::MultiEdit.

virtual Pt GG::Edit::ClientUpperLeft ( ) const
virtual

Returns upper-left 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::Wnd.

virtual Pt GG::Edit::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::Wnd.

Reimplemented in GG::MultiEdit.

const std::pair<CPSize, CPSize>& GG::Edit::CursorPosn ( ) const

Returns the current position of the cursor (first selected character to one past the last selected one).

Clr GG::Edit::InteriorColor ( ) const

Returns the color used to render the iterior of the control.

Clr GG::Edit::HiliteColor ( ) const

Returns the color used to render hiliting around selected text.

Clr GG::Edit::SelectedTextColor ( ) const

Returns the color used to render selected text.

virtual void GG::Edit::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::TextControl.

Reimplemented in GG::MultiEdit.

virtual void GG::Edit::SetColor ( Clr  c)
virtual

Just like Control::SetColor(), except that this one also adjusts the text color.

Reimplemented from GG::TextControl.

void GG::Edit::SetInteriorColor ( Clr  c)

Sets the interior color of the control.

void GG::Edit::SetHiliteColor ( Clr  c)

Sets the color used to render hiliting around selected text.

void GG::Edit::SetSelectedTextColor ( Clr  c)

Sets the color used to render selected text.

virtual void GG::Edit::SelectRange ( CPSize  from,
CPSize  to 
)
virtual

Selects all text in the given range. When from == to, this function just places the caret at from. Note that it is legal to pass values such that to < from. The difference is that from < to simulates a drag-selection from left to right, and to < from simulates one from right to left. The direction of the simulated drag affects which part of the text is visible at the end of the function call.

virtual void GG::Edit::SelectAll ( )
virtual

Selects all text in the entire control. This function leaves the beginning of the text in view; see SelectRange().

Reimplemented in GG::MultiEdit.

virtual void GG::Edit::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::TextControl.

Reimplemented in GG::MultiEdit.

virtual bool GG::Edit::MultiSelected ( ) const
protectedvirtual

Returns true if >= 1 characters selected.

Reimplemented in GG::MultiEdit.

CPSize GG::Edit::FirstCharShown ( ) const
protected

Returns the index of the first character visible in the Edit.

bool GG::Edit::RecentlyEdited ( ) const
protected

Returns true iff the contents have been changed since the last time the focus was gained.

CPSize GG::Edit::CharIndexOf ( X  x) const
protected

Returns the index of the code point x pixels from left edge of visible portion of string.

X GG::Edit::FirstCharOffset ( ) const
protected

Returns the distance from the beginning of the string to just before the first visible character.

X GG::Edit::ScreenPosOfChar ( CPSize  idx) const
protected

Returns the screen x-coordinate of the left side of the code point at index idx.

CPSize GG::Edit::LastVisibleChar ( ) const
protected

Returns the last visible char (not one past the last visible char).

unsigned int GG::Edit::LastButtonDownTime ( ) const
protected

Returns the value of GUI::Ticks() at the last left button press.

bool GG::Edit::InDoubleButtonDownMode ( ) const
protected

Returns true iff the button is still down after being pressed twice within GUI::DoubleClickInterval() ticks.

std::pair<CPSize, CPSize> GG::Edit::DoubleButtonDownCursorPos ( ) const
protected

Returns the cursor position at the time of the most recent double-button-down.

virtual void GG::Edit::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::Wnd.

Reimplemented in GG::MultiEdit.

virtual void GG::Edit::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::Wnd.

Reimplemented in GG::MultiEdit.

virtual void GG::Edit::LButtonUp ( const Pt pt,
Flags< ModKey >  mod_keys 
)
protectedvirtual

Respond to release of left mouse button outside this Wnd, if it was originally depressed over this Wnd. A Wnd will receive an LButtonUp() message whenever a drag that started over its area ends, even if the cursor is not currently over the window when this happens.

Reimplemented from GG::Wnd.

virtual void GG::Edit::LClick ( const Pt pt,
Flags< ModKey >  mod_keys 
)
protectedvirtual

Respond to release of left mouse button over this Wnd, if it was also originally depressed over this Wnd. A Wnd will receive an LButtonUp() message whenever a drag that started over its area ends over its area as well.

Reimplemented from GG::Wnd.

virtual void GG::Edit::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::Control.

Reimplemented in GG::MultiEdit.

virtual void GG::Edit::GainingFocus ( )
protectedvirtual

Respond to this window gaining the input focus.

Reimplemented from GG::Wnd.

virtual void GG::Edit::LosingFocus ( )
protectedvirtual

Respond to this window losing the input focus.

Reimplemented from GG::Wnd.

std::pair<CPSize, CPSize> GG::Edit::GetDoubleButtonDownWordIndices ( CPSize  char_index)
protected

Does a bit more than its name suggests. Records the current time, and if it's within GUI::DoubleClickInterval() of the last button down time, returns the code point indices that delimit the word around index char_index. If not within the time limit, or if no such word exists, the returned range will be empty (its .first and .second members will be equal). This function should be called in LButtonDown() overrides.

std::pair<CPSize, CPSize> GG::Edit::GetDoubleButtonDownDragWordIndices ( CPSize  char_index)
protected

Returns the code point indices that delimit the word around index char_index. If no such word exists, the returned range will be empty (its .first and .second members will be equal). This function should be called in LDrag() overrides when InDoubleButtonDownMode() is true.

void GG::Edit::ClearDoubleButtonDownMode ( )
protected

Sets the value of InDoubleButtonDownMode() to false. This should be called in LClick() and LButtonUp() overrides.


Member Data Documentation

EditedSignalType GG::Edit::EditedSignal
mutable

The edited signal object for this Edit.

Definition at line 96 of file Edit.h.

FocusUpdateSignalType GG::Edit::FocusUpdateSignal
mutable

The focus update signal object for this Edit.

Definition at line 99 of file Edit.h.

const int GG::Edit::PIXEL_MARGIN
staticprotected

The number of pixels to leave between the text and the control's frame.

Definition at line 208 of file Edit.h.


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