Add support for the eventual inclusion of the single instance code.
[wxWidgets.git] / include / wx / os2 / app.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: app.h
3 // Purpose: wxApp class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/13/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_APP_H_
13 #define _WX_APP_H_
14
15 #include <sys/time.h>
16 #include <sys/types.h>
17
18 #ifdef __EMX__
19 #include <unistd.h>
20 #else
21 #include <utils.h>
22 #undef BYTE_ORDER
23 #include <types.h>
24 #define INCL_ORDERS
25 #endif
26
27 #include "wx/event.h"
28 #include "wx/icon.h"
29
30 class WXDLLEXPORT wxFrame;
31 class WXDLLEXPORT wxWindow;
32 class WXDLLEXPORT wxApp;
33 class WXDLLEXPORT wxKeyEvent;
34 class WXDLLEXPORT wxLog;
35
36 WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
37 WXDLLEXPORT_DATA(extern HAB) vHabmain;
38
39 // Force an exit from main loop
40 void WXDLLEXPORT wxExit(void);
41
42 // Yield to other apps/messages
43 bool WXDLLEXPORT wxYield(void);
44
45 extern MRESULT EXPENTRY wxWndProc( HWND
46 ,ULONG
47 ,MPARAM
48 ,MPARAM
49 );
50
51
52 // Represents the application. Derive OnInit and declare
53 // a new App object to start application
54 class WXDLLEXPORT wxApp : public wxAppBase
55 {
56 DECLARE_DYNAMIC_CLASS(wxApp)
57
58 public:
59 wxApp();
60 virtual ~wxApp();
61
62 virtual bool OnInitGui(void);
63
64 // override base class (pure) virtuals
65 virtual int MainLoop(void);
66 virtual void ExitMainLoop(void);
67 virtual bool Initialized(void);
68 virtual bool Pending(void) ;
69 virtual void Dispatch(void);
70
71 virtual wxIcon GetStdIcon(int which) const;
72
73 virtual void SetPrintMode(int mode) { m_nPrintMode = mode; }
74 virtual int GetPrintMode(void) const { return m_nPrintMode; }
75
76 // implementation only
77 void OnIdle(wxIdleEvent& rEvent);
78 void OnEndSession(wxCloseEvent& rEvent);
79 void OnQueryEndSession(wxCloseEvent& rEvent);
80
81 // Send idle event to all top-level windows.
82 // Returns TRUE if more idle time is requested.
83 bool SendIdleEvents(void);
84
85 // Send idle event to window and all subwindows
86 // Returns TRUE if more idle time is requested.
87 bool SendIdleEvents(wxWindow* pWin);
88
89 void SetAuto3D(bool bFlag) { m_bAuto3D = bFlag; }
90 bool GetAuto3D(void) const { return m_bAuto3D; }
91
92 int AddSocketHandler(int handle, int mask,
93 void (*callback)(void*), void * gsock);
94 void RemoveSocketHandler(int handle);
95 void HandleSockets();
96
97 protected:
98 bool m_bShowOnInit;
99 int m_nPrintMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
100 bool m_bAuto3D ; // Always use 3D controls, except where overriden
101
102 //
103 // PM-specific wxApp definitions */
104 //
105 private:
106 int m_maxSocketHandles;
107 int m_maxSocketNr;
108 int m_lastUsedHandle;
109 fd_set m_readfds;
110 fd_set m_writefds;
111 void* m_sockCallbackInfo;
112
113 public:
114
115 // Implementation
116 static bool Initialize(HAB vHab);
117 static void CleanUp(void);
118
119 static bool RegisterWindowClasses(HAB vHab);
120 virtual void DoMessage(WXMSG *pMsg);
121 virtual bool DoMessage(void);
122 virtual bool ProcessMessage(WXMSG* pMsg);
123 void DeletePendingObjects(void);
124 bool ProcessIdle(void);
125
126 public:
127 int m_nCmdShow;
128 HMQ m_hMq;
129
130 protected:
131 bool m_bKeepGoing ;
132
133 DECLARE_EVENT_TABLE()
134 };
135
136 int WXDLLEXPORT wxEntry( int argc, char *argv[] );
137 #endif
138 // _WX_APP_H_
139