EXPORT_CLASSclass TWidget

The base class for all widgets.

Inheritance:


Public Fields

[more] Widget event signals
Signals called to annouce specific widget events.

Public Methods

[more] TWidget(TWidget* _parent)
Create a widget with the parent passed.
[more]virtual ~TWidget()
[more]TWidget* GetParent()
Returns the parent of this widget
[more]virtual std::string GetCaption() const
Returns the widget caption.
[more]virtual int GetWidth() const
Returns the actual widget width, including all of its decorations.
[more]virtual int GetHeight() const
Returns the actual widget height, including all of its decorations.
[more]int GetClientWidth() const
Returns the width of the widgets client area.
[more]int GetClientHeight() const
Returns the height of the widgets client area.
[more]virtual TPoint2D GetPosition() const
Returns the position of this widget, relative to its parent
[more]virtual void SetCaption(const std::string& _caption)
Assigns the widget caption.
[more] void SetPosition(...)
Sets the widgets position, relative to its parent.
[more]virtual bool IsInside(int X, int Y)
Takes a global point, and returns true of that point is inside of the widget.
[more]virtual bool IsInsideLocal(int X, int Y)
Takes a ``local" point, and returns true if that point is inside of the widget.
[more]void MakeLocal(int& X, int& Y)
Takes a global position and transforms it into a local position.
[more]void MakeGlobal(int& X, int& Y)
Takes a local position and transforms it into a global position.
[more]void Resize(int w, int h)
Resizes the widget to the specified size.
[more] Public widget flag "sets"
These are widget flags that should always be configurable.
[more] Widget flags "gets"
Return the state of any widget flag.
[more]inline TSurface* GetSurface()
Returns the surface that this widget outputs to.
[more] Widget Attribute "Sets"
Functions to set widget appearance attributes
[more] Widget Attribute "Gets"
Functions for getting widget appearance attributes.
[more]void Show()
Makes the widget visible
[more]void Hide()
Make the widget invisible.
[more]void SetVisible(bool v)
When true, show the widget; when false, hide the widget
[more]bool IsVisible() const
Returns true if widget is visible
[more]void SetEnabled(bool _enable)
Enables or disables a widget.
[more]void Enable()
Enables the widget.
[more]void Disable()
Disables the widget/
[more]bool IsEnabled() const
Returns true if the widget is enabled, false otherwise.
[more]void NeedsRepaint()
Marks a widget for repaint.
[more]void NeedsUpdate()
Marks a widget for update.
[more]void MarkAsChanged()
Marks a widget as changed.
[more]void MarkAllAsChanged()
Works just like MarkAsChange except that it marks all the widget's children as well.
[more]void ResetChanged()
Marks the widget as un-changed.
[more]bool GetChanged() const
Returns the Changed flag.

Protected Methods

[more]bool GrabKeyboardFocus()
Returns true if it got focus.
[more]bool GrabJoystickFocus()
Returns true if it got focus.
[more]inline void Scroll(Uint16 ScrollX, Uint16 ScrollY)
Used by children to "scroll" the client area.
[more]virtual bool Draw(TCanvas*, DrawType dt)
Draw the widget to the requested canvas.
[more]virtual void Cycle()
Update the internal state of the widget.
[more]virtual void DoResize(int Width, int Height)
Perform the actual resize.
[more]void ClearBuffer()
Draws the widget background according to the parameters set, effectively clearing the buffer.
[more]virtual TSurface* GetParentSurface()
Returns the parent surface.
[more]virtual TRect GetClientRect() const
Returns the client rect.
[more]void SetAutoClearBuffer(bool _acb)
When set to true, the buffer will automatically be cleared on each UPDATE, DRAW, or REPAINT.
[more]void SetDrawOnDemand(bool _dod)
When set to true, the widget will only draw when explicitly told to.
[more]void SetTransparentBackground(bool _tb)
When set to true, the widget background will be transparent.
[more]void SetAcceptInput(bool _ai)
When set to false, this widget and its children will be passed over when input is being passed down the widget tree.
[more]void SetAllowChildren(bool _ac)
When set to true, this widget will not accept children.
[more]void SetHollowClientArea(bool _hca)
When set to true, causes the widget client area to act like a "hole" through the widget.
[more]void SetDoubleBuffered(bool _db)
When set to true, the widget will draw to a software back-buffer before drawing the buffer to the screen.
[more]void SetEmbedInParent(bool _eip)
When set to true, this widget will be drawn on the main widget Surface instead of to the ClientSurface.
[more]void SetAutoSaveBuffer(bool _asb)
When set to true along with DoubleBuffered, this widget will automatically re-draw the buffer when repainted, but not changed.
[more]void SetAutoResetChanged(bool _arc)
When set to true, the Changed flag will be reset after every draw loop.
[more]void SetHasClientArea(bool _hca)
When set to true, the widget is composed of a decoration area and a client area.
[more]void SetParentDirect(bool _pd)
When set to true, this widgets surface is the parent surface.
[more] Built-in Event Functions
Corresponding to events with names prepended by: On*
[more] Do-Event Functions
Emits signal, and calls built handler.

