]> git.saurik.com Git - wxWidgets.git/blame - src/os2/app.cpp
fix for link errors in DLL build
[wxWidgets.git] / src / os2 / app.cpp
CommitLineData
0e320a79 1/////////////////////////////////////////////////////////////////////////////
ad9835c9 2// Name: src/os2/app.cpp
0e320a79 3// Purpose: wxApp
d88de032 4// Author: David Webster
0e320a79 5// Modified by:
d88de032 6// Created: 10/13/99
0e320a79 7// RCS-ID: $Id$
d88de032 8// Copyright: (c) David Webster
65571936 9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
d88de032
DW
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
e4db172a
WS
15#include "wx/app.h"
16
d88de032 17#ifndef WX_PRECOMP
ad9835c9 18 #include "wx/dynarray.h"
d88de032 19 #include "wx/frame.h"
d88de032
DW
20 #include "wx/utils.h"
21 #include "wx/gdicmn.h"
22 #include "wx/pen.h"
23 #include "wx/brush.h"
24 #include "wx/cursor.h"
25 #include "wx/icon.h"
26 #include "wx/palette.h"
27 #include "wx/dc.h"
28 #include "wx/dialog.h"
29 #include "wx/msgdlg.h"
30 #include "wx/intl.h"
3a3dde0d 31 #include "wx/crt.h"
e4db172a 32 #include "wx/log.h"
02761f6c 33 #include "wx/module.h"
0e320a79
DW
34#endif
35
f18ad9c6
WS
36#include "wx/stdpaths.h"
37#include "wx/filename.h"
38
d88de032
DW
39#include "wx/os2/private.h"
40
29d83fc1
DW
41#ifdef __EMX__
42
19193a2c
KB
43#include <sys/ioctl.h>
44#include <sys/select.h>
29d83fc1
DW
45
46#else
47
65b851bb 48#include <nerrno.h>
19193a2c
KB
49#include <sys/ioctl.h>
50#include <sys/select.h>
51#include <sys/time.h>
29d83fc1 52
19193a2c 53#endif //
29d83fc1 54
6670f564
WS
55#if defined(__WATCOMC__)
56
57#include <tcpustd.h>
58
59#elif !defined(__EMX__)
29d83fc1 60
3958ae62 61#define select(a,b,c,d,e) bsdselect(a,b,c,d,e)
19193a2c
KB
62extern "C" int _System bsdselect(int,
63 struct fd_set *,
64 struct fd_set *,
65 struct fd_set *,
66 struct timeval *);
3958ae62
SN
67#endif
68
d88de032
DW
69#if wxUSE_THREADS
70 #include "wx/thread.h"
d88de032 71#endif // wxUSE_THREADS
0e320a79 72
8df85a61
DW
73#if wxUSE_TOOLTIPS
74 #include "wx/tooltip.h"
75#endif // wxUSE_TOOLTIPS
76
0e320a79 77#include <string.h>
d88de032
DW
78#include <ctype.h>
79
80// ---------------------------------------------------------------------------
81// global variables
82// ---------------------------------------------------------------------------
83
e7445ff8 84WXDLLEXPORT_DATA(wxChar*) wxBuffer;
9ed0fac8 85extern wxCursor* g_globalCursor;
0e320a79 86
8df85a61 87HAB vHabmain = NULLHANDLE;
d88de032 88
d88de032 89
9ed0fac8
DW
90HICON wxSTD_FRAME_ICON = (HICON) NULL;
91HICON wxSTD_MDICHILDFRAME_ICON = (HICON) NULL;
d88de032
DW
92HICON wxSTD_MDIPARENTFRAME_ICON = (HICON) NULL;
93
9ed0fac8
DW
94HICON wxDEFAULT_FRAME_ICON = (HICON) NULL;
95HICON wxDEFAULT_MDICHILDFRAME_ICON = (HICON) NULL;
96HICON wxDEFAULT_MDIPARENTFRAME_ICON = (HICON) NULL;
d88de032
DW
97
98HBRUSH wxDisableButtonBrush = (HBRUSH) 0;
99
51c1d535
DW
100MRESULT EXPENTRY wxWndProc( HWND hWnd,ULONG message,MPARAM mp1,MPARAM mp2);
101MRESULT EXPENTRY wxFrameWndProc( HWND hWnd,ULONG message,MPARAM mp1,MPARAM mp2);
102
d88de032
DW
103// ===========================================================================
104// implementation
105// ===========================================================================
106
3958ae62
SN
107// ---------------------------------------------------------------------------
108// helper struct and functions for socket handling
109// ---------------------------------------------------------------------------
110
111struct GsocketCallbackInfo{
112 void (*proc)(void *);
113 int type;
114 int handle;
115 void* gsock;
116};
117
621b4574 118// These defines are used here and in gsockpm.cpp
3958ae62
SN
119#define wxSockReadMask 0x01
120#define wxSockWriteMask 0x02
121
3958ae62
SN
122void wxApp::HandleSockets()
123{
ad9835c9 124 bool pendingEvent = false;
3958ae62
SN
125
126 // Check whether it's time for Gsocket operation
127 if (m_maxSocketHandles > 0 && m_maxSocketNr > 0)
128 {
129 fd_set readfds = m_readfds;
130 fd_set writefds = m_writefds;
131 struct timeval timeout;
132 int i;
133 struct GsocketCallbackInfo
134 *CallbackInfo = (struct GsocketCallbackInfo *)m_sockCallbackInfo;
3958ae62
SN
135 timeout.tv_sec = 0;
136 timeout.tv_usec = 0;
137 if ( select(m_maxSocketNr, &readfds, &writefds, 0, &timeout) > 0)
138 {
5c9ee6dd
SN
139 for (i = m_lastUsedHandle + 1; i != m_lastUsedHandle;
140 (i < m_maxSocketNr - 1) ? i++ : (i = 0))
3958ae62 141 {
3958ae62
SN
142 if (FD_ISSET(i, &readfds))
143 {
144 int r;
145 for (r = 0; r < m_maxSocketHandles; r++){
146 if(CallbackInfo[r].handle == i &&
147 CallbackInfo[r].type == wxSockReadMask)
148 break;
149 }
150 if (r < m_maxSocketHandles)
151 {
152 CallbackInfo[r].proc(CallbackInfo[r].gsock);
ad9835c9 153 pendingEvent = true;
3958ae62
SN
154 }
155 }
156 if (FD_ISSET(i, &writefds))
157 {
158 int r;
159 for (r = 0; r < m_maxSocketHandles; r++)
160 if(CallbackInfo[r].handle == i &&
161 CallbackInfo[r].type == wxSockWriteMask)
162 break;
163 if (r < m_maxSocketHandles)
164 {
165 CallbackInfo[r].proc(CallbackInfo[r].gsock);
ad9835c9 166 pendingEvent = true;
3958ae62
SN
167 }
168 }
169 }
170 m_lastUsedHandle = i;
171 }
172 if (pendingEvent)
5c9ee6dd 173 ProcessPendingEvents();
3958ae62
SN
174 }
175}
d88de032
DW
176// ---------------------------------------------------------------------------
177// wxApp
178// ---------------------------------------------------------------------------
179
d88de032 180 IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
0e320a79 181
d88de032
DW
182 BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
183 EVT_IDLE(wxApp::OnIdle)
184 EVT_END_SESSION(wxApp::OnEndSession)
185 EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession)
186 END_EVENT_TABLE()
0e320a79 187
8df85a61
DW
188//
189// Initialize
190//
05e2b077 191bool wxApp::Initialize(int& argc, wxChar **argv)
0e320a79 192{
94826170
VZ
193 if ( !wxAppBase::Initialize(argc, argv) )
194 return false;
195
7e99520b
DW
196#if defined(wxUSE_CONSOLEDEBUG)
197 #if wxUSE_CONSOLEDEBUG
198/***********************************************/
199/* Code for using stdout debug */
200/* To use it you mast link app as "Window" - EK*/
201/***********************************************/
202 {
203 PPIB pib;
204 PTIB tib;
205
206 printf("In console\n");
207
208 DosGetInfoBlocks(&tib, &pib);
209/* Try morphing into a PM application. */
210// if(pib->pib_ultype == 2) /* VIO */
211 pib->pib_ultype = 3;
212 }
213/**********************************************/
214/**********************************************/
215 #endif //wxUSE_CONSOLEDEBUG
216#endif
217
54ffa107
DW
218 //
219 // OS2 has to have an anchorblock
220 //
94826170 221 vHabmain = WinInitialize(0);
175bb578
SN
222 wxFileName GetPrefix(argv[0]);
223 GetPrefix.MakeAbsolute();
224 wxStandardPaths::SetInstallPrefix(GetPrefix.GetPath());
94826170
VZ
225 if (!vHabmain)
226 {
227 // TODO: at least give some error message here...
228 wxAppBase::CleanUp();
54ffa107 229
ad9835c9 230 return false;
94826170
VZ
231 }
232
233 wxBuffer = new wxChar[1500]; // FIXME; why?
54ffa107
DW
234
235 // Some people may wish to use this, but
236 // probably it shouldn't be here by default.
237#ifdef __WXDEBUG__
238 // wxRedirectIOToConsole();
239#endif
240
2461cfa0 241 wxWinHandleHash = new wxWinHashTable(wxKEY_INTEGER, 100);
d88de032
DW
242
243 // This is to foil optimizations in Visual C++ that throw out dummy.obj.
244 // PLEASE DO NOT ALTER THIS.
1b3d5e55 245#if !defined(WXMAKINGDLL) && defined(__VISAGECPP__)
d88de032
DW
246 extern char wxDummyChar;
247 if (wxDummyChar) wxDummyChar++;
248#endif
249
61243a51 250 // wxSetKeyboardHook(TRUE);
d88de032 251
459073a9 252 RegisterWindowClasses(vHabmain);
94826170 253
ad9835c9 254 return true;
8df85a61 255} // end of wxApp::Initialize
d88de032 256
7e99520b 257const char* CANTREGISTERCLASS = " Can't register Class ";
d88de032
DW
258// ---------------------------------------------------------------------------
259// RegisterWindowClasses
260// ---------------------------------------------------------------------------
261
ad9835c9 262bool wxApp::RegisterWindowClasses( HAB vHab )
d88de032 263{
ad9835c9
WS
264 ERRORID vError = 0L;
265 wxString sError;
3b9e3455 266
f23208ca 267 if (!::WinRegisterClass( vHab
0fba44b4 268 ,(PSZ)wxFrameClassName
51c1d535 269 ,wxFrameWndProc
f9efbe3a 270 ,CS_SIZEREDRAW | CS_SYNCPAINT
a0606634 271 ,sizeof(ULONG)
f23208ca 272 ))
d88de032 273 {
914589c2
DW
274 vError = ::WinGetLastError(vHab);
275 sError = wxPMErrorToStr(vError);
9923c37d 276 wxLogLastError(sError.c_str());
ad9835c9 277 return false;
d88de032
DW
278 }
279
f23208ca 280 if (!::WinRegisterClass( vHab
0fba44b4 281 ,(PSZ)wxFrameClassNameNoRedraw
51c1d535 282 ,wxWndProc
f23208ca 283 ,0
51c1d535 284 ,sizeof(ULONG)
f23208ca 285 ))
d88de032 286 {
914589c2
DW
287 vError = ::WinGetLastError(vHab);
288 sError = wxPMErrorToStr(vError);
9923c37d 289 wxLogLastError(sError.c_str());
ad9835c9 290 return false;
d88de032
DW
291 }
292
f23208ca 293 if (!::WinRegisterClass( vHab
0fba44b4 294 ,(PSZ)wxMDIFrameClassName
51c1d535 295 ,wxWndProc
f6bcfd97 296 ,CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT
51c1d535 297 ,sizeof(ULONG)
f23208ca 298 ))
d88de032 299 {
914589c2
DW
300 vError = ::WinGetLastError(vHab);
301 sError = wxPMErrorToStr(vError);
9923c37d 302 wxLogLastError(sError.c_str());
ad9835c9 303 return false;
d88de032 304 }
0e320a79 305
f23208ca 306 if (!::WinRegisterClass( vHab
0fba44b4 307 ,(PSZ)wxMDIFrameClassNameNoRedraw
51c1d535 308 ,wxWndProc
f23208ca 309 ,0
51c1d535 310 ,sizeof(ULONG)
f23208ca 311 ))
d88de032 312 {
914589c2
DW
313 vError = ::WinGetLastError(vHab);
314 sError = wxPMErrorToStr(vError);
9923c37d 315 wxLogLastError(sError.c_str());
ad9835c9 316 return false;
d88de032
DW
317 }
318
f23208ca 319 if (!::WinRegisterClass( vHab
0fba44b4 320 ,(PSZ)wxMDIChildFrameClassName
51c1d535 321 ,wxWndProc
f23208ca 322 ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_SYNCPAINT | CS_HITTEST
51c1d535 323 ,sizeof(ULONG)
f23208ca 324 ))
d88de032 325 {
914589c2
DW
326 vError = ::WinGetLastError(vHab);
327 sError = wxPMErrorToStr(vError);
9923c37d 328 wxLogLastError(sError.c_str());
ad9835c9 329 return false;
d88de032
DW
330 }
331
f23208ca 332 if (!::WinRegisterClass( vHab
0fba44b4 333 ,(PSZ)wxMDIChildFrameClassNameNoRedraw
51c1d535 334 ,wxWndProc
f23208ca 335 ,CS_HITTEST
51c1d535 336 ,sizeof(ULONG)
f23208ca 337 ))
d88de032 338 {
914589c2
DW
339 vError = ::WinGetLastError(vHab);
340 sError = wxPMErrorToStr(vError);
9923c37d 341 wxLogLastError(sError.c_str());
ad9835c9 342 return false;
d88de032
DW
343 }
344
f23208ca 345 if (!::WinRegisterClass( vHab
0fba44b4 346 ,(PSZ)wxPanelClassName
51c1d535 347 ,wxWndProc
f23208ca 348 ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT
51c1d535 349 ,sizeof(ULONG)
f23208ca 350 ))
d88de032 351 {
914589c2
DW
352 vError = ::WinGetLastError(vHab);
353 sError = wxPMErrorToStr(vError);
9923c37d 354 wxLogLastError(sError.c_str());
ad9835c9 355 return false;
d88de032
DW
356 }
357
f23208ca 358 if (!::WinRegisterClass( vHab
0fba44b4 359 ,(PSZ)wxCanvasClassName
51c1d535 360 ,wxWndProc
54ffa107 361 ,CS_SIZEREDRAW | CS_HITTEST | CS_SYNCPAINT
51c1d535 362 ,sizeof(ULONG)
f23208ca 363 ))
d88de032 364 {
914589c2
DW
365 vError = ::WinGetLastError(vHab);
366 sError = wxPMErrorToStr(vError);
9923c37d 367 wxLogLastError(sError.c_str());
ad9835c9 368 return false;
d88de032 369 }
0256cfeb 370 if (!::WinRegisterClass( vHab
0fba44b4 371 ,(PSZ)wxCanvasClassNameNR
0256cfeb
DW
372 ,wxWndProc
373 ,CS_HITTEST | CS_SYNCPAINT
374 ,sizeof(ULONG)
375 ))
376 {
377 vError = ::WinGetLastError(vHab);
378 sError = wxPMErrorToStr(vError);
9923c37d 379 wxLogLastError(sError.c_str());
ad9835c9 380 return false;
0256cfeb 381 }
ad9835c9 382 return true;
8df85a61 383} // end of wxApp::RegisterWindowClasses
d88de032 384
8df85a61 385//
77ffb593 386// Cleans up any wxWidgets internal structures left lying around
8df85a61 387//
0e320a79
DW
388void wxApp::CleanUp()
389{
d88de032
DW
390 delete[] wxBuffer;
391 wxBuffer = NULL;
0e320a79 392
8df85a61
DW
393 //
394 // PM-SPECIFIC CLEANUP
395 //
0e320a79 396
ad9835c9 397 // wxSetKeyboardHook(false);
9ed0fac8 398
d88de032 399 if (wxSTD_FRAME_ICON)
9ed0fac8 400 ::WinFreeFileIcon(wxSTD_FRAME_ICON);
d88de032 401 if (wxSTD_MDICHILDFRAME_ICON)
9ed0fac8 402 ::WinFreeFileIcon(wxSTD_MDICHILDFRAME_ICON);
d88de032 403 if (wxSTD_MDIPARENTFRAME_ICON)
9ed0fac8 404 ::WinFreeFileIcon(wxSTD_MDIPARENTFRAME_ICON);
d88de032
DW
405
406 if (wxDEFAULT_FRAME_ICON)
9ed0fac8 407 ::WinFreeFileIcon(wxDEFAULT_FRAME_ICON);
d88de032 408 if (wxDEFAULT_MDICHILDFRAME_ICON)
9ed0fac8 409 ::WinFreeFileIcon(wxDEFAULT_MDICHILDFRAME_ICON);
d88de032 410 if (wxDEFAULT_MDIPARENTFRAME_ICON)
9ed0fac8
DW
411 ::WinFreeFileIcon(wxDEFAULT_MDIPARENTFRAME_ICON);
412
d88de032
DW
413 if ( wxDisableButtonBrush )
414 {
415// TODO: ::DeleteObject( wxDisableButtonBrush );
416 }
417
2461cfa0
SN
418 delete wxWinHandleHash;
419 wxWinHandleHash = NULL;
d88de032 420
468e327a
SN
421 // Delete Message queue
422 if (wxTheApp->m_hMq)
423 ::WinDestroyMsgQueue(wxTheApp->m_hMq);
424
94826170 425 wxAppBase::CleanUp();
8df85a61 426} // end of wxApp::CleanUp
0e320a79 427
9ed0fac8 428bool wxApp::OnInitGui()
d88de032 429{
ad9835c9
WS
430 ERRORID vError;
431 wxString sError;
77cd51c3 432
19193a2c 433 if (!wxAppBase::OnInitGui())
ad9835c9 434 return false;
19193a2c 435
f23208ca 436 m_hMq = ::WinCreateMsgQueue(vHabmain, 0);
914589c2
DW
437 if (!m_hMq)
438 {
439 vError = ::WinGetLastError(vHabmain);
440 sError = wxPMErrorToStr(vError);
441 wxLogDebug(sError);
ad9835c9 442 return false;
914589c2 443 }
19193a2c 444
ad9835c9 445 return true;
8df85a61 446} // end of wxApp::OnInitGui
0e320a79 447
0e320a79
DW
448wxApp::wxApp()
449{
9ed0fac8 450 m_nPrintMode = wxPRINT_WINDOWS;
468e327a 451 m_hMq = 0;
3958ae62
SN
452 m_maxSocketHandles = 0;
453 m_maxSocketNr = 0;
454 m_sockCallbackInfo = 0;
8df85a61 455} // end of wxApp::wxApp
d88de032
DW
456
457wxApp::~wxApp()
458{
8df85a61 459} // end of wxApp::~wxApp
0e320a79 460
ad9835c9 461bool gbInOnIdle = false;
2b5f62a0 462
4bbd8098 463void wxApp::OnIdle( wxIdleEvent& WXUNUSED(rEvent) )
d88de032 464{
9ed0fac8 465 //
d88de032 466 // Avoid recursion (via ProcessEvent default case)
9ed0fac8 467 //
2b5f62a0 468 if (gbInOnIdle)
d88de032 469 return;
0e320a79 470
6670f564
WS
471 gbInOnIdle = true;
472
893758d5
DW
473#if wxUSE_DC_CACHEING
474 // automated DC cache management: clear the cached DCs and bitmap
475 // if it's likely that the app has finished with them, that is, we
476 // get an idle event and we're not dragging anything.
19193a2c
KB
477 if (!::WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) &&
478 !::WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) &&
479 !::WinGetKeyState(HWND_DESKTOP, VK_BUTTON2))
893758d5
DW
480 wxDC::ClearCache();
481#endif // wxUSE_DC_CACHEING
482
ad9835c9 483 gbInOnIdle = false;
8df85a61 484} // end of wxApp::OnIdle
9779893b 485
9ed0fac8
DW
486void wxApp::OnEndSession(
487 wxCloseEvent& WXUNUSED(rEvent))
0e320a79 488{
d88de032 489 if (GetTopWindow())
ad9835c9 490 GetTopWindow()->Close(true);
8df85a61 491} // end of wxApp::OnEndSession
0e320a79 492
9ed0fac8 493//
d88de032
DW
494// Default behaviour: close the application with prompts. The
495// user can veto the close, and therefore the end session.
9ed0fac8 496//
ad9835c9 497void wxApp::OnQueryEndSession( wxCloseEvent& rEvent )
0e320a79 498{
d88de032
DW
499 if (GetTopWindow())
500 {
9ed0fac8 501 if (!GetTopWindow()->Close(!rEvent.CanVeto()))
ad9835c9 502 rEvent.Veto(true);
d88de032 503 }
8df85a61 504} // end of wxApp::OnQueryEndSession
0e320a79 505
8df85a61 506//
d88de032 507// Yield to incoming messages
8df85a61 508//
8461e4c2 509bool wxApp::Yield(bool onlyIfNeeded)
0e320a79 510{
ad9835c9 511 static bool s_inYield = false;
8461e4c2
VZ
512
513 if ( s_inYield )
514 {
515 if ( !onlyIfNeeded )
516 {
517 wxFAIL_MSG( _T("wxYield() called recursively") );
518 }
519
ad9835c9 520 return false;
8461e4c2
VZ
521 }
522
ad9835c9
WS
523 HAB vHab = 0;
524 QMSG vMsg;
ee453a16 525
8df85a61
DW
526 //
527 // Disable log flushing from here because a call to wxYield() shouldn't
528 // normally result in message boxes popping up &c
529 //
530 wxLog::Suspend();
531
ad9835c9 532 s_inYield = true;
8b63ae37 533
8df85a61 534 //
d88de032
DW
535 // We want to go back to the main message loop
536 // if we see a WM_QUIT. (?)
8df85a61 537 //
dde11e60 538 while (::WinPeekMsg(vHab, &vMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) && vMsg.msg != WM_QUIT)
d88de032 539 {
8df85a61
DW
540#if wxUSE_THREADS
541 wxMutexGuiLeaveOrEnter();
542#endif // wxUSE_THREADS
598dc9b7 543 if (!wxTheApp->Dispatch())
d88de032
DW
544 break;
545 }
8df85a61 546 //
d88de032 547 // If they are pending events, we must process them.
8df85a61
DW
548 //
549 if (wxTheApp)
550 wxTheApp->ProcessPendingEvents();
551
5c9ee6dd 552 HandleSockets();
8df85a61
DW
553 //
554 // Let the logs be flashed again
555 //
556 wxLog::Resume();
ad9835c9
WS
557 s_inYield = false;
558 return true;
8df85a61 559} // end of wxYield
d88de032 560
3958ae62
SN
561int wxApp::AddSocketHandler(int handle, int mask,
562 void (*callback)(void*), void * gsock)
563{
564 int find;
565 struct GsocketCallbackInfo
566 *CallbackInfo = (struct GsocketCallbackInfo *)m_sockCallbackInfo;
567
568 for (find = 0; find < m_maxSocketHandles; find++)
569 if (CallbackInfo[find].handle == -1)
570 break;
571 if (find == m_maxSocketHandles)
572 {
573 // Allocate new memory
574 m_sockCallbackInfo = realloc(m_sockCallbackInfo,
575 (m_maxSocketHandles+=10)*
576 sizeof(struct GsocketCallbackInfo));
577 CallbackInfo = (struct GsocketCallbackInfo *)m_sockCallbackInfo;
578 for (find = m_maxSocketHandles - 10; find < m_maxSocketHandles; find++)
579 CallbackInfo[find].handle = -1;
580 find = m_maxSocketHandles - 10;
581 }
582 CallbackInfo[find].proc = callback;
583 CallbackInfo[find].type = mask;
584 CallbackInfo[find].handle = handle;
585 CallbackInfo[find].gsock = gsock;
586 if (mask & wxSockReadMask)
587 FD_SET(handle, &m_readfds);
588 if (mask & wxSockWriteMask)
589 FD_SET(handle, &m_writefds);
590 if (handle >= m_maxSocketNr)
591 m_maxSocketNr = handle + 1;
592 return find;
593}
594
595void wxApp::RemoveSocketHandler(int handle)
596{
597 struct GsocketCallbackInfo
598 *CallbackInfo = (struct GsocketCallbackInfo *)m_sockCallbackInfo;
599 if (handle < m_maxSocketHandles)
600 {
601 if (CallbackInfo[handle].type & wxSockReadMask)
602 FD_CLR(CallbackInfo[handle].handle, &m_readfds);
603 if (CallbackInfo[handle].type & wxSockWriteMask)
604 FD_CLR(CallbackInfo[handle].handle, &m_writefds);
605 CallbackInfo[handle].handle = -1;
606 }
607}
608
8df85a61
DW
609//-----------------------------------------------------------------------------
610// wxWakeUpIdle
611//-----------------------------------------------------------------------------
612
e2478fde 613void wxApp::WakeUpIdle()
8df85a61
DW
614{
615 //
616 // Send the top window a dummy message so idle handler processing will
617 // start up again. Doing it this way ensures that the idle handler
618 // wakes up in the right thread (see also wxWakeUpMainThread() which does
619 // the same for the main app thread only)
620 //
621 wxWindow* pTopWindow = wxTheApp->GetTopWindow();
622
623 if (pTopWindow)
624 {
625 if ( !::WinPostMsg(GetHwndOf(pTopWindow), WM_NULL, (MPARAM)0, (MPARAM)0))
626 {
627 //
628 // Should never happen
629 //
2173b18f 630 wxLogLastError(wxT("PostMessage(WM_NULL)"));
8df85a61
DW
631 }
632 }
633} // end of wxWakeUpIdle
d88de032 634
76990f63 635HAB wxGetInstance()
d88de032 636{
76990f63 637 return vHabmain;
d88de032
DW
638}
639
6670f564 640void wxSetInstance( HAB vHab )
d88de032 641{
76990f63 642 vHabmain = vHab;
0e320a79 643}