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