]> git.saurik.com Git - wxWidgets.git/blame - src/os2/app.cpp
wx-config2.6
[wxWidgets.git] / src / os2 / app.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: app.cpp
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
272ebf16
SN
12#ifdef __GNUG__
13 #pragma implementation "app.h"
14#endif
15
d88de032
DW
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifndef WX_PRECOMP
20 #include "wx/frame.h"
21 #include "wx/app.h"
22 #include "wx/utils.h"
23 #include "wx/gdicmn.h"
24 #include "wx/pen.h"
25 #include "wx/brush.h"
26 #include "wx/cursor.h"
27 #include "wx/icon.h"
28 #include "wx/palette.h"
29 #include "wx/dc.h"
30 #include "wx/dialog.h"
31 #include "wx/msgdlg.h"
32 #include "wx/intl.h"
33 #include "wx/dynarray.h"
cb21bd1b
SN
34 #include "wx/wxchar.h"
35 #include "wx/icon.h"
0e320a79
DW
36#endif
37
0e320a79
DW
38#include "wx/log.h"
39#include "wx/module.h"
d88de032
DW
40
41#include "wx/os2/private.h"
42
29d83fc1
DW
43#ifdef __EMX__
44
19193a2c
KB
45#include <sys/ioctl.h>
46#include <sys/select.h>
29d83fc1
DW
47
48#else
49
65b851bb 50#include <nerrno.h>
19193a2c
KB
51#include <sys/ioctl.h>
52#include <sys/select.h>
53#include <sys/time.h>
29d83fc1 54
19193a2c 55#endif //
29d83fc1 56
3958ae62 57#ifndef __EMX__
29d83fc1 58
3958ae62 59#define select(a,b,c,d,e) bsdselect(a,b,c,d,e)
19193a2c
KB
60extern "C" int _System bsdselect(int,
61 struct fd_set *,
62 struct fd_set *,
63 struct fd_set *,
64 struct timeval *);
3958ae62
SN
65#endif
66
d88de032
DW
67#if wxUSE_THREADS
68 #include "wx/thread.h"
d88de032 69#endif // wxUSE_THREADS
0e320a79 70
8df85a61
DW
71#if wxUSE_TOOLTIPS
72 #include "wx/tooltip.h"
73#endif // wxUSE_TOOLTIPS
74
0e320a79 75#include <string.h>
d88de032
DW
76#include <ctype.h>
77
78// ---------------------------------------------------------------------------
79// global variables
80// ---------------------------------------------------------------------------
81
9ed0fac8 82extern wxChar* wxBuffer;
9ed0fac8
DW
83extern wxList* wxWinHandleList;
84extern wxList WXDLLEXPORT wxPendingDelete;
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{
29d83fc1 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);
29d83fc1 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);
29d83fc1 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
VZ
221 vHabmain = WinInitialize(0);
222
223 if (!vHabmain)
224 {
225 // TODO: at least give some error message here...
226 wxAppBase::CleanUp();
54ffa107 227
54ffa107 228 return FALSE;
94826170
VZ
229 }
230
231 wxBuffer = new wxChar[1500]; // FIXME; why?
54ffa107
DW
232
233 // Some people may wish to use this, but
234 // probably it shouldn't be here by default.
235#ifdef __WXDEBUG__
236 // wxRedirectIOToConsole();
237#endif
238
d88de032
DW
239 wxWinHandleList = new wxList(wxKEY_INTEGER);
240
241 // This is to foil optimizations in Visual C++ that throw out dummy.obj.
242 // PLEASE DO NOT ALTER THIS.
1b3d5e55 243#if !defined(WXMAKINGDLL) && defined(__VISAGECPP__)
d88de032
DW
244 extern char wxDummyChar;
245 if (wxDummyChar) wxDummyChar++;
246#endif
247
61243a51 248 // wxSetKeyboardHook(TRUE);
d88de032 249
459073a9 250 RegisterWindowClasses(vHabmain);
94826170 251
d88de032 252 return TRUE;
8df85a61 253} // end of wxApp::Initialize
d88de032 254
7e99520b 255const char* CANTREGISTERCLASS = " Can't register Class ";
d88de032
DW
256// ---------------------------------------------------------------------------
257// RegisterWindowClasses
258// ---------------------------------------------------------------------------
259
9ed0fac8
DW
260bool wxApp::RegisterWindowClasses(
261 HAB vHab
262)
d88de032 263{
914589c2
DW
264 ERRORID vError = 0L;
265 wxString sError;
3b9e3455 266
f23208ca
DW
267 if (!::WinRegisterClass( vHab
268 ,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());
d88de032
DW
277 return FALSE;
278 }
279
f23208ca
DW
280 if (!::WinRegisterClass( vHab
281 ,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());
d88de032
DW
290 return FALSE;
291 }
292
f23208ca
DW
293 if (!::WinRegisterClass( vHab
294 ,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());
d88de032
DW
303 return FALSE;
304 }
0e320a79 305
f23208ca
DW
306 if (!::WinRegisterClass( vHab
307 ,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());
d88de032
DW
316 return FALSE;
317 }
318
f23208ca
DW
319 if (!::WinRegisterClass( vHab
320 ,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());
d88de032
DW
329 return FALSE;
330 }
331
f23208ca
DW
332 if (!::WinRegisterClass( vHab
333 ,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());
d88de032
DW
342 return FALSE;
343 }
344
f23208ca
DW
345 if (!::WinRegisterClass( vHab
346 ,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());
d88de032
DW
355 return FALSE;
356 }
357
f23208ca
DW
358 if (!::WinRegisterClass( vHab
359 ,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());
d88de032
DW
368 return FALSE;
369 }
0256cfeb
DW
370 if (!::WinRegisterClass( vHab
371 ,wxCanvasClassNameNR
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());
0256cfeb
DW
380 return FALSE;
381 }
d88de032 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
61243a51 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
418 if (wxWinHandleList)
419 delete wxWinHandleList;
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{
914589c2
DW
430 ERRORID vError;
431 wxString sError;
77cd51c3 432
19193a2c
KB
433 if (!wxAppBase::OnInitGui())
434 return FALSE;
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);
442 return FALSE;
443 }
19193a2c 444
9ed0fac8 445 return TRUE;
8df85a61 446} // end of wxApp::OnInitGui
0e320a79 447
0e320a79
DW
448wxApp::wxApp()
449{
d88de032
DW
450 argc = 0;
451 argv = NULL;
9ed0fac8 452 m_nPrintMode = wxPRINT_WINDOWS;
468e327a 453 m_hMq = 0;
3958ae62
SN
454 m_maxSocketHandles = 0;
455 m_maxSocketNr = 0;
456 m_sockCallbackInfo = 0;
8df85a61 457} // end of wxApp::wxApp
d88de032
DW
458
459wxApp::~wxApp()
460{
8df85a61 461 //
d88de032 462 // Delete command-line args
8df85a61 463 //
039bec17 464#if wxUSE_UNICODE
8df85a61
DW
465 int i;
466
d88de032
DW
467 for (i = 0; i < argc; i++)
468 {
469 delete[] argv[i];
470 }
471 delete[] argv;
039bec17 472#endif
8df85a61 473} // end of wxApp::~wxApp
0e320a79 474
2b5f62a0
VZ
475bool gbInOnIdle = FALSE;
476
9ed0fac8
DW
477void wxApp::OnIdle(
478 wxIdleEvent& rEvent
479)
d88de032 480{
d88de032 481
9ed0fac8 482 //
d88de032 483 // Avoid recursion (via ProcessEvent default case)
9ed0fac8 484 //
2b5f62a0 485 if (gbInOnIdle)
d88de032 486 return;
0e320a79 487
2b5f62a0 488 gbInOnIdle = TRUE;
955a9197 489
459073a9 490 wxAppBase::OnIdle(rEvent);
0e320a79 491
893758d5
DW
492#if wxUSE_DC_CACHEING
493 // automated DC cache management: clear the cached DCs and bitmap
494 // if it's likely that the app has finished with them, that is, we
495 // get an idle event and we're not dragging anything.
19193a2c
KB
496 if (!::WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) &&
497 !::WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) &&
498 !::WinGetKeyState(HWND_DESKTOP, VK_BUTTON2))
893758d5
DW
499 wxDC::ClearCache();
500#endif // wxUSE_DC_CACHEING
501
2b5f62a0 502 gbInOnIdle = FALSE;
8df85a61 503} // end of wxApp::OnIdle
9779893b 504
9ed0fac8
DW
505void wxApp::OnEndSession(
506 wxCloseEvent& WXUNUSED(rEvent))
0e320a79 507{
d88de032
DW
508 if (GetTopWindow())
509 GetTopWindow()->Close(TRUE);
8df85a61 510} // end of wxApp::OnEndSession
0e320a79 511
9ed0fac8 512//
d88de032
DW
513// Default behaviour: close the application with prompts. The
514// user can veto the close, and therefore the end session.
9ed0fac8
DW
515//
516void wxApp::OnQueryEndSession(
517 wxCloseEvent& rEvent
518)
0e320a79 519{
d88de032
DW
520 if (GetTopWindow())
521 {
9ed0fac8
DW
522 if (!GetTopWindow()->Close(!rEvent.CanVeto()))
523 rEvent.Veto(TRUE);
d88de032 524 }
8df85a61 525} // end of wxApp::OnQueryEndSession
0e320a79 526
8df85a61 527//
d88de032 528// Yield to incoming messages
8df85a61 529//
8461e4c2 530bool wxApp::Yield(bool onlyIfNeeded)
0e320a79 531{
8461e4c2
VZ
532 static bool s_inYield = FALSE;
533
534 if ( s_inYield )
535 {
536 if ( !onlyIfNeeded )
537 {
538 wxFAIL_MSG( _T("wxYield() called recursively") );
539 }
540
541 return FALSE;
542 }
543
9dea36ef 544 HAB vHab = 0;
dde11e60 545 QMSG vMsg;
ee453a16 546
8df85a61
DW
547 //
548 // Disable log flushing from here because a call to wxYield() shouldn't
549 // normally result in message boxes popping up &c
550 //
551 wxLog::Suspend();
552
8461e4c2 553 s_inYield = TRUE;
8b63ae37 554
8df85a61 555 //
d88de032
DW
556 // We want to go back to the main message loop
557 // if we see a WM_QUIT. (?)
8df85a61 558 //
dde11e60 559 while (::WinPeekMsg(vHab, &vMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) && vMsg.msg != WM_QUIT)
d88de032 560 {
8df85a61
DW
561#if wxUSE_THREADS
562 wxMutexGuiLeaveOrEnter();
563#endif // wxUSE_THREADS
598dc9b7 564 if (!wxTheApp->Dispatch())
d88de032
DW
565 break;
566 }
8df85a61 567 //
d88de032 568 // If they are pending events, we must process them.
8df85a61
DW
569 //
570 if (wxTheApp)
571 wxTheApp->ProcessPendingEvents();
572
5c9ee6dd 573 HandleSockets();
8df85a61
DW
574 //
575 // Let the logs be flashed again
576 //
577 wxLog::Resume();
8461e4c2 578 s_inYield = FALSE;
d88de032 579 return TRUE;
8df85a61 580} // end of wxYield
d88de032 581
3958ae62
SN
582int wxApp::AddSocketHandler(int handle, int mask,
583 void (*callback)(void*), void * gsock)
584{
585 int find;
586 struct GsocketCallbackInfo
587 *CallbackInfo = (struct GsocketCallbackInfo *)m_sockCallbackInfo;
588
589 for (find = 0; find < m_maxSocketHandles; find++)
590 if (CallbackInfo[find].handle == -1)
591 break;
592 if (find == m_maxSocketHandles)
593 {
594 // Allocate new memory
595 m_sockCallbackInfo = realloc(m_sockCallbackInfo,
596 (m_maxSocketHandles+=10)*
597 sizeof(struct GsocketCallbackInfo));
598 CallbackInfo = (struct GsocketCallbackInfo *)m_sockCallbackInfo;
599 for (find = m_maxSocketHandles - 10; find < m_maxSocketHandles; find++)
600 CallbackInfo[find].handle = -1;
601 find = m_maxSocketHandles - 10;
602 }
603 CallbackInfo[find].proc = callback;
604 CallbackInfo[find].type = mask;
605 CallbackInfo[find].handle = handle;
606 CallbackInfo[find].gsock = gsock;
607 if (mask & wxSockReadMask)
608 FD_SET(handle, &m_readfds);
609 if (mask & wxSockWriteMask)
610 FD_SET(handle, &m_writefds);
611 if (handle >= m_maxSocketNr)
612 m_maxSocketNr = handle + 1;
613 return find;
614}
615
616void wxApp::RemoveSocketHandler(int handle)
617{
618 struct GsocketCallbackInfo
619 *CallbackInfo = (struct GsocketCallbackInfo *)m_sockCallbackInfo;
620 if (handle < m_maxSocketHandles)
621 {
622 if (CallbackInfo[handle].type & wxSockReadMask)
623 FD_CLR(CallbackInfo[handle].handle, &m_readfds);
624 if (CallbackInfo[handle].type & wxSockWriteMask)
625 FD_CLR(CallbackInfo[handle].handle, &m_writefds);
626 CallbackInfo[handle].handle = -1;
627 }
628}
629
8df85a61
DW
630//-----------------------------------------------------------------------------
631// wxWakeUpIdle
632//-----------------------------------------------------------------------------
633
e2478fde 634void wxApp::WakeUpIdle()
8df85a61
DW
635{
636 //
637 // Send the top window a dummy message so idle handler processing will
638 // start up again. Doing it this way ensures that the idle handler
639 // wakes up in the right thread (see also wxWakeUpMainThread() which does
640 // the same for the main app thread only)
641 //
642 wxWindow* pTopWindow = wxTheApp->GetTopWindow();
643
644 if (pTopWindow)
645 {
646 if ( !::WinPostMsg(GetHwndOf(pTopWindow), WM_NULL, (MPARAM)0, (MPARAM)0))
647 {
648 //
649 // Should never happen
650 //
651 wxLogLastError("PostMessage(WM_NULL)");
652 }
653 }
654} // end of wxWakeUpIdle
d88de032 655
76990f63 656HAB wxGetInstance()
d88de032 657{
76990f63 658 return vHabmain;
d88de032
DW
659}
660
76990f63
DW
661void wxSetInstance(
662 HAB vHab
663)
d88de032 664{
76990f63 665 vHabmain = vHab;
0e320a79
DW
666}
667