Support Forum       G3D Web Page     
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
G3D::GuiControl Class Referenceabstract

Base class for all controls. More...

Inherited by G3D::_GuiSliderBase, G3D::GuiButton, G3D::GuiCheckBox, G3D::GuiContainer, G3D::GuiDropDownList, G3D::GuiFunctionBox, G3D::GuiLabel, G3D::GuiRadioButton, G3D::GuiScrollBar, G3D::GuiTextBox, G3D::GuiWidgetDestructor, and G3D::ProfilerWindow::ProfilerTreeDisplay.

Classes

class  Callback
 Base class for GuiButton pre-event handlers. More...
 

Public Member Functions

virtual ~GuiControl ()
 
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. More...
 
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. More...
 
const Rect2DclickRect () const
 Used by GuiContainers. More...
 
virtual float defaultCaptionHeight () const
 Default caption size for this control. More...
 
virtual float defaultCaptionWidth () const
 
bool enabled () const
 
virtual void findControlUnderMouse (Vector2 mouse, GuiControl *&control)
 Return the enabled, visible control containing the mouse. More...
 
bool focused () const
 
Vector2 fromOSWindowCoords (const Vector2 &v) const
 Transforms v from OS window coordinates to this control's coordinates. More...
 
bool mouseOver () const
 
void moveBy (const Vector2 &delta)
 
void moveBy (float dx, float dy)
 
void moveRightOf (const GuiControl *control, const Vector2 &offset)
 If these two controls have the same parent, move this one immediately to the right of the argument. More...
 
void moveRightOf (const GuiControl *control, float offsetX=0.0f)
 
const Rect2Drect () const
 
virtual void render (RenderDevice *rd, const shared_ptr< GuiTheme > &theme, bool ancestorsEnabled) const =0
 
Only methods on theme may be called from this method by default. More...
 
virtual void setCaption (const GuiText &caption)
 
virtual void setCaptionHeight (float c)
 
virtual void setCaptionWidth (float c)
 
virtual void setEnabled (bool e)
 
void setEventSource (GuiControl *c)
 
void setFocused (bool b)
 Grab or release keyboard focus. More...
 
void setHeight (float h)
 
void setPosition (const Vector2 &v)
 
void setPosition (float x, float y)
 
virtual void setRect (const Rect2D &rect)
 If you explicitly change the rectangle of a control, the containing pane may clip its borders. More...
 
void setSize (const Vector2 &v)
 
void setSize (float x, float y)
 
void setVisible (bool b)
 
void setWidth (float w)
 
shared_ptr< GuiThemetheme () const
 
virtual bool toolStyle () const
 Return true if this is in tool button style. More...
 
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. More...
 
Rect2D toOSWindowCoords (const Rect2D &r) const
 
bool visible () const
 
GuiWindowwindow () const
 Get the window containing this control. More...
 

Protected Types

enum  {
  LEFT_CAPTION_WIDTH = 80,
  TOP_CAPTION_HEIGHT = 20
}
 

Protected Member Functions

 GuiControl (GuiWindow *gui, const GuiText &text="")
 
 GuiControl (GuiContainer *parent, const GuiText &text="")
 
void fireEvent (GEventType type)
 Fires an event. More...
 
virtual bool onEvent (const GEvent &event)
 Events are only delivered (by GuiWindow) to a GuiControl when the control has the key focus. More...
 

Protected Attributes

GuiText m_caption
 
float m_captionHeight
 
float m_captionWidth
 
Rect2D m_clickRect
 Rect bounds used for mouse actions. More...
 
bool m_enabled
 
GuiControlm_eventSource
 Sent events should appear to be from this object, which is usually "this". More...
 
GuiWindowm_gui
 The window that ultimately contains this control. More...
 
GuiContainerm_parent
 Parent pane. More...
 
Rect2D m_rect
 Rect bounds used for rendering and layout. More...
 
bool m_visible
 

Friends

class GuiContainer
 
class GuiPane
 
class GuiWindow
 
class WidgetManager
 

Detailed Description

Base class for all controls.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
LEFT_CAPTION_WIDTH 
TOP_CAPTION_HEIGHT 

Constructor & Destructor Documentation

◆ GuiControl() [1/2]

G3D::GuiControl::GuiControl ( GuiWindow gui,
const GuiText text = "" 
)
protected

◆ GuiControl() [2/2]

G3D::GuiControl::GuiControl ( GuiContainer parent,
const GuiText text = "" 
)
protected

◆ ~GuiControl()

virtual G3D::GuiControl::~GuiControl ( )
inlinevirtual

Member Function Documentation

◆ caption()

const GuiText& G3D::GuiControl::caption ( ) const

◆ captionHeight()

float G3D::GuiControl::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.

◆ captionWidth()

float G3D::GuiControl::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.

◆ clickRect()

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

Used by GuiContainers.

◆ defaultCaptionHeight()

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

Default caption size for this control.

Reimplemented in G3D::GuiFunctionBox.

◆ defaultCaptionWidth()

virtual float G3D::GuiControl::defaultCaptionWidth ( ) const
inlinevirtual

◆ enabled()

bool G3D::GuiControl::enabled ( ) const

◆ findControlUnderMouse()

virtual void G3D::GuiControl::findControlUnderMouse ( Vector2  mouse,
GuiControl *&  control 
)
inlinevirtual

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 in G3D::GuiNumberBox< Value >, G3D::GuiNumberBox< float >, G3D::GuiNumberBox< int >, G3D::GuiTextureBox, G3D::GuiPane, G3D::GuiScrollPane, G3D::GuiFrameBox, and G3D::GuiTabPane.

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

