____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"#include <dropdown.h>

Public Member Functions | |
| DropDown () | |
| DropDown (ListModel *listModel) | |
| DropDown (ListModel *listModel, ScrollArea *scrollArea, ListBox *listBox) | |
| virtual | ~DropDown () |
| virtual int | getSelected () |
| virtual void | setSelected (int selected) |
| virtual void | setListModel (ListModel *listModel) |
| virtual ListModel * | getListModel () |
| virtual void | setScrollArea (ScrollArea *scrollArea) |
| virtual ScrollArea * | getScrollArea () |
| virtual void | setListBox (ListBox *listBox) |
| virtual ListBox * | getListBox () |
| virtual void | adjustHeight () |
| virtual void | draw (Graphics *graphics) |
| virtual void | drawBorder (Graphics *graphics) |
| virtual bool | _keyInputMessage (const KeyInput &keyInput) |
| virtual void | logic () |
| virtual void | _mouseInputMessage (const MouseInput &mouseInput) |
| virtual void | lostFocus () |
| virtual void | setBaseColor (const Color &color) |
| virtual void | setBackgroundColor (const Color &color) |
| virtual void | setForegroundColor (const Color &color) |
| virtual void | moveToTop (Widget *widget) |
| virtual void | moveToBottom (Widget *widget) |
| virtual void | _announceDeath (Widget *widget) |
| virtual void | getDrawSize (int &width, int &height, Widget *widget) |
| virtual void | action (const std::string &eventId) |
| virtual bool | keyPress (const Key &key) |
| virtual void | mousePress (int x, int y, int button) |
| virtual void | mouseRelease (int x, int y, int button) |
| virtual void | setFont (Font *font) |
| virtual bool | getDirty () const |
Protected Member Functions | |
| virtual void | drawButton (Graphics *graphics) |
| virtual void | dropDown () |
| virtual void | foldUp () |
Protected Attributes | |
| bool | mDroppedDown |
| bool | mPushed |
| int | mOldH |
| ScrollArea * | mScrollArea |
| ListBox * | mListBox |
| ScrollArea * | mDefaultScrollArea |
| ListBox * | mDefaultListBox |
| FocusHandler | mFocusHandler |
Definition at line 78 of file dropdown.h.
| gcn::DropDown::DropDown | ( | ) |
Constructor.
Definition at line 60 of file dropdown.cpp.
References gcn::ScrollArea::_setFocusHandler(), gcn::Widget::_setParent(), gcn::Widget::addActionListener(), gcn::Widget::addKeyListener(), gcn::Widget::addMouseListener(), adjustHeight(), mDefaultListBox, mDefaultScrollArea, mDroppedDown, mFocusHandler, mListBox, mOldH, mPushed, mScrollArea, gcn::Widget::setBorderSize(), gcn::ScrollArea::setContent(), gcn::Widget::setFocusable(), gcn::ScrollArea::setHorizontalScrollPolicy(), gcn::Widget::setWidth(), and gcn::ScrollArea::SHOW_NEVER.
| gcn::DropDown::DropDown | ( | ListModel * | listModel | ) |
Contructor.
| listModel | the ListModel to use. |
Definition at line 87 of file dropdown.cpp.
References gcn::ScrollArea::_setFocusHandler(), gcn::Widget::_setParent(), gcn::Widget::addActionListener(), gcn::Widget::addKeyListener(), gcn::Widget::addMouseListener(), adjustHeight(), gcn::ListBox::getSelected(), mDefaultListBox, mDefaultScrollArea, mDroppedDown, mFocusHandler, mListBox, mOldH, mPushed, mScrollArea, gcn::Widget::setBorderSize(), gcn::ScrollArea::setContent(), gcn::Widget::setFocusable(), gcn::ScrollArea::setHorizontalScrollPolicy(), setListModel(), gcn::ListBox::setSelected(), gcn::Widget::setWidth(), and gcn::ScrollArea::SHOW_NEVER.
| gcn::DropDown::DropDown | ( | ListModel * | listModel, | |
| ScrollArea * | scrollArea, | |||
| ListBox * | listBox | |||
| ) |
Contructor.
| listModel | the ListModel to use. | |
| scrollArea | the ScrollArea to use. | |
| listBox | the listBox to use. |
Definition at line 121 of file dropdown.cpp.
References gcn::ScrollArea::_setFocusHandler(), gcn::Widget::_setParent(), gcn::Widget::addActionListener(), gcn::Widget::addKeyListener(), gcn::Widget::addMouseListener(), adjustHeight(), gcn::ListBox::getSelected(), mDefaultListBox, mDefaultScrollArea, mDroppedDown, mFocusHandler, mListBox, mOldH, mPushed, mScrollArea, gcn::Widget::setBorderSize(), gcn::ScrollArea::setContent(), gcn::Widget::setFocusable(), setListModel(), gcn::ListBox::setSelected(), and gcn::Widget::setWidth().
| gcn::DropDown::~DropDown | ( | ) | [virtual] |
Destructor.
Definition at line 155 of file dropdown.cpp.
References gcn::ScrollArea::_setFocusHandler(), mDefaultListBox, mDefaultScrollArea, mListBox, mScrollArea, gcn::Widget::removeActionListener(), and gcn::Widget::widgetExists().
| int gcn::DropDown::getSelected | ( | ) | [virtual] |
Gets the index int the ListModel of the selected element.
Definition at line 339 of file dropdown.cpp.
References GCN_EXCEPTION, gcn::ScrollArea::getContent(), gcn::ListBox::getSelected(), mListBox, and mScrollArea.
| void gcn::DropDown::setSelected | ( | int | selected | ) | [virtual] |
Sets the ListModel index of the selected element.
| selected | the ListModel index of the selected element. |
Definition at line 349 of file dropdown.cpp.
References GCN_EXCEPTION, gcn::ScrollArea::getContent(), mListBox, mScrollArea, and gcn::ListBox::setSelected().
| void gcn::DropDown::setListModel | ( | ListModel * | listModel | ) | [virtual] |
Sets the ListModel to use.
| listModel | the ListModel to use. |
Definition at line 405 of file dropdown.cpp.
References adjustHeight(), GCN_EXCEPTION, gcn::ScrollArea::getContent(), gcn::ListBox::getSelected(), mListBox, mScrollArea, gcn::ListBox::setListModel(), and gcn::ListBox::setSelected().
Referenced by DropDown(), and DropDownWidget::setList().
| ListModel * gcn::DropDown::getListModel | ( | ) | [virtual] |
Gets the ListModel used.
Definition at line 422 of file dropdown.cpp.
References GCN_EXCEPTION, gcn::ScrollArea::getContent(), gcn::ListBox::getListModel(), mListBox, and mScrollArea.
| void gcn::DropDown::setScrollArea | ( | ScrollArea * | scrollArea | ) | [virtual] |
Sets the ScrollArea to use.
| scrollArea | the ScrollArea to use. |
Definition at line 432 of file dropdown.cpp.
References gcn::ScrollArea::_setFocusHandler(), gcn::Widget::_setParent(), adjustHeight(), mFocusHandler, mListBox, mScrollArea, and gcn::ScrollArea::setContent().
| ScrollArea * gcn::DropDown::getScrollArea | ( | ) | [virtual] |
Gets the ScrollArea used.
Definition at line 443 of file dropdown.cpp.
References mScrollArea.
| void gcn::DropDown::setListBox | ( | ListBox * | listBox | ) | [virtual] |
Sets the ListBox to use.
| listBox | the ListBox to use. |
Definition at line 448 of file dropdown.cpp.
References gcn::Widget::addActionListener(), gcn::ScrollArea::getContent(), gcn::ListBox::getListModel(), gcn::ListBox::getSelected(), mListBox, mScrollArea, gcn::Widget::removeActionListener(), gcn::ScrollArea::setContent(), gcn::ListBox::setListModel(), and gcn::ListBox::setSelected().
| ListBox * gcn::DropDown::getListBox | ( | ) | [virtual] |
Gets the ListBox used.
Definition at line 469 of file dropdown.cpp.
References mListBox.
Referenced by DropDownWidget::setSize().
| void gcn::DropDown::adjustHeight | ( | ) | [virtual] |
Adjusts the height of the DropDown fitting it's parents height.
Definition at line 474 of file dropdown.cpp.
References GCN_EXCEPTION, gcn::ScrollArea::getContent(), gcn::Widget::getFont(), gcn::Font::getHeight(), gcn::Widget::getHeight(), gcn::Widget::getParent(), gcn::Widget::getWidth(), gcn::Widget::getY(), mDroppedDown, mListBox, mOldH, mScrollArea, gcn::Widget::setHeight(), gcn::Widget::setPosition(), and gcn::Widget::setWidth().
Referenced by dropDown(), DropDown(), foldUp(), setListModel(), and setScrollArea().
| void gcn::DropDown::draw | ( | Graphics * | graphics | ) | [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.
| graphics | a Graphics object to draw with. |
Implements gcn::Widget.
Definition at line 189 of file dropdown.cpp.
References gcn::Color::a, gcn::ScrollArea::draw(), drawButton(), gcn::Graphics::drawLine(), gcn::Graphics::drawRectangle(), gcn::Graphics::drawText(), gcn::Graphics::fillRectangle(), GCN_EXCEPTION, gcn::Widget::getBackgroundColor(), gcn::Widget::getBaseColor(), gcn::ScrollArea::getContent(), gcn::Widget::getDimension(), gcn::ListModel::getElementAt(), gcn::Widget::getFont(), gcn::Widget::getForegroundColor(), gcn::Font::getHeight(), gcn::Widget::getHeight(), gcn::ListBox::getListModel(), gcn::ListBox::getSelected(), gcn::Widget::getWidth(), gcn::Widget::hasFocus(), mDroppedDown, mListBox, mOldH, mScrollArea, gcn::Graphics::popClipArea(), gcn::Graphics::pushClipArea(), gcn::Graphics::setColor(), and gcn::Graphics::setFont().
| void gcn::DropDown::drawBorder | ( | Graphics * | graphics | ) | [virtual] |
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 from gcn::Widget.
Definition at line 250 of file dropdown.cpp.
References gcn::Color::a, gcn::Graphics::drawLine(), gcn::Widget::getBaseColor(), gcn::Widget::getBorderSize(), gcn::Widget::getHeight(), gcn::Widget::getWidth(), and gcn::Graphics::setColor().
| bool gcn::DropDown::_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.
| keyInput | the KeyInput message. |
Reimplemented from gcn::Widget.
Definition at line 536 of file dropdown.cpp.
References gcn::Widget::_keyInputMessage(), GCN_EXCEPTION, gcn::ScrollArea::getContent(), gcn::FocusHandler::getFocused(), mDroppedDown, mFocusHandler, and mScrollArea.
| void gcn::DropDown::logic | ( | ) | [virtual] |
Called for all Widgets in the gui each time Gui::logic is called. You can do logic stuff here like playing an animation.
Reimplemented from gcn::Widget.
Definition at line 178 of file dropdown.cpp.
References gcn::FocusHandler::applyChanges(), GCN_EXCEPTION, gcn::ScrollArea::getContent(), gcn::ScrollArea::logic(), mFocusHandler, and mScrollArea.
| void gcn::DropDown::_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.
| mouseInput | the MouseInput message. |
Reimplemented from gcn::Widget.
Definition at line 560 of file dropdown.cpp.
References gcn::ScrollArea::_mouseInputMessage(), gcn::Widget::_mouseInputMessage(), GCN_EXCEPTION, gcn::ScrollArea::getContent(), gcn::Widget::getY(), gcn::Widget::hasFocus(), mDroppedDown, mListBox, mOldH, mScrollArea, and gcn::MouseInput::y.
| void gcn::DropDown::lostFocus | ( | ) | [virtual] |
Called if the Widget loses focus.
Reimplemented from gcn::Widget.
Definition at line 586 of file dropdown.cpp.
References foldUp().
| void gcn::DropDown::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.
| color | the baseground Color. |
Reimplemented from gcn::Widget.
Definition at line 645 of file dropdown.cpp.
References mDefaultListBox, mDefaultScrollArea, mListBox, mScrollArea, and gcn::Widget::setBaseColor().
| void gcn::DropDown::setBackgroundColor | ( | const Color & | color | ) | [virtual] |
Sets the background color.
| color | the background Color. |
Reimplemented from gcn::Widget.
Definition at line 660 of file dropdown.cpp.
References mDefaultListBox, mDefaultScrollArea, mListBox, mScrollArea, and gcn::Widget::setBackgroundColor().
| void gcn::DropDown::setForegroundColor | ( | const Color & | color | ) | [virtual] |
Sets the foreground color.
| color | the foreground Color. |
Reimplemented from gcn::Widget.
Definition at line 675 of file dropdown.cpp.
References mDefaultListBox, mDefaultScrollArea, mListBox, mScrollArea, and gcn::Widget::setForegroundColor().
| void gcn::DropDown::moveToTop | ( | Widget * | widget | ) | [virtual] |
Moves a Widget to the top of the BasicContainer. The widget will be drawn above all other Widgets in the BasicContainer.
| widget | the Widget to move. |
Implements gcn::BasicContainer.
Definition at line 591 of file dropdown.cpp.
References gcn::Widget::getParent(), and gcn::BasicContainer::moveToTop().
| void gcn::DropDown::moveToBottom | ( | Widget * | widget | ) | [virtual] |
Moves a widget to the bottom of the BasicContainer. The Widget will be drawn below all other Widgets in the BasicContainer.
| widget | the Widget to move. |
Implements gcn::BasicContainer.
Definition at line 599 of file dropdown.cpp.
References gcn::Widget::getParent(), and gcn::BasicContainer::moveToBottom().
| void gcn::DropDown::_announceDeath | ( | Widget * | widget | ) | [virtual] |
Called when a child of the BasicContainer gets destroyed.
| widget | the destroyed Widget. |
Implements gcn::BasicContainer.
Definition at line 607 of file dropdown.cpp.
References GCN_EXCEPTION, and mScrollArea.
| void gcn::DropDown::getDrawSize | ( | int & | width, | |
| int & | height, | |||
| Widget * | widget | |||
| ) | [virtual] |
Gets the drawing space size a Widget has in the BasicContainer. It may not be the same size as the Widgets width and height.
NOTE: Size is not checked recursively all the way back to the top Widget. If the BasicContainer itself is clipped, the size may be inaccurate.
| width | the width the Widget's draw space has. | |
| height | the height the Widget's draw space has. | |
| widget | the Widget calling the function. |
Implements gcn::BasicContainer.
Definition at line 625 of file dropdown.cpp.
References GCN_EXCEPTION, gcn::Widget::getHeight(), gcn::Widget::getWidth(), mDroppedDown, mOldH, and mScrollArea.
| void gcn::DropDown::action | ( | const std::string & | eventId | ) | [virtual] |
Called whan an action is recieved from a Widget. It is used to be able to recieve a notification that an action has occured.
| eventId | the identifier of the Widget. |
Implements gcn::ActionListener.
Definition at line 619 of file dropdown.cpp.
References foldUp(), and gcn::Widget::generateAction().
| bool gcn::DropDown::keyPress | ( | const Key & | key | ) | [virtual] |
Called if a key is pressed when the widget has keyboard focus. If a key is held down the widget will generate multiple key presses.
| key | the key pressed. |
Reimplemented from gcn::KeyListener.
Definition at line 362 of file dropdown.cpp.
References dropDown(), gcn::Key::ENTER, GCN_EXCEPTION, gcn::ScrollArea::getContent(), gcn::Key::getValue(), mDroppedDown, mScrollArea, and gcn::Key::SPACE.
| void gcn::DropDown::mousePress | ( | int | x, | |
| int | y, | |||
| int | button | |||
| ) | [virtual] |
Called when a mouse button is pressed when the mouse is in the Widget area or if the Widget has focus.
NOTE: A mouse press is NOT equal to a mouse click. Use mouseClickMessage to check for mouse clicks.
| x | the x coordinate of the mouse relative to the Widget itself. | |
| y | the y coordinate of the mouse relative to the Widget itself. | |
| button | the button pressed. |
Reimplemented from gcn::MouseListener.
Definition at line 378 of file dropdown.cpp.
References dropDown(), foldUp(), gcn::Widget::hasMouse(), gcn::MouseInput::LEFT, mDroppedDown, mOldH, and mPushed.
| void gcn::DropDown::mouseRelease | ( | int | x, | |
| int | y, | |||
| int | button | |||
| ) | [virtual] |
Called when a mouse button is released when the mouse is in the Widget area or if the Widget has focus.
| x | the x coordinate of the mouse relative to the Widget itself. | |
| y | the y coordinate of the mouse relative to the Widget itself. | |
| button | the button released. |
Reimplemented from gcn::MouseListener.
Definition at line 397 of file dropdown.cpp.
References gcn::MouseInput::LEFT, and mPushed.
| void gcn::DropDown::setFont | ( | Font * | font | ) | [virtual] |
Sets the font. If font is NULL, the global font will be used.
| font | the Font. |
Reimplemented from gcn::Widget.
Definition at line 690 of file dropdown.cpp.
References mListBox, and gcn::Widget::setFont().
| bool gcn::DropDown::getDirty | ( | ) | const [virtual] |
Reimplemented from gcn::Widget.
Definition at line 696 of file dropdown.cpp.
References gcn::Widget::getDirty(), gcn::Widget::mDirty, mDroppedDown, and mScrollArea.
| void gcn::DropDown::drawButton | ( | Graphics * | graphics | ) | [protected, virtual] |
Draws the button with the little down arrow.
| graphics | a Graphics object to draw with. |
Definition at line 274 of file dropdown.cpp.
References gcn::Color::a, gcn::Graphics::drawLine(), gcn::Graphics::fillRectangle(), gcn::Widget::getBaseColor(), gcn::Widget::getForegroundColor(), gcn::Widget::getHeight(), gcn::Widget::getWidth(), mDroppedDown, mOldH, mPushed, gcn::Graphics::setColor(), and y.
Referenced by draw().
| void gcn::DropDown::dropDown | ( | ) | [protected, virtual] |
Sets the DropDown Widget to dropped-down mode.
Definition at line 509 of file dropdown.cpp.
References adjustHeight(), gcn::ScrollArea::getContent(), gcn::Widget::getHeight(), gcn::Widget::getParent(), mDroppedDown, mFocusHandler, mOldH, gcn::BasicContainer::moveToTop(), mScrollArea, and gcn::FocusHandler::requestFocus().
Referenced by keyPress(), and mousePress().
| void gcn::DropDown::foldUp | ( | ) | [protected, virtual] |
Sets the DropDown Widget to folded-up mode.
Definition at line 526 of file dropdown.cpp.
References adjustHeight(), gcn::FocusHandler::focusNone(), mDroppedDown, and mFocusHandler.
Referenced by action(), lostFocus(), and mousePress().
bool gcn::DropDown::mDroppedDown [protected] |
Definition at line 247 of file dropdown.h.
Referenced by _keyInputMessage(), _mouseInputMessage(), adjustHeight(), draw(), drawButton(), dropDown(), DropDown(), foldUp(), getDirty(), getDrawSize(), keyPress(), and mousePress().
bool gcn::DropDown::mPushed [protected] |
Definition at line 248 of file dropdown.h.
Referenced by drawButton(), DropDown(), mousePress(), and mouseRelease().
int gcn::DropDown::mOldH [protected] |
Definition at line 249 of file dropdown.h.
Referenced by _mouseInputMessage(), adjustHeight(), draw(), drawButton(), dropDown(), DropDown(), getDrawSize(), and mousePress().
ScrollArea* gcn::DropDown::mScrollArea [protected] |
Definition at line 250 of file dropdown.h.
Referenced by _announceDeath(), _keyInputMessage(), _mouseInputMessage(), adjustHeight(), draw(), dropDown(), DropDown(), getDirty(), getDrawSize(), getListModel(), getScrollArea(), getSelected(), keyPress(), logic(), setBackgroundColor(), setBaseColor(), setForegroundColor(), setListBox(), setListModel(), setScrollArea(), setSelected(), and ~DropDown().
ListBox* gcn::DropDown::mListBox [protected] |
Definition at line 251 of file dropdown.h.
Referenced by _mouseInputMessage(), adjustHeight(), draw(), DropDown(), getListBox(), getListModel(), getSelected(), setBackgroundColor(), setBaseColor(), setFont(), setForegroundColor(), setListBox(), setListModel(), setScrollArea(), setSelected(), and ~DropDown().
ScrollArea* gcn::DropDown::mDefaultScrollArea [protected] |
Definition at line 252 of file dropdown.h.
Referenced by DropDown(), setBackgroundColor(), setBaseColor(), setForegroundColor(), and ~DropDown().
ListBox* gcn::DropDown::mDefaultListBox [protected] |
Definition at line 253 of file dropdown.h.
Referenced by DropDown(), setBackgroundColor(), setBaseColor(), setForegroundColor(), and ~DropDown().
FocusHandler gcn::DropDown::mFocusHandler [protected] |
Reimplemented from gcn::Widget.
Definition at line 254 of file dropdown.h.
Referenced by _keyInputMessage(), dropDown(), DropDown(), foldUp(), logic(), and setScrollArea().
1.5.6