00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _uevent_hpp_
00022 #define _uevent_hpp_
00023
00024 #include <ubit/udefs.hpp>
00025 #include <ubit/uchild.hpp>
00026 #include <ubit/ueventImpl.hpp>
00027 namespace ubit {
00028
00029
00032 class UEvent : public UEventImpl {
00033 public:
00034 enum {ShiftButton = 1<<0, ControlButton = 1<<2};
00036
00037 enum {LeftButton = 1<<8, MidButton = 1<<9, RightButton = 1<<10};
00039
00040 enum {MButton1 = LeftButton, MButton2 = MidButton, MButton3 = RightButton};
00042
00043 virtual UInputEvent* inputEvent() {return null;}
00044 virtual UMouseEvent* mouseEvent() {return null;}
00045 virtual UKeyEvent* keyEvent() {return null;}
00046 virtual UWheelEvent* wheelEvent() {return null;}
00047 virtual UPaintEvent* paintEvent() {return null;}
00048 virtual UMessageEvent* messageEvent() {return null;}
00050
00051 const UCond& getCond() const {return *cond;}
00056 UGroup* getSource() const;
00058
00059 UView* getView() const {return sourceView;}
00065 UView* getParentView() const;
00067
00068 UBrick* getTarget() const;
00075 UWin* getWin() const;
00077
00078 UView* getWinView() const;
00080
00081 UEventFlow* getFlow() const {return eflow;}
00088 int getFlowID() const;
00094 UDisp* getDisp() const;
00101 UNatDisp* getNatDisp() const;
00103
00104 USysEvent getSysEvent() const {return sys_event;}
00106
00107 UTime getWhen() const;
00109
00110
00111
00112
00113 bool isConsumed() const {return is_consumed;}
00114 void consume() {is_consumed = true;}
00121 bool isIgnored() const {return is_ignored;}
00122 void ignore() {is_ignored = true;}
00128 void addFlagdef(const UFlagdef*);
00130
00131 const UFlagdef* getFlagdef(const UFlag&) const;
00133
00134 const UPropdef* getPropdef(const UFlag&) const;
00136
00137
00138
00139
00140
00141
00142
00143 UEvent(UEventFlow* = null, UView* hardwin_view = null, USysEvent = null,
00144 UTime = 0, const UCond* = null);
00149 UEvent(UBrick* source);
00153 private:
00154 friend class UEventFlow;
00155 friend class UControl;
00156 friend class UGroup;
00157 friend class UView;
00158 };
00159
00160
00163 class UInputEvent : public UEvent {
00164 public:
00165 virtual UInputEvent* inputEvent() {return this;}
00166
00167 int getState() const;
00179 int getButtonState() const;
00181
00182 bool isShiftDown() const;
00183 bool isControlDown() const;
00184 bool isAltDown() const;
00185 bool isAltGraphDown() const;
00186 bool isMetaDown() const;
00188
00189 virtual bool setPosAndSource(int x_hardwin, int y_hardwin);
00196 UInputEvent(UEventFlow* f, UView* v, USysEvent e, UTime t, const UCond& c)
00197 : UEvent(f,v,e,t,&c) {}
00198 };
00199
00200
00203 class UMouseEvent : public UInputEvent {
00204 public:
00205 virtual UMouseEvent* mouseEvent() {return this;}
00206
00207 int getX() const;
00208 int getY() const;
00210
00211 int getXwin() const {return xmouse;}
00212 int getYwin() const {return ymouse;}
00214
00215 int getXscreen() const;
00216 int getYscreen() const;
00218
00219 virtual int getButton() const;
00236 virtual int getClickCount() const;
00238
00239 virtual bool isBrowsing() const {return is_browsing;}
00240 virtual bool isFirstDrag() const;
00241
00242 virtual UData* getData();
00243 virtual UStr* getStr();
00244 virtual UData* getData(UDataProps&);
00245 virtual UStr* getStr(UDataProps&);
00255 int getButtons() const;
00257
00258 UMouseEvent(UEventFlow* f, UView* v, USysEvent e, UTime t, const UCond& c)
00259 : UInputEvent(f,v,e,t,c) {}
00260 };
00261
00262
00265 class UKeyEvent : public UInputEvent {
00266 public:
00267 virtual UKeyEvent* keyEvent() {return this;}
00268
00269 virtual unsigned short getKeyChar() const;
00271
00272 virtual unsigned long getKeyCode() const;
00274
00275 virtual void setKeyChar(unsigned short);
00280 virtual void setKeyCode(unsigned long);
00282
00283 virtual int decodeKey();
00284
00285
00286 UKeyEvent(UEventFlow* f, UView* v, USysEvent e, UTime t, const UCond& c)
00287 : UInputEvent(f,v,e,t,c) {}
00288 };
00289
00290
00293 class UWheelEvent : public UInputEvent {
00294 public:
00295 enum {WHEEL_DELTA = 120};
00296
00297 virtual UWheelEvent* wheelEvent() {return this;}
00298
00299 virtual int getWheelDelta() const;
00307 UWheelEvent(UEventFlow* f, UView* v, USysEvent e, UTime t, const UCond& c)
00308 : UInputEvent(f,v,e,t,c) {}
00309 };
00310
00311
00314 class UPaintEvent : public UEvent {
00315 public:
00316 virtual UPaintEvent* paintEvent() {return this;}
00317
00318 UPaintEvent(UEventFlow*, UView* hardwin_view, USysEvent);
00319 };
00320
00321
00325 class UMessageEvent : public UEvent {
00326 public:
00327 virtual UMessageEvent* messageEvent() {return this;}
00328
00329 const UStr* getMessage() const;
00330 UMessagePort* getMessagePort() const;
00331
00332 UMessageEvent(UEventFlow* f, UView* v, USysEvent e);
00333 };
00334
00335
00336
00340 struct UDataProps {
00341 UDataProps();
00342 ~UDataProps();
00343
00344 UData* data;
00345
00346 UChildIter dataIter, endIter;
00351 URegion region;
00358 bool exactMatch;
00363 int strpos, strpos2;
00365
00366 UWinContext* winContext;
00367 UContext* dataContext;
00372 int getX(UEvent*);
00373 int getY(UEvent*);
00378 int getWidth();
00379 int getHeight();
00381
00382
00383
00384 void set(UContext&, UData*,
00385 UChildIter data_iter, UChildIter end_iter,
00386 const URegion&, int _strpos, bool exact_match);
00387
00388 void merge(UContext&, UData*,
00389 UChildIter data_iter, UChildIter end_iter,
00390 const URegion&, bool exact_match);
00392 };
00393
00394 }
00395 #endif
00396
00397