wxX11:
[wxWidgets.git] / src / gtk1 / app.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: app.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifdef __GNUG__
11 #pragma implementation "app.h"
12 #endif
13
14 #ifdef __VMS
15 #include <vms_jackets.h>
16 #endif
17
18 #include "wx/app.h"
19 #include "wx/gdicmn.h"
20 #include "wx/utils.h"
21 #include "wx/intl.h"
22 #include "wx/log.h"
23 #include "wx/memory.h"
24 #include "wx/font.h"
25 #include "wx/settings.h"
26 #include "wx/dialog.h"
27
28 #if wxUSE_WX_RESOURCES
29 #include "wx/resource.h"
30 #endif
31
32 #include "wx/module.h"
33 #include "wx/image.h"
34
35 #ifdef __WXUNIVERSAL__
36 #include "wx/univ/theme.h"
37 #include "wx/univ/renderer.h"
38 #endif
39
40 #if wxUSE_THREADS
41 #include "wx/thread.h"
42 #endif
43
44 #include <unistd.h>
45 #ifdef __VMS
46 # include <poll.h>
47 #else
48 # include <sys/poll.h>
49 #endif
50 #include "wx/gtk/win_gtk.h"
51
52 #include <gtk/gtk.h>
53
54
55 //-----------------------------------------------------------------------------
56 // global data
57 //-----------------------------------------------------------------------------
58
59 wxApp *wxTheApp = (wxApp *) NULL;
60 wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
61
62 bool g_mainThreadLocked = FALSE;
63 gint g_pendingTag = 0;
64
65 static GtkWidget *gs_RootWindow = (GtkWidget*) NULL;
66
67 //-----------------------------------------------------------------------------
68 // idle system
69 //-----------------------------------------------------------------------------
70
71 extern bool g_isIdle;
72
73 void wxapp_install_idle_handler();
74
75 //-----------------------------------------------------------------------------
76 // wxExit
77 //-----------------------------------------------------------------------------
78
79 void wxExit()
80 {
81 gtk_main_quit();
82 }
83
84 //-----------------------------------------------------------------------------
85 // wxYield
86 //-----------------------------------------------------------------------------
87
88 bool wxApp::Yield(bool onlyIfNeeded)
89 {
90 // MT-FIXME
91 static bool s_inYield = FALSE;
92
93 if ( s_inYield )
94 {
95 if ( !onlyIfNeeded )
96 {
97 wxFAIL_MSG( wxT("wxYield called recursively" ) );
98 }
99
100 return FALSE;
101 }
102
103 #if wxUSE_THREADS
104 if ( !wxThread::IsMain() )
105 {
106 // can't call gtk_main_iteration() from other threads like this
107 return TRUE;
108 }
109 #endif // wxUSE_THREADS
110
111 s_inYield = TRUE;
112
113 if (!g_isIdle)
114 {
115 // We need to remove idle callbacks or the loop will
116 // never finish.
117 gtk_idle_remove( m_idleTag );
118 m_idleTag = 0;
119 g_isIdle = TRUE;
120 }
121
122 // disable log flushing from here because a call to wxYield() shouldn't
123 // normally result in message boxes popping up &c
124 wxLog::Suspend();
125
126 while (gtk_events_pending())
127 gtk_main_iteration();
128
129 // It's necessary to call ProcessIdle() to update the frames sizes which
130 // might have been changed (it also will update other things set from
131 // OnUpdateUI() which is a nice (and desired) side effect). But we
132 // call ProcessIdle() only once since this is not meant for longish
133 // background jobs (controlled by wxIdleEvent::RequestMore() and the
134 // return value of Processidle().
135 ProcessIdle();
136
137 // let the logs be flashed again
138 wxLog::Resume();
139
140 s_inYield = FALSE;
141
142 return TRUE;
143 }
144
145 //-----------------------------------------------------------------------------
146 // wxWakeUpIdle
147 //-----------------------------------------------------------------------------
148
149 void wxWakeUpIdle()
150 {
151 #if wxUSE_THREADS
152 if (!wxThread::IsMain())
153 wxMutexGuiEnter();
154 #endif
155
156 if (g_isIdle)
157 wxapp_install_idle_handler();
158
159 #if wxUSE_THREADS
160 if (!wxThread::IsMain())
161 wxMutexGuiLeave();
162 #endif
163 }
164
165 //-----------------------------------------------------------------------------
166 // local functions
167 //-----------------------------------------------------------------------------
168
169 // the callback functions must be extern "C" to comply with GTK+ declarations
170 extern "C"
171 {
172
173 static gint wxapp_pending_callback( gpointer WXUNUSED(data) )
174 {
175 if (!wxTheApp) return TRUE;
176
177 // When getting called from GDK's time-out handler
178 // we are no longer within GDK's grab on the GUI
179 // thread so we must lock it here ourselves.
180 gdk_threads_enter();
181
182 // Sent idle event to all who request them.
183 wxTheApp->ProcessPendingEvents();
184
185 g_pendingTag = 0;
186
187 // Flush the logged messages if any.
188 #if wxUSE_LOG
189 wxLog::FlushActive();
190 #endif // wxUSE_LOG
191
192 // Release lock again
193 gdk_threads_leave();
194
195 // Return FALSE to indicate that no more idle events are
196 // to be sent (single shot instead of continuous stream)
197 return FALSE;
198 }
199
200 static gint wxapp_idle_callback( gpointer WXUNUSED(data) )
201 {
202 if (!wxTheApp)
203 return TRUE;
204
205 #ifdef __WXDEBUG__
206 // don't generate the idle events while the assert modal dialog is shown,
207 // this completely confuses the apps which don't expect to be reentered
208 // from some safely-looking functions
209 if ( wxTheApp->IsInAssert() )
210 {
211 return TRUE;
212 }
213 #endif // __WXDEBUG__
214
215 // When getting called from GDK's time-out handler
216 // we are no longer within GDK's grab on the GUI
217 // thread so we must lock it here ourselves.
218 gdk_threads_enter();
219
220 // Indicate that we are now in idle mode and event handlers
221 // will have to reinstall the idle handler again.
222 g_isIdle = TRUE;
223 wxTheApp->m_idleTag = 0;
224
225 // Send idle event to all who request them as long as
226 // no events have popped up in the event queue.
227 while (wxTheApp->ProcessIdle() && (gtk_events_pending() == 0))
228 ;
229
230 // Release lock again
231 gdk_threads_leave();
232
233 // Return FALSE to indicate that no more idle events are
234 // to be sent (single shot instead of continuous stream).
235 return FALSE;
236 }
237
238 #if wxUSE_THREADS
239
240 static gint wxapp_poll_func( GPollFD *ufds, guint nfds, gint timeout )
241 {
242 gint res;
243 gdk_threads_enter();
244
245 wxMutexGuiLeave();
246 g_mainThreadLocked = TRUE;
247
248 res = poll( (struct pollfd*) ufds, nfds, timeout );
249
250 wxMutexGuiEnter();
251 g_mainThreadLocked = FALSE;
252
253 gdk_threads_leave();
254
255 return res;
256 }
257
258 #endif // wxUSE_THREADS
259
260 } // extern "C"
261
262 void wxapp_install_idle_handler()
263 {
264 wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") );
265
266 g_isIdle = FALSE;
267
268 if (g_pendingTag == 0)
269 g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL );
270
271 // This routine gets called by all event handlers
272 // indicating that the idle is over. It may also
273 // get called from other thread for sending events
274 // to the main thread (and processing these in
275 // idle time). Very low priority.
276 wxTheApp->m_idleTag = gtk_idle_add_priority( 1000, wxapp_idle_callback, (gpointer) NULL );
277 }
278
279 //-----------------------------------------------------------------------------
280 // Access to the root window global
281 //-----------------------------------------------------------------------------
282
283 GtkWidget* wxGetRootWindow()
284 {
285 if (gs_RootWindow == NULL)
286 {
287 gs_RootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
288 gtk_widget_realize( gs_RootWindow );
289 }
290 return gs_RootWindow;
291 }
292
293 //-----------------------------------------------------------------------------
294 // wxApp
295 //-----------------------------------------------------------------------------
296
297 IMPLEMENT_DYNAMIC_CLASS(wxApp,wxEvtHandler)
298
299 BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
300 EVT_IDLE(wxApp::OnIdle)
301 END_EVENT_TABLE()
302
303 wxApp::wxApp()
304 {
305 m_initialized = FALSE;
306 #ifdef __WXDEBUG__
307 m_isInAssert = FALSE;
308 #endif // __WXDEBUG__
309
310 m_idleTag = 0;
311 wxapp_install_idle_handler();
312
313 #if wxUSE_THREADS
314 g_main_set_poll_func( wxapp_poll_func );
315 #endif
316
317 m_colorCube = (unsigned char*) NULL;
318
319 // this is NULL for a "regular" wxApp, but is set (and freed) by a wxGLApp
320 m_glVisualInfo = (void *) NULL;
321 }
322
323 wxApp::~wxApp()
324 {
325 if (m_idleTag) gtk_idle_remove( m_idleTag );
326
327 if (m_colorCube) free(m_colorCube);
328 }
329
330 bool wxApp::OnInitGui()
331 {
332 if ( !wxAppBase::OnInitGui() )
333 return FALSE;
334
335 GdkVisual *visual = gdk_visual_get_system();
336
337 // if this is a wxGLApp (derived from wxApp), and we've already
338 // chosen a specific visual, then derive the GdkVisual from that
339 if (m_glVisualInfo != NULL)
340 {
341 #ifdef __WXGTK20__
342 // seems gtk_widget_set_default_visual no longer exists?
343 GdkVisual* vis = gtk_widget_get_default_visual();
344 #else
345 GdkVisual* vis = gdkx_visual_get(
346 ((XVisualInfo *) m_glVisualInfo) ->visualid );
347 gtk_widget_set_default_visual( vis );
348 #endif
349
350 GdkColormap *colormap = gdk_colormap_new( vis, FALSE );
351 gtk_widget_set_default_colormap( colormap );
352
353 visual = vis;
354 }
355
356 // On some machines, the default visual is just 256 colours, so
357 // we make sure we get the best. This can sometimes be wasteful.
358
359 else
360 if ((gdk_visual_get_best() != gdk_visual_get_system()) && (m_useBestVisual))
361 {
362 #ifdef __WXGTK20__
363 /* seems gtk_widget_set_default_visual no longer exists? */
364 GdkVisual* vis = gtk_widget_get_default_visual();
365 #else
366 GdkVisual* vis = gdk_visual_get_best();
367 gtk_widget_set_default_visual( vis );
368 #endif
369
370 GdkColormap *colormap = gdk_colormap_new( vis, FALSE );
371 gtk_widget_set_default_colormap( colormap );
372
373 visual = vis;
374 }
375
376 // Nothing to do for 15, 16, 24, 32 bit displays
377 if (visual->depth > 8) return TRUE;
378
379 // initialize color cube for 8-bit color reduction dithering
380
381 GdkColormap *cmap = gtk_widget_get_default_colormap();
382
383 m_colorCube = (unsigned char*)malloc(32 * 32 * 32);
384
385 for (int r = 0; r < 32; r++)
386 {
387 for (int g = 0; g < 32; g++)
388 {
389 for (int b = 0; b < 32; b++)
390 {
391 int rr = (r << 3) | (r >> 2);
392 int gg = (g << 3) | (g >> 2);
393 int bb = (b << 3) | (b >> 2);
394
395 int index = -1;
396
397 GdkColor *colors = cmap->colors;
398 if (colors)
399 {
400 int max = 3 * 65536;
401
402 for (int i = 0; i < cmap->size; i++)
403 {
404 int rdiff = ((rr << 8) - colors[i].red);
405 int gdiff = ((gg << 8) - colors[i].green);
406 int bdiff = ((bb << 8) - colors[i].blue);
407 int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
408 if (sum < max)
409 {
410 index = i; max = sum;
411 }
412 }
413 }
414 else
415 {
416 // assume 8-bit true or static colors. this really exists
417 GdkVisual* vis = gdk_colormap_get_visual( cmap );
418 index = (r >> (5 - vis->red_prec)) << vis->red_shift;
419 index |= (g >> (5 - vis->green_prec)) << vis->green_shift;
420 index |= (b >> (5 - vis->blue_prec)) << vis->blue_shift;
421 }
422 m_colorCube[ (r*1024) + (g*32) + b ] = index;
423 }
424 }
425 }
426
427 return TRUE;
428 }
429
430 GdkVisual *wxApp::GetGdkVisual()
431 {
432 GdkVisual *visual = NULL;
433
434 if (m_glVisualInfo)
435 visual = gdkx_visual_get( ((XVisualInfo *) m_glVisualInfo)->visualid );
436 else
437 visual = gdk_window_get_visual( wxGetRootWindow()->window );
438
439 wxASSERT( visual );
440
441 return visual;
442 }
443
444 bool wxApp::ProcessIdle()
445 {
446 wxIdleEvent event;
447 event.SetEventObject( this );
448 ProcessEvent( event );
449
450 return event.MoreRequested();
451 }
452
453 void wxApp::OnIdle( wxIdleEvent &event )
454 {
455 static bool s_inOnIdle = FALSE;
456
457 // Avoid recursion (via ProcessEvent default case)
458 if (s_inOnIdle)
459 return;
460
461 s_inOnIdle = TRUE;
462
463 // Resend in the main thread events which have been prepared in other
464 // threads
465 ProcessPendingEvents();
466
467 // 'Garbage' collection of windows deleted with Close()
468 DeletePendingObjects();
469
470 // Send OnIdle events to all windows
471 bool needMore = SendIdleEvents();
472
473 if (needMore)
474 event.RequestMore(TRUE);
475
476 s_inOnIdle = FALSE;
477 }
478
479 bool wxApp::SendIdleEvents()
480 {
481 bool needMore = FALSE;
482
483 wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
484 while (node)
485 {
486 wxWindow* win = node->GetData();
487 if (SendIdleEvents(win))
488 needMore = TRUE;
489 node = node->GetNext();
490 }
491
492 return needMore;
493 }
494
495 bool wxApp::SendIdleEvents( wxWindow* win )
496 {
497 bool needMore = FALSE;
498
499 wxIdleEvent event;
500 event.SetEventObject(win);
501
502 win->GetEventHandler()->ProcessEvent(event);
503
504 win->OnInternalIdle();
505
506 if (event.MoreRequested())
507 needMore = TRUE;
508
509 wxNode* node = win->GetChildren().First();
510 while (node)
511 {
512 wxWindow* win = (wxWindow*) node->Data();
513 if (SendIdleEvents(win))
514 needMore = TRUE;
515
516 node = node->Next();
517 }
518 return needMore ;
519 }
520
521 int wxApp::MainLoop()
522 {
523 gtk_main();
524 return 0;
525 }
526
527 void wxApp::ExitMainLoop()
528 {
529 if (gtk_main_level() > 0)
530 gtk_main_quit();
531 }
532
533 bool wxApp::Initialized()
534 {
535 return m_initialized;
536 }
537
538 bool wxApp::Pending()
539 {
540 return (gtk_events_pending() > 0);
541 }
542
543 void wxApp::Dispatch()
544 {
545 gtk_main_iteration();
546 }
547
548 void wxApp::DeletePendingObjects()
549 {
550 wxNode *node = wxPendingDelete.First();
551 while (node)
552 {
553 wxObject *obj = (wxObject *)node->Data();
554
555 delete obj;
556
557 if (wxPendingDelete.Find(obj))
558 delete node;
559
560 node = wxPendingDelete.First();
561 }
562 }
563
564 bool wxApp::Initialize()
565 {
566 wxBuffer = new wxChar[BUFSIZ + 512];
567
568 wxClassInfo::InitializeClasses();
569
570 #if wxUSE_INTL
571 wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
572 #endif
573
574 // GL: I'm annoyed ... I don't know where to put this and I don't want to
575 // create a module for that as it's part of the core.
576 #if wxUSE_THREADS
577 wxPendingEvents = new wxList();
578 wxPendingEventsLocker = new wxCriticalSection();
579 #endif
580
581 wxTheColourDatabase = new wxColourDatabase( wxKEY_STRING );
582 wxTheColourDatabase->Initialize();
583
584 wxInitializeStockLists();
585 wxInitializeStockObjects();
586
587 #if wxUSE_WX_RESOURCES
588 wxInitializeResourceSystem();
589 #endif
590
591 wxModule::RegisterModules();
592 if (!wxModule::InitializeModules()) return FALSE;
593
594 return TRUE;
595 }
596
597 void wxApp::CleanUp()
598 {
599 wxModule::CleanUpModules();
600
601 #if wxUSE_WX_RESOURCES
602 wxCleanUpResourceSystem();
603 #endif
604
605 delete wxTheColourDatabase;
606 wxTheColourDatabase = (wxColourDatabase*) NULL;
607
608 wxDeleteStockObjects();
609
610 wxDeleteStockLists();
611
612 delete wxTheApp;
613 wxTheApp = (wxApp*) NULL;
614
615 delete[] wxBuffer;
616 wxBuffer = NULL;
617
618 wxClassInfo::CleanUpClasses();
619
620 #if wxUSE_THREADS
621 delete wxPendingEvents;
622 delete wxPendingEventsLocker;
623 #endif
624
625 // check for memory leaks
626 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
627 if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
628 {
629 wxLogDebug(wxT("There were memory leaks.\n"));
630 wxDebugContext::Dump();
631 wxDebugContext::PrintStatistics();
632 }
633 #endif // Debug
634
635 #if wxUSE_LOG
636 // do this as the very last thing because everything else can log messages
637 wxLog::DontCreateOnDemand();
638
639 wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
640 if (oldLog)
641 delete oldLog;
642 #endif // wxUSE_LOG
643 }
644
645 //-----------------------------------------------------------------------------
646 // wxEntry
647 //-----------------------------------------------------------------------------
648
649 // NB: argc and argv may be changed here, pass by reference!
650 int wxEntryStart( int& argc, char *argv[] )
651 {
652 #if wxUSE_THREADS
653 // GTK 1.2 up to version 1.2.3 has broken threads
654 if ((gtk_major_version == 1) &&
655 (gtk_minor_version == 2) &&
656 (gtk_micro_version < 4))
657 {
658 printf( "wxWindows warning: GUI threading disabled due to outdated GTK version\n" );
659 }
660 else
661 {
662 g_thread_init(NULL);
663 }
664 #endif
665
666 gtk_set_locale();
667
668 // We should have the wxUSE_WCHAR_T test on the _outside_
669 #if wxUSE_WCHAR_T
670 #if defined(__WXGTK20__)
671 // gtk+ 2.0 supports Unicode through UTF-8 strings
672 wxConvCurrent = &wxConvUTF8;
673 #else
674 if (!wxOKlibc()) wxConvCurrent = &wxConvLocal;
675 #endif
676 #else
677 if (!wxOKlibc()) wxConvCurrent = (wxMBConv*) NULL;
678 #endif
679
680 gdk_threads_enter();
681
682 gtk_init( &argc, &argv );
683
684 wxSetDetectableAutoRepeat( TRUE );
685
686 if (!wxApp::Initialize())
687 {
688 gdk_threads_leave();
689 return -1;
690 }
691
692 return 0;
693 }
694
695
696 int wxEntryInitGui()
697 {
698 int retValue = 0;
699
700 if ( !wxTheApp->OnInitGui() )
701 retValue = -1;
702
703 wxGetRootWindow();
704
705 return retValue;
706 }
707
708
709 void wxEntryCleanup()
710 {
711 #if wxUSE_LOG
712 // flush the logged messages if any
713 wxLog *log = wxLog::GetActiveTarget();
714 if (log != NULL && log->HasPendingMessages())
715 log->Flush();
716
717 // continuing to use user defined log target is unsafe from now on because
718 // some resources may be already unavailable, so replace it by something
719 // more safe
720 wxLog *oldlog = wxLog::SetActiveTarget(new wxLogStderr);
721 if ( oldlog )
722 delete oldlog;
723 #endif // wxUSE_LOG
724
725 wxApp::CleanUp();
726
727 gdk_threads_leave();
728 }
729
730
731 int wxEntry( int argc, char *argv[] )
732 {
733 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
734 // This seems to be necessary since there are 'rogue'
735 // objects present at this point (perhaps global objects?)
736 // Setting a checkpoint will ignore them as far as the
737 // memory checking facility is concerned.
738 // Of course you may argue that memory allocated in globals should be
739 // checked, but this is a reasonable compromise.
740 wxDebugContext::SetCheckpoint();
741 #endif
742 int err = wxEntryStart(argc, argv);
743 if (err)
744 return err;
745
746 if (!wxTheApp)
747 {
748 wxCHECK_MSG( wxApp::GetInitializerFunction(), -1,
749 wxT("wxWindows error: No initializer - use IMPLEMENT_APP macro.\n") );
750
751 wxAppInitializerFunction app_ini = wxApp::GetInitializerFunction();
752
753 wxObject *test_app = app_ini();
754
755 wxTheApp = (wxApp*) test_app;
756 }
757
758 wxCHECK_MSG( wxTheApp, -1, wxT("wxWindows error: no application object") );
759
760 wxTheApp->argc = argc;
761 #if wxUSE_UNICODE
762 wxTheApp->argv = new wxChar*[argc+1];
763 int mb_argc = 0;
764 while (mb_argc < argc)
765 {
766 wxTheApp->argv[mb_argc] = wxStrdup(wxConvLibc.cMB2WX(argv[mb_argc]));
767 mb_argc++;
768 }
769 wxTheApp->argv[mb_argc] = (wxChar *)NULL;
770 #else
771 wxTheApp->argv = argv;
772 #endif
773
774 wxString name(wxFileNameFromPath(argv[0]));
775 wxStripExtension( name );
776 wxTheApp->SetAppName( name );
777
778 int retValue;
779 retValue = wxEntryInitGui();
780
781 // Here frames insert themselves automatically into wxTopLevelWindows by
782 // getting created in OnInit().
783 if ( retValue == 0 )
784 {
785 if ( !wxTheApp->OnInit() )
786 retValue = -1;
787 }
788
789 if ( retValue == 0 )
790 {
791 /* delete pending toplevel windows (typically a single
792 dialog) so that, if there isn't any left, we don't
793 call OnRun() */
794 wxTheApp->DeletePendingObjects();
795
796 wxTheApp->m_initialized = wxTopLevelWindows.GetCount() != 0;
797
798 if (wxTheApp->Initialized())
799 {
800 wxTheApp->OnRun();
801
802 wxWindow *topWindow = wxTheApp->GetTopWindow();
803 if (topWindow)
804 {
805 /* Forcibly delete the window. */
806 if (topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
807 topWindow->IsKindOf(CLASSINFO(wxDialog)) )
808 {
809 topWindow->Close( TRUE );
810 wxTheApp->DeletePendingObjects();
811 }
812 else
813 {
814 delete topWindow;
815 wxTheApp->SetTopWindow( (wxWindow*) NULL );
816 }
817 }
818
819 retValue = wxTheApp->OnExit();
820 }
821 }
822
823 wxEntryCleanup();
824
825 return retValue;
826 }
827
828 #ifndef __WXUNIVERSAL__
829
830 // XPM hack: make the arrays const
831 #define static static const
832
833 #include "wx/gtk/info.xpm"
834 #include "wx/gtk/error.xpm"
835 #include "wx/gtk/question.xpm"
836 #include "wx/gtk/warning.xpm"
837
838 #undef static
839
840 wxIcon wxApp::GetStdIcon(int which) const
841 {
842 switch(which)
843 {
844 case wxICON_INFORMATION:
845 return wxIcon(info_xpm);
846
847 case wxICON_QUESTION:
848 return wxIcon(question_xpm);
849
850 case wxICON_EXCLAMATION:
851 return wxIcon(warning_xpm);
852
853 default:
854 wxFAIL_MSG(wxT("requested non existent standard icon"));
855 // still fall through
856
857 case wxICON_HAND:
858 return wxIcon(error_xpm);
859 }
860 }
861 #else
862 wxIcon wxApp::GetStdIcon(int which) const
863 {
864 return wxTheme::Get()->GetRenderer()->GetStdIcon(which);
865 }
866 #endif // !__WXUNIVERSAL__
867
868
869 #ifdef __WXDEBUG__
870
871 void wxApp::OnAssert(const wxChar *file, int line, const wxChar *msg)
872 {
873 m_isInAssert = TRUE;
874
875 wxAppBase::OnAssert(file, line, msg);
876
877 m_isInAssert = FALSE;
878 }
879
880 #endif // __WXDEBUG__
881