____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       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"

gcn::DropDown Class Reference

#include <dropdown.h>

Inheritance diagram for gcn::DropDown:

gcn::BasicContainer gcn::MouseListener gcn::KeyListener gcn::ActionListener gcn::Widget DropDownWidget

List of all members.

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 ListModelgetListModel ()
virtual void setScrollArea (ScrollArea *scrollArea)
virtual ScrollAreagetScrollArea ()
virtual void setListBox (ListBox *listBox)
virtual ListBoxgetListBox ()
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
ScrollAreamScrollArea
ListBoxmListBox
ScrollAreamDefaultScrollArea
ListBoxmDefaultListBox
FocusHandler mFocusHandler


Detailed Description

A drop down box from which you can select different values. 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.h.


Constructor & Destructor Documentation

gcn::DropDown::DropDown (  ) 

gcn::DropDown::DropDown ( ListModel listModel  ) 

gcn::DropDown::DropDown ( ListModel listModel,
ScrollArea scrollArea,
ListBox listBox 
)

gcn::DropDown::~DropDown (  )  [virtual]


Member Function Documentation

int gcn::DropDown::getSelected (  )  [virtual]

Gets the index int the ListModel of the selected element.

Returns:
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.

Parameters:
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]

ListModel * gcn::DropDown::getListModel (  )  [virtual]

Gets the ListModel used.

Returns:
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.

Parameters:
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.

Returns:
the ScrollArea used.

Definition at line 443 of file dropdown.cpp.

References mScrollArea.

void gcn::DropDown::setListBox ( ListBox listBox  )  [virtual]

ListBox * gcn::DropDown::getListBox (  )  [virtual]

Gets the ListBox used.

Returns:
the ListBox used.

Definition at line 469 of file dropdown.cpp.

References mListBox.

Referenced by DropDownWidget::setSize().

void gcn::DropDown::adjustHeight (  )  [virtual]

void gcn::DropDown::draw ( Graphics graphics  )  [virtual]

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.

Parameters:
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.

Parameters:
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.

See also:
Gui

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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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]

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().


Member Data Documentation

bool gcn::DropDown::mDroppedDown [protected]

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 252 of file dropdown.h.

Referenced by DropDown(), setBackgroundColor(), setBaseColor(), setForegroundColor(), and ~DropDown().

Definition at line 253 of file dropdown.h.

Referenced by DropDown(), setBackgroundColor(), setBaseColor(), setForegroundColor(), and ~DropDown().

Reimplemented from gcn::Widget.

Definition at line 254 of file dropdown.h.

Referenced by _keyInputMessage(), dropDown(), DropDown(), foldUp(), logic(), and setScrollArea().


The documentation for this class was generated from the following files:

Generated on Sat Feb 21 00:28:27 2009 for Bos Wars by  doxygen 1.5.6