HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UI_Object.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UI_Object.h
7  *
8  * COMMENTS:
9  *
10  * A UI_Object is the base class for objects that are organized in a
11  * hierarchy and are capable of receiving UI_Events.
12  *
13  */
14 #ifndef __UI_Object__
15 #define __UI_Object__
16 
17 #include "UI_API.h"
18 #include "UI_EventType.h"
19 
20 #include <UT/UT_Assert.h>
21 #include <hboost/container/stable_vector.hpp>
22 
23 
24 class RE_Render;
25 class UT_WorkBuffer;
26 class UI_Event;
27 class UI_Manager;
28 class UI_Queue;
29 class UI_DeviceEvent;
30 class UI_Object;
31 class UI_Value;
32 class UI_HotkeyEcho;
33 
34 
36 
37 // stable_vector is a hybrid of list and vector; giving random access and
38 // stable iterators upon insert/erase (except for an element pointed to),
39 // albeit with the loss of contiguity.
40 typedef hboost::container::stable_vector<UI_Object *> UI_ObjectList;
41 typedef hboost::container::stable_vector<UI_Value *> UI_ValueList;
42 
44 {
45 public:
46  UI_Object();
47 
48  virtual ~UI_Object();
49 
50  // !!! WARNING: Do NOT derive from UT_NonCopyable due to Visual C++ bug !!!
51  // !!! Otherwise Visual C++ will start causing subclass callback member
52  // !!! method pointers (of single inheritance chains) to become larger than
53  // !!! UI_EventMethod.
54  UI_Object(const UI_Object &) = delete;
55  UI_Object &operator=(const UI_Object &) = delete;
56  // !!! WARNING: Do NOT derive from UT_NonCopyable due to Visual C++ bug !!!
57 
58  virtual void handleEvent(UI_Event *event);
59  virtual int interestingEvent(UI_EventType t, UI_DeviceEvent *event) const;
60  virtual void deleteReferences(UI_Object *to_whom);
61 
62  UI_Object *getParent() const { return myParent; }
63  void setParent(UI_Object *p) { myParent = p; }
64  bool isAncestor(const UI_Object *who) const;
65 
66  void addDependent(UI_Object *who);
67  bool removeDependent(UI_Object *who);
68  bool replaceDependent(UI_Object *who, UI_Object *with);
69  bool isDependent(UI_Object *who) const;
70  bool hasDependents() const { return !myDependents.empty(); }
71  const UI_ObjectList &dependents() const { return myDependents; }
72 
73  void sendEvent(const UI_Event &e) const;
74  void distributeEvent(UI_Event *event, int upwards);
75  void relayEvent(UI_Event *event, UI_Object *target);
76  void generateEvent(UI_EventType t, UI_Object *target);
77  void purgeEvents(UI_EventType t, UI_Object *target,
78  UI_EventMethod method=0);
79 
80  // This method is similar to "distributeEvent()" but it bypasses the event
81  // queue, triggering the events on the dependents immediately.
82  // **This should only be used in special circumstances.**
83  void triggerImmediateEvent(UI_Event *event, int upwards);
84 
85  virtual const char *className() const { return "UI_Object"; }
86 
87  int getProxyId();
88 
89  void bumpQueueCount(int dir) { myQueueCount += dir; }
90 
91 
92  // only works in debug.
93  void setName(const char *symbolName);
94  const char *getName() const;
95  void buildFullPath(UT_WorkBuffer &string) const;
96 
97  // Debug events which target this UI_Object coming in from given UI_Value.
98  // You must also enable the define UI_QUEUE_DEBUG_TARGET_ORIGIN in
99  // UI_Queue.C in order to use this method. The type is optional; if
100  // specified, only events of that type are monitored.
101  // Either object or value (or both) can be specified.
102  void debugQueueEventsFor(
103  const UI_Value *value,
104  const char *name,
105  UI_EventType t = UI_EVENT_NO_EVENT) const;
106 
107 
108  static UI_Manager *getManager() { return theUIManager; }
109  static UI_Queue *getInputQueue() { return theUIQueue; }
110 
111  static int keycmp(const char *, int key);
112  static int keycmp(const char *, int key,
113  const UI_HotkeyEcho &);
114 
115  static void keyEcho(const char *, const UI_HotkeyEcho &);
116  static void actionKeyEcho(const char *,
117  const char *custom_suffix = 0);
118  static void toggleKeyEcho(const char *, bool new_value);
119 
120  const UI_ValueList &valueInterests() const { return myValueInterests; }
121 
122 
123  // only UI_Value should call these methods.
124  void interestedInValue(UI_Value *);
125  void removeValueInterest(UI_Value *);
126 
127 protected:
128  UI_ObjectList &dependents() { return myDependents; }
129 
130  // This is the function called by the UI_Manager at the start of a call
131  // to terminate, but only if this object has been added to the UI_Manager
132  // list of pre-terminate callbacks.
133  virtual void preTerminateCallback()
134  { }
135 
136 private:
137  UI_Object *myParent;
138  UI_ObjectList myDependents;
139  UI_ValueList myValueInterests;
140  int myQueueCount;
141  int myProxyId;
142  char *myName;
143 
144  friend class UI_Manager;
145  void setManager(UI_Manager *m, UI_Queue *q);
146 
147  static UI_Manager *theUIManager;
148  static UI_Queue *theUIQueue;
149 };
150 
151 #endif
const UI_ObjectList & dependents() const
Definition: UI_Object.h:71
hboost::container::stable_vector< UI_Object * > UI_ObjectList
Definition: UI_Object.h:40
GLuint const GLchar * name
Definition: glew.h:1814
GLenum target
Definition: glew.h:2865
UI_Object * getParent() const
Definition: UI_Object.h:62
const GLdouble * m
Definition: glew.h:9124
void setParent(UI_Object *p)
Definition: UI_Object.h:63
const UI_ValueList & valueInterests() const
Definition: UI_Object.h:120
static UI_Manager * getManager()
Definition: UI_Object.h:108
virtual void preTerminateCallback()
Definition: UI_Object.h:133
GLdouble GLdouble GLdouble GLdouble q
Definition: glew.h:1414
UI_ObjectList & dependents()
Definition: UI_Object.h:128
bool hasDependents() const
Definition: UI_Object.h:70
void bumpQueueCount(int dir)
Definition: UI_Object.h:89
void
Definition: png.h:1083
UI_EventType
Definition: UI_EventType.h:20
GLfloat GLfloat p
Definition: glew.h:16321
cl_event event
Definition: glew.h:3695
static UI_Queue * getInputQueue()
Definition: UI_Object.h:109
hboost::container::stable_vector< UI_Value * > UI_ValueList
Definition: UI_Object.h:41
void(UI_Object::* UI_EventMethod)(UI_Event *)
Definition: UI_Object.h:35
virtual const char * className() const
Definition: UI_Object.h:85
#define UI_API
Definition: UI_API.h:10
GLsizei const GLfloat * value
Definition: glew.h:1849
GLdouble GLdouble t
Definition: glew.h:1398