00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _ulistbox_hpp_
00021 #define _ulistbox_hpp_
00022
00023 #include <ubit/utextbox.hpp>
00024 #include <ubit/uchoice.hpp>
00025 namespace ubit {
00026
00027
00028
00092 class UListbox: public UBox {
00093 public:
00094 UBIT_ELEMENT_CLASS(UListbox, UBox)
00095
00096 UListbox(const UArgs& args = UArgs::none);
00098
00099 friend UListbox& ulistbox(const UArgs& args = UArgs::none) {return *new UListbox(args);}
00101
00102
00103
00104 bool isTransparent() const {return transp_style;}
00105 UListbox& setTransparent(bool s = true) {transp_style = s; return *this;}
00106
00107 UChoice& choice() {return *pchoice;}
00108 const UChoice& choice() const {return *pchoice;}
00110
00111 virtual UBox* getSelectedItem() const;
00113
00114 virtual void setSelectedItem(UBox&);
00116
00117 virtual int getSelectedIndex() const;
00119
00120 virtual void setSelectedIndex(int n);
00122
00123 virtual UListbox& addItem(const UStr& string);
00124 virtual UListbox& addItem(UStr& string, bool duplicate);
00137 virtual UListbox& addItems(const UStr& strings, const UStr& separ = ",");
00138 virtual UListbox& addItems(const UArgs& prefix, const UStr& strings, const UStr& separ = ",");
00148 virtual UListbox& addItems(const char* items[]);
00149 virtual UListbox& addItems(const std::vector<UStr*>& items, bool duplicate = true);
00150 virtual UListbox& addItems(const UArgs& prefix, const char* items[]);
00151 virtual UListbox& addItems(const UArgs& prefix, const std::vector<UStr*>& items,
00152 bool duplicate = true);
00159 static UStyle* createStyle();
00160
00161 protected:
00162 uptr<UChoice> pchoice;
00163 bool transp_style;
00164 };
00165
00166
00167
00193 class UCombobox : public UTextfield {
00194 public:
00195 UBIT_ELEMENT_CLASS(UCombobox, UTextfield)
00196
00197 UCombobox(UListbox&, const UArgs& = UArgs::none);
00198
00199
00200
00201
00202
00203
00204 friend UCombobox& ucombobox(UListbox&, const UArgs& a = UArgs::none);
00205
00206
00207
00208
00209 virtual bool isEditable() const;
00210 virtual UCombobox& setEditable(bool state = true);
00212
00213 bool isTextMode() const {return text_only;};
00214 UCombobox& setTextMode(bool = true);
00216
00217 UListbox& list() {return *plist;}
00218 class UChoice& choice();
00219 UGroup& entry() {return *pentry;}
00220 UEdit& edit() {return *pedit;}
00221 UMenu& menu() {return *pmenu;}
00223
00224 static UStyle* createStyle();
00225
00226 protected:
00227 virtual void changed(class UEvent&);
00228 virtual void action(class UEvent&);
00229 virtual void openMenu(UEvent&);
00230 virtual void syncText();
00231
00232 private:
00233 uptr<UListbox> plist;
00234 uptr<UGroup> pentry;
00235 uptr<class UMenu> pmenu;
00236 bool text_only;
00237
00238 friend class UCombobox::Class;
00239 UCombobox(const UArgs& = UArgs::none);
00240 void constructs(const UArgs&);
00241 };
00242
00243 }
00244 #endif
00245
00246
00247