00001 #ifndef KDE__APPLICATION_H
00002 #define KDE__APPLICATION_H
00003
00004 #include <vector>
00005
00006 #include <faith/object.h>
00007 #include <faith/global.h>
00008
00009 #ifdef WIN32
00010
00011 typedef void* Handle;
00012
00013 extern "C" int __declspec(dllexport) main(int argc, char **argv);
00014
00015
00016
00017
00018 #define main __declspec(dllexport) main
00019
00020 #else
00021 #define WITH_X11
00022 typedef long Handle;
00023 #endif
00024
00025 #ifdef WITH_X11
00026 #include <X11/Xlib.h>
00027 #undef None
00028
00029 #endif
00030
00031
00032 namespace Faith
00033 {
00034 #ifdef WITH_GUI
00035 class Widget;
00036 class Font;
00037 class Style;
00038 class ColorGroup;
00039 #endif
00040 class SocketNotifier;
00041
00053 class FAITH_CORE_EXPORT Application : public Object
00054 {
00055 Q_OBJECT
00056 struct Private;
00057 Private *d;
00058
00059 friend class ::Faith::Object;
00060 friend class ::Faith::SocketNotifier;
00061 friend class ::Faith::Widget;
00062
00063 #ifdef INTERNAL_GLOBALS_WIN32_H
00064 friend LRESULT CALLBACK ::Faith::Internal::wndProc(HWND, UINT msg, WPARAM w, LPARAM l);
00065 #endif
00066
00067
00068 std::list<Faith::TimerInfo> *mTimers;
00069 std::vector<Faith::SocketNotifier*> mSockets;
00070
00071 private:
00072 #ifdef WITH_GUI
00073 void addWidget(Widget *w);
00074 void layoutWidget(Widget *w);
00075 void addWidgetEventLoop(Faith::Widget *w);
00076 void removeWidget(Widget *w);
00077 void addUpdateRequest(Faith::Widget *w);
00078 #endif
00079 void deleteLater(Faith::Object *w);
00080 void objectDeleted(Faith::Object *w);
00081 #ifdef WIN32
00082 void faith_setFocusWidget(Faith::Widget *w);
00083 #endif
00084
00085 signals:
00092 void aboutToExit();
00093
00094 public:
00101 Application(int argc, char **argv, bool gui=true);
00102 virtual ~Application();
00103
00107 int exec();
00108
00112 void processEvents();
00113
00114 #ifdef WITH_GUI
00115
00119 void setStyle(Style *style);
00120
00125 Style *style();
00126
00130 const ColorGroup &colorGroup() const;
00131 #endif
00132
00133 #ifdef WITH_X11
00134 Display *x11Display();
00135 void xEvent(XEvent *event);
00136 void xExposeEvents(XEvent *events, int count);
00137 Handle x11Screen();
00138 #elif WIN32
00139 int win32Event(void *event);
00140 #endif
00141
00145 virtual void warning(const char *message);
00146
00147 #ifdef WITH_GUI
00148
00151 Font font(Faith::Widget *widget=0);
00152 #endif
00153
00163 void postEvent(Faith::Object *dest, Faith::Event *e);
00164
00165 public slots:
00170 void quit();
00171
00172 private:
00173 void exec(bool repeat);
00174
00175 };
00176
00177 extern FAITH_CORE_EXPORT Application *faithapp;
00178 }
00179
00180 #endif