gcn::Widget Class Reference

#include <widget.hpp>

Inheritance diagram for gcn::Widget:

gcn::BasicContainer gcn::Button gcn::CheckBox gcn::Icon gcn::Label gcn::ListBox gcn::RadioButton gcn::Slider gcn::TextBox gcn::TextField List of all members.

Detailed Description

Abstract class for widgets of Guichan.

It contains basic functions every widget should have.

NOTE: Functions begining with underscore "_" should not be overloaded unless you know what you are doing

Author:
Olof Naessén

Per Larsson.

Since:
0.1.0

Definition at line 93 of file widget.hpp.

Public Member Functions

virtual FocusHandler_getFocusHandler ()
 Gets the focus handler used.
virtual const std::list< FocusListener * > & _getFocusListeners ()
 Gets the focus listeners of the widget.
virtual FocusHandler_getInternalFocusHandler ()
 Gets the internal focus handler used.
virtual const std::list< KeyListener * > & _getKeyListeners ()
 Gets the key listeners of the widget.
virtual const std::list< MouseListener * > & _getMouseListeners ()
 Gets the mouse listeners of the widget.
virtual void _setFocusHandler (FocusHandler *focusHandler)
 Sets the focus handler to be used.
virtual void _setParent (Widget *parent)
 Sets the parent of the widget.
void addActionListener (ActionListener *actionListener)
 Adds an action listener to the widget.
void addDeathListener (DeathListener *deathListener)
 Adds a death listener to the widget.
void addFocusListener (FocusListener *focusListener)
 Adds a focus listener to the widget.
void addKeyListener (KeyListener *keyListener)
 Adds a key listener to the widget.
void addMouseListener (MouseListener *mouseListener)
 Adds a mouse listener to the widget.
void addWidgetListener (WidgetListener *widgetListener)
 Adds a widget listener to the widget.
virtual void draw (Graphics *graphics)=0
 Draws the widget.
virtual void drawFrame (Graphics *graphics)
 Called when a widget is given a chance to draw a frame around itself.
virtual void focusNext ()
 Focuses the next widget in the widget.
virtual void focusPrevious ()
 Focuses the previous widget in the widget.
virtual void fontChanged ()
 Called when the font has changed.
virtual void getAbsolutePosition (int &x, int &y) const
 Gets the absolute position on the screen for the widget.
const std::string & getActionEventId () const
 Gets the action event identifier of the widget.
const ColorgetBackgroundColor () const
 Gets the background color.
const ColorgetBaseColor () const
 Gets the base color.
virtual Rectangle getChildrenArea ()
 Gets the area of the widget that the widget's children occupy.
const RectanglegetDimension () const
 Gets the dimension of the widget.
FontgetFont () const
 Gets the font set for the widget.
const ColorgetForegroundColor () const
 Gets the foreground color.
unsigned int getFrameSize () const
 Gets the size of the widget's frame.
int getHeight () const
 Gets the height of the widget.
const std::string & getId ()
 Gets the id of a widget.
virtual WidgetgetParent () const
 Gets the widget's parent container.
const ColorgetSelectionColor () const
 Gets the selection color.
virtual WidgetgetWidgetAt (int x, int y)
 Gets a widget from a certain position in the widget.
int getWidth () const
 Gets the width of the widget.
int getX () const
 Gets the x coordinate of the widget.
int getY () const
 Gets the y coordinate of the widget.
bool isEnabled () const
 Checks if the widget is enabled.
bool isFocusable () const
 Checks if a widget is focsable.
virtual bool isFocused () const
 Checks if the widget is focused.
virtual bool isModalFocused () const
 Checks if the widget or it's parent has modal focus.
virtual bool isModalMouseInputFocused () const
 Checks if the widget or it's parent has modal mouse input focus.
bool isTabInEnabled () const
 Checks if tab in is enabled.
bool isTabOutEnabled () const
 Checks if tab out is enabled.
bool isVisible () const
 Checks if the widget is visible.
virtual void logic ()
 Called for all widgets in the gui each time Gui::logic is called.
virtual void moveToBottom (Widget *widget)
 Moves a widget in this widget to the bottom of this widget.
virtual void moveToTop (Widget *widget)
 Moves a widget to the top of this widget.
virtual void releaseModalFocus ()
 Releases modal focus.
virtual void releaseModalMouseInputFocus ()
 Releases modal mouse input focus.
void removeActionListener (ActionListener *actionListener)
 Removes an added action listener from the widget.
void removeDeathListener (DeathListener *deathListener)
 Removes an added death listener from the widget.
void removeFocusListener (FocusListener *focusListener)
 Removes an added focus listener from the widget.
void removeKeyListener (KeyListener *keyListener)
 Removes an added key listener from the widget.
void removeMouseListener (MouseListener *mouseListener)
 Removes an added mouse listener from the widget.
void removeWidgetListener (WidgetListener *widgetListener)
 Removes an added widget listener from the widget.
virtual void requestFocus ()
 Requests focus for the widget.
virtual void requestModalFocus ()
 Requests modal focus.
virtual void requestModalMouseInputFocus ()
 Requests modal mouse input focus.
virtual void requestMoveToBottom ()
 Requests a move to the bottom in the parent widget.
virtual void requestMoveToTop ()
 Requests a move to the top in the parent widget.
void setActionEventId (const std::string &actionEventId)
 Sets the action event identifier of the widget.
void setBackgroundColor (const Color &color)
 Sets the background color.
void setBaseColor (const Color &color)
 Sets the base color of the widget.
void setDimension (const Rectangle &dimension)
 Sets the dimension of the widget.
void setEnabled (bool enabled)
 Sets the widget to enabled, or not.
void setFocusable (bool focusable)
 Sets the widget to be fosusable, or not.
void setFont (Font *font)
 Sets the font for the widget.
void setForegroundColor (const Color &color)
 Sets the foreground color.
void setFrameSize (unsigned int frameSize)
 Sets the size of the widget's frame.
void setHeight (int height)
 Sets the height of the widget.
void setId (const std::string &id)
 Sets an id of a widget.
void setInternalFocusHandler (FocusHandler *internalFocusHandler)
 Sets the internal focus handler.
void setPosition (int x, int y)
 Sets position of the widget.
void setSelectionColor (const Color &color)
 Sets the selection color.
void setSize (int width, int height)
 Sets the size of the widget.
void setTabInEnabled (bool enabled)
 Sets tab in enabled, or not.
void setTabOutEnabled (bool enabled)
 Sets tab out enabled.
void setVisible (bool visible)
 Sets the widget to be visible, or not.
void setWidth (int width)
 Sets the width of the widget.
void setX (int x)
 Sets the x coordinate of the widget.
void setY (int y)
 Sets the y coordinate of the widget.
virtual void showPart (Rectangle rectangle)
 Shows a certain part of a widget in the widget's parent.
virtual void showWidgetPart (Widget *widget, Rectangle area)
 Tries to show a specific part of a widget by moving it.
 Widget ()
 Constructor.
virtual ~Widget ()
 Default destructor.

Static Public Member Functions

static void setGlobalFont (Font *font)
 Sets the global font to be used by default for all widgets.
static bool widgetExists (const Widget *widget)
 Checks if a widget exists or not, that is if it still exists an instance of the object.

Protected Types

typedef ActionListenerList::iterator ActionListenerIterator
 Typdef.
typedef std::list< ActionListener * > ActionListenerList
 Typdef.
