]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/helpers.cpp
Always set background colour prior to any HTML rendering (this fixes assert in GTK2...
[wxWidgets.git] / wxPython / src / helpers.cpp
index 4c9f9beca887f1bbb806b9bcbaed7ccc86e0bfa6..18a46a2f830af07ad3eb66cd122fe8c980a7fe9b 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <wx/clipbrd.h>
 #include <wx/mimetype.h>
+#include <wx/image.h>
 
 //----------------------------------------------------------------------
 
@@ -114,9 +115,6 @@ int  wxPyApp::MainLoop() {
 
     DeletePendingObjects();
     bool initialized = wxTopLevelWindows.GetCount() != 0;
-#ifdef __WXGTK__
-    m_initialized = initialized;
-#endif
 
     if (initialized) {
         if ( m_exitOnFrameDelete == Later ) {
@@ -227,15 +225,6 @@ void wxPyApp::OnAssert(const wxChar *file,
 #endif
 
 
-/*static*/
-bool wxPyApp::GetMacDefaultEncodingIsPC() {
-#ifdef __WXMAC__
-    return s_macDefaultEncodingIsPC;
-#else
-    return 0;
-#endif
-}
-
 /*static*/
 bool wxPyApp::GetMacSupportPCMenuShortcuts() {
 #ifdef __WXMAC__
@@ -281,13 +270,6 @@ wxString wxPyApp::GetMacHelpMenuTitleName() {
 #endif
 }
 
-/*static*/
-void wxPyApp::SetMacDefaultEncodingIsPC(bool val) {
-#ifdef __WXMAC__
-    s_macDefaultEncodingIsPC = val;
-#endif
-}
-
 /*static*/
 void wxPyApp::SetMacSupportPCMenuShortcuts(bool val) {
 #ifdef __WXMAC__
@@ -380,10 +362,14 @@ void __wxPreStart(PyObject* moduleDict)
     PyEval_InitThreads();
     wxPyTStates = new wxPyThreadStateArray;
     wxPyTMutex = new wxMutex;
+
+    // Save the current (main) thread state in our array
+    PyThreadState* tstate = wxPyBeginAllowThreads();
+    wxPyEndAllowThreads(tstate);
 #endif
 
     // Ensure that the build options in the DLL (or whatever) match this build
-    wxApp::CheckBuildOptions(wxBuildOptions());
+    wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "wxPython");
 
     // Create an exception object to use for wxASSERTions
     wxPyAssertionError = PyErr_NewException("wxPython.wxc.wxPyAssertionError",
@@ -454,10 +440,6 @@ PyObject* __wxStart(PyObject* /* self */, PyObject* args)
         goto error;
     }
 
-#ifdef __WXGTK__
-    wxTheApp->m_initialized = (wxTopLevelWindows.GetCount() > 0);
-#endif
-
     Py_DECREF(result);
     Py_DECREF(pyint);
     Py_INCREF(Py_None);
@@ -1305,29 +1287,50 @@ void wxPyCallback::EventThunker(wxEvent& event) {
     PyObject*       result;
     PyObject*       arg;
     PyObject*       tuple;
-
+    bool            checkSkip = FALSE;
 
     wxPyBeginBlockThreads();
     wxString className = event.GetClassInfo()->GetClassName();
 
-    if (className == wxT("wxPyEvent"))
-        arg = ((wxPyEvent*)&event)->GetSelf();
-    else if (className == wxT("wxPyCommandEvent"))
-        arg = ((wxPyCommandEvent*)&event)->GetSelf();
+    // If the event is one of these types then pass the original
+    // event object instead of the one passed to us.
+    if ( className == wxT("wxPyEvent") ) {
+        arg =       ((wxPyEvent*)&event)->GetSelf();
+        checkSkip = ((wxPyEvent*)&event)->GetCloned();
+    }
+    else if ( className == wxT("wxPyCommandEvent") ) {
+        arg =       ((wxPyCommandEvent*)&event)->GetSelf();
+        checkSkip = ((wxPyCommandEvent*)&event)->GetCloned();
+    }
     else {
         arg = wxPyConstructObject((void*)&event, className);
     }
 
+    // Call the event handler, passing the event object
     tuple = PyTuple_New(1);
-    PyTuple_SET_ITEM(tuple, 0, arg);
+    PyTuple_SET_ITEM(tuple, 0, arg);  // steals ref to arg
     result = PyEval_CallObject(func, tuple);
-    Py_DECREF(tuple);
-    if (result) {
-        Py_DECREF(result);
+    if ( result ) {
+        Py_DECREF(result);   // result is ignored, but we still need to decref it
         PyErr_Clear();       // Just in case...
     } else {
         PyErr_Print();
     }
+
+    if ( checkSkip ) {
+        // if the event object was one of our special types and
+        // it had been cloned, then we need to extract the Skipped
+        // value from the original and set it in the clone.
+        result = PyObject_CallMethod(arg, "GetSkipped", "");
+        if ( result ) {
+            event.Skip(PyInt_AsLong(result));
+            Py_DECREF(result);
+        } else {
+            PyErr_Print();
+        }
+    }
+
+    Py_DECREF(tuple);
     wxPyEndBlockThreads();
 }
 
@@ -1563,8 +1566,8 @@ IMPLEMENT_ABSTRACT_CLASS(wxPyEvent, wxEvent);
 IMPLEMENT_ABSTRACT_CLASS(wxPyCommandEvent, wxCommandEvent);
 
 
-wxPyEvent::wxPyEvent(int id)
-    : wxEvent(id) {
+wxPyEvent::wxPyEvent(int winid, wxEventType commandType)
+    : wxEvent(winid, commandType) {
 }
 
 
@@ -1667,6 +1670,10 @@ long wxPyGetWinHandle(wxWindow* win) {
     return (long)win->GetHandle();
 #endif
 
+#ifdef __WXAC__
+    return (long)win->GetHandle();
+#endif
+
     // Find and return the actual X-Window.
 #ifdef __WXGTK__
     if (win->m_wxwindow) {