KSD_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] Do-Event Functions
Emits signal, and calls built handler.
[more]TWidget* GetParent()
Returns the parent of this widget
[more]virtual std::string GetCaption() const = 0
Returns the widget caption.
[more]virtual int GetWidth() const = 0
Returns the actual widget width, including all of its decorations.
[more]virtual int GetHeight() const = 0
Returns the actual widget height, including all of its decorations.
[more]virtual TPoint2D GetPosition() const = 0
Returns the position of this widget, relative to its parent
[more]virtual void SetCaption(const std::string& _caption) = 0
Assigns the widget caption.
[more] void SetPosition(...)
Sets the widgets position, relative to its parent.
[more]bool IsInside(int X, int Y)
Takes a global point, and returns true of that point is inside of the widget.
[more]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]virtual TPoint2D GetChildPosition(TWidget* child) const = 0
Returns the actual child position relative to this widgets origin.
[more]virtual void Resize(int w, int h) = 0
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]virtual TSurface* GetSurface() = 0
Returns the surface that this widget outputs to.
[more]virtual TSurface* GetClientSurface() = 0
The client surface that is used for the widget client area, or where the children of this widget draw to by default.
[more]virtual bool IsClientWidget() const = 0
Returns true if this widget draws to its parent's client surface as a opposed to its main surface.
[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 MoveUp()
Moves the widget up one in the draw order
[more]void MoveToFront()
Move the widget to the front of the draw order
[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.
[more]virtual bool CanAcceptInput() const = 0
Returns true if this widget will accept input
[more]virtual bool CanAcceptMouseInput(int X, int Y) const = 0
Returns true if this widget will accept mouse input

Protected Methods

[more]bool GrabKeyboardFocus()
Returns true if it got focus.
[more]bool GrabJoystickFocus()
Returns true if it got focus.
[more]void ClearBuffer()
Draws the widget background according to the parameters set, effectively clearing the buffer.
[more]void RecreateAllBuffers()
Recreates the buffer for this widget and all of its children using the function RecreateBuffer.
[more]virtual bool Draw(TCanvas*, DrawType dt) = 0
Draw the widget to the requested canvas.
[more]virtual void Cycle() = 0
Update the internal state of the widget.
[more] Widget Implementation Functions
These functions define some basic behaviors for this particular widget implementation. They are meant to be defined for a whole class of widgets and not redefined for each individual end widget.
[more]void SetAllowChildren(bool _ac)
When set to true, this widget will not accept children.
[more]void SetDrawOnDemand(bool _dod)
When set to true, the widget will only draw when explicitly told to.
[more] Built-in Event Functions
Corresponding to events with names prepended by: On*

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

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)

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)

oTWidget* GetParent()
Returns the parent of this widget

ovirtual std::string GetCaption() const = 0
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 = 0
Returns the actual widget width, including all of its decorations.
See Also:
GetClientWidth

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

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

ovirtual void SetCaption(const std::string& _caption) = 0
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) = 0
Set using two integers

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

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

obool 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

ovirtual TPoint2D GetChildPosition(TWidget* child) const = 0
Returns the actual child position relative to this widgets origin. This is necessary when the widget uses a seperate client surface because the child widget may actually get drawn offset from the position it has stored. When overriding this function, you can assume that it is only called with valid children of this widget.

ovirtual void Resize(int w, int h) = 0
Resizes the widget to the specified size

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 GetAllowChildren() const
Returns the value set by SetAllowChildren

obool GetUseParentBackground() const
Returns the value set by SetUseParentBackground

obool GetDrawBackgroundColor() const
Returns the value set by SetDrawBackgroundColor

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 GetKeyPreview() const
Returns the value set by SetKeyPreview

obool GetDrawOnDemand() const
Returns the value set by SetDrawOnDemand

ovirtual TSurface* GetSurface() = 0
Returns the surface that this widget outputs to. All widgets must return their valid main surface.

ovirtual TSurface* GetClientSurface() = 0
The client surface that is used for the widget client area, or where the children of this widget draw to by default. A unique client surface is not required, and the main surface can be used for both.

ovirtual bool IsClientWidget() const = 0
Returns true if this widget draws to its parent's client surface as a opposed to its main surface. This value must be returned honestly or a few widget operations will not work properly.

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 MoveUp()
Moves the widget up one in the draw order

ovoid MoveToFront()
Move the widget to the front of the draw order

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

ovirtual bool CanAcceptInput() const = 0
Returns true if this widget will accept input

ovirtual bool CanAcceptMouseInput(int X, int Y) const = 0
Returns true if this widget will accept mouse input

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

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

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

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:
SetBackgroundColor, SetBackgroundImage, SetUseBackgroundColor, SetUseBackgroundImage, SetStretchBackground, SetTileBackground

ovoid RecreateAllBuffers()
Recreates the buffer for this widget and all of its children using the function RecreateBuffer. This can be used when this widget needs to create a different kind of surface for its buffer. This kind of thing is common when you change the video backend.

ovirtual bool Draw(TCanvas*, DrawType dt) = 0
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() = 0
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

o Widget Implementation Functions
These functions define some basic behaviors for this particular widget implementation. They are meant to be defined for a whole class of widgets and not redefined for each individual end widget.

ovirtual void RecreateBuffer() = 0
Asks the widget to recreate its buffer(s). This is necessary for when the video mode changes.

ovirtual bool DrawWidget(DrawType mode) = 0
Called upon by DrawWidgetTree to handle actual widget drawing for each individual widget. Should call the widgets Draw function. This is meant to define an overall policy for a \textsl{type} of widget, while leaving Draw to be implemented only be the ultimate child class.

ovirtual void UpdateWidget() = 0
Copies the widget to its parent, if necessary. Call RequiresUpdate() in order to check if this is necessary.

ovirtual bool RequiresUpdate() const = 0
Returns true if this widget must be updated after draw

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 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

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)


Direct child classes:
TCustomWidget
TApplication
Friends:
class TApplication
class TWidgetTree
See Also:
Widgets

Alphabetic index HTML hierarchy of classes or Java



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