X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..e195c8c95fb154d035bab400952fc81c62439549:/wxPython/src/controls2.i?ds=sidebyside diff --git a/wxPython/src/controls2.i b/wxPython/src/controls2.i index d24b8ebb28..77ae496ebc 100644 --- a/wxPython/src/controls2.i +++ b/wxPython/src/controls2.i @@ -19,6 +19,7 @@ #endif #include #include +#include %} //---------------------------------------------------------------------- @@ -38,11 +39,6 @@ //---------------------------------------------------------------------- -%{ -extern wxValidator wxPyDefaultValidator; -%} - -//---------------------------------------------------------------------- enum { wxLIST_MASK_TEXT, @@ -96,6 +92,52 @@ enum wxListColumnFormat }; +enum { + /* List control event types */ + wxEVT_COMMAND_LIST_BEGIN_DRAG, + wxEVT_COMMAND_LIST_BEGIN_RDRAG, + wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, + wxEVT_COMMAND_LIST_END_LABEL_EDIT, + wxEVT_COMMAND_LIST_DELETE_ITEM, + wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, + wxEVT_COMMAND_LIST_GET_INFO, + wxEVT_COMMAND_LIST_SET_INFO, + wxEVT_COMMAND_LIST_ITEM_SELECTED, + wxEVT_COMMAND_LIST_ITEM_DESELECTED, + wxEVT_COMMAND_LIST_KEY_DOWN, + wxEVT_COMMAND_LIST_INSERT_ITEM, + wxEVT_COMMAND_LIST_COL_CLICK, + wxEVT_COMMAND_LIST_ITEM_ACTIVATED, + wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, + wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, +}; + +enum { + /* Style flags */ + wxLC_ICON, + wxLC_SMALL_ICON, + wxLC_LIST, + wxLC_REPORT, + wxLC_ALIGN_TOP, + wxLC_ALIGN_LEFT, + wxLC_AUTOARRANGE, + wxLC_USER_TEXT, + wxLC_EDIT_LABELS, + wxLC_NO_HEADER, + wxLC_NO_SORT_HEADER, + wxLC_SINGLE_SEL, + wxLC_SORT_ASCENDING, + wxLC_SORT_DESCENDING, + wxLC_MASK_TYPE, + wxLC_MASK_ALIGN, + wxLC_MASK_SORT, + wxLC_HRULES, + wxLC_VRULES, + wxLC_VIRTUAL, +}; + + + class wxListItemAttr { public: @@ -122,7 +164,7 @@ public: }; -class wxListItem { +class wxListItem : public wxObject { public: wxListItem(); ~wxListItem(); @@ -184,7 +226,7 @@ public: }; -class wxListEvent: public wxCommandEvent { +class wxListEvent: public wxNotifyEvent { public: int m_code; long m_itemIndex; @@ -214,15 +256,17 @@ public: class wxListCtrl : public wxControl { public: wxListCtrl(wxWindow* parent, wxWindowID id, - const wxPoint& pos = wxPyDefaultPosition, - const wxSize& size = wxPyDefaultSize, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxLC_ICON, - const wxValidator& validator = wxPyDefaultValidator, + const wxValidator& validator = wxDefaultValidator, char* name = "listCtrl"); %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)" bool Arrange(int flag = wxLIST_ALIGN_DEFAULT); + void AssignImageList(wxImageList* imageList, int which); + %pragma(python) addtomethod = "AssignImageList:_args[0].thisown = 0" bool DeleteItem(long item); bool DeleteAllItems(); bool DeleteColumn(int col); @@ -281,7 +325,7 @@ public: #endif long GetTopItem(); long HitTest(const wxPoint& point, int& OUTPUT); - %name(InsertColumnWith)long InsertColumn(long col, wxListItem& info); + %name(InsertColumnInfo)long InsertColumn(long col, wxListItem& info); long InsertColumn(long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT, int width = -1); @@ -372,6 +416,29 @@ enum { }; +enum { + /* Tree control event types */ + wxEVT_COMMAND_TREE_BEGIN_DRAG, + wxEVT_COMMAND_TREE_BEGIN_RDRAG, + wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, + wxEVT_COMMAND_TREE_END_LABEL_EDIT, + wxEVT_COMMAND_TREE_DELETE_ITEM, + wxEVT_COMMAND_TREE_GET_INFO, + wxEVT_COMMAND_TREE_SET_INFO, + wxEVT_COMMAND_TREE_ITEM_EXPANDED, + wxEVT_COMMAND_TREE_ITEM_EXPANDING, + wxEVT_COMMAND_TREE_ITEM_COLLAPSED, + wxEVT_COMMAND_TREE_ITEM_COLLAPSING, + wxEVT_COMMAND_TREE_SEL_CHANGED, + wxEVT_COMMAND_TREE_SEL_CHANGING, + wxEVT_COMMAND_TREE_KEY_DOWN, + wxEVT_COMMAND_TREE_ITEM_ACTIVATED, + wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, + wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, + wxEVT_COMMAND_TREE_END_DRAG, +}; + + class wxTreeItemId { public: wxTreeItemId(); @@ -380,7 +447,7 @@ public: %addmethods { int __cmp__(wxTreeItemId* other) { - if (! other) return 0; + if (! other) return -1; return *self != *other; } } @@ -392,15 +459,15 @@ public: class wxPyTreeItemData : public wxTreeItemData { public: wxPyTreeItemData(PyObject* obj = NULL) { - if (obj == NULL) + if (obj == NULL) obj = Py_None; - Py_INCREF(obj); - m_obj = obj; + Py_INCREF(obj); + m_obj = obj; } ~wxPyTreeItemData() { bool doSave = wxPyRestoreThread(); - Py_DECREF(m_obj); + Py_DECREF(m_obj); wxPySaveThread(doSave); } @@ -410,7 +477,9 @@ public: } void SetData(PyObject* obj) { + bool doSave = wxPyRestoreThread(); Py_DECREF(m_obj); + wxPySaveThread(doSave); m_obj = obj; Py_INCREF(obj); } @@ -421,7 +490,7 @@ public: -%name(wxTreeItemData) class wxPyTreeItemData { +%name(wxTreeItemData) class wxPyTreeItemData : public wxObject { public: wxPyTreeItemData(PyObject* obj = NULL); @@ -447,6 +516,7 @@ public: %{ class wxPyTreeCtrl : public wxTreeCtrl { + DECLARE_ABSTRACT_CLASS(wxPyTreeCtrl); public: wxPyTreeCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos, @@ -456,7 +526,6 @@ public: char* name) : wxTreeCtrl(parent, id, pos, size, style, validator, name) {} - int OnCompareItems(const wxTreeItemId& item1, const wxTreeItemId& item2) { int rval = 0; @@ -474,6 +543,8 @@ public: PYPRIVATE; }; +IMPLEMENT_ABSTRACT_CLASS(wxPyTreeCtrl, wxTreeCtrl); + %} // These are for the GetFirstChild/GetNextChild methods below @@ -484,22 +555,24 @@ public: %name(wxTreeCtrl)class wxPyTreeCtrl : public wxControl { public: wxPyTreeCtrl(wxWindow *parent, wxWindowID id = -1, - const wxPoint& pos = wxPyDefaultPosition, - const wxSize& size = wxPyDefaultSize, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, - const wxValidator& validator = wxPyDefaultValidator, + const wxValidator& validator = wxDefaultValidator, char* name = "wxTreeCtrl"); void _setSelf(PyObject* self, PyObject* _class); %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)" %pragma(python) addtomethod = "__init__:self._setSelf(self, wxTreeCtrl)" + void AssignImageList(wxImageList* imageList); + %pragma(python) addtomethod = "AssignImageList:_args[0].thisown = 0" size_t GetCount(); unsigned int GetIndent(); void SetIndent(unsigned int indent); wxImageList *GetImageList(); wxImageList *GetStateImageList(); - void SetImageList(wxImageList *imageList/*, int which = wxIMAGE_LIST_NORMAL*/); + void SetImageList(wxImageList *imageList); void SetStateImageList(wxImageList *imageList); unsigned int GetSpacing(); @@ -517,8 +590,8 @@ public: void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = TRUE); %addmethods { - // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData - // if needed. + // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData + // if needed. wxPyTreeItemData* GetItemData(const wxTreeItemId& item) { wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); if (data == NULL) { @@ -532,11 +605,11 @@ public: void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) { data->SetId(item); // set the id self->SetItemData(item, data); - } + } - // [Get|Set]PyData are short-cuts. Also made somewhat crash-proof by - // automatically creating data classes. - PyObject* GetPyData(const wxTreeItemId& item) { + // [Get|Set]PyData are short-cuts. Also made somewhat crash-proof by + // automatically creating data classes. + PyObject* GetPyData(const wxTreeItemId& item) { wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); if (data == NULL) { data = new wxPyTreeItemData(); @@ -544,7 +617,7 @@ public: self->SetItemData(item, data); } return data->GetData(); - } + } void SetPyData(const wxTreeItemId& item, PyObject* obj) { wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); @@ -554,7 +627,7 @@ public: self->SetItemData(item, data); } else data->SetData(obj); - } + } } @@ -575,8 +648,8 @@ public: size_t num, x; num = self->GetSelections(array); for (x=0; x < num; x++) { - PyObject* item = wxPyConstructObject((void*)&array.Item(x), - "wxTreeItemId"); + wxTreeItemId *tii = new wxTreeItemId(array.Item(x)); + PyObject* item = wxPyConstructObject((void*)tii, "wxTreeItemId", TRUE); PyList_Append(rval, item); } wxPySaveThread(doSave); @@ -703,6 +776,15 @@ public: #ifdef SKIPTHIS #ifdef __WXMSW__ + + +enum { + /* tab control event types */ + wxEVT_COMMAND_TAB_SEL_CHANGED, + wxEVT_COMMAND_TAB_SEL_CHANGING, +}; + + class wxTabEvent : public wxCommandEvent { public: }; @@ -712,8 +794,8 @@ public: class wxTabCtrl : public wxControl { public: wxTabCtrl(wxWindow* parent, wxWindowID id, - const wxPoint& pos = wxPyDefaultPosition, - const wxSize& size = wxPyDefaultSize, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, char* name = "tabCtrl"); @@ -755,4 +837,11 @@ public: //---------------------------------------------------------------------- +%init %{ + wxPyPtrTypeMap_Add("wxTreeItemData", "wxPyTreeItemData"); + wxPyPtrTypeMap_Add("wxTreeCtrl", "wxPyTreeCtrl"); +%} + +//---------------------------------------------------------------------- +