00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _ucontrol_hpp_
00022 #define _ucontrol_hpp_
00023
00024 #include <ubit/ubrick.hpp>
00025 #include <ubit/umode.hpp>
00026 #include <ubit/update.hpp>
00027 namespace ubit {
00028
00035 class UControl: public UBrick {
00036 public:
00037 UControl();
00039
00040 virtual void update(const UUpdate&) = 0;
00042
00043 virtual void update() {update(UUpdate::layoutAndPaint);}
00045
00046 virtual void updatePaint() {update(UUpdate::paint);}
00048
00049 virtual void updateView(UEvent&, UView*, const UUpdate&) = 0;
00054 virtual bool isShown() const;
00063 bool isShowable() const {return (cmodes & UMode::CAN_SHOW) != 0;}
00071 bool isEnabled() const;
00078 virtual void setEnabled(bool state, bool call_callbacks = true);
00084 void enable(bool state = true) {setEnabled(state);}
00085 void disable() {setEnabled(false);}
00086
00087 bool isSelected() const {return (cmodes & UMode::SELECTED) != 0;}
00093 virtual void setSelected(bool state, bool call_callbacks = true);
00099 void select(bool state, bool call_cb = true) {setSelected(state,call_cb);}
00101
00102 bool isArmed() const;
00103
00104 bool isArmable() const {return (cmodes & UMode::CAN_ARM) != 0;}
00113 bool isEntered() const;
00114 bool isActionPerformed() const;
00115 bool isDragged() const;
00116
00117
00118
00119
00120
00121 UMask getCModes() const {return cmodes;}
00123
00124 bool hasCMode(UMask modes) const {return (cmodes & modes) != 0;}
00126
00127 void addCModes(UMask modes) {cmodes |= modes;}
00129
00130 void removeCModes(UMask modes) {cmodes &= ~modes;}
00132
00133 short getInterState() const {return istate;}
00135
00136 void setInterState(short);
00138
00139
00140 protected:
00141 friend class UMode;
00142 friend class UOn;
00143 friend class UAppli;
00144 friend class UEventFlow;
00145 UMask cmodes;
00146 short istate;
00147
00148 public:
00149 enum InputType {NORMAL=0, BROWSE=1, TYPE=2};
00150
00151 virtual void enterBehavior(UEventFlow&, UEvent&, int input_type = 0);
00152 virtual void leaveBehavior(UEventFlow&, UEvent&);
00153 virtual void keyPressBehavior(UEventFlow&, UEvent&);
00154 virtual void keyReleaseBehavior(UEventFlow&, UEvent&);
00155 virtual void armBehavior(UEventFlow&, UEvent&, int input_type = 0);
00156 virtual bool disarmBehavior(UEventFlow&, UEvent&, int input_type = 0);
00157 virtual void actionBehavior(UEventFlow&, UEvent&);
00158 virtual void changeBehavior(UEventFlow&, UEvent&);
00165 };
00166
00167 }
00168 #endif
00169
00170
00171
00172