ubit
uon.hpp
1 /************************************************************************
2  *
3  * uon.hpp: Callback conditions
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 _uon_hpp_
18 #define _uon_hpp_ 1
19 #include <ubit/ucond.hpp>
20 namespace ubit {
21 
35  class UOn : public UCond {
36  public:
37  static UOn
38  idle,
43  action,
52  &arm, &disarm,
68  &select, &deselect,
77  enter, leave,
85  click, doubleClick,
98  mpress, mrelease, mdrag, mmove,
118  wheel,
127  kpress, krelease,
142  ktype,
157  &dragStart, &dragDone, &dropEnter, &dropLeave, &dropDone,
161  show, hide,
167  close,
169 
170  paint,
182  resize, motion,
193  addChild, removeChild,
200  destruct,
204  winState,
209  sysWM,
215  change,
230  propChange, dataChange, strChange, //caretChange,
242  userEvent;
244 
245  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
246 
247  enum Callback {
248  DESTRUCT_CB = 1<<12,
249  CONTAINER_CB = 1<<13,
250  CHANGE_CB = 1<<14,
251  CHILD_CHANGE_CB = 1<<15,
252  VIEW_PAINT_CB = 1<<16,
253  VIEW_CHANGE_CB = 1<<17,
254  SHOW_HIDE_CB = 1<<18,
255  MOUSE_CB = 1<<19,
256  MOUSE_CROSS_CB = 1<<20,
257  MOUSE_DRAG_CB = 1<<21,
258  MOUSE_MOVE_CB = 1<<22,
259  KEY_CB = 1<<23,
260  DND_CB = 1<<24,
261  MESSAGE_CB = 1<<25,
262  WIN_STATE_CB = 1<<27,
263  SYSWM_CB = 1<<28,
264  USER_EVENT_CB = 1<<29,
265 
266  CALLBACKS = DESTRUCT_CB | CONTAINER_CB | CHANGE_CB | CHILD_CHANGE_CB
267  | VIEW_PAINT_CB | VIEW_CHANGE_CB | SHOW_HIDE_CB
268  | MOUSE_CB | MOUSE_CROSS_CB | MOUSE_DRAG_CB | MOUSE_MOVE_CB | KEY_CB | DND_CB
269  | MESSAGE_CB | WIN_STATE_CB | SYSWM_CB
270  /*| FILTER_EVENT_CB*/ | USER_EVENT_CB
271  };
272 
273  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
274  // interaction state
275 
276  enum IState {
277  ANY = -1,
278  IDLE = 0, // must be 0 (index in style arrays)
279  DISABLED, ENTERED, ARMED, ACTIONED, DRAGGED, DROP_ENTERED,
280  ACTION_COUNT
281  };
282 
283  const int ID;
284 
285  UOn(int id, long callback_mask, int istate = -1); // -1 == UMode::ANY
295  virtual int getID() const {return ID;}
296 
297  // see superclass for details.
298  virtual bool operator==(const UCond&) const;
299  virtual bool operator!=(const UCond&) const;
300  virtual const UCond* matches(const UCond&) const;
301  virtual bool verifies(const UUpdateContext&, const UElem&) const;
302 
303  virtual UOn* toOn() {return this;}
304  virtual const UOn* toOn() const {return this;}
305 
306  protected:
307  friend class UElem;
308  long callback_mask;
309  int istate;
310  virtual void setParentModes(UElem& parent) const;
311  };
312 
313  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
314 
315  class UOn2 : public UOn {
316  public:
317  typedef UElem& (UElem::*SetModeFunc)(bool);
318 
319  UOn2(int id, long callback_mask, int state, SetModeFunc);
320 
321  protected:
322  virtual void setParentModes(UElem& parent) const;
323  SetModeFunc set_mode_func;
324  };
325 
326 }
327 #endif
328 
static UOn krelease
fire callbacks when a key is pressed or released.
Definition: uon.hpp:41
static UOn ktype
fire callbacks when a text is entered by pressing a key.
Definition: uon.hpp:41
static UOn paint
detect that a widget was repainted.
Definition: uon.hpp:41
static UOn removeChild
fire callbacks when a child is added to / removed from an object.
Definition: uon.hpp:41
static UOn winState
fires callbacks when a window state is changed.
Definition: uon.hpp:41
virtual int getID() const
< creates a callback condition.
Definition: uon.hpp:295
Base class for Ubit conditions.
Definition: ucond.hpp:29
static UOn destruct
detects when an object is being destructed.
Definition: uon.hpp:41
Definition: uon.hpp:315
static UOn action
detects that a high-level "action" was performed on a widget.
Definition: uon.hpp:41
static UOn change
fires callbacks when the value of an object is changed.
Definition: uon.hpp:41
static UOn close
fires callbacks when a window (or a menu) is closed by the window manager (
Definition: uon.hpp:41
static UOn & dropDone
detects drag and drop events occuring on a widget.
Definition: uon.hpp:41
static UOn doubleClick
detects that the mouse was clicked or double-clicked on a widget.
Definition: uon.hpp:41
lightweight general purpose container.
Definition: uelem.hpp:44
static UOn wheel
detects that the wheel was moved while the mouse was over a widget.
Definition: uon.hpp:41
static UOn hide
detect that a widget was shown or hidden.
Definition: uon.hpp:41
static UOn sysWM
fires callbacks when a platform-dependent window manager event is received.
Definition: uon.hpp:41
static UOn motion
detect that a widget was resized or moved.
Definition: uon.hpp:41
Callback conditions.
Definition: uon.hpp:35
static UOn userEvent
< child change conditions.
Definition: uon.hpp:41
Callback
Definition: uon.hpp:247
virtual bool verifies(const UUpdateContext &, const UElem &) const
Definition: uon.cpp:137
Definition: uupdatecontext.hpp:32
static UOn & deselect
detects that a widget was "selected" or "deselected".
Definition: uon.hpp:41
static UOn & disarm
detects that a widget was "armed" or "disarmed".
Definition: uon.hpp:41
Definition: uhardfont.hpp:31
callbacks this object is sensitive to
Definition: uon.hpp:248
static UOn idle
no event condition.
Definition: uon.hpp:41
static UOn mmove
detects that the mouse was pressed, released, dragged or moved.
Definition: uon.hpp:41
static UOn leave
detects that the mouse entered or left a widget.
Definition: uon.hpp:41