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

PG_DropDown Class Reference

Inheritance diagram for PG_DropDown:

Inheritance graph
[legend]
Collaboration diagram for PG_DropDown:

Collaboration graph
[legend]
List of all members.

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.

Examples:

paratest.cpp.


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 char *style="DropDown")
 Construct a PG_DropDown object.

 ~PG_DropDown ()
void LoadThemeStyle (const char *widgettype)
 Load a style from the theme definition.

void AddItem (const char *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 char * GetText ()
 Get the current text string.

void SetText (const char *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.

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.

void AddChild (PG_Widget *child)
 Add a clientwidget (which will be embedded into this widget).


Public Attributes

SignalSelectItem sigSelectItem

Protected Member Functions

void eventShow ()
 overridable eventhandler called whenever the widget gets shown.

void eventHide ()
 overridable eventhandler called whenever the widget gets hidden.

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)
bool select_handler (PG_ListBoxBaseItem *item)

Protected Attributes

PG_LineEditmy_EditBox
PG_Buttonmy_DropButton
PG_ListBoxmy_DropList


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
IDDROPDOWN_BOX 


Constructor & Destructor Documentation

PG_DropDown::PG_DropDown PG_Widget parent,
const PG_Rect r = PG_Rect::null,
int  id = -1,
const char *  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)

PG_DropDown::~PG_DropDown  ) 
 


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.

void PG_DropDown::AddItem const char *  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.
Examples:
paratest.cpp.

void PG_DropDown::DeleteAll  ) 
 

Delete (destroy) all widgets from the drop down.

void PG_DropDown::eventHide  )  [protected, virtual]
 

overridable eventhandler called whenever the widget gets hidden.

Reimplemented from PG_Widget.

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.

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

void PG_DropDown::eventShow  )  [protected, virtual]
 

overridable eventhandler called whenever the widget gets shown.

Reimplemented from PG_Widget.

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.

PG_Label::TextAlign PG_DropDown::GetAlignment  ) 
 

Returns the set alignment rule of this list.

bool PG_DropDown::GetEditable  ) 
 

Check if the widget is editable by the user.

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

Uint16 PG_DropDown::GetIndent  ) 
 

Returns the item indentation.

const char* PG_DropDown::GetText  )  [virtual]
 

Get the current text string.

Returns:
pointer to text string

Reimplemented from PG_Widget.

bool PG_DropDown::handleButtonClick PG_Button button  )  [protected]
 

void PG_DropDown::LoadThemeStyle const char *  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.

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.

Reimplemented from PG_Widget.

void PG_DropDown::RemoveAll  ) 
 

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

bool PG_DropDown::select_handler PG_ListBoxBaseItem item  )  [protected]
 

void PG_DropDown::SelectFirstItem  ) 
 

Select the first item.

void PG_DropDown::SelectItem const int  n  ) 
 

Select the n-th item.

Parameters:
n number of item to select

void PG_DropDown::SelectNextItem  ) 
 

Select the next item.

void PG_DropDown::SelectPrevItem  ) 
 

Select the previous item.

void PG_DropDown::SetAlignment PG_Label::TextAlign  style  ) 
 

Set the item's alignment.

Parameters:
style alignment to be set for the item
Examples:
paratest.cpp.

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

void PG_DropDown::SetIndent Uint16  indent  ) 
 

Set the item indentation.

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

void PG_DropDown::SetText const char *  new_text  )  [virtual]
 

Set the current text string.

Parameters:
new_text pointer to text string

Reimplemented from PG_Widget.


Member Data Documentation

PG_Button* PG_DropDown::my_DropButton [protected]
 

PG_ListBox* PG_DropDown::my_DropList [protected]
 

PG_LineEdit* PG_DropDown::my_EditBox [protected]
 

SignalSelectItem PG_DropDown::sigSelectItem
 



The ParaGUI Project - Alexander Pipelka