#include <Edit.h>
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 |
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 |
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) | |
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 | DefineAttributes (WndEditor *editor) |
Structors | |
Edit () | |
Accessors | |
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, CPSize > | DoubleButtonDownCursorPos () 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 | 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, CPSize > | GetDoubleButtonDownWordIndices (CPSize char_index) |
std::pair< CPSize, CPSize > | GetDoubleButtonDownDragWordIndices (CPSize char_index) |
void | ClearDoubleButtonDownMode () |
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.
typedef boost::signal<void (const std::string&)> GG::Edit::EditedSignalType |
typedef boost::signal<void (const std::string&)> GG::Edit::FocusUpdateSignalType |
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.
GG::Edit::Edit | ( | ) | [protected] |
Default ctor.
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.
Referenced by GG::Spin< T >::MinUsableSize().
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.
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.
Referenced by GG::Spin< T >::InteriorColor().
Clr GG::Edit::HiliteColor | ( | ) | const |
Returns the color used to render hiliting around selected text.
Referenced by GG::Spin< T >::HiliteColor().
Clr GG::Edit::SelectedTextColor | ( | ) | const |
Returns the color used to render selected text.
Referenced by GG::Spin< T >::SelectedTextColor().
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.
Referenced by GG::Spin< T >::SetInteriorColor().
void GG::Edit::SetHiliteColor | ( | Clr | c | ) |
Sets the color used to render hiliting around selected text.
Referenced by GG::Spin< T >::SetHiliteColor().
void GG::Edit::SetSelectedTextColor | ( | Clr | c | ) |
Sets the color used to render selected text.
Referenced by GG::Spin< T >::SetSelectedTextColor().
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 void GG::Edit::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::TextControl.
Reimplemented in GG::MultiEdit.
virtual bool GG::Edit::MultiSelected | ( | ) | const [protected, virtual] |
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.
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.
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.
Returns the cursor position at the time of the most recent double-button-down.
Respond to left button down msg. A window receives this whenever any input device button changes from up to down while over the window.
Reimplemented from GG::Wnd.
Reimplemented in GG::MultiEdit.
virtual void GG::Edit::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::Wnd.
Reimplemented in GG::MultiEdit.
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.
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 | |||
) | [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.
key_code_point will be zero if Unicode support is unavailable.
Reimplemented from GG::Control.
Reimplemented in GG::MultiEdit.
virtual void GG::Edit::GainingFocus | ( | ) | [protected, virtual] |
Respond to this window gaining the input focus.
Reimplemented from GG::Wnd.
virtual void GG::Edit::LosingFocus | ( | ) | [protected, virtual] |
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.
EditedSignalType GG::Edit::EditedSignal [mutable] |
const int GG::Edit::PIXEL_MARGIN [static, protected] |