Protected Members

[more]enum DrawType
A flag describing what type of draw is requested


Documentation

The base class for all widgets.
o TWidget(TWidget* _parent)
Create a widget with the parent passed. A widgets parent is the widget that it resides on. Parent-less widgets CAN exist. But here's the confusing part: the really distinction is not the presense of a parent widget but of a parent surface.

See Also:
GetParentSurface

ovirtual ~TWidget()

o Widget event signals
Signals called to annouce specific widget events.

oSigC::Signal1<void, TWidget*> OnEnter
Called when the mouse enters this widget

oSigC::Signal1<void, TWidget*> OnExit
Called when the mouse exits this widget

oSigC::Signal2<void, TWidget*, const TKey&> OnKeyDown
Called when a key down event is given to this widget

oSigC::Signal2<void, TWidget*, const TKey&> OnKeyUp
Called when a key up event is given to this widget

oSigC::Signal6<void, TWidget*, int, int, int, int, TMouseButton> OnMouseMove
Called when the mouse is moved inside of this widget

oSigC::Signal4<void, TWidget*, int, int, TMouseButton> OnMouseDown
Called when a mouse button is pressed inside of this widget

oSigC::Signal4<void, TWidget*, int, int, TMouseButton> OnMouseUp
Called when a mouse button is released inside of this widget

oSigC::Signal4<void, TWidget*, Uint8, Uint8, Sint16> OnJoyAxisMove
Called when this widget receives a joystick axis move event

oSigC::Signal5<void, TWidget*, Uint8, Uint8, Sint16, Sint16> OnJoyBallMove
Called when this widget receives a jotstick ball move event

oSigC::Signal4<void, TWidget*, Uint8, Uint8, TJoyHatPosition> OnJoyHatMove
Called when this widget receives a joytsick hat move event

oSigC::Signal3<void, TWidget*, Uint8, Uint8> OnJoyDown
Called when this widget receives a joystick button press

oSigC::Signal3<void, TWidget*, Uint8, Uint8> OnJoyUp
Called when this widget receives a joystick button release

oSigC::Signal3<bool, TWidget*, int, int> OnResize
Called when this widget is resized

oSigC::Signal1<void, TWidget*> OnShow
Called when this widget is shown (made visible)

oSigC::Signal1<void, TWidget*> OnHide
Called when this widget is hidden (made invisible)

oTWidget* GetParent()
Returns the parent of this widget

ovirtual std::string GetCaption() const
Returns the widget caption. A widget caption is used to apply a label to the widget. How this label is actually used is up to the widget author.

ovirtual int GetWidth() const
Returns the actual widget width, including all of its decorations.
See Also:
GetClientWidth

ovirtual int GetHeight() const
Returns the actual widget height, including all of its decorations.
See Also:
GetClientHeight

