KSD_EXPORT_CLASSclass TWidget
The base class for all widgets.
Inheritance:
Public Fields
-
Widget event signals
- Signals called to annouce specific widget events.
Public Methods
-
TWidget(TWidget* _parent)
- Create a widget with the parent passed.
-
Do-Event Functions
- Emits signal, and calls built handler.
-
TWidget* GetParent()
- Returns the parent of this widget
-
virtual std::string GetCaption() const = 0
- Returns the widget caption.
-
virtual int GetWidth() const = 0
- Returns the actual widget width, including all of its decorations.
-
virtual int GetHeight() const = 0
- Returns the actual widget height, including all of its decorations.
-
virtual TPoint2D GetPosition() const = 0
- Returns the position of this widget, relative to its parent
-
virtual void SetCaption(const std::string& _caption) = 0
- Assigns the widget caption.
-
void SetPosition(...)
- Sets the widgets position, relative to its parent.
-
bool IsInside(int X, int Y)
- Takes a global point, and returns true of that point is inside of the widget.
-
bool IsInsideLocal(int X, int Y)
- Takes a ``local" point, and returns true if that point is inside of the widget.
-
void MakeLocal(int& X, int& Y)
- Takes a global position and transforms it into a local position.
-
void MakeGlobal(int& X, int& Y)
- Takes a local position and transforms it into a global position.
-
virtual TPoint2D GetChildPosition(TWidget* child) const = 0
- Returns the actual child position relative to this widgets origin.
-
virtual void Resize(int w, int h) = 0
- Resizes the widget to the specified size
-
Public widget flag "sets"
- These are widget flags that should always be configurable.
-
Widget flags "gets"
- Return the state of any widget flag.
-
virtual TSurface* GetSurface() = 0
- Returns the surface that this widget outputs to.
-
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.
-
virtual bool IsClientWidget() const = 0
- Returns true if this widget draws to its parent's client surface as a opposed to its main surface.
-
Widget Attribute "Sets"
- Functions to set widget appearance attributes
-
Widget Attribute "Gets"
- Functions for getting widget appearance attributes.
-
void Show()
- Makes the widget visible
-
void Hide()
- Make the widget invisible.
-
void SetVisible(bool v)
- When true, show the widget; when false, hide the widget
-
bool IsVisible() const
- Returns true if widget is visible
-
void MoveUp()
- Moves the widget up one in the draw order
-
void MoveToFront()
- Move the widget to the front of the draw order
-
void SetEnabled(bool _enable)
- Enables or disables a widget.
-
void Enable()
- Enables the widget.
-
void Disable()
- Disables the widget/
-
bool IsEnabled() const
- Returns true if the widget is enabled, false otherwise.
-
void NeedsRepaint()
- Marks a widget for repaint.
-
void NeedsUpdate()
- Marks a widget for update.
-
void MarkAsChanged()
- Marks a widget as changed.
-
void MarkAllAsChanged()
- Works just like MarkAsChange except that it marks all the widget's children as well.
-
void ResetChanged()
- Marks the widget as un-changed.
-
bool GetChanged() const
- Returns the Changed flag.
-
virtual bool CanAcceptInput() const = 0
- Returns true if this widget will accept input
-
virtual bool CanAcceptMouseInput(int X, int Y) const = 0
- Returns true if this widget will accept mouse input
Protected Methods
-
bool GrabKeyboardFocus()
- Returns true if it got focus.
-
bool GrabJoystickFocus()
- Returns true if it got focus.
-
void ClearBuffer()
- Draws the widget background according to the parameters set, effectively clearing the buffer.
-
void RecreateAllBuffers()
- Recreates the buffer for this widget and all of its children using the function RecreateBuffer.
-
virtual bool Draw(TCanvas*, DrawType dt) = 0
- Draw the widget to the requested canvas.
-
virtual void Cycle() = 0
- Update the internal state of the widget.
-
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.
-
void SetAllowChildren(bool _ac)
- When set to true, this widget will not accept children.
-
void SetDrawOnDemand(bool _dod)
- When set to true, the widget will only draw when explicitly told to.
-
Built-in Event Functions
- Corresponding to events with names prepended by: On*
Protected Members
-
enum DrawType
- A flag describing what type of draw is requested
Documentation
The base class for all widgets.
- 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
- Widget event signals
- Signals called to annouce specific widget events.
- SigC::Signal1<void, TWidget*> OnEnter
- Called when the mouse enters this widget
- SigC::Signal1<void, TWidget*> OnExit
- Called when the mouse exits this widget
- SigC::Signal2<void, TWidget*, const TKey&> OnKeyDown
- Called when a key down event is given to this widget
- SigC::Signal2<void, TWidget*, const TKey&> OnKeyUp
- Called when a key up event is given to this widget
- SigC::Signal6<void, TWidget*, int, int, int, int, TMouseButton> OnMouseMove
- Called when the mouse is moved inside of this widget
- SigC::Signal4<void, TWidget*, int, int, TMouseButton> OnMouseDown
- Called when a mouse button is pressed inside of this widget
- SigC::Signal4<void, TWidget*, int, int, TMouseButton> OnMouseUp
- Called when a mouse button is released inside of this widget
- SigC::Signal4<void, TWidget*, Uint8, Uint8, Sint16> OnJoyAxisMove
- Called when this widget receives a joystick axis move event
- SigC::Signal5<void, TWidget*, Uint8, Uint8, Sint16, Sint16> OnJoyBallMove
- Called when this widget receives a jotstick ball move event
- SigC::Signal4<void, TWidget*, Uint8, Uint8, TJoyHatPosition> OnJoyHatMove
- Called when this widget receives a joytsick hat move event
- SigC::Signal3<void, TWidget*, Uint8, Uint8> OnJoyDown
- Called when this widget receives a joystick button press
- SigC::Signal3<void, TWidget*, Uint8, Uint8> OnJoyUp
- Called when this widget receives a joystick button release
- SigC::Signal3<bool, TWidget*, int, int> OnResize
- Called when this widget is resized
- SigC::Signal1<void, TWidget*> OnShow
- Called when this widget is shown (made visible)
- SigC::Signal1<void, TWidget*> OnHide
- Called when this widget is hidden (made invisible)
- Do-Event Functions
- Emits signal, and calls built handler.
- inline void DoEnter()
- inline void DoExit()
- inline void DoKeyDown(const TKey& key)
- inline void DoKeyUp(const TKey& key)
- inline void DoMouseMove(int X, int Y, int RelX, int RelY, TMouseButton button)
- inline void DoMouseDown(int X, int Y, TMouseButton button)
- inline void DoMouseUp(int X, int Y, TMouseButton button)
- inline void DoJoyAxisMove(Uint8 joy, Uint8 axis, Sint16 value)
- inline void DoJoyBallMove(Uint8 joy, Uint8 ball, Sint16 X, Sint16 Y)
- inline void DoJoyHatMove(Uint8 joy, Uint8 hat, TJoyHatPosition pos)
- inline void DoJoyDown(Uint8 joy, Uint8 button)
- inline void DoJoyUp(Uint8 joy, Uint8 button)
- TWidget* GetParent()
- Returns the parent of this widget
- virtual 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.
- virtual int GetWidth() const = 0
- Returns the actual widget width, including all of its decorations.
- See Also:
- GetClientWidth
- virtual int GetHeight() const = 0
- Returns the actual widget height, including all of its decorations.
- See Also:
- GetClientHeight
- virtual TPoint2D GetPosition() const = 0
- Returns the position of this widget, relative to its parent
- virtual 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.
- void SetPosition(...)
- Sets the widgets position, relative to its parent.
- virtual void SetPosition(int X, int Y) = 0
- Set using two integers
- virtual void SetPosition(const TPoint2D& p)
- Set using a TPoint2D object
- 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
- 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
- void MakeLocal(int& X, int& Y)
- Takes a global position and transforms it into a local position.
- See Also:
- Widget Positions
- void MakeGlobal(int& X, int& Y)
- Takes a local position and transforms it into a global position.
- See Also:
- Widget Positions
- virtual 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.
- virtual void Resize(int w, int h) = 0
- Resizes the widget to the specified size
- Public widget flag "sets"
- These are widget flags that should always be configurable.
- See Also:
- Widget Flags
- void 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
- void 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
- void 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
- void 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
- void 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
- void 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
- void 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
- void 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
- Widget flags "gets"
- Return the state of any widget flag.
- bool GetAllowChildren() const
- Returns the value set by SetAllowChildren
- bool GetUseParentBackground() const
- Returns the value set by SetUseParentBackground
- bool GetDrawBackgroundColor() const
- Returns the value set by SetDrawBackgroundColor
- bool GetDrawBackgroundImage() const
- Returns the value set by SetDrawBackgroundImage
- bool GetStretchBackground() const
- Returns the value set by SetStretchBackground
- bool GetTileBackground() const
- Returns the value set by SetTileBackground
- bool GetUseParentColor() const
- Returns the value set by SetUseParentColor
- bool GetUseParentFont() const
- Returns the value set by SetUseParentFont
- bool GetKeyPreview() const
- Returns the value set by SetKeyPreview
- bool GetDrawOnDemand() const
- Returns the value set by SetDrawOnDemand
- virtual TSurface* GetSurface() = 0
- Returns the surface that this widget outputs to. All widgets must return
their valid main surface.
- 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. A unique client surface is
not required, and the main surface can be used for both.
- virtual 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.
- Widget Attribute "Sets"
- Functions to set widget appearance attributes
- void 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
- void 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
- void SetBackgroundColor(const TColor& _c)
- Sets the background color. Used to fill the background of the widget.
- See Also:
- SetDrawBackgroundColor, SetAutoClearBuffer
\textbf{default: black}
- void SetBackgroundImage(TImage* img)
- Sets the background image. Used to fill the background of the widget.
- See Also:
- SetDrawBackgroundImage, SetStretchBackground, SetTileBackground, SetAutoClearBuffer
- Widget Attribute "Gets"
- Functions for getting widget appearance attributes.
- TColor GetColor() const
- Returns the widget color
- TFont* GetFont() const
- Resturns the widget font
- TColor GetBackgroundColor() const
- Returns the widget background color
- TImage* GetBackgroundImage() const
- Returns the widget image
- void Show()
- Makes the widget visible
- void Hide()
- Make the widget invisible. Only widgets with parent's can use.
- void SetVisible(bool v)
- When true, show the widget; when false, hide the widget
- bool IsVisible() const
- Returns true if widget is visible
- void MoveUp()
- Moves the widget up one in the draw order
- void MoveToFront()
- Move the widget to the front of the draw order
- void 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.
- void Enable()
- Enables the widget.
- See Also:
- SetEnabled
- void Disable()
- Disables the widget/
- See Also:
- SetEnabled
- bool IsEnabled() const
- Returns true if the widget is enabled, false otherwise.
- See Also:
- SetEnabled
- void 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
- void NeedsUpdate()
- Marks a widget for update. On the next draw cycle, the widgets
draw function will be called with REPAINT.
- See Also:
- Draw, DrawType
- void 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.)
- void MarkAllAsChanged()
- Works just like MarkAsChange except that it marks all the widget's
children as well.
- See Also:
- MarkAsChanged
- void ResetChanged()
- Marks the widget as un-changed.
- See Also:
- MarkAsChanged, MarkAllAsChanged
- bool GetChanged() const
- Returns the Changed flag.
- See Also:
- NeedsRepaint
- virtual bool CanAcceptInput() const = 0
- Returns true if this widget will accept input
- virtual bool CanAcceptMouseInput(int X, int Y) const = 0
- Returns true if this widget will accept mouse input
- bool GrabKeyboardFocus()
- Returns true if it got focus. For use by children.
- bool GrabJoystickFocus()
- Returns true if it got focus. For use by children.
- enum DrawType
- A flag describing what type of draw is requested
- 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.
- REPAINT
- "Re-draw" the entire widget
- void 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
- void 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.
- virtual 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
- virtual 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
- 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.
- virtual void RecreateBuffer() = 0
- Asks the widget to recreate its buffer(s). This is necessary for when
the video mode changes.
- virtual 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.
- virtual void UpdateWidget() = 0
- Copies the widget to its parent, if necessary. Call RequiresUpdate() in
order to check if this is necessary.
- virtual bool RequiresUpdate() const = 0
- Returns true if this widget must be updated after draw
- void 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
- void 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
- Built-in Event Functions
-
Override in child class to provided custom behaviors for a custom
widget type.
- virtual void Enter()
- virtual void Exit()
- virtual void KeyDown(const TKey& key)
- virtual void KeyUp(const TKey& key)
- virtual void MouseMove(int X, int Y, int RelX, int RelY, TMouseButton button)
- virtual void MouseDown(int X, int Y, TMouseButton button)
- virtual void MouseUp(int X, int Y, TMouseButton button)
- virtual void JoyAxisMove(Uint8 joy, Uint8 axis, Sint16 value)
- virtual void JoyBallMove(Uint8 joy, Uint8 ball, Sint16 X, Sint16 Y)
- virtual void JoyHatMove(Uint8 joy, Uint8 hat, TJoyHatPosition pos)
- virtual void JoyDown(Uint8 joy, Uint8 button)
- virtual void JoyUp(Uint8 joy, Uint8 button)
- virtual void VisibilityEvent(bool _visible)
- virtual 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++.