From a1df7a952683b7fbcafa575505368e57ce96b011 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 7 Jan 2000 09:09:50 +0000 Subject: [PATCH] small fixes and cleanups git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5286 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- utils/wxPython/demo/wxTreeCtrl.py | 26 +++--- utils/wxPython/src/_defs.i | 1 + utils/wxPython/src/_extras.py | 11 ++- utils/wxPython/src/misc2.i | 2 + utils/wxPython/src/msw/misc2.cpp | 66 ++++++++++++++ utils/wxPython/src/msw/misc2.py | 6 ++ utils/wxPython/src/msw/windows.cpp | 140 ++++++++++++++++++++++++++++- utils/wxPython/src/msw/windows.py | 20 +++++ utils/wxPython/src/windows.i | 21 +++++ 9 files changed, 278 insertions(+), 15 deletions(-) diff --git a/utils/wxPython/demo/wxTreeCtrl.py b/utils/wxPython/demo/wxTreeCtrl.py index b3407c0fbe..3c8587db27 100644 --- a/utils/wxPython/demo/wxTreeCtrl.py +++ b/utils/wxPython/demo/wxTreeCtrl.py @@ -15,27 +15,27 @@ class TestTreeCtrlPanel(wxPanel): self.tree = wxTreeCtrl(self, tID, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS)# | wxTR_MULTIPLE) - il = wxImageList(16, 16) - idx1 = il.Add(wxBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP)) - idx2 = il.Add(wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP)) - idx3 = il.Add(wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP)) - idx4 = il.Add(wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP)) - idx5 = il.Add(wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP)) + #il = wxImageList(16, 16) + #idx1 = il.Add(wxBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP)) + #idx2 = il.Add(wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP)) + #idx3 = il.Add(wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP)) + #idx4 = il.Add(wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP)) + #idx5 = il.Add(wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP)) - self.tree.SetImageList(il) - self.il = il + #self.tree.SetImageList(il) + #self.il = il self.root = self.tree.AddRoot("The Root Item") - self.tree.SetItemImage(self.root, idx1) + #self.tree.SetItemImage(self.root, idx1) for x in range(15): child = self.tree.AppendItem(self.root, "Item %d" % x) - self.tree.SetItemImage(child, idx2) - self.tree.SetItemSelectedImage(child, idx3) + #self.tree.SetItemImage(child, idx2) + #self.tree.SetItemSelectedImage(child, idx3) for y in range(5): last = self.tree.AppendItem(child, "item %d-%s" % (x, chr(ord("a")+y))) - self.tree.SetItemImage(last, idx4) - self.tree.SetItemSelectedImage(last, idx5) + #self.tree.SetItemImage(last, idx4) + #self.tree.SetItemSelectedImage(last, idx5) for z in range(5): self.tree.AppendItem(last, "item %d-%s-%d" % (x, chr(ord("a")+y), z)) diff --git a/utils/wxPython/src/_defs.i b/utils/wxPython/src/_defs.i index c5121712ac..8209f1a2a9 100644 --- a/utils/wxPython/src/_defs.i +++ b/utils/wxPython/src/_defs.i @@ -23,6 +23,7 @@ class wxBitmap; class wxBrush; class wxButton; class wxCalculateLayoutEvent; +class wxCaret; class wxCheckBox; class wxCheckListBox; class wxChoice; diff --git a/utils/wxPython/src/_extras.py b/utils/wxPython/src/_extras.py index 686803f320..cad11d21a1 100644 --- a/utils/wxPython/src/_extras.py +++ b/utils/wxPython/src/_extras.py @@ -733,15 +733,18 @@ class wxPyOnDemandOutputWindow: self.frame = None self.title = title + def SetParent(self, parent): self.parent = parent + def OnCloseWindow(self, event): if self.frame != None: self.frame.Destroy() self.frame = None self.text = None + # this provides the file-like behaviour def write(self, str): if not self.frame: @@ -753,7 +756,10 @@ class wxPyOnDemandOutputWindow: EVT_CLOSE(self.frame, self.OnCloseWindow) self.text.AppendText(str) + def close(self): + if self.frame != None: + self.frame.Destroy() self.frame = None self.text = None @@ -789,19 +795,22 @@ class wxApp(wxPyApp): def SetTopWindow(self, frame): if self.stdioWin: self.stdioWin.SetParent(frame) - sys.stdout = self.stdioWin #sys.stderr = + sys.stderr = sys.stdout = self.stdioWin wxPyApp.SetTopWindow(self, frame) + def MainLoop(self): wxPyApp.MainLoop(self) self.RestoreStdio() + def RedirectStdio(self, filename): if filename: sys.stdout = sys.stderr = open(filename, 'a') else: self.stdioWin = self.outputWindowClass() # wxPyOnDemandOutputWindow + def RestoreStdio(self): sys.stdout, sys.stderr = self.saveStdio if self.stdioWin != None: diff --git a/utils/wxPython/src/misc2.i b/utils/wxPython/src/misc2.i index 6f1d507e0a..cffc30fd28 100644 --- a/utils/wxPython/src/misc2.i +++ b/utils/wxPython/src/misc2.i @@ -274,6 +274,8 @@ public: wxWindow *GetWindow(); %name(MoveXY)void Move(int x, int y); void Move(const wxPoint& pt); + %name(SetSizeWH) void SetSize(int width, int height); + void SetSize(const wxSize& size); void Show(int show = TRUE); void Hide(); void OnSetFocus(); diff --git a/utils/wxPython/src/msw/misc2.cpp b/utils/wxPython/src/msw/misc2.cpp index fee12a3390..432197a8ed 100644 --- a/utils/wxPython/src/msw/misc2.cpp +++ b/utils/wxPython/src/msw/misc2.cpp @@ -1670,6 +1670,70 @@ static PyObject *_wrap_wxCaret_Move(PyObject *self, PyObject *args, PyObject *kw return _resultobj; } +#define wxCaret_SetSizeWH(_swigobj,_swigarg0,_swigarg1) (_swigobj->SetSize(_swigarg0,_swigarg1)) +static PyObject *_wrap_wxCaret_SetSizeWH(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxCaret * _arg0; + int _arg1; + int _arg2; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self","width","height", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oii:wxCaret_SetSizeWH",_kwnames,&_argo0,&_arg1,&_arg2)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxCaret_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxCaret_SetSizeWH. Expected _wxCaret_p."); + return NULL; + } + } +{ + wxPy_BEGIN_ALLOW_THREADS; + wxCaret_SetSizeWH(_arg0,_arg1,_arg2); + + wxPy_END_ALLOW_THREADS; +} Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +#define wxCaret_SetSize(_swigobj,_swigarg0) (_swigobj->SetSize(_swigarg0)) +static PyObject *_wrap_wxCaret_SetSize(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxCaret * _arg0; + wxSize * _arg1; + PyObject * _argo0 = 0; + wxSize temp; + PyObject * _obj1 = 0; + char *_kwnames[] = { "self","size", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxCaret_SetSize",_kwnames,&_argo0,&_obj1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxCaret_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxCaret_SetSize. Expected _wxCaret_p."); + return NULL; + } + } +{ + _arg1 = &temp; + if (! wxSize_helper(_obj1, &_arg1)) + return NULL; +} +{ + wxPy_BEGIN_ALLOW_THREADS; + wxCaret_SetSize(_arg0,*_arg1); + + wxPy_END_ALLOW_THREADS; +} Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + #define wxCaret_Show(_swigobj,_swigarg0) (_swigobj->Show(_swigarg0)) static PyObject *_wrap_wxCaret_Show(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -2067,6 +2131,8 @@ static PyMethodDef misc2cMethods[] = { { "wxCaret_OnSetFocus", (PyCFunction) _wrap_wxCaret_OnSetFocus, METH_VARARGS | METH_KEYWORDS }, { "wxCaret_Hide", (PyCFunction) _wrap_wxCaret_Hide, METH_VARARGS | METH_KEYWORDS }, { "wxCaret_Show", (PyCFunction) _wrap_wxCaret_Show, METH_VARARGS | METH_KEYWORDS }, + { "wxCaret_SetSize", (PyCFunction) _wrap_wxCaret_SetSize, METH_VARARGS | METH_KEYWORDS }, + { "wxCaret_SetSizeWH", (PyCFunction) _wrap_wxCaret_SetSizeWH, METH_VARARGS | METH_KEYWORDS }, { "wxCaret_Move", (PyCFunction) _wrap_wxCaret_Move, METH_VARARGS | METH_KEYWORDS }, { "wxCaret_MoveXY", (PyCFunction) _wrap_wxCaret_MoveXY, METH_VARARGS | METH_KEYWORDS }, { "wxCaret_GetWindow", (PyCFunction) _wrap_wxCaret_GetWindow, METH_VARARGS | METH_KEYWORDS }, diff --git a/utils/wxPython/src/msw/misc2.py b/utils/wxPython/src/msw/misc2.py index bae1cec70f..b91f79aab2 100644 --- a/utils/wxPython/src/msw/misc2.py +++ b/utils/wxPython/src/msw/misc2.py @@ -71,6 +71,12 @@ class wxCaretPtr : def Move(self, *_args, **_kwargs): val = apply(misc2c.wxCaret_Move,(self,) + _args, _kwargs) return val + def SetSizeWH(self, *_args, **_kwargs): + val = apply(misc2c.wxCaret_SetSizeWH,(self,) + _args, _kwargs) + return val + def SetSize(self, *_args, **_kwargs): + val = apply(misc2c.wxCaret_SetSize,(self,) + _args, _kwargs) + return val def Show(self, *_args, **_kwargs): val = apply(misc2c.wxCaret_Show,(self,) + _args, _kwargs) return val diff --git a/utils/wxPython/src/msw/windows.cpp b/utils/wxPython/src/msw/windows.cpp index dd11b7dfca..4c8f6108dc 100644 --- a/utils/wxPython/src/msw/windows.cpp +++ b/utils/wxPython/src/msw/windows.cpp @@ -168,6 +168,16 @@ wxWindow* wxWindow_FromHWND(unsigned long hWnd) { win->SubclassWin(hWnd); return win; } + + int wxWindow_NewControlId() { + return wxWindow::NewControlId(); + } + int wxWindow_NextControlId(int id) { + return wxWindow::NextControlId(id); + } + int wxWindow_PrevControlId(int id) { + return wxWindow::PrevControlId(id); + } #ifdef __cplusplus extern "C" { #endif @@ -255,6 +265,59 @@ static PyObject *_wrap_wxWindow_FromHWND(PyObject *self, PyObject *args, PyObjec return _resultobj; } +static PyObject *_wrap_wxWindow_NewControlId(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + int _result; + char *_kwnames[] = { NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,":wxWindow_NewControlId",_kwnames)) + return NULL; +{ + wxPy_BEGIN_ALLOW_THREADS; + _result = (int )wxWindow_NewControlId(); + + wxPy_END_ALLOW_THREADS; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +static PyObject *_wrap_wxWindow_NextControlId(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + int _result; + int _arg0; + char *_kwnames[] = { "id", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"i:wxWindow_NextControlId",_kwnames,&_arg0)) + return NULL; +{ + wxPy_BEGIN_ALLOW_THREADS; + _result = (int )wxWindow_NextControlId(_arg0); + + wxPy_END_ALLOW_THREADS; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +static PyObject *_wrap_wxWindow_PrevControlId(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + int _result; + int _arg0; + char *_kwnames[] = { "id", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"i:wxWindow_PrevControlId",_kwnames,&_arg0)) + return NULL; +{ + wxPy_BEGIN_ALLOW_THREADS; + _result = (int )wxWindow_PrevControlId(_arg0); + + wxPy_END_ALLOW_THREADS; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + #define wxEvtHandler_ProcessEvent(_swigobj,_swigarg0) (_swigobj->ProcessEvent(_swigarg0)) static PyObject *_wrap_wxEvtHandler_ProcessEvent(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -3802,7 +3865,7 @@ static PyObject *_wrap_wxWindow_SetDimensions(PyObject *self, PyObject *args, Py } static void wxWindow_SetSize(wxWindow *self,const wxSize & size) { - self->SetSize(size.x, size.y); + self->SetSize(size); } static PyObject *_wrap_wxWindow_SetSize(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -4687,6 +4750,76 @@ static PyObject *_wrap_wxWindow_GetBestSize(PyObject *self, PyObject *args, PyOb return _resultobj; } +#define wxWindow_SetCaret(_swigobj,_swigarg0) (_swigobj->SetCaret(_swigarg0)) +static PyObject *_wrap_wxWindow_SetCaret(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxWindow * _arg0; + wxCaret * _arg1; + PyObject * _argo0 = 0; + PyObject * _argo1 = 0; + char *_kwnames[] = { "self","caret", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxWindow_SetCaret",_kwnames,&_argo0,&_argo1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxWindow_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxWindow_SetCaret. Expected _wxWindow_p."); + return NULL; + } + } + if (_argo1) { + if (_argo1 == Py_None) { _arg1 = NULL; } + else if (SWIG_GetPtrObj(_argo1,(void **) &_arg1,"_wxCaret_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of wxWindow_SetCaret. Expected _wxCaret_p."); + return NULL; + } + } +{ + wxPy_BEGIN_ALLOW_THREADS; + wxWindow_SetCaret(_arg0,_arg1); + + wxPy_END_ALLOW_THREADS; +} Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +#define wxWindow_GetCaret(_swigobj) (_swigobj->GetCaret()) +static PyObject *_wrap_wxWindow_GetCaret(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxCaret * _result; + wxWindow * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + char _ptemp[128]; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxWindow_GetCaret",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxWindow_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxWindow_GetCaret. Expected _wxWindow_p."); + return NULL; + } + } +{ + wxPy_BEGIN_ALLOW_THREADS; + _result = (wxCaret *)wxWindow_GetCaret(_arg0); + + wxPy_END_ALLOW_THREADS; +} if (_result) { + SWIG_MakePtr(_ptemp, (char *) _result,"_wxCaret_p"); + _resultobj = Py_BuildValue("s",_ptemp); + } else { + Py_INCREF(Py_None); + _resultobj = Py_None; + } + return _resultobj; +} + static void *SwigwxPanelTowxWindow(void *ptr) { wxPanel *src; wxWindow *dest; @@ -8797,6 +8930,8 @@ static PyMethodDef windowscMethods[] = { { "wxPanel_GetDefaultItem", (PyCFunction) _wrap_wxPanel_GetDefaultItem, METH_VARARGS | METH_KEYWORDS }, { "wxPanel_InitDialog", (PyCFunction) _wrap_wxPanel_InitDialog, METH_VARARGS | METH_KEYWORDS }, { "new_wxPanel", (PyCFunction) _wrap_new_wxPanel, METH_VARARGS | METH_KEYWORDS }, + { "wxWindow_GetCaret", (PyCFunction) _wrap_wxWindow_GetCaret, METH_VARARGS | METH_KEYWORDS }, + { "wxWindow_SetCaret", (PyCFunction) _wrap_wxWindow_SetCaret, METH_VARARGS | METH_KEYWORDS }, { "wxWindow_GetBestSize", (PyCFunction) _wrap_wxWindow_GetBestSize, METH_VARARGS | METH_KEYWORDS }, { "wxWindow_GetDropTarget", (PyCFunction) _wrap_wxWindow_GetDropTarget, METH_VARARGS | METH_KEYWORDS }, { "wxWindow_SetDropTarget", (PyCFunction) _wrap_wxWindow_SetDropTarget, METH_VARARGS | METH_KEYWORDS }, @@ -8929,6 +9064,9 @@ static PyMethodDef windowscMethods[] = { { "wxEvtHandler_SetEvtHandlerEnabled", (PyCFunction) _wrap_wxEvtHandler_SetEvtHandlerEnabled, METH_VARARGS | METH_KEYWORDS }, { "wxEvtHandler_GetEvtHandlerEnabled", (PyCFunction) _wrap_wxEvtHandler_GetEvtHandlerEnabled, METH_VARARGS | METH_KEYWORDS }, { "wxEvtHandler_ProcessEvent", (PyCFunction) _wrap_wxEvtHandler_ProcessEvent, METH_VARARGS | METH_KEYWORDS }, + { "wxWindow_PrevControlId", (PyCFunction) _wrap_wxWindow_PrevControlId, METH_VARARGS | METH_KEYWORDS }, + { "wxWindow_NextControlId", (PyCFunction) _wrap_wxWindow_NextControlId, METH_VARARGS | METH_KEYWORDS }, + { "wxWindow_NewControlId", (PyCFunction) _wrap_wxWindow_NewControlId, METH_VARARGS | METH_KEYWORDS }, { "wxWindow_FromHWND", (PyCFunction) _wrap_wxWindow_FromHWND, METH_VARARGS | METH_KEYWORDS }, { "wxWindow_FindFocus", (PyCFunction) _wrap_wxWindow_FindFocus, METH_VARARGS | METH_KEYWORDS }, { "wxValidator_SetBellOnError", (PyCFunction) _wrap_wxValidator_SetBellOnError, METH_VARARGS | METH_KEYWORDS }, diff --git a/utils/wxPython/src/msw/windows.py b/utils/wxPython/src/msw/windows.py index fa91a2508b..1828af38c4 100644 --- a/utils/wxPython/src/msw/windows.py +++ b/utils/wxPython/src/msw/windows.py @@ -485,8 +485,22 @@ class wxWindowPtr(wxEvtHandlerPtr): val = apply(windowsc.wxWindow_GetBestSize,(self,) + _args, _kwargs) if val: val = wxSizePtr(val) ; val.thisown = 1 return val + def SetCaret(self, *_args, **_kwargs): + val = apply(windowsc.wxWindow_SetCaret,(self,) + _args, _kwargs) + return val + def GetCaret(self, *_args, **_kwargs): + val = apply(windowsc.wxWindow_GetCaret,(self,) + _args, _kwargs) + if val: val = wxCaretPtr(val) + return val def __repr__(self): return "" % (self.this,) + # replaces broken shadow method + def GetCaret(self, *_args, **_kwargs): + from misc2 import wxCaretPtr + val = apply(windowsc.wxWindow_GetCaret,(self,) + _args, _kwargs) + if val: val = wxCaretPtr(val) + return val + class wxWindow(wxWindowPtr): def __init__(self,*_args,**_kwargs): self.this = apply(windowsc.new_wxWindow,_args,_kwargs) @@ -939,6 +953,12 @@ def wxWindow_FromHWND(*_args, **_kwargs): if val: val = wxWindowPtr(val) return val +wxWindow_NewControlId = windowsc.wxWindow_NewControlId + +wxWindow_NextControlId = windowsc.wxWindow_NextControlId + +wxWindow_PrevControlId = windowsc.wxWindow_PrevControlId + #-------------- VARIABLE WRAPPERS ------------------ diff --git a/utils/wxPython/src/windows.i b/utils/wxPython/src/windows.i index 91964d7a5f..3c21bff6bf 100644 --- a/utils/wxPython/src/windows.i +++ b/utils/wxPython/src/windows.i @@ -324,6 +324,16 @@ public: %pragma(python) addtomethod = "SetDropTarget:_args[0].thisown = 0" wxSize GetBestSize(); + + void SetCaret(wxCaret *caret); + wxCaret *GetCaret(); + %pragma(python) addtoclass = "# replaces broken shadow method + def GetCaret(self, *_args, **_kwargs): + from misc2 import wxCaretPtr + val = apply(windowsc.wxWindow_GetCaret,(self,) + _args, _kwargs) + if val: val = wxCaretPtr(val) + return val +" }; //%clear int* x, int* y; @@ -362,6 +372,17 @@ wxWindow* wxWindow_FromHWND(unsigned long hWnd) { %} #endif +%inline %{ + int wxWindow_NewControlId() { + return wxWindow::NewControlId(); + } + int wxWindow_NextControlId(int id) { + return wxWindow::NextControlId(id); + } + int wxWindow_PrevControlId(int id) { + return wxWindow::PrevControlId(id); + } +%} //--------------------------------------------------------------------------- -- 2.45.2