Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

PG_DropDown Class Reference

A edit / dropdown combo item. More...

#include <pgdropdown.h>

Inheritance diagram for PG_DropDown:

Inheritance graph
[legend]
List of all members.

Public Types

enum  { IDDROPDOWN_BOX = PG_WIDGETID_INTERNAL + 11 }

Public Member Functions

 PG_DropDown (PG_Widget *parent, const PG_Rect &r=PG_Rect::null, int id=-1, const std::string &style="DropDown")
 Construct a PG_DropDown object.
 ~PG_DropDown ()
void LoadThemeStyle (const std::string &widgettype)
 Load a style from the theme definition.
void AddItem (const std::string &text, void *userdata=NULL, Uint16 height=0)
 Add a new item to the dropdown box.
void RemoveAll ()
 Remove all widgets from the drop down(without deletion).
void DeleteAll ()
 Delete (destroy) all widgets from the drop down.
void SetIndent (Uint16 indent)
 Set the item indentation.
Uint16 GetIndent ()
 Returns the item indentation.
void SetEditable (bool edit)
 Set if the widget is editable by the user.
bool GetEditable ()
 Check if the widget is editable by the user.
const PG_String & GetText ()
 Get the current text string.
void SetText (const std::string &new_text)
 Set the current text string.
bool ProcessEvent (const SDL_Event *event, bool bModal)
 Process a native PG_ event.
void SelectFirstItem ()
 Select the first item.
int GetSelectedItemIndex ()
 Returns the index of the last selected item.
void SelectNextItem ()
 Select the next item.
void SelectPrevItem ()
 Select the previous item.
void SelectItem (const int n)
 Select the n-th item.
void SetAlignment (PG_Label::TextAlign style)
 Set the item's alignment.
PG_Label::TextAlign GetAlignment ()
 Returns the set alignment rule of this list.
PG_WidgetGetFirstInList ()
void AddChild (PG_Widget *child)
 Add a clientwidget (which will be embedded into this widget).

Public Attributes

SignalSelectItem sigSelectItem
PG_LineEdit::SignalEditBegin sigEditBegin
PG_LineEdit::SignalEditEnd sigEditEnd
PG_LineEdit::SignalEditReturn sigEditReturn

Protected Member Functions

void eventShow ()
 overridable eventhandler called whenever the widget gets shown.
void eventHide ()
 overridable eventhandler called whenever the widget gets hidden.
virtual bool handleButtonClick (PG_Button *button)
void eventSizeWidget (Uint16 w, Uint16 h)
 Callback for the SizeWidget event.
void eventMoveWidget (int x, int y)
 Callback for the MoveWidget event.
virtual bool eventSelectItem (PG_ListBoxBaseItem *item)

Protected Attributes

PG_LineEditmy_EditBox
PG_Buttonmy_DropButton
PG_ListBoxmy_DropList

Classes

class  SignalSelectItem
 Signal type declaration. More...

Detailed Description

A edit / dropdown combo item.

Author:
Alexander Pipelka
Basically a PG_LineEdit widget but with a button to show a dropdown list with predefined entries.

Definition at line 55 of file pgdropdown.h.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
IDDROPDOWN_BOX 

Definition at line 65 of file pgdropdown.h.


Constructor & Destructor Documentation

PG_DropDown::PG_DropDown PG_Widget parent,
const PG_Rect r = PG_Rect::null,
int  id = -1,
const std::string &  style = "DropDown"
 

Construct a PG_DropDown object.

Parameters:
parent pointer to the parent of the widget of NULL
id id of the widget
r position of the widget
style style of the widget (loaded from the theme)

Definition at line 37 of file pgdropdown.cpp.

References PG_Signal1< P1, datatype >::connect(), handleButtonClick(), IDDROPDOWN_BOX, LoadThemeStyle(), my_DropButton, my_DropList, my_EditBox, PG_Rect::my_height, PG_Rect::my_width, PG_Rect::my_xpos, PG_Rect::my_ypos, PG_NULLSTR, PG_ScrollWidget::SetAutoResize(), PG_Widget::SetID(), PG_ScrollWidget::SetShiftOnRemove(), PG_Button::sigClick, PG_MessageObject::sigDelete, sigEditBegin, PG_LineEdit::sigEditBegin, sigEditEnd, PG_LineEdit::sigEditEnd, sigEditReturn, PG_LineEdit::sigEditReturn, and PG_ListBox::sigSelectItem.

PG_DropDown::~PG_DropDown  ) 
 

Definition at line 74 of file pgdropdown.cpp.

References my_DropList.


Member Function Documentation

void PG_DropDown::AddChild PG_Widget child  )  [virtual]
 

Add a clientwidget (which will be embedded into this widget).

Parameters:
child the widget to add

Reimplemented from PG_Widget.

Definition at line 84 of file pgdropdown.cpp.

References PG_ListBox::AddChild(), PG_Widget::AddChild(), my_DropButton, my_DropList, and my_EditBox.

void PG_DropDown::AddItem const std::string &  text,
void *  userdata = NULL,
Uint16  height = 0
 

Add a new item to the dropdown box.

Parameters:
text text of the new item
userdata pointer to userdefined data linked to the item.
height Height of the listbox item in pixels. If 0 the height will be calculated using the text height.

Reimplemented in DropDownSelector.

Definition at line 94 of file pgdropdown.cpp.

References PG_Widget::GetFont(), PG_FontEngine::GetTextSize(), and PG_String.

Referenced by DropDownSelector::AddItem(), AddWeatherAreaDialog::AddWeatherAreaDialog(), AddWindChangeDialog::AddWindChangeDialog(), EditPlayerData::EditPlayerData(), PG_PropertyField_DropDown< StringType, iterator >::PG_PropertyField_DropDown(), PG_PropertyField_IntDropDown< IntType, iterator >::PG_PropertyField_IntDropDown(), and WeatherDialog::WeatherDialog().

void PG_DropDown::DeleteAll  ) 
 

Delete (destroy) all widgets from the drop down.

Definition at line 113 of file pgdropdown.cpp.

References PG_ListBox::DeleteAll(), and my_DropList.

void PG_DropDown::eventHide  )  [protected, virtual]
 

overridable eventhandler called whenever the widget gets hidden.

Reimplemented from PG_Widget.

Definition at line 123 of file pgdropdown.cpp.

References PG_Widget::Hide(), and my_DropList.

void PG_DropDown::eventMoveWidget int  x,
int  y
[protected, virtual]
 

Callback for the MoveWidget event.

Parameters:
x new x position
y new y position This virtual function can be used to implement custom behavior for MoveWidget events.

Reimplemented from PG_Widget.

Definition at line 177 of file pgdropdown.cpp.

References PG_Widget::Hide(), PG_Widget::IsVisible(), and my_DropList.

bool PG_DropDown::eventSelectItem PG_ListBoxBaseItem item  )  [protected, virtual]
 

Definition at line 171 of file pgdropdown.cpp.

void PG_DropDown::eventShow  )  [protected, virtual]
 

overridable eventhandler called whenever the widget gets shown.

Reimplemented from PG_Widget.

Definition at line 118 of file pgdropdown.cpp.

References my_DropList, and PG_Widget::SetVisible().

void PG_DropDown::eventSizeWidget Uint16  w,
Uint16  h
[protected, virtual]
 

Callback for the SizeWidget event.

Parameters:
w new width
h new height This virtual function can be used to implement custom behavior for SizeWidget events.

Reimplemented from PG_Widget.

Definition at line 175 of file pgdropdown.cpp.

PG_Label::TextAlign PG_DropDown::GetAlignment  ) 
 

Returns the set alignment rule of this list.

Definition at line 240 of file pgdropdown.cpp.

References PG_ListBox::GetAlignment(), and my_DropList.

bool PG_DropDown::GetEditable  ) 
 