oint GetClientWidth() const
Returns the width of the widgets client area.
See Also:
Client Area

oint GetClientHeight() const
Returns the height of the widgets client area.
See Also:
Client Area

ovirtual TPoint2D GetPosition() const
Returns the position of this widget, relative to its parent

ovirtual void SetCaption(const std::string& _caption)
Assigns the widget caption. A widget caption is used to apply a label to the widget. How this label is actually used is up to the widget author.

o void SetPosition(...)
Sets the widgets position, relative to its parent.

ovirtual void SetPosition(int X, int Y)
Set using two integers

ovirtual void SetPosition(const TPoint2D& p)
Set using a TPoint2D object

ovirtual bool IsInside(int X, int Y)
Takes a global point, and returns true of that point is inside of the widget.
See Also:
Widget Positions

ovirtual bool IsInsideLocal(int X, int Y)
Takes a ``local" point, and returns true if that point is inside of the widget. IsInsideLocal has somewhat cyptic behavior. Its checks the point relative to the widget direct parent NOT a true local point like the name might suggest.
See Also:
Widget Positions

ovoid MakeLocal(int& X, int& Y)
Takes a global position and transforms it into a local position.
See Also:
Widget Positions

ovoid MakeGlobal(int& X, int& Y)
Takes a local position and transforms it into a global position.
See Also:
Widget Positions

ovoid Resize(int w, int h)
Resizes the widget to the specified size. Enacted immediately!!

o Public widget flag "sets"
These are widget flags that should always be configurable.
See Also:
Widget Flags

ovoid SetUseParentBackground(bool _upb)
When set to true this widget will use its parent's background parameters instead of its custom settings. A widgets background parameters include: background color, background image, stretch background, and tile background.

Default: true (except for TApplication)

See Also:
Inheriting Parent Attributes

ovoid SetDrawBackgroundColor(bool _dbc)
When set to true, the color set by SetBackgroundColor is used to clear the buffer. The buffer is cleared on Repaint, when ClearBuffer is called or on Update if AutoClearBuffer is set to true.

Default: true

See Also:
GetDrawBackgroundColor, SetAutoClearBuffer, GetAutoClearBuffer

ovoid SetDrawBackgroundImage(bool _dbi)
When set to true, the image set by SetBackgroundImage is used to clear the buffer. The buffer is cleared on Repaint, when ClearBuffer is called or on Update if AutoClearBuffer is set to true. The way the image is drawn (tiled or stretched) is controlled by the functions SetStretchBackground and SetTileBackground. If SetDrawBackgroundColor is set to true, the the background color is drawn first.

Default: false

See Also:
GetDrawBackgroundImage

ovoid SetStretchBackground(bool _sb)
When set to true and a background image is used, it will stretch the image to fill the widget background. Incompatable with SetTileBackground.

Default: false

See Also:
GetStretchBackground, SetDrawBackgroundImage

ovoid SetTileBackground(bool _tb)
When set to true and a background image is used, it will tile the image to fill the widget background. Incompatable with SetStretchBackground.

Default: false

See Also:
GetTileBackground, SetDrawBackgroundImage

ovoid SetUseParentColor(bool _upc)
When set to true, this widget will inherit the color of its parent. Otherwise it will use the color set by SetColor.

Default: true

See Also:
Inheriting Parent Attributes

ovoid SetUseParentFont(bool _upf)
When set to true, this widget will inherit the font of its parent. Otherwise it will use the font set by SetFont.

Default: true

See Also:
Inheriting Parent Attributes

ovoid SetKeyPreview(bool _kp)
When set to true, this widget will recieve he keyboard input of its children before it is set to them.

Default: false

See Also:
GetKeyPreview

o Widget flags "gets"
Return the state of any widget flag.

obool GetDoubleBuffered() const
Returns the value set by SetDoubleBuffered.

obool GetAutoClearBuffer() const
Returns the value set by SetDoubleBuffered

obool GetDrawOnDemand() const
Returns the value set by SetAutoClearBuffer

