00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _uchoice_hpp_
00021 #define _uchoice_hpp_
00022
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
00112 #ifndef NO_DOC
00113
00114 virtual void putProp(UContext*, UControl*);
00115 virtual void addingTo(UChild*, UGroup *parent);
00116
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
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
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
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
00222