X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b09a59f521e4a365f1b073e26e53f17a5e03e1fa..a912e81f6409f4ae37ddb1f66d8474decd8da9aa:/src/motif/app.cpp?ds=sidebyside diff --git a/src/motif/app.cpp b/src/motif/app.cpp index d6c6206c93..b9ac5cc2be 100644 --- a/src/motif/app.cpp +++ b/src/motif/app.cpp @@ -18,20 +18,24 @@ #endif #include "wx/app.h" -#include "wx/utils.h" -#include "wx/module.h" -#include "wx/memory.h" -#include "wx/log.h" -#include "wx/intl.h" + +#ifndef WX_PRECOMP + #include "wx/hash.h" + #include "wx/intl.h" + #include "wx/log.h" + #include "wx/utils.h" + #include "wx/memory.h" + #include "wx/font.h" +#endif + #include "wx/evtloop.h" -#include "wx/hash.h" #if wxUSE_THREADS #include "wx/thread.h" #endif #ifdef __VMS__ -#pragma message disable nosimpint + #pragma message disable nosimpint #endif #include #include @@ -39,7 +43,7 @@ #include #include #ifdef __VMS__ -#pragma message enable nosimpint + #pragma message enable nosimpint #endif #include "wx/motif/private.h" @@ -63,17 +67,12 @@ static void wxTLWidgetDestroyCallback(Widget w, XtPointer clientData, XtPointer ptr); static WXWidget wxCreateTopLevelWidget( WXDisplay* display ); -extern wxList wxPendingDelete; extern bool wxAddIdleCallback(); wxHashTable *wxWidgetHashTable = NULL; IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) -BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) - EVT_IDLE(wxAppBase::OnIdle) -END_EVENT_TABLE() - #ifdef __WXDEBUG__ extern "C" { @@ -96,15 +95,15 @@ static int wxXErrorHandler(Display *dpy, XErrorEvent *xevent) bool wxApp::Initialize(int& argcOrig, wxChar **argvOrig) { +#if wxUSE_INTL + wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); +#endif + if ( !wxAppBase::Initialize(argcOrig, argvOrig) ) return false; wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER); -#if wxUSE_INTL - wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); -#endif - return true; } @@ -129,8 +128,6 @@ void wxApp::CleanUp() #endif delete it->second; } - - delete m_perDisplayData; } void wxApp::Exit() @@ -158,7 +155,7 @@ wxApp::wxApp() wxApp::~wxApp() { - wxApp::SetInstance(NULL); + delete m_perDisplayData; } int wxApp::MainLoop() @@ -196,10 +193,17 @@ static char *fallbackResources[] = { wxMOTIF_STR("*sgiMode: True"), wxMOTIF_STR("*useSchemes: all"), #else // !__SGI__ - wxMOTIF_STR("*menuBar.marginHeight: 0"), - wxMOTIF_STR("*menuBar.shadowThickness: 1"), - wxMOTIF_STR("*background: #c0c0c0"), - wxMOTIF_STR("*foreground: black"), +#if !wxMOTIF_USE_RENDER_TABLE + wxMOTIF_STR("*.fontList: -*-helvetica-medium-r-normal-*-*-120-*-*-*-*-*-*"), +#else + wxMOTIF_STR("*wxDefaultRendition.fontName: -*-helvetica-medium-r-normal-*-*-120-*-*-*-*-*-*"), + wxMOTIF_STR("*wxDefaultRendition.fontType: FONT_IS_FONTSET"), + wxMOTIF_STR("*.renderTable: wxDefaultRendition"), +#endif + wxMOTIF_STR("*listBox.background: white"), + wxMOTIF_STR("*text.background: white"), + wxMOTIF_STR("*comboBox.Text.background: white"), + wxMOTIF_STR("*comboBox.List.background: white"), #endif // __SGI__/!__SGI__ NULL }; @@ -256,6 +260,60 @@ bool wxApp::OnInitGui() if ( clsname.empty() ) clsname = _T("wx"); + // FIXME-UTF8: This code is taken from wxGTK and duplicated here. This + // is just a temporary fix to make wxX11 compile in Unicode + // build, the real fix is to change Initialize()'s signature + // to use char* on Unix. +#if wxUSE_UNICODE + // XtOpenDisplay() wants char*, not wchar_t*, so convert + int i; + char **argvX11 = new char *[argc + 1]; + for ( i = 0; i < argc; i++ ) + { + argvX11[i] = strdup(wxConvLibc.cWX2MB(argv[i])); + } + + argvX11[argc] = NULL; + + int argcX11 = argc; + + Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext, + (String)NULL, + appname.c_str(), + clsname.c_str(), + NULL, 0, // no options +# if XtSpecificationRelease < 5 + (Cardinal*) &argcX11, +# else + &argcX11, +# endif + argvX11); + + if ( argcX11 != argc ) + { + // we have to drop the parameters which were consumed by X11+ + for ( i = 0; i < argcX11; i++ ) + { + while ( strcmp(wxConvLibc.cWX2MB(argv[i]), argvX11[i]) != 0 ) + { + memmove(argv + i, argv + i + 1, (argc - i)*sizeof(*argv)); + } + } + + argc = argcX11; + } + //else: XtOpenDisplay() didn't modify our parameters + + // free our copy + for ( i = 0; i < argcX11; i++ ) + { + free(argvX11[i]); + } + + delete [] argvX11; + +#else // ANSI + Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext, (String)NULL, appname.c_str(), @@ -268,6 +326,8 @@ bool wxApp::OnInitGui() # endif argv); +#endif // Unicode/ANSI + if (!dpy) { // if you don't log to stderr, nothing will be shown... delete wxLog::SetActiveTarget(new wxLogStderr);