]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/helpers.cpp
Fixed some colours
[wxWidgets.git] / wxPython / src / helpers.cpp
index 0c2e631e36b3e0e9476fbc1f3a8f97dc6ebfb32d..c08d2872655c17602e6f358d5298ec244d167eae 100644 (file)
 #endif
 
 #ifdef __WXGTK__
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkprivate.h>
 #include <wx/gtk/win_gtk.h>
+#define GetXWindow(wxwin)   GDK_WINDOW_XWINDOW((wxwin)->m_widget->window)
+#include <locale.h>
+#endif
+
+#ifdef __WXX11__
+#include "wx/x11/privx.h"
+#define GetXWindow(wxwin)   ((Window)(wxwin)->GetHandle())
 #endif
 
 #ifdef __WXMAC__
@@ -390,15 +399,28 @@ void wxPyApp::_BootstrapApp()
     }
     wxPyEndBlockThreads(blocked);
 
+    // Initialize wxWidgets
     result = wxEntryStart(argc, argv);
     delete [] argv;
 
     blocked = wxPyBeginBlockThreads();
     if (! result)  {
-        PyErr_SetString(PyExc_SystemError, "wxEntryStart failed!");
+        PyErr_SetString(PyExc_SystemError,
+                        "wxEntryStart failed, unable to initialize wxWidgets!"
+#ifdef __WXGTK__
+                        "  (Is DISPLAY set properly?)"
+#endif
+            );
         goto error;
     }
 
+    // On wxGTK the locale will be changed to match the system settings, but
+    // Python needs to have LC_NUMERIC set to "C" in order for the floating
+    // point conversions and such to work right.
+#ifdef __WXGTK__
+    setlocale(LC_NUMERIC, "C");
+#endif
+    
     // The stock objects were all NULL when they were loaded into
     // SWIG generated proxies, so re-init those now...
     wxPy_ReinitStockObjects(3);
@@ -429,7 +451,6 @@ void wxPyApp::_BootstrapApp()
         result = True;
     }
 
-
     if (! result) {
         PyErr_SetString(PyExc_SystemExit, "OnInit returned False, exiting...");
     }
@@ -515,6 +536,8 @@ void __wxPyPreStart(PyObject* moduleDict)
 
     // Init the stock objects to a non-NULL value so SWIG doesn't create them as None
     wxPy_ReinitStockObjects(1);
+
+    wxInitAllImageHandlers();
 }
 
 
@@ -535,7 +558,7 @@ void __wxPyCleanup() {
 }
 
 
-// Save a reference to the dictionary of the wx.core module, and inject
+// Save a reference to the dictionary of the wx._core module, and inject
 // a few more things into it.
 PyObject* __wxPySetDictionary(PyObject* /* self */, PyObject* args)
 {
@@ -553,7 +576,7 @@ PyObject* __wxPySetDictionary(PyObject* /* self */, PyObject* args)
     PyDict_SetItemString(wxPython_dict, "__wxPyPtrTypeMap", wxPyPtrTypeMap);
 
     // Create an exception object to use for wxASSERTions
-    wxPyAssertionError = PyErr_NewException("wx.core.PyAssertionError",
+    wxPyAssertionError = PyErr_NewException("wx._core.PyAssertionError",
                                             PyExc_AssertionError, NULL);
     PyDict_SetItemString(wxPython_dict, "PyAssertionError", wxPyAssertionError);
 
@@ -1805,22 +1828,13 @@ long wxPyGetWinHandle(wxWindow* win) {
     return (long)win->GetHandle();
 #endif
 
-    // Find and return the actual X-Window.
-#ifdef __WXGTK__
-    if (win->m_wxwindow) {
-#ifdef __WXGTK20__
-        return (long) GDK_WINDOW_XWINDOW(GTK_PIZZA(win->m_wxwindow)->bin_window);
-#else
-        GdkWindowPrivate* bwin = (GdkWindowPrivate*)GTK_PIZZA(win->m_wxwindow)->bin_window;
-        if (bwin) {
-            return (long)bwin->xwindow;
-        }
+#if defined(__WXGTK__) || defined(__WXX11)
+    return (long)GetXWindow(win);
 #endif
-    }
-#endif
-
+    
 #ifdef __WXMAC__
-    return (long)MAC_WXHWND(win->MacGetRootWindow());
+    //return (long)MAC_WXHWND(win->MacGetTopLevelWindowRef());
+    return (long)win->GetHandle();
 #endif
 
     return 0;