ubit
ueventflow.hpp
1 /************************************************************************
2  *
3  * ueventflow.hpp: Event Flow
4  * Ubit GUI Toolkit - Version 6
5  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _ueventflow_hpp_
18 #define _ueventflow_hpp_ 1
19 #include <ubit/uappli.hpp>
20 #include <ubit/uevent.hpp>
21 #include <ubit/uviewImpl.hpp>
22 namespace ubit {
23 
24  class UMenuManager;
25 
34  class UEventFlow {
35  public:
36  UEventFlow(UDisp&, int channel);
41  virtual ~UEventFlow();
42 
43  int getID() const {return id;}
50  int getChannel() const {return channel;}
61  UDisp& getDisp() const {return disp;}
63 
64  void setFocus(UView*);
70  USelection* getSelection() {return &selection;}
72 
73  UMenuManager& getMenuManager() const {return menu_man;}
74 
75  UObject* getUserData() {return user_data;}
77 
78  void setUserData(UObject* obj) {user_data = obj;}
80 
81  void closeAllMenus();
83 
84  void deleteNotify(UView* deleted_view);
85  void deleteNotify(UElem* deleted_group);
86 
87  void redirectMousePress(UMouseEvent&, UView* winview);
88 
89  // - - - Impl. - - - - - - - - - - - - - - - - - - - - - - - - - - -
90 
91  void mousePress(UView* win_view, unsigned long time, int state,
92  const UPoint& win_pos, const UPoint& abs_pos, int btn);
93  void mouseRelease(UView* win_view, unsigned long time, int state,
94  const UPoint& win_pos, const UPoint& abs_pos, int btn);
95  void mouseMotion(UView* win_view, unsigned long time, int state,
96  const UPoint& win_pos, const UPoint& abs_pos);
97  void wheelMotion(UView* win_view, unsigned long time, int state,
98  const UPoint& win_pos, const UPoint& abs_pos, int type, int delta);
99  void keyPress(UView* win_view, unsigned long time, int state, int keycode, short keychar);
100  void keyRelease(UView* win_view, unsigned long time, int state, int keycode, short keychar);
101  void winEnter(UView* win_view, unsigned long time);
102  void winLeave(UView* win_view, unsigned long time);
103 
104  void setCursor(UEvent&, const UCursor*);
105  void startAutoRepeat(UEvent&);
106  void stopAutoRepeat(UEvent&);
107 
108  protected:
109  void boxCross(UView* box_view, unsigned long time, int state, const UCursor*, bool is_browsing);
110  bool mustCloseMenus(UView* source_view);
111  void autoRepeatCB(UTimerEvent&);
112  void openTipCB(UTimerEvent&);
113  void openTipRequest(UEvent&);
114  void closeTipRequest(UEvent&);
115  UWin* retrieveTelePointer(UDisp*);
116  void showTelePointers(UMouseEvent&, int mode = 0);
117 
118  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
119  private:
120  friend class UAppli;
121  friend class UEvent;
122  friend class UElem;
123  static int TIP_X_SHIFT;
124  int id, channel;
125  UDisp& disp;
126 
127  struct LastPressed {
128  LastPressed() {reset();}
129  void reset();
130  void set(UView* source_view, const UPoint& win_pos, const UPoint& screen_pos, const UViewFind&);
131  UView* view;
132  UBox* box;
133  UPoint win_in_screen; // pos of win in the screen (for drag and release events)
134  U3DcanvasView* canvas_view; // != null if the source is in a 3Dwidget
135  U3Dpos* refpos_in_canvas; // 3Dpos of the 3Dwidget in canvas_view (if it is != null)
136  UBehavior behavior;
137  } lastPressed;
138 
139  UView *lastEntered, *currentFocus;
140  UElem *lastArmed, *beingClicked, *dragSource, *dropTarget;
141  UPoint click_pos;
142  int click_count;
143  unsigned long click_time;
144  const class UCursor* lastCursor; // cursor being currently shown
145  uptr<UTimer> auto_repeat_timer; // timer fo auto_repeat actions
146  uptr<UTimer> tip_timer; // timer for tool tips
147  UWin& tip_win; // window for tool tips
148  UMenuManager& menu_man; // menubars & pulldown menus manager
149  USelection& selection; // text selection management
150  std::vector<class UWin*> tele_pointers; // remote pointers
151  UObject* user_data;
152  };
153 
154 }
155 #endif
UDisp & getDisp() const
returns the display that controls this event flow.
Definition: ueventflow.hpp:61
Definition: uviewImpl.hpp:92
text selection.
Definition: uselection.hpp:25
Box container.
Definition: ubox.hpp:64
2D Point.
Definition: ugeom.hpp:25
Ubit Event class.
Definition: uevent.hpp:30
Definition: uviewImpl.hpp:30
Display Context.
Definition: udisp.hpp:44
UEventFlow(UDisp &, int channel)
creates a new Event Flow on this Display.
Definition: ueventflow.cpp:64
The Application Context.
Definition: uappli.hpp:79
USelection * getSelection()
returns the text selection of this event flow.
Definition: ueventflow.hpp:70
int getID() const
returns the global ID of this Event Flow.
Definition: ueventflow.hpp:43
lightweight general purpose container.
Definition: uelem.hpp:44
[Instable/OpenGL] 3D position.
Definition: u3d.hpp:129
Smart Pointer for UObject instances (.
Definition: uobject.hpp:365
int getChannel() const
returns the channel of this Event Flow relatively to its Display.
Definition: ueventflow.hpp:50
void winEnter(UView *win_view, unsigned long time)
Definition: ueventflow.cpp:514
Event Flow.
Definition: ueventflow.hpp:34
Box View.
Definition: uview.hpp:65
Definition: u3d.hpp:173
Definition: uhardfont.hpp:31
void setFocus(UView *)
gives the input focus to this view.
Definition: ueventflow.cpp:131
UObject * getUserData()
gets a handle to user data.
Definition: ueventflow.hpp:75
Base class for windows and menus.
Definition: uwin.hpp:47
void closeAllMenus()
close all menus related to this eventflow.
Definition: ueventflow.cpp:125
timer event.
Definition: uevent.hpp:485
Mouse cursor property.
Definition: ucursor.hpp:31
[Implementation] manages the stack of menus that are currently opened on a given EventFlow.
Definition: umenuImpl.hpp:24
void setUserData(UObject *obj)
sets a handle to user data.
Definition: ueventflow.hpp:78
mouse events
Definition: uevent.hpp:172
Base class of most Ubit objects (SEE DETAILS!).
Definition: uobject.hpp:113