typedef DeathListenerList::iterator DeathListenerIterator
 Typdef.
typedef std::list< DeathListener * > DeathListenerList
 Typdef.
typedef FocusListenerList::iterator FocusListenerIterator
 Typdef.
typedef std::list< FocusListener * > FocusListenerList
 Typdef.
typedef KeyListenerList::iterator KeyListenerIterator
 Typdef.
typedef std::list< KeyListener * > KeyListenerList
 Typdef.
typedef MouseListenerList::iterator MouseListenerIterator
 Typdef.
typedef std::list< MouseListener * > MouseListenerList
 Typdef.
typedef WidgetListenerList::iterator WidgetListenerIterator
 Typdef.
typedef std::list< WidgetListener * > WidgetListenerList

Protected Member Functions

void distributeActionEvent ()
 Distributes an action event to all action listeners of the widget.
void distributeHiddenEvent ()
 Distributes hidden events to all of the widget's listeners.
void distributeMovedEvent ()
 Distributes moved events to all of the widget's listeners.
void distributeResizedEvent ()
 Distributes resized events to all of the widget's listeners.
void distributeShownEvent ()
 Distributes shown events to all of the widget's listeners.

Protected Attributes

std::string mActionEventId
 Holds the action event of the widget.
ActionListenerList mActionListeners
 Holds the action listeners of the widget.
Color mBackgroundColor
 Holds the background color of the widget.
Color mBaseColor
 Holds the base color of the widget.
FontmCurrentFont
 Holds the font used by the widget.
DeathListenerList mDeathListeners
 Holds the death listeners of the widget.
Rectangle mDimension
 Holds the dimension of the widget.
bool mEnabled
 True if the widget is enabled, false otherwise.
bool mFocusable
 True if the widget focusable, false otherwise.
FocusHandlermFocusHandler
 Holds the focus handler used by the widget.
FocusListenerList mFocusListeners
 Holds the focus listeners of the widget.
Color mForegroundColor
 Holds the foreground color of the widget.
unsigned int mFrameSize
 Holds the frame size of the widget.
std::string mId
 Holds the id of the widget.
FocusHandlermInternalFocusHandler
 Holds the focus handler used by the widget.
KeyListenerList mKeyListeners
 Holds the key listeners of the widget.
MouseListenerList mMouseListeners
 Holds the mouse listeners of the widget.
WidgetmParent
 Holds the parent of the widget.
Color mSelectionColor
 Holds the selection color of the widget.
bool mTabIn
 True if the widget has tab in enabled, false otherwise.
bool mTabOut
 True if the widget has tab in enabled, false otherwise.
bool mVisible
 True if the widget visible, false otherwise.
WidgetListenerList mWidgetListeners
 Holds the widget listeners of the widget.

Static Protected Attributes

static DefaultFont mDefaultFont
 Holds the default font used by the widget.
static FontmGlobalFont = NULL
 Holds the global font used by the widget.
static std::list< Widget * > mWidgets
 Holds a list of all instances of widgets.


Constructor & Destructor Documentation

gcn::Widget::Widget (  ) 

Constructor.

Resets member variables. Noteable, a widget is not focusable as default, therefore, widgets that are supposed to be focusable should overide this default in their own constructor.

Definition at line 84 of file widget.cpp.

References mWidgets.


Member Function Documentation

FocusHandler * gcn::Widget::_getFocusHandler (  )  [virtual]

Gets the focus handler used.

WARNING: This function is used internally and should not be called or overloaded unless you know what you are doing.

Returns:
The focus handler used.
See also:
_setFocusHandler
Since:
0.1.0

Definition at line 397 of file widget.cpp.

References mFocusHandler.

Referenced by gcn::BasicContainer::add(), and gcn::BasicContainer::setInternalFocusHandler().

const std::list< FocusListener * > & gcn::Widget::_getFocusListeners (  )  [virtual]

Gets the focus listeners of the widget.

Returns:
The focus listeners of the widget.
Since:
0.7.0

Definition at line 657 of file widget.cpp.

References mFocusListeners.

Referenced by gcn::FocusHandler::distributeFocusGainedEvent(), and gcn::FocusHandler::distributeFocusLostEvent().

FocusHandler * gcn::Widget::_getInternalFocusHandler (  )  [virtual]

Gets the internal focus handler used.

Returns:
the internalFocusHandler used. If no internal focus handler is used, NULL will be returned.
See also:
setInternalFocusHandler
Since:
0.1.0

Definition at line 667 of file widget.cpp.

References mInternalFocusHandler.

Referenced by gcn::Gui::getKeyEventSource().

const std::list< KeyListener * > & gcn::Widget::_getKeyListeners (  )  [virtual]

Gets the key listeners of the widget.

Returns:
The key listeners of the widget.
Since:
0.6.0

Definition at line 652 of file widget.cpp.

References mKeyListeners.

Referenced by gcn::Gui::distributeKeyEvent().

const std::list< MouseListener * > & gcn::Widget::_getMouseListeners (  )  [virtual]

Gets the mouse listeners of the widget.

Returns:
The mouse listeners of the widget.
Since:
0.6.0

Definition at line 647 of file widget.cpp.

References mMouseListeners.

void gcn::Widget::_setFocusHandler ( FocusHandler focusHandler  )  [virtual]

Sets the focus handler to be used.

WARNING: This function is used internally and should not be called or overloaded unless you know what you are doing.

Parameters:
focusHandler The focus handler to use.
See also:
_getFocusHandler
Since:
0.1.0

Reimplemented in gcn::BasicContainer.

Definition at line 381 of file widget.cpp.

References gcn::FocusHandler::add(), mFocusHandler, releaseModalFocus(), and gcn::FocusHandler::remove().

Referenced by gcn::BasicContainer::_setFocusHandler(), gcn::BasicContainer::add(), gcn::BasicContainer::remove(), gcn::Gui::setTop(), and ~Widget().

void gcn::Widget::_setParent ( Widget parent  )  [virtual]

Sets the parent of the widget.

A parent must be a BasicContainer.

WARNING: This function is used internally and should not be called or overloaded unless you know what you are doing.

Parameters:
parent The parent of the widget.
See also:
getParent
Since:
0.1.0

Definition at line 142 of file widget.cpp.

References mParent.

Referenced by gcn::BasicContainer::add(), and gcn::BasicContainer::remove().

void gcn::Widget::addActionListener ( ActionListener actionListener  ) 

Adds an action listener to the widget.

When an action event is fired by the widget the action listeners of the widget will get notified.

Parameters:
actionListener The action listener to add.
See also:
removeActionListener
Since:
0.1.0

Definition at line 402 of file widget.cpp.

References mActionListeners.

Referenced by gcn::TabbedArea::addTab(), and gcn::DropDown::DropDown().

void gcn::Widget::addDeathListener ( DeathListener deathListener  ) 

Adds a death listener to the widget.

When a death event is fired by the widget the death listeners of the widget will get notified.

Parameters:
deathListener The death listener to add.
See also:
removeDeathListener
Since:
0.1.0

Definition at line 412 of file widget.cpp.

References mDeathListeners.

Referenced by gcn::BasicContainer::add().

void gcn::Widget::addFocusListener ( FocusListener focusListener  ) 

Adds a focus listener to the widget.

When a focus event is fired by the widget the key listeners of the widget will get notified.

Parameters:
focusListener The focus listener to add.
See also:
removeFocusListener
Since:
0.7.0

Definition at line 432 of file widget.cpp.

References mFocusListeners.

Referenced by gcn::Button::Button(), and gcn::DropDown::DropDown().

void gcn::Widget::addKeyListener ( KeyListener keyListener  ) 

Adds a key listener to the widget.

When a key event is fired by the widget the key listeners of the widget will get notified.

Parameters:
keyListener The key listener to add.
See also:
removeKeyListener
Since:
0.1.0

Definition at line 422 of file widget.cpp.

References mKeyListeners.

Referenced by gcn::Button::Button(), gcn::CheckBox::CheckBox(), gcn::DropDown::DropDown(), gcn::ListBox::ListBox(), gcn::RadioButton::RadioButton(), gcn::Slider::Slider(), gcn::TabbedArea::TabbedArea(), gcn::TextBox::TextBox(), and gcn::TextField::TextField().

void gcn::Widget::addMouseListener ( MouseListener mouseListener  ) 

Adds a mouse listener to the widget.

When a mouse event is fired by the widget the mouse listeners of the widget will get notified.

Parameters:
mouseListener The mouse listener to add.
See also:
removeMouseListener
Since:
0.1.0

Definition at line 442 of file widget.cpp.

References mMouseListeners.

Referenced by gcn::Button::Button(), gcn::CheckBox::CheckBox(), gcn::DropDown::DropDown(), gcn::ListBox::ListBox(), gcn::RadioButton::RadioButton(), gcn::ScrollArea::ScrollArea(), gcn::Slider::Slider(), gcn::Tab::Tab(), gcn::TabbedArea::TabbedArea(), gcn::TextBox::TextBox(), gcn::TextField::TextField(), and gcn::Window::Window().

void gcn::Widget::addWidgetListener ( WidgetListener widgetListener  ) 

Adds a widget listener to the widget.

When a widget event is fired by the widget the key listeners of the widget will get notified.

Parameters:
widgetListener The widget listener to add.
See also:
removeWidgetListener
Since:
0.8.0

Definition at line 452 of file widget.cpp.

References mWidgetListeners.

void gcn::Widget::distributeActionEvent (  )  [protected]

Distributes an action event to all action listeners of the widget.

Since:
0.8.0

Definition at line 720 of file widget.cpp.

References mActionEventId, and mActionListeners.

Referenced by gcn::DropDown::action(), gcn::TextField::keyPressed(), gcn::Slider::keyPressed(), gcn::RadioButton::keyPressed(), gcn::ListBox::keyPressed(), gcn::Button::keyReleased(), gcn::RadioButton::mouseClicked(), gcn::Slider::mouseDragged(), gcn::Slider::mousePressed(), gcn::ListBox::mousePressed(), gcn::Button::mouseReleased(), gcn::Slider::mouseWheelMovedDown(), gcn::Slider::mouseWheelMovedUp(), and gcn::CheckBox::toggleSelected().

void gcn::Widget::distributeHiddenEvent (  )  [protected]

Distributes hidden events to all of the widget's listeners.

Since:
0.8.0
Author:
Olof Naessén

Definition at line 709 of file widget.cpp.

References mWidgetListeners.

Referenced by setVisible().

void gcn::Widget::distributeMovedEvent (  )  [protected]

Distributes moved events to all of the widget's listeners.

Since:
0.8.0

Definition at line 698 of file widget.cpp.

References mWidgetListeners.

Referenced by setDimension().

void gcn::Widget::distributeResizedEvent (  )  [protected]

Distributes resized events to all of the widget's listeners.

Since:
0.8.0

Definition at line 687 of file widget.cpp.

References mWidgetListeners.

Referenced by setDimension().

void gcn::Widget::distributeShownEvent (  )  [protected]

Distributes shown events to all of the widget's listeners.

Since:
0.8.0
Author:
Olof Naessén

Definition at line 730 of file widget.cpp.

References mWidgetListeners.

Referenced by setVisible().

virtual void gcn::Widget::draw ( Graphics graphics  )  [pure virtual]

Draws the widget.

It is called by the parent widget when it is time for the widget to draw itself. The graphics object is set up so that all drawing is relative to the widget, i.e coordinate (0,0) is the top left corner of the widget. It is not possible to draw outside of a widget's dimension.

Parameters:
graphics aA graphics object to draw with.
Since:
0.1.0

Implemented in gcn::Button, gcn::CheckBox, gcn::Container, gcn::DropDown, gcn::Icon, gcn::ImageButton, gcn::Label, gcn::ListBox, gcn::RadioButton, gcn::ScrollArea, gcn::Slider, gcn::Tab, gcn::TabbedArea, gcn::TextBox, gcn::TextField, and gcn::Window.

Referenced by gcn::Gui::draw().

void gcn::Widget::drawFrame ( Graphics graphics  )  [virtual]

Called when a widget is given a chance to draw a frame around itself.

The frame is not considered a part of the widget, it only allows a frame to be drawn around the widget, thus a frame will never be included when calculating if a widget should receive events from user input. Also a widget's frame will never be included when calculating a widget's position.

The size of the frame is calculated using the widget's frame size. If a widget has a frame size of 10 pixels than the area the drawFrame function can draw to will be the size of the widget with an additional extension of 10 pixels in each direction.

An example when drawFrame is a useful function is if a widget needs a glow around itself.

Parameters:
graphics A graphics object to draw with.
See also:
setFrameSize, getFrameSize
Since:
0.8.0

Definition at line 118 of file widget.cpp.

References gcn::Color::a, gcn::Graphics::drawLine(), getBaseColor(), getFrameSize(), getHeight(), getWidth(), and gcn::Graphics::setColor().

Referenced by gcn::Gui::draw().

virtual void gcn::Widget::focusNext (  )  [inline, virtual]

Focuses the next widget in the widget.

See also:
moveToBottom
Since:
0.1.0

Reimplemented in gcn::BasicContainer.

Definition at line 907 of file widget.hpp.

virtual void gcn::Widget::focusPrevious (  )  [inline, virtual]

Focuses the previous widget in the widget.

See also:
moveToBottom
Since:
0.1.0

Reimplemented in gcn::BasicContainer.

Definition at line 915 of file widget.hpp.

virtual void gcn::Widget::fontChanged (  )  [inline, virtual]

Called when the font has changed.

If the change is global, this function will only be called if the widget doesn't have a font already set.

Since:
0.1.0

Reimplemented in gcn::TextBox, and gcn::TextField.

Definition at line 694 of file widget.hpp.

Referenced by setFont().

void gcn::Widget::getAbsolutePosition ( int &  x,
int &  y 
) const [virtual]

Gets the absolute position on the screen for the widget.

Parameters:
x The absolute x coordinate will be stored in this parameter.
y The absolute y coordinate will be stored in this parameter.
Since:
0.1.0

Definition at line 462 of file widget.cpp.

References getAbsolutePosition(), getChildrenArea(), getParent(), mDimension, gcn::Rectangle::x, and gcn::Rectangle::y.

Referenced by gcn::Gui::distributeMouseEvent(), getAbsolutePosition(), gcn::Gui::getWidgetAt(), gcn::Gui::handleMouseMoved(), gcn::Gui::handleMousePressed(), gcn::Gui::handleMouseReleased(), gcn::Gui::handleMouseWheelMovedDown(), and gcn::Gui::handleMouseWheelMovedUp().

const std::string & gcn::Widget::getActionEventId (  )  const

Gets the action event identifier of the widget.

Returns:
The action event identifier of the widget.
See also:
setActionEventId
Since:
0.6.0

Definition at line 246 of file widget.cpp.

References mActionEventId.

const Color & gcn::Widget::getBackgroundColor (  )  const

Gets the background color.

See also:
setBackgroundColor
Since:
0.1.0

Definition at line 366 of file widget.cpp.

References mBackgroundColor.

Referenced by gcn::TextField::draw(), gcn::TextBox::draw(), gcn::ListBox::draw(), gcn::DropDown::draw(), gcn::ScrollArea::drawBackground(), gcn::RadioButton::drawBox(), and gcn::CheckBox::drawBox().

const Color & gcn::Widget::getBaseColor (  )  const

Gets the base color.

Returns:
The base color.
See also:
setBaseColor
Since:
0.1.0

Definition at line 346 of file widget.cpp.

References mBaseColor.

Referenced by gcn::Window::draw(), gcn::TextField::draw(), gcn::TabbedArea::draw(), gcn::Tab::draw(), gcn::Slider::draw(), gcn::ScrollArea::draw(), gcn::ImageButton::draw(), gcn::DropDown::draw(), gcn::Container::draw(), gcn::Button::draw(), gcn::RadioButton::drawBox(), gcn::CheckBox::drawBox(), gcn::DropDown::drawButton(), gcn::ScrollArea::drawDownButton(), drawFrame(), gcn::ScrollArea::drawHBar(), gcn::ScrollArea::drawHMarker(), gcn::ScrollArea::drawLeftButton(), gcn::Slider::drawMarker(), gcn::ScrollArea::drawRightButton(), gcn::ScrollArea::drawUpButton(), gcn::ScrollArea::drawVBar(), and gcn::ScrollArea::drawVMarker().

Rectangle gcn::Widget::getChildrenArea (  )  [virtual]

Gets the area of the widget that the widget's children occupy.

Returns:
The area of the widget that the widget's children occupy.
Since:
0.1.0

Reimplemented in gcn::BasicContainer, gcn::DropDown, gcn::ScrollArea, and gcn::Window.

Definition at line 662 of file widget.cpp.

Referenced by gcn::DropDown::adjustHeight(), getAbsolutePosition(), and gcn::TextBox::keyPressed().

const Rectangle & gcn::Widget::getDimension (  )  const

Gets the dimension of the widget.

The dimension is relative to the widget's parent.

Returns:
The dimension of the widget.
See also:
getDimension, setX, getX, setY, getY, setPosition
Since:
0.1.0

Definition at line 241 of file widget.cpp.

References mDimension.

Referenced by gcn::ImageButton::draw(), gcn::Gui::draw(), gcn::Button::draw(), and gcn::Gui::handleMouseMoved().

Font * gcn::Widget::getFont (  )  const

Gets the font set for the widget.

If no font has been set, the global font will be returned. If no global font has been set, the default font will be returend.

Returns:
The font set for the widget.
See also:
setFont, setGlobalFont
Since:
0.1.0

Definition at line 480 of file widget.cpp.

References mCurrentFont, mDefaultFont, and mGlobalFont.

Referenced by gcn::TextField::adjustHeight(), gcn::DropDown::adjustHeight(), gcn::TextField::adjustSize(), gcn::TextBox::adjustSize(), gcn::RadioButton::adjustSize(), gcn::ListBox::adjustSize(), gcn::Label::adjustSize(), gcn::CheckBox::adjustSize(), gcn::Button::adjustSize(), gcn::Window::draw(), gcn::TextField::draw(), gcn::TextBox::draw(), gcn::RadioButton::draw(), gcn::ListBox::draw(), gcn::Label::draw(), gcn::DropDown::draw(), gcn::CheckBox::draw(), gcn::Button::draw(), gcn::TextBox::drawCaret(), gcn::TextField::fixScroll(), gcn::TextBox::keyPressed(), gcn::Label::Label(), gcn::TextField::mousePressed(), gcn::TextBox::mousePressed(), gcn::ListBox::mousePressed(), gcn::TextBox::scrollToCaret(), and gcn::ListBox::setSelected().

const Color & gcn::Widget::getForegroundColor (  )  const

Gets the foreground color.

See also:
setForegroundColor
Since:
0.1.0

Definition at line 356 of file widget.cpp.

References mForegroundColor.

Referenced by gcn::Window::draw(), gcn::TextField::draw(), gcn::TextBox::draw(), gcn::RadioButton::draw(), gcn::ListBox::draw(), gcn::Label::draw(), gcn::ImageButton::draw(), gcn::DropDown::draw(), gcn::CheckBox::draw(), gcn::Button::draw(), gcn::RadioButton::drawBox(), gcn::CheckBox::drawBox(), gcn::DropDown::drawButton(), gcn::TextField::drawCaret(), gcn::TextBox::drawCaret(), gcn::ScrollArea::drawDownButton(), gcn::ScrollArea::drawLeftButton(), gcn::Slider::drawMarker(), gcn::ScrollArea::drawRightButton(), and gcn::ScrollArea::drawUpButton().

unsigned int gcn::Widget::getFrameSize (  )  const

Gets the size of the widget's frame.

The frame is not considered a part of the widget, it only allows a frame to be drawn around the widget, thus a frame will never be included when calculating if a widget should receive events from user input. Also a widget's frame will never be included when calculating a widget's position.

A frame size of 0 means that the widget has no frame. The default frame size is 0.

Returns:
The size of the widget's frame.
See also:
setFrameSize, drawFrame
Since:
0.8.0

Definition at line 236 of file widget.cpp.

References mFrameSize.

Referenced by gcn::Window::draw(), gcn::Gui::draw(), drawFrame(), gcn::ScrollArea::getHorizontalMaxScroll(), gcn::ScrollArea::getVerticalMaxScroll(), gcn::ScrollArea::logic(), and gcn::ScrollArea::showWidgetPart().

int gcn::Widget::getHeight (  )  const

Gets the height of the widget.

Returns:
The height of the widget.
See also:
setHeight, setWidth, getWidth, setSize, setDimension, getDimension
Since:
0.1.0

Definition at line 173 of file widget.cpp.

References gcn::Rectangle::height, and mDimension.

Referenced by gcn::TextField::adjustHeight(), gcn::DropDown::adjustHeight(), gcn::TextBox::adjustSize(), gcn::TabbedArea::adjustSize(), gcn::Tab::adjustSize(), gcn::ListBox::adjustSize(), gcn::Label::adjustSize(), gcn::Button::adjustSize(), gcn::ScrollArea::checkPolicies(), gcn::Window::draw(), gcn::TextField::draw(), gcn::TextBox::draw(), gcn::TabbedArea::draw(), gcn::Tab::draw(), gcn::Slider::draw(), gcn::ScrollArea::draw(), gcn::RadioButton::draw(), gcn::ListBox::draw(), gcn::Label::draw(), gcn::ImageButton::draw(), gcn::Icon::draw(), gcn::DropDown::draw(), gcn::Container::draw(), gcn::CheckBox::draw(), gcn::Button::draw(), gcn::RadioButton::drawBox(), gcn::CheckBox::drawBox(), gcn::TextBox::drawCaret(), drawFrame(), gcn::Slider::drawMarker(), gcn::DropDown::dropDown(), gcn::Window::getChildrenArea(), gcn::ScrollArea::getChildrenArea(), gcn::DropDown::getChildrenArea(), gcn::BasicContainer::getChildrenArea(), gcn::ScrollArea::getDownButtonDimension(), gcn::ScrollArea::getHorizontalBarDimension(), gcn::ScrollArea::getLeftButtonDimension(), gcn::ScrollArea::getRightButtonDimension(), gcn::ScrollArea::getVerticalBarDimension(), gcn::ScrollArea::getVerticalMarkerDimension(), gcn::ScrollArea::getVerticalMaxScroll(), gcn::Label::Label(), gcn::Slider::markerPositionToValue(), gcn::Slider::mouseDragged(), gcn::Slider::mousePressed(), gcn::DropDown::mousePressed(), gcn::DropDown::mouseReleased(), and gcn::Slider::valueToMarkerPosition().

const std::string & gcn::Widget::getId (  ) 

Gets the id of a widget.

An id can be useful if a widget needs to be identified in a container. For example, if widgets are created by an XML document, a certain widget can be retrieved given that the widget has an id.

Parameters:
id The id to set to the widget.
See also:
setId, BasicContainer::findWidgetById
Since:
0.8.0

Definition at line 682 of file widget.cpp.

References mId.

Widget * gcn::Widget::getParent (  )  const [virtual]

Gets the widget's parent container.

Returns:
The widget's parent container. NULL if the widget has no parent.
Since:
0.1.0

Definition at line 147 of file widget.cpp.

References mParent.

Referenced by gcn::DropDown::adjustHeight(), gcn::Gui::distributeKeyEvent(), gcn::Gui::distributeMouseEvent(), gcn::DropDown::dropDown(), getAbsolutePosition(), gcn::Gui::handleModalFocusReleased(), gcn::Gui::handleMouseMoved(), isModalFocused(), isModalMouseInputFocused(), isVisible(), gcn::TextBox::keyPressed(), and gcn::Window::mousePressed().

const Color & gcn::Widget::getSelectionColor (  )  const

Gets the selection color.

Returns:
The selection color.
See also:
setSelectionColor
Since:
0.6.0

Definition at line 376 of file widget.cpp.

References mSelectionColor.

Referenced by gcn::ListBox::draw(), and gcn::DropDown::draw().

Widget * gcn::Widget::getWidgetAt ( int  x,
int  y 
) [virtual]

Gets a widget from a certain position in the widget.

This function is used to decide which gets mouse input, thus it can be overloaded to change that behaviour.

NOTE: This always returns NULL if the widget is not a container.

Parameters:
x The x coordinate of the widget to get.
y The y coordinate of the widget to get.
Returns:
The widget at the specified coodinate, NULL if no widget is found.
Since:
0.6.0

Reimplemented in gcn::BasicContainer, and gcn::ScrollArea.

Definition at line 642 of file widget.cpp.

Referenced by gcn::Gui::getWidgetAt().

int gcn::Widget::getWidth (  )  const

Gets the width of the widget.

Returns:
The width of the widget.
See also:
setWidth, setHeight, getHeight, setSize, setDimension, getDimension
Since:
0.1.0

Definition at line 160 of file widget.cpp.

References mDimension, and gcn::Rectangle::width.

Referenced by gcn::DropDown::adjustHeight(), gcn::TextField::adjustSize(), gcn::TabbedArea::adjustSize(), gcn::RadioButton::adjustSize(), gcn::Label::adjustSize(), gcn::CheckBox::adjustSize(), gcn::Button::adjustSize(), gcn::ScrollArea::checkPolicies(), gcn::Window::draw(), gcn::TextField::draw(), gcn::TextBox::draw(), gcn::TabbedArea::draw(), gcn::Tab::draw(), gcn::Slider::draw(), gcn::ScrollArea::draw(), gcn::RadioButton::draw(), gcn::ListBox::draw(), gcn::Label::draw(), gcn::ImageButton::draw(), gcn::Icon::draw(), gcn::DropDown::draw(), gcn::Container::draw(), gcn::Button::draw(), drawFrame(), gcn::Slider::drawMarker(), gcn::TextField::fixScroll(), gcn::Window::getChildrenArea(), gcn::ScrollArea::getChildrenArea(), gcn::DropDown::getChildrenArea(), gcn::BasicContainer::getChildrenArea(), gcn::ScrollArea::getDownButtonDimension(), gcn::ScrollArea::getHorizontalBarDimension(), gcn::ScrollArea::getHorizontalMarkerDimension(), gcn::ScrollArea::getHorizontalMaxScroll(), gcn::ScrollArea::getRightButtonDimension(), gcn::ScrollArea::getUpButtonDimension(), gcn::ScrollArea::getVerticalBarDimension(), gcn::Label::Label(), gcn::Slider::markerPositionToValue(), gcn::Slider::mousePressed(), gcn::DropDown::mousePressed(), gcn::DropDown::mouseReleased(), and gcn::Slider::valueToMarkerPosition().

int gcn::Widget::getX (  )  const

Gets the x coordinate of the widget.

The coordinate is relative to the widget's parent.

Returns:
The x coordinate of the widget.
See also:
setX, setY, getY, setPosition, setDimension, getDimension
Since:
0.1.0

Definition at line 186 of file widget.cpp.

References mDimension, and gcn::Rectangle::x.

Referenced by gcn::TabbedArea::draw(), gcn::Window::mouseDragged(), gcn::ScrollArea::showWidgetPart(), and gcn::BasicContainer::showWidgetPart().

int gcn::Widget::getY (  )  const

Gets the y coordinate of the widget.

The coordinate is relative to the widget's parent.

Returns:
The y coordinate of the widget.
See also:
setY, setX, getX, setPosition, setDimension, getDimension
Since:
0.1.0

Definition at line 199 of file widget.cpp.

References mDimension, and gcn::Rectangle::y.

Referenced by gcn::DropDown::adjustHeight(), gcn::Window::mouseDragged(), gcn::ScrollArea::showWidgetPart(), and gcn::BasicContainer::showWidgetPart().

bool gcn::Widget::isEnabled (  )  const

Checks if the widget is enabled.

A disabled widget will never recieve mouse or key events.

Returns:
True if widget is enabled, false otherwise.
See also:
setEnabled
Since:
0.1.0

Definition at line 565 of file widget.cpp.

References isVisible(), and mEnabled.

Referenced by isFocusable().

bool gcn::Widget::isFocusable (  )  const

Checks if a widget is focsable.

Returns:
True if the widget should be focusable, false otherwise.
See also:
setFocusable
Since:
0.1.0

Definition at line 276 of file widget.cpp.

References isEnabled(), isVisible(), and mFocusable.

Referenced by gcn::Gui::handleKeyInput(), gcn::TabbedArea::mousePressed(), and requestFocus().

bool gcn::Widget::isFocused (  )  const [virtual]

Checks if the widget is focused.

Returns:
True if the widget is focused, false otherwise.
Since:
0.1.0

Definition at line 256 of file widget.cpp.

References gcn::FocusHandler::isFocused(), and mFocusHandler.

Referenced by gcn::TextField::draw(), gcn::TextBox::draw(), gcn::Tab::draw(), gcn::RadioButton::draw(), gcn::ImageButton::draw(), gcn::DropDown::draw(), gcn::Button::draw(), gcn::CheckBox::drawBox(), gcn::Slider::drawMarker(), gcn::TextField::fixScroll(), gcn::TabbedArea::keyPressed(), gcn::ListBox::mouseWheelMovedDown(), gcn::DropDown::mouseWheelMovedDown(), gcn::ListBox::mouseWheelMovedUp(), gcn::DropDown::mouseWheelMovedUp(), setFocusable(), and setVisible().

bool gcn::Widget::isModalFocused (  )  const [virtual]

Checks if the widget or it's parent has modal focus.

Returns:
True if the widget has modal focus, false otherwise.
See also:
requestModalFocus, releaseModalFocus
Since:
0.8.0

Definition at line 610 of file widget.cpp.

References gcn::FocusHandler::getModalFocused(), getParent(), isModalFocused(), and mFocusHandler.

Referenced by gcn::Gui::distributeKeyEvent(), gcn::Gui::distributeMouseEvent(), gcn::Gui::handleMousePressed(), isModalFocused(), and gcn::FocusHandler::requestModalFocus().

bool gcn::Widget::isModalMouseInputFocused (  )  const [virtual]

Checks if the widget or it's parent has modal mouse input focus.

Returns:
True if the widget has modal mouse input focus, false otherwise.
See also:
requestModalMouseInputFocus, releaseModalMouseInputFocus
Since:
0.8.0

Definition at line 626 of file widget.cpp.

References gcn::FocusHandler::getModalMouseInputFocused(), getParent(), isModalMouseInputFocused(), and mFocusHandler.

Referenced by gcn::Gui::distributeKeyEvent(), gcn::Gui::distributeMouseEvent(), gcn::Gui::getMouseEventSource(), isModalMouseInputFocused(), and gcn::DropDown::mouseReleased().

bool gcn::Widget::isTabInEnabled (  )  const

Checks if tab in is enabled.

Tab in means that you can set focus to this widget by pressing the tab button. If tab in is disabled then the focus handler will skip this widget and focus the next in its focus order.

Returns:
True if tab in is enabled, false otherwise.
See also:
setTabInEnabled
Since:
0.1.0

Definition at line 531 of file widget.cpp.

References mTabIn.

bool gcn::Widget::isTabOutEnabled (  )  const

Checks if tab out is enabled.

Tab out means that you can lose focus to this widget by pressing the tab button. If tab out is disabled then the FocusHandler ignores tabbing and focus will stay with this widget.

Returns:
True if tab out is enabled, false otherwise.
See also:
setTabOutEnabled
Since:
0.1.0

Definition at line 541 of file widget.cpp.

References mTabOut.

Referenced by gcn::FocusHandler::tabNext(), and gcn::FocusHandler::tabPrevious().

bool gcn::Widget::isVisible (  )  const

Checks if the widget is visible.

Returns:
True if widget is be visible, false otherwise.
See also:
setVisible
Since:
0.1.0

Definition at line 329 of file widget.cpp.

References getParent(), isVisible(), and mVisible.

Referenced by gcn::Gui::draw(), isEnabled(), isFocusable(), and isVisible().

virtual void gcn::Widget::logic (  )  [inline, virtual]

Called for all widgets in the gui each time Gui::logic is called.

You can do logic stuff here like playing an animation.

See also:
Gui::logic
Since:
0.1.0

Reimplemented in gcn::BasicContainer, gcn::ListBox, gcn::ScrollArea, and gcn::TabbedArea.

Definition at line 181 of file widget.hpp.

Referenced by gcn::ScrollArea::logic(), and gcn::Gui::logic().

virtual void gcn::Widget::moveToBottom ( Widget widget  )  [inline, virtual]

Moves a widget in this widget to the bottom of this widget.

The moved widget will be drawn below all other widgets in this widget.

Parameters:
widget The widget to move to the bottom.
See also:
moveToTop
Since:
0.1.0

Reimplemented in gcn::BasicContainer.

Definition at line 899 of file widget.hpp.

Referenced by requestMoveToBottom().

virtual void gcn::Widget::moveToTop ( Widget widget  )  [inline, virtual]

Moves a widget to the top of this widget.

The moved widget will be drawn above all other widgets in this widget.

Parameters:
widget The widget to move to the top.
See also:
moveToBottom
Since:
0.1.0

Reimplemented in gcn::BasicContainer.

Definition at line 889 of file widget.hpp.

Referenced by gcn::DropDown::dropDown(), gcn::Window::mousePressed(), and requestMoveToTop().

void gcn::Widget::releaseModalFocus (  )  [virtual]

Releases modal focus.

Modal focus will only be released if the widget has modal focus.

See also:
requestModalFocus, isModalFocused
Since:
0.4.0

Definition at line 590 of file widget.cpp.

References mFocusHandler, and gcn::FocusHandler::releaseModalFocus().

Referenced by _setFocusHandler().

void gcn::Widget::releaseModalMouseInputFocus (  )  [virtual]

Releases modal mouse input focus.

Modal mouse input focus will only be released if the widget has modal mouse input focus.

See also:
requestModalMouseInputFocus, isModalMouseInputFocused
Since:
0.6.0

Definition at line 600 of file widget.cpp.

References mFocusHandler, and gcn::FocusHandler::releaseModalMouseInputFocus().

Referenced by gcn::DropDown::action(), gcn::DropDown::mousePressed(), and gcn::DropDown::mouseReleased().

void gcn::Widget::removeActionListener ( ActionListener actionListener  ) 

Removes an added action listener from the widget.

Parameters:
actionListener The action listener to remove.
See also:
addActionListener
Since:
0.1.0

Definition at line 407 of file widget.cpp.

References mActionListeners.

Referenced by gcn::DropDown::~DropDown().

void gcn::Widget::removeDeathListener ( DeathListener deathListener  ) 

Removes an added death listener from the widget.

Parameters:
deathListener The death listener to remove.
See also:
addDeathListener
Since:
0.1.0

Definition at line 417 of file widget.cpp.

References mDeathListeners.

Referenced by gcn::BasicContainer::remove().

void gcn::Widget::removeFocusListener ( FocusListener focusListener  ) 

Removes an added focus listener from the widget.

Parameters:
focusListener The focus listener to remove.
See also:
addFocusListener
Since:
0.7.0

Definition at line 437 of file widget.cpp.

References mFocusListeners.

void gcn::Widget::removeKeyListener ( KeyListener keyListener  ) 

Removes an added key listener from the widget.

Parameters:
keyListener The key listener to remove.
See also:
addKeyListener
Since:
0.1.0

Definition at line 427 of file widget.cpp.

References mKeyListeners.

void gcn::Widget::removeMouseListener ( MouseListener mouseListener  ) 

Removes an added mouse listener from the widget.

Parameters:
mouseListener The mouse listener to remove.
See also:
addMouseListener
Since:
0.1.0

Definition at line 447 of file widget.cpp.

References mMouseListeners.

void gcn::Widget::removeWidgetListener ( WidgetListener widgetListener  ) 

Removes an added widget listener from the widget.

Parameters:
widgetListener The widget listener to remove.
See also:
addWidgetListener
Since:
0.8.0

Definition at line 457 of file widget.cpp.

References mWidgetListeners.

void gcn::Widget::requestFocus (  )  [virtual]

Requests focus for the widget.

A widget will only recieve focus if it is focusable.

Definition at line 281 of file widget.cpp.

References isFocusable(), mFocusHandler, and gcn::FocusHandler::requestFocus().

Referenced by gcn::DropDown::dropDown(), gcn::Gui::handleMousePressed(), and gcn::TabbedArea::mousePressed().

void gcn::Widget::requestModalFocus (  )  [virtual]

Requests modal focus.

When a widget has modal focus, only that widget and it's children may recieve input.

Exceptions:
Exception if another widget already has modal focus.
See also:
releaseModalFocus, isModalFocused
Since:
0.4.0

Definition at line 570 of file widget.cpp.

References mFocusHandler, and gcn::FocusHandler::requestModalFocus().

void gcn::Widget::requestModalMouseInputFocus (  )  [virtual]

Requests modal mouse input focus.

When a widget has modal input focus that widget will be the only widget receiving input even if the input occurs outside of the widget and no matter what the input is.

Exceptions:
Exception if another widget already has modal focus.
See also:
releaseModalMouseInputFocus, isModalMouseInputFocused
Since:
0.6.0

Definition at line 580 of file widget.cpp.

References mFocusHandler, and gcn::FocusHandler::requestModalMouseInputFocus().

Referenced by gcn::DropDown::mousePressed().

void gcn::Widget::setActionEventId ( const std::string &  actionEventId  ) 

Sets the action event identifier of the widget.

The identifier is used to be able to identify which action has occured.

NOTE: An action event identifier should not be used to identify a certain widget but rather a certain event in your application. Several widgets can have the same action event identifer.

Parameters:
actionEventId The action event identifier.
See also:
getActionEventId
Since:
0.6.0

Definition at line 251 of file widget.cpp.

References mActionEventId.

void gcn::Widget::setBackgroundColor ( const Color color  ) 

Sets the background color.

Parameters:
color The background Color.
See also:
setBackgroundColor
Since:
0.1.0

Reimplemented in gcn::DropDown.

Definition at line 361 of file widget.cpp.

References mBackgroundColor.

Referenced by gcn::DropDown::setBackgroundColor().

void gcn::Widget::setBaseColor ( const Color color  ) 

Sets the base color of the widget.

Parameters:
color The baseground color.
See also:
getBaseColor
Since:
0.1.0

Reimplemented in gcn::DropDown.

Definition at line 341 of file widget.cpp.

References mBaseColor.

Referenced by gcn::DropDown::setBaseColor().

void gcn::Widget::setDimension ( const Rectangle dimension  ) 

Sets the dimension of the widget.

The dimension is relative to the widget's parent.

Parameters:
dimension The dimension of the widget.
See also:
getDimension, setX, getX, setY, getY, setPosition
Since:
0.1.0

Reimplemented in gcn::ScrollArea, and gcn::TabbedArea.

Definition at line 213 of file widget.cpp.

References distributeMovedEvent(), distributeResizedEvent(), gcn::Rectangle::height, mDimension, gcn::Rectangle::width, gcn::Rectangle::x, and gcn::Rectangle::y.

Referenced by gcn::ScrollArea::setDimension(), setHeight(), setPosition(), setSize(), setWidth(), setX(), and setY().

void gcn::Widget::setEnabled ( bool  enabled  ) 

Sets the widget to enabled, or not.

A disabled widget will never recieve mouse or key events.

Parameters:
enabled True if widget should be enabled, false otherwise.
See also:
isEnabled
Since:
0.1.0

Definition at line 560 of file widget.cpp.

References mEnabled.

void gcn::Widget::setFocusable ( bool  focusable  ) 

Sets the widget to be fosusable, or not.

Parameters:
focusable True if the widget should be focusable, false otherwise.
See also:
isFocusable
Since:
0.1.0

Definition at line 266 of file widget.cpp.

References gcn::FocusHandler::focusNone(), isFocused(), mFocusable, and mFocusHandler.

Referenced by gcn::Button::Button(), gcn::CheckBox::CheckBox(), gcn::DropDown::DropDown(), gcn::ListBox::ListBox(), gcn::RadioButton::RadioButton(), gcn::Slider::Slider(), gcn::TabbedArea::TabbedArea(), gcn::TextBox::TextBox(), and gcn::TextField::TextField().

void gcn::Widget::setFont ( Font font  ) 

Sets the font for the widget.

If NULL is passed, the global font will be used.

Parameters:
font The font to set for the widget.
See also:
getFont
Since:
0.1.0

Reimplemented in gcn::DropDown.

Definition at line 509 of file widget.cpp.

References fontChanged(), and mCurrentFont.

Referenced by gcn::DropDown::setFont().

void gcn::Widget::setForegroundColor ( const Color color  ) 

Sets the foreground color.

Parameters:
color The foreground color.
See also:
getForegroundColor
Since:
0.1.0

Reimplemented in gcn::DropDown.

Definition at line 351 of file widget.cpp.

References mForegroundColor.

Referenced by gcn::DropDown::setForegroundColor().

void gcn::Widget::setFrameSize ( unsigned int  frameSize  ) 

Sets the size of the widget's frame.

The frame is not considered a part of the widget, it only allows a frame to be drawn around the widget, thus a frame will never be included when calculating if a widget should receive events from user input. Also a widget's frame will never be included when calculating a widget's position.

A frame size of 0 means that the widget has no frame. The default frame size is 0.

Parameters:
frameSize The size of the widget's frame.
See also:
getFrameSize, drawFrame
Since:
0.8.0

Definition at line 231 of file widget.cpp.

References mFrameSize.

Referenced by gcn::Button::Button(), gcn::Slider::Slider(), and gcn::Window::Window().

void gcn::Widget::setGlobalFont ( Font font  )  [static]

Sets the global font to be used by default for all widgets.

Parameters:
font The global font.
See also:
getGlobalFont
Since:
0.1.0

Definition at line 495 of file widget.cpp.

References mGlobalFont, and mWidgets.

void gcn::Widget::setHeight ( int  height  ) 

Sets the height of the widget.

Parameters:
height The height of the widget.
See also:
getHeight, setWidth, getWidth, setSize, setDimension, getDimension
Since:
0.1.0

Reimplemented in gcn::ScrollArea, and gcn::TabbedArea.

Definition at line 165 of file widget.cpp.

References gcn::Rectangle::height, mDimension, and setDimension().

Referenced by gcn::TextField::adjustHeight(), gcn::DropDown::adjustHeight(), gcn::TextBox::adjustSize(), gcn::TabbedArea::adjustSize(), gcn::Tab::adjustSize(), gcn::RadioButton::adjustSize(), gcn::ListBox::adjustSize(), gcn::Label::adjustSize(), gcn::CheckBox::adjustSize(), gcn::Button::adjustSize(), gcn::Icon::Icon(), gcn::ImageButton::ImageButton(), gcn::Label::Label(), gcn::TabbedArea::setHeight(), and gcn::ScrollArea::setHeight().

void gcn::Widget::setId ( const std::string &  id  ) 

Sets an id of a widget.

An id can be useful if a widget needs to be identified in a container. For example, if widgets are created by an XML document, a certain widget can be retrieved given that the widget has an id.

Parameters:
id The id to set to the widget.
See also:
getId, BasicContainer::findWidgetById
Since:
0.8.0

Definition at line 677 of file widget.cpp.

References mId.

void gcn::Widget::setInternalFocusHandler ( FocusHandler internalFocusHandler  ) 

Sets the internal focus handler.

An internal focus handler is needed if both a widget in the widget and the widget itself should be foucsed at the same time.

Parameters:
focusHandler The internal focus handler to be used.
See also:
getInternalFocusHandler
Since:
0.1.0

Reimplemented in gcn::BasicContainer.

Definition at line 672 of file widget.cpp.

References mInternalFocusHandler.

Referenced by gcn::BasicContainer::setInternalFocusHandler().

void gcn::Widget::setPosition ( int  x,
int  y 
)

Sets position of the widget.

The position is relative to the widget's parent.

Parameters:
x The x coordinate of the widget.
y The y coordinate of the widget.
See also:
setX, getX, setY, getY, setDimension, getDimension
Since:
0.1.0

Definition at line 204 of file widget.cpp.

References mDimension, setDimension(), gcn::Rectangle::x, and gcn::Rectangle::y.

Referenced by gcn::Container::add(), gcn::DropDown::adjustHeight(), gcn::TabbedArea::adjustSize(), gcn::ScrollArea::logic(), gcn::Window::mouseDragged(), gcn::ScrollArea::setContent(), and gcn::Tab::Tab().

void gcn::Widget::setSelectionColor ( const Color color  ) 

Sets the selection color.

Parameters:
color The selection color.
See also:
getSelectionColor
Since:
0.6.0

Reimplemented in gcn::DropDown.

Definition at line 371 of file widget.cpp.

References mSelectionColor.

Referenced by gcn::DropDown::setSelectionColor().

void gcn::Widget::setSize ( int  width,
int  height 
)

Sets the size of the widget.

Parameters:
width The width of the widget.
height The height of the widget.
See also:
setWidth, setHeight, getWidth, getHeight, setDimension, getDimension
Since:
0.1.0

Reimplemented in gcn::TabbedArea.

Definition at line 551 of file widget.cpp.

References gcn::Rectangle::height, mDimension, setDimension(), and gcn::Rectangle::width.

Referenced by gcn::TabbedArea::addTab(), and gcn::Window::resizeToContent().

void gcn::Widget::setTabInEnabled ( bool  enabled  ) 

Sets tab in enabled, or not.

Tab in means that you can set focus to this widget by pressing the tab button. If tab in is disabled then the FocusHandler will skip this widget and focus the next in its focus order.

Parameters:
enabled True if tab in should be enabled, false otherwise.
See also:
isTabInEnabled
Since:
0.1.0

Definition at line 536 of file widget.cpp.

References mTabIn.

void gcn::Widget::setTabOutEnabled ( bool  enabled  ) 

Sets tab out enabled.

Tab out means that you can lose focus to this widget by pressing the tab button. If tab out is disabled then the FocusHandler ignores tabbing and focus will stay with this widget.

Parameters:
enabled True if tab out should be enabled, false otherwise.
See also:
isTabOutEnabled
Since:
0.1.0

Definition at line 546 of file widget.cpp.

References mTabOut.

void gcn::Widget::setVisible ( bool  visible  ) 

Sets the widget to be visible, or not.

Parameters:
visible True if widget should be visible, false otherwise.
See also:
isVisible
Since:
0.1.0

Definition at line 310 of file widget.cpp.

References distributeHiddenEvent(), distributeShownEvent(), gcn::FocusHandler::focusNone(), isFocused(), mFocusHandler, and mVisible.

void gcn::Widget::setWidth ( int  width  ) 

Sets the width of the widget.

Parameters:
width The width of the widget.
See also:
getWidth, setHeight, getHeight, setSize, setDimension, getDimensi
Since:
0.1.0

Reimplemented in gcn::ScrollArea, and gcn::TabbedArea.

Definition at line 152 of file widget.cpp.

References mDimension, setDimension(), and gcn::Rectangle::width.

Referenced by gcn::DropDown::adjustHeight(), gcn::TextField::adjustSize(), gcn::TextBox::adjustSize(), gcn::TabbedArea::adjustSize(), gcn::RadioButton::adjustSize(), gcn::Label::adjustSize(), gcn::CheckBox::adjustSize(), gcn::Button::adjustSize(), gcn::DropDown::DropDown(), gcn::Icon::Icon(), gcn::ImageButton::ImageButton(), gcn::Label::Label(), gcn::ListBox::ListBox(), gcn::TabbedArea::setWidth(), and gcn::ScrollArea::setWidth().

void gcn::Widget::setX ( int  x  ) 

Sets the x coordinate of the widget.

The coordinate is relateive to the widget's parent.

Parameters:
x The x coordinate of the widget.
See also:
getX, setY, getY, setPosition, setDimension, getDimension
Since:
0.1.0

Definition at line 178 of file widget.cpp.

References mDimension, setDimension(), and gcn::Rectangle::x.

Referenced by gcn::TabbedArea::setDimension(), and gcn::BasicContainer::showWidgetPart().

void gcn::Widget::setY ( int  y  ) 

Sets the y coordinate of the widget.

The coordinate is relative to the widget's parent.

Parameters:
y The y coordinate of the widget.
See also:
setY, setX, getX, setPosition, setDimension, getDimension
Since:
0.1.0

Definition at line 191 of file widget.cpp.

References mDimension, setDimension(), and gcn::Rectangle::y.

Referenced by gcn::TabbedArea::setDimension(), and gcn::BasicContainer::showWidgetPart().

void gcn::Widget::showPart ( Rectangle  rectangle  )  [virtual]

Shows a certain part of a widget in the widget's parent.

Used when widgets want a specific part to be visible in its parent. An example is a TextArea that wants a specific part of its text to be visible when a TextArea is a child of a ScrollArea.

Parameters:
rectangle The rectangle to be shown.
Since:
0.8.0

Definition at line 741 of file widget.cpp.

References mParent, and showWidgetPart().

Referenced by gcn::TextBox::scrollToCaret(), and gcn::ListBox::setSelected().

virtual void gcn::Widget::showWidgetPart ( Widget widget,
Rectangle  area 
) [inline, virtual]

Tries to show a specific part of a widget by moving it.

Used if the widget should act as a container.

Parameters:
widget The target widget.
area The area to show.
Since:
0.1.0

Reimplemented in gcn::BasicContainer, and gcn::ScrollArea.

Definition at line 925 of file widget.hpp.

Referenced by showPart().

bool gcn::Widget::widgetExists ( const Widget widget  )  [static]

Checks if a widget exists or not, that is if it still exists an instance of the object.

Parameters:
widget The widget to check.
Returns:
True if an instance of the widget exists, false otherwise.
Since:
0.1.0

Definition at line 515 of file widget.cpp.

References mWidgets.

Referenced by gcn::Gui::distributeKeyEvent(), gcn::Gui::distributeMouseEvent(), gcn::Gui::handleModalFocusGained(), gcn::Gui::handleModalFocusReleased(), gcn::Gui::handleMouseMoved(), gcn::DropDown::~DropDown(), and gcn::Gui::~Gui().


Member Data Documentation

FocusHandler* gcn::Widget::mInternalFocusHandler [protected]

Holds the focus handler used by the widget.

NULL if no internal focus handler is used.

Reimplemented in gcn::DropDown.

Definition at line 1118 of file widget.hpp.

Referenced by _getInternalFocusHandler(), gcn::BasicContainer::_setFocusHandler(), gcn::BasicContainer::add(), setInternalFocusHandler(), and gcn::BasicContainer::setInternalFocusHandler().

Widget* gcn::Widget::mParent [protected]

Holds the parent of the widget.

NULL if the widget has no parent.

Definition at line 1124 of file widget.hpp.

Referenced by _setParent(), getParent(), requestMoveToBottom(), requestMoveToTop(), and showPart().


The documentation for this class was generated from the following files:
Generated on Sun Jan 20 21:48:15 2008 for Guichan by  doxygen 1.5.2