00001 /* 00002 ParaGUI - crossplatform widgetset 00003 Copyright (C) 2000,2001,2002 Alexander Pipelka 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 Alexander Pipelka 00020 pipelka@teleweb.at 00021 00022 Last Update: $Author: mbickel $ 00023 Update Date: $Date: 2007-04-13 16:15:56 $ 00024 Source File: $Source: /home/cvspsrv/cvsroot/games/asc/source/libs/paragui/include/pgdropdown.h,v $ 00025 CVS/RCS Revision: $Revision: 1.2 $ 00026 Status: $State: Exp $ 00027 */ 00028 00033 #ifndef PG_DROPDOWN_H 00034 #define PG_DROPDOWN_H 00035 00036 #include "pgwidget.h" 00037 #include "pgsignals.h" 00038 #include "pglabel.h" 00039 #include "pglineedit.h" 00040 00041 class PG_Button; 00042 class PG_LineEdit; 00043 class PG_ListBox; 00044 class PG_ListBoxBaseItem; 00045 00055 class DECLSPEC PG_DropDown : public PG_Widget { 00056 public: 00057 00061 template<class datatype = PG_Pointer> 00062 class SignalSelectItem : public PG_Signal1<PG_ListBoxBaseItem*, datatype> {} 00063 ; 00064 00065 enum { 00066 IDDROPDOWN_BOX = PG_WIDGETID_INTERNAL + 11 00067 }; 00068 00076 PG_DropDown(PG_Widget* parent, const PG_Rect& r = PG_Rect::null, int id = -1, const std::string& style="DropDown"); 00077 00079 ~PG_DropDown(); 00080 00082 void LoadThemeStyle(const std::string& widgettype); 00083 00091 void AddItem(const std::string& text, void* userdata = NULL, Uint16 height = 0); 00092 00096 void RemoveAll(); 00097 00101 void DeleteAll(); 00102 00106 void SetIndent(Uint16 indent); 00107 00109 Uint16 GetIndent(); 00110 00115 void SetEditable(bool edit); 00116 00121 bool GetEditable(); 00122 00127 const PG_String& GetText(); 00128 00133 void SetText(const std::string& new_text); 00134 00136 bool ProcessEvent(const SDL_Event * event, bool bModal); 00137 00141 void SelectFirstItem(); 00142 00143 00147 int GetSelectedItemIndex(); 00148 00152 void SelectNextItem(); 00153 00157 void SelectPrevItem(); 00158 00163 void SelectItem(const int n); 00164 00169 void SetAlignment(PG_Label::TextAlign style); 00170 00174 PG_Label::TextAlign GetAlignment(); 00175 00176 PG_Widget* GetFirstInList(); 00177 00178 void AddChild(PG_Widget* child); 00179 00180 SignalSelectItem<> sigSelectItem; 00181 00182 PG_LineEdit::SignalEditBegin<> sigEditBegin; 00183 PG_LineEdit::SignalEditEnd<> sigEditEnd; 00184 PG_LineEdit::SignalEditReturn<> sigEditReturn; 00185 00186 protected: 00187 00189 void eventShow(); 00190 00192 void eventHide(); 00193 00195 virtual bool handleButtonClick(PG_Button* button); 00196 00198 void eventSizeWidget(Uint16 w, Uint16 h); 00199 00201 void eventMoveWidget(int x, int y); 00202 00204 virtual bool eventSelectItem(PG_ListBoxBaseItem* item); 00205 00206 PG_LineEdit* my_EditBox; 00207 00208 PG_Button* my_DropButton; 00209 00210 PG_ListBox* my_DropList; 00211 00212 private: 00213 bool onDropListDeletion( const PG_MessageObject* dropList ); 00214 00215 DLLLOCAL bool select_handler(PG_ListBoxBaseItem* item); 00216 00217 }; 00218 00219 #endif // PG_DROPDOWN_H
1.4.2