Check if the widget is editable by the user.

Returns:
true - widget is editable / false - widget is read only

Definition at line 159 of file pgdropdown.cpp.

References PG_LineEdit::GetEditable(), and my_EditBox.

PG_Widget * PG_DropDown::GetFirstInList  ) 
 

Definition at line 244 of file pgdropdown.cpp.

References PG_ScrollWidget::GetFirstInList(), and my_DropList.

Uint16 PG_DropDown::GetIndent  ) 
 

Returns the item indentation.

Definition at line 232 of file pgdropdown.cpp.

References PG_ListBox::GetIndent(), and my_DropList.

int PG_DropDown::GetSelectedItemIndex  ) 
 

Returns the index of the last selected item.

Definition at line 227 of file pgdropdown.cpp.

References PG_ListBox::GetSelectedIndex(), and my_DropList.

Referenced by PG_PropertyField_IntDropDown< IntType, iterator >::Apply(), and DropDownSelector::itemSelected().

const PG_String & PG_DropDown::GetText  )  [virtual]
 

Get the current text string.

Returns:
pointer to text string

Reimplemented from PG_Widget.

Definition at line 163 of file pgdropdown.cpp.

References PG_Widget::GetText(), and my_EditBox.

Referenced by PG_PropertyField_DropDown< StringType, iterator >::Apply().

bool PG_DropDown::handleButtonClick PG_Button button  )  [protected, virtual]
 

Definition at line 128 of file pgdropdown.cpp.

References PG_Application::GetScreenHeight(), PG_Application::GetScreenWidth(), PG_Widget::Hide(), IDDROPDOWN_BOX, PG_Widget::IsVisible(), PG_Widget::MoveWidget(), my_DropList, PG_Rect::my_height, PG_Rect::my_width, PG_Rect::my_xpos, PG_Rect::my_ypos, PG_MIN, and PG_Widget::Show().

Referenced by PG_DropDown().

void PG_DropDown::LoadThemeStyle const std::string &  widgettype  ) 
 

Load a style from the theme definition.

Parameters:
widgettype name of the widgettype
Loads the defined style for a given widgettype

Reimplemented from PG_Widget.

Definition at line 78 of file pgdropdown.cpp.

References PG_ScrollWidget::LoadThemeStyle(), PG_Button::LoadThemeStyle(), PG_LineEdit::LoadThemeStyle(), my_DropButton, my_DropList, and my_EditBox.

Referenced by PG_DropDown().

bool PG_DropDown::ProcessEvent const SDL_Event *  event,
bool  bModal
[virtual]
 

Process a native PG_ event.

Parameters:
event PG_ event to process
bModal set to true if processing takes place in a modal loop
Returns:
true if the event was sucessfully processed
ProcessEvent asks the widget to process a given event. It also asks its parent and, if bModal is true, its children.

Reimplemented from PG_Widget.

Definition at line 195 of file pgdropdown.cpp.

References PG_Widget::IsVisible(), my_DropList, and PG_Widget::ProcessEvent().

void PG_DropDown::RemoveAll  ) 
 

Remove all widgets from the drop down(without deletion).

Definition at line 108 of file pgdropdown.cpp.

References my_DropList, and PG_ListBox::RemoveAll().

void PG_DropDown::SelectFirstItem  ) 
 

Select the first item.

Definition at line 206 of file pgdropdown.cpp.

References my_DropList, and PG_ListBox::SelectFirstItem().

Referenced by DropDownSelector::AddItem().

void PG_DropDown::SelectItem const int  n  ) 
 

Select the n-th item.

Parameters:
n number of item to select

Definition at line 218 of file pgdropdown.cpp.

References my_DropList, PG_ListBox::SelectFirstItem(), and PG_ListBox::SelectNextItem().