obool GetUseParentBackground() const
Returns the value set by SetDrawOnDemand

obool GetDrawBackgroundColor() const
Returns the value set by SetUseParentBackground

obool GetDrawBackgroundImage() const
Returns the value set by SetDrawBackgroundImage

obool GetStretchBackground() const
Returns the value set by SetStretchBackground

obool GetTileBackground() const
Returns the value set by SetTileBackground

obool GetUseParentColor() const
Returns the value set by SetUseParentColor

obool GetUseParentFont() const
Returns the value set by SetUseParentFont

obool GetAcceptInput() const
Returns the value set by SetAcceptInput

obool GetTransparentBackground() const
Returns the value set by SetTransparentBackground

obool GetAllowChildren() const
Returns the value set by SetAllowChildren

obool GetKeyPreview() const
Returns the value set by SetKeyPreview

obool GetEmbedInParent() const
Returns the value set by SetEmbedInParent

obool GetHollowClientArea() const
Returns the value set by SetHollowClientArea

obool GetAutoSaveBuffer() const
Returns the value set by SetAutoSaveBuffer

obool GetAutoResetChanged() const
Returns the value set by SetAutoResetChanged

obool GetHasClientArea() const
Returns the value set by SetHasClientArea

obool GetParentDirect() const
Returns the value set by SetParentDirect

oinline TSurface* GetSurface()
Returns the surface that this widget outputs to.

o Widget Attribute "Sets"
Functions to set widget appearance attributes

ovoid SetColor(const TColor& _c)
Sets the widget color. What the widget color is actually used for is up to the widget writter. Its use is not mandatory. But calling SetColor, you implicitly set UseParentColor to false.

default: black

ovoid SetFont(TFont* _f)
Sets the widget color. What the widget color is actually used for is up to the widget writter. Its use is not mandatory. But calling SetFont, you implicitly set UseParentFont to false

ovoid SetBackgroundColor(const TColor& _c)
Sets the background color. Used to fill the background of the widget.
See Also:
SetDrawBackgroundColor, SetAutoClearBuffer \textbf{default: black}

ovoid SetBackgroundImage(TImage* img)
Sets the background image. Used to fill the background of the widget.
See Also:
SetDrawBackgroundImage, SetStretchBackground, SetTileBackground, SetAutoClearBuffer

o Widget Attribute "Gets"
Functions for getting widget appearance attributes.

oTColor GetColor() const
Returns the widget color

oTFont* GetFont() const
Resturns the widget font

oTColor GetBackgroundColor() const
Returns the widget background color

oTImage* GetBackgroundImage() const
Returns the widget image

ovoid Show()
Makes the widget visible

ovoid Hide()
Make the widget invisible. Only widgets with parent's can use.

ovoid SetVisible(bool v)
When true, show the widget; when false, hide the widget

obool IsVisible() const
Returns true if widget is visible

ovoid SetEnabled(bool _enable)
Enables or disables a widget. This usually means that the widget will be greyed out and won't receive input, but its actual interpretation is up to the widget writter.

ovoid Enable()
Enables the widget.
See Also:
SetEnabled

ovoid Disable()
Disables the widget/
See Also:
SetEnabled

obool IsEnabled() const
Returns true if the widget is enabled, false otherwise.
See Also:
SetEnabled

ovoid NeedsRepaint()
Marks a widget for repaint. On the next draw cycle, the widgets draw function will be called with REPAINT.

See Also:
Draw, DrawType, SetAutoClearBuffer

ovoid NeedsUpdate()
Marks a widget for update. On the next draw cycle, the widgets draw function will be called with REPAINT.
See Also:
Draw, DrawType

ovoid MarkAsChanged()
Marks a widget as changed. Changed is reset to false after each draw cycle is AutoResetChanged is true. How changed is actually used depends mostly on the widget writter. The only time that Changed is used as a standard part of widget is when AutoSaveBuffer is set to true. (NOTE: This function does not imply any draw flag. You must call either NeedsRepaint or NeedsUpdate to actually draw the changes.)

ovoid MarkAllAsChanged()
Works just like MarkAsChange except that it marks all the widget's children as well.

See Also:
MarkAsChanged

ovoid ResetChanged()
Marks the widget as un-changed.

See Also:
MarkAsChanged, MarkAllAsChanged

obool GetChanged() const
Returns the Changed flag.
See Also:
NeedsRepaint

obool GrabKeyboardFocus()
Returns true if it got focus. For use by children.

obool GrabJoystickFocus()
Returns true if it got focus. For use by children.

oinline void Scroll(Uint16 ScrollX, Uint16 ScrollY)
Used by children to "scroll" the client area. This causes all of the children widgets and anything else on the client surface (or in the client area) to move by (-ScrollX, -ScrollY). UI might use ScrollBars, etc. in the decoration area of the widget.

oenum DrawType
A flag describing what type of draw is requested

o UPDATE
Only update the appearance of the widget. This can be used to just update the parts of the widget that actively change. For example, drawing and undrawing a cursor to move it around the screen.

o REPAINT
"Re-draw" the entire widget

ovirtual bool Draw(TCanvas*, DrawType dt)
Draw the widget to the requested canvas. The type of draw required will be passed as the second argument. All widgets must implement this method. Returns true if anything has actually been drawn. If the widget has in fact drawn to the screen but returns false anyway, the part of the screen which was changed, may not be updated (depending on specific settings and the output target).

See Also:
DrawType

ovirtual void Cycle()
Update the internal state of the widget. In a "coupled" gameloop, Cycle is always called before Draw. All widgets must implement this method.

See Also:
Decoupled Game Loop

ovirtual void DoResize(int Width, int Height)
Perform the actual resize. While TWidget will automatically resize the surfaces used by the widget, it cannot update the widgets internal state. Override this method to handle a resize in the appropriate widget specific way. For example, TApplication requests a new screen resolution when resized

ovoid ClearBuffer()
Draws the widget background according to the parameters set, effectively clearing the buffer. Called on Repaint or on Update and Draw when AutoClearBuffer is set to true.

See Also:
SetAcutoClearBuffer, SetBackgroundColor, SetBackgroundImage, SetUseBackgroundColor, SetUseBackgroundImage, SetStretchBackground, SetTileBackground

ovirtual TSurface* GetParentSurface()
Returns the parent surface. Normally this returns the surface of the parent widget and NULL for widgets without parents. Override to have the widget paint to a different surface. This could be used to create gateways to other toolkits. For example, TApplication uses this to draw to the screen surface.

ovirtual TRect GetClientRect() const
Returns the client rect. A client rect is the area that the children of the control can reside. The area outside the client rect is for widget decorations, like borders or scrollbars. Children CANNOT draw outside of the client area and only that area is affected by Scroll. Override this method to create a mechanism for setting the client rect.

ovoid SetAutoClearBuffer(bool _acb)
When set to true, the buffer will automatically be cleared on each UPDATE, DRAW, or REPAINT.

Default: false

See Also:
ClearBuffer, GetAutoClearBuffer

ovoid SetDrawOnDemand(bool _dod)
When set to true, the widget will only draw when explicitly told to. In normal operation, the each widget is called with UPDATE on every draw cycle. With draw on demand this is not so.

Default: false

See Also:
GetDrawOnDemand

ovoid SetTransparentBackground(bool _tb)
When set to true, the widget background will be transparent. In most cases this means that the buffer is never cleared. But when it is double buffered is has to copy part of the parent surface to its buffer first. Combining double buffered and transparent background can be slow.

Default: false

See Also:
GetTransparentBackground

ovoid SetAcceptInput(bool _ai)
When set to false, this widget and its children will be passed over when input is being passed down the widget tree. When set to true, everything will operate as expected.

Default: true

See Also:
GetAcceptInput

ovoid SetAllowChildren(bool _ac)
When set to true, this widget will not accept children. When a widget tries to use a widget as its parent that doesn't allow it, will have its parent set to NULL.

Default: true

See Also:
GetAllowChildren

ovoid SetHollowClientArea(bool _hca)
When set to true, causes the widget client area to act like a "hole" through the widget. The widget will only recieve mouse events if they hit outside the client area.

Default: false

See Also:
GetHollowClientArea

ovoid SetDoubleBuffered(bool _db)
When set to true, the widget will draw to a software back-buffer before drawing the buffer to the screen. This can be used to create smoother animation, but will take more memory and can be slower.

Default: false

See Also:
SetAutoSaveBuffer, GetDoubleBuffered

ovoid SetEmbedInParent(bool _eip)
When set to true, this widget will be drawn on the main widget Surface instead of to the ClientSurface. This means that this widget will not scroll with the other children and can exist outside of the client area. This can allow widgets to be used to draw the widget decorations, which should allow higher reuse.

Default: false

See Also:
GetClientSurface, Scroll, GetClientRect

ovoid SetAutoSaveBuffer(bool _asb)
When set to true along with DoubleBuffered, this widget will automatically re-draw the buffer when repainted, but not changed. This should speed up certain operations.

Default: true

See Also:
SetDoubleBuffered, GetAutoSaveBuffer

ovoid SetAutoResetChanged(bool _arc)
When set to true, the Changed flag will be reset after every draw loop. Most of the time this is the desired behavior.

See Also:
MarkAsChanged, MarkAllAsChanged

ovoid SetHasClientArea(bool _hca)
When set to true, the widget is composed of a decoration area and a client area. The client area contains all normal widgets and can be scrolled. The decoration area is where the widget it self draws as well as widgets that are marked as EmbedInParent and ParentDirect.

ovoid SetParentDirect(bool _pd)
When set to true, this widgets surface is the parent surface. This type of operation is not frequently needed. It can be used to apply an effect to the parent widget.

o Built-in Event Functions
Override in child class to provided custom behaviors for a custom widget type.

ovirtual void Enter()

ovirtual void Exit()

ovirtual void KeyDown(const TKey& key)

ovirtual void KeyUp(const TKey& key)

ovirtual void MouseMove(int X, int Y, int RelX, int RelY, TMouseButton button)

ovirtual void MouseDown(int X, int Y, TMouseButton button)

ovirtual void MouseUp(int X, int Y, TMouseButton button)

ovirtual void JoyAxisMove(Uint8 joy, Uint8 axis, Sint16 value)

ovirtual void JoyBallMove(Uint8 joy, Uint8 ball, Sint16 X, Sint16 Y)

ovirtual void JoyHatMove(Uint8 joy, Uint8 hat, TJoyHatPosition pos)

ovirtual void JoyDown(Uint8 joy, Uint8 button)

ovirtual void JoyUp(Uint8 joy, Uint8 button)

ovirtual void VisibilityEvent(bool _visible)

ovirtual bool ResizeEvent(int w, int h)

o Do-Event Functions
Emits signal, and calls built handler.

oinline void DoEnter()

oinline void DoExit()

oinline void DoKeyDown(const TKey& key)

oinline void DoKeyUp(const TKey& key)

oinline void DoMouseMove(int X, int Y, int RelX, int RelY, TMouseButton button)

oinline void DoMouseDown(int X, int Y, TMouseButton button)

oinline void DoMouseUp(int X, int Y, TMouseButton button)

oinline void DoJoyAxisMove(Uint8 joy, Uint8 axis, Sint16 value)

oinline void DoJoyBallMove(Uint8 joy, Uint8 ball, Sint16 X, Sint16 Y)

oinline void DoJoyHatMove(Uint8 joy, Uint8 hat, TJoyHatPosition pos)

oinline void DoJoyDown(Uint8 joy, Uint8 button)

oinline void DoJoyUp(Uint8 joy, Uint8 button)


Direct child classes:
TApplication
Friends:
class TApplication
struct WidgetNode
See Also:
Widgets

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.