00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __UI_Object__
00023 #define __UI_Object__
00024
00025 #include "UI_API.h"
00026 #include "UI_EventType.h"
00027
00028 #include <UT/UT_Pointers.h>
00029 #include <UT/UT_Assert.h>
00030
00031 class RE_Render;
00032 class UT_String;
00033 class UI_Event;
00034 class UI_Manager;
00035 class UI_Queue;
00036 class UI_DeviceEvent;
00037 class UI_Object;
00038 class UI_Value;
00039
00040
00041
00042
00043
00044
00045
00046 #define UI_ENABLE_PROXY_POINTERS 1
00047
00048 typedef void (UI_Object::*UI_EventMethod)(UI_Event *);
00049
00050 class UI_API UI_Object
00051 {
00052 public:
00053 UI_Object();
00054
00055 virtual ~UI_Object();
00056
00057 virtual void handleEvent(UI_Event *event);
00058 virtual int interestingEvent(UI_EventType t, UI_DeviceEvent *event) const;
00059 virtual void deleteReferences(UI_Object *to_whom);
00060
00061 UI_Object *getParent() const { return parent; }
00062 void setParent(UI_Object *p) { parent = p; }
00063 int isAncestor(UI_Object *who) const;
00064
00065 void addDependent(UI_Object *who);
00066 int removeDependent(UI_Object *who);
00067 int replaceDependent(UI_Object *who, UI_Object *with);
00068 int isDependent(UI_Object *who) const;
00069 UT_Pointers *getDependents() const { return dependents; }
00070
00071
00072
00073
00074
00075 void dependentCountHint(int count);
00076
00077 void sendEvent(const UI_Event &e, int purge=0) const;
00078 void distributeEvent(UI_Event *event, int upwards);
00079 void relayEvent(UI_Event *event, UI_Object *target);
00080 void generateEvent(UI_EventType t, UI_Object *target,
00081 int purge=0);
00082 void purgeEvents(UI_EventType t, UI_Object *target,
00083 UI_EventMethod method=0);
00084
00085 virtual const char *className() const;
00086
00087 #if UI_ENABLE_PROXY_POINTERS == 1
00088 int getProxyId();
00089 #endif
00090
00091
00092 int getRedrawPriority() const
00093 { return myRedrawPriority; }
00094 void setRedrawPriority(int priority)
00095 {
00096 UT_ASSERT(priority >= 0 && priority <= 1);
00097 myRedrawPriority = priority;
00098 }
00099
00100
00101 void bumpQueueCount(int dir) { myQueueCount += dir; }
00102
00103
00104
00105 void setName(const char *symbolName);
00106 const char *getName() const;
00107 void buildFullPath(UT_String &string) const;
00108
00109
00110 static UI_Manager *getManager() { return theUIManager; }
00111 static UI_Queue *getInputQueue() { return theUIQueue; }
00112
00113 static int keycmp(const char *, int key);
00114
00115 int getNumValueInterests();
00116 UI_Value *getValueInterest(int i);
00117
00118
00119
00120 void interestedInValue(UI_Value *);
00121 void removeValueInterest(UI_Value *);
00122
00123 protected:
00124
00125
00126
00127 virtual void preTerminateCallback()
00128 { }
00129
00130 UT_Pointers *dependents;
00131 UT_Pointers *myValueInterests;
00132 UI_Object *parent;
00133 int myRedrawPriority;
00134 int myQueueCount;
00135 #if UI_ENABLE_PROXY_POINTERS == 1
00136 int myProxyId;
00137 #endif
00138 #if defined(UI_DEBUG_OBJECT_NAME)
00139 char *myName;
00140 #endif
00141
00142 private:
00143 friend class UI_Manager;
00144 void setManager(UI_Manager *m, UI_Queue *q);
00145
00146 static UI_Manager *theUIManager;
00147 static UI_Queue *theUIQueue;
00148 };
00149
00150 #endif