ueventImpl.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  ueventImpl.hpp
00004  *  Ubit Project
00005  *  Author: Eric Lecolinet
00006  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00007  *  (C) 1999-2005 EricLecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00008  *
00009  * ***********************************************************************
00010  * COPYRIGHT NOTICE : 
00011  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00012  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00013  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00014  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00015  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00016  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00017  * ***********************************************************************
00018  * ==================================================== [(c)Elc] ======= *
00019  * ==================================================== ======== ======= */
00020 
00021 #ifndef _ueventImpl_hpp_
00022 #define _ueventImpl_hpp_
00023 //pragma ident  "@(#)ueventImpl.hpp     ubit:05.05.00"
00024 #include <ubit/ugeom.hpp>
00025 
00026 /* ==================================================== ===== ======= */
00029 #ifdef WITH_GDK
00030   typedef union _GdkEvent* USysEvent;
00031 #else
00032   typedef union _XEvent* USysEvent;
00033 #endif
00034 
00035 namespace ubit {
00036 
00037 /* ==================================================== ===== ======= */
00038 /* [impl] Implementation of Event Properties ; subject to change.
00039 */
00040 struct UEventProps {
00041   UEventProps(UView* hardwin_view = null, UContext* parent_context = null);
00042   void reset(UView* hardwin_view, UContext* parent_context);
00043   void update(UView* view, UGroup*, const UContext& curp);
00044 
00045   enum {
00046     ENABLED               = 1<<0,  // is the source enabled ?.
00047     IN_MENU               = 1<<1,  // is the source (indirectly) included in a menu?.
00048     AUTO_CLOSE_MENU       = 1<<2,  // does the source close menus when clicked?.
00049     //GO_THROUGH          = 1<<3,  // events go through object
00050     //GO_THROUGH_CHILDREN = 1<<4,  // events go through object and children
00051     HAS_REDRAW_CLIP       = 1<<5  // redrawClip is valid
00052   };
00053   unsigned short modes;
00054   
00055   UMask parent_bmodes;
00056 
00057   float xyscale;
00059   
00060   inline bool hasRedrawClip() {return modes & HAS_REDRAW_CLIP;}
00061   URegion redrawClip;
00066   const UCursor* cursor;
00068 
00069   UView* opaqueView;
00071 
00072   UView* layoutView;
00074 
00075   UView* childwinView;
00076   // necessaire car gestion specifique des events par ce type d'objets.
00077 
00078   UGroup *browsingGroup;
00079   UGroup *parentBrowsingGroup;  
00081   
00082   UContext* parentContext, *childContext;  
00084 };
00085 
00086 /* ==================================================== ===== ======= */
00087 /* [impl] Event Implementation; subject to change.
00088 */
00089 struct UEventImpl {
00090 public:  
00091   bool initFromView(UView*);
00092   void setCond(const UCond&);
00093   void setDetail(int);
00094   void setSource(UBrick*);  // DANGER: peut ecraser UInput::setPosAndSource
00095   void setSource(UView*);
00096   void setTarget(UBrick*);
00097   void setWhen(UTime);
00098   void setPosImpl(int xwin, int ywin);
00099   void translatePos(int x, int y);
00100   void setFirstDrag(bool);  
00101 
00102   UData* searchData(const UData* searched_data, UDataProps&, 
00103                     int str_pos1, int str_pos2);
00104   /* searches the data object that is given as an argument.
00105     * UDataProps is filled with useful info (see UDataProps).
00106     * Arguments strpos1, strpos2 can be used when searching for UStr(s) :
00107     * the region returned in UDataProps does not contain the entire string
00108     * but just its 'strpos1' to 'strpos2' subpart
00109     */
00110   
00111   bool u3dIsTransformed() const;
00112   void u3dTransformMouse(int x, int y, UView* transformedView);
00113   /* transforms the mouse coordinates.
00114     * Any component that 'distorts' the view in any way should use this function
00115     * to distort the mouse coordinates. x and y are the transformed mouse
00116     * coordinates, transformedView is the view that is distorted.
00117     */
00118   
00119   void u3dRestoreMouse();
00120   // restore the mouse coordinates to their original value.
00121   
00122   void u3dPushMatch();
00123   // must be called when locateSource() has found a matching view.
00124   
00125   void u3dPopMatch();
00126   // called to set the current mouse coordinates to the matched coordinates.
00127   
00128   const UEventProps& props() const {return _props;}
00129 
00130 protected:    
00131   UEventImpl(UEventFlow*, UView* hardwin_view, USysEvent, UTime, const UCond*);
00132   virtual ~UEventImpl();   
00133   
00134   void actualize(const UCond&, UEvent&);
00135   // these 2 methods are useful for PaintEvent and Input/MouseEvent
00136   
00137 public:
00138   UEventProps _props;
00139   const UCond* cond;         
00140   int detail;                
00141   unsigned long misc;        
00142   UTime time;                
00143   int xmouse, ymouse;        
00144   int xdrag_ref, ydrag_ref;  
00145   USysEvent sys_event;       
00146   UBrick* source;                
00147   UBrick* aux;               
00148   UView*  sourceView;        
00149   UView*  hardWinView;       
00150   UEventFlow* eflow;         
00151   std::vector<const UFlagdef*>flagdefs;  
00152   
00153   // GL/U3D
00154   UView* transformView; // the first view transformed in the matching coordinate system.
00155   int xmouse_orig, ymouse_orig; // original xmouse and ymouse
00156   int xmouse_match, ymouse_match; // xmouse and ymouse for current matching view
00157   
00158   unsigned char 
00159     coord_changed:1/*u3d*/,
00160     is_consumed:1, is_ignored:1, is_browsing:1, is_mdrag:1, is_first_mdrag:1;
00161 };
00162 
00163 }
00164 #endif
00165 /* ==================================================== [TheEnd] ======= */
00166 /* ==================================================== [(c)Elc] ======= */
00167 

Generated on Mon Jan 29 00:20:38 2007 for Ubit by  doxygen 1.4.7