Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

gcn::DropDown Class Reference

#include <dropdown.hpp>

Inheritance diagram for gcn::DropDown:

gcn::BasicContainer gcn::MouseListener gcn::KeyListener gcn::ActionListener gcn::Widget List of all members.

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.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 ListModelgetListModel ()
 Gets the ListModel used.
virtual void setScrollArea (ScrollArea *scrollArea)
 Sets the ScrollArea to use.
virtual ScrollAreagetScrollArea ()
 Gets the ScrollArea used.
virtual void setListBox (ListBox *listBox)
 Sets the ListBox to use.
virtual ListBoxgetListBox ()
 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
ScrollAreamScrollArea
ListBoxmListBox
ScrollAreamDefaultScrollArea
ListBoxmDefaultListBox
FocusHandler mFocusHandler


Constructor & Destructor Documentation

gcn::DropDown::DropDown ListModel listModel  ) 
 

Contructor.

Parameters:
listModel the ListModel to use.
See also:
ListModel.

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

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

Contructor.

Parameters:
listModel the ListModel to use.
scrollArea the ScrollArea to use.
listBox the listBox to use.
See also:
ListModel, ScrollArea, ListBox.

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


Member Function Documentation

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 597 of file dropdown.cpp.

void 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 530 of file dropdown.cpp.

References gcn::Widget::_keyInputMessage(), gcn::ScrollArea::getContent(), and gcn::FocusHandler::getFocused().

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

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 609 of file dropdown.cpp.

References foldUp(), and gcn::Widget::generateAction().

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.

Parameters:
graphics a Graphics object to draw with.

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

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 246 of file dropdown.cpp.

References gcn::Color::a, gcn::Widget::getBaseColor(), gcn::Widget::getBorderSize(), gcn::Widget::getHeight(), and gcn::Widget::getWidth().

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

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 615 of file dropdown.cpp.

References gcn::Widget::getHeight(), and gcn::Widget::getWidth().

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

Gets the ListBox used.

Returns:
the ListBox used.

Definition at line 463 of file dropdown.cpp.

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

Gets the ListModel used.

Returns:
the ListModel used.

Definition at line 416 of file dropdown.cpp.

References gcn::ScrollArea::getContent(), and gcn::ListBox::getListModel().

ScrollArea * gcn::DropDown::getScrollArea  )  [virtual]
 

Gets the ScrollArea used.

Returns:
the ScrollArea used.

Definition at line 437 of file dropdown.cpp.

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

Gets the index int the ListModel of the selected element.

Returns:
the selected element.

Definition at line 335 of file dropdown.cpp.

References gcn::ScrollArea::getContent(), and gcn::ListBox::getSelected().

void 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 358 of file dropdown.cpp.

References dropDown(), and gcn::ScrollArea::getContent().

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 175 of file dropdown.cpp.

References gcn::FocusHandler::applyChanges(), gcn::ScrollArea::getContent(), and gcn::ScrollArea::logic().

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 372 of file dropdown.cpp.

References dropDown(), foldUp(), and gcn::Widget::hasMouse().

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 391 of file dropdown.cpp.

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 589 of file dropdown.cpp.

References gcn::Widget::getParent(), and gcn::BasicContainer::moveToBottom().

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 581 of file dropdown.cpp.

References gcn::Widget::getParent(), and gcn::BasicContainer::moveToTop().

void gcn::DropDown::setBackgroundColor const Color color  )  [virtual]
 

Sets the background color.

Parameters:
color the background Color.

Reimplemented from gcn::Widget.

Definition at line 650 of file dropdown.cpp.

References gcn::Widget::setBackgroundColor().

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 635 of file dropdown.cpp.

References gcn::Widget::setBaseColor().

void gcn::DropDown::setForegroundColor const Color color  )  [virtual]
 

Sets the foreground color.

Parameters:
color the foreground Color.

Reimplemented from gcn::Widget.

Definition at line 665 of file dropdown.cpp.

References gcn::Widget::setForegroundColor().

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

Sets the ListBox to use.

Parameters:
listBox 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().

void gcn::DropDown::setListModel ListModel listModel  )  [virtual]
 

Sets the ListModel to use.

Parameters:
listModel 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().

void gcn::DropDown::setScrollArea ScrollArea scrollArea  )  [virtual]
 

Sets the ScrollArea to use.

Parameters:
scrollArea the ScrollArea to use.

Definition at line 426 of file dropdown.cpp.

References gcn::ScrollArea::_setFocusHandler(), gcn::Widget::_setParent(), adjustHeight(), and gcn::ScrollArea::setContent().

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 345 of file dropdown.cpp.

References gcn::ScrollArea::getContent(), and gcn::ListBox::setSelected().


The documentation for this class was generated from the following files:
Generated on Tue May 17 21:23:27 2005 for Guichan by  doxygen 1.4.1