ulistbox.hpp

00001 /* ==================================================== ======== ======= *
00002 *
00003 *  ulistbox.hpp
00004 *  Ubit Project
00005 *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00006 *  (C) 1999-2006 / Eric Lecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00007 *
00008 * ***********************************************************************
00009 * COPYRIGHT NOTICE : 
00010 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00011 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00012 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00013 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00014 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00015 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00016 * ***********************************************************************
00017 * ==================================================== [(c)Elc] ======= *
00018 * ==================================================== ======== ======= */
00019 
00020 #ifndef _ulistbox_hpp_
00021 #define _ulistbox_hpp_
00022 //pragma ident  "@(#)ulistbox.hpp       ubit:05.05.00"
00023 #include <ubit/utextbox.hpp>
00024 #include <ubit/uchoice.hpp>
00025 namespace ubit {
00026   
00027 /* ==================================================== [Elc] ======= */
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 /* ==================================================== [Elc] ======= */
00167 /* ==================================================== ===== ======= */
00193 class UCombobox : public UTextfield  {
00194 public:
00195   UBIT_ELEMENT_CLASS(UCombobox, UTextfield)
00196 
00197   UCombobox(UListbox&, const UArgs& = UArgs::none);
00198   /* creates a combobox.
00199   * arguments:
00200   * - 1st arg: the UListbox that is displayed in the menu
00201   * - 2nd arg: a standard arglist (callback specs should be added here)
00202   */
00203   
00204   friend UCombobox& ucombobox(UListbox&, const UArgs& a = UArgs::none);
00205   // shortcut that returns *new UCombobox(listbox, args);
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;}    // inherited
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 /* ==================================================== [TheEnd] ======= */
00246 /* ==================================================== [(c)Elc] ======= */
00247 

Generated on Mon Jan 29 00:20:39 2007 for Ubit by  doxygen 1.4.7