00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _upiemenu_hpp_
00022 #define _upiemenu_hpp_
00023 #include <ubit/umenu.hpp>
00024 #include <ubit/uboxGeom.hpp>
00025 namespace ubit {
00026
00027
00071 class UPiemenu : public UPopmenu {
00072 public:
00073 UBIT_ELEMENT_CLASS(UPiemenu, UPopmenu)
00074
00075 UPiemenu(const UArgs& = UArgs::none);
00076 virtual ~UPiemenu();
00077
00078 friend UPiemenu& upiemenu(const UArgs& a = UArgs::none) {return *new UPiemenu(a);}
00079
00080
00081
00082 virtual UBox* item(int n);
00089 virtual UBox* getItem(int n) const;
00096 virtual UBox* getSelectedItem() const;
00098
00099 virtual int getSelectedIndex() const;
00101
00102 virtual UBox* createItem();
00104
00105
00106
00107 virtual void open(UMouseEvent& e) {show(e);}
00109
00110 virtual void show(bool state, UDisp*);
00111 virtual void show(bool state = true) {UPiemenu::show(state,null);}
00113
00114 virtual void show(UMouseEvent& e, float x = 0, float y = 0)
00115 {UPiemenu::show(e, x, y, show_delay);}
00121 virtual void show(UMouseEvent&, float x, float y, UTime delay);
00127 UTime getShowDelay() const {return show_delay;}
00129
00130 void setShowDelay(UTime d) {show_delay = d;}
00132
00133
00134
00135 enum MenuStyle {CONCENTRIC, COMPOUND, MULTISTROKE};
00136 void setMenuStyle(int);
00137
00138 virtual void addSubMenu(int N, UPiemenu* submenu);
00140
00141
00142
00143 void setPieAlpha(UAlpha& a) {pie_alpha = a;}
00144 void setPieColor(UColor& c) {pie_color = c;}
00145 void setPieBorderColor(UColor& c) {pie_border_color = c;}
00146 void setSliceColor(UColor& c) {slice_color = c;}
00147 void setCenterColor(UColor& c) {center_color = c;}
00148 void setCenterBorderColor(UColor& c) {center_border_color = c;}
00154 int getCenterRadius() const {return center_radius;}
00156
00157 void setCenterRadius(int d) {center_radius = d;}
00162 int getItemRadius() const {return item_radius;}
00164
00165 void setItemRadius(int d) {item_radius = d;}
00167
00168 UWin* getContainingWin(UDisp* = null) const;
00170
00171 UPoint getCenterInContainingWin(UDisp* = null) const;
00173
00174 const UPoint& getLastDrag() const {return last_drag;}
00176
00177
00178
00179 UScale* getScale();
00180 float getScaleValue();
00181
00182 virtual void pressCB(UMouseEvent&);
00184
00185 virtual void releaseCB(UMouseEvent&);
00187
00188 virtual void motionCB(UMouseEvent&);
00190
00191 virtual void hideCB(UEvent&);
00193
00194 virtual void paintCB(UPaintEvent&);
00196
00197 virtual void resizeCB(UEvent&);
00199
00200 virtual void armItemCB(UMouseEvent& e, UPiemenu* submenu);
00202
00203 virtual void disarmItemCB(UMouseEvent& e, UPiemenu* submenu);
00205
00206 virtual float getCentredCoords(UMouseEvent& e, UPoint& p, bool& must_forward);
00208
00209 virtual void reset(UMouseEvent*);
00211
00212 virtual void startNoviceMode();
00214
00215 virtual void forwardToMenu(UPiemenu* submenu);
00217
00218 virtual void receiveFromMenu(UPiemenu* supermenu);
00220
00221 virtual void unlinkFromAndToMenus();
00223
00224 virtual void closeMenus(UMouseEvent& e, bool);
00226
00227 static UStyle* createStyle();
00228
00229 #ifndef NO_DOC
00230 protected:
00231 unsigned short submenu_layout;
00232 unsigned short ctlmenu_mode:1, novice_mode:1, in_show_function:1, entered:1;
00233 short center_radius, item_radius, item_margin;
00234 short curitem;
00235 UPoint last_arm, last_drag;
00236 UTime show_delay;
00237 uptr<UTimer> ptimer;
00238 uptr<UBox> parmed;
00239 UPiemenu *from_menu, *to_menu;
00240 UGroup gitems;
00241 UWidth width;
00242 UHeight height;
00243 uptr<UAlpha> pie_alpha;
00244 uptr<UColor> pie_color, center_color, slice_color, pie_border_color, center_border_color;
00245 #endif
00246 };
00247
00248 }
00249 #endif
00250
00251