00001 #ifndef KDE__OBJECT_H
00002 #define KDE__OBJECT_H
00003
00004 #define K_OBJECT Q_OBJECT
00005 #define Q_OBJECT \
00006 protected: \
00007 virtual void *faith_get_list_for_signal_magna(const char *) const; \
00008 virtual bool faith_add_slot_to_list_magna(const char *, void *) const; \
00009 virtual bool faith_inherits_magna(const char *) const; \
00010 virtual const char *className() const; \
00011 int faith_vector_size() const; \
00012 private:
00013
00014 #define emit
00015
00016 #define SIGNAL(sig) (#sig)
00017 #define SLOT(slot) (#slot)
00018
00019 #define slots
00020 #define signals protected
00021
00022 #include <faith/event.h>
00023 #include <faith/core.h>
00024
00025 #include <list>
00026 #include <set>
00027
00028
00029 #ifdef WIN32
00030
00031 #else
00032 #include <sys/time.h>
00033 #endif
00034
00035
00036 namespace Faith
00037 {
00038
00039 typedef const char *Slot;
00040 typedef const char *Signal;
00041
00042 class Widget;
00043
00044 struct TimerInfo;
00045
00056 class FAITH_CORE_EXPORT Object
00057 {
00058 K_OBJECT
00059 Object *mParent;
00060 const char *mName;
00061 struct Private;
00062 Private *d;
00063 friend class Application;
00064 friend class Widget;
00065
00066 std::list<TimerInfo*> mTimers;
00067 std::list<Object*> mFilters;
00068
00069 enum MagicFlags
00070 {
00071 MagicIsWidget=1
00072 };
00073
00074 int mMagicFlags;
00075
00076
00077 void *faith_connector_map;
00078
00079 public:
00083 struct Faith_CalledSlot
00084 {
00085 Faith::Object *source;
00086 void *signalListItem;
00087 void *signalList;
00088 };
00089
00090 protected:
00091 mutable void **faith_callbacks_magna;
00092
00096 void faith_magna_slot_begin(Faith_CalledSlot *slot);
00100 void faith_magna_slot_end(Faith_CalledSlot *slot);
00101
00102 private:
00108 Object(int magicflags, Object *parent, const char *name);
00109
00110 public:
00120 Object(Object *parent=0, const char *name=0);
00121 virtual ~Object();
00122
00126 inline bool isA(const char *type) const { return faith_inherits_magna(type); }
00127
00131 bool isWidgetType() const { return mMagicFlags & MagicIsWidget; }
00132
00136 const char *name() const { return mName; }
00140 Object *parent() { return mParent; }
00141
00142 const Object *parent() const { return mParent; }
00143
00148 static bool connect(const Faith::Object *from, Signal signal, Faith::Object *to, Slot slot)
00149 {
00150 return to->connect(from, signal, slot);
00151 }
00152
00157 bool connect(const Faith::Object *from, Signal signal, Slot slot);
00158
00165 void blockSignals(bool on);
00166
00170 bool signalsBlocked() const;
00171
00180 int startTimer(int msecs);
00185 void killTimer(int id);
00186
00192 void killTimers();
00193
00202 virtual bool event(Event *event);
00203
00210 void installEventFilter(Faith::Object *filter);
00211
00216 void removeEventFilter(Faith::Object *filter);
00217
00218 public slots:
00222 void deleteLater();
00223
00224 protected:
00225
00229 virtual void timerEvent(Faith::TimerEvent *) { }
00230
00235 virtual void userEvent(Faith::Event *) { }
00236
00250 virtual bool eventFilter(Faith::Object *filtered, Faith::Event *e);
00251
00252
00253
00254 protected:
00255 std::set<Faith::Object*>::iterator beginChildren();
00256 std::set<Faith::Object*>::iterator endChildren();
00257
00258 private:
00264 bool kde_event(Faith::Event *event);
00265 };
00266
00267 template<class T> struct faith_callback_magna
00268 {
00269 Faith::Object *obj;
00270 T method;
00271 };
00272
00273 }
00274
00275
00276
00277
00278 #endif
00279