]> git.saurik.com Git - wxWidgets.git/commitdiff
Changes needed to accomodate wxTheClipboard now being a macro for wxClipboard::Get
authorRobin Dunn <robin@alldunn.com>
Mon, 21 Jun 2004 22:37:35 +0000 (22:37 +0000)
committerRobin Dunn <robin@alldunn.com>
Mon, 21 Jun 2004 22:37:35 +0000 (22:37 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27928 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/src/__misc_rename.i
wxPython/src/__misc_reverse.txt
wxPython/src/_clipbrd.i
wxPython/src/helpers.cpp
wxPython/wxPython/_misc.py

index 63047cb483ce8cb90280e59520e7c215ae8035fa..77165d95027fd4efc92136c4bb5b8f9f857746e2 100644 (file)
 %rename(DragCancel)                         wxDragCancel;
 %rename(IsDragResultOk)                     wxIsDragResultOk;
 %rename(Clipboard)                          wxClipboard;
-%rename(TheClipboard)                       wxTheClipboard;
 %rename(ClipboardLocker)                    wxClipboardLocker;
 %rename(VideoMode)                          wxVideoMode;
 %rename(DefaultVideoMode)                   wxDefaultVideoMode;
index db39fd5d5ce51e4a9e31ac65099a04eeb2e98f92..aae30d4bdd7c64db5a1058dbdc4afb802494f177 100644 (file)
@@ -7,6 +7,7 @@ PyDropTarget
 #SystemSettings_GetSystemFont
 #SystemSettings_GetSystemMetric
 
+TheClipboard
 
 # With the * on the end these will cause code to be added that 
 # will scan for other names in the source module tha have the
index 89c143f3b424396da8a64e1a93c10ccee82fa032..8fb471613e57cb93125eb4fa5af0d2b01db719ab 100644 (file)
@@ -117,13 +117,40 @@ exit.  Returns False if the operation is unsuccesful for any reason.", "");
         "On platforms supporting it (the X11 based platforms), selects the
 so called PRIMARY SELECTION as the clipboard as opposed to the
 normal clipboard, if primary is True.", "");
-};
 
 
-%immutable;
-wxClipboard* const wxTheClipboard;
-%mutable;
+    DocDeclStr(
+        static wxClipboard *, Get(),
+        "Returns global instance (wxTheClipboard) of the object.", "");
+    
+};
+
 
+// Previously we just declared wxTheClipboard as a global, but in C++
+// is has been changed to be a macro for wxClipboard::Get, but the
+// swig generated code will try to evaluate it when it assigns to the
+// swig wrapper var so this causes Get to be called too early on
+// wxGTK.  So instead we'll create a Python class that can delay the
+// Get until it is really needed, which is similar in effect to what
+// is really happening on the C++ side too.
+%pythoncode {
+    class _wxPyDelayedInitWrapper(object):
+        def __init__(self, initfunc, *args, **kwargs):
+            self._initfunc = initfunc
+            self._args = args
+            self._kwargs = kwargs
+            self._instance = None
+        def _checkInstance(self):
+            if self._instance is None:
+                self._instance = self._initfunc(*self._args, **self._kwargs)        
+        def __getattr__(self, name):
+            self._checkInstance()
+            return getattr(self._instance, name)
+        def __repr__(self):
+            self._checkInstance()
+            return repr(self._instance)
+    TheClipboard = _wxPyDelayedInitWrapper(Clipboard.Get)
+}
 
 
 //---------------------------------------------------------------------------
index 1d662540a522a9020a33ea2df9d9696994d97167..b89e8fec50b036ab87155f49bb9edd48fab25dfe 100644 (file)
@@ -825,7 +825,6 @@ void wxPy_ReinitStockObjects(int pass)
     REINITOBJ(wxTheColourDatabase, wxColourDatabase);
 
 
-    REINITOBJ(wxTheClipboard, wxClipboard);
     REINITOBJ2(wxDefaultValidator, wxValidator);
     REINITOBJ2(wxNullImage, wxImage);
     REINITOBJ2(wxNullAcceleratorTable, wxAcceleratorTable);
index 2dab45e21c99a02b125083d022e6996815dfcea1..3cb27c1f09c01b124cc2374873d1024cdd37bdf9 100644 (file)
@@ -563,7 +563,7 @@ wxFileDropTarget = wx._misc.FileDropTarget
 wxFileDropTargetPtr = wx._misc.FileDropTargetPtr
 wxClipboard = wx._misc.Clipboard
 wxClipboardPtr = wx._misc.ClipboardPtr
-wxTheClipboard = wx._misc.TheClipboard
+wxClipboard_Get = wx._misc.Clipboard_Get
 wxClipboardLocker = wx._misc.ClipboardLocker
 wxClipboardLockerPtr = wx._misc.ClipboardLockerPtr
 wxVideoMode = wx._misc.VideoMode
@@ -576,5 +576,6 @@ wxDisplay_GetFromPoint = wx._misc.Display_GetFromPoint
 wxDisplay_GetFromWindow = wx._misc.Display_GetFromWindow
 wxPyTimer = wx._misc.PyTimer
 wxPyDropTarget = wx._misc.PyDropTarget
+wxTheClipboard = wx._misc.TheClipboard