diff --git a/wxPython/contrib/activex/activex.i b/wxPython/contrib/activex/activex.i index df0f3c7cd1..c663e332a4 100644 --- a/wxPython/contrib/activex/activex.i +++ b/wxPython/contrib/activex/activex.i @@ -515,6 +515,8 @@ specified by the TypeInfo. ", ""); +MustHaveApp(wxActiveXWindow); + class wxActiveXWindow : public wxWindow { public: @@ -1053,6 +1055,8 @@ public: %feature("noautodoc") wxIEHtmlWindowBase::GetText; +MustHaveApp(wxIEHtmlWindowBase); + class wxIEHtmlWindowBase : public wxActiveXWindow { public: diff --git a/wxPython/contrib/gizmos/gizmos.i b/wxPython/contrib/gizmos/gizmos.i index 6f48b39f4c..e24377889e 100644 --- a/wxPython/contrib/gizmos/gizmos.i +++ b/wxPython/contrib/gizmos/gizmos.i @@ -139,6 +139,8 @@ public: */ +MustHaveApp(wxDynamicSashWindow); + class wxDynamicSashWindow : public wxWindow { public: %pythonAppend wxDynamicSashWindow "self._setOORInfo(self)" @@ -177,6 +179,7 @@ enum { // This class provides a composite control that lets the // user easily enter list of strings +MustHaveApp(wxEditableListBox); class wxEditableListBox : public wxPanel { public: @@ -227,6 +230,8 @@ public: typedef wxTreeCtrl wxPyTreeCtrl; %} +MustHaveApp(wxRemotelyScrolledTreeCtrl); + class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl { public: @@ -298,6 +303,8 @@ public: %} +MustHaveApp(wxPyTreeCompanionWindow); + %name(TreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow { public: @@ -323,6 +330,8 @@ public: * than the usual one. */ +MustHaveApp(wxThinSplitterWindow); + class wxThinSplitterWindow: public wxSplitterWindow { public: @@ -346,6 +355,8 @@ public: * scroll appropriately. */ +MustHaveApp(wxSplitterScrolledWindow); + class wxSplitterScrolledWindow: public wxScrolledWindow { public: @@ -375,6 +386,8 @@ enum wxLEDValueAlign }; +MustHaveApp(wxLEDNumberCtrl); + class wxLEDNumberCtrl : public wxControl { public: @@ -501,6 +514,8 @@ IMPLEMENT_ABSTRACT_CLASS(wxPyTreeListCtrl, wxTreeListCtrl) +MustHaveApp(wxPyTreeListCtrl); + %name(TreeListCtrl) class wxPyTreeListCtrl : public wxControl { public: diff --git a/wxPython/contrib/glcanvas/glcanvas.i b/wxPython/contrib/glcanvas/glcanvas.i index 9892e2751a..ab3dd14b29 100644 --- a/wxPython/contrib/glcanvas/glcanvas.i +++ b/wxPython/contrib/glcanvas/glcanvas.i @@ -43,6 +43,8 @@ class wxPalette; //--------------------------------------------------------------------------- +MustHaveApp(wxGLContext); + class wxGLContext : public wxObject { public: #ifndef __WXMAC__ @@ -118,6 +120,8 @@ enum { +MustHaveApp(wxGLCanvas); + class wxGLCanvas : public wxWindow { public: %pythonAppend wxGLCanvas "self._setOORInfo(self)" diff --git a/wxPython/contrib/iewin/iewin.i b/wxPython/contrib/iewin/iewin.i index 72342916c0..b97f5fca0b 100644 --- a/wxPython/contrib/iewin/iewin.i +++ b/wxPython/contrib/iewin/iewin.i @@ -78,6 +78,8 @@ enum wxIEHtmlRefreshLevel { }; +MustHaveApp(wxIEHtmlWin); + class wxIEHtmlWin : public wxWindow /* wxActiveX */ { public: diff --git a/wxPython/contrib/ogl/_oglcanvas.i b/wxPython/contrib/ogl/_oglcanvas.i index b220dee2a2..af80f9ad97 100644 --- a/wxPython/contrib/ogl/_oglcanvas.i +++ b/wxPython/contrib/ogl/_oglcanvas.i @@ -99,6 +99,8 @@ public: %} +MustHaveApp(wxPyShapeCanvas); + class wxPyShapeCanvas : public wxScrolledWindow { public: %pythonAppend wxPyShapeCanvas "self._setOORandCallbackInfo(PyShapeCanvas)" diff --git a/wxPython/contrib/xrc/_xmlres.i b/wxPython/contrib/xrc/_xmlres.i index fca287e729..2861a13f26 100644 --- a/wxPython/contrib/xrc/_xmlres.i +++ b/wxPython/contrib/xrc/_xmlres.i @@ -44,9 +44,8 @@ class wxXmlResource : public wxObject { public: - %pythonAppend wxXmlResource(const wxString& filemask, int flags) "self.InitAllHandlers()" - - %pythonAppend wxXmlResource(int flags) "val.InitAllHandlers()" + %pythonAppend wxXmlResource(const wxString& filemask, int flags) "self.InitAllHandlers()" + %pythonAppend wxXmlResource(int flags) "val.InitAllHandlers()" // Ctors. // Flags: wxXRC_USE_LOCALE diff --git a/wxPython/docs/CHANGES.txt b/wxPython/docs/CHANGES.txt index cc94500d62..84e1810a90 100644 --- a/wxPython/docs/CHANGES.txt +++ b/wxPython/docs/CHANGES.txt @@ -95,6 +95,10 @@ MigrationGuide_ file for details. EVT_STC_POSCHANGED has been removed as it has been deprecated in Scintilla for several releases now. +All the Window and GDI (pen, bitmap, etc.) classes and also many +toplevel functions will now check that a wx.App object has already +been created and will raise a wx.PyNoAppError exception if not. + diff --git a/wxPython/docs/MigrationGuide.txt b/wxPython/docs/MigrationGuide.txt index 690436e242..79d79ae383 100644 --- a/wxPython/docs/MigrationGuide.txt +++ b/wxPython/docs/MigrationGuide.txt @@ -52,6 +52,11 @@ Also, you will probably not be able to do any kind of GUI or bitmap operation unless you first have created an app object, (even on Windows where most anything was possible before.) +**[Changed in 2.5.2.0]** All the Window and GDI (pen, bitmap, etc.) +classes and also many toplevel functions will now check that a wx.App +object has already been created and will raise a wx.PyNoAppError +exception if not. + SWIG 1.3 diff --git a/wxPython/include/wx/wxPython/wxPython.h b/wxPython/include/wx/wxPython/wxPython.h index e925902d66..dc3a1f6820 100644 --- a/wxPython/include/wx/wxPython/wxPython.h +++ b/wxPython/include/wx/wxPython/wxPython.h @@ -133,6 +133,8 @@ inline wxPyCoreAPI* wxPyGetCoreAPIPtr() #define wxPyInstance_Check(a) (wxPyGetCoreAPIPtr()->p_wxPyInstance_Check(a)) #define wxPySwigInstance_Check(a) (wxPyGetCoreAPIPtr()->p_wxPySwigInstance_Check(a)) +#define wxPyCheckForApp() (wxPyGetCoreAPIPtr()->p_wxPyCheckForApp()) + //---------------------------------------------------------------------- #endif diff --git a/wxPython/include/wx/wxPython/wxPython_int.h b/wxPython/include/wx/wxPython/wxPython_int.h index 14686c748f..f942120404 100644 --- a/wxPython/include/wx/wxPython/wxPython_int.h +++ b/wxPython/include/wx/wxPython/wxPython_int.h @@ -187,7 +187,9 @@ bool wxPoint2D_helper(PyObject* source, wxPoint2D** obj); bool wxPySimple_typecheck(PyObject* source, const wxChar* classname, int seqLen); bool wxColour_typecheck(PyObject* source); +bool wxPyCheckForApp(); + template bool wxPyTwoIntItem_helper(PyObject* source, T** obj, const wxChar* name) { @@ -428,7 +430,9 @@ struct wxPyCoreAPI { bool (*p_wxPyInstance_Check)(PyObject* obj); bool (*p_wxPySwigInstance_Check)(PyObject* obj); - + + bool (*p_wxPyCheckForApp)(); + }; #ifdef wxPyUSE_EXPORTED_API diff --git a/wxPython/src/_artprov.i b/wxPython/src/_artprov.i index 0f1511589a..586c4e7873 100644 --- a/wxPython/src/_artprov.i +++ b/wxPython/src/_artprov.i @@ -186,6 +186,10 @@ identical bitmap for different client values! of the categories above) "); +MustHaveApp(wxPyArtProvider); +MustHaveApp(wxPyArtProvider::GetBitmap); +MustHaveApp(wxPyArtProvider::GetIcon); + %name(ArtProvider) class wxPyArtProvider /*: public wxObject*/ { public: diff --git a/wxPython/src/_bitmap.i b/wxPython/src/_bitmap.i index 241c9ceada..88e91c0d5e 100644 --- a/wxPython/src/_bitmap.i +++ b/wxPython/src/_bitmap.i @@ -65,6 +65,8 @@ converted to a wx.Bitmap, so any image file format supported by "); +MustHaveApp(wxBitmap); + class wxBitmap : public wxGDIObject { public: @@ -306,6 +308,8 @@ A mask may be associated with a `wx.Bitmap`. It is used in `wx.MemoryDC` with a `wx.Bitmap` selected into it that contains a mask.", ""); +MustHaveApp(wxMask); + class wxMask : public wxObject { public: diff --git a/wxPython/src/_brush.i b/wxPython/src/_brush.i index 3545f9b975..ac34681356 100644 --- a/wxPython/src/_brush.i +++ b/wxPython/src/_brush.i @@ -33,6 +33,8 @@ a `wx.DC`. It has a colour and a style.", " :see: `wx.BrushList`, `wx.DC`, `wx.DC.SetBrush` "); +MustHaveApp(wxBrush); + class wxBrush : public wxGDIObject { public: DocCtorStr( diff --git a/wxPython/src/_button.i b/wxPython/src/_button.i index 2826dd75a8..cbba457512 100644 --- a/wxPython/src/_button.i +++ b/wxPython/src/_button.i @@ -58,6 +58,8 @@ Events :see: `wx.BitmapButton` "); +MustHaveApp(wxButton); + class wxButton : public wxControl { public: @@ -143,6 +145,8 @@ Events :see: `wx.Button`, `wx.Bitmap` "); +MustHaveApp(wxBitmapButton); + class wxBitmapButton : public wxButton { public: diff --git a/wxPython/src/_checkbox.i b/wxPython/src/_checkbox.i index 626c4f20fb..0d7800accb 100644 --- a/wxPython/src/_checkbox.i +++ b/wxPython/src/_checkbox.i @@ -78,6 +78,8 @@ Events +MustHaveApp(wxCheckBox); + class wxCheckBox : public wxControl { public: diff --git a/wxPython/src/_choice.i b/wxPython/src/_choice.i index 37492a18d6..6620524128 100644 --- a/wxPython/src/_choice.i +++ b/wxPython/src/_choice.i @@ -34,6 +34,8 @@ Events "); +MustHaveApp(wxChoice); + class wxChoice : public wxControlWithItems { public: diff --git a/wxPython/src/_cmndlgs.i b/wxPython/src/_cmndlgs.i index 1b1294e0ab..de1705f176 100644 --- a/wxPython/src/_cmndlgs.i +++ b/wxPython/src/_cmndlgs.i @@ -80,6 +80,8 @@ integer between 0 and 15. The default custom colours are all white.", ""); DocStr(wxColourDialog, "This class represents the colour chooser dialog.", ""); +MustHaveApp(wxColourDialog); + class wxColourDialog : public wxDialog { public: %pythonAppend wxColourDialog "self._setOORInfo(self)" @@ -113,6 +115,8 @@ Window Styles ==================== ========================================== "); +MustHaveApp(wxDirDialog); + class wxDirDialog : public wxDialog { public: %pythonAppend wxDirDialog "self._setOORInfo(self)" @@ -198,6 +202,8 @@ Window Styles +MustHaveApp(wxFileDialog); + class wxFileDialog : public wxDialog { public: %pythonAppend wxFileDialog "self._setOORInfo(self)" @@ -334,6 +340,8 @@ enum { wxCHOICEDLG_STYLE }; DocStr(wxMultiChoiceDialog, "A simple dialog with a multi selection listbox.", ""); +MustHaveApp(wxMultiChoiceDialog); + class wxMultiChoiceDialog : public wxDialog { public: @@ -374,6 +382,8 @@ integers.", ""); DocStr(wxSingleChoiceDialog, "A simple dialog with a single selection listbox.", ""); +MustHaveApp(wxSingleChoiceDialog); + class wxSingleChoiceDialog : public wxDialog { public: %pythonAppend wxSingleChoiceDialog "self._setOORInfo(self)" @@ -418,6 +428,8 @@ public: DocStr(wxTextEntryDialog, "A dialog with text control, [ok] and [cancel] buttons", ""); +MustHaveApp(wxTextEntryDialog); + class wxTextEntryDialog : public wxDialog { public: %pythonAppend wxTextEntryDialog "self._setOORInfo(self)" @@ -528,6 +540,8 @@ DocStr(wxFontDialog, :see: `wx.FontData` ", ""); +MustHaveApp(wxFontDialog); + class wxFontDialog : public wxDialog { public: %pythonAppend wxFontDialog "self._setOORInfo(self)" @@ -575,6 +589,8 @@ Window Styles "); +MustHaveApp(wxMessageDialog); + class wxMessageDialog : public wxDialog { public: %pythonAppend wxMessageDialog "self._setOORInfo(self)" @@ -625,6 +641,8 @@ Window Styles "); +MustHaveApp(wxProgressDialog); + class wxProgressDialog : public wxFrame { public: %pythonAppend wxProgressDialog "self._setOORInfo(self)" @@ -841,6 +859,8 @@ Window Styles ===================== ========================================= "); +MustHaveApp(wxFindReplaceDialog); + class wxFindReplaceDialog : public wxDialog { public: %pythonAppend wxFindReplaceDialog "self._setOORInfo(self)" diff --git a/wxPython/src/_combobox.i b/wxPython/src/_combobox.i index 8c964c1d92..079591dd81 100644 --- a/wxPython/src/_combobox.i +++ b/wxPython/src/_combobox.i @@ -56,6 +56,8 @@ Events +MustHaveApp(wxComboBox); + #ifdef __WXMSW__ class wxComboBox : public wxChoice #else diff --git a/wxPython/src/_control.i b/wxPython/src/_control.i index f681865741..555f535ad9 100644 --- a/wxPython/src/_control.i +++ b/wxPython/src/_control.i @@ -27,6 +27,8 @@ DocStr(wxControl, A control is generally a small window which processes user input and/or displays one or more item of data.", ""); +MustHaveApp(wxControl); + class wxControl : public wxWindow { public: diff --git a/wxPython/src/_core_api.i b/wxPython/src/_core_api.i index 0cb17d7e62..8ebca68b4d 100644 --- a/wxPython/src/_core_api.i +++ b/wxPython/src/_core_api.i @@ -206,7 +206,9 @@ static wxPyCoreAPI API = { wxPyCBInputStream_create, wxPyInstance_Check, - wxPySwigInstance_Check + wxPySwigInstance_Check, + + wxPyCheckForApp }; diff --git a/wxPython/src/_cshelp.i b/wxPython/src/_cshelp.i index 30a9ad44fd..31944bf0a5 100644 --- a/wxPython/src/_cshelp.i +++ b/wxPython/src/_cshelp.i @@ -133,6 +133,8 @@ There are a couple of ways to invoke this behaviour implicitly: :see: `wx.ContextHelpButton` ", ""); +MustHaveApp(wxContextHelp); + class wxContextHelp : public wxObject { public: DocCtorStr( @@ -178,6 +180,8 @@ similar buttons. :see: `wx.ContextHelp`, `wx.ContextHelpButton` ", ""); +MustHaveApp(wxContextHelpButton); + class wxContextHelpButton : public wxBitmapButton { public: %pythonAppend wxContextHelpButton "self._setOORInfo(self)" diff --git a/wxPython/src/_cursor.i b/wxPython/src/_cursor.i index 6b07a0ad67..ecb8a7a9ce 100644 --- a/wxPython/src/_cursor.i +++ b/wxPython/src/_cursor.i @@ -61,6 +61,8 @@ Stock Cursor IDs "); +MustHaveApp(wxCursor); + class wxCursor : public wxGDIObject { public: diff --git a/wxPython/src/_dc.i b/wxPython/src/_dc.i index 70642a4327..0032639fe2 100644 --- a/wxPython/src/_dc.i +++ b/wxPython/src/_dc.i @@ -626,6 +626,8 @@ static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) { //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxMemoryDC); + class wxMemoryDC : public wxDC { public: wxMemoryDC(); @@ -643,6 +645,8 @@ public: %} +MustHaveApp(wxBufferedDC); + class wxBufferedDC : public wxMemoryDC { public: @@ -680,6 +684,7 @@ public: +MustHaveApp(wxBufferedPaintDC); // Creates a double buffered wxPaintDC, optionally allowing the // user to specify their own buffer to use. @@ -696,6 +701,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxScreenDC); + class wxScreenDC : public wxDC { public: wxScreenDC(); @@ -708,6 +715,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxClientDC); + class wxClientDC : public wxDC { public: wxClientDC(wxWindow* win); @@ -716,6 +725,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxPaintDC); + class wxPaintDC : public wxDC { public: wxPaintDC(wxWindow* win); @@ -724,6 +735,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxWindowDC); + class wxWindowDC : public wxDC { public: wxWindowDC(wxWindow* win); @@ -732,6 +745,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxMirrorDC); + class wxMirrorDC : public wxDC { public: @@ -751,6 +766,8 @@ public: #include %} +MustHaveApp(wxPostScriptDC); + class wxPostScriptDC : public wxDC { public: wxPostScriptDC(const wxPrintData& printData); @@ -769,6 +786,10 @@ public: %newgroup +MustHaveApp(wxMetaFile); +MustHaveApp(wxMetaFileDC); + + #if defined(__WXMSW__) || defined(__WXMAC__) %{ @@ -843,6 +864,8 @@ public: //--------------------------------------------------------------------------- +MustHaveApp(wxPrinterDC); + #if defined(__WXMSW__) || defined(__WXMAC__) class wxPrinterDC : public wxDC { diff --git a/wxPython/src/_defs.i b/wxPython/src/_defs.i index e384cee753..2e0aa6c8a6 100644 --- a/wxPython/src/_defs.i +++ b/wxPython/src/_defs.i @@ -11,17 +11,40 @@ ///////////////////////////////////////////////////////////////////////////// +//--------------------------------------------------------------------------- // Globally turn on the autodoc feature + %feature("autodoc", "1"); // 0 == no param types, 1 == show param types +//--------------------------------------------------------------------------- +// Tell SWIG to wrap all the wrappers with our thread protection by default + +%exception { + PyThreadState* __tstate = wxPyBeginAllowThreads(); + $action + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) SWIG_fail; +} + + +// This one can be used to add a check for an existing wxApp before the real +// work is done. An exception is raised if there isn't one. +%define MustHaveApp(name) + %exception name { + if (!wxPyCheckForApp()) SWIG_fail; + PyThreadState* __tstate = wxPyBeginAllowThreads(); + $action + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) SWIG_fail; + } +%enddef + + + //--------------------------------------------------------------------------- // some type definitions to simplify things for SWIG -// typedef int wxWindowID; -// typedef int wxCoord; -// typedef int wxInt32; -// typedef unsigned int wxUint32; typedef int wxEventType; typedef unsigned int size_t; typedef unsigned int time_t; @@ -31,10 +54,6 @@ typedef unsigned char byte; #define wxCoord int #define wxInt32 int #define wxUint32 unsigned int -//#define wxEventType int -//#define size_t unsigned int -//#define time_t unsigned int -//#define byte unsigned char //---------------------------------------------------------------------- diff --git a/wxPython/src/_dirctrl.i b/wxPython/src/_dirctrl.i index 08921efef1..b33d701442 100644 --- a/wxPython/src/_dirctrl.i +++ b/wxPython/src/_dirctrl.i @@ -54,6 +54,8 @@ public: +MustHaveApp(wxGenericDirCtrl); + class wxGenericDirCtrl: public wxControl { public: @@ -136,6 +138,8 @@ leaf), done is set to True. +MustHaveApp(wxDirFilterListCtrl); + class wxDirFilterListCtrl: public wxChoice { public: diff --git a/wxPython/src/_dragimg.i b/wxPython/src/_dragimg.i index 3213480036..fdbbb93d1f 100644 --- a/wxPython/src/_dragimg.i +++ b/wxPython/src/_dragimg.i @@ -24,6 +24,8 @@ +MustHaveApp(wxGenericDragImage); + %name (DragImage) class wxGenericDragImage : public wxObject { public: diff --git a/wxPython/src/_font.i b/wxPython/src/_font.i index 6045d4c4a2..c1d8805762 100644 --- a/wxPython/src/_font.i +++ b/wxPython/src/_font.i @@ -430,6 +430,10 @@ public: %newgroup +MustHaveApp(wxFont); +MustHaveApp(wxFont::GetDefaultEncoding); +MustHaveApp(wxFont::SetDefaultEncoding); + class wxFont : public wxGDIObject { public: %pythonPrepend wxFont "if kwargs.has_key('faceName'): kwargs['face'] = kwargs['faceName'];del kwargs['faceName']" @@ -533,6 +537,8 @@ IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEnc %} +MustHaveApp(wxPyFontEnumerator); + %name(FontEnumerator) class wxPyFontEnumerator { public: %pythonAppend wxPyFontEnumerator "self._setCallbackInfo(self, FontEnumerator, 0)" diff --git a/wxPython/src/_functions.i b/wxPython/src/_functions.i index 4e7423d506..b562214ae4 100644 --- a/wxPython/src/_functions.i +++ b/wxPython/src/_functions.i @@ -27,11 +27,15 @@ long wxNewId(); void wxRegisterId(long id); long wxGetCurrentId(); +MustHaveApp(wxBell); void wxBell(); + +MustHaveApp(wxEndBusyCursor); void wxEndBusyCursor(); long wxGetElapsedTime(bool resetTimer = True); +MustHaveApp(wxGetMousePosition); DocDeclA( void, wxGetMousePosition(int* OUTPUT, int* OUTPUT), "GetMousePosition() -> (x,y)"); @@ -63,6 +67,7 @@ enum wxShutdownFlags }; // Shutdown or reboot the PC +MustHaveApp(wxShutdown); bool wxShutdown(wxShutdownFlags wFlags); @@ -88,6 +93,7 @@ void wxTrap(); // Dialog Functions +MustHaveApp(wxFileSelector); wxString wxFileSelector(const wxString& message = wxPyFileSelectorPromptStr, const wxString& default_path = wxPyEmptyString, const wxString& default_filename = wxPyEmptyString, @@ -101,24 +107,28 @@ wxString wxFileSelector(const wxString& message = wxPyFileSelectorPromptStr, // Ask for filename to load +MustHaveApp(wxLoadFileSelector); wxString wxLoadFileSelector(const wxString& what, const wxString& extension, const wxString& default_name = wxPyEmptyString, wxWindow *parent = NULL); // Ask for filename to save +MustHaveApp(wxSaveFileSelector); wxString wxSaveFileSelector(const wxString& what, const wxString& extension, const wxString& default_name = wxPyEmptyString, wxWindow *parent = NULL); +MustHaveApp(wxDirSelector); wxString wxDirSelector(const wxString& message = wxPyDirSelectorPromptStr, const wxString& defaultPath = wxPyEmptyString, long style = wxDD_DEFAULT_STYLE, const wxPoint& pos = wxDefaultPosition, wxWindow *parent = NULL); +MustHaveApp(wxGetTextFromUser); wxString wxGetTextFromUser(const wxString& message, const wxString& caption = wxPyEmptyString, const wxString& default_value = wxPyEmptyString, @@ -126,6 +136,7 @@ wxString wxGetTextFromUser(const wxString& message, int x = -1, int y = -1, bool centre = True); +MustHaveApp(wxGetPasswordFromUser); wxString wxGetPasswordFromUser(const wxString& message, const wxString& caption = wxPyEmptyString, const wxString& default_value = wxPyEmptyString, @@ -140,6 +151,7 @@ wxString wxGetPasswordFromUser(const wxString& message, // bool centre = True, int width=150, int height=200); +MustHaveApp(wxGetSingleChoice); wxString wxGetSingleChoice(const wxString& message, const wxString& caption, int choices, wxString* choices_array, wxWindow *parent = NULL, @@ -147,6 +159,7 @@ wxString wxGetSingleChoice(const wxString& message, const wxString& caption, bool centre = True, int width=150, int height=200); +MustHaveApp(wxGetSingleChoiceIndex); int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption, int choices, wxString* choices_array, wxWindow *parent = NULL, @@ -155,12 +168,14 @@ int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption, int width=150, int height=200); +MustHaveApp(wxMessageBox); int wxMessageBox(const wxString& message, const wxString& caption = wxPyEmptyString, int style = wxOK | wxCENTRE, wxWindow *parent = NULL, int x = -1, int y = -1); +MustHaveApp(wxGetNumberFromUser); long wxGetNumberFromUser(const wxString& message, const wxString& prompt, const wxString& caption, @@ -171,38 +186,60 @@ long wxGetNumberFromUser(const wxString& message, // GDI Functions +MustHaveApp(wxColourDisplay); bool wxColourDisplay(); +MustHaveApp(wxDisplayDepth); int wxDisplayDepth(); + +MustHaveApp(wxGetDisplayDepth); int wxGetDisplayDepth(); +MustHaveApp(wxDisplaySize); DocDeclA( void, wxDisplaySize(int* OUTPUT, int* OUTPUT), "DisplaySize() -> (width, height)"); + +MustHaveApp(wxGetDisplaySize); wxSize wxGetDisplaySize(); +MustHaveApp(wxDisplaySizeMM); DocDeclA( void, wxDisplaySizeMM(int* OUTPUT, int* OUTPUT), "DisplaySizeMM() -> (width, height)"); + +MustHaveApp(wxGetDisplaySizeMM); wxSize wxGetDisplaySizeMM(); +MustHaveApp(wxClientDisplayRect); DocDeclA( void, wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT), "ClientDisplayRect() -> (x, y, width, height)"); + +MustHaveApp(wxGetClientDisplayRect); wxRect wxGetClientDisplayRect(); + +MustHaveApp(wxSetCursor); void wxSetCursor(wxCursor& cursor); // Miscellaneous functions +MustHaveApp(wxBeginBusyCursor); void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR); + +MustHaveApp(wxGetActiveWindow); wxWindow * wxGetActiveWindow(); +MustHaveApp(wxGenericFindWindowAtPoint); wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt); + +MustHaveApp(wxFindWindowAtPoint); wxWindow* wxFindWindowAtPoint(const wxPoint& pt); +MustHaveApp(wxGetTopLevelParent); wxWindow* wxGetTopLevelParent(wxWindow *win); //bool wxSpawnBrowser(wxWindow *parent, wxString href); @@ -210,6 +247,7 @@ wxWindow* wxGetTopLevelParent(wxWindow *win); +MustHaveApp(wxGetKeyState); DocDeclStr( bool , wxGetKeyState(wxKeyCode key), "Get the state of a key (true if pressed or toggled on, false if not.) @@ -221,6 +259,8 @@ toggle keys. On some platforms those may be the only keys that work. //--------------------------------------------------------------------------- +MustHaveApp(wxWakeUpMainThread); + #if defined(__WXMSW__) || defined(__WXMAC__) void wxWakeUpMainThread(); #else @@ -229,10 +269,15 @@ void wxWakeUpMainThread(); %} #endif + +MustHaveApp(wxMutexGuiEnter); void wxMutexGuiEnter(); + +MustHaveApp(wxMutexGuiLeave); void wxMutexGuiLeave(); +MustHaveApp(wxMutexGuiLocker); class wxMutexGuiLocker { public: wxMutexGuiLocker(); @@ -240,6 +285,7 @@ public: }; +MustHaveApp(wxThread); %inline %{ bool wxThread_IsMain() { #ifdef WXP_WITH_THREAD diff --git a/wxPython/src/_gauge.i b/wxPython/src/_gauge.i index 6197cde3d4..0aad4c78f5 100644 --- a/wxPython/src/_gauge.i +++ b/wxPython/src/_gauge.i @@ -29,6 +29,8 @@ enum { //--------------------------------------------------------------------------- +MustHaveApp(wxGauge); + class wxGauge : public wxControl { public: %pythonAppend wxGauge "self._setOORInfo(self)" diff --git a/wxPython/src/_gdicmn.i b/wxPython/src/_gdicmn.i index 860d306be4..399b5749f1 100644 --- a/wxPython/src/_gdicmn.i +++ b/wxPython/src/_gdicmn.i @@ -576,6 +576,8 @@ bottom, otherwise it is moved to the left or top respectively.", "", }; +MustHaveApp(wxIntersectRect); + DocAStr(wxIntersectRect, "IntersectRect(Rect r1, Rect r2) -> Rect", "Calculate and return the intersection of r1 and r2.", ""); diff --git a/wxPython/src/_gdiobj.i b/wxPython/src/_gdiobj.i index 5eee9400d1..a334c9f2f1 100644 --- a/wxPython/src/_gdiobj.i +++ b/wxPython/src/_gdiobj.i @@ -15,6 +15,8 @@ //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxGDIObject); + class wxGDIObject : public wxObject { public: wxGDIObject(); diff --git a/wxPython/src/_icon.i b/wxPython/src/_icon.i index 6a69d79f41..f43e09910b 100644 --- a/wxPython/src/_icon.i +++ b/wxPython/src/_icon.i @@ -20,6 +20,8 @@ //--------------------------------------------------------------------------- +MustHaveApp(wxIcon); + class wxIcon : public wxGDIObject { public: diff --git a/wxPython/src/_image.i b/wxPython/src/_image.i index 700cfdc938..d248f1a0fa 100644 --- a/wxPython/src/_image.i +++ b/wxPython/src/_image.i @@ -90,7 +90,8 @@ public: else return new wxImage; } - + + MustHaveApp(wxImage(const wxBitmap &bitmap)); %name(ImageFromBitmap) wxImage(const wxBitmap &bitmap) { return new wxImage(bitmap.ConvertToImage()); } @@ -312,6 +313,9 @@ success flag and rgb values.", ""); static wxString GetImageExtWildcard(); +MustHaveApp(ConvertToBitmap); +MustHaveApp(ConvertToMonoBitmap); + %extend { wxBitmap ConvertToBitmap() { wxBitmap bitmap(*self); diff --git a/wxPython/src/_imaglist.i b/wxPython/src/_imaglist.i index 87962cdbab..98625e782f 100644 --- a/wxPython/src/_imaglist.i +++ b/wxPython/src/_imaglist.i @@ -33,6 +33,8 @@ enum { }; +MustHaveApp(wxImageList); + // wxImageList is used for wxListCtrl, wxTreeCtrl. These controls refer to // images for their items by an index into an image list. diff --git a/wxPython/src/_joystick.i b/wxPython/src/_joystick.i index 24b523e145..add72d6b92 100644 --- a/wxPython/src/_joystick.i +++ b/wxPython/src/_joystick.i @@ -103,6 +103,8 @@ public: %} +MustHaveApp(wxJoystick); + class wxJoystick /* : public wxObject */ { public: diff --git a/wxPython/src/_listbox.i b/wxPython/src/_listbox.i index d2144006ce..f17f096ac1 100644 --- a/wxPython/src/_listbox.i +++ b/wxPython/src/_listbox.i @@ -26,6 +26,8 @@ MAKE_CONST_WXSTRING(ListBoxNameStr); //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxListBox); + class wxListBox : public wxControlWithItems { public: @@ -137,6 +139,8 @@ public: %newgroup +MustHaveApp(wxCheckListBox); + // wxCheckListBox: a listbox whose items may be checked class wxCheckListBox : public wxListBox { diff --git a/wxPython/src/_listctrl.i b/wxPython/src/_listctrl.i index f0b4ac39c5..c969897f71 100644 --- a/wxPython/src/_listctrl.i +++ b/wxPython/src/_listctrl.i @@ -17,8 +17,8 @@ %{ #include - %} + MAKE_CONST_WXSTRING2(ListCtrlNameStr, _T("wxListCtrl")); //--------------------------------------------------------------------------- @@ -398,6 +398,8 @@ IMP_PYCALLBACK_LISTATTR_LONG(wxPyListCtrl, wxListCtrl, OnGetItemAttr); +MustHaveApp(wxPyListCtrl); + %name(ListCtrl)class wxPyListCtrl : public wxControl { public: @@ -778,6 +780,8 @@ details in the second return value (see wxLIST_HITTEST_... flags.)", ""); %newgroup +MustHaveApp(wxListView); + // wxListView: a class which provides a little better API for list control class wxListView : public wxPyListCtrl { diff --git a/wxPython/src/_mdi.i b/wxPython/src/_mdi.i index daf66d111a..355c6cf1f8 100644 --- a/wxPython/src/_mdi.i +++ b/wxPython/src/_mdi.i @@ -33,6 +33,8 @@ +MustHaveApp(wxMDIParentFrame); + class wxMDIParentFrame : public wxFrame { public: %pythonAppend wxMDIParentFrame "self._setOORInfo(self)" @@ -78,6 +80,8 @@ public: //--------------------------------------------------------------------------- +MustHaveApp(wxMDIChildFrame); + class wxMDIChildFrame : public wxFrame { public: %pythonAppend wxMDIChildFrame "self._setOORInfo(self)" @@ -109,6 +113,8 @@ public: //--------------------------------------------------------------------------- +MustHaveApp(wxMDIClientWindow); + class wxMDIClientWindow : public wxWindow { public: %pythonAppend wxMDIClientWindow "self._setOORInfo(self)" diff --git a/wxPython/src/_menu.i b/wxPython/src/_menu.i index af7a940d08..59fb473645 100644 --- a/wxPython/src/_menu.i +++ b/wxPython/src/_menu.i @@ -17,6 +17,8 @@ %newgroup +MustHaveApp(wxMenu); + class wxMenu : public wxEvtHandler { public: @@ -203,6 +205,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxMenuBar); + class wxMenuBar : public wxWindow { public: diff --git a/wxPython/src/_misc.i b/wxPython/src/_misc.i index a1f6e305f1..5ae57e1f9c 100644 --- a/wxPython/src/_misc.i +++ b/wxPython/src/_misc.i @@ -19,6 +19,9 @@ #ifndef __WXX11__ + +MustHaveApp(wxToolTip); + class wxToolTip : public wxObject { public: wxToolTip(const wxString &tip); @@ -35,6 +38,8 @@ public: //--------------------------------------------------------------------------- +MustHaveApp(wxCaret); + class wxCaret { public: wxCaret(wxWindow* window, const wxSize& size); @@ -79,6 +84,8 @@ public: //--------------------------------------------------------------------------- +MustHaveApp(wxBusyCursor); + class wxBusyCursor { public: wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR); @@ -87,6 +94,8 @@ public: //--------------------------------------------------------------------------- +MustHaveApp(wxWindowDisabler); + class wxWindowDisabler { public: wxWindowDisabler(wxWindow *winToSkip = NULL); @@ -95,6 +104,8 @@ public: //--------------------------------------------------------------------------- +MustHaveApp(wxBusyInfo); + class wxBusyInfo : public wxObject { public: wxBusyInfo(const wxString& message); diff --git a/wxPython/src/_notebook.i b/wxPython/src/_notebook.i index 81c854cc62..853ffe03b3 100644 --- a/wxPython/src/_notebook.i +++ b/wxPython/src/_notebook.i @@ -22,6 +22,8 @@ MAKE_CONST_WXSTRING(NOTEBOOK_NAME); // TODO: Virtualize this class so other book controls can be derived in Python +MustHaveApp(wxBookCtrl); + // Common base class for wxList/Tree/Notebook class wxBookCtrl : public wxControl { @@ -160,6 +162,8 @@ enum { +MustHaveApp(wxNotebook); + class wxNotebook : public wxBookCtrl { public: %pythonAppend wxNotebook "self._setOORInfo(self)" @@ -286,6 +290,8 @@ enum +MustHaveApp(wxListbook); + // wxListCtrl and wxNotebook combination class wxListbook : public wxBookCtrl { diff --git a/wxPython/src/_palette.i b/wxPython/src/_palette.i index e2fdbe4b69..c83602f393 100644 --- a/wxPython/src/_palette.i +++ b/wxPython/src/_palette.i @@ -19,6 +19,8 @@ //--------------------------------------------------------------------------- +MustHaveApp(wxPalette); + class wxPalette : public wxGDIObject { public: wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); diff --git a/wxPython/src/_panel.i b/wxPython/src/_panel.i index bee9ca00fd..180bd8c8ed 100644 --- a/wxPython/src/_panel.i +++ b/wxPython/src/_panel.i @@ -22,6 +22,8 @@ %newgroup +MustHaveApp(wxPanel); + class wxPanel : public wxWindow { public: @@ -57,6 +59,8 @@ public: // derive from it and wxPanel. But what to do about wxGTK where this // is not True? +MustHaveApp(wxScrolledWindow); + class wxScrolledWindow : public wxPanel { public: diff --git a/wxPython/src/_pen.i b/wxPython/src/_pen.i index cf9d76b28c..5f9f7a278e 100644 --- a/wxPython/src/_pen.i +++ b/wxPython/src/_pen.i @@ -29,6 +29,8 @@ %newgroup +MustHaveApp(wxPen); + class wxPen : public wxGDIObject { public: wxPen(wxColour& colour, int width=1, int style=wxSOLID); diff --git a/wxPython/src/_popupwin.i b/wxPython/src/_popupwin.i index 38ae99eda9..706fbccab0 100644 --- a/wxPython/src/_popupwin.i +++ b/wxPython/src/_popupwin.i @@ -23,9 +23,12 @@ #ifndef __WXMAC__ %newgroup; +MustHaveApp(wxPopupWindow); // wxPopupWindow: a special kind of top level window used for popup menus, // combobox popups and such. +MustHaveApp(wxPopupWindow); + class wxPopupWindow : public wxWindow { public: %pythonAppend wxPopupWindow "self._setOORInfo(self)" @@ -73,9 +76,11 @@ IMP_PYCALLBACK_BOOL_(wxPyPopupTransientWindow, wxPopupTransientWindow, CanDismis %} +MustHaveApp(wxPyPopupTransientWindow); // wxPopupTransientWindow: a wxPopupWindow which disappears automatically // when the user clicks mouse outside it or if it loses focus in any other way + %name(PopupTransientWindow) class wxPyPopupTransientWindow : public wxPopupWindow { public: diff --git a/wxPython/src/_printfw.i b/wxPython/src/_printfw.i index e81578d220..78bb05e19d 100644 --- a/wxPython/src/_printfw.i +++ b/wxPython/src/_printfw.i @@ -149,6 +149,8 @@ public: +MustHaveApp(wxPageSetupDialog); + class wxPageSetupDialog : public wxDialog { public: %pythonAppend wxPageSetupDialog "self._setOORInfo(self)" @@ -217,6 +219,8 @@ public: }; +MustHaveApp(wxPrintDialog); + class wxPrintDialog : public wxDialog { public: %pythonAppend wxPrintDialog "self._setOORInfo(self)" @@ -243,6 +247,8 @@ enum wxPrinterError }; +MustHaveApp(wxPrinter); + class wxPrinter : public wxObject { public: wxPrinter(wxPrintDialogData* data = NULL); @@ -323,6 +329,8 @@ IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage); %} +MustHaveApp(wxPyPrintout); + // Now define the custom class for SWIGging %name(Printout) class wxPyPrintout : public wxObject { public: @@ -377,6 +385,8 @@ public: +MustHaveApp(wxPreviewCanvas); + class wxPreviewCanvas: public wxScrolledWindow { public: @@ -391,6 +401,8 @@ public: }; +MustHaveApp(wxPreviewFrame); + class wxPreviewFrame : public wxFrame { public: %pythonAppend wxPreviewFrame "self._setOORInfo(self)" @@ -430,6 +442,8 @@ enum { wxID_PREVIEW_GOTO }; +MustHaveApp(wxPreviewControlBar); + class wxPreviewControlBar: public wxPanel { public: @@ -458,6 +472,8 @@ public: //--------------------------------------------------------------------------- +MustHaveApp(wxPrintPreview); + class wxPrintPreview : public wxObject { public: %nokwargs wxPrintPreview; @@ -592,6 +608,8 @@ IMP_PYCALLBACK_VOID_ (wxPyPrintPreview, wxPrintPreview, DetermineScaling) %} +MustHaveApp(wxPyPrintPreview); + class wxPyPrintPreview : public wxPrintPreview { public: @@ -650,6 +668,8 @@ IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar); %} +MustHaveApp(wxPyPreviewFrame); + class wxPyPreviewFrame : public wxPreviewFrame { public: @@ -704,6 +724,8 @@ IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomContr %} +MustHaveApp(wxPyPreviewControlBar); + class wxPyPreviewControlBar : public wxPreviewControlBar { public: diff --git a/wxPython/src/_process.i b/wxPython/src/_process.i index 642a03134e..dffe60ec6f 100644 --- a/wxPython/src/_process.i +++ b/wxPython/src/_process.i @@ -159,6 +159,8 @@ enum }; +MustHaveApp(wxExecute); + long wxExecute(const wxString& command, int flags = wxEXEC_ASYNC, wxPyProcess *process = NULL); diff --git a/wxPython/src/_pycontrol.i b/wxPython/src/_pycontrol.i index 205dab0e90..eb2a01b87f 100644 --- a/wxPython/src/_pycontrol.i +++ b/wxPython/src/_pycontrol.i @@ -99,6 +99,7 @@ IMP_PYCALLBACK_VIZATTR_(wxPyControl, wxControl, GetDefaultAttributes); %} // And now the one for SWIG to see +MustHaveApp(wxPyControl); class wxPyControl : public wxControl { public: diff --git a/wxPython/src/_pywindows.i b/wxPython/src/_pywindows.i index 6a9ad8862f..4cc0976bd3 100644 --- a/wxPython/src/_pywindows.i +++ b/wxPython/src/_pywindows.i @@ -129,6 +129,7 @@ IMP_PYCALLBACK_VIZATTR_(wxPyWindow, wxWindow, GetDefaultAttributes); %} // And now the one for SWIG to see +MustHaveApp(wxPyWindow); class wxPyWindow : public wxWindow { public: @@ -273,6 +274,7 @@ IMP_PYCALLBACK_VIZATTR_(wxPyPanel, wxPanel, GetDefaultAttributes); %} // And now the one for SWIG to see +MustHaveApp(wxPyPanel); class wxPyPanel : public wxPanel { public: @@ -409,6 +411,7 @@ IMP_PYCALLBACK_VIZATTR_(wxPyScrolledWindow, wxScrolledWindow, GetDefaultAttribut %} // And now the one for SWIG to see +MustHaveApp(wxPyScrolledWindow); class wxPyScrolledWindow : public wxScrolledWindow { public: diff --git a/wxPython/src/_radio.i b/wxPython/src/_radio.i index c70ce8c11c..9a2551def1 100644 --- a/wxPython/src/_radio.i +++ b/wxPython/src/_radio.i @@ -21,6 +21,8 @@ MAKE_CONST_WXSTRING(RadioButtonNameStr); //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxRadioBox); + class wxRadioBox : public wxControl { public: @@ -94,6 +96,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxRadioButton); + class wxRadioButton : public wxControl { public: diff --git a/wxPython/src/_region.i b/wxPython/src/_region.i index 55a9cc4834..29f18cb677 100644 --- a/wxPython/src/_region.i +++ b/wxPython/src/_region.i @@ -41,6 +41,8 @@ enum wxRegionContain +MustHaveApp(wxRegion); + class wxRegion : public wxGDIObject { public: wxRegion(wxCoord x=0, wxCoord y=0, wxCoord width=0, wxCoord height=0); @@ -108,6 +110,8 @@ public: +MustHaveApp(wxRegionIterator); + class wxRegionIterator : public wxObject { public: wxRegionIterator(const wxRegion& region); diff --git a/wxPython/src/_sashwin.i b/wxPython/src/_sashwin.i index eb2d828ac9..df6c53ebbf 100644 --- a/wxPython/src/_sashwin.i +++ b/wxPython/src/_sashwin.i @@ -48,6 +48,8 @@ enum wxSashEdgePosition { // wxSashWindow allows any of its edges to have a sash which can be dragged // to resize the window. The actual content window will be created as a child // of wxSashWindow. +MustHaveApp(wxSashWindow); + class wxSashWindow: public wxWindow { public: @@ -234,6 +236,8 @@ public: // This is window that can remember alignment/orientation, does its own layout, // and can provide sashes too. Useful for implementing docked windows with sashes in // an IDE-style interface. +MustHaveApp(wxSashLayoutWindow); + class wxSashLayoutWindow: public wxSashWindow { public: diff --git a/wxPython/src/_scrolbar.i b/wxPython/src/_scrolbar.i index 2cdd183639..a4c01b1c92 100644 --- a/wxPython/src/_scrolbar.i +++ b/wxPython/src/_scrolbar.i @@ -20,6 +20,8 @@ MAKE_CONST_WXSTRING(ScrollBarNameStr); //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxScrollBar); + class wxScrollBar : public wxControl { public: %pythonAppend wxScrollBar "self._setOORInfo(self)" diff --git a/wxPython/src/_settings.i b/wxPython/src/_settings.i index 0525c88310..38720a9537 100644 --- a/wxPython/src/_settings.i +++ b/wxPython/src/_settings.i @@ -148,6 +148,12 @@ enum wxSystemScreenType //--------------------------------------------------------------------------- +MustHaveApp(wxSystemSettings::GetColour); +MustHaveApp(wxSystemSettings::GetFont); +MustHaveApp(wxSystemSettings::GetMetric); +MustHaveApp(wxSystemSettings::HasFeature); +MustHaveApp(wxSystemSettings::GetScreenType); +MustHaveApp(wxSystemSettings::SetScreenType); class wxSystemSettings { diff --git a/wxPython/src/_slider.i b/wxPython/src/_slider.i index 7ecf040a2e..17d51db2e6 100644 --- a/wxPython/src/_slider.i +++ b/wxPython/src/_slider.i @@ -25,6 +25,8 @@ MAKE_CONST_WXSTRING(SliderNameStr); //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxSlider); + class wxSlider : public wxControl { public: %pythonPrepend wxSlider "if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'];del kwargs['point']" diff --git a/wxPython/src/_sound.i b/wxPython/src/_sound.i index 2339bb2cec..ad1e0ea9a8 100644 --- a/wxPython/src/_sound.i +++ b/wxPython/src/_sound.i @@ -71,6 +71,10 @@ public: +MustHaveApp(wxSound); +MustHaveApp(wxSound::Play); +MustHaveApp(wxSound::Stop); + class wxSound /*: public wxObject*/ { public: diff --git a/wxPython/src/_spin.i b/wxPython/src/_spin.i index 29b9ca22ab..7f9f33a1da 100644 --- a/wxPython/src/_spin.i +++ b/wxPython/src/_spin.i @@ -38,6 +38,7 @@ enum { // wxSP_VERTICAL: vertical spin button (the default) // wxSP_ARROW_KEYS: arrow keys increment/decrement value // wxSP_WRAP: value wraps at either end +MustHaveApp(wxSpinButton); class wxSpinButton : public wxControl { public: @@ -80,6 +81,8 @@ public: // a spin ctrl is a text control with a spin button which is usually used to // prompt the user for a numeric input +MustHaveApp(wxSpinCtrl); + class wxSpinCtrl : public wxControl { public: diff --git a/wxPython/src/_splitter.i b/wxPython/src/_splitter.i index 962e8e0ad9..af4516454a 100644 --- a/wxPython/src/_splitter.i +++ b/wxPython/src/_splitter.i @@ -104,6 +104,8 @@ Events +MustHaveApp(wxSplitterWindow); + class wxSplitterWindow: public wxWindow { public: diff --git a/wxPython/src/_statctrls.i b/wxPython/src/_statctrls.i index c407a4d799..f2f726e60b 100644 --- a/wxPython/src/_statctrls.i +++ b/wxPython/src/_statctrls.i @@ -23,6 +23,8 @@ MAKE_CONST_WXSTRING(StaticTextNameStr); //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxStaticBox); + class wxStaticBox : public wxControl { public: %pythonAppend wxStaticBox "self._setOORInfo(self)" @@ -50,6 +52,8 @@ public: %newgroup +MustHaveApp(wxStaticLine); + class wxStaticLine : public wxControl { public: %pythonAppend wxStaticLine "self._setOORInfo(self)" @@ -82,6 +86,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxStaticText); + class wxStaticText : public wxControl { public: %pythonAppend wxStaticText "self._setOORInfo(self)" @@ -107,6 +113,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxStaticBitmap); + class wxStaticBitmap : public wxControl { public: %pythonAppend wxStaticBitmap "self._setOORInfo(self)" diff --git a/wxPython/src/_statusbar.i b/wxPython/src/_statusbar.i index e3a0d66c3b..4eb81820a0 100644 --- a/wxPython/src/_statusbar.i +++ b/wxPython/src/_statusbar.i @@ -24,6 +24,7 @@ // wxStatusBar: a window near the bottom of the frame used for status info +MustHaveApp(wxStatusBar); class wxStatusBar : public wxWindow { public: diff --git a/wxPython/src/_stockobjs.i b/wxPython/src/_stockobjs.i index 12aa013492..885b0775f0 100644 --- a/wxPython/src/_stockobjs.i +++ b/wxPython/src/_stockobjs.i @@ -99,6 +99,8 @@ public: //--------------------------------------------------------------------------- +MustHaveApp(wxColourDatabase); + class wxColourDatabase : public wxObject { public: wxColourDatabase(); diff --git a/wxPython/src/_taskbar.i b/wxPython/src/_taskbar.i index 5d4c54bf88..3fbbbc660c 100644 --- a/wxPython/src/_taskbar.i +++ b/wxPython/src/_taskbar.i @@ -56,6 +56,8 @@ enum { +MustHaveApp(wxTaskBarIcon); + class wxTaskBarIcon : public wxEvtHandler { public: diff --git a/wxPython/src/_textctrl.i b/wxPython/src/_textctrl.i index 4f8e3b616f..7924ad77ca 100644 --- a/wxPython/src/_textctrl.i +++ b/wxPython/src/_textctrl.i @@ -161,6 +161,7 @@ public: // wxTextCtrl: a single or multiple line text zone where user can enter and // edit text +MustHaveApp(wxTextCtrl); class wxTextCtrl : public wxControl { public: diff --git a/wxPython/src/_tglbtn.i b/wxPython/src/_tglbtn.i index 9fde315a8e..d3947cc5e3 100644 --- a/wxPython/src/_tglbtn.i +++ b/wxPython/src/_tglbtn.i @@ -50,6 +50,8 @@ public: } +MustHaveApp(wxToggleButton); + class wxToggleButton : public wxControl { public: diff --git a/wxPython/src/_timer.i b/wxPython/src/_timer.i index 1042c7f52f..e09e7509d0 100644 --- a/wxPython/src/_timer.i +++ b/wxPython/src/_timer.i @@ -53,6 +53,8 @@ void wxPyTimer::base_Notify() { +MustHaveApp(wxPyTimer); + %name(Timer) class wxPyTimer : public wxEvtHandler { public: @@ -130,6 +132,7 @@ public: // wxTimerRunner: starts the timer in its ctor, stops in the dtor +MustHaveApp(wxTimerRunner); class wxTimerRunner { public: diff --git a/wxPython/src/_tipdlg.i b/wxPython/src/_tipdlg.i index ef7d617e02..cd839ccca8 100644 --- a/wxPython/src/_tipdlg.i +++ b/wxPython/src/_tipdlg.i @@ -81,11 +81,13 @@ public: // not, the dialog on startup depending on its value, not this class). // // The function returns True if this checkbox is checked, False otherwise. +MustHaveApp(wxShowTip); bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = True); // a function which returns an implementation of wxTipProvider using the // specified text file as the source of tips (each line is a tip). %newobject wxCreateFileTipProvider; +MustHaveApp(wxCreateFileTipProvider); wxTipProvider* wxCreateFileTipProvider(const wxString& filename, size_t currentTip); diff --git a/wxPython/src/_tipwin.i b/wxPython/src/_tipwin.i index 1cb3e5cc5e..15e52ead46 100644 --- a/wxPython/src/_tipwin.i +++ b/wxPython/src/_tipwin.i @@ -23,6 +23,8 @@ %newgroup; +MustHaveApp(wxTipWindow); + class wxTipWindow : #ifndef __WXMAC__ public wxPyPopupTransientWindow diff --git a/wxPython/src/_toolbar.i b/wxPython/src/_toolbar.i index 16db24619b..0c9ad075ce 100644 --- a/wxPython/src/_toolbar.i +++ b/wxPython/src/_toolbar.i @@ -384,6 +384,8 @@ public: +MustHaveApp(wxToolBar); + class wxToolBar : public wxToolBarBase { public: %pythonAppend wxToolBar "self._setOORInfo(self)" diff --git a/wxPython/src/_toplvl.i b/wxPython/src/_toplvl.i index 5dc4b30684..597b5c8399 100644 --- a/wxPython/src/_toplvl.i +++ b/wxPython/src/_toplvl.i @@ -145,6 +145,8 @@ public: // is accounted for in client size calculations - all others should be taken // care of manually. +MustHaveApp(wxFrame); + class wxFrame : public wxTopLevelWindow { public: %pythonAppend wxFrame "self._setOORInfo(self)" @@ -255,6 +257,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxDialog); + class wxDialog : public wxTopLevelWindow { public: %pythonAppend wxDialog "self._setOORInfo(self)" @@ -311,6 +315,8 @@ public: %newgroup +MustHaveApp(wxMiniFrame); + class wxMiniFrame : public wxFrame { public: %pythonAppend wxMiniFrame "self._setOORInfo(self)" @@ -345,6 +351,8 @@ enum { }; +MustHaveApp(wxSplashScreenWindow); + class wxSplashScreenWindow: public wxWindow { public: @@ -361,6 +369,8 @@ public: }; +MustHaveApp(wxSplashScreen); + class wxSplashScreen : public wxFrame { public: %pythonAppend wxSplashScreen "self._setOORInfo(self)" diff --git a/wxPython/src/_treectrl.i b/wxPython/src/_treectrl.i index a59c3fc2ce..c10298c9b5 100644 --- a/wxPython/src/_treectrl.i +++ b/wxPython/src/_treectrl.i @@ -309,6 +309,8 @@ IMPLEMENT_ABSTRACT_CLASS(wxPyTreeCtrl, wxTreeCtrl); +MustHaveApp(wxPyTreeCtrl); + %name(TreeCtrl)class wxPyTreeCtrl : public wxControl { public: %pythonAppend wxPyTreeCtrl "self._setOORInfo(self);self._setCallbackInfo(self, TreeCtrl)" diff --git a/wxPython/src/_vscroll.i b/wxPython/src/_vscroll.i index fdbf1cf3c7..9cc2071a9b 100644 --- a/wxPython/src/_vscroll.i +++ b/wxPython/src/_vscroll.i @@ -125,6 +125,8 @@ IMP_PYCALLBACK_COORD_const (wxPyVScrolledWindow, wxVScrolledWindow, Est of the window and not its entire client area. */ +MustHaveApp(wxPyVScrolledWindow); + %name(VScrolledWindow) class wxPyVScrolledWindow : public wxPanel { public: @@ -282,6 +284,8 @@ IMP_PYCALLBACK__DCRECTSIZET_const (wxPyVListBox, wxVListBox, OnDrawBackground It emits the same events as wxListBox and the same event macros may be used with it. */ +MustHaveApp(wxPyVListBox); + %name(VListBox) class wxPyVListBox : public wxPyVScrolledWindow { public: @@ -478,6 +482,7 @@ IMP_PYCALLBACK_STRING_SIZET (wxPyHtmlListBox, wxHtmlListBox, OnGetItemMarkup // wxHtmlListBox is a listbox whose items are wxHtmlCells +MustHaveApp(wxPyHtmlListBox); %name(HtmlListBox) class wxPyHtmlListBox : public wxPyVListBox { public: diff --git a/wxPython/src/_window.i b/wxPython/src/_window.i index 83bccaaf2c..63a951f25a 100644 --- a/wxPython/src/_window.i +++ b/wxPython/src/_window.i @@ -187,6 +187,10 @@ Extra Styles "); +MustHaveApp(wxWindow); +MustHaveApp(wxWindow::FindFocus); +MustHaveApp(wxWindow::GetCapture); +MustHaveApp(wxWindow::GetClassDefaultAttributes); class wxWindow : public wxEvtHandler { @@ -1850,6 +1854,10 @@ non-None, the search will be limited to the given window hierarchy. The search is recursive in both cases.", ""); +MustHaveApp(wxFindWindowById); +MustHaveApp(wxFindWindowByName); +MustHaveApp(wxFindWindowByLabel); + %inline %{ wxWindow* wxFindWindowById( long id, const wxWindow *parent = NULL ) { return wxWindow::FindWindowById(id, parent); diff --git a/wxPython/src/calendar.i b/wxPython/src/calendar.i index f3154a5a75..225444160c 100644 --- a/wxPython/src/calendar.i +++ b/wxPython/src/calendar.i @@ -211,6 +211,8 @@ event. "); +MustHaveApp(wxCalendarCtrl); + class wxCalendarCtrl : public wxControl { public: diff --git a/wxPython/src/grid.i b/wxPython/src/grid.i index bf6b371d04..ab5fd1a864 100644 --- a/wxPython/src/grid.i +++ b/wxPython/src/grid.i @@ -1546,6 +1546,8 @@ typedef wxGrid::wxGridSelectionModes WXGRIDSELECTIONMODES; +MustHaveApp(wxGrid); + class wxGrid : public wxScrolledWindow { public: diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index c01fa664a4..edb5a91791 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -79,6 +79,7 @@ wxMutex* wxPyTMutex = NULL; static PyObject* wxPython_dict = NULL; static PyObject* wxPyAssertionError = NULL; +static PyObject* wxPyNoAppError = NULL; PyObject* wxPyPtrTypeMap = NULL; @@ -567,7 +568,8 @@ PyObject* __wxPySetDictionary(PyObject* /* self */, PyObject* args) return NULL; if (!PyDict_Check(wxPython_dict)) { - PyErr_SetString(PyExc_TypeError, "_wxPySetDictionary must have dictionary object!"); + PyErr_SetString(PyExc_TypeError, + "_wxPySetDictionary must have dictionary object!"); return NULL; } @@ -580,6 +582,12 @@ PyObject* __wxPySetDictionary(PyObject* /* self */, PyObject* args) PyExc_AssertionError, NULL); PyDict_SetItemString(wxPython_dict, "PyAssertionError", wxPyAssertionError); + // Create an exception object to use when the app object hasn't been created yet + wxPyNoAppError = PyErr_NewException("wx._core.PyNoAppError", + PyExc_RuntimeError, NULL); + PyDict_SetItemString(wxPython_dict, "PyNoAppError", wxPyNoAppError); + + #ifdef __WXMOTIF__ #define wxPlatform "__WXMOTIF__" @@ -636,7 +644,12 @@ PyObject* __wxPySetDictionary(PyObject* /* self */, PyObject* args) _AddInfoString("gtk1"); #endif #endif - +#ifdef __WXDEBUG__ + _AddInfoString("wx-assertions-on"); +#else + _AddInfoString("wx-assertions-off"); +#endif + #undef _AddInfoString PyObject* PlatInfoTuple = PyList_AsTuple(PlatInfo); @@ -823,6 +836,22 @@ void wxPy_ReinitStockObjects(int pass) //--------------------------------------------------------------------------- +// Check for existence of a wxApp, setting an exception if there isn't one. +// This doesn't need to aquire the GIL because it should only be called from +// an %exception before the lock is released. + +bool wxPyCheckForApp() { + if (wxTheApp != NULL) + return true; + else { + PyErr_SetString(wxPyNoAppError, "The wx.App object must be created first!"); + return false; + } +} + +//--------------------------------------------------------------------------- + + void wxPyClientData_dtor(wxPyClientData* self) { if (! wxPyDoingCleanup) { // Don't do it during cleanup as Python // may have already garbage collected the object... diff --git a/wxPython/src/html.i b/wxPython/src/html.i index 412fcb3b50..ca4889fded 100644 --- a/wxPython/src/html.i +++ b/wxPython/src/html.i @@ -785,6 +785,8 @@ wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type, +MustHaveApp(wxPyHtmlWindow); + %name(HtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow { public: %pythonAppend wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)" @@ -919,6 +921,8 @@ public: %newgroup +MustHaveApp(wxHtmlDCRenderer); + class wxHtmlDCRenderer : public wxObject { public: wxHtmlDCRenderer(); @@ -956,6 +960,8 @@ enum { }; +MustHaveApp(wxHtmlPrintout); + class wxHtmlPrintout : public wxPyPrintout { public: wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr); @@ -991,6 +997,8 @@ public: +MustHaveApp(wxHtmlEasyPrinting); + class wxHtmlEasyPrinting : public wxObject { public: wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr, @@ -1104,6 +1112,8 @@ public: //--------------------------------------------------------------------------- +MustHaveApp(wxHtmlHelpFrame); + class wxHtmlHelpFrame : public wxFrame { public: %pythonAppend wxHtmlHelpFrame "self._setOORInfo(self)" @@ -1141,6 +1151,8 @@ enum { }; +MustHaveApp(wxHtmlHelpController); + class wxHtmlHelpController : public wxEvtHandler { public: %pythonAppend wxHtmlHelpController "self._setOORInfo(self)" diff --git a/wxPython/src/misc.i b/wxPython/src/misc.i index 2919e201e0..61579d8d0f 100644 --- a/wxPython/src/misc.i +++ b/wxPython/src/misc.i @@ -17,8 +17,7 @@ %{ #include "wx/wxPython/wxPython.h" #include "wx/wxPython/pyclasses.h" -#include "wx/wxPython/pyistream.h" - +#include "wx/wxPython/pyistream.h" %} //--------------------------------------------------------------------------- diff --git a/wxPython/src/my_typemaps.i b/wxPython/src/my_typemaps.i index d9b078bc4e..f1bfc3cd7d 100644 --- a/wxPython/src/my_typemaps.i +++ b/wxPython/src/my_typemaps.i @@ -11,17 +11,6 @@ ///////////////////////////////////////////////////////////////////////////// -//--------------------------------------------------------------------------- -// Tell SWIG to wrap all the wrappers with our thread protection - -%exception { - PyThreadState* __tstate = wxPyBeginAllowThreads(); - $action - wxPyEndAllowThreads(__tstate); - if (PyErr_Occurred()) SWIG_fail; -} - - //---------------------------------------------------------------------- // Typemaps to convert a list of items to an int (size) and an array diff --git a/wxPython/src/wizard.i b/wxPython/src/wizard.i index 03862c5cc9..48a8e9d31c 100644 --- a/wxPython/src/wizard.i +++ b/wxPython/src/wizard.i @@ -84,6 +84,7 @@ public: // // Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be // used as such (i.e. controls may be placed directly on it &c). +MustHaveApp(wxWizardPage); class wxWizardPage : public wxPanel { public: @@ -198,6 +199,8 @@ IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild); +MustHaveApp(wxPyWizardPage); + class wxPyWizardPage : public wxWizardPage { public: @@ -275,6 +278,7 @@ public: // OTOH, it is also possible to dynamicly decide which page to return (i.e. // depending on the user's choices) as the wizard sample shows - in order to do // this, you must derive from wxWizardPage directly. +MustHaveApp(wxWizardPageSimple); class wxWizardPageSimple : public wxWizardPage { public: @@ -307,6 +311,8 @@ public: //---------------------------------------------------------------------- +MustHaveApp(wxWizard); + class wxWizard : public wxDialog { public: