#include <dropdown.hpp>
Inheritance diagram for gcn::DropDown:
It is one of the most complicated Widgets you will find in Guichan. For drawing the DroppedDown box it uses one ScrollArea and one ListBox. It also uses an internal FocusHandler to handle the focus of the internal ScollArea and ListBox. DropDown uses a ListModel to handle the list. To be able to use DropDown you must give DropDown an implemented ListModel which represents your list.
Definition at line 78 of file dropdown.hpp.
Public Member Functions | |
DropDown () | |
Constructor. | |
DropDown (ListModel *listModel) | |
Contructor. | |
DropDown (ListModel *listModel, ScrollArea *scrollArea, ListBox *listBox) | |
Contructor. | |
virtual | ~DropDown () |
Destructor. | |
virtual int | getSelected () |
Gets the index int the ListModel of the selected element. | |
virtual void | setSelected (int selected) |
Sets the ListModel index of the selected element. | |
virtual void | setListModel (ListModel *listModel) |
Sets the ListModel to use. | |
virtual ListModel * | getListModel () |
Gets the ListModel used. | |
virtual void | setScrollArea (ScrollArea *scrollArea) |
Sets the ScrollArea to use. | |
virtual ScrollArea * | getScrollArea () |
Gets the ScrollArea used. | |
virtual void | setListBox (ListBox *listBox) |
Sets the ListBox to use. | |
virtual ListBox * | getListBox () |
Gets the ListBox used. | |
virtual void | adjustHeight () |
Adjusts the height of the DropDown fitting it's parents height. | |
virtual void | draw (Graphics *graphics) |
Draws the Widget. | |
virtual void | drawBorder (Graphics *graphics) |
Draws a the Widget border. | |
virtual void | _keyInputMessage (const KeyInput &keyInput) |
Called when a Widget recieves a KeyInput. | |
virtual void | logic () |
Called for all Widgets in the gui each time Gui::logic is called. | |
virtual void | _mouseInputMessage (const MouseInput &mouseInput) |
Called when a Widget recieves a MouseInput. | |
virtual void | lostFocus () |
Called if the Widget looses focus. | |
virtual void | setBaseColor (const Color &color) |
Sets the base color. | |
virtual void | setBackgroundColor (const Color &color) |
Sets the background color. | |
virtual void | setForegroundColor (const Color &color) |
Sets the foreground color. | |
virtual void | moveToTop (Widget *widget) |
Moves a Widget to the top of the BasicContainer. | |
virtual void | moveToBottom (Widget *widget) |
Moves a widget to the bottom of the BasicContainer. | |
virtual void | _announceDeath (Widget *widget) |
Called when a child of the BasicContainer gets destroyed. | |
virtual void | getDrawSize (int &width, int &height, Widget *widget) |
Gets the drawing space size a Widget has in the BasicContainer. | |
virtual void | action (const std::string &eventId) |
Called whan an action is recieved from a Widget. | |
virtual void | keyPress (const Key &key) |
Called if a key is pressed when the widget has keyboard focus. | |
virtual void | mousePress (int x, int y, int button) |
Called when a mouse button is pressed when the mouse is in the Widget area or if the Widget has focus. | |
virtual void | mouseRelease (int x, int y, int button) |
Called when a mouse button is released when the mouse is in the Widget area or if the Widget has focus. | |
Protected Member Functions | |
virtual void | drawButton (Graphics *graphics) |
Draws the button with the little down arrow. | |
virtual void | dropDown () |
Sets the DropDown Widget to dropped-down mode. | |
virtual void | foldUp () |
Sets the DropDown Widget to folded-up mode. | |
Protected Attributes | |
bool | mDroppedDown |
bool | mPushed |
int | mOldH |
ScrollArea * | mScrollArea |
ListBox * | mListBox |
ScrollArea * | mDefaultScrollArea |
ListBox * | mDefaultListBox |
FocusHandler | mFocusHandler |
|
Contructor.
Definition at line 86 of file dropdown.cpp. References gcn::ScrollArea::_setFocusHandler(), gcn::Widget::_setParent(), gcn::Widget::addActionListener(), gcn::Widget::addKeyListener(), gcn::Widget::addMouseListener(), adjustHeight(), gcn::ListBox::getSelected(), gcn::Widget::setBorderSize(), gcn::ScrollArea::setContent(), gcn::Widget::setFocusable(), gcn::ScrollArea::setHorizontalScrollPolicy(), setListModel(), gcn::ListBox::setSelected(), and gcn::Widget::setWidth(). |
|
Contructor.
Definition at line 119 of file dropdown.cpp. References gcn::ScrollArea::_setFocusHandler(), gcn::Widget::_setParent(), gcn::Widget::addActionListener(), gcn::Widget::addKeyListener(), gcn::Widget::addMouseListener(), adjustHeight(), gcn::ListBox::getSelected(), gcn::Widget::setBorderSize(), gcn::ScrollArea::setContent(), gcn::Widget::setFocusable(), setListModel(), gcn::ListBox::setSelected(), and gcn::Widget::setWidth(). |
|
Called when a child of the BasicContainer gets destroyed.
Implements gcn::BasicContainer. Definition at line 597 of file dropdown.cpp. |
|
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.
Reimplemented from gcn::Widget. Definition at line 530 of file dropdown.cpp. References gcn::Widget::_keyInputMessage(), gcn::ScrollArea::getContent(), and gcn::FocusHandler::getFocused(). |
|
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.
Reimplemented from gcn::Widget. Definition at line 550 of file dropdown.cpp. References gcn::Widget::_mouseInputMessage(), gcn::ScrollArea::_mouseInputMessage(), gcn::ScrollArea::getContent(), gcn::Widget::getY(), gcn::Widget::hasFocus(), and gcn::MouseInput::y. |
|
Called whan an action is recieved from a Widget. It is used to be able to recieve a notification that an action has occured.
Implements gcn::ActionListener. Definition at line 609 of file dropdown.cpp. References foldUp(), and gcn::Widget::generateAction(). |
|
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.
Implements gcn::Widget. Definition at line 186 of file dropdown.cpp. References gcn::Color::a, gcn::ScrollArea::draw(), drawButton(), gcn::Widget::getBackgroundColor(), gcn::Widget::getBaseColor(), gcn::ScrollArea::getContent(), gcn::Widget::getDimension(), gcn::ListModel::getElementAt(), gcn::Widget::getFont(), gcn::Widget::getForegroundColor(), gcn::Widget::getHeight(), gcn::ListBox::getListModel(), gcn::ListBox::getSelected(), gcn::Widget::getWidth(), and gcn::Widget::hasFocus(). |
|
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.
Reimplemented from gcn::Widget. Definition at line 246 of file dropdown.cpp. References gcn::Color::a, gcn::Widget::getBaseColor(), gcn::Widget::getBorderSize(), gcn::Widget::getHeight(), and gcn::Widget::getWidth(). |
|
Draws the button with the little down arrow.
Definition at line 270 of file dropdown.cpp. References gcn::Color::a, gcn::Widget::getBaseColor(), gcn::Widget::getForegroundColor(), gcn::Widget::getHeight(), and gcn::Widget::getWidth(). Referenced by draw(). |
|
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.
Implements gcn::BasicContainer. Definition at line 615 of file dropdown.cpp. References gcn::Widget::getHeight(), and gcn::Widget::getWidth(). |
|
Gets the ListBox used.
Definition at line 463 of file dropdown.cpp. |
|
Gets the ListModel used.
Definition at line 416 of file dropdown.cpp. References gcn::ScrollArea::getContent(), and gcn::ListBox::getListModel(). |
|
Gets the ScrollArea used.
Definition at line 437 of file dropdown.cpp. |
|
Gets the index int the ListModel of the selected element.
Definition at line 335 of file dropdown.cpp. References gcn::ScrollArea::getContent(), and gcn::ListBox::getSelected(). |
|
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.
Reimplemented from gcn::KeyListener. Definition at line 358 of file dropdown.cpp. References dropDown(), and gcn::ScrollArea::getContent(). |
|
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 175 of file dropdown.cpp. References gcn::FocusHandler::applyChanges(), gcn::ScrollArea::getContent(), and gcn::ScrollArea::logic(). |
|
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.
Reimplemented from gcn::MouseListener. Definition at line 372 of file dropdown.cpp. References dropDown(), foldUp(), and gcn::Widget::hasMouse(). |
|
Called when a mouse button is released when the mouse is in the Widget area or if the Widget has focus.
Reimplemented from gcn::MouseListener. Definition at line 391 of file dropdown.cpp. |
|
Moves a widget to the bottom of the BasicContainer. The Widget will be drawn below all other Widgets in the BasicContainer.
Implements gcn::BasicContainer. Definition at line 589 of file dropdown.cpp. References gcn::Widget::getParent(), and gcn::BasicContainer::moveToBottom(). |
|
Moves a Widget to the top of the BasicContainer. The widget will be drawn above all other Widgets in the BasicContainer.
Implements gcn::BasicContainer. Definition at line 581 of file dropdown.cpp. References gcn::Widget::getParent(), and gcn::BasicContainer::moveToTop(). |
|
Sets the background color.
Reimplemented from gcn::Widget. Definition at line 650 of file dropdown.cpp. References gcn::Widget::setBackgroundColor(). |
|
Sets the base color. The base color is the background color for many Widgets like the Button and Contianer Widgets.
Reimplemented from gcn::Widget. Definition at line 635 of file dropdown.cpp. References gcn::Widget::setBaseColor(). |
|
Sets the foreground color.
Reimplemented from gcn::Widget. Definition at line 665 of file dropdown.cpp. References gcn::Widget::setForegroundColor(). |
|
Sets the ListBox to use.
Definition at line 442 of file dropdown.cpp. References gcn::Widget::addActionListener(), gcn::ScrollArea::getContent(), gcn::ListBox::getListModel(), gcn::ListBox::getSelected(), gcn::Widget::removeActionListener(), gcn::ScrollArea::setContent(), and gcn::ListBox::setSelected(). |
|
Sets the ListModel to use.
Definition at line 399 of file dropdown.cpp. References adjustHeight(), gcn::ScrollArea::getContent(), gcn::ListBox::getSelected(), gcn::ListBox::setListModel(), and gcn::ListBox::setSelected(). Referenced by DropDown(). |
|
Sets the ScrollArea to use.
Definition at line 426 of file dropdown.cpp. References gcn::ScrollArea::_setFocusHandler(), gcn::Widget::_setParent(), adjustHeight(), and gcn::ScrollArea::setContent(). |
|
Sets the ListModel index of the selected element.
Definition at line 345 of file dropdown.cpp. References gcn::ScrollArea::getContent(), and gcn::ListBox::setSelected(). |