Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Sharpie/1847199 to your computer and use it in GitHub Desktop.
Save Sharpie/1847199 to your computer and use it in GitHub Desktop.
Patches to allow Spatialite GUI to build against wxWidgets 2.9.x, 64 bit, on OS X
From c2751383a22aff1b4fec59d5f536d551e4655c90 Mon Sep 17 00:00:00 2001
From: Charlie Sharpsteen <[email protected]>
Date: Thu, 16 Feb 2012 11:19:40 -0800
Subject: [PATCH 1/2] Use GetEventHandler to call AddPendingEvent
`AddPendingEvent` is now a private method in wxWidgets 2.9.x so we must access
the event handler and use that to add the event.
---
ResultSetView.cpp | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ResultSetView.cpp b/ResultSetView.cpp
index 3c65d5c..913a097 100644
--- a/ResultSetView.cpp
+++ b/ResultSetView.cpp
@@ -343,7 +343,7 @@ int SqlProgressCallback(void *arg)
{
// requesting a GUI update
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, ID_RS_STATS_UPDATE);
- params->GetMother()->AddPendingEvent(event);
+ params->GetMother()->GetEventHandler()->AddPendingEvent(event);
params->SetLastGuiUpdate(clock_end);
}
return 0;
@@ -461,7 +461,7 @@ error:
params->SetError();
ok:
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, ID_RS_THREAD_FINISHED);
- params->GetMother()->AddPendingEvent(event);
+ params->GetMother()->GetEventHandler()->AddPendingEvent(event);
#ifdef _WIN32
return 0;
#else
--
1.7.9
From 38b5acdf42854842402e082f9c72e6c060035b84 Mon Sep 17 00:00:00 2001
From: Charlie Sharpsteen <[email protected]>
Date: Thu, 16 Feb 2012 11:35:00 -0800
Subject: [PATCH 2/2] Allow GUI on OS X without being an app bundle
For some strange reason, wxWidgets does not take the required steps to register
programs as GUI apps like other toolkits do. This necessitates the creation of
an app bundle on OS X.
This clever hack sidesteps the headache of packing simple programs into app
bundles:
http://www.miscdebris.net/blog/2010/03/30/
solution-for-my-mac-os-x-gui-program-doesnt-get-focus-if-its-outside-an-application-bundle
---
Main.cpp | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/Main.cpp b/Main.cpp
index a857e8a..9c90afb 100644
--- a/Main.cpp
+++ b/Main.cpp
@@ -71,6 +71,12 @@
#define unlink _unlink
#endif
+#ifdef __WXMAC__
+// Allow the program to run and recieve focus without creating an app bundle.
+#include <Carbon/Carbon.h>
+extern "C" { void CPSEnableForegroundOperation(ProcessSerialNumber* psn); }
+#endif
+
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
@@ -86,6 +92,21 @@ IMPLEMENT_APP(MyApp)
frame->Show(true);
SetTopWindow(frame);
frame->LoadConfig(path);
+
+#ifdef __WXMAC__
+ // Acquire the necessary resources to run as a GUI app without being inside
+ // an app bundle.
+ //
+ // Credit for this hack goes to:
+ //
+ // http://www.miscdebris.net/blog/2010/03/30/solution-for-my-mac-os-x-gui-program-doesnt-get-focus-if-its-outside-an-application-bundle
+ ProcessSerialNumber psn;
+
+ GetCurrentProcess( &psn );
+ CPSEnableForegroundOperation( &psn );
+ SetFrontProcess( &psn );
+#endif
+
return true;
}
--
1.7.9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment