From c6ed20e00d2eb39813ec8bdab4a9257a323f7357 Mon Sep 17 00:00:00 2001 From: Metallicow Date: Mon, 5 Dec 2016 16:39:14 -0600 Subject: [PATCH] Trim trailing space src directory --- src/app_ex.cpp | 68 ++++++++++---------- src/arrayholder.h | 8 +-- src/arrayholder.sip | 8 +-- src/arrays.sip | 38 +++++------ src/bitmap_ex.cpp | 42 ++++++------- src/bitmap_ex.h | 8 +-- src/clntdata.sip | 12 ++-- src/core_ex.cpp | 16 ++--- src/core_ex.py | 18 +++--- src/dc_ex.cpp | 4 +- src/dvcvariant.sip | 30 ++++----- src/event_ex.cpp | 2 +- src/event_ex.py | 12 ++-- src/filename.sip | 4 +- src/pseudodc.cpp | 54 ++++++++-------- src/pseudodc.h | 142 +++++++++++++++++++++--------------------- src/pyevent.h | 30 ++++----- src/stockgdi.sip | 24 +++---- src/stream_input.cpp | 54 ++++++++-------- src/stream_output.cpp | 58 ++++++++--------- src/string.sip | 12 ++-- src/treeitemdata.sip | 8 +-- src/userdata.sip | 8 +-- src/wacky_ints.sip | 10 +-- src/window_ex.cpp | 2 +- src/wxpy_api.h | 74 +++++++++++----------- src/wxpy_api.sip | 42 ++++++------- src/wxpybuffer.h | 16 ++--- src/wxpybuffer.sip | 8 +-- 29 files changed, 406 insertions(+), 406 deletions(-) diff --git a/src/app_ex.cpp b/src/app_ex.cpp index 3df7545d..7203f890 100644 --- a/src/app_ex.cpp +++ b/src/app_ex.cpp @@ -18,7 +18,7 @@ #ifdef __WXMSW__ // If building for Windows... //---------------------------------------------------------------------- -// This gets run when the DLL is loaded. We just need to save the +// This gets run when the DLL is loaded. We just need to save the // instance handle. //---------------------------------------------------------------------- @@ -43,7 +43,7 @@ BOOL WINAPI DllMain( //---------------------------------------------------------------------- -class wxPyApp : public wxApp +class wxPyApp : public wxApp { DECLARE_ABSTRACT_CLASS(wxPyApp) @@ -54,13 +54,13 @@ public: //m_callFilterEvent = false; ms_appInstance = this; } - + ~wxPyApp() { ms_appInstance = NULL; wxApp::SetInstance(NULL); } - + #ifndef __WXMAC__ virtual void MacNewFile() {} virtual void MacOpenFile(const wxString &) {} @@ -72,28 +72,28 @@ public: #endif #ifdef __WXMAC__ - static long GetMacAboutMenuItemId() { return s_macAboutMenuItemId; } - static long GetMacPreferencesMenuItemId() { return s_macPreferencesMenuItemId; } - static long GetMacExitMenuItemId() { return s_macExitMenuItemId; } + static long GetMacAboutMenuItemId() { return s_macAboutMenuItemId; } + static long GetMacPreferencesMenuItemId() { return s_macPreferencesMenuItemId; } + static long GetMacExitMenuItemId() { return s_macExitMenuItemId; } static wxString GetMacHelpMenuTitleName() { return s_macHelpMenuTitleName; } - static void SetMacAboutMenuItemId(long val) { s_macAboutMenuItemId = val; } + static void SetMacAboutMenuItemId(long val) { s_macAboutMenuItemId = val; } static void SetMacPreferencesMenuItemId(long val) { s_macPreferencesMenuItemId = val; } - static void SetMacExitMenuItemId(long val) { s_macExitMenuItemId = val; } + static void SetMacExitMenuItemId(long val) { s_macExitMenuItemId = val; } static void SetMacHelpMenuTitleName(const wxString& val) { s_macHelpMenuTitleName = val; } #else static long GetMacAboutMenuItemId() { return 0; } - static long GetMacPreferencesMenuItemId() { return 0; } + static long GetMacPreferencesMenuItemId() { return 0; } static long GetMacExitMenuItemId() { return 0; } static wxString GetMacHelpMenuTitleName() { return wxEmptyString; } - static void SetMacAboutMenuItemId(long) { } + static void SetMacAboutMenuItemId(long) { } static void SetMacPreferencesMenuItemId(long) { } - static void SetMacExitMenuItemId(long) { } + static void SetMacExitMenuItemId(long) { } static void SetMacHelpMenuTitleName(const wxString&) { } #endif wxAppAssertMode GetAssertMode() { return m_assertMode; } - void SetAssertMode(wxAppAssertMode mode) { - m_assertMode = mode; + void SetAssertMode(wxAppAssertMode mode) { + m_assertMode = mode; if (mode & wxAPP_ASSERT_SUPPRESS) wxDisableAsserts(); else @@ -106,20 +106,20 @@ public: const wxChar *cond, const wxChar *msg); - + // Implementing OnInit is optional for wxPython apps virtual bool OnInit() { return true; } virtual void OnPreInit() { } - + void _BootstrapApp(); - virtual int MainLoop(); + virtual int MainLoop(); static bool IsDisplayAvailable(); // implementation only - void SetStartupComplete(bool val) { m_startupComplete = val; } + void SetStartupComplete(bool val) { m_startupComplete = val; } static wxPyApp* ms_appInstance; - + private: wxAppAssertMode m_assertMode; bool m_startupComplete; @@ -149,9 +149,9 @@ void wxPyApp::OnAssertFailure(const wxChar *file, buf.Printf(wxT("C++ assertion \"%s\" failed at %s(%d)"), cond, file, line); if ( func && *func ) buf << wxT(" in ") << func << wxT("()"); - if (msg != NULL) + if (msg != NULL) buf << wxT(": ") << msg; - + // set the exception wxPyThreadBlocker blocker; PyObject* s = wx2PyString(buf); @@ -172,15 +172,15 @@ void wxPyApp::OnAssertFailure(const wxChar *file, file, line, cond); if ( func && *func ) buf << wxT(" in ") << func << wxT("()"); - if (msg != NULL) + if (msg != NULL) buf << wxT(": ") << msg; wxLogDebug(buf); } // do the normal wx assert dialog? if (m_assertMode & wxAPP_ASSERT_DIALOG) - wxApp::OnAssertFailure(file, line, func, cond, msg); -} + wxApp::OnAssertFailure(file, line, func, cond, msg); +} void wxPyApp::_BootstrapApp() @@ -190,7 +190,7 @@ void wxPyApp::_BootstrapApp() // Only initialize wxWidgets once if (! haveInitialized) { - + // Copy the values in Python's sys.argv list to a C array of char* to // be passed to the wxEntryStart function below. #if PY_MAJOR_VERSION >= 3 @@ -203,14 +203,14 @@ void wxPyApp::_BootstrapApp() { wxPyThreadBlocker blocker; PyObject* sysargv = PySys_GetObject("argv"); - if (sysargv != NULL) { + if (sysargv != NULL) { argc = PyList_Size(sysargv); argv = new argType*[argc+1]; int x; for(x=0; x= 3 int len = PyObject_Length(pyArg); @@ -223,7 +223,7 @@ void wxPyApp::_BootstrapApp() argv[argc] = NULL; } } - + // Initialize wxWidgets #ifdef __WXOSX__ wxMacAutoreleasePool autoreleasePool; @@ -245,7 +245,7 @@ void wxPyApp::_BootstrapApp() else { this->argc = 0; } - + // It's now ok to generate exceptions for assertion errors. SetStartupComplete(true); @@ -257,17 +257,17 @@ void wxPyApp::_BootstrapApp() result = CallOnInit(); else result = OnInit(); - + //#ifdef __WXOSX_COCOA__ // OSXSetInitWasCalled(true); TODO: consider adding this method to wxApp //#endif - + if (! result) { wxPyErr_SetString(PyExc_SystemExit, "OnInit returned false, exiting..."); } haveInitialized = true; - + error: return; } @@ -297,7 +297,7 @@ int wxPyApp::MainLoop() // Function to test if the Display (or whatever is the platform equivallent) -// can be connected to. +// can be connected to. bool wxPyApp::IsDisplayAvailable() { #ifdef __WXGTK__ @@ -328,7 +328,7 @@ bool wxPyApp::IsDisplayAvailable() */ if (CGMainDisplayID() == 0) { rv = false; - } else + } else #endif { // Also foreground the application on the first call as a side-effect. diff --git a/src/arrayholder.h b/src/arrayholder.h index 696fe1e4..06e2e3b1 100644 --- a/src/arrayholder.h +++ b/src/arrayholder.h @@ -1,6 +1,6 @@ //-------------------------------------------------------------------------- // Name: src/arrayholder.h -// Purpose: A simple template class that can hold and delete a pointer +// Purpose: A simple template class that can hold and delete a pointer // to a C array // // Author: Robin Dunn @@ -25,11 +25,11 @@ class wxCArrayHolder { public: wxCArrayHolder() : m_array(NULL) {} - ~wxCArrayHolder() { - delete [] m_array; + ~wxCArrayHolder() { + delete [] m_array; m_array = NULL; } - T* m_array; + T* m_array; }; typedef wxCArrayHolder wxIntCArrayHolder; diff --git a/src/arrayholder.sip b/src/arrayholder.sip index abf167bf..a57cb8ea 100644 --- a/src/arrayholder.sip +++ b/src/arrayholder.sip @@ -1,6 +1,6 @@ //-------------------------------------------------------------------------- // Name: arrayholder.sip -// Purpose: +// Purpose: // // Author: Robin Dunn // @@ -22,13 +22,13 @@ class wxCArrayHolder %TypeHeaderCode #include "arrayholder.h" %End - + public: wxCArrayHolder(); ~wxCArrayHolder(); - + private: - wxCArrayHolder(const wxCArrayHolder&); // no copies + wxCArrayHolder(const wxCArrayHolder&); // no copies wxCArrayHolder& operator=(wxCArrayHolder); // no assignment }; diff --git a/src/arrays.sip b/src/arrays.sip index a7b396e3..49ab591f 100644 --- a/src/arrays.sip +++ b/src/arrays.sip @@ -22,7 +22,7 @@ if (!sipIsErr) { int success = TRUE; // ensure that it is a sequence - if (! PySequence_Check(sipPy)) + if (! PySequence_Check(sipPy)) success = FALSE; // Ensure it is not a string or unicode object (they are sequences) else if (PyBytes_Check(sipPy) || PyUnicode_Check(sipPy)) @@ -38,13 +38,13 @@ break; } Py_DECREF(item); - } + } } - if (!success) + if (!success) PyErr_SetString(PyExc_TypeError, "Sequence of string or unicode objects expected."); return success; } - + // Code to create a new wxArrayString and convert a compatible PyObject wxArrayString *array = new wxArrayString; Py_ssize_t i, len = PySequence_Length(sipPy); @@ -61,7 +61,7 @@ Py_DECREF(item); return 0; } - } + } wxString string; size_t len = PyUnicode_GET_SIZE(item); if (len) { @@ -80,7 +80,7 @@ return sipGetState(sipTransferObj); %End - + %ConvertFromTypeCode // Code to convert a wxArrayString to a Python list of strings. PyObject* list = PyList_New(0); @@ -91,7 +91,7 @@ } return list; %End - + }; @@ -115,7 +115,7 @@ wxArrayString testArrayStringTypemap(const wxArrayString& arr); if (!sipIsErr) { int success = TRUE; // ensure that it is a sequence - if (! PySequence_Check(sipPy)) + if (! PySequence_Check(sipPy)) success = FALSE; // ensure each item is a number object else { @@ -128,13 +128,13 @@ wxArrayString testArrayStringTypemap(const wxArrayString& arr); break; } Py_DECREF(item); - } + } } - if (!success) + if (!success) PyErr_SetString(PyExc_TypeError, "Sequence of numbers expected."); return success; } - + // Code to create a new wxArrayInt and convert a compatible PyObject wxArrayInt *array = new wxArrayInt; Py_ssize_t i, len = PySequence_Length(sipPy); @@ -155,7 +155,7 @@ wxArrayString testArrayStringTypemap(const wxArrayString& arr); return sipGetState(sipTransferObj); %End - + %ConvertFromTypeCode // Code to convert a wxArrayInt to a Python list of integers. PyObject* list = PyList_New(0); @@ -166,7 +166,7 @@ wxArrayString testArrayStringTypemap(const wxArrayString& arr); } return list; %End - + }; @@ -191,7 +191,7 @@ wxArrayInt testArrayIntTypemap(const wxArrayInt& arr); if (!sipIsErr) { int success = TRUE; // ensure that it is a sequence - if (! PySequence_Check(sipPy)) + if (! PySequence_Check(sipPy)) success = FALSE; // ensure each item is a number object else { @@ -204,13 +204,13 @@ wxArrayInt testArrayIntTypemap(const wxArrayInt& arr); break; } Py_DECREF(item); - } + } } - if (!success) + if (!success) PyErr_SetString(PyExc_TypeError, "Sequence of numbers expected."); return success; } - + // Code to create a new wxArrayDouble and convert a compatible PyObject wxArrayDouble *array = new wxArrayDouble; Py_ssize_t i, len = PySequence_Length(sipPy); @@ -231,7 +231,7 @@ wxArrayInt testArrayIntTypemap(const wxArrayInt& arr); return sipGetState(sipTransferObj); %End - + %ConvertFromTypeCode // Code to convert a wxArrayDouble to a Python list of floating point values. PyObject* list = PyList_New(0); @@ -242,7 +242,7 @@ wxArrayInt testArrayIntTypemap(const wxArrayInt& arr); } return list; %End - + }; diff --git a/src/bitmap_ex.cpp b/src/bitmap_ex.cpp index 1dbba6a3..6dc2332b 100644 --- a/src/bitmap_ex.cpp +++ b/src/bitmap_ex.cpp @@ -1,7 +1,7 @@ //-------------------------------------------------------------------------- // Name: src/bitmap_ex.h -// Purpose: Helper functions and etc. for copying bitmap data to/from -// buffer objects. This file is included in etg/bitmap.py and +// Purpose: Helper functions and etc. for copying bitmap data to/from +// buffer objects. This file is included in etg/bitmap.py and // used in the wxBitmap wrapper. // // Author: Robin Dunn @@ -17,7 +17,7 @@ // TODO: Switch these APIs to use the new wxPyBuffer class void wxPyCopyBitmapFromBuffer(wxBitmap* bmp, - buffer data, Py_ssize_t DATASIZE, + buffer data, Py_ssize_t DATASIZE, wxBitmapBufferFormat format, int stride) { int height = bmp->GetHeight(); @@ -52,7 +52,7 @@ void wxPyCopyBitmapFromBuffer(wxBitmap* bmp, } break; } - + // A simple sequence of RGBA bytes case wxBitmapBufferFormat_RGBA: { @@ -82,7 +82,7 @@ void wxPyCopyBitmapFromBuffer(wxBitmap* bmp, } break; } - + // A sequence of 32-bit values in native endian order, // where the alpha is in the upper 8 bits, then red, then // green, then blue. The stride is the distance in bytes @@ -94,7 +94,7 @@ void wxPyCopyBitmapFromBuffer(wxBitmap* bmp, // NOTE: This is normally used with Cairo, which seems to // already have the values premultiplied. Should we have // a way to optionally do it anyway? - + case wxBitmapBufferFormat_RGB32: case wxBitmapBufferFormat_ARGB32: { @@ -102,10 +102,10 @@ void wxPyCopyBitmapFromBuffer(wxBitmap* bmp, byte* rowStart = data; wxUint32* bufptr; wxUint32 value; - + if (stride == -1) stride = width * 4; - + if (DATASIZE < stride * height) { wxPyErr_SetString(PyExc_ValueError, "Invalid data buffer size."); return; @@ -115,7 +115,7 @@ void wxPyCopyBitmapFromBuffer(wxBitmap* bmp, if (! pixData) { wxPyErr_SetString(PyExc_RuntimeError, "Failed to gain raw access to bitmap data."); - return; + return; } wxAlphaPixelData::Iterator pix(pixData); @@ -165,13 +165,13 @@ void wxPyCopyBitmapToBuffer(wxBitmap* bmp, int depth = bmp->GetDepth(); // images loaded from a file may not have set the depth, at least on Mac... - if (depth == -1) { + if (depth == -1) { if (bmp->HasAlpha()) depth = 32; else depth = 24; } - + switch (format) { // A simple sequence of RGB bytes case wxBitmapBufferFormat_RGB: @@ -179,7 +179,7 @@ void wxPyCopyBitmapToBuffer(wxBitmap* bmp, CHECK_BUFFERSIZE(width * height * 3); if (depth == 24) { MAKE_PIXDATA(wxNativePixelData); - + for (int y=0; y(sipCpp)); return obj; %End - + }; diff --git a/src/core_ex.cpp b/src/core_ex.cpp index feed75fb..de6c4bfd 100644 --- a/src/core_ex.cpp +++ b/src/core_ex.cpp @@ -23,11 +23,11 @@ static ULONG_PTR wxPySetActivationContext() OSVERSIONINFO info; wxZeroMemory(info); - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&info); if (info.dwMajorVersion < 5) return 0; - + ULONG_PTR cookie = 0; HANDLE h; ACTCTX actctx; @@ -40,7 +40,7 @@ static ULONG_PTR wxPySetActivationContext() actctx.lpResourceName = MAKEINTRESOURCE(2); actctx.hModule = wxGetInstance(); actctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID | ACTCTX_FLAG_RESOURCE_NAME_VALID; - + h = CreateActCtx(&actctx); if (h == INVALID_HANDLE_VALUE) { wxLogLastError(wxT("CreateActCtx")); @@ -49,7 +49,7 @@ static ULONG_PTR wxPySetActivationContext() if (! ActivateActCtx(h, &cookie)) wxLogLastError(wxT("ActivateActCtx")); - + return cookie; } @@ -109,8 +109,8 @@ void wxPyCoreModuleInject(PyObject* moduleDict) // An alias that should be deprecated sometime PyDict_SetItemString(moduleDict, "PyAssertionError", wxAssertionError); - - + + // // Create an exception object to use when the app object hasn't been created yet // wxPyNoAppError = PyErr_NewException("wx._core.PyNoAppError", // PyExc_RuntimeError, NULL); @@ -131,10 +131,10 @@ void wxPyCoreModuleInject(PyObject* moduleDict) wxInitAllImageHandlers(); - // TODO: Find some blackmagic way to deprecate wx.Platform such that it raises + // TODO: Find some blackmagic way to deprecate wx.Platform such that it raises // a wraning when used... Maybe a class that returns wx.Port for any __getattr__? PyDict_SetItemString(moduleDict, "Port", PyUnicode_FromString(wxPort)); - PyDict_SetItemString(moduleDict, "Platform", PyUnicode_FromString(wxPort)); + PyDict_SetItemString(moduleDict, "Platform", PyUnicode_FromString(wxPort)); // Make a tuple of strings that gives more info about the platform and build. PyObject* PlatformInfo = PyList_New(0); diff --git a/src/core_ex.py b/src/core_ex.py index 5ade3b4e..efb2fed0 100644 --- a/src/core_ex.py +++ b/src/core_ex.py @@ -11,7 +11,7 @@ if 'wxEVT_NULL' in dir(): if RELEASE_NUMBER != wx._core.RELEASE_NUMBER: import warnings warnings.warn("wxPython/wxWidgets release number mismatch") - + # Register a function to be called when Python terminates that will clean # up and release all system resources that wxWidgets allocated. import atexit @@ -26,8 +26,8 @@ else: # A little trick to make 'wx' be a reference to this module so wx.Names can # be used in the python code here. wx = _sys.modules[__name__] - - + + import warnings class wxPyDeprecationWarning(DeprecationWarning): pass @@ -43,14 +43,14 @@ def deprecated(item, msg='', useName=False): properties. """ import warnings - + name = '' if useName: try: name = ' ' + item.__name__ except AttributeError: pass - + if isinstance(item, type): # It is a class. Make a subclass that raises a warning. class DeprecatedClassProxy(item): @@ -60,7 +60,7 @@ def deprecated(item, msg='', useName=False): item.__init__(*args, **kw) DeprecatedClassProxy.__name__ = item.__name__ return DeprecatedClassProxy - + elif callable(item): # wrap a new function around the callable def deprecated_func(*args, **kw): @@ -74,7 +74,7 @@ def deprecated(item, msg='', useName=False): if hasattr(item, '__dict__'): deprecated_func.__dict__.update(item.__dict__) return deprecated_func - + elif hasattr(item, '__get__'): # it should be a property if there is a getter class DepGetProp(object): @@ -95,7 +95,7 @@ def deprecated(item, msg='', useName=False): warnings.warn("Accessing deprecated property. %s" % msg, wxPyDeprecationWarning, stacklevel=2) return self.item.__delete__(inst) - + if hasattr(item, '__set__') and hasattr(item, '__delete__'): return DepGetSetDelProp(item, msg) elif hasattr(item, '__set__'): @@ -104,7 +104,7 @@ def deprecated(item, msg='', useName=False): return DepGetProp(item, msg) else: raise TypeError("unsupported type %s" % type(item)) - + def deprecatedMsg(msg): """ diff --git a/src/dc_ex.cpp b/src/dc_ex.cpp index 4bccf48e..e63964a4 100644 --- a/src/dc_ex.cpp +++ b/src/dc_ex.cpp @@ -30,7 +30,7 @@ PyObject* wxPyDrawTextList(wxDC& dc, PyObject* textList, PyObject* pyPoints, PyObject* wxPyDrawXXXList(wxDC& dc, wxPyDrawListOp_t doDraw, PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) { - wxPyBlock_t blocked = wxPyBeginBlockThreads(); + wxPyBlock_t blocked = wxPyBeginBlockThreads(); bool isFastSeq = PyList_Check(pyCoords) || PyTuple_Check(pyCoords); bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens); @@ -193,7 +193,7 @@ bool wxPyDrawXXXEllipse(wxDC& dc, PyObject* coords) } -wxPoint* wxPoint_LIST_helper(PyObject* source, int *count); +wxPoint* wxPoint_LIST_helper(PyObject* source, int *count); bool wxPyDrawXXXPolygon(wxDC& dc, PyObject* coords) { diff --git a/src/dvcvariant.sip b/src/dvcvariant.sip index bfcf7491..96d289bf 100644 --- a/src/dvcvariant.sip +++ b/src/dvcvariant.sip @@ -10,8 +10,8 @@ //-------------------------------------------------------------------------- %ModuleHeaderCode -// A wxDVCVariant is really the same thing as a wxVariant. We just create -// this new type so a different %MappedType can be created for it that also +// A wxDVCVariant is really the same thing as a wxVariant. We just create +// this new type so a different %MappedType can be created for it that also // knows how to put DVC types in and out of a variant. typedef wxVariant wxDVCVariant; @@ -27,12 +27,12 @@ typedef wxVector wxVariantVector; wxVariant wxDVCVariant_in_helper(PyObject* source) { wxVariant ret; - + if (wxPyWrappedPtr_TypeCheck(source, wxT("wxDataViewIconText"))) { wxDataViewIconText* ptr; wxPyConvertWrappedPtr(source, (void**)&ptr, wxT("wxDataViewIconText")); ret << *ptr; - } + } else ret = wxVariant_in_helper(source); return ret; @@ -42,7 +42,7 @@ wxVariant wxDVCVariant_in_helper(PyObject* source) PyObject* wxDVCVariant_out_helper(const wxVariant& value) { PyObject* ret; - + if ( value.IsType("wxDataViewIconText") ) { wxDataViewIconText val; @@ -60,25 +60,25 @@ PyObject* wxDVCVariant_out_helper(const wxVariant& value) %MappedType wxDVCVariant { %ConvertToTypeCode - // Code to test a PyObject for compatibility. + // Code to test a PyObject for compatibility. if (!sipIsErr) { - // Any type should work since we'll just use the PyObject directly + // Any type should work since we'll just use the PyObject directly // if the type is not one that is explicitly supported. return TRUE; } - + // Code to create a new wxVariant from the PyObject - wxVariant* value = new wxVariant(wxDVCVariant_in_helper(sipPy)); + wxVariant* value = new wxVariant(wxDVCVariant_in_helper(sipPy)); *sipCppPtr = value; return sipGetState(sipTransferObj); %End - + %ConvertFromTypeCode // Code to convert a wxVariant to a PyObject. if (sipCpp == NULL) { return Py_None; - } else { + } else { return wxDVCVariant_out_helper(*sipCpp); } %End @@ -86,7 +86,7 @@ PyObject* wxDVCVariant_out_helper(const wxVariant& value) -// Some DVC classes also make use of a wxVector type. This code +// Some DVC classes also make use of a wxVector type. This code // will convert Python sequences to that type. %MappedType wxVariantVector { @@ -95,7 +95,7 @@ PyObject* wxDVCVariant_out_helper(const wxVariant& value) // We expect a sequence return PySequence_Check(sipPy); } - + wxVariantVector* vector = new wxVariantVector; Py_ssize_t size = PySequence_Length(sipPy); Py_ssize_t idx; @@ -104,12 +104,12 @@ PyObject* wxDVCVariant_out_helper(const wxVariant& value) vector->push_back( wxDVCVariant_in_helper(item) ); Py_DECREF(item); } - + *sipCppPtr = vector; return sipGetState(sipTransferObj); %End - + %ConvertFromTypeCode // no C++ --> Python convert needed yet... return NULL; diff --git a/src/event_ex.cpp b/src/event_ex.cpp index 5103e734..1f965519 100644 --- a/src/event_ex.cpp +++ b/src/event_ex.cpp @@ -43,7 +43,7 @@ void wxPyCallback::EventThunker(wxEvent& event) { wxPyThreadBlocker blocker; wxString className = event.GetClassInfo()->GetClassName(); arg = wxPyConstructObject((void*)&event, className); - + if (!arg) { PyErr_Print(); } else { diff --git a/src/event_ex.py b/src/event_ex.py index 7e8a8524..a2a30477 100644 --- a/src/event_ex.py +++ b/src/event_ex.py @@ -76,10 +76,10 @@ EVT_MOUSE_EVENTS = wx.PyEventBinder([ wxEVT_LEFT_DOWN, wxEVT_LEAVE_WINDOW, wxEVT_MOUSEWHEEL, wxEVT_AUX1_DOWN, - wxEVT_AUX1_UP, + wxEVT_AUX1_UP, wxEVT_AUX1_DCLICK, - wxEVT_AUX2_DOWN, - wxEVT_AUX2_UP, + wxEVT_AUX2_DOWN, + wxEVT_AUX2_UP, wxEVT_AUX2_DCLICK, ]) @@ -172,7 +172,7 @@ EVT_TOOL_ENTER = wx.PyEventBinder( wxEVT_TOOL_ENTER, 1) EVT_TOOL_DROPDOWN = wx.PyEventBinder( wxEVT_TOOL_DROPDOWN, 1) EVT_CHECKLISTBOX = wx.PyEventBinder( wxEVT_CHECKLISTBOX, 1) EVT_COMBOBOX_DROPDOWN = wx.PyEventBinder( wxEVT_COMBOBOX_DROPDOWN , 1) -EVT_COMBOBOX_CLOSEUP = wx.PyEventBinder( wxEVT_COMBOBOX_CLOSEUP , 1) +EVT_COMBOBOX_CLOSEUP = wx.PyEventBinder( wxEVT_COMBOBOX_CLOSEUP , 1) EVT_COMMAND_LEFT_CLICK = wx.PyEventBinder( wxEVT_COMMAND_LEFT_CLICK, 1) EVT_COMMAND_LEFT_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_LEFT_DCLICK, 1) @@ -203,8 +203,8 @@ EVT_JOY_BUTTON_UP = wx.PyEventBinder( wxEVT_JOY_BUTTON_UP ) EVT_JOY_MOVE = wx.PyEventBinder( wxEVT_JOY_MOVE ) EVT_JOY_ZMOVE = wx.PyEventBinder( wxEVT_JOY_ZMOVE ) EVT_JOYSTICK_EVENTS = wx.PyEventBinder([ wxEVT_JOY_BUTTON_DOWN, - wxEVT_JOY_BUTTON_UP, - wxEVT_JOY_MOVE, + wxEVT_JOY_BUTTON_UP, + wxEVT_JOY_MOVE, wxEVT_JOY_ZMOVE, ]) diff --git a/src/filename.sip b/src/filename.sip index b0ed9664..1e6520c4 100644 --- a/src/filename.sip +++ b/src/filename.sip @@ -27,11 +27,11 @@ return sipGetState(sipTransferObj); %End - + %ConvertFromTypeCode // Convert a wxString to a Python Unicode object. See wxpy_api.sip return wx2PyString(sipCpp->GetFullPath()); - %End + %End }; diff --git a/src/pseudodc.cpp b/src/pseudodc.cpp index 0a3d127a..4e4d0596 100644 --- a/src/pseudodc.cpp +++ b/src/pseudodc.cpp @@ -67,7 +67,7 @@ void GreyOutImage(wxImage &img) for (i=0;iGetData()->DrawToDC(dc, m_greyedout); @@ -281,13 +281,13 @@ void pdcObject::DrawToDC(wxDC *dc) // ---------------------------------------------------------------------------- void pdcObject::Translate(wxCoord dx, wxCoord dy) { - pdcOpList::compatibility_iterator node = m_oplist.GetFirst(); + pdcOpList::compatibility_iterator node = m_oplist.GetFirst(); while(node) { node->GetData()->Translate(dx,dy); node = node->GetNext(); } - if (m_bounded) + if (m_bounded) { m_bounds.x += dx; m_bounds.y += dy; @@ -298,12 +298,12 @@ void pdcObject::Translate(wxCoord dx, wxCoord dy) // SetGreyedOut - set the greyout member and cache grey versions of everything // if greyout is true // ---------------------------------------------------------------------------- -void pdcObject::SetGreyedOut(bool greyout) +void pdcObject::SetGreyedOut(bool greyout) { m_greyedout=greyout; if (greyout) { - pdcOpList::compatibility_iterator node = m_oplist.GetFirst(); + pdcOpList::compatibility_iterator node = m_oplist.GetFirst(); pdcOp *obj; while(node) { @@ -325,7 +325,7 @@ wxPseudoDC::~wxPseudoDC() { // delete all the nodes in the list RemoveAll(); - + } // ---------------------------------------------------------------------------- @@ -337,7 +337,7 @@ void wxPseudoDC::RemoveAll(void) m_objectIndex.clear(); m_currId = -1; m_lastObject = NULL; - + } // ---------------------------------------------------------------------------- @@ -347,7 +347,7 @@ int wxPseudoDC::GetLen(void) { pdcObjectList::compatibility_iterator pt = m_objectlist.GetFirst(); int len=0; - while (pt) + while (pt) { len += pt->GetData()->GetLen(); pt = pt->GetNext(); @@ -365,7 +365,7 @@ pdcObject *wxPseudoDC::FindObject(int id, bool create) // see if last operation was for same id //~ if (m_lastObject && m_lastObject->GetId() == id) //~ return m_lastObject; - // if not then search for it + // if not then search for it pdcObjectHash::iterator lookup = m_objectIndex.find(id); if (lookup == m_objectIndex.end()) {//not found if (create) { @@ -406,7 +406,7 @@ void wxPseudoDC::ClearId(int id) void wxPseudoDC::RemoveId(int id) { pdcObject *obj = FindObject(id); - if (obj) + if (obj) { if (m_lastObject == obj) m_lastObject = obj; @@ -488,7 +488,7 @@ PyObject *wxPseudoDC::FindObjectsByBBox(wxCoord x, wxCoord y) PyObject* pyList = NULL; pyList = PyList_New(0); wxRect r; - while (pt) + while (pt) { obj = pt->GetData(); r = obj->GetBounds(); @@ -507,7 +507,7 @@ PyObject *wxPseudoDC::FindObjectsByBBox(wxCoord x, wxCoord y) // ---------------------------------------------------------------------------- // FindObjects - Return a list of all the ids that draw to (x,y) // ---------------------------------------------------------------------------- -PyObject *wxPseudoDC::FindObjects(wxCoord x, wxCoord y, +PyObject *wxPseudoDC::FindObjects(wxCoord x, wxCoord y, wxCoord radius, const wxColor& bg) { //wxPyBlock_t blocked = wxPyBeginBlockThreads(); @@ -529,7 +529,7 @@ PyObject *wxPseudoDC::FindObjects(wxCoord x, wxCoord y, memdc.SetBackground(bgbrush); memdc.Clear(); memdc.SetDeviceOrigin(2-x,2-y); - while (pt) + while (pt) { obj = pt->GetData(); if (obj->IsBounded() && obj->GetBounds().Contains(x,y)) @@ -573,7 +573,7 @@ PyObject *wxPseudoDC::FindObjects(wxCoord x, wxCoord y, memdc.SetDeviceOrigin(radius-x,radius-y); // a region will be used to see if the result is empty wxRegion rgn2; - while (pt) + while (pt) { obj = pt->GetData(); if (obj->IsBounded() && viewrect.Intersects(obj->GetBounds())) @@ -616,15 +616,15 @@ PyObject *wxPseudoDC::FindObjects(wxCoord x, wxCoord y, // ---------------------------------------------------------------------------- // DrawToDCClipped - play back the op list to the DC but clip any objects -// known to be not in rect. This is a coarse level of -// clipping to speed things up when lots of objects are off +// known to be not in rect. This is a coarse level of +// clipping to speed things up when lots of objects are off // screen and doesn't affect the dc level clipping // ---------------------------------------------------------------------------- void wxPseudoDC::DrawToDCClipped(wxDC *dc, const wxRect& rect) { pdcObjectList::compatibility_iterator pt = m_objectlist.GetFirst(); pdcObject *obj; - while (pt) + while (pt) { obj = pt->GetData(); if (!obj->IsBounded() || rect.Intersects(obj->GetBounds())) @@ -636,10 +636,10 @@ void wxPseudoDC::DrawToDCClippedRgn(wxDC *dc, const wxRegion& region) { pdcObjectList::compatibility_iterator pt = m_objectlist.GetFirst(); pdcObject *obj; - while (pt) + while (pt) { obj = pt->GetData(); - if (!obj->IsBounded() || + if (!obj->IsBounded() || (region.Contains(obj->GetBounds()) != wxOutRegion)) obj->DrawToDC(dc); pt = pt->GetNext(); @@ -647,15 +647,15 @@ void wxPseudoDC::DrawToDCClippedRgn(wxDC *dc, const wxRegion& region) } // ---------------------------------------------------------------------------- -// DrawToDC - play back the op list to the DC +// DrawToDC - play back the op list to the DC // ---------------------------------------------------------------------------- void wxPseudoDC::DrawToDC(wxDC *dc) { pdcObjectList::compatibility_iterator pt = m_objectlist.GetFirst(); - while (pt) + while (pt) { pt->GetData()->DrawToDC(dc); pt = pt->GetNext(); } } - + diff --git a/src/pseudodc.h b/src/pseudodc.h index 0be2a5b0..d2c76bc0 100644 --- a/src/pseudodc.h +++ b/src/pseudodc.h @@ -50,7 +50,7 @@ wxBitmap &GetGreyBitmap(wxBitmap &bmp); class pdcSetFontOp : public pdcOp { public: - pdcSetFontOp(const wxFont& font) + pdcSetFontOp(const wxFont& font) {m_font=font;} virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->SetFont(m_font);} protected: @@ -60,9 +60,9 @@ class pdcSetFontOp : public pdcOp class pdcSetBrushOp : public pdcOp { public: - pdcSetBrushOp(const wxBrush& brush) - {m_greybrush=m_brush=brush;} - virtual void DrawToDC(wxDC *dc, bool grey=false) + pdcSetBrushOp(const wxBrush& brush) + {m_greybrush=m_brush=brush;} + virtual void DrawToDC(wxDC *dc, bool grey=false) { if (!grey) dc->SetBrush(m_brush); else dc->SetBrush(m_greybrush); @@ -76,8 +76,8 @@ class pdcSetBrushOp : public pdcOp class pdcSetBackgroundOp : public pdcOp { public: - pdcSetBackgroundOp(const wxBrush& brush) - {m_greybrush=m_brush=brush;} + pdcSetBackgroundOp(const wxBrush& brush) + {m_greybrush=m_brush=brush;} virtual void DrawToDC(wxDC *dc, bool grey=false) { if (!grey) dc->SetBackground(m_brush); @@ -92,7 +92,7 @@ class pdcSetBackgroundOp : public pdcOp class pdcSetPenOp : public pdcOp { public: - pdcSetPenOp(const wxPen& pen) + pdcSetPenOp(const wxPen& pen) {m_greypen=m_pen=pen;} virtual void DrawToDC(wxDC *dc, bool grey=false) { @@ -108,9 +108,9 @@ class pdcSetPenOp : public pdcOp class pdcSetTextBackgroundOp : public pdcOp { public: - pdcSetTextBackgroundOp(const wxColour& colour) + pdcSetTextBackgroundOp(const wxColour& colour) {m_colour=colour;} - virtual void DrawToDC(wxDC *dc, bool grey=false) + virtual void DrawToDC(wxDC *dc, bool grey=false) { if (!grey) dc->SetTextBackground(m_colour); else dc->SetTextBackground(MakeColourGrey(m_colour)); @@ -122,7 +122,7 @@ class pdcSetTextBackgroundOp : public pdcOp class pdcSetTextForegroundOp : public pdcOp { public: - pdcSetTextForegroundOp(const wxColour& colour) + pdcSetTextForegroundOp(const wxColour& colour) {m_colour=colour;} virtual void DrawToDC(wxDC *dc, bool grey=false) { @@ -139,7 +139,7 @@ class pdcDrawRectangleOp : public pdcOp pdcDrawRectangleOp(wxCoord x, wxCoord y, wxCoord w, wxCoord h) {m_x=x; m_y=y; m_w=w; m_h=h;} virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->DrawRectangle(m_x,m_y,m_w,m_h);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x+=dx;m_y+=dy;} protected: wxCoord m_x,m_y,m_w,m_h; @@ -151,7 +151,7 @@ class pdcDrawLineOp : public pdcOp pdcDrawLineOp(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) {m_x1=x1; m_y1=y1; m_x2=x2; m_y2=y2;} virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->DrawLine(m_x1,m_y1,m_x2,m_y2);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x1+=dx; m_y1+=dy; m_x2+=dx; m_y2+=dy;} protected: wxCoord m_x1,m_y1,m_x2,m_y2; @@ -172,7 +172,7 @@ class pdcDrawTextOp : public pdcOp pdcDrawTextOp(const wxString& text, wxCoord x, wxCoord y) {m_text=text; m_x=x; m_y=y;} virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->DrawText(m_text, m_x, m_y);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x+=dx; m_y+=dy;} protected: wxString m_text; @@ -205,12 +205,12 @@ class pdcFloodFillOp : public pdcOp public: pdcFloodFillOp(wxCoord x, wxCoord y, const wxColour& col, wxFloodFillStyle style) {m_x=x; m_y=y; m_col=col; m_style=style;} - virtual void DrawToDC(wxDC *dc, bool grey=false) + virtual void DrawToDC(wxDC *dc, bool grey=false) { if (!grey) dc->FloodFill(m_x,m_y,m_col,m_style); else dc->FloodFill(m_x,m_y,MakeColourGrey(m_col),m_style); } - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x+=dx; m_y+=dy;} protected: wxCoord m_x,m_y; @@ -223,7 +223,7 @@ class pdcCrossHairOp : public pdcOp public: pdcCrossHairOp(wxCoord x, wxCoord y) {m_x=x; m_y=y;} virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->CrossHair(m_x,m_y);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x+=dx; m_y+=dy;} protected: wxCoord m_x,m_y; @@ -233,11 +233,11 @@ class pdcDrawArcOp : public pdcOp { public: pdcDrawArcOp(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, - wxCoord xc, wxCoord yc) + wxCoord xc, wxCoord yc) {m_x1=x1; m_y1=y1; m_x2=x2; m_y2=y2; m_xc=xc; m_yc=yc;} - virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) + virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->DrawArc(m_x1,m_y1,m_x2,m_y2,m_xc,m_yc);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x1+=dx; m_x2+=dx; m_y1+=dy; m_y2+=dy;} protected: wxCoord m_x1,m_x2,m_xc; @@ -248,11 +248,11 @@ class pdcDrawCheckMarkOp : public pdcOp { public: pdcDrawCheckMarkOp(wxCoord x, wxCoord y, - wxCoord width, wxCoord height) + wxCoord width, wxCoord height) {m_x=x; m_y=y; m_w=width; m_h=height;} - virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) + virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->DrawCheckMark(m_x,m_y,m_w,m_h);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x+=dx; m_y+=dy;} protected: wxCoord m_x,m_y,m_w,m_h; @@ -262,11 +262,11 @@ class pdcDrawEllipticArcOp : public pdcOp { public: pdcDrawEllipticArcOp(wxCoord x, wxCoord y, wxCoord w, wxCoord h, - double sa, double ea) + double sa, double ea) {m_x=x; m_y=y; m_w=w; m_h=h; m_sa=sa; m_ea=ea;} - virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) + virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->DrawEllipticArc(m_x,m_y,m_w,m_h,m_sa,m_ea);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x+=dx; m_y+=dy;} protected: wxCoord m_x,m_y,m_w,m_h; @@ -276,10 +276,10 @@ class pdcDrawEllipticArcOp : public pdcOp class pdcDrawPointOp : public pdcOp { public: - pdcDrawPointOp(wxCoord x, wxCoord y) + pdcDrawPointOp(wxCoord x, wxCoord y) {m_x=x; m_y=y;} virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->DrawPoint(m_x,m_y);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x+=dx; m_y+=dy;} protected: wxCoord m_x,m_y; @@ -288,12 +288,12 @@ class pdcDrawPointOp : public pdcOp class pdcDrawRoundedRectangleOp : public pdcOp { public: - pdcDrawRoundedRectangleOp(wxCoord x, wxCoord y, wxCoord width, - wxCoord height, double radius) + pdcDrawRoundedRectangleOp(wxCoord x, wxCoord y, wxCoord width, + wxCoord height, double radius) {m_x=x; m_y=y; m_w=width; m_h=height; m_r=radius;} - virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) + virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->DrawRoundedRectangle(m_x,m_y,m_w,m_h,m_r);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x+=dx; m_y+=dy;} protected: wxCoord m_x,m_y,m_w,m_h; @@ -303,10 +303,10 @@ class pdcDrawRoundedRectangleOp : public pdcOp class pdcDrawEllipseOp : public pdcOp { public: - pdcDrawEllipseOp(wxCoord x, wxCoord y, wxCoord width, wxCoord height) + pdcDrawEllipseOp(wxCoord x, wxCoord y, wxCoord width, wxCoord height) {m_x=x; m_y=y; m_w=width; m_h=height;} virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->DrawEllipse(m_x,m_y,m_w,m_h);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x+=dx; m_y+=dy;} protected: wxCoord m_x,m_y,m_w,m_h; @@ -315,15 +315,15 @@ class pdcDrawEllipseOp : public pdcOp class pdcDrawIconOp : public pdcOp { public: - pdcDrawIconOp(const wxIcon& icon, wxCoord x, wxCoord y) + pdcDrawIconOp(const wxIcon& icon, wxCoord x, wxCoord y) {m_icon=icon; m_x=x; m_y=y;} - virtual void DrawToDC(wxDC *dc, bool grey=false) + virtual void DrawToDC(wxDC *dc, bool grey=false) { if (grey) dc->DrawIcon(m_greyicon,m_x,m_y); else dc->DrawIcon(m_icon,m_x,m_y); } virtual void CacheGrey() {m_greyicon=GetGreyIcon(m_icon);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x+=dx; m_y+=dy;} protected: wxIcon m_icon; @@ -359,9 +359,9 @@ class pdcDrawPolygonOp : public pdcOp wxPolygonFillMode fillStyle = wxODDEVEN_RULE); virtual ~pdcDrawPolygonOp(); - virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) + virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) { dc->DrawPolygon(m_points, m_xoffset, m_yoffset, m_fillStyle); } - + virtual void Translate(wxCoord dx, wxCoord dy); protected: @@ -378,14 +378,14 @@ class pdcDrawPolyPolygonOp : public pdcOp wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); virtual ~pdcDrawPolyPolygonOp(); - virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) + virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->DrawPolyPolygon(m_n,m_count,m_points, m_xoffset,m_yoffset,m_fillStyle);} virtual void Translate(wxCoord dx, wxCoord dy) - { + { for(int i=0; iDrawRotatedText(m_text,m_x,m_y,m_angle);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x+=dx; m_y+=dy;} protected: wxString m_text; @@ -417,15 +417,15 @@ class pdcDrawBitmapOp : public pdcOp { public: pdcDrawBitmapOp(const wxBitmap &bmp, wxCoord x, wxCoord y, - bool useMask = false) + bool useMask = false) {m_bmp=bmp; m_x=x; m_y=y; m_useMask=useMask;} - virtual void DrawToDC(wxDC *dc, bool grey=false) + virtual void DrawToDC(wxDC *dc, bool grey=false) { if (grey) dc->DrawBitmap(m_greybmp,m_x,m_y,m_useMask); else dc->DrawBitmap(m_bmp,m_x,m_y,m_useMask); } virtual void CacheGrey() {m_greybmp=GetGreyBitmap(m_bmp);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_x+=dx; m_y+=dy;} protected: wxBitmap m_bmp; @@ -442,11 +442,11 @@ class pdcDrawLabelOp : public pdcOp const wxRect& rect, int alignment = wxALIGN_LEFT | wxALIGN_TOP, int indexAccel = -1) - {m_text=text; m_image=image; m_rect=rect; + {m_text=text; m_image=image; m_rect=rect; m_align=alignment; m_iAccel=indexAccel;} - virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) + virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->DrawLabel(m_text,m_image,m_rect,m_align,m_iAccel);} - virtual void Translate(wxCoord dx, wxCoord dy) + virtual void Translate(wxCoord dx, wxCoord dy) {m_rect.x+=dx; m_rect.y+=dy;} protected: wxString m_text; @@ -498,12 +498,12 @@ class pdcSetLogicalFunctionOp : public pdcOp class pdcObject { public: - pdcObject(int id) + pdcObject(int id) {m_id=id; m_bounded=false; m_oplist.DeleteContents(true); m_greyedout=false;} virtual ~pdcObject() {m_oplist.Clear();} - + // Protected Member Access void SetId(int id) {m_id=id;} int GetId() {return m_id;} @@ -513,17 +513,17 @@ class pdcObject bool IsBounded() {return m_bounded;} void SetGreyedOut(bool greyout=true); bool GetGreyedOut() {return m_greyedout;} - + // Op List Management Methods void Clear() {m_oplist.Clear();} - void AddOp(pdcOp *op) + void AddOp(pdcOp *op) { m_oplist.Append(op); if (m_greyedout) op->CacheGrey(); } int GetLen() {return m_oplist.GetCount();} virtual void Translate(wxCoord dx, wxCoord dy); - + // Drawing Method virtual void DrawToDC(wxDC *dc); protected: @@ -559,24 +559,24 @@ WX_DECLARE_HASH_MAP( // This is the actual PseudoDC class // This class stores a list of recorded dc operations in m_list // and plays them back to a real dc using DrawToDC or DrawToDCClipped. -// Drawing methods are mirrored from wxDC but add nodes to m_list +// Drawing methods are mirrored from wxDC but add nodes to m_list // instead of doing any real drawing. // ---------------------------------------------------------------------------- class wxPseudoDC : public wxObject { public: - wxPseudoDC() + wxPseudoDC() {m_currId=-1; m_lastObject=NULL; m_objectlist.DeleteContents(true);m_objectIndex.clear();} ~wxPseudoDC(); // ------------------------------------------------------------------------ // List management methods - // + // void RemoveAll(); int GetLen(); - + // ------------------------------------------------------------------------ // methods for managing operations by ID - // + // // Set the Id for all subsequent operations (until SetId is called again) void SetId(int id) {m_currId = id;} // Remove all the operations associated with an id so it can be redrawn @@ -595,7 +595,7 @@ public: // Find Objects at a point. Returns Python list of id's // sorted in reverse drawing order (result[0] is top object) // This version looks at drawn pixels - PyObject *FindObjects(wxCoord x, wxCoord y, + PyObject *FindObjects(wxCoord x, wxCoord y, wxCoord radius=1, const wxColor& bg=*wxWHITE); // This version only looks at bounding boxes PyObject *FindObjectsByBBox(wxCoord x, wxCoord y); @@ -604,8 +604,8 @@ public: // Playback Methods // // draw to dc but skip objects known to be outside of rect - // This is a coarse level of clipping to speed things up - // when lots of objects are off screen and doesn't affect the dc level + // This is a coarse level of clipping to speed things up + // when lots of objects are off screen and doesn't affect the dc level // clipping void DrawToDCClipped(wxDC *dc, const wxRect& rect); void DrawToDCClippedRgn(wxDC *dc, const wxRegion& region); @@ -622,8 +622,8 @@ public: // PyObject *HitTest(wxCoord x, wxCoord y, double radius) // returns list of objects whose bounding boxes include (x,y) // PyObject *HitTestBB(wxCoord x, wxCoord y) - - + + // ------------------------------------------------------------------------ // Methods mirrored from wxDC // @@ -735,7 +735,7 @@ public: // this version puts both optional bitmap and the text into the given // rectangle and aligns is as specified by alignment parameter; it also - // will emphasize the character with the given index if it is != -1 + // will emphasize the character with the given index if it is != -1 void DrawLabel(const wxString& text, const wxBitmap& image, const wxRect& rect, @@ -758,7 +758,7 @@ public: wxDC *source, const wxPoint& srcPt, int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition) { - Blit(destPt.x, destPt.y, sz.x, sz.y, source, srcPt.x, srcPt.y, + Blit(destPt.x, destPt.y, sz.x, sz.y, source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y); } ??????*/ @@ -775,7 +775,7 @@ public: void SetLogicalFunction(wxRasterOperationMode function) {AddToList(new pdcSetLogicalFunctionOp(function));} - void SetFont(const wxFont& font) + void SetFont(const wxFont& font) {AddToList(new pdcSetFontOp(font));} void SetPen(const wxPen& pen) {AddToList(new pdcSetPenOp(pen));} @@ -802,15 +802,15 @@ protected: // protected helper methods void AddToList(pdcOp *newOp); pdcObject *FindObject(int id, bool create=false); - + // ------------------------------------------------------------------------ // Data members - // + // int m_currId; // id to use for operations done on the PseudoDC pdcObject *m_lastObject; // used to find last used object quickly pdcObjectList m_objectlist; // list of objects pdcObjectHash m_objectIndex; //id->object lookup index - + }; #endif diff --git a/src/pyevent.h b/src/pyevent.h index 7e53f490..29a30b56 100644 --- a/src/pyevent.h +++ b/src/pyevent.h @@ -1,6 +1,6 @@ //-------------------------------------------------------------------------- // Name: pyevent.h -// Purpose: A set of event classes that can be derived from in Python +// Purpose: A set of event classes that can be derived from in Python // and that preserve their attributes when cloned. // // Author: Robin Dunn @@ -30,18 +30,18 @@ class wxPyEvtDict { public: - wxPyEvtDict() + wxPyEvtDict() { wxPyThreadBlocker blocker; - m_dict = PyDict_New(); + m_dict = PyDict_New(); } - + wxPyEvtDict(const wxPyEvtDict& other) { wxPyThreadBlocker blocker; m_dict = PyDict_Copy(other.m_dict); } - + ~wxPyEvtDict() { wxPyThreadBlocker blocker; @@ -55,7 +55,7 @@ public: Py_INCREF(m_dict); return m_dict; } - + PyObject* __getattr__(PyObject* name) { PyObject* value = NULL; @@ -69,25 +69,25 @@ public: } return value; } - + void __setattr__(PyObject* name, PyObject* value) { wxPyThreadBlocker blocker; PyDict_SetItem(m_dict, name, value); } - + void __delattr__(PyObject* name) { wxPyThreadBlocker blocker; if (PyDict_Contains(m_dict, name)) PyDict_DelItem(m_dict, name); - else + else PyErr_SetObject(PyExc_AttributeError, name); } - + protected: PyObject* m_dict; -}; +}; //-------------------------------------------------------------------------- @@ -99,8 +99,8 @@ class wxPyEvent : public wxEvent, public wxPyEvtDict public: wxPyEvent(int id=0, wxEventType eventType = wxEVT_NULL) : wxEvent(id, eventType) {} - - // NOTE: The default copy ctor is used here + + // NOTE: The default copy ctor is used here virtual wxEvent* Clone() const { return new wxPyEvent(*this); } }; @@ -114,8 +114,8 @@ class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtDict public: wxPyCommandEvent(wxEventType eventType = wxEVT_NULL, int id=0) : wxCommandEvent(eventType, id) {} - - // NOTE: The default copy ctor is used here + + // NOTE: The default copy ctor is used here virtual wxEvent* Clone() const { return new wxPyCommandEvent(*this); } }; diff --git a/src/stockgdi.sip b/src/stockgdi.sip index cf159ec1..32e79d77 100644 --- a/src/stockgdi.sip +++ b/src/stockgdi.sip @@ -1,8 +1,8 @@ //-------------------------------------------------------------------------- // Name: src/stockobj.sip // Purpose: Wrapper definition and some Python code for wxStockGDI and -// using it to initialize the stock objects like wx.BLUE_BRUSH, -// etc. We're putting it here because wxStockGDI is not +// using it to initialize the stock objects like wx.BLUE_BRUSH, +// etc. We're putting it here because wxStockGDI is not // documented, and probably should not be. // // Author: Robin Dunn @@ -69,30 +69,30 @@ public: static const wxPen* GetPen(Item item); const wxFont* GetFont(Item item); - + // Add some methods for fetching the various global gdi object lists so - // they can be set at app creation time too. + // they can be set at app creation time too. static wxFontList* _getTheFontList(); %MethodCode sipRes = wxTheFontList; %End - + static wxPenList* _getThePenList(); %MethodCode sipRes = wxThePenList; %End - + static wxBrushList* _getTheBrushList(); %MethodCode sipRes = wxTheBrushList; %End - + static wxColourDatabase* _getTheColourDatabase(); %MethodCode sipRes = wxTheColourDatabase; %End - - + + private: wxStockGDI(const wxStockGDI&); wxStockGDI& operator=(const wxStockGDI&); @@ -105,7 +105,7 @@ def _initStockObjects(): wx.SMALL_FONT._copyFrom( StockGDI.instance().GetFont(StockGDI.FONT_SMALL)) wx.SWISS_FONT._copyFrom( StockGDI.instance().GetFont(StockGDI.FONT_SWISS)) wx.ITALIC_FONT._copyFrom( StockGDI.instance().GetFont(StockGDI.FONT_ITALIC)) - + wx.BLACK_DASHED_PEN._copyFrom( StockGDI.GetPen(StockGDI.PEN_BLACKDASHED)) wx.BLACK_PEN._copyFrom( StockGDI.GetPen(StockGDI.PEN_BLACK)) wx.BLUE_PEN._copyFrom( StockGDI.GetPen(StockGDI.PEN_BLUE)) @@ -148,7 +148,7 @@ def _initStockObjects(): wx.ThePenList = StockGDI._getThePenList() wx.TheBrushList = StockGDI._getTheBrushList() wx.TheColourDatabase = StockGDI._getTheColourDatabase() - - + + StockGDI._initStockObjects = staticmethod(_initStockObjects) %End diff --git a/src/stream_input.cpp b/src/stream_input.cpp index 344d10aa..b22ca9c6 100644 --- a/src/stream_input.cpp +++ b/src/stream_input.cpp @@ -15,14 +15,14 @@ static PyObject* wxPyGetMethod(PyObject* py, char* name) #define wxPyBlock_t_default PyGILState_UNLOCKED -// This class can wrap a Python file-like object and allow it to be used +// This class can wrap a Python file-like object and allow it to be used // as a wxInputStream. class wxPyInputStream : public wxInputStream { public: // Make sure there is at least a read method - static bool Check(PyObject* fileObj) + static bool Check(PyObject* fileObj) { PyObject* method = wxPyGetMethod(fileObj, "read"); bool rval = method != NULL; @@ -30,16 +30,16 @@ public: return rval; } - wxPyInputStream(PyObject* fileObj, bool block=true) + wxPyInputStream(PyObject* fileObj, bool block=true) { m_block = block; wxPyThreadBlocker blocker(m_block); - + m_read = wxPyGetMethod(fileObj, "read"); m_seek = wxPyGetMethod(fileObj, "seek"); m_tell = wxPyGetMethod(fileObj, "tell"); } - + virtual ~wxPyInputStream() { wxPyThreadBlocker blocker(m_block); @@ -47,7 +47,7 @@ public: Py_XDECREF(m_seek); Py_XDECREF(m_tell); } - + wxPyInputStream(const wxPyInputStream& other) { wxPyThreadBlocker blocker; @@ -59,12 +59,12 @@ public: Py_INCREF(m_seek); Py_INCREF(m_tell); } - + protected: // implement base class virtuals - - wxFileOffset GetLength() const + + wxFileOffset GetLength() const { wxPyInputStream* self = (wxPyInputStream*)this; // cast off const if (m_seek && m_tell) { @@ -77,16 +77,16 @@ protected: return wxInvalidOffset; } - size_t OnSysRead(void *buffer, size_t bufsize) + size_t OnSysRead(void *buffer, size_t bufsize) { if (bufsize == 0) return 0; - + wxPyThreadBlocker blocker; PyObject* arglist = Py_BuildValue("(i)", bufsize); PyObject* result = PyEval_CallObject(m_read, arglist); Py_DECREF(arglist); - + size_t o = 0; if ((result != NULL) && PyBytes_Check(result)) { o = PyBytes_Size(result); @@ -96,40 +96,40 @@ protected: o = bufsize; memcpy((char*)buffer, PyBytes_AsString(result), o); // strings only, not unicode... Py_DECREF(result); - + } else m_lasterror = wxSTREAM_READ_ERROR; return o; } - - size_t OnSysWrite(const void *buffer, size_t bufsize) + + size_t OnSysWrite(const void *buffer, size_t bufsize) { m_lasterror = wxSTREAM_WRITE_ERROR; return 0; } - - wxFileOffset OnSysSeek(wxFileOffset off, wxSeekMode mode) + + wxFileOffset OnSysSeek(wxFileOffset off, wxSeekMode mode) { wxPyThreadBlocker blocker; PyObject* arglist = PyTuple_New(2); - + if (sizeof(wxFileOffset) > sizeof(long)) // wxFileOffset is a 64-bit value... PyTuple_SET_ITEM(arglist, 0, PyLong_FromLongLong(off)); else PyTuple_SET_ITEM(arglist, 0, wxPyInt_FromLong(off)); - + PyTuple_SET_ITEM(arglist, 1, wxPyInt_FromLong(mode)); - - + + PyObject* result = PyEval_CallObject(m_seek, arglist); Py_DECREF(arglist); Py_XDECREF(result); return OnSysTell(); } - - wxFileOffset OnSysTell() const + + wxFileOffset OnSysTell() const { wxPyThreadBlocker blocker; PyObject* arglist = Py_BuildValue("()"); @@ -145,18 +145,18 @@ protected: }; return o; } - - bool IsSeekable() const + + bool IsSeekable() const { return (m_seek != NULL); } - + private: PyObject* m_read; PyObject* m_seek; PyObject* m_tell; bool m_block; }; - + //-------------------------------------------------------------------------- diff --git a/src/stream_output.cpp b/src/stream_output.cpp index 691bda59..c135e209 100644 --- a/src/stream_output.cpp +++ b/src/stream_output.cpp @@ -15,14 +15,14 @@ static PyObject* wxPyGetMethod(PyObject* py, char* name) #define wxPyBlock_t_default PyGILState_UNLOCKED -// This class can wrap a Python file-like object and allow it to be used +// This class can wrap a Python file-like object and allow it to be used // as a wxInputStream. class wxPyOutputStream : public wxOutputStream { public: // Make sure there is at least a write method - static bool Check(PyObject* fileObj) + static bool Check(PyObject* fileObj) { PyObject* method = wxPyGetMethod(fileObj, "write"); bool rval = method != NULL; @@ -30,16 +30,16 @@ public: return rval; } - wxPyOutputStream(PyObject* fileObj, bool block=true) + wxPyOutputStream(PyObject* fileObj, bool block=true) { m_block = block; wxPyThreadBlocker blocker(m_block); - + m_write = wxPyGetMethod(fileObj, "write"); m_seek = wxPyGetMethod(fileObj, "seek"); m_tell = wxPyGetMethod(fileObj, "tell"); } - + virtual ~wxPyOutputStream() { wxPyThreadBlocker blocker(m_block); @@ -47,7 +47,7 @@ public: Py_XDECREF(m_seek); Py_XDECREF(m_tell); } - + wxPyOutputStream(const wxPyOutputStream& other) { wxPyThreadBlocker blocker; @@ -59,12 +59,12 @@ public: Py_INCREF(m_seek); Py_INCREF(m_tell); } - + protected: // implement base class virtuals - - wxFileOffset GetLength() const + + wxFileOffset GetLength() const { wxPyOutputStream* self = (wxPyOutputStream*)this; // cast off const if (m_seek && m_tell) { @@ -77,52 +77,52 @@ protected: return wxInvalidOffset; } - size_t OnSysRead(void *buffer, size_t bufsize) + size_t OnSysRead(void *buffer, size_t bufsize) { m_lasterror = wxSTREAM_READ_ERROR; return 0; } - - size_t OnSysWrite(const void *buffer, size_t bufsize) - { + + size_t OnSysWrite(const void *buffer, size_t bufsize) + { if (bufsize == 0) return 0; - + wxPyThreadBlocker blocker; PyObject* arglist = PyTuple_New(1); PyTuple_SET_ITEM(arglist, 0, PyBytes_FromStringAndSize((char*)buffer, bufsize)); - + PyObject* result = PyEval_CallObject(m_write, arglist); Py_DECREF(arglist); - + if (result != NULL) Py_DECREF(result); else m_lasterror = wxSTREAM_WRITE_ERROR; - return bufsize; + return bufsize; } - - wxFileOffset OnSysSeek(wxFileOffset off, wxSeekMode mode) + + wxFileOffset OnSysSeek(wxFileOffset off, wxSeekMode mode) { wxPyThreadBlocker blocker; PyObject* arglist = PyTuple_New(2); - + if (sizeof(wxFileOffset) > sizeof(long)) // wxFileOffset is a 64-bit value... PyTuple_SET_ITEM(arglist, 0, PyLong_FromLongLong(off)); else PyTuple_SET_ITEM(arglist, 0, wxPyInt_FromLong(off)); - + PyTuple_SET_ITEM(arglist, 1, wxPyInt_FromLong(mode)); - - + + PyObject* result = PyEval_CallObject(m_seek, arglist); Py_DECREF(arglist); Py_XDECREF(result); return OnSysTell(); } - - wxFileOffset OnSysTell() const + + wxFileOffset OnSysTell() const { wxPyThreadBlocker blocker; PyObject* arglist = Py_BuildValue("()"); @@ -138,17 +138,17 @@ protected: }; return o; } - - bool IsSeekable() const + + bool IsSeekable() const { return (m_seek != NULL); } - + private: PyObject* m_write; PyObject* m_seek; PyObject* m_tell; bool m_block; }; - + //-------------------------------------------------------------------------- diff --git a/src/string.sip b/src/string.sip index 65b4ce9d..ad1c57ce 100644 --- a/src/string.sip +++ b/src/string.sip @@ -13,7 +13,7 @@ // We don't want the Python user to ever need to deal directly with wxString // at all, so it will be mapped to and from Python Unicode objects using the // code snippets below. -// NOTE: Currently we assume that string objects are encoded in utf-8. +// NOTE: Currently we assume that string objects are encoded in utf-8. %MappedType wxString { @@ -21,12 +21,12 @@ // TODO: It is still possible to have a wx build that uses utf-8 inside // wxString, so we should probably be checking wxUSE_UNICODE_WCHAR or // wxUSE_UNICODE_UTF8 for this conversion. - + %ConvertToTypeCode #if wxUSE_UNICODE_WCHAR == 0 #error wxString converison can only handle WCHAR wxStrings currently #endif - + // Code to test a PyObject for compatibility with wxString if (!sipIsErr) { if (PyBytes_Check(sipPy) || PyUnicode_Check(sipPy)) @@ -43,7 +43,7 @@ *sipIsErr = 1; return 0; } - } + } *sipCppPtr = new wxString(); size_t len = PyUnicode_GET_SIZE(uni); if (len) { @@ -54,11 +54,11 @@ return sipGetState(sipTransferObj); %End - + %ConvertFromTypeCode // Convert a wxString to a Python Unicode object. See wxpy_api.sip return wx2PyString(*sipCpp); - %End + %End }; diff --git a/src/treeitemdata.sip b/src/treeitemdata.sip index 16ff0404..295911cf 100644 --- a/src/treeitemdata.sip +++ b/src/treeitemdata.sip @@ -1,6 +1,6 @@ //-------------------------------------------------------------------------- // Name: treeitemdata.sip -// Purpose: A MappedType for wxTreeItemData that handles containing +// Purpose: A MappedType for wxTreeItemData that handles containing // arbitrary PyObjects, dealing with their refcounts, etc. // // Author: Robin Dunn @@ -33,19 +33,19 @@ public: if (!sipIsErr) { return TRUE; // any python object is valid } - + // Code to create a new wxTreeItemData from the PyObject wxPyTreeItemData* data = new wxPyTreeItemData(sipPy); *sipCppPtr = data; return sipGetState(sipTransferObj); %End - + %ConvertFromTypeCode // Code to convert a wxPyTreeItemData back to the PyObject. PyObject* obj; obj = wxPyTreeItemData::SafeGetData(static_cast(sipCpp)); return obj; %End - + }; diff --git a/src/userdata.sip b/src/userdata.sip index 57c31582..9965f410 100644 --- a/src/userdata.sip +++ b/src/userdata.sip @@ -1,6 +1,6 @@ //-------------------------------------------------------------------------- // Name: userdata.sip -// Purpose: +// Purpose: // // Author: Kevin Ollivier // @@ -12,7 +12,7 @@ // We'll use the wxPyUserData defined above wherever a wxObject parameter or // return value is specified in the API. This MappedType code will convert to/from a -// PyObject so it will be totally transparent to the programmer and from their +// PyObject so it will be totally transparent to the programmer and from their // perspective any python object is being stored as the client data. %MappedType wxPyUserData { @@ -21,14 +21,14 @@ if (!sipIsErr) { return TRUE; // any python object is valid } - + // Code to create a new wxPyUserData from the PyObject wxPyUserData* data = new wxPyUserData(sipPy); *sipCppPtr = data; return sipGetState(sipTransferObj); %End - + %ConvertFromTypeCode // Code to convert a wxPyUserData back to the PyObject. PyObject* obj; diff --git a/src/wacky_ints.sip b/src/wacky_ints.sip index e5ee280c..bb187b12 100644 --- a/src/wacky_ints.sip +++ b/src/wacky_ints.sip @@ -1,8 +1,8 @@ //-------------------------------------------------------------------------- -// Name: wacky_ints.sip +// Name: wacky_ints.sip // // Purpose: Implements a %MappedType for size_t and others in order to -// deal with different sizeof's on different platforms. They're +// deal with different sizeof's on different platforms. They're // 32bit on some, 64bit on others. // // Author: Robin Dunn @@ -14,7 +14,7 @@ // size_t will either be equivalent to an unsigned long, or to an -// unsigned long long. wxWidgets' configure script has already figured out +// unsigned long long. wxWidgets' configure script has already figured out // which it is, so we can make it conditional on those results. %MappedType size_t { @@ -42,7 +42,7 @@ }; -// This type is a signed integer value that is large enough to hold a +// This type is a signed integer value that is large enough to hold a // pointer. Again we'll use the results of wxWidgets configuration. %MappedType wxIntPtr { @@ -78,7 +78,7 @@ }; -// This type is an unsigned integer value that is large enough to hold a +// This type is an unsigned integer value that is large enough to hold a // pointer. Again we'll use the results of wxWidgets configuration. %MappedType wxUIntPtr { diff --git a/src/window_ex.cpp b/src/window_ex.cpp index 4df37253..b5d100c9 100644 --- a/src/window_ex.cpp +++ b/src/window_ex.cpp @@ -31,7 +31,7 @@ static XID GetXWindow(const wxWindow* wxwin) { -wxUIntPtr wxPyGetWinHandle(const wxWindow* win) +wxUIntPtr wxPyGetWinHandle(const wxWindow* win) { #ifdef __WXMSW__ return (wxUIntPtr)win->GetHandle(); diff --git a/src/wxpy_api.h b/src/wxpy_api.h index 02509900..089d459b 100644 --- a/src/wxpy_api.h +++ b/src/wxpy_api.h @@ -1,7 +1,7 @@ //-------------------------------------------------------------------------- // Name: wxpy_api.h -// Purpose: Some utility functions and such that can be used in other -// snippets of C++ code to help reduce complexity, etc. They +// Purpose: Some utility functions and such that can be used in other +// snippets of C++ code to help reduce complexity, etc. They // are all either macros, inline functions, or functions that // are exported from the core extension module. // @@ -41,7 +41,7 @@ #include //-------------------------------------------------------------------------- -// The API items that can be inline functions or macros. +// The API items that can be inline functions or macros. // These are made available simply by #including this header file. //-------------------------------------------------------------------------- @@ -83,7 +83,7 @@ inline void wxPyEndAllowThreads(PyThreadState* saved) { #define wxPyErr_SetString(err, str) \ wxPyBLOCK_THREADS(PyErr_SetString(err, str)) - + // Raise NotImplemented exceptions #define wxPyRaiseNotImplemented() \ wxPyBLOCK_THREADS( PyErr_SetNone(PyExc_NotImplementedError) ) @@ -138,7 +138,7 @@ inline PyObject* wxPyMakeBuffer(void* ptr, Py_ssize_t len, bool readOnly=false) #define wxPyNumber_Int PyNumber_Int #endif -inline +inline Py_ssize_t wxPyUnicode_AsWideChar(PyObject* unicode, wchar_t* w, Py_ssize_t size) { // GIL should already be held @@ -177,13 +177,13 @@ struct wxPyAPI { inline wxPyAPI* wxPyGetAPIPtr() { static wxPyAPI* wxPyAPIPtr = NULL; - + if (wxPyAPIPtr == NULL) { PyGILState_STATE state = PyGILState_Ensure(); wxPyAPIPtr = (wxPyAPI*)PyCapsule_Import("wx._wxPyAPI", 0); // uncomment if needed for debugging //if (PyErr_Occurred()) { PyErr_Print(); } - //wxASSERT_MSG(wxPyAPIPtr != NULL, wxT("wxPyAPIPtr is NULL!!!")); + //wxASSERT_MSG(wxPyAPIPtr != NULL, wxT("wxPyAPIPtr is NULL!!!")); PyGILState_Release(state); } @@ -195,13 +195,13 @@ inline wxPyAPI* wxPyGetAPIPtr() // Convert a PyObject to a wxString // Assumes that the GIL has already been acquired. -inline wxString Py2wxString(PyObject* source) +inline wxString Py2wxString(PyObject* source) { return wxPyGetAPIPtr()->p_Py2wxString(source); } // Create a PyObject of the requested type from a void* and a class name. // Assumes that the GIL has already been acquired. -inline PyObject* wxPyConstructObject(void* ptr, const wxString& className, bool setThisOwn=false) +inline PyObject* wxPyConstructObject(void* ptr, const wxString& className, bool setThisOwn=false) { return wxPyGetAPIPtr()->p_wxPyConstructObject(ptr, className, setThisOwn); } @@ -217,36 +217,36 @@ inline bool wxPyWrappedPtr_TypeCheck(PyObject* obj, const wxString& className) // Convert a wrapped SIP object to its C++ pointer, ensuring that it is of the expected type inline bool wxPyConvertWrappedPtr(PyObject* obj, void **ptr, const wxString& className) { return wxPyGetAPIPtr()->p_wxPyConvertWrappedPtr(obj, ptr, className); } - - + + // Calls from wxWindows back to Python code, or even any PyObject // manipulations, PyDECREF's and etc. should be wrapped in calls to these functions: -inline wxPyBlock_t wxPyBeginBlockThreads() +inline wxPyBlock_t wxPyBeginBlockThreads() { return wxPyGetAPIPtr()->p_wxPyBeginBlockThreads(); } - -inline void wxPyEndBlockThreads(wxPyBlock_t blocked) + +inline void wxPyEndBlockThreads(wxPyBlock_t blocked) { wxPyGetAPIPtr()->p_wxPyEndBlockThreads(blocked); } - - + + // A helper for converting a 2 element sequence to a pair of integers inline bool wxPy2int_seq_helper(PyObject* source, int* i1, int* i2) { return wxPyGetAPIPtr()->p_wxPy2int_seq_helper(source, i1, i2); } // A helper for converting a 4 element sequence to a set of integers -inline bool wxPy4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4) +inline bool wxPy4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4) { return wxPyGetAPIPtr()->p_wxPy4int_seq_helper(source, i1, i2, i3, i4); } - - + + // Convert a PyObject to a wxVariant inline wxVariant wxVariant_in_helper(PyObject* obj) { return wxPyGetAPIPtr()->p_wxVariant_in_helper(obj); } - -// Convert a wxVariant to a PyObject + +// Convert a wxVariant to a PyObject inline PyObject* wxVariant_out_helper(const wxVariant& value) { return wxPyGetAPIPtr()->p_wxVariant_out_helper(value); } - + //-------------------------------------------------------------------------- // Convenience helper for RAII-style thread blocking @@ -262,33 +262,33 @@ public: if (m_block) { wxPyEndBlockThreads(m_oldstate); } - } + } private: void operator=(const wxPyThreadBlocker&); - explicit wxPyThreadBlocker(const wxPyThreadBlocker&); + explicit wxPyThreadBlocker(const wxPyThreadBlocker&); wxPyBlock_t m_oldstate; bool m_block; }; - - + + //-------------------------------------------------------------------------- // helper template to make common code for all of the various user data owners template class wxPyUserDataHelper : public Base { public: - explicit wxPyUserDataHelper(PyObject* obj = NULL) - : m_obj(obj ? obj : Py_None) + explicit wxPyUserDataHelper(PyObject* obj = NULL) + : m_obj(obj ? obj : Py_None) { wxPyThreadBlocker blocker; - Py_INCREF(m_obj); - } - + Py_INCREF(m_obj); + } + ~wxPyUserDataHelper() { // normally the derived class does the clean up, or deliberately leaks // by setting m_obj to 0, but if not then do it here. - if (m_obj) { + if (m_obj) { wxPyThreadBlocker blocker; Py_DECREF(m_obj); m_obj = 0; @@ -301,7 +301,7 @@ public: Py_INCREF(m_obj); return m_obj; } - + // Return Value: Borrowed reference PyObject* BorrowData() const { return m_obj; @@ -315,7 +315,7 @@ public: Py_INCREF(m_obj); } } - + // Return the object in udata or None if udata is null // Return Value: New reference static PyObject* SafeGetData(wxPyUserDataHelper* udata) { @@ -324,13 +324,13 @@ public: Py_INCREF(obj); return obj; } - + // Set the m_obj to null, this should only be used during clean up, when // the object should be leaked. // Calling any other methods on this object is then undefined behaviour void ReleaseDataDuringCleanup() { - m_obj = 0; + m_obj = 0; } private: @@ -361,5 +361,5 @@ public: }; -//-------------------------------------------------------------------------- +//-------------------------------------------------------------------------- #endif diff --git a/src/wxpy_api.sip b/src/wxpy_api.sip index a2ca7558..1a48ac1f 100644 --- a/src/wxpy_api.sip +++ b/src/wxpy_api.sip @@ -1,6 +1,6 @@ //-------------------------------------------------------------------------- // Name: wxpy_api.sip -// Purpose: The implementation of the API functions that are exported +// Purpose: The implementation of the API functions that are exported // from the core extension module. // // Author: Robin Dunn @@ -25,8 +25,8 @@ //-------------------------------------------------------------------------- // wxString conversion -// See also the wxString MappedType. This code is similar, but doesn't -// allocate a new wxString instance on the heap, is able to convert +// See also the wxString MappedType. This code is similar, but doesn't +// allocate a new wxString instance on the heap, is able to convert // non-string/unicode objects to unicode, and won't raise exceptions static wxString i_Py2wxString(PyObject* source) { @@ -41,12 +41,12 @@ static wxString i_Py2wxString(PyObject* source) PyErr_Clear(); return wxEmptyString; } - } + } else if (!PyUnicode_Check(source)) { #if PY_MAJOR_VERSION >= 3 uni = PyObject_Str(source); #else - uni = PyObject_Unicode(source); + uni = PyObject_Unicode(source); #endif if (PyErr_Occurred()) { PyErr_Clear(); @@ -63,8 +63,8 @@ static wxString i_Py2wxString(PyObject* source) return target; } - -// TODO: This might be a good way to share the string conversion code here and in string.sip... + +// TODO: This might be a good way to share the string conversion code here and in string.sip... // A function to convert a Python string or unicode object to a wxString // NOTE that it is inline so it should go in the header section //inline wxString Py2wxString(PyObject* obj, bool setException=false, int& isErr=0) { @@ -92,7 +92,7 @@ static wxString i_Py2wxString(PyObject* source) // Py_DECREF(uni) // release the temporary Unicode object we may have created // return str; //} - + //-------------------------------------------------------------------------- // Wrapped object checks and converters @@ -105,13 +105,13 @@ static PyObject* i_wxPyConstructObject(void* ptr, wxString nsDelimiter = "::"; int pos = name.Find(nsDelimiter); if (pos != wxNOT_FOUND) - name = name.Mid(pos + nsDelimiter.Len()); + name = name.Mid(pos + nsDelimiter.Len()); const sipTypeDef* td = sipFindType(name); if (!td) return NULL; PyObject* transferObj = setThisOwn ? Py_None : NULL; - return sipConvertFromType(ptr, td, transferObj); + return sipConvertFromType(ptr, td, transferObj); } @@ -148,7 +148,7 @@ static bool i_wxPyConvertWrappedPtr(PyObject* obj, void **ptr, const wxString& c // Calls from wxWindows back to Python code, or even any PyObject // manipulations, PyDECREF's and etc. should be wrapped in calls to these functions: -static wxPyBlock_t i_wxPyBeginBlockThreads() +static wxPyBlock_t i_wxPyBeginBlockThreads() { if (! Py_IsInitialized()) { return (wxPyBlock_t)0; @@ -157,11 +157,11 @@ static wxPyBlock_t i_wxPyBeginBlockThreads() return state; } -static void i_wxPyEndBlockThreads(wxPyBlock_t blocked) +static void i_wxPyEndBlockThreads(wxPyBlock_t blocked) { if (! Py_IsInitialized()) { return; - } + } PyGILState_Release(blocked); } @@ -197,7 +197,7 @@ static bool i_wxPy2int_seq_helper(PyObject* source, int* i1, int* i2) } // A helper for converting a 4 element sequence to a set of integers -static bool i_wxPy4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4) +static bool i_wxPy4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4) { bool isFast = PyList_Check(source) || PyTuple_Check(source); PyObject *o1, *o2, *o3, *o4; @@ -243,9 +243,9 @@ class wxVariantDataPyObject : public wxPyUserDataHelper public: explicit wxVariantDataPyObject(PyObject* obj = 0) : wxPyUserDataHelper(obj) {} - + virtual bool Eq(wxVariantData& data) const; - + virtual wxString GetType() const { return wxT("PyObject"); } wxVariantData* Clone() const { return new wxVariantDataPyObject(BorrowData()); } }; @@ -275,8 +275,8 @@ bool wxVariantDataPyObject::Eq(wxVariantData& data) const wxVariant i_wxVariant_in_helper(PyObject* obj) { wxVariant value; - - if (PyBytes_Check(obj) || PyUnicode_Check(obj)) + + if (PyBytes_Check(obj) || PyUnicode_Check(obj)) value = Py2wxString(obj); else if (PyBool_Check(obj)) value = (obj == Py_True); @@ -303,7 +303,7 @@ wxVariant i_wxVariant_in_helper(PyObject* obj) } else value = new wxVariantDataPyObject(obj); - + return value; } @@ -312,7 +312,7 @@ wxVariant i_wxVariant_in_helper(PyObject* obj) PyObject* i_wxVariant_out_helper(const wxVariant& value) { PyObject* obj; - + if (value.IsType("string")) obj = wx2PyString(value.GetString()); else if (value.IsType("bool")) @@ -348,7 +348,7 @@ PyObject* i_wxVariant_out_helper(const wxVariant& value) wxString msg = "Unexpected type (\"" + value.GetType() + "\") in wxVariant."; wxPyErr_SetString(PyExc_TypeError, msg.mb_str()); obj = NULL; - } + } return obj; } diff --git a/src/wxpybuffer.h b/src/wxpybuffer.h index 3d2899f0..9a79093a 100644 --- a/src/wxpybuffer.h +++ b/src/wxpybuffer.h @@ -1,6 +1,6 @@ //-------------------------------------------------------------------------- // Name: src/wxpybuffer.h -// Purpose: A simple class to hold a pointer and a size. See +// Purpose: A simple class to hold a pointer and a size. See // wxpybuffer.sip for code that converts from a Python buffer // object as a MappedType. // @@ -21,15 +21,15 @@ public: wxPyBuffer() : m_ptr(NULL), m_len(0) {} // Initialize this object's pointer and length from a PyObject supporting - // the Python buffer protocol. Raises a TypeError if the object can not + // the Python buffer protocol. Raises a TypeError if the object can not // be used as a buffer. bool create(PyObject* obj) { int rv = PyObject_AsReadBuffer(obj, (const void**)&m_ptr, &m_len); return rv != -1; } - - - // Ensure that the buffer's size is the expected size. Raises a + + + // Ensure that the buffer's size is the expected size. Raises a // Python ValueError exception and returns false if not. bool checkSize(Py_ssize_t expectedSize) { if (m_len < expectedSize) { @@ -39,15 +39,15 @@ public: return true; } - // Make a simple C copy of the data buffer. Malloc is used because - // the wxAPIs this is used with will later free() the pointer. Raises + // Make a simple C copy of the data buffer. Malloc is used because + // the wxAPIs this is used with will later free() the pointer. Raises // a Python exception if there is an allocation error. void* copy() { void* ptr = malloc(m_len); if (ptr == NULL) { wxPyBLOCK_THREADS(PyErr_NoMemory()); return NULL; - } + } memcpy(ptr, m_ptr, m_len); return ptr; } diff --git a/src/wxpybuffer.sip b/src/wxpybuffer.sip index 53c90cb7..cb9d2fcf 100644 --- a/src/wxpybuffer.sip +++ b/src/wxpybuffer.sip @@ -28,7 +28,7 @@ return TRUE; return FALSE; } - + // Code to create a new wxPyBuffer from the PyObject wxPyBuffer* buf = new wxPyBuffer(); buf->create(sipPy); @@ -37,7 +37,7 @@ %End - // This isn't being used anywhere yet, but it should work. + // This isn't being used anywhere yet, but it should work. %ConvertFromTypeCode return wxPyMakeBuffer(sipCpp->m_ptr, sipCpp->m_len); %End @@ -62,7 +62,7 @@ return TRUE; return FALSE; } - + // Code to create a new wxMemoryBuffer from the PyObject wxPyBuffer pybuf; pybuf.create(sipPy); @@ -91,7 +91,7 @@ return TRUE; return FALSE; } - + // Code to create a new wxCharBuffer from the PyObject char* bbuf; Py_ssize_t blen;