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 <UT/UT_UniquePtr.h>
22 #include <hboost/container/stable_vector.hpp>
23 
24 
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_KeyDelegate;
33 class UI_HotkeyEcho;
34 
35 
37 
38 // stable_vector is a hybrid of list and vector; giving random access and
39 // stable iterators upon insert/erase (except for an element pointed to),
40 // albeit with the loss of contiguity.
41 typedef hboost::container::stable_vector<UI_Object *> UI_ObjectList;
42 typedef hboost::container::stable_vector<UI_Value *> UI_ValueList;
43 typedef hboost::container::stable_vector<UI_KeyDelegate *> UI_KeyDelegateList;
44 
46 {
47 public:
48  UI_Object();
49 
50  virtual ~UI_Object();
51 
52  // !!! WARNING: Do NOT derive from UT_NonCopyable due to Visual C++ bug !!!
53  // !!! Otherwise Visual C++ will start causing subclass callback member
54  // !!! method pointers (of single inheritance chains) to become larger than
55  // !!! UI_EventMethod.
56  UI_Object(const UI_Object &) = delete;
57  UI_Object &operator=(const UI_Object &) = delete;
58  // !!! WARNING: Do NOT derive from UT_NonCopyable due to Visual C++ bug !!!
59 
60  virtual void handleEvent(UI_Event *event);
61  virtual int interestingEvent(UI_EventType t, UI_DeviceEvent *event) const;
62  virtual void deleteReferences(UI_Object *to_whom);
63 
64  UI_Object *getParent() const { return myParent; }
65  void setParent(UI_Object *p) { myParent = p; }
66  bool isAncestor(const UI_Object *who) const;
67 
68  void addDependent(UI_Object *who);
69  bool removeDependent(UI_Object *who);
70  bool replaceDependent(UI_Object *who, UI_Object *with);
71  bool isDependent(UI_Object *who) const;
72  bool hasDependents() const { return !myDependents.empty(); }
73  const UI_ObjectList &dependents() const { return myDependents; }
74 
75  void sendEvent(const UI_Event &e) const;
76  void distributeEvent(UI_Event *event, int upwards);
77  void relayEvent(UI_Event *event, UI_Object *target);
78  void generateEvent(UI_EventType t, UI_Object *target);
79  void purgeEvents(UI_EventType t, UI_Object *target,
80  UI_EventMethod method=0);
81 
82  // This method is similar to "distributeEvent()" but it bypasses the event
83  // queue, triggering the events on the dependents immediately.
84  // **This should only be used in special circumstances.**
85  void triggerImmediateEvent(UI_Event *event, int upwards);
86 
87  virtual const char *className() const { return "UI_Object"; }
88 
89  int getProxyId();
90 
91  void bumpQueueCount(int dir) { myQueueCount += dir; }
92 
93 
94  // only works in debug.
95  void setName(const char *symbolName);
96  const char *getName() const;
97  void buildFullPath(UT_WorkBuffer &string) const;
98 
99  // Debug events which target this UI_Object coming in from given UI_Value.
100  // You must also enable the define UI_QUEUE_DEBUG_TARGET_ORIGIN in
101  // UI_Queue.C in order to use this method. The type is optional; if
102  // specified, only events of that type are monitored.
103  // Either object or value (or both) can be specified.
104  void debugQueueEventsFor(
105  const UI_Value *value,
106  const char *name,
107  UI_EventType t = UI_EVENT_NO_EVENT) const;
108 
109 
110  static UI_Manager *getManager() { return theUIManager; }
111  static UI_Queue *getInputQueue() { return theUIQueue; }
112 
113  static int keycmp(const char *, int key);
114  static int keycmp(const char *, int key,
115  const UI_HotkeyEcho &);
116 
117  static void keyEcho(const char *, const UI_HotkeyEcho &);
118  static void actionKeyEcho(const char *,
119  const char *custom_suffix = 0);
120  static void toggleKeyEcho(const char *, bool new_value);
121 
122  const UI_ValueList &valueInterests() const { return myValueInterests; }
123 
124 
125  // Only UI_Value should call these methods.
126  // DO NOT MAKE THESE VIRTUAL!
127  void interestedInValue(UI_Value *);
128  void removeValueInterest(UI_Value *);
129 
130  // Only UI_KeyDelegate should call these methods.
131  // DO NOT MAKE THESE VIRTUAL!
132  void addKeyDelegateClientship(UI_KeyDelegate *);
133  void removeKeyDelegateClientship(UI_KeyDelegate *);
134 
135 protected:
136  UI_ObjectList &dependents() { return myDependents; }
137 
138  // This is the function called by the UI_Manager at the start of a call
139  // to terminate, but only if this object has been added to the UI_Manager
140  // list of pre-terminate callbacks.
141  virtual void preTerminateCallback()
142  { }
143 
144 private:
145  UI_Object *myParent;
146  UI_ObjectList myDependents;
147  UI_ValueList myValueInterests;
149  myKeyDelegateClientships;
150  int myQueueCount;
151  int myProxyId;
152  char *myName;
153 
154  friend class UI_Manager;
155  void setManager(UI_Manager *m, UI_Queue *q);
156 
157  static UI_Manager *theUIManager;
158  static UI_Queue *theUIQueue;
159 };
160 
161 #endif
const UI_ObjectList & dependents() const
Definition: UI_Object.h:73
hboost::container::stable_vector< UI_Object * > UI_ObjectList
Definition: UI_Object.h:41
void
Definition: png.h:1083
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate and *a name There is also one special expression _ which means *the weaker expression when composing expressions together See with
UI_Object * getParent() const
Definition: UI_Object.h:64
GLdouble GLdouble GLdouble q
Definition: glad.h:2445
void setParent(UI_Object *p)
Definition: UI_Object.h:65
const UI_ValueList & valueInterests() const
Definition: UI_Object.h:122
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
struct _cl_event * event
Definition: glcorearb.h:2961
static UI_Manager * getManager()
Definition: UI_Object.h:110
virtual void preTerminateCallback()
Definition: UI_Object.h:141
UI_ObjectList & dependents()
Definition: UI_Object.h:136
bool hasDependents() const
Definition: UI_Object.h:72
void bumpQueueCount(int dir)
Definition: UI_Object.h:91
PXL_API const char * getName(const ColorSpace *space)
Return the name of the color space.
UI_EventType
Definition: UI_EventType.h:20
GLenum target
Definition: glcorearb.h:1667
GLuint const GLchar * name
Definition: glcorearb.h:786
GLdouble t
Definition: glad.h:2397
static UI_Queue * getInputQueue()
Definition: UI_Object.h:111
LeafData & operator=(const LeafData &)=delete
hboost::container::stable_vector< UI_Value * > UI_ValueList
Definition: UI_Object.h:42
void(UI_Object::* UI_EventMethod)(UI_Event *)
Definition: UI_Object.h:36
virtual const char * className() const
Definition: UI_Object.h:87
#define UI_API
Definition: UI_API.h:10
Definition: core.h:1131
hboost::container::stable_vector< UI_KeyDelegate * > UI_KeyDelegateList
Definition: UI_Object.h:43