Referenced by EditPlayerData::EditPlayerData(), EventEditor::EventEditor(), ExchangeGraphics::ExchangeGraphics(), PG_PropertyField_DropDown< StringType, iterator >::PG_PropertyField_DropDown(), PG_PropertyField_IntDropDown< IntType, iterator >::PG_PropertyField_IntDropDown(), Maped_MainScreenWidget::playerChanged(), and PG_PropertyField_IntDropDown< IntType, iterator >::Reload().

void PG_DropDown::SelectNextItem  ) 
 

Select the next item.

Definition at line 210 of file pgdropdown.cpp.

References my_DropList, and PG_ListBox::SelectNextItem().

void PG_DropDown::SelectPrevItem  ) 
 

Select the previous item.

Definition at line 214 of file pgdropdown.cpp.

References my_DropList, and PG_ListBox::SelectPrevItem().

void PG_DropDown::SetAlignment PG_Label::TextAlign  style  ) 
 

Set the item's alignment.

Parameters:
style alignment to be set for the item

Definition at line 236 of file pgdropdown.cpp.

References my_DropList, and PG_ListBox::SetAlignment().

void PG_DropDown::SetEditable bool  edit  ) 
 

Set if the widget is editable by the user.

Parameters:
edit true - widget is editable / false - widget is read only

Definition at line 155 of file pgdropdown.cpp.

References my_EditBox, and PG_LineEdit::SetEditable().

Referenced by DropDownSelector::DropDownSelector(), and SetDropDownAtts().

void PG_DropDown::SetIndent Uint16  indent  ) 
 

Set the item indentation.

Parameters:
indent number of pixels for item indentation (must be set before adding items)

Definition at line 151 of file pgdropdown.cpp.

References my_DropList, and PG_ListBox::SetIndent().

Referenced by SetDropDownAtts().

void PG_DropDown::SetText const std::string &  new_text  )  [virtual]
 

Set the current text string.

Parameters:
new_text pointer to text string

Reimplemented from PG_Widget.

Definition at line 167 of file pgdropdown.cpp.

References my_EditBox, and PG_LineEdit::SetText().

Referenced by PG_PropertyField_DropDown< StringType, iterator >::Reload().


Member Data Documentation

PG_Button* PG_DropDown::my_DropButton [protected]
 

Definition at line 208 of file pgdropdown.h.

Referenced by AddChild(), LoadThemeStyle(), and PG_DropDown().

PG_ListBox* PG_DropDown::my_DropList [protected]
 

Definition at line 210 of file pgdropdown.h.

Referenced by AddChild(), DeleteAll(), eventHide(), eventMoveWidget(), eventShow(), GetAlignment(), GetFirstInList(), GetIndent(), GetSelectedItemIndex(), handleButtonClick(), LoadThemeStyle(), PG_DropDown(), ProcessEvent(), RemoveAll(), SelectFirstItem(), SelectItem(), SelectNextItem(), SelectPrevItem(), SetAlignment(), SetIndent(), and ~PG_DropDown().

PG_LineEdit* PG_DropDown::my_EditBox [protected]
 

Definition at line 206 of file pgdropdown.h.

Referenced by AddChild(), GetEditable(), GetText(), LoadThemeStyle(), PG_DropDown(), SetEditable(), and SetText().

PG_LineEdit::SignalEditBegin PG_DropDown::sigEditBegin
 

Definition at line 182 of file pgdropdown.h.

Referenced by PG_DropDown().

PG_LineEdit::SignalEditEnd PG_DropDown::sigEditEnd
 

Definition at line 183 of file pgdropdown.h.

Referenced by PG_DropDown().

PG_LineEdit::SignalEditReturn PG_DropDown::sigEditReturn
 

Definition at line 184 of file pgdropdown.h.

Referenced by PG_DropDown().

SignalSelectItem PG_DropDown::sigSelectItem
 

Definition at line 180 of file pgdropdown.h.

Referenced by DropDownSelector::DropDownSelector().


The documentation for this class was generated from the following files:
Generated on Tue Jun 24 02:18:51 2008 for Advanced Strategic Command by  doxygen 1.4.2