◆ fireEvent()

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

Fires an event.

◆ focused()

bool G3D::GuiControl::focused ( ) const

◆ fromOSWindowCoords()

Vector2 G3D::GuiControl::fromOSWindowCoords ( const Vector2 v) const

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

◆ mouseOver()

bool G3D::GuiControl::mouseOver ( ) const

◆ moveBy() [1/2]

void G3D::GuiControl::moveBy ( const Vector2 delta)

◆ moveBy() [2/2]

void G3D::GuiControl::moveBy ( float  dx,
float  dy 
)

◆ moveRightOf() [1/2]

void G3D::GuiControl::moveRightOf ( const GuiControl control,
const Vector2 offset 
)

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

Parameters
offsetMay be negative

Referenced by moveRightOf().

◆ moveRightOf() [2/2]

void G3D::GuiControl::moveRightOf ( const GuiControl control,
float  offsetX = 0.0f 
)
inline

◆ onEvent()

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

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::GuiTextBox, G3D::GuiFunctionBox, G3D::GuiScrollBar, G3D::GuiDropDownList, G3D::GuiButton, G3D::ProfilerWindow::ProfilerTreeDisplay, G3D::GuiRadioButton, G3D::_GuiSliderBase, G3D::GuiTabPane, G3D::GuiCheckBox, G3D::GuiScrollPane, and G3D::GuiMultiLineTextBox.

◆ rect()

const Rect2D& G3D::GuiControl::rect ( ) const

◆ render()

virtual void G3D::GuiControl::render ( RenderDevice rd,
const shared_ptr< GuiTheme > &  theme,
bool  ancestorsEnabled 
) const
pure virtual

◆ setCaption()

virtual void G3D::GuiControl::setCaption ( const GuiText caption)
virtual

◆ setCaptionHeight()

virtual void G3D::GuiControl::setCaptionHeight ( float  c)
virtual

◆ setCaptionWidth()

virtual void G3D::GuiControl::setCaptionWidth ( float  c)
virtual

◆ setEnabled()

virtual void G3D::GuiControl::setEnabled ( bool  e)
virtual

◆ setEventSource()

void G3D::GuiControl::setEventSource ( GuiControl c)
inline

◆ setFocused()

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

Grab or release keyboard focus.

◆ setHeight()

void G3D::GuiControl::setHeight ( float  h)

◆ setPosition() [1/2]

void G3D::GuiControl::setPosition ( const Vector2 v)

◆ setPosition() [2/2]

void G3D::GuiControl::setPosition ( float  x,
float  y 
)

◆ setRect()

virtual void G3D::GuiControl::setRect ( const Rect2D rect)
virtual

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 in G3D::GuiNumberBox< Value >, G3D::GuiNumberBox< float >, G3D::GuiNumberBox< int >, G3D::GuiTextureBox, G3D::GuiPane, G3D::GuiTextBox, G3D::GuiDropDownList, G3D::GuiScrollPane, G3D::GuiTabPane, G3D::GuiContainer, G3D::GuiFrameBox, G3D::GuiRadioButton, and G3D::GuiCheckBox.

◆ setSize() [1/2]

void G3D::GuiControl::setSize ( const Vector2 v)

◆ setSize() [2/2]

void G3D::GuiControl::setSize ( float  x,
float  y 
)

◆ setVisible()

void G3D::GuiControl::setVisible ( bool  b)

◆ setWidth()

void G3D::GuiControl::setWidth ( float  w)

◆ theme()

shared_ptr<GuiTheme> G3D::GuiControl::theme ( ) const

◆ toolStyle()

virtual bool G3D::GuiControl::toolStyle ( ) const
inlinevirtual

Return true if this is in tool button style.

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

◆ toOSWindowCoords() [1/2]

Vector2 G3D::GuiControl::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.

Referenced by toOSWindowCoords().

◆ toOSWindowCoords() [2/2]

Rect2D G3D::GuiControl::toOSWindowCoords ( const Rect2D r) const
inline

◆ visible()

bool G3D::GuiControl::visible ( ) const

◆ window()

GuiWindow* G3D::GuiControl::window ( ) const

Get the window containing this control.

Friends And Related Function Documentation

◆ GuiContainer

friend class GuiContainer
friend

◆ GuiPane

friend class GuiPane
friend

◆ GuiWindow

friend class GuiWindow
friend

◆ WidgetManager

friend class WidgetManager
friend

Member Data Documentation

◆ m_caption

GuiText G3D::GuiControl::m_caption
protected

◆ m_captionHeight

float G3D::GuiControl::m_captionHeight
protected

◆ m_captionWidth

float G3D::GuiControl::m_captionWidth
protected

◆ m_clickRect

Rect2D G3D::GuiControl::m_clickRect
protected

Rect bounds used for mouse actions.

Updated by setRect.

Referenced by clickRect().

◆ m_enabled

bool G3D::GuiControl::m_enabled
protected

◆ m_eventSource

GuiControl* G3D::GuiControl::m_eventSource
protected

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(), G3D::GuiNumberBox< Value >::MyTextBox::MyTextBox(), and setEventSource().

◆ m_gui

GuiWindow* G3D::GuiControl::m_gui
protected

The window that ultimately contains this control.

◆ m_parent

GuiContainer* G3D::GuiControl::m_parent
protected

Parent pane.

◆ m_rect

Rect2D G3D::GuiControl::m_rect
protected

Rect bounds used for rendering and layout.

Relative to the enclosing pane's clientRect.

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

◆ m_visible

bool G3D::GuiControl::m_visible
protected

documentation generated on Wed Nov 24 2021 08:01:56 using doxygen 1.8.15