Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

uevent.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  uevent.hpp
00004  *  Ubit Project  [Elc][2003]
00005  *  Author: Eric Lecolinet
00006  *
00007  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00008  *
00009  *  (C) 1999-2003 Eric Lecolinet @ ENST Paris
00010  *  WWW: http://www.enst.fr/~elc/ubit   Email: elc@enst.fr (subject: ubit)
00011  *
00012  * ***********************************************************************
00013  * COPYRIGHT NOTICE : 
00014  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00015  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00016  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00017  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00018  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00019  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00020  * ***********************************************************************
00021  *
00022  * ==================================================== [Elc:03] ======= *
00023  * ==================================================== ======== ======= */
00024 
00025 #ifndef _uevent_hpp_
00026 #define _uevent_hpp_
00027 //pragma ident  "@(#)uevent.hpp ubit:03.05.03"
00028 #include <ubit/udefs.hpp>
00029 
00032 typedef union _XEvent* UX_Event; 
00033 
00034 /* ==================================================== ======== ======= */
00035 
00038 struct URegion {
00039   u_pos x, y;
00040   u_dim width, height;
00041  
00042   URegion() {};
00043   URegion(const URegion& r) {*this = r;}
00044   URegion(u_pos rx, u_pos ry, u_dim rwidth, u_dim rheight) {
00045     x = rx; y = ry; width = rwidth; height = rheight;
00046   }
00047 
00048   void set(const URegion& r) {*this = r;}
00049   void set(u_pos rx, u_pos ry, u_dim rwidth, u_dim rheight) {
00050     x = rx; y = ry; width = rwidth; height = rheight;
00051   }
00052   
00053   // effectue l'intersection de this avec clip
00054   // this est mis a jour (contient l'intersection), clip ne change pas.
00055   // renvoie:
00056   // - false si pas d'intersection (region inchangee)
00057   // - true sinon si region est incluse dans clip (ie. clipping inutile)
00058   //
00059   bool setInter(const URegion &clip2);
00060   bool setInter(const URegion *clip2);
00061   bool setInter(u_pos x, u_pos y, u_dim w, u_dim h);
00062 
00063   //Note: les regions vides ne sont pas prises en compte!
00064   void setClosure(const URegion &clip2);
00065   void setClosure(const URegion *clip2);
00066   void setClosure(u_pos x, u_pos y, u_dim w, u_dim h);
00067 };
00068 
00069 /* ==================================================== ======== ======= */
00070 
00073 struct USourceProps {
00074   unsigned char enabled;
00076 
00077   unsigned char inMenu;
00079   
00080   unsigned char autoCloseMenu;
00082 
00083   unsigned char redrawStatus;
00084   URegion redrawClip;
00086 
00087   class UView* opaqueView;
00089 
00090   class UView* layoutView;
00092 
00093   class UView* incrustView;
00094 
00095   const UCursor* cursor;
00097 
00098   class UGroup   *browsingGroup, *parentBrowsingGroup;  
00099   class UContext *parentContext;  
00100 
00101   USourceProps(UView* hardwin_view) {reset(hardwin_view);}
00102 
00103   void reset(UView* hardwin_view);
00104   void set(UView* view, UGroup*, const UContext& curp);
00105 };
00106 
00107 /* ==================================================== [Elc:03] ======= */
00108 /* ==================================================== ======== ======= */
00109 
00112 class UEvent {
00113 public:
00115   enum ID {
00116     rawEvent    = 0,
00117     mpress      = 1<<0, 
00118     mrelease    = 1<<1, 
00119     mmove       = 1<<2, 
00120     mdrag       = 1<<3, 
00121     kpress      = 1<<4, 
00122     krelease    = 1<<5, 
00123     enter       = 1<<6, 
00124     leave       = 1<<7, 
00125     change      = 1<<8,
00126     select      = 1<<9,
00127     unselect    = 1<<10,
00128     action      = 1<<11,  // pas utilise correctement!
00129     add         = 1<<15,
00130     remove      = 1<<16,
00131     close       = 1<<17,
00132     destruct    = 1<<18,
00133     viewPaint   = 1<<20, 
00134     viewResize  = 1<<21, 
00135     viewMove    = 1<<22, 
00136     search      = 1<<23, 
00137     //input     = 1<<24, 
00138     //timeout   = 1<<25, 
00139     umessage    = 1<<26,
00140     notifyEvent = 1<<27 
00141   };
00142 
00143   static const u_id MButton1, MButton2, MButton3, MButton4, MButton5;
00148   static const u_id MShift, MLock, MControl, MOption; //MAlt, MNumLock, MAltGr;
00153   static const u_id UbitEventFlow;
00159   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00160   // basics
00161 
00162   int getID() const {return id;}
00164 
00165   const class UCond* getCond() const {return cond;}
00172   UView* getView() const {return sourceView;}
00177   UGroup* getSource() const;
00178   UBox* getBoxSource() const;
00184   UGroup* getTarget() const;
00185   UBox*   getBoxTarget() const;
00186   UBrick* getBrickTarget() const;
00192   class UAppli* getAppli() const;
00194 
00195   class UDisp* getDisp() const;
00196   int getDispID() const;
00200   class UFlow* getFlow() const {return eflow;}
00201   int getFlowID() const;
00206   u_time getTime() const;
00208   
00209   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00210   // mouse events
00211 
00212   u_pos getX() const;
00213   u_pos getY() const;
00218   u_pos getXscreen() const;
00219   u_pos getYscreen() const;
00221 
00222   u_pos getXwin()  const {return xmouse;}
00223   u_pos getYwin()  const {return ymouse;}
00228   int getClickCount() const;
00230 
00231   u_id getButtons() const;
00246   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00247   // mouse and keyboard events
00248 
00249   u_id getMods() const;
00255   //u_id getState() const;
00256   // (mouse & keyboard events) returns a combination of key and mouse button modifiers.
00257     
00258   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00259   // keyboard events
00260 
00261   int getKeyChar() const;
00263 
00264   void setKeyChar(int);
00266 
00267   u_id getKeySym() const;
00272   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00273   // change events.
00274   
00275   UProp* getChangedProp() const;
00276   UElem* getChangedElem() const;
00277   UStr*  getChangedStr() const;
00279 
00280   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00281   // umessage events.
00282   
00283   bool getMessage(UStr&) const;
00285 
00286   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00287   // element retrieval
00288 
00289   class UElem* getElem();
00291 
00292   class UStr*  getStr();
00298   class UElem* getElem(class UElemProps&);
00299   class UStr*  getStr(class UElemProps&);
00310   class UElem* searchElem(class UElemProps&, const UElem* searched_elem,
00311                           int strpos1 = -1, int strpos2 = -1);
00321   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00322   // flags and event management for transparent tools
00323 
00324   void goThrough(UBox*);
00326 
00327   void setMouse(u_pos x, u_pos y);
00329 
00330   void addFlagdef(const class UFlagdef*);
00332 
00333   const class UFlagdef* getFlagdef(const class UFlag&) const;
00334   const class UPropdef* getPropdef(const class UFlag&) const;
00335 
00336   const class UFlagdef** getFlagdefs() const {return flagdefs;}
00337   u_count getFlagdefCount() const {return flagdefCount;}
00338 
00339   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00340   // implementation
00341 
00342   class UWin*  getHardWin() const;
00343   class UView* getHardWinView() const;
00345 
00346   class USourceProps& getSourceProps() {return sp;}
00348 
00349   UX_Event getXEvent() const {return xev;}
00351   
00352   UEvent(int event_id, class UFlow*, class UView* hardwin_view, UX_Event);
00354 
00355   ~UEvent(); 
00356 
00357 #ifndef NO_DOC
00358   USourceProps   sp;             // Source properties
00359 private:
00360   friend class UFlow;
00361   friend class UCtrl;
00362   friend class UView;
00363 
00364   class UGroup*  source;         // the box or group that produced this event
00365   class UView*   sourceView;     // the view that contains the mouse
00366   class UView*   hardWinView;    // the view of the containing HARD window
00367   class UBrick*  aux;            // target or non group source
00368   class UFlow*   eflow;          // input flow that produced this event
00369   const class UCond* cond;       // UOn condition of the ucall()
00370   const class UFlagdef**  flagdefs;    // event flags
00371   unsigned short flagdefCount;
00372   unsigned char preChildEventNotify, postChildEventNotify, resendEvent;
00373   int    id;                     // event id
00374   int    detail;                 // additional data
00375   u_time time;                   // event time stamp
00376   u_pos  xmouse, ymouse;         // current mouse position in the HARD window
00377   u_pos  xdrag_ref, ydrag_ref;   // screen coords of the View that got the mpress
00378   UX_Event xev;                  // pointer to X event (hidden type)
00379 
00380 public:
00381   void setID(int);               // sets Event ID
00382   void setSource(UView*);        // sets the View & the Box that produced this event
00383   void setSource(UGroup*);       // sets the Group (when no View is available)
00384   void setAux(UBrick*);
00385   void setCond(const UCond*);
00386   void setTime(u_time t)               {time = t;}
00387   void setPostChildEventNotify(bool s) {postChildEventNotify = bool(s);}
00388   bool isPostChildEventNotify()        {return bool(postChildEventNotify);}
00389 
00390   UView* locateSource(UView* searched_view);
00391   UView* locateSource(u_pos x_in_hardwin, u_pos y_in_hardwin);
00393 
00394   void actualize(int event_id, u_pos x_in_hardwin, u_pos y_in_hardwin, UX_Event ev)
00395   {id = event_id; xev = ev; xmouse = x_in_hardwin; ymouse = y_in_hardwin;}
00397 
00398   void copy(const UEvent&);
00400 #endif
00401 };
00402 
00403 /* ==================================================== [Elc:03] ======= */
00404 /* ==================================================== ======== ======= */
00405 
00409 class UElemProps {
00410 public:
00411   class UElem* elem;
00412   class ULink* elemLink;
00416   URegion region;
00422   bool exactMatch;
00426   int strpos, strpos2;
00428 
00429   class UWinContext* winContext;
00430   class UContext*    elemContext;
00434 public:
00435   UElemProps(); 
00436   ~UElemProps();
00437 
00438   u_pos getX(class UEvent*);
00439   u_pos getY(class UEvent*);
00443   u_dim getWidth();
00444   u_dim getHeight();
00446 
00447   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00448   // implementation
00449 
00450 #ifndef NO_DOC
00451   friend class UEvent;
00452   friend class UView;
00453 
00454   void set(UContext&, UElem*, class ULink*, const URegion&, 
00455            int _strpos, bool exact_match);
00456   void merge(UContext&, UElem*, class ULink*, const URegion&,
00457              bool exact_match);
00458 #endif
00459 };
00460 
00461 
00462 #endif
00463 /* ==================================================== [TheEnd] ======= */
00464 /* ==================================================== [Elc:03] ======= */
00465 

Generated on Fri Mar 4 01:34:32 2005 for Ubit[Eric.Lecolinet@enst.fr] by  doxygen 1.4.1