00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GUIDROPDOWN_H
00023 #define GUIDROPDOWN_H
00024
00025 #include "guilist.h"
00026
00033 class GuiList;
00034 class GuiText;
00035 class GuiTextInput;
00036 class GuiClickableBtn;
00037 class UiTheme;
00038
00045 class DECLSPEC GuiDropDown : public GuiElement
00046 {
00047 public:
00055 DECLSPEC GuiDropDown( const SDL_Rect &r, GuiElement *p, const char *name, bool editable = false );
00062 DECLSPEC GuiDropDown(TiXmlElement *el, GuiElement *p);
00063 virtual DECLSPEC ~GuiDropDown();
00064
00065 virtual const char *getClassName() { return "GuiDropDown"; }
00069 DECLSPEC void destroy();
00075 void setCallback( Callback c, BasicObject *d ) { cb.func = c; cb.obj = d; }
00076
00082 int insertStr( const char* str, int pos = -1 ) { return gList->insertStr( str, pos ); }
00088 bool clearStr( int pos = -1 ) { return gList->clearStr( pos ); }
00092 void clearAll() { gList->clearAll(); }
00099 bool changeStr( const char *newstr, int pos ) { return gList->changeStr( newstr, pos ); }
00104 const char *getStr( int pos ) const { return gList->getStr( pos ); }
00108 const char *getSelStr() const { return gList->getSelStr(); }
00112 const char *getString() const;
00116 int getSelId() const { gList->getSelId(); }
00120 int getCount() const { gList->getCount(); }
00121
00126 void setSelected(int i) { gList->setSelected( i );}
00127
00128 static void newguiobject(void *presult, BasicObject *o, void *xmldata)
00129 {
00130 GuiElement *r = new GuiDropDown((TiXmlElement*)xmldata, (GuiElement*)o);
00131 *(GuiElement**)presult = r;
00132 }
00133 protected:
00134 virtual DECLSPEC Uint32 onResize();
00135 virtual DECLSPEC void onInit();
00136 virtual DECLSPEC Uint32 onThemeChanged( UiTheme *t );
00137
00138 private:
00139 void onButton();
00140 void onList();
00141
00142 GuiList *gList;
00143 GuiText *gText;
00144 GuiTextInput *gtInput;
00145 GuiCheckableBtn *gcButton;
00146 GuiPictureBg *gpBg;
00147
00148 FunctionData cb;
00149
00150 static void onButton( void *sender, BasicObject *data, void* )
00151 {
00152 ((GuiDropDown*)data)->onButton();
00153 }
00154 static void onList( void *sender, BasicObject *data, void* )
00155 {
00156 ((GuiDropDown*)data)->onList();
00157 }
00158 };
00159
00160 #endif