00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "dropdownselector.h"
00018
00019
00020 DropDownSelector::DropDownSelector( PG_Widget *parent, const PG_Rect &r, int itemnum, const char** items, const std::string &style )
00021 : PG_DropDown( parent, r, -1, style ), first(true)
00022 {
00023 SetEditable(false);
00024 sigSelectItem.connect( SigC::slot( *this, &DropDownSelector::itemSelected ));
00025
00026 for ( int i = 0; i < itemnum; ++i )
00027 AddItem( items[i] );
00028
00029 }
00030
00031
00032 DropDownSelector::DropDownSelector( PG_Widget *parent, const PG_Rect &r, const std::vector<ASCString>& names, const std::string &style )
00033 : PG_DropDown( parent, r, -1, style ), first(true)
00034 {
00035 SetEditable(false);
00036 sigSelectItem.connect( SigC::slot( *this, &DropDownSelector::itemSelected ));
00037
00038 for ( std::vector<ASCString>::const_iterator i = names.begin(); i != names.end(); ++i )
00039 AddItem( *i );
00040 }
00041
00042
00043
00044 DropDownSelector::DropDownSelector( PG_Widget *parent, const PG_Rect &r, int id, const std::string &style)
00045 : PG_DropDown( parent, r, id, style ), first(true)
00046 {
00047 SetEditable(false);
00048 sigSelectItem.connect( SigC::slot( *this, &DropDownSelector::itemSelected ));
00049 }
00050
00051 bool DropDownSelector::itemSelected( )
00052 {
00053 selectionSignal( GetSelectedItemIndex ());
00054 return true;
00055 }
00056
00057
00058 void DropDownSelector::AddItem (const std::string &text, void *userdata, Uint16 height)
00059 {
00060 PG_DropDown::AddItem( text, userdata, height );
00061 if ( first ) {
00062 first = false;
00063 SelectFirstItem();
00064 }
00065 }
00066
00067