_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include <widget.h>
Public Member Functions | |
Widget () | |
virtual | ~Widget () |
virtual void | draw (Graphics *graphics)=0 |
virtual void | drawBorder (Graphics *) |
virtual void | logic () |
virtual BasicContainer * | getParent () const |
virtual void | setWidth (int width) |
virtual int | getWidth () const |
virtual void | setHeight (int height) |
virtual int | getHeight () const |
virtual void | setSize (int width, int height) |
virtual void | setX (int x) |
virtual int | getX () const |
virtual void | setY (int y) |
virtual int | getY () const |
virtual void | setPosition (int x, int y) |
virtual void | setDimension (const Rectangle &dimension) |
virtual void | setBorderSize (unsigned int borderSize) |
virtual unsigned int | getBorderSize () const |
virtual const Rectangle & | getDimension () const |
virtual void | setFocusable (bool focusable) |
virtual bool | isFocusable () const |
virtual bool | hasFocus () const |
virtual void | setEnabled (bool enabled) |
virtual bool | isEnabled () const |
virtual void | lostFocus () |
virtual void | gotFocus () |
virtual bool | hasMouse () const |
virtual void | setVisible (bool visible) |
virtual bool | isVisible () const |
virtual void | setBaseColor (const Color &color) |
virtual const Color & | getBaseColor () const |
virtual void | setForegroundColor (const Color &color) |
virtual const Color & | getForegroundColor () const |
virtual void | setBackgroundColor (const Color &color) |
virtual const Color & | getBackgroundColor () const |
virtual void | setDisabledColor (const Color &color) |
virtual const Color & | getDisabledColor () const |
virtual void | _mouseInputMessage (const MouseInput &mouseInput) |
virtual bool | _keyInputMessage (const KeyInput &keyInput) |
virtual void | hotKeyPress () |
virtual void | hotKeyRelease () |
virtual void | _mouseInMessage () |
virtual void | _mouseOutMessage () |
virtual void | requestFocus () |
virtual void | requestMoveToTop () |
virtual void | requestMoveToBottom () |
virtual void | _setFocusHandler (FocusHandler *focusHandler) |
virtual FocusHandler * | _getFocusHandler () |
virtual void | addActionListener (ActionListener *actionListener) |
virtual void | removeActionListener (ActionListener *actionListener) |
virtual void | addMouseListener (MouseListener *mouseListener) |
virtual void | removeMouseListener (MouseListener *mouseListener) |
virtual void | addKeyListener (KeyListener *keyListener) |
virtual void | removeKeyListener (KeyListener *keyListener) |
virtual void | setEventId (const std::string &eventId) |
virtual const std::string & | getEventId () const |
virtual void | getAbsolutePosition (int &x, int &y) const |
virtual void | _setParent (BasicContainer *parent) |
Font * | getFont () const |
virtual void | setFont (Font *font) |
virtual void | fontChanged () |
virtual int | getHotKey () const |
virtual void | setHotKey (const int key) |
virtual void | setHotKey (const char *key) |
virtual bool | isTabInEnabled () const |
virtual void | setTabInEnabled (bool enabled) |
virtual bool | isTabOutEnabled () const |
virtual void | setTabOutEnabled (bool enabled) |
virtual bool | isDragged () const |
virtual void | requestModalFocus () |
virtual void | releaseModalFocus () |
virtual bool | hasModalFocus () const |
virtual void | setDirty (bool dirty) |
virtual bool | getDirty () const |
Static Public Member Functions | |
static void | setGlobalFont (Font *font) |
static bool | widgetExists (const Widget *widget) |
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 () |
Protected Attributes | |
MouseListenerList | mMouseListeners |
KeyListenerList | mKeyListeners |
ActionListenerList | mActionListeners |
Color | mForegroundColor |
Color | mBackgroundColor |
Color | mBaseColor |
Color | mDisabledColor |
FocusHandler * | mFocusHandler |
BasicContainer * | mParent |
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 |
Font * | mCurrentFont |
int | mHotKey |
bool | mDirty |
Static Protected Attributes | |
static DefaultFont | mDefaultFont |
static Font * | mGlobalFont = NULL |
static std::list< Widget * > | mWidgets |
Friends | |
class | BasicContainer |
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.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
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.
|
virtual |
Default destructor.
|
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.
|
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.
keyInput | the KeyInput message. |
Reimplemented in gcn::DropDown.
|
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.
|
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.
mouseInput | the MouseInput message. |
Reimplemented in gcn::ScrollArea, gcn::Window, gcn::DropDown, gcn::Container, and ImageDropDownWidget.
|
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::ScrollArea, gcn::Window, and gcn::Container.
|
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.
focusHandler | the FocusHandler to use. |
Reimplemented in gcn::ScrollArea, gcn::Window, and gcn::Container.
|
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.
parent | the parent BasicContainer.. |
|
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.
actionListener | the ActionListener to add. |
Reimplemented in ImageListBoxWidget, and ListBoxWidget.
|
virtual |
Adds a KeyListener to the Widget. When a key message is recieved, it will be sent to the Widget's KeyListeners.
keyListener | the KeyListener to add. |
|
virtual |
Adds a MouseListener to the Widget. When a mouse message is recieved, it will be sent to the Widget's MouseListeners.
mouseListener | the MouseListener to add. |
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.
graphics | a Graphics object to draw with. |
Implemented in gcn::ScrollArea, gcn::Window, gcn::TextBox, gcn::DropDown, gcn::RadioButton, gcn::TextField, gcn::Container, gcn::CheckBox, gcn::Button, gcn::ListBox, gcn::Label, gcn::Icon, MenuScreen, StatBoxWidget, ImageDropDownWidget, ImageListBoxWidget, ImageListBox, ImageTextField, MultiLineLabel, gcn::Slider, ImageSlider, ImageCheckBox, ImageRadioButton, and ImageButton.
Draws a 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.
graphics | a Graphics object to draw with. |
Reimplemented in gcn::ScrollArea, gcn::Window, gcn::TextBox, gcn::DropDown, gcn::RadioButton, gcn::TextField, gcn::Container, gcn::CheckBox, gcn::Button, gcn::ListBox, gcn::Label, gcn::Icon, ImageDropDownWidget, ImageListBoxWidget, ImageListBox, ImageTextField, MultiLineLabel, and gcn::Slider.
|
inlinevirtual |
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.
|
virtual |
Gets the absolute position on the screen for the Widget.
x | absolute x coordinate will be stored in this parameter. |
y | absolute y coordinate will be stored in this parameter. |
|
virtual |
Gets the background color.
|
virtual |
Gets the base color.
|
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.
|
virtual |
Gets the dimension of the Widget. It is relative to it's parent.
|
virtual |
Reimplemented in gcn::Window, gcn::DropDown, gcn::Container, and gcn::Icon.
|
virtual |
Gets the disabled color.
|
virtual |
Gets the event identifier.
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.
|
virtual |
Gets the foreground color.
|
virtual |
|
inlinevirtual |
Get the hot key
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Checks if the Widget has focus.
|
virtual |
Checks if the Widget or it's parent has modal focus.
|
virtual |
|
inlinevirtual |
Called when a Widget's hot key is pressed
Reimplemented in gcn::Button.
|
inlinevirtual |
Called when a Widget's hot key is released
Reimplemented in gcn::Button.
|
virtual |
|
virtual |
|
virtual |
Checks whether the Widget is focusable.
|
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.
|
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.
|
virtual |
|
inlinevirtual |
Called for all Widgets in the gui each time Gui::logic is called. You can do logic stuff here like playing an animation.
Reimplemented in MenuScreen, ImageListBox, gcn::ScrollArea, gcn::Window, gcn::DropDown, gcn::Container, and gcn::ListBox.
|
inlinevirtual |
Called if the Widget loses focus.
Reimplemented in gcn::Slider, gcn::DropDown, and gcn::Button.
|
virtual |
Releases modal focus. Modal focus will only be released if the Widget has the modal focus.
|
virtual |
Removes an added ActionListener from the Widget.
actionListener | the ActionListener to remove. |
|
virtual |
Removes an added KeyListener from the Widget.
keyListener | the KeyListener to remove. |
|
virtual |
Removes an added MouseListener from the Widget.
mouseListener | the MouseListener to remove. |
|
virtual |
|
virtual |
|
virtual |
Requests a move to the bottom in the parent Widget.
Sets the background color.
color | the background Color. |
Reimplemented in ImageListBoxWidget, ListBoxWidget, and gcn::DropDown.
Sets the base color. The base color is the background color for many Widgets like the Button and Contianer Widgets.
color | the baseground Color. |
Reimplemented in gcn::DropDown, and gcn::Icon.
|
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.
borderSize | the size of the border. |
|
virtual |
Reimplemented in gcn::Window, and gcn::Container.
Sets the disabled color.
color | the disabled Color. |
|
virtual |
|
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.
eventId | the event identifier. |
|
virtual |
Sets a Widgets focusability.
focusable | true if the Widget should be focusable. |
Sets the font. If font is NULL, the global font will be used.
font | the Font. |
Reimplemented in ImageDropDownWidget, ImageListBoxWidget, ListBoxWidget, and gcn::DropDown.
Sets the global font to be used by default for all Widgets.
font | the global Font. |
|
virtual |
|
virtual |
|
virtual |
Set the hot key
|
virtual |
|
virtual |
Sets the size of the Widget.
width | the width. |
height | the height. |
Reimplemented in ImageDropDownWidget, and DropDownWidget.
|
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.
enabled | true if tab in should be 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.
enabled | true if tab out should be enabled. |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
static |
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |