uchoice.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  uchoice.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
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 _uchoice_hpp_
00021 #define _uchoice_hpp_
00022 //pragma ident  "@(#)uchoice.hpp        ubit:05.05.00"
00023 #include <ubit/uprop.hpp>
00024 namespace ubit {
00025 
00026 /* ==================================================== ===== ======= */
00029 class UChoice : public UProp {
00030 public:
00031   UBIT_ATTR_CLASS(UChoice, UProp)
00032 
00033   UChoice();  
00035 
00036   friend UChoice& uchoice() {return *new UChoice;}
00038   
00039   virtual ~UChoice();
00040       
00041   virtual void clearSelection();
00043   
00044   virtual UBox* getSelectedItem() const;
00046   
00047   virtual UBox* setSelectedItem(UBox& obj);
00049   
00050   virtual int getSelectedIndex() const;
00057   virtual UBox* setSelectedIndex(int N);
00065   virtual UBox* getSelectableItem(int N) const;
00072   virtual UBox* getSelectableItem(const UStr& s, bool ignore_case = true) const;
00079   enum {
00080     NO_SELECTION, SINGLE_SELECTION, 
00081     SINGLE_INTERVAL_SELECTION, MULTIPLE_INTERVAL_SELECTION
00082   };
00083   virtual int getSelectionMode() const {return sel_mode;}
00084   virtual void setSelectionMode(int);
00089   enum {SELECT_ON_ARM = 1<<0, SELECT_ON_DISARM = 1<<1, SELECT_ON_DRAG = 1<<2};
00090   virtual int getSelectionStyle() const {return sel_style;}
00091   virtual void setSelectionStyle(int);
00097   struct IsSelectable {
00098     virtual bool operator()(const UBox*) const;
00099     virtual ~IsSelectable() {}
00100   };
00101   
00102   virtual void setSelectionRule(IsSelectable&);
00109   virtual void update();  
00110 
00111   // - - - impl - -  - - - - - - - - - - - - - - - - - - - - - - - - - - -
00112 #ifndef NO_DOC
00113 
00114   virtual void putProp(UContext*, UControl*);
00115   virtual void addingTo(UChild*, UGroup *parent);
00116   // NB: removingFrom() requires a destructor to be defined
00117   virtual void removingFrom(UChild*, UGroup *parent);
00118 
00119 protected:
00120   uptr<UCall>  callbacks;
00121   uptr<UBox>   container;
00122   uptr<UGroup> last_browsing_group;
00123   uptr<UGroup> sel_items;
00124   IsSelectable*is_selectable;
00125   short sel_mode, sel_style;
00126   
00127   virtual void mouseCB(UEvent&);
00128   virtual void actionCB(UEvent*);
00129   virtual void changeCB(UEvent*);
00130   virtual void changed(bool update = true);
00131   virtual UBox* setSelectedItemImpl(UBox* item, UEvent*);
00132   virtual UBox* getSelectedItemImpl() const;
00133 #endif
00134 };
00135 
00136 /* ==================================================== [Elc] ======= */
00137 /* ==================================================== ===== ======= */
00151 class URadioSelect : public UProp {
00152 public:
00153   UBIT_ATTR_CLASS(URadioSelect,UProp)
00154 
00155   URadioSelect();
00156   URadioSelect(UInteger& index);
00164   friend URadioSelect& uradioSelect() {return *new URadioSelect;}
00166 
00167   virtual ~URadioSelect();
00168   
00169   virtual void setCanUnselectMode(bool);
00170   virtual bool isCanUnselectMode() const;
00172 
00173   virtual void clearSelection();
00175 
00176   virtual UGroup* getSelectedItem() const;
00178 
00179   virtual void setSelectedItem(UGroup&);
00181 
00182   UInteger& index() const {return *pindex;}
00183   virtual int getSelectedIndex() const;
00185 
00186   virtual void setSelectedIndex(int n);
00187   virtual void setSelectedIndex(const UInteger& n);
00189 
00190   virtual void update();
00191 
00192   // - - impl  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00193 #ifndef NO_DOC
00194 
00195   virtual void changed(bool update = true);
00196   virtual void changed(UGroup* target);
00204   virtual void putProp(UContext*, UControl*);
00205   virtual void addingTo(UChild*, UGroup *parent);
00206   // NB: removingFrom() requires a destructor to be defined
00207   virtual void removingFrom(UChild*, UGroup *parent);
00208   
00209 protected:
00210   bool can_unselect_mode;
00211   uptr<UInteger> pindex;
00212   uptr<UCall> pselect_callback;
00213   void itemChanged(UEvent&);
00214   void setIndexImpl();
00215   void _selectItem(UGroup*);
00216 #endif
00217 };
00218 
00219 }
00220 #endif
00221 /* ==================================================== [TheEnd] ======= */
00222 /* ==================================================== [(c)Elc] ======= */

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