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

Widget base class.

Contains basic widget functions every widget should have. Widgets should inherit from this class and implements it's functions.

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

Definition at line 87 of file widget.hpp.

Public Member Functions

 Widget ()
 Constructor.
virtual ~Widget ()
 Default destructor.
virtual void draw (Graphics *graphics)=0
 Draws the Widget.
virtual void drawBorder (Graphics *graphics)
 Draws the Widget border.
virtual void logic ()
 Called for all Widgets in the gui each time Gui::logic is called.
virtual BasicContainergetParent () const
 Gets the Widget parent container.
virtual void setWidth (int width)
 Sets the width of the Widget in pixels.
virtual int getWidth () const
 Gets the width of the Widget in pixels.
virtual void setHeight (int height)
 Sets the height of the Widget in pixels.
virtual int getHeight () const
 Gets the height of the Widget in pixels.
virtual void setSize (int width, int height)
 Sets the size of the Widget.
virtual void setX (int x)
 Set the Widget x coordinate.
virtual int getX () const
 Gets the Widget x coordinate.
virtual void setY (int y)
 Set the Widget y coordinate.
virtual int getY () const
 Gets the Widget y coordinate.
virtual void setPosition (int x, int y)
 Sets the Widget position.
virtual void setDimension (const Rectangle &dimension)
 Sets the dimension of the Widget.
virtual void setBorderSize (unsigned int borderSize)
 Sets the size of the border, or the width if you so like.
virtual unsigned int getBorderSize () const
 Gets the size of the border, or the width if you so like.
virtual const RectanglegetDimension () const
 Gets the dimension of the Widget.
virtual void setFocusable (bool focusable)
 Sets a Widgets focusability.
virtual bool isFocusable () const
 Checks whether the Widget is focusable.
virtual bool isFocused () const
 Checks if the Widget is focused.
virtual void setEnabled (bool enabled)
 Sets the Widget to be disabled or enabled.
virtual bool isEnabled () const
 Checks if a Widget is disabled or not.
virtual void lostFocus ()
 Called if the Widget looses focus.
virtual void gotFocus ()
 Called if the Widget recieves focus.
virtual bool hasMouse () const
 Checks if the Widget has the mouse.
virtual void setVisible (bool visible)
 Sets the Widget to be visible.
virtual bool isVisible () const
 Checks if the Widget is visible.
virtual void setBaseColor (const Color &color)
 Sets the base color.
virtual const ColorgetBaseColor () const
 Gets the base color.
virtual void setForegroundColor (const Color &color)
 Sets the foreground color.
virtual const ColorgetForegroundColor () const
 Gets the foreground color.
virtual void setBackgroundColor (const Color &color)
 Sets the background color.
virtual const ColorgetBackgroundColor () const
 Gets the background color.
virtual void _mouseInputMessage (const MouseInput &mouseInput)
 Called when a Widget recieves a MouseInput.
virtual void _keyInputMessage (const KeyInput &keyInput)
 Called when a Widget recieves a KeyInput.
virtual void _mouseInMessage ()
 Called when the mouse enters the Widget area.
virtual void _mouseOutMessage ()
 Called when the mouse leaves the Widget area.
virtual void requestFocus ()
 Requests focus for the Widget.
virtual void requestMoveToTop ()
 Requests a move to the top in the parent Widget.
virtual void requestMoveToBottom ()
 Requests a move to the bottom in the parent Widget.
virtual void _setFocusHandler (FocusHandler *focusHandler)
 Sets the FocusHandler to be used.
virtual FocusHandler_getFocusHandler ()
 Gets the FocusHandler used.
virtual void addActionListener (ActionListener *actionListener)
 Adds an ActionListener to the Widget.
virtual void removeActionListener (ActionListener *actionListener)
 Removes an added ActionListener from the Widget.
virtual void addMouseListener (MouseListener *mouseListener)
 Adds a MouseListener to the Widget.
virtual void removeMouseListener (MouseListener *mouseListener)
 Removes an added MouseListener from the Widget.
virtual void addKeyListener (KeyListener *keyListener)
 Adds a KeyListener to the Widget.
virtual void removeKeyListener (KeyListener *keyListener)
 Removes an added KeyListener from the Widget.
virtual void setEventId (const std::string &eventId)
 Sets the event identifier of the Widget.
virtual const std::string & getEventId () const
 Gets the event identifier.
virtual void getAbsolutePosition (int &x, int &y) const
 Gets the absolute position on the screen for the Widget.
virtual void _setParent (BasicContainer *parent)
 Sets the parent of the Widget.
FontgetFont () const
 Gets the font used.
virtual void setFont (Font *font)
 Sets the font.
virtual void fontChanged ()
 Called when the font has changed.
virtual bool isTabInEnabled () const
 Check if tab in is enabled.
virtual void setTabInEnabled (bool enabled)
 Sets tab in enabled.
virtual bool isTabOutEnabled () const
 Checks if tab out is enabled.
virtual void setTabOutEnabled (bool enabled)
 Sets tab out enabled.
virtual bool isDragged () const
 Checks if the Widget is dragged.
virtual void requestModalFocus ()
 Requests modal focus.
virtual void releaseModalFocus ()
 Releases modal focus.
virtual bool hasModalFocus () const
 Checks if the Widget or it's parent has modal focus.

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 whether a Widget exists or not, that is if it still exists an instance of the object.

Protected Types

typedef std::list< MouseListener * > MouseListenerList
typedef MouseListenerList::iterator MouseListenerIterator
typedef std::list< KeyListener * > KeyListenerList
typedef KeyListenerList::iterator KeyListenerIterator
typedef std::list< ActionListener * > ActionListenerList
typedef ActionListenerList::iterator ActionListenerIterator

Protected Member Functions

void generateAction ()
 Generates an action to the Widget's ActionListeners.

Protected Attributes

MouseListenerList mMouseListeners
KeyListenerList mKeyListeners
ActionListenerList mActionListeners
Color mForegroundColor
Color mBackgroundColor
Color mBaseColor
FocusHandlermFocusHandler
BasicContainermParent
Rectangle mDimension
unsigned int mBorderSize
std::string mEventId
int mClickTimeStamp
int mClickCount
int mClickButton
bool mHasMouse
bool mFocusable
bool mVisible
bool mTabIn
bool mTabOut
bool mEnabled
FontmCurrentFont

Static Protected Attributes

static DefaultFont mDefaultFont
static FontmGlobalFont = NULL
static std::list< Widget * > mWidgets


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 80 of file widget.cpp.

References mBackgroundColor, mBaseColor, mBorderSize, mClickButton, mClickCount, mClickTimeStamp, mCurrentFont, mEnabled, mFocusable, mFocusHandler, mForegroundColor, mHasMouse, mParent, mTabIn, mTabOut, mVisible, and mWidgets.


Member Function Documentation

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

Gets the FocusHandler used.

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

Returns:
the FocusHandler used.

Definition at line 326 of file widget.cpp.

References mFocusHandler.

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

void gcn::Widget::_keyInputMessage ( const KeyInput keyInput  )  [virtual]

Called when a Widget recieves a KeyInput.

WARNING: This function is used internally to handle all key messages. Don't call or overload it unless you know what you are doing.

Parameters:
keyInput the KeyInput message.

Reimplemented in gcn::BasicContainer.

Definition at line 477 of file widget.cpp.

References gcn::KeyInput::getKey(), gcn::FocusHandler::getModalFocused(), gcn::KeyInput::getType(), hasModalFocus(), mEnabled, mFocusHandler, and mKeyListeners.

Referenced by gcn::BasicContainer::_keyInputMessage(), and gcn::Gui::logic().

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

Called when the mouse enters the Widget area.

WARNING: This function is used internally to handle mouse in messages. Don't call or overload this function unless you know what you are doing.

Definition at line 510 of file widget.cpp.

References mEnabled, mHasMouse, and mMouseListeners.

Referenced by gcn::BasicContainer::_mouseInputMessage(), and gcn::Gui::logic().

void gcn::Widget::_mouseInputMessage ( const MouseInput mouseInput  )  [virtual]

Called when a Widget recieves a MouseInput.

WARNING: This function is used internally to handle all mouse messages. Don't call or overload it unless you know what you are doing.

Parameters:
mouseInput the MouseInput message.

Reimplemented in gcn::BasicContainer.

Definition at line 361 of file widget.cpp.

References gcn::FocusHandler::dragNone(), gcn::MouseInput::getButton(), gcn::FocusHandler::getModalFocused(), gcn::MouseInput::getTimeStamp(), gcn::MouseInput::getType(), hasModalFocus(), hasMouse(), isDragged(), mClickButton, mClickCount, mClickTimeStamp, mEnabled, mFocusHandler, mHasMouse, mMouseListeners, gcn::FocusHandler::requestDrag(), requestFocus(), gcn::MouseInput::x, and gcn::MouseInput::y.

Referenced by gcn::BasicContainer::_mouseInputMessage(), and gcn::Gui::logic().

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

Called when the mouse leaves the Widget area.

WARNING: This function is used internally be to handle mouse out messages. Don't call or overload this function unless you know what you are doing.

Reimplemented in gcn::BasicContainer.

Definition at line 526 of file widget.cpp.

References mHasMouse, and mMouseListeners.

Referenced by gcn::BasicContainer::_mouseInputMessage(), gcn::BasicContainer::_mouseOutMessage(), and gcn::Gui::logic().

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

Sets the FocusHandler 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 FocusHandler to use.

Reimplemented in gcn::BasicContainer.

Definition at line 310 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 ( BasicContainer 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 BasicContainer..

Definition at line 114 of file widget.cpp.

References mParent.

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

void gcn::Widget::addActionListener ( ActionListener actionListener  )  [virtual]

Adds an ActionListener to the Widget.

When an action is triggered by the Widget, the action function in all the Widget's ActionListeners will be called.

Parameters:
actionListener the ActionListener to add.

Definition at line 331 of file widget.cpp.

References mActionListeners.

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

void gcn::Widget::addKeyListener ( KeyListener keyListener  )  [virtual]

Adds a KeyListener to the Widget.

When a key message is recieved, it will be sent to the Widget's KeyListeners.

Parameters:
keyListener the KeyListener to add.

Definition at line 341 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::TextBox::TextBox(), and gcn::TextField::TextField().

void gcn::Widget::addMouseListener ( MouseListener mouseListener  )  [virtual]

Adds a MouseListener to the Widget.

When a mouse message is recieved, it will be sent to the Widget's MouseListeners.

Parameters:
mouseListener the MouseListener to add.

Definition at line 351 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::TextBox::TextBox(), gcn::TextField::TextField(), and gcn::Window::Window().

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 Widgets dimension.

Parameters:
graphics a Graphics object to draw with.

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

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

virtual void gcn::Widget::drawBorder ( Graphics graphics  )  [inline, virtual]

Draws the Widget border.

A border is drawn around a Widget. The width and height of the border is therefore the Widgets height+2*bordersize. Think of a painting that has a certain size, the border surrounds the painting.

Parameters:
graphics a Graphics object to draw with.

Reimplemented in gcn::Button, gcn::CheckBox, gcn::Container, gcn::DropDown, gcn::Icon, gcn::Label, gcn::ListBox, gcn::RadioButton, gcn::ScrollArea, gcn::Slider, gcn::TextBox, gcn::TextField, and gcn::Window.

Definition at line 121 of file widget.hpp.

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

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 don't have a font already set.

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

Definition at line 547 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 absolute x coordinate will be stored in this parameter.
y absolute y coordinate will be stored in this parameter.

Definition at line 537 of file widget.cpp.

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

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

const Color & gcn::Widget::getBackgroundColor (  )  const [virtual]

Gets the background color.

Returns:
the background Color.

Definition at line 305 of file widget.cpp.

References mBackgroundColor.

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

const Color & gcn::Widget::getBaseColor (  )  const [virtual]

Gets the base color.

Returns:
the foreground Color.

Definition at line 285 of file widget.cpp.

References mBaseColor.

Referenced by gcn::Window::draw(), gcn::Slider::draw(), gcn::ScrollArea::draw(), gcn::DropDown::draw(), gcn::Container::draw(), gcn::Button::draw(), gcn::Window::drawBorder(), gcn::TextField::drawBorder(), gcn::Slider::drawBorder(), gcn::ScrollArea::drawBorder(), gcn::RadioButton::drawBorder(), gcn::ListBox::drawBorder(), gcn::Label::drawBorder(), gcn::Icon::drawBorder(), gcn::DropDown::drawBorder(), gcn::Container::drawBorder(), gcn::CheckBox::drawBorder(), gcn::Button::drawBorder(), gcn::RadioButton::drawBox(), gcn::CheckBox::drawBox(), gcn::DropDown::drawButton(), gcn::ScrollArea::drawDownButton(), 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().

unsigned int gcn::Widget::getBorderSize (  )  const [virtual]

Gets the size of the border, or the width if you so like.

The size is the number of pixels that the border extends outside the Widget. Border size = 0 means no border.

Returns:
the size of the border.
See also:
drawBorder

Definition at line 180 of file widget.cpp.

References mBorderSize.

Referenced by gcn::Window::draw(), gcn::Gui::draw(), gcn::Window::drawBorder(), gcn::TextField::drawBorder(), gcn::TextBox::drawBorder(), gcn::Slider::drawBorder(), gcn::ScrollArea::drawBorder(), gcn::RadioButton::drawBorder(), gcn::ListBox::drawBorder(), gcn::Label::drawBorder(), gcn::Icon::drawBorder(), gcn::DropDown::drawBorder(), gcn::Container::drawBorder(), gcn::CheckBox::drawBorder(), gcn::Button::drawBorder(), gcn::ScrollArea::getHorizontalMaxScroll(), gcn::ScrollArea::getVerticalMaxScroll(), gcn::ScrollArea::logic(), and gcn::ScrollArea::showWidgetPart().

const Rectangle & gcn::Widget::getDimension (  )  const [virtual]

Gets the dimension of the Widget.

It is relative to it's parent.

Returns:
the widget dimension.

Definition at line 185 of file widget.cpp.

References mDimension.

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

const std::string & gcn::Widget::getEventId (  )  const [virtual]

Gets the event identifier.

Returns:
the event identifier.

Definition at line 190 of file widget.cpp.

References mEventId.

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

Gets the font used.

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

Returns:
the used Font.

Definition at line 564 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::keyPress(), gcn::Label::Label(), gcn::TextField::mousePress(), gcn::TextBox::mousePress(), gcn::ListBox::mousePress(), gcn::TextBox::scrollToCaret(), and gcn::ListBox::setSelected().

const Color & gcn::Widget::getForegroundColor (  )  const [virtual]

Gets the foreground color.

Returns:
the foreground Color.

Definition at line 295 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::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().

int gcn::Widget::getHeight (  )  const [virtual]

Gets the height of the Widget in pixels.

Returns:
the Widget height in pixels.

Definition at line 139 of file widget.cpp.

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

Referenced by gcn::BasicContainer::_mouseInputMessage(), gcn::TextField::adjustHeight(), gcn::DropDown::adjustHeight(), gcn::TextBox::adjustSize(), gcn::ListBox::adjustSize(), gcn::Label::adjustSize(), gcn::Button::adjustSize(), gcn::ScrollArea::checkPolicies(), gcn::Window::draw(), gcn::TextField::draw(), gcn::TextBox::draw(), gcn::Slider::draw(), gcn::ScrollArea::draw(), gcn::RadioButton::draw(), gcn::ListBox::draw(), gcn::Label::draw(), gcn::DropDown::draw(), gcn::Container::draw(), gcn::CheckBox::draw(), gcn::Button::draw(), gcn::Window::drawBorder(), gcn::TextField::drawBorder(), gcn::TextBox::drawBorder(), gcn::Slider::drawBorder(), gcn::ScrollArea::drawBorder(), gcn::RadioButton::drawBorder(), gcn::ListBox::drawBorder(), gcn::Label::drawBorder(), gcn::Icon::drawBorder(), gcn::DropDown::drawBorder(), gcn::Container::drawBorder(), gcn::CheckBox::drawBorder(), gcn::Button::drawBorder(), gcn::RadioButton::drawBox(), gcn::CheckBox::drawBox(), gcn::DropDown::drawButton(), gcn::TextField::drawCaret(), gcn::TextBox::drawCaret(), 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::mouseMotion(), gcn::Slider::mousePress(), gcn::ListBox::mousePress(), and gcn::Slider::valueToMarkerPosition().

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

Gets the Widget parent container.

Returns:
the Widget parent container. Returns NULL if the Widget has no parent.

Definition at line 119 of file widget.cpp.

References mParent.

Referenced by gcn::DropDown::adjustHeight(), gcn::DropDown::dropDown(), getAbsolutePosition(), hasModalFocus(), isVisible(), gcn::TextBox::keyPress(), gcn::Window::mousePress(), gcn::TextBox::scrollToCaret(), gcn::ListBox::setSelected(), and ~Widget().

int gcn::Widget::getWidth (  )  const [virtual]

Gets the width of the Widget in pixels.

Returns:
the Widget with in pixels.

Definition at line 129 of file widget.cpp.

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

Referenced by gcn::BasicContainer::_mouseInputMessage(), gcn::DropDown::adjustHeight(), gcn::TextField::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::Slider::draw(), gcn::ScrollArea::draw(), gcn::RadioButton::draw(), gcn::ListBox::draw(), gcn::Label::draw(), gcn::DropDown::draw(), gcn::Container::draw(), gcn::CheckBox::draw(), gcn::Button::draw(), gcn::Window::drawBorder(), gcn::TextField::drawBorder(), gcn::TextBox::drawBorder(), gcn::Slider::drawBorder(), gcn::ScrollArea::drawBorder(), gcn::RadioButton::drawBorder(), gcn::ListBox::drawBorder(), gcn::Label::drawBorder(), gcn::Icon::drawBorder(), gcn::DropDown::drawBorder(), gcn::Container::drawBorder(), gcn::CheckBox::drawBorder(), gcn::Button::drawBorder(), gcn::DropDown::drawButton(), 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::mousePress(), and gcn::Slider::valueToMarkerPosition().

int gcn::Widget::getX (  )  const [virtual]

Gets the Widget x coordinate.

It is relative to it's parent.

Returns:
the Widget x coordinate.

Definition at line 149 of file widget.cpp.

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

Referenced by gcn::BasicContainer::_mouseInputMessage(), gcn::Gui::logic(), gcn::Window::mouseMotion(), gcn::ScrollArea::showWidgetPart(), and gcn::BasicContainer::showWidgetPart().

int gcn::Widget::getY (  )  const [virtual]

Gets the Widget y coordinate.

It is relative to it's parent.

Returns:
the Widget y coordinate.

Definition at line 159 of file widget.cpp.

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

Referenced by gcn::BasicContainer::_mouseInputMessage(), gcn::DropDown::adjustHeight(), gcn::Gui::logic(), gcn::Window::mouseMotion(), gcn::ScrollArea::showWidgetPart(), and gcn::BasicContainer::showWidgetPart().

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

Checks if the Widget has the mouse.

Returns:
true if the Widget has the mouse.

Definition at line 210 of file widget.cpp.

References mHasMouse.

Referenced by _mouseInputMessage(), gcn::BasicContainer::_mouseInputMessage(), gcn::Button::isPressed(), gcn::Gui::logic(), gcn::Window::mousePress(), gcn::TextField::mousePress(), gcn::TextBox::mousePress(), gcn::ListBox::mousePress(), gcn::DropDown::mousePress(), gcn::Button::mousePress(), gcn::ScrollArea::mouseWheelDown(), and gcn::ScrollArea::mouseWheelUp().

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

Checks if the Widget is dragged.

Dragged means that the mouse button has been pressed down over the Widget and the mouse has been moved.

Returns:
true if the widget is dragged.

Definition at line 651 of file widget.cpp.

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

Referenced by _mouseInputMessage(), and gcn::BasicContainer::_mouseInputMessage().

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

Checks if a Widget is disabled or not.

Returns:
true if the Widget should be enabled.

Definition at line 646 of file widget.cpp.

References isVisible(), and mEnabled.

Referenced by isFocusable().

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

Checks whether the Widget is focusable.

Returns:
true if the widget is focusable.

Definition at line 225 of file widget.cpp.

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

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

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

Checks if the Widget is focused.

Returns:
true if the widget currently has focus.

Definition at line 200 of file widget.cpp.

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

Referenced by gcn::BasicContainer::_mouseInputMessage(), gcn::TextField::draw(), gcn::TextBox::draw(), gcn::RadioButton::draw(), gcn::DropDown::draw(), gcn::CheckBox::draw(), gcn::Button::draw(), gcn::Slider::drawMarker(), gcn::TextField::fixScroll(), setFocusable(), and setVisible().

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

Check 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 FocusHandler will skip this widget and focus the next in its focus order.

Returns:
true if tab in is enabled.

Definition at line 615 of file widget.cpp.

References mTabIn.

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

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.

Definition at line 625 of file widget.cpp.

References mTabOut.

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

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

Checks if the Widget is visible.

Returns:
true if the Widget is visible.

Definition at line 268 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

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

Definition at line 129 of file widget.hpp.

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

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

Releases modal focus.

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

Definition at line 671 of file widget.cpp.

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

Referenced by _setFocusHandler().

void gcn::Widget::removeActionListener ( ActionListener actionListener  )  [virtual]

Removes an added ActionListener from the Widget.

Parameters:
actionListener the ActionListener to remove.

Definition at line 336 of file widget.cpp.

References mActionListeners.

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

void gcn::Widget::removeKeyListener ( KeyListener keyListener  )  [virtual]

Removes an added KeyListener from the Widget.

Parameters:
keyListener the KeyListener to remove.

Definition at line 346 of file widget.cpp.

References mKeyListeners.

void gcn::Widget::removeMouseListener ( MouseListener mouseListener  )  [virtual]

Removes an added MouseListener from the Widget.

Parameters:
mouseListener the MouseListener to remove.

Definition at line 356 of file widget.cpp.

References mMouseListeners.

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

Requests focus for the Widget.

A Widget will only recieve focus if it is focusable.

Definition at line 230 of file widget.cpp.

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

Referenced by _mouseInputMessage(), and gcn::DropDown::dropDown().

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

Requests modal focus.

When a widget has modal focus, only that Widget and it's children may recieve input. If some other Widget already has modal focus, an exception will be thrown.

Exceptions:
Exception if another Widget already has modal focus.

Definition at line 661 of file widget.cpp.

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

void gcn::Widget::setBackgroundColor ( const Color color  )  [virtual]

Sets the background color.

Parameters:
color the background Color.

Reimplemented in gcn::DropDown.

Definition at line 300 of file widget.cpp.

References mBackgroundColor.

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

void gcn::Widget::setBaseColor ( const Color color  )  [virtual]

Sets the base color.

The base color is the background color for many Widgets like the Button and Contianer Widgets.

Parameters:
color the baseground Color.

Reimplemented in gcn::DropDown.

Definition at line 280 of file widget.cpp.

References mBaseColor.

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

void gcn::Widget::setBorderSize ( unsigned int  borderSize  )  [virtual]

Sets the size of the border, or the width if you so like.

The size is the number of pixels that the border extends outside the Widget. Border size = 0 means no border.

Parameters:
borderSize the size of the border.
See also:
drawBorder

Definition at line 175 of file widget.cpp.

References mBorderSize.

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

void gcn::Widget::setDimension ( const Rectangle dimension  )  [virtual]

Sets the dimension of the Widget.

It is relative to it's parent.

Parameters:
dimension the Widget dimension.

Reimplemented in gcn::ScrollArea.

Definition at line 170 of file widget.cpp.

References mDimension.

Referenced by gcn::ScrollArea::setDimension().

void gcn::Widget::setEnabled ( bool  enabled  )  [virtual]

Sets the Widget to be disabled or enabled.

A disabled Widget will never recieve mouse or key input.

Parameters:
enabled true if Widget is enabled.

Definition at line 641 of file widget.cpp.

References mEnabled.

void gcn::Widget::setEventId ( const std::string &  eventId  )  [virtual]

Sets the event identifier of the Widget.

The event identifier is used to be able to identify which Widget generated an action when an action has occured.

NOTE: An 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 event identifer.

Parameters:
eventId the event identifier.

Definition at line 195 of file widget.cpp.

References mEventId.

void gcn::Widget::setFocusable ( bool  focusable  )  [virtual]

Sets a Widgets focusability.

Parameters:
focusable true if the Widget should be focusable.

Definition at line 215 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::TextBox::TextBox(), and gcn::TextField::TextField().

void gcn::Widget::setFont ( Font font  )  [virtual]

Sets the font.

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

Parameters:
font the Font.

Reimplemented in gcn::DropDown.

Definition at line 593 of file widget.cpp.

References fontChanged(), and mCurrentFont.

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

void gcn::Widget::setForegroundColor ( const Color color  )  [virtual]

Sets the foreground color.

Parameters:
color the foreground Color.

Reimplemented in gcn::DropDown.

Definition at line 290 of file widget.cpp.

References mForegroundColor.

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

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

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

Parameters:
font the global Font.

Definition at line 579 of file widget.cpp.

References mGlobalFont, and mWidgets.

void gcn::Widget::setHeight ( int  height  )  [virtual]

Sets the height of the Widget in pixels.

Parameters:
height the Widget height in pixels.

Reimplemented in gcn::ScrollArea.

Definition at line 134 of file widget.cpp.

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

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

void gcn::Widget::setPosition ( int  x,
int  y 
) [virtual]

Sets the Widget position.

It is relative to it's parent.

Parameters:
x the Widget x coordinate.
y the Widgets y coordinate.

Definition at line 164 of file widget.cpp.

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

Referenced by gcn::Container::add(), gcn::DropDown::adjustHeight(), gcn::ScrollArea::logic(), gcn::Window::mouseMotion(), and gcn::ScrollArea::setContent().

void gcn::Widget::setSize ( int  width,
int  height 
) [virtual]

Sets the size of the Widget.

Parameters:
width the width.
height the height.

Definition at line 635 of file widget.cpp.

References setHeight(), and setWidth().

Referenced by gcn::Window::resizeToContent().

void gcn::Widget::setTabInEnabled ( bool  enabled  )  [virtual]

Sets tab in enabled.

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.

Definition at line 620 of file widget.cpp.

References mTabIn.

void gcn::Widget::setTabOutEnabled ( bool  enabled  )  [virtual]

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.

Definition at line 630 of file widget.cpp.

References mTabOut.

void gcn::Widget::setVisible ( bool  visible  )  [virtual]

Sets the Widget to be visible.

Parameters:
visible true if the Widget should be visiable.

Definition at line 259 of file widget.cpp.

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

void gcn::Widget::setWidth ( int  width  )  [virtual]

Sets the width of the Widget in pixels.

Parameters:
width the Widget width in pixels.

Reimplemented in gcn::ScrollArea.

Definition at line 124 of file widget.cpp.

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

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

void gcn::Widget::setX ( int  x  )  [virtual]

Set the Widget x coordinate.

It is relateive to it's parent.

Parameters:
x the Widget x coordinate.

Definition at line 144 of file widget.cpp.

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

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

void gcn::Widget::setY ( int  y  )  [virtual]

Set the Widget y coordinate.

It is relative to it's parent.

Parameters:
y the Widget y coordinate.

Definition at line 154 of file widget.cpp.

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

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

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

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

Parameters:
widget the Widget to check.

Definition at line 599 of file widget.cpp.

References mWidgets.

Referenced by gcn::DropDown::~DropDown(), and gcn::Gui::~Gui().


The documentation for this class was generated from the following files:
Generated on Sat Jul 29 19:38:49 2006 for Guichan by  doxygen 1.4.7