PixelLightAPI  .
Public Member Functions | Protected Member Functions | Protected Attributes
PLGui::Widget Class Reference

Widget class. More...

#include <Widget.h>

Inheritance diagram for PLGui::Widget:
Inheritance graph
[legend]

List of all members.

Public Member Functions

PLGUI_API Widget (Widget *pParent=nullptr, bool bManaged=false)
 Constructor.
PLGUI_API Widget (PLCore::handle nNativeWindowHandle)
 Constructor.
virtual PLGUI_API ~Widget ()
 Destructor.
PLGUI_API GuiGetGui () const
 Get owner GUI.
PLGUI_API WidgetImplGetImpl () const
 Get implementation.
PLGUI_API PLCore::handle GetNativeWindowHandle () const
 Get system native window handle.
PLGUI_API PLCore::uint32 GetID () const
 Get ID.
PLGUI_API void SetID (PLCore::uint32 nID)
 Set ID.
PLGUI_API PLCore::String GetName () const
 Get name.
PLGUI_API void SetName (const PLCore::String &sName)
 Set name.
PLGUI_API PLCore::String GetDescriptor () const
 Get descriptor.
PLGUI_API void * GetUserData () const
 Get user defined data.
PLGUI_API void SetUserData (void *pData)
 Set user defined data.
PLGUI_API bool IsManaged () const
 Get whether or not the widget is managed.
PLGUI_API PLCore::String GetTitle () const
 Get title.
PLGUI_API void SetTitle (const PLCore::String &sTitle)
 Set title.
PLGUI_API const ImageGetIcon () const
 Get icon.
PLGUI_API void SetIcon (const Image &cIcon)
 Set icon.
PLGUI_API const CursorGetCursor () const
 Get cursor.
PLGUI_API void SetCursor (const Cursor &cCursor)
 Set cursor.
PLGUI_API WidgetGetParent () const
 Get parent widget.
PLGUI_API WidgetGetCommonParent (const Widget &cWidget) const
 Get common parent of this and another widget.
PLGUI_API WidgetGetTopLevelWidget () const
 Get top level widget that is parent of this widget.
virtual PLGUI_API WidgetGetContentWidget () const
 Get content widget.
PLGUI_API const PLCore::List
< Widget * > & 
GetChildren () const
 Get list of children.
PLGUI_API WidgetGetFirstChild () const
 Get first child widget.
PLGUI_API WidgetGetLastChild () const
 Get last child widget.
PLGUI_API WidgetGetPreviousSibling () const
 Get previous sibling widget.
PLGUI_API WidgetGetNextSibling () const
 Get next sibling widget.
PLGUI_API bool IsTopLevel () const
 Check if widget is a top level window.
PLGUI_API bool IsShowInTaskbar () const
 Check if widget is visible in the taskbar.
PLGUI_API void SetShowInTaskbar (bool bShowInTaskbar)
 Set if widget is visible in the taskbar.
PLGUI_API ScreenGetScreen () const
 Get screen the widget is on.
PLGUI_API void MoveToScreen (Screen &cScreen)
 Move widget to another screen.
PLGUI_API PLMath::Vector2i GetPos () const
 Get widget position.
PLGUI_API void SetPos (const PLMath::Vector2i &vPos)
 Set widget position.
PLGUI_API PLMath::Vector2i GetSize () const
 Get widget size.
PLGUI_API void SetSize (const PLMath::Vector2i &vSize)
 Set widget size.
PLGUI_API bool GetTopmost () const
 Check if widget is topmost (always above all other widgets)
PLGUI_API void SetTopmost (bool bTopmost)
 Set if widget is topmost (always above all other widgets)
PLGUI_API PLMath::Vector2i GetAbsPos () const
 Get absolute widget position.
PLGUI_API PLMath::Vector2i GetRelativePos (Widget &cWidget) const
 Get position relative to another widget.
PLGUI_API void Center (ECenter nCenter)
 Center widget.
PLGUI_API void CenterOnScreen (Screen &cScreen)
 Center widget relative to the screen.
PLGUI_API void CenterOnWidget (Widget &cWidget)
 Center widget relative to another widget.
PLGUI_API void CalculatePreferredSize (const PLMath::Vector2i &vRefSize=PLMath::Vector2i(-1,-1))
 Calculate preferred size.
PLGUI_API PLMath::Vector2i GetPreferredSize () const
 Get preferred size.
PLGUI_API void FitSize ()
 Set size of widget to fit it's content.
PLGUI_API void SetZPos (EZPos nZPos, Widget *pWidget=nullptr)
 Set Z position.
PLGUI_API EWindowState GetWindowState () const
 Get window state.
PLGUI_API void SetWindowState (EWindowState nWindowState)
 Set window state.
PLGUI_API PLGraphics::Color4 GetBackgroundColor () const
 Get background color.
PLGUI_API void SetBackgroundColor (const PLGraphics::Color4 &cColor)
 Set background color.
PLGUI_API void SetTransparency (ETransparency nTransparency, const PLGraphics::Color4 &cColor)
 Set transparency mode.
PLGUI_API void Close ()
 Close widget.
PLGUI_API bool IsDestroyed () const
 Check if widget has been destroyed.
PLGUI_API void Destroy ()
 Destroy widget.
PLGUI_API bool IsVisible () const
 Check if widget is visible.
PLGUI_API void SetVisible (bool bVisible)
 Show or hide widget.
PLGUI_API bool IsEnabled () const
 Check if widget is enabled.
PLGUI_API void SetEnabled (bool bEnabled)
 Enable or disable widget.
PLGUI_API EFocusStyle GetFocusStyle () const
 Get focus style.
PLGUI_API void SetFocusStyle (EFocusStyle nFocusStyle)
 Set focus style.
PLGUI_API bool CanAcceptFocus () const
 Check if widget can accept the focus.
PLGUI_API bool IsTabStop ()
 Get tab-stop.
PLGUI_API void SetTabStop (bool bTabStop)
 Set tab-stop.
PLGUI_API bool HasFocus () const
 Check if widget has the focus.
PLGUI_API bool SetFocus ()
 Set keyboard focus to the widget.
PLGUI_API bool IsActive () const
 Check if widget is active (either the widget or one of it's children has the focus)
PLGUI_API void Activate ()
 Activate a widget (bring it to the top and set the focus to it)
PLGUI_API bool NextTabStop (bool bForward)
 Give keyboard focus to next tab-stop widget.
PLGUI_API bool IsMouseIn () const
 Check if the mouse is currently inside the widget.
PLGUI_API bool IsMouseOver () const
 Check if the mouse is currently over either the widget or one of it's child widgets.
PLGUI_API bool GetMousePos (PLMath::Vector2i &vPos) const
 Get current mouse cursor position inside the widget.
virtual PLGUI_API PLCore::uint32 GetWidgetState () const
 Get widget state.
PLGUI_API void Redraw ()
 Redraw widget.
PLGUI_API void RedrawAll ()
 Redraw widget and all child widgets.
PLGUI_API bool IsCaptureMouse () const
 Check if widget has captured mouse input.
PLGUI_API void SetCaptureMouse (bool bCapture)
 Capture mouse input.
PLGUI_API void SetTrapMouse (bool bTrap)
 Trap mouse inside the widget.
PLGUI_API PLCore::uint32 RegisterHotkey (PLCore::uint32 nModKey, PLCore::uint32 nKey)
 Register a hotkey.
PLGUI_API void UnregisterHotkey (PLCore::uint32 nID)
 Unregister a hotkey.
PLGUI_API ThemeGetTheme () const
 Get theme.
PLGUI_API void SetTheme (Theme *pTheme)
 Set theme.
PLGUI_API const PLCore::List
< Modifier * > & 
GetModifiers () const
 Get modifiers.
PLGUI_API ModifierGetModifier (const PLCore::String &sName) const
 Get modifier.
PLGUI_API void AddModifier (Modifier *pModifier)
 Add modifier.
PLGUI_API void AddModifier (const PLCore::String &sName, Modifier *pModifier)
 Add modifier.
PLGUI_API void AddModifier (const PLCore::String &sClass, const PLCore::String &sOptions)
 Add modifier.
PLGUI_API void AddModifier (const PLCore::String &sName, const PLCore::String &sClass, const PLCore::String &sOptions)
 Add modifier.
PLGUI_API void RemoveModifier (Modifier *pModifier)
 Remove modifier.
PLGUI_API void RemoveModifier (const PLCore::String &sName)
 Remove modifier.
PLGUI_API LayoutGetLayout () const
 Get layout.
PLGUI_API void SetLayout (Layout *pLayout)
 Set layout.
PLGUI_API void SetLayout (const PLCore::String &sClass, const PLCore::String &sOptions)
 Set layout.
PLGUI_API LayoutHintsGetLayoutHints ()
 Get layout hints.
PLGUI_API void AdjustContent ()
 Adjust content of the widget.
PLGUI_API void UpdateContent ()
 Update content.

Protected Member Functions

PLGUI_API Widget (Gui *pGui)
 Constructor.
PLGUI_API void AddChild (Widget *pWidget)
 Add child widget.
PLGUI_API void RemoveChild (Widget *pWidget)
 Remove child widget.
PLGUI_API bool ActivateFirstTabStop ()
 Give focus to first tab-stop widget (including this and all children)
PLGUI_API bool ActivateLastTabStop ()
 Give focus to last tab-stop widget (including this and all children)
PLGUI_API void DrawBackground (Graphics &cGraphics)
 Draw background.
PLGUI_API void Draw (Graphics &cGraphics)
 Draw widget.
virtual PLGUI_API void OnMessage (const GuiMessage &cMessage) override
 Process GUI message.
virtual PLGUI_API PLMath::Vector2i OnPreferredSize (const PLMath::Vector2i &vRefSize) const override
 Called when the widget is to calculate it's preferred size.
virtual PLGUI_API void OnThemeChanged () override
 Called when the theme has been changed.
virtual PLGUI_API void OnUpdateContent () override
 Called when the widget has been changed.
virtual PLGUI_API void OnAdjustContent () override
 Called when the widget content has to be adjusted.

Protected Attributes

Guim_pGui
bool m_bManaged
bool m_bRootWidget
PLCore::uint32 m_nID
PLCore::String m_sName
Widgetm_pParent
WidgetImplm_pWidgetImpl
Themem_pTheme
PLCore::List< Widget * > m_lstChildren
PLCore::List< Modifier * > m_lstModifiers
PLCore::HashMap
< PLCore::String, Modifier * > 
m_mapModifiers
Layoutm_pLayout
LayoutHints m_cLayoutHints
EWindowState m_nWindowState
PLMath::Vector2i m_vPos
PLMath::Vector2i m_vSize
bool m_bTopmost
PLCore::String m_sTitle
Image m_cIcon
Cursor m_cCursor
EFocusStyle m_nFocusStyle
bool m_bTabStop
bool m_bCaptureMouse
PLGraphics::Color4 m_cBackgroundColor
PLMath::Vector2i m_vPreferredSize
void * m_pUserData

Detailed Description

Widget class.

Remarks:
This class represents a basic widget
Note:
  • Implementation of the bridge design pattern, this class is the abstraction

Constructor & Destructor Documentation

PLGUI_API PLGui::Widget::Widget ( Widget pParent = nullptr,
bool  bManaged = false 
)

Constructor.

Parameters:
[in]pParentPointer to the parent widget
[in]bManagedIf 'true', the widget is not automatically destroyed by Gui and will not appear in the list of top-level windows
Remarks:
If pParent == nullptr, the root widget of the system GUI is used as parent widget
PLGUI_API PLGui::Widget::Widget ( PLCore::handle  nNativeWindowHandle)

Constructor.

Parameters:
[in]nNativeWindowHandleSystem native window handle
Remarks:
This constructor can be used to wrap an already existing system window into a PLGui Widget, there you need to pass a valid system handle for the window being wrapped. This only works with the system GUI, which is being used automatically.
virtual PLGUI_API PLGui::Widget::~Widget ( ) [virtual]

Destructor.

PLGUI_API PLGui::Widget::Widget ( Gui pGui) [protected]

Constructor.

Parameters:
[in]pGuiPointer to the parent GUI
Remarks:
This create a dummy widget for the 'root' of a GUI. This widget is not a real widget, so don't call anything that would need a real widget backend to be present. It is only used to server as a parent for new widgets and should not be used for anything else. Also note that if you pass a root widget as parent, it will be used to obtain the GUI pointer but than be discarded (afterwards, GetParent() of the new widget will return a null pointer)

Member Function Documentation

PLGUI_API Gui* PLGui::Widget::GetGui ( ) const

Get owner GUI.

Returns:
Pointer to GUI object
PLGUI_API WidgetImpl* PLGui::Widget::GetImpl ( ) const

Get implementation.

Returns:
Pointer to platform specific implementation
PLGUI_API PLCore::handle PLGui::Widget::GetNativeWindowHandle ( ) const

Get system native window handle.

Returns:
Native window handle
PLGUI_API PLCore::uint32 PLGui::Widget::GetID ( ) const

Get ID.

Returns:
Widget ID
PLGUI_API void PLGui::Widget::SetID ( PLCore::uint32  nID)

Set ID.

Parameters:
[in]nIDWidget ID

Get name.

Returns:
Widget name
PLGUI_API void PLGui::Widget::SetName ( const PLCore::String sName)

Set name.

Parameters:
[in]sNameWidget name

Get descriptor.

Returns:
Descriptor for widget (Name, ID or window handle)
Remarks:
This functions returns a readable descriptor for the widget, which is either the name (if a name has been set), the ID (if set) or the window handle if all of the previous mentioned weren't available. Use this function e.g. to output a widget descriptor in debug messages.
PLGUI_API void* PLGui::Widget::GetUserData ( ) const

Get user defined data.

Returns:
User data

Reimplemented in PLGui::TabBarEntry.

PLGUI_API void PLGui::Widget::SetUserData ( void *  pData)

Set user defined data.

Parameters:
[in]pDataUser data

Reimplemented in PLGui::TabBarEntry.

PLGUI_API bool PLGui::Widget::IsManaged ( ) const

Get whether or not the widget is managed.

Returns:
'true' if the widget is managed, else 'false'

Get title.

Returns:
Widget title
PLGUI_API void PLGui::Widget::SetTitle ( const PLCore::String sTitle)

Set title.

Parameters:
[in]sTitleWidget title
PLGUI_API const Image& PLGui::Widget::GetIcon ( ) const

Get icon.

Returns:
Image of window icon

Reimplemented in PLGui::TabBarEntry.

PLGUI_API void PLGui::Widget::SetIcon ( const Image cIcon)

Set icon.

Parameters:
[in]cIconImage of window icon

Reimplemented in PLGui::TabBarEntry.

PLGUI_API const Cursor& PLGui::Widget::GetCursor ( ) const

Get cursor.

Returns:
Mouse cursor
PLGUI_API void PLGui::Widget::SetCursor ( const Cursor cCursor)

Set cursor.

Parameters:
[in]cCursorMouse cursor
PLGUI_API Widget* PLGui::Widget::GetParent ( ) const

Get parent widget.

Returns:
Parent widget, can be a null pointer
PLGUI_API Widget* PLGui::Widget::GetCommonParent ( const Widget cWidget) const

Get common parent of this and another widget.

Parameters:
[in]cWidgetThe other widget
Returns:
The first widget that is parent of both widgets, or a null pointer if there is none

Get top level widget that is parent of this widget.

Returns:
The top level parent widget, can be this widget
virtual PLGUI_API Widget* PLGui::Widget::GetContentWidget ( ) const [virtual]

Get content widget.

Returns:
Content widget
Remarks:
If a widget is a container for other widgets, a content widget is often used as the parent for all of the child widgets. This is e.g. necessary to separate the "outside" from the "inside", e.g. there may be other (internal) child widgets, that are also children of the same parent (e.g. buttons in the title bar or frame widgets). So if you want to insert widgets inside other widgets, you should use the widget return by GetContentWidget() as the parent widget, not the widget itself. If a widget don't have a content widget, it will return a pointer to itself as the content widget.

Reimplemented in PLGui::Splitter, PLGui::WindowContainer, and PLGui::ContainerWidget.

PLGUI_API const PLCore::List<Widget*>& PLGui::Widget::GetChildren ( ) const

Get list of children.

Returns:
List of child widgets
PLGUI_API Widget* PLGui::Widget::GetFirstChild ( ) const

Get first child widget.

Returns:
Child widget, or a null pointer
PLGUI_API Widget* PLGui::Widget::GetLastChild ( ) const

Get last child widget.

Returns:
Child widget, or a null pointer

Get previous sibling widget.

Returns:
Sibling widget, or a null pointer
PLGUI_API Widget* PLGui::Widget::GetNextSibling ( ) const

Get next sibling widget.

Returns:
Sibling widget, or a null pointer
PLGUI_API bool PLGui::Widget::IsTopLevel ( ) const

Check if widget is a top level window.

Returns:
'true' if the widget is a top level window (has no other parent than the desktop)
PLGUI_API bool PLGui::Widget::IsShowInTaskbar ( ) const

Check if widget is visible in the taskbar.

Returns:
'true' if the widget is visible in the taskbar, else 'false'
Note:
  • If the system doesn't support a taskbar, the function will always return 'false'
PLGUI_API void PLGui::Widget::SetShowInTaskbar ( bool  bShowInTaskbar)

Set if widget is visible in the taskbar.

Parameters:
[in]bShowInTaskbar'true' if the widget is visible in the taskbar, else 'false'
See also:
PLGUI_API Screen* PLGui::Widget::GetScreen ( ) const

Get screen the widget is on.

Returns:
Pointer to the screen that contains this widget
PLGUI_API void PLGui::Widget::MoveToScreen ( Screen cScreen)

Move widget to another screen.

Parameters:
[in]cScreenScreen to which the widget shall be moved

Get widget position.

Returns:
Position (X, Y)
PLGUI_API void PLGui::Widget::SetPos ( const PLMath::Vector2i vPos)

Set widget position.

Parameters:
[in]vPosPosition (X, Y)

Get widget size.

Returns:
Size (width, height)
PLGUI_API void PLGui::Widget::SetSize ( const PLMath::Vector2i vSize)

Set widget size.

Parameters:
[in]vSizeSize (width, height)
PLGUI_API bool PLGui::Widget::GetTopmost ( ) const

Check if widget is topmost (always above all other widgets)

Returns:
'true' if the widget is topmost, else 'false'
PLGUI_API void PLGui::Widget::SetTopmost ( bool  bTopmost)

Set if widget is topmost (always above all other widgets)

Parameters:
[in]bTopmost'true' if the widget is topmost, else 'false'
Note:
  • Whenever possible, do not use topmost, this may backfire when you don't expect it

Get absolute widget position.

Returns:
Position (X, Y)
PLGUI_API PLMath::Vector2i PLGui::Widget::GetRelativePos ( Widget cWidget) const

Get position relative to another widget.

Parameters:
[in]cWidgetWidget to which the relative position shall be computed
Returns:
Position relative to the given widget (X, Y)
PLGUI_API void PLGui::Widget::Center ( ECenter  nCenter)

Center widget.

Parameters:
[in]nCenterHow to center the widget (see ECenter)
PLGUI_API void PLGui::Widget::CenterOnScreen ( Screen cScreen)

Center widget relative to the screen.

Parameters:
[in]cScreenScreen to which this widget is centered
PLGUI_API void PLGui::Widget::CenterOnWidget ( Widget cWidget)

Center widget relative to another widget.

Parameters:
[in]cWidgetWidget to which this widget is centered
PLGUI_API void PLGui::Widget::CalculatePreferredSize ( const PLMath::Vector2i vRefSize = PLMath::Vector2i(-1,-1))

Calculate preferred size.

Parameters:
[in]vRefSizePrecalculated reference size, can be (-1, -1) if no reference size is available
Remarks:
This causes the widget to calculate it's preferred size by calling the virtual function OnPreferredSize() and stores the result. To retrieve the preferred size of a widget, call GetPreferredSize().

Get preferred size.

Returns:
Preferred size
Remarks:
This return the preferred size of a widget. If the widget does not do it itself (which it should), you have to call CalculatePreferredSize(), in order to calculate the preferred size before retrieving it.
PLGUI_API void PLGui::Widget::FitSize ( )

Set size of widget to fit it's content.

Remarks:
This sets the widget's size to the preferred size (see CalculatePreferredSize())
PLGUI_API void PLGui::Widget::SetZPos ( EZPos  nZPos,
Widget pWidget = nullptr 
)

Set Z position.

Parameters:
[in]nZPosZ position (see EZPos)
[in]pWidgetOther widget used to align relative to (only matters for 'ZAbove' or 'ZBehind')

Get window state.

Returns:
Window state (see EWindowState)
PLGUI_API void PLGui::Widget::SetWindowState ( EWindowState  nWindowState)

Set window state.

Parameters:
[in]nWindowStateWindow state (see EWindowState)

Get background color.

Returns:
Background color
See also:
SetBackgroundColor()
PLGUI_API void PLGui::Widget::SetBackgroundColor ( const PLGraphics::Color4 cColor)

Set background color.

Parameters:
[in]cColorBackground color
Remarks:
The background color is used to automatically fill the background of the widget whenever the background is painted. If you don't want a background to be painted or if you paint it yourself (see OnDrawBackground), set this color to Color4::Transparent.
PLGUI_API void PLGui::Widget::SetTransparency ( ETransparency  nTransparency,
const PLGraphics::Color4 cColor 
)

Set transparency mode.

Parameters:
[in]nTransparencyTransparency mode (see ETransparency)
[in]cColorIf nMode is ColorKey, all pixels of the specified color will be transparent. If nMode is Alpha, only the alpha channel of the color will be used (1.0 = opaque, 0.0 = transparent)
PLGUI_API void PLGui::Widget::Close ( )

Close widget.

Remarks:
"Closing a widget" means sending it a message, that it shall close. This message is sent automatically if you press the 'X'-Button or e.g. with "ALT+F4" on Windows. The default behavior of widgets is: nothing. The default behavior of windows is: destroying the window. You can control the behavior by overriding OnClose() or hooking into SignalClose.
PLGUI_API bool PLGui::Widget::IsDestroyed ( ) const

Check if widget has been destroyed.

Returns:
'true' if the widget is destroyed, else 'false'
PLGUI_API void PLGui::Widget::Destroy ( )

Destroy widget.

PLGUI_API bool PLGui::Widget::IsVisible ( ) const

Check if widget is visible.

Returns:
'true' if the widget is visible, else 'false'
PLGUI_API void PLGui::Widget::SetVisible ( bool  bVisible)

Show or hide widget.

Parameters:
[in]bVisible'true' shows the widget, 'false' hides it
Note:
  • When a widget is created, it is invisible by default
PLGUI_API bool PLGui::Widget::IsEnabled ( ) const

Check if widget is enabled.

Returns:
'true' if the widget is enabled, else 'false'
PLGUI_API void PLGui::Widget::SetEnabled ( bool  bEnabled)

Enable or disable widget.

Parameters:
[in]bEnabled'true' if the widget is enabled, else 'false'

Get focus style.

Returns:
Focus style(s)
PLGUI_API void PLGui::Widget::SetFocusStyle ( EFocusStyle  nFocusStyle)

Set focus style.

Parameters:
[in]nFocusStyleFocus style(s)
Remarks:
The focus style determines how a widget is able to get the focus. If this is set to NoFocus (as by default), a widget will never get the focus. See EFocusStyle for other possible values.
PLGUI_API bool PLGui::Widget::CanAcceptFocus ( ) const

Check if widget can accept the focus.

Returns:
'true' if widget can get the focus, else 'false'
Remarks:
Returns 'true' if the focus style is set to AcceptFocus, ChildFocus or ChildFocusOrSelf and the widget is not disabled.
PLGUI_API bool PLGui::Widget::IsTabStop ( )

Get tab-stop.

Returns:
'true' if widget can get the focus by tabbing, else 'false'
PLGUI_API void PLGui::Widget::SetTabStop ( bool  bTabStop)

Set tab-stop.

Parameters:
[in]bTabStop'true' if widget can get the focus by tabbing, else 'false'
PLGUI_API bool PLGui::Widget::HasFocus ( ) const

Check if widget has the focus.

Returns:
'true' if this widget has the focus, else 'false'
PLGUI_API bool PLGui::Widget::SetFocus ( )

Set keyboard focus to the widget.

Returns:
'true' if keyboard focus is accepted by this widget or one of it's child widgets, else 'false'
Remarks:
This function should be called by a GUI backend in order to set the keyboard focus to this widget. The widget will then decide on base of it's parameter, if it accepts the keyboard focus, or if it delegates it to a child widget. It will then call SetFocus() from the backend, to finally set the focus. So don't call this function again when receiving the event caused by SetFocus(), otherwise it will end in an endless loop.
PLGUI_API bool PLGui::Widget::IsActive ( ) const

Check if widget is active (either the widget or one of it's children has the focus)

Returns:
'true' if this widget is active, else 'false'
PLGUI_API void PLGui::Widget::Activate ( )

Activate a widget (bring it to the top and set the focus to it)

PLGUI_API bool PLGui::Widget::NextTabStop ( bool  bForward)

Give keyboard focus to next tab-stop widget.

Parameters:
[in]bForward'true' to go forward, 'false' to go backwards
Returns:
'true' if a tab-stop widget could be found, else 'false'
PLGUI_API bool PLGui::Widget::IsMouseIn ( ) const

Check if the mouse is currently inside the widget.

Returns:
'true' if this widget is the mouse-over widget, else 'false'
PLGUI_API bool PLGui::Widget::IsMouseOver ( ) const

Check if the mouse is currently over either the widget or one of it's child widgets.

Returns:
'true' if mouse-over, else 'false'
PLGUI_API bool PLGui::Widget::GetMousePos ( PLMath::Vector2i vPos) const

Get current mouse cursor position inside the widget.

Parameters:
[out]vPosReceives the mouse cursor position if all went fine, on error, the given variable is not manipulated
Returns:
'true' if all went fine, else 'false' (maybe the mouse cursor is currently not over the widget?)
virtual PLGUI_API PLCore::uint32 PLGui::Widget::GetWidgetState ( ) const [virtual]

Get widget state.

Returns:
Widget states as flags (see EWidgetState)
Remarks:
This returns the current states of the widget together as a single flags-variable containing a combination of the values defined by EWidgetState. Not that this virtual function can be overwritten in derived classes to modify it's behavior according to the widget or add new states (e.g. WidgetPressed for buttons)
PLGUI_API void PLGui::Widget::Redraw ( )

Redraw widget.

PLGUI_API void PLGui::Widget::RedrawAll ( )

Redraw widget and all child widgets.

PLGUI_API bool PLGui::Widget::IsCaptureMouse ( ) const

Check if widget has captured mouse input.

Returns:
'true' if the mouse is captured by the widget, else 'false'
PLGUI_API void PLGui::Widget::SetCaptureMouse ( bool  bCapture)

Capture mouse input.

Parameters:
[in]bCapture'true' if the mouse should be captured by the widget, else 'false'
PLGUI_API void PLGui::Widget::SetTrapMouse ( bool  bTrap)

Trap mouse inside the widget.

Parameters:
[in]bTrap'true' if the mouse should be trapped inside the widget, else 'false'
PLGUI_API PLCore::uint32 PLGui::Widget::RegisterHotkey ( PLCore::uint32  nModKey,
PLCore::uint32  nKey 
)

Register a hotkey.

Parameters:
[in]nModKeyModification key (for example PLGUIMOD_ALT)
[in]nKeyKey (for example PLGUIKEY_RETURN)
Returns:
Hotkey ID, 0 on error
PLGUI_API void PLGui::Widget::UnregisterHotkey ( PLCore::uint32  nID)

Unregister a hotkey.

Parameters:
[in]nIDHotkey ID
PLGUI_API Theme* PLGui::Widget::GetTheme ( ) const

Get theme.

Returns:
Pointer to current theme
PLGUI_API void PLGui::Widget::SetTheme ( Theme pTheme)

Set theme.

Parameters:
[in]pThemeTheme
PLGUI_API const PLCore::List<Modifier*>& PLGui::Widget::GetModifiers ( ) const

Get modifiers.

Returns:
List of modifiers that belong to the widget
PLGUI_API Modifier* PLGui::Widget::GetModifier ( const PLCore::String sName) const

Get modifier.

Parameters:
[in]sNameName of modifier
Remarks:
Modifier, or a null pointer if no modifier with that name exists
PLGUI_API void PLGui::Widget::AddModifier ( Modifier pModifier)

Add modifier.

Parameters:
[in]pModifierPointer to the new modifier
Remarks:
The widget will take over the modifier and also destroy it later
PLGUI_API void PLGui::Widget::AddModifier ( const PLCore::String sName,
Modifier pModifier 
)

Add modifier.

Parameters:
[in]sNameName of modifier (can be empty)
[in]pModifierPointer to the new modifier
Remarks:
The widget will take over the modifier and also destroy it later. The name of the modifier is optional and can be left empty, if a name is provided, it must be unique. If a name is provided and there is already a modifier with the same name, the old modifier is destroyed and replaced by the new one.
PLGUI_API void PLGui::Widget::AddModifier ( const PLCore::String sClass,
const PLCore::String sOptions 
)

Add modifier.

Parameters:
[in]sClassName of the modifier class
[in]sOptionsOptions for the modifier
PLGUI_API void PLGui::Widget::AddModifier ( const PLCore::String sName,
const PLCore::String sClass,
const PLCore::String sOptions 
)

Add modifier.

Parameters:
[in]sNameName of modifier (can be empty)
[in]sClassName of the modifier class
[in]sOptionsOptions for the modifier
Remarks:
The name of the modifier is optional and can be left empty, if a name is provided, it must be unique. If a name is provided and there is already a modifier with the same name, the old modifier is destroyed and replaced by the new one.
PLGUI_API void PLGui::Widget::RemoveModifier ( Modifier pModifier)

Remove modifier.

Parameters:
[in]pModifierPointer to the modifier
Remarks:
The widget will remove and delete the modifier
PLGUI_API void PLGui::Widget::RemoveModifier ( const PLCore::String sName)

Remove modifier.

Parameters:
[in]sNameName of modifier
Remarks:
The widget will remove and delete the modifier
PLGUI_API Layout* PLGui::Widget::GetLayout ( ) const

Get layout.

Returns:
Layout
Remarks:
As a layout is just a modifier, this is equal to GetModifier("Layout")
PLGUI_API void PLGui::Widget::SetLayout ( Layout pLayout)

Set layout.

Parameters:
[in]pLayoutLayout
PLGUI_API void PLGui::Widget::SetLayout ( const PLCore::String sClass,
const PLCore::String sOptions 
)

Set layout.

Parameters:
[in]sClassLayout class
[in]sOptionsLayout options

Get layout hints.

Remarks:
For widgets that are positioned by a layout manager, additional hints can be set for the layout manager on how to layout the specific widget. These options include e.g. the minimum and maximum size, hints on when and how to resize the widget etc. Note that it depends on the layout manager, which (if any) of the layout hints it uses to modify the layout behavior.
PLGUI_API void PLGui::Widget::AdjustContent ( )

Adjust content of the widget.

PLGUI_API void PLGui::Widget::UpdateContent ( )

Update content.

Remarks:
This function has to be called by a widget whenever it has been changed in a way that could alter it's appearance or size. E.G. if the text of a label has been altered, it will most certainly change the size of the text label on the screen. To indicate this, the widget has to call UpdateContent() after such a change, so that the layout of the parent widget can be updated accordingly.
PLGUI_API void PLGui::Widget::AddChild ( Widget pWidget) [protected]

Add child widget.

Parameters:
[in]pWidgetWidget to add
PLGUI_API void PLGui::Widget::RemoveChild ( Widget pWidget) [protected]

Remove child widget.

Parameters:
[in]pWidgetWidget to remove
PLGUI_API bool PLGui::Widget::ActivateFirstTabStop ( ) [protected]

Give focus to first tab-stop widget (including this and all children)

Returns:
'true' if a tab-stop widget could be found, else 'false'
PLGUI_API bool PLGui::Widget::ActivateLastTabStop ( ) [protected]

Give focus to last tab-stop widget (including this and all children)

Returns:
'true' if a tab-stop widget could be found, else 'false'
PLGUI_API void PLGui::Widget::DrawBackground ( Graphics cGraphics) [protected]

Draw background.

Parameters:
[in]cGraphicsGraphics object used for painting
PLGUI_API void PLGui::Widget::Draw ( Graphics cGraphics) [protected]

Draw widget.

Parameters:
[in]cGraphicsGraphics object used for painting
virtual PLGUI_API void PLGui::Widget::OnMessage ( const GuiMessage cMessage) [override, protected, virtual]

Process GUI message.

Parameters:
[in]cMessageGUI message
Remarks:
Usually, you should not override this method, but rather use the virtual functions that are called after a specific message arrived (e.g. OnShow(), OnClose() etc.). If you decide to override this method, make sure to call the base implementation first, otherwise the messages will not be processed and no virtual functions or events will be called anymore.

Reimplemented from PLGui::WidgetFunctions.

virtual PLGUI_API PLMath::Vector2i PLGui::Widget::OnPreferredSize ( const PLMath::Vector2i vRefSize) const [override, protected, virtual]

Called when the widget is to calculate it's preferred size.

Parameters:
[in]vRefSizePrecalculated reference size, can be (-1, -1) if no reference size is available
Returns:
Preferred size
Remarks:
If the widget returns -1 in a component (X/Y), it means that there is no preferred size in that direction. A layout will in that case use 'as much space as possible', while the FitSize() functions will use the current size.

Reimplemented from PLGui::WidgetFunctions.

Reimplemented in PLGui::TabBar, PLGui::TabBarEntry, PLGui::AbstractMenu, PLGui::Splitter, PLGui::Border, PLGui::ScrollBar, PLGui::Slider, PLGui::Panel, PLGui::Button, PLGui::CheckBox, PLGui::MenuBar, PLGui::RadioButton, and PLGui::SlimEntry.

virtual PLGUI_API void PLGui::Widget::OnThemeChanged ( ) [override, protected, virtual]

Called when the theme has been changed.

Remarks:
This event is caused, when the widget gets a new theme. Use this to perform all tasks necessary to adjust to the new theme, e.g. resizing certain child widgets or redrawing the widget.

Reimplemented from PLGui::WidgetFunctions.

Reimplemented in PLGui::ContainerWidget.

virtual PLGUI_API void PLGui::Widget::OnUpdateContent ( ) [override, protected, virtual]

Called when the widget has been changed.

Remarks:
This event is caused, when the widget calls UpdateContent() to indicate that the widget has been changed in a way that could affect it's size or appearance. This is used to perform an AdjustContent() on the parent widget, whenever the size of a child widget could have been altered.

Reimplemented from PLGui::WidgetFunctions.

virtual PLGUI_API void PLGui::Widget::OnAdjustContent ( ) [override, protected, virtual]

Member Data Documentation

Gui* PLGui::Widget::m_pGui [protected]

Pointer to GUI instance

bool PLGui::Widget::m_bManaged [protected]

If a widget is managed, it will not be listed in the list of top level widgets and not be deleted automatically!

bool PLGui::Widget::m_bRootWidget [protected]

If 'true', the widget is a dummy object for the 'root' of a GUI implementation (no real widget at all!)

PLCore::uint32 PLGui::Widget::m_nID [protected]

Widget ID

Widget name

Pointer to parent widget

Widget implementation

Current theme

List of child widgets

List of modifiers

Map 'Name' -> 'Modifier'

Layout hints for the widget

Current window state

Position of the widget

Reimplemented in PLGui::Window.

Size of the widget

bool PLGui::Widget::m_bTopmost [protected]

Topmost flag

Widget title

Widget icon

Reimplemented in PLGui::TabBarEntry.

Mouse cursor

How does this widget accept the keyboard focus?

bool PLGui::Widget::m_bTabStop [protected]

Does the widget accept the focus by tabbing?

Is the mouse captured by the widget?

Background color of the widget

Preferred size of the widget

void* PLGui::Widget::m_pUserData [protected]

User defined data


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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:33
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported