Support Forum       Library Source       SourceForge Page       G3D Web Page     
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
G3D::GuiNumberBox< Value > Class Template Reference

Number editing textbox with associated slider. More...

Inherits G3D::GuiContainer.

Classes

class  MyTextBox
 Notifies the containing pane when the text is commited. More...
 

Public Types

enum  { CONTROL_HEIGHT = 25 }
 
enum  { CONTROL_WIDTH = 215 }
 
enum  { BUTTON_WIDTH = 80 }
 
enum  { TOOL_BUTTON_WIDTH = 50 }
 

Public Member Functions

 GuiNumberBox (GuiContainer *parent, const GuiText &caption, const Pointer< Value > &value, const GuiText &units, GuiTheme::SliderScale scale, Value minValue, Value maxValue, Value roundIncrement, GuiTheme::TextBoxStyle textBoxStyle)
 For use when building larger controls out of GuiNumberBox.
 
 ~GuiNumberBox ()
 
const GuiTextcaption () const
 
float captionHeight () const
 For controls that have a caption outside the bounds of the control on the top or bottom, this is the size reserved for the caption.
 
float captionWidth () const
 For controls that have a caption outside the bounds of the control on the left, this is the size reserved for the caption.
 
const Rect2DclickRect () const
 Used by GuiContainers.
 
const Rect2DclientRect () const
 Client rect bounds, relative to the parent (or window if there is no parent).
 
virtual float defaultCaptionHeight () const
 Default caption size for this control.
 
virtual float defaultCaptionWidth () const
 
bool enabled () const
 
virtual void findControlUnderMouse (Vector2 mouse, GuiControl *&control) override
 Return the enabled, visible control containing the mouse.
 
bool focused () const
 
Vector2 fromOSWindowCoords (const Vector2 &v) const
 Transforms v from OS window coordinates to this control's coordinates.
 
virtual void increaseBounds (const Vector2 &extent)
 Updates this container to ensure that its client rect is least as wide and high as the specified extent, then recursively calls increaseBounds on its parent.
 
Value maxValue () const
 
Value minValue () const
 
bool mouseOver () const
 
void moveBy (const Vector2 &delta)
 
void moveBy (float dx, float dy)
 
void moveRightOf (const GuiControl *control)
 If these two controls have the same parent, move this one immediately to the right of the argument.
 
virtual bool onChildControlEvent (const GEvent &event)
 
Invoked immediately (i.e., outside of the queue sequence) when a child fires an event 

through Widget::fireEvent.

 
const Rect2Drect () const
 
virtual void render (RenderDevice *rd, const GuiThemeRef &skin) const override
 Only methods on skin may be called from this method by default.
 
virtual void setCaption (const GuiText &c) override
 
virtual void setCaptionHeight (float c)
 
virtual void setCaptionWidth (float c)
 
virtual void setEnabled (bool e) override
 
void setFocused (bool b)
 Grab or release keyboard focus.
 
void setHeight (float h)
 
void setPosition (const Vector2 &v)
 
void setPosition (float x, float y)
 
void setRange (Value lo, Value hi)
 
virtual void setRect (const Rect2D &rect) override
 If you explicitly change the rectangle of a control, the containing pane may clip its borders.
 
void setSize (const Vector2 &v)
 
void setSize (float x, float y)
 
void setUnitsSize (float s)
 
void setVisible (bool b)
 
void setWidth (float w)
 
GuiThemeRef theme () const
 
virtual bool toolStyle () const
 Return true if this is in tool button style.
 
Vector2 toOSWindowCoords (const Vector2 &v) const
 Returns the coordinates of v, which is in the coordinate system of this object, relative to the OSWindow on which it will be rendered.
 
Rect2D toOSWindowCoords (const Rect2D &r) const
 
float unitsSize () const
 The number of pixels between the text box and the slider.
 
bool visible () const
 
GuiWindowwindow () const
 Get the window containing this control.
 

Protected Types

enum  {
  LEFT_CAPTION_WIDTH = 80,
  TOP_CAPTION_HEIGHT = 20
}
 
enum  { textBoxWidth = 60 }
 

Protected Member Functions

void commit ()
 Called when the user commits the text box.
 
void fireEvent (GEventType type)
 Fires an event.
 
std::string formatString (double v, double roundIncrement)
 
virtual bool onEvent (const GEvent &event)
 Events are only delivered (by GuiWindow) to a GuiControl when the control has the key focus.
 
void roundAndClamp (Value &v) const
 
void updateText ()
 

Static Protected Member Functions

static std::string formatString (int v, int roundIncrement)
 
static std::string formatString (int64 v, int64 roundIncrement)
 
static std::string formatString (uint64 v, uint64 roundIncrement)
 
static std::string formatString (float v, float roundIncrement)
 
static std::string precision (double roundIncrement)
 Computes the format string for the precision specification needed to see the most significant digit of roundIncrement.
 

Protected Attributes

GuiText m_caption
 
float m_captionHeight
 
float m_captionWidth
 
Rect2D m_clickRect
 Rect bounds used for mouse actions.
 
Rect2D m_clientRect
 Position to which all child controls are relative.
 
bool m_enabled
 
GuiControlm_eventSource
 Sent events should appear to be from this object, which is usually "this".
 
std::string m_formatString
 
GuiWindowm_gui
 The window that ultimately contains this control.
 
Value m_maxValue
 
Value m_minValue
 
Value m_oldValue
 Value represented by m_textValue.
 
GuiContainerm_parent
 Parent pane.
 
Rect2D m_rect
 Rect bounds used for rendering and layout.
 
Value m_roundIncrement
 Round to the nearest multiple of this value.
 
GuiSlider< Value > * m_slider
 NULL if there is no slider.
 
GuiTextBoxm_textBox
 
std::string m_textValue
 Text version of value.
 
GuiText m_units
 
float m_unitsSize
 
Pointer< Value > m_value
 Current value.
 
bool m_visible
 

Friends

class GuiPane
 
class GuiWindow
 

Detailed Description

template<class Value>
class G3D::GuiNumberBox< Value >

Number editing textbox with associated slider.

See GuiWindow for an example of creating a number box.

Events:

The min/mix/rounding values are enforced on the GUI, but not on the underlying value if it is changed programmatically.

"nan", "inf", and "-inf" are all parsed to the appropriate floating point values.

See Also
G3D::GuiPane::addNumberBox

Member Enumeration Documentation

anonymous enum
inherited
Enumerator:
CONTROL_HEIGHT 
anonymous enum
inherited
Enumerator:
CONTROL_WIDTH 
anonymous enum
inherited
Enumerator:
BUTTON_WIDTH 
anonymous enum
inherited
Enumerator:
TOOL_BUTTON_WIDTH 
anonymous enum
protectedinherited
Enumerator:
LEFT_CAPTION_WIDTH 
TOP_CAPTION_HEIGHT 
template<class Value>
anonymous enum
protected
Enumerator:
textBoxWidth 

Constructor & Destructor Documentation

template<class Value>
G3D::GuiNumberBox< Value >::GuiNumberBox ( GuiContainer parent,
const GuiText caption,
const Pointer< Value > &  value,
const GuiText units,
GuiTheme::SliderScale  scale,
Value  minValue,
Value  maxValue,
Value  roundIncrement,
GuiTheme::TextBoxStyle  textBoxStyle 
)
inline

For use when building larger controls out of GuiNumberBox.

For making a regular GUI, use GuiPane::addNumberBox.

template<class Value>
G3D::GuiNumberBox< Value >::~GuiNumberBox ( )
inline

Member Function Documentation

const GuiText& G3D::GuiControl::caption ( ) const
inherited
float G3D::GuiControl::captionHeight ( ) const
inherited

For controls that have a caption outside the bounds of the control on the top or bottom, this is the size reserved for the caption.

float G3D::GuiControl::captionWidth ( ) const
inherited

For controls that have a caption outside the bounds of the control on the left, this is the size reserved for the caption.

const Rect2D& G3D::GuiControl::clickRect ( ) const
inlineinherited

Used by GuiContainers.

const Rect2D& G3D::GuiContainer::clientRect ( ) const
inlineinherited

Client rect bounds, relative to the parent (or window if there is no parent).

template<class Value>
void G3D::GuiNumberBox< Value >::commit ( )
inlineprotected

Called when the user commits the text box.

virtual float G3D::GuiControl::defaultCaptionHeight ( ) const
inlinevirtualinherited

Default caption size for this control.

Reimplemented in G3D::GuiFunctionBox.

virtual float G3D::GuiControl::defaultCaptionWidth ( ) const
inlinevirtualinherited
bool G3D::GuiControl::enabled ( ) const
inherited
template<class Value>
virtual void G3D::GuiNumberBox< Value >::findControlUnderMouse ( Vector2  mouse,
GuiControl *&  control 
)
inlineoverridevirtual

Return the enabled, visible control containing the mouse.

The default implementation returns itself if the mouse is within its bounds. GuiContainers should override this to iterate through children. Since only one (non-overlapping) child will write to control, it is sufficient to call this on all children without testing to see if one already wrote to control.

Reimplemented from G3D::GuiControl.

void G3D::GuiControl::fireEvent ( GEventType  type)
protectedinherited

Fires an event.

bool G3D::GuiControl::focused ( ) const
inherited
template<class Value>
static std::string G3D::GuiNumberBox< Value >::formatString ( int  v,
int  roundIncrement 
)
inlinestaticprotected
template<class Value>
static std::string G3D::GuiNumberBox< Value >::formatString ( int64  v,
int64  roundIncrement 
)
inlinestaticprotected
template<class Value>
static std::string G3D::GuiNumberBox< Value >::formatString ( uint64  v,
uint64  roundIncrement 
)
inlinestaticprotected
template<class Value>
static std::string G3D::GuiNumberBox< Value >::formatString ( float  v,
float  roundIncrement 
)
inlinestaticprotected
template<class Value>
std::string G3D::GuiNumberBox< Value >::formatString ( double  v,
double  roundIncrement 
)
inlineprotected
Vector2 G3D::GuiControl::fromOSWindowCoords ( const Vector2 v) const
inherited

Transforms v from OS window coordinates to this control's coordinates.

virtual void G3D::GuiContainer::increaseBounds ( const Vector2 extent)
virtualinherited

Updates this container to ensure that its client rect is least as wide and high as the specified extent, then recursively calls increaseBounds on its parent.

Used during automatic layout sizing.

template<class Value>
Value G3D::GuiNumberBox< Value >::maxValue ( ) const
inline
template<class Value>
Value G3D::GuiNumberBox< Value >::minValue ( ) const
inline
bool G3D::GuiControl::mouseOver ( ) const
inherited
void G3D::GuiControl::moveBy ( const Vector2 delta)
inherited
void G3D::GuiControl::moveBy ( float  dx,
float  dy 
)
inherited
void G3D::GuiControl::moveRightOf ( const GuiControl control)
inherited

If these two controls have the same parent, move this one immediately to the right of the argument.

virtual bool G3D::GuiContainer::onChildControlEvent ( const GEvent event)
virtualinherited

Invoked immediately (i.e., outside of the queue sequence) when a child fires an event 

through Widget::fireEvent.

If this method returns true, the event is never submitted to the event queue. The default implementation passes the event to the GUI parent of this GuiContainer.

This enables creation of new custom controls by embedding other controls inside a GuiContainer; the container can suppress or watch the child control events in order to present its own behavior to its parent and the GuiWindow.

virtual bool G3D::GuiControl::onEvent ( const GEvent event)
inlineprotectedvirtualinherited

Events are only delivered (by GuiWindow) to a GuiControl when the control has the key focus.

If the control does not consume the event, the event is delivered to each of its GUI parents in order, back to the window's root pane.

Key focus is transferred during a mouse down event.

Reimplemented in G3D::GuiTextureBox, G3D::GuiFunctionBox, G3D::GuiTextBox, G3D::GuiDropDownList, G3D::GuiButton, G3D::GuiRadioButton, G3D::_GuiSliderBase, G3D::GuiCheckBox, and G3D::GuiTabPane.

template<class Value>
static std::string G3D::GuiNumberBox< Value >::precision ( double  roundIncrement)
inlinestaticprotected

Computes the format string for the precision specification needed to see the most significant digit of roundIncrement.

Referenced by G3D::GuiNumberBox< int >::formatString().

const Rect2D& G3D::GuiControl::rect ( ) const
inherited
template<class Value>
virtual void G3D::GuiNumberBox< Value >::render ( RenderDevice rd,
const GuiThemeRef skin 
) const
inlineoverridevirtual

Only methods on skin may be called from this method by default.

To make arbitrary RenderDevice calls, wrap them in GuiTheme::pauseRendering ... GuiTheme::resumeRendering.

Implements G3D::GuiControl.

template<class Value>
void G3D::GuiNumberBox< Value >::roundAndClamp ( Value &  v) const
inlineprotected
template<class Value>
virtual void G3D::GuiNumberBox< Value >::setCaption ( const GuiText c)
inlineoverridevirtual

Reimplemented from G3D::GuiControl.

virtual void G3D::GuiControl::setCaptionHeight ( float  c)
virtualinherited
virtual void G3D::GuiControl::setCaptionWidth ( float  c)
virtualinherited
template<class Value>
virtual void G3D::GuiNumberBox< Value >::setEnabled ( bool  e)
inlineoverridevirtual

Reimplemented from G3D::GuiControl.

void G3D::GuiControl::setFocused ( bool  b)
inherited

Grab or release keyboard focus.

void G3D::GuiControl::setHeight ( float  h)
inherited
void G3D::GuiControl::setPosition ( const Vector2 v)
inherited
void G3D::GuiControl::setPosition ( float  x,
float  y 
)
inherited
template<class Value>
void G3D::GuiNumberBox< Value >::setRange ( Value  lo,
Value  hi 
)
inline
template<class Value>
virtual void G3D::GuiNumberBox< Value >::setRect ( const Rect2D rect)
inlineoverridevirtual

If you explicitly change the rectangle of a control, the containing pane may clip its borders.

Call pack() on the containing pane (or window) to resize that container appropriately.

Reimplemented from G3D::GuiContainer.

Referenced by G3D::GuiNumberBox< int >::setCaption(), and G3D::GuiNumberBox< int >::setUnitsSize().

void G3D::GuiControl::setSize ( const Vector2 v)
inherited
void G3D::GuiControl::setSize ( float  x,
float  y 
)
inherited
template<class Value>
void G3D::GuiNumberBox< Value >::setUnitsSize ( float  s)
inline
void G3D::GuiControl::setVisible ( bool  b)
inherited
void G3D::GuiControl::setWidth ( float  w)
inherited
GuiThemeRef G3D::GuiControl::theme ( ) const
inherited
virtual bool G3D::GuiControl::toolStyle ( ) const
inlinevirtualinherited

Return true if this is in tool button style.

Reimplemented in G3D::GuiButton, G3D::GuiRadioButton, and G3D::GuiCheckBox.

Vector2 G3D::GuiControl::toOSWindowCoords ( const Vector2 v) const
inherited

Returns the coordinates of v, which is in the coordinate system of this object, relative to the OSWindow on which it will be rendered.

Referenced by G3D::GuiControl::toOSWindowCoords().

Rect2D G3D::GuiControl::toOSWindowCoords ( const Rect2D r) const
inlineinherited
template<class Value>
float G3D::GuiNumberBox< Value >::unitsSize ( ) const
inline

The number of pixels between the text box and the slider.

template<class Value>
void G3D::GuiNumberBox< Value >::updateText ( )
inlineprotected
bool G3D::GuiControl::visible ( ) const
inherited
GuiWindow* G3D::GuiControl::window ( ) const
inherited

Get the window containing this control.

Friends And Related Function Documentation

template<class Value>
friend class GuiPane
friend
template<class Value>
friend class GuiWindow
friend

Member Data Documentation

GuiText G3D::GuiControl::m_caption
protectedinherited
float G3D::GuiControl::m_captionHeight
protectedinherited
float G3D::GuiControl::m_captionWidth
protectedinherited
Rect2D G3D::GuiControl::m_clickRect
protectedinherited

Rect bounds used for mouse actions.

Updated by setRect.

Referenced by G3D::GuiControl::clickRect().

Rect2D G3D::GuiContainer::m_clientRect
protectedinherited

Position to which all child controls are relative.

Referenced by G3D::GuiContainer::clientRect(), G3D::GuiNumberBox< int >::findControlUnderMouse(), and G3D::GuiNumberBox< int >::render().

bool G3D::GuiControl::m_enabled
protectedinherited
GuiControl* G3D::GuiControl::m_eventSource
protectedinherited

Sent events should appear to be from this object, which is usually "this".

Other controls can set the event source to create compound controls that seem atomic from the outside.

Referenced by G3D::GuiSlider< int >::GuiSlider(), and G3D::GuiNumberBox< Value >::MyTextBox::MyTextBox().

template<class Value>
std::string G3D::GuiNumberBox< Value >::m_formatString
protected
GuiWindow* G3D::GuiControl::m_gui
protectedinherited

The window that ultimately contains this control.

template<class Value>
Value G3D::GuiNumberBox< Value >::m_maxValue
protected
template<class Value>
Value G3D::GuiNumberBox< Value >::m_minValue
protected
template<class Value>
Value G3D::GuiNumberBox< Value >::m_oldValue
protected
GuiContainer* G3D::GuiControl::m_parent
protectedinherited

Parent pane.

Rect2D G3D::GuiControl::m_rect
protectedinherited

Rect bounds used for rendering and layout.

Relative to the enclosing pane's clientRect.

Referenced by G3D::GuiControl::findControlUnderMouse(), G3D::GuiNumberBox< int >::render(), G3D::GuiNumberBox< int >::setCaption(), and G3D::GuiNumberBox< int >::setRect().

template<class Value>
Value G3D::GuiNumberBox< Value >::m_roundIncrement
protected

Round to the nearest multiple of this value.

Referenced by G3D::GuiNumberBox< int >::GuiNumberBox(), and G3D::GuiNumberBox< int >::roundAndClamp().

template<class Value>
GuiSlider<Value>* G3D::GuiNumberBox< Value >::m_slider
protected
template<class Value>
GuiTextBox* G3D::GuiNumberBox< Value >::m_textBox
protected
template<class Value>
std::string G3D::GuiNumberBox< Value >::m_textValue
protected
template<class Value>
GuiText G3D::GuiNumberBox< Value >::m_units
protected
template<class Value>
float G3D::GuiNumberBox< Value >::m_unitsSize
protected
template<class Value>
Pointer<Value> G3D::GuiNumberBox< Value >::m_value
protected
bool G3D::GuiControl::m_visible
protectedinherited

documentation generated on Sat Jan 12 2013 22:49:55 using doxygen 1.8.2