00001
00002 #ifndef __QApplication_h
00003 #define __QApplication_h
00004
00005 #include "qwidget.h"
00006 #include "GContainers.h"
00007 #include "GSemaphore.h"
00008
00009 #define XA_WmDeleteWindow XAtom[0]
00010 #define XA_WmProtocols XAtom[1]
00011 #define XA_Clipboard XAtom[2]
00012 #define XA_XdndEnter XAtom[3]
00013 #define XA_XdndPosition XAtom[4]
00014 #define XA_XdndStatus XAtom[5]
00015 #define XA_XdndLeave XAtom[6]
00016 #define XA_XdndDrop XAtom[7]
00017 #define XA_XdndFinished XAtom[8]
00018 #define XA_XdndSelection XAtom[9]
00019 #define XA_NetWmIcon XAtom[10]
00020 #define XA_Cardinal XAtom[11]
00021 #define XA_Max 20 // leave room for growth
00022
00023 class QApplication : public QEventSink, public GSemaphore
00024 {
00025 friend class QObject;
00026 friend class QPopup;
00027 friend class QWidgetPrivate;
00028 friend class QEvent;
00029 friend class QWidget;
00030 friend class QWindow;
00031
00032 static QApplication *_App;
00033 static QWidget *WantsFocus;
00034 class QApplicationPrivate *d;
00035
00036 Display *Dsp;
00037 QList<QWidget> Delete;
00038
00039
00040 Atom XAtom[XA_Max];
00041
00042
00043 char *ClipText;
00044 Pixmap ClipImage;
00045 QEventSink *SelectionSink;
00046
00047
00048 List<char> DndTypes, DndAccepted;
00049 class GDragDropTarget *DndTarget;
00050
00051
00052 void OnDeleteWidget(QWidget *w);
00053 void OnEvent(XEvent *Event);
00054 QWidget *GetKeyTarget();
00055
00056 public:
00057 QApplication(int args, char **arg);
00058 virtual ~QApplication();
00059
00060
00061 bool IsOk();
00062 QWidget *desktop();
00063 int exec();
00064 void onEvent(XEvent &Event);
00065 void processEvents();
00066 void exit(int code);
00067 void enter_loop();
00068 void exit_loop();
00069 void OnTabKey(QWidget *w, int Dir);
00070 uint64 GetLastButtonPressTime(int Button, int x, int y);
00071 OsThreadId GetGuiThread();
00072
00073
00074 QWidget *GetFocus();
00075 QWidget *GetFocusWindow();
00076 void SetFocus(QWidget *q);
00077
00078
00079 Atom GetClipboard() { return XA_Clipboard; }
00080 void EmptyClip();
00081 void SetClipText(QWidget *w, char *s);
00082 void SetClipImage(QWidget *w, class GSurface *pDC);
00083 void SetSelectionSink(QEventSink *s);
00084 bool GetSelection(Window w, Atom Selection, Atom Format, uchar *&Data, ulong &Len);
00085
00086
00087 static void postEvent(QWidget *o, QEvent *e);
00088 static int wheelScrollLines();
00089 static QApplication *GetApp() { return _App; }
00090 };
00091
00092 #endif