X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/60e05667cba1b7f31540bef7cc9647159aa5047a..d9f39e09e82e99c422619f4e3df536d0a9e87987:/utils/wxPython/src/controls2.i?ds=inline diff --git a/utils/wxPython/src/controls2.i b/utils/wxPython/src/controls2.i index 56dcdaaae3..4e85f0fe10 100644 --- a/utils/wxPython/src/controls2.i +++ b/utils/wxPython/src/controls2.i @@ -16,9 +16,6 @@ #include "helpers.h" #include #include -#if 0 -#include -#endif %} //---------------------------------------------------------------------- @@ -34,7 +31,7 @@ %import events.i %import controls.i -%pragma(python) code = "import wxp" +%pragma(python) code = "import wx" //---------------------------------------------------------------------- @@ -44,6 +41,52 @@ extern wxValidator wxPyDefaultValidator; //---------------------------------------------------------------------- +enum { + wxLIST_MASK_TEXT, + wxLIST_MASK_IMAGE, + wxLIST_MASK_DATA, + wxLIST_MASK_WIDTH, + wxLIST_MASK_FORMAT, + wxLIST_STATE_DONTCARE, + wxLIST_STATE_DROPHILITED, + wxLIST_STATE_FOCUSED, + wxLIST_STATE_SELECTED, + wxLIST_STATE_CUT, + wxLIST_HITTEST_ABOVE, + wxLIST_HITTEST_BELOW, + wxLIST_HITTEST_NOWHERE, + wxLIST_HITTEST_ONITEMICON, + wxLIST_HITTEST_ONITEMLABEL, + wxLIST_HITTEST_ONITEMRIGHT, + wxLIST_HITTEST_ONITEMSTATEICON, + wxLIST_HITTEST_TOLEFT, + wxLIST_HITTEST_TORIGHT, + wxLIST_HITTEST_ONITEM, + wxLIST_NEXT_ABOVE, + wxLIST_NEXT_ALL, + wxLIST_NEXT_BELOW, + wxLIST_NEXT_LEFT, + wxLIST_NEXT_RIGHT, + wxLIST_ALIGN_DEFAULT, + wxLIST_ALIGN_LEFT, + wxLIST_ALIGN_TOP, + wxLIST_ALIGN_SNAP_TO_GRID, + wxLIST_FORMAT_LEFT, + wxLIST_FORMAT_RIGHT, + wxLIST_FORMAT_CENTRE, + wxLIST_FORMAT_CENTER, + wxLIST_AUTOSIZE, + wxLIST_AUTOSIZE_USEHEADER, + wxLIST_RECT_BOUNDS, + wxLIST_RECT_ICON, + wxLIST_RECT_LABEL, + wxLIST_FIND_UP, + wxLIST_FIND_DOWN, + wxLIST_FIND_LEFT, + wxLIST_FIND_RIGHT, +}; + + class wxListItem { public: long m_mask; // Indicates what fields are valid @@ -87,17 +130,18 @@ public: const wxValidator& validator = wxPyDefaultValidator, char* name = "listCtrl"); - %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)" + %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" bool Arrange(int flag = wxLIST_ALIGN_DEFAULT); bool DeleteItem(long item); bool DeleteAllItems(); bool DeleteColumn(int col); -#ifdef __WXMSW__ bool DeleteAllColumns(void); void ClearAll(void); +#ifdef __WXMSW__ wxTextCtrl* EditLabel(long item); bool EndEditLabel(bool cancel); + wxTextCtrl* GetEditControl(); #endif bool EnsureVisible(long item); long FindItem(long start, const wxString& str, bool partial = FALSE); @@ -107,15 +151,13 @@ public: bool GetColumn(int col, wxListItem& item); int GetColumnWidth(int col); int GetCountPerPage(); -#ifdef __WXMSW__ - wxTextCtrl* GetEditControl(); -#endif wxImageList* GetImageList(int which); long GetItemData(long item); %addmethods { - %new wxListItem* GetItem() { + %new wxListItem* GetItem(long itemId) { wxListItem* info = new wxListItem; + info->m_itemId = itemId; self->GetItem(*info); return info; } @@ -141,10 +183,11 @@ public: int GetSelectedItemCount(); #ifdef __WXMSW__ wxColour GetTextColour(); + void SetTextColour(const wxColour& col); #endif long GetTopItem(); long HitTest(const wxPoint& point, int& OUTPUT); - %name(InsertColumnWithInfo)long InsertColumn(long col, wxListItem& info); + %name(InsertColumnWith)long InsertColumn(long col, wxListItem& info); long InsertColumn(long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT, int width = -1); @@ -160,18 +203,17 @@ public: bool SetColumn(int col, wxListItem& item); bool SetColumnWidth(int col, int width); void SetImageList(wxImageList* imageList, int which); + bool SetItem(wxListItem& info); - %name(SetItemString)long SetItem(long index, int col, const wxString& label, + %name(SetStringItem)long SetItem(long index, int col, const wxString& label, int imageId = -1); + bool SetItemData(long item, long data); bool SetItemImage(long item, int image, int selImage); bool SetItemPosition(long item, const wxPoint& pos); bool SetItemState(long item, long state, long stateMask); void SetItemText(long item, const wxString& text); void SetSingleStyle(long style, bool add = TRUE); -#ifdef __WXMSW__ - void SetTextColour(const wxColour& col); -#endif void SetWindowStyleFlag(long style); // TODO: bool SortItems(wxListCtrlCompare fn, long data); }; @@ -181,31 +223,57 @@ public: //---------------------------------------------------------------------- -//#ifdef __WXMSW__ class wxTreeItemId { public: wxTreeItemId(); ~wxTreeItemId(); bool IsOk() const { return m_itemId != 0; } -// %addmethods { -// long GetId() { return (long)(*self); } -// } }; -// **** This isn't very useful yet. This needs to be specialized to enable -// derived Python classes... -class wxTreeItemData { +%{ +class wxPyTreeItemData : public wxTreeItemData { public: - wxTreeItemData(); - ~wxTreeItemData(); + wxPyTreeItemData(PyObject* obj = NULL) { + if (obj == NULL) + obj = Py_None; + Py_INCREF(obj); + m_obj = obj; + } - const wxTreeItemId& GetId(); - void SetId(const wxTreeItemId& id); + ~wxPyTreeItemData() { + Py_DECREF(m_obj); + } + + PyObject* GetData() { + Py_INCREF(m_obj); + return m_obj; + } + + void SetData(PyObject* obj) { + Py_DECREF(m_obj); + m_obj = obj; + Py_INCREF(obj); + } + + PyObject* m_obj; }; +%} + + +%name(wxTreeItemData) class wxPyTreeItemData { +public: + wxPyTreeItemData(PyObject* obj = NULL); + + PyObject* GetData(); + void SetData(PyObject* obj); + + const wxTreeItemId& GetId(); + void SetId(const wxTreeItemId& id); +}; @@ -233,7 +301,7 @@ public: const wxValidator& validator = wxPyDefaultValidator, char* name = "wxTreeCtrl"); - %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)" + %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" size_t GetCount(); unsigned int GetIndent(); @@ -246,12 +314,49 @@ public: wxString GetItemText(const wxTreeItemId& item); int GetItemImage(const wxTreeItemId& item); int GetItemSelectedImage(const wxTreeItemId& item); - wxTreeItemData *GetItemData(const wxTreeItemId& item); void SetItemText(const wxTreeItemId& item, const wxString& text); void SetItemImage(const wxTreeItemId& item, int image); void SetItemSelectedImage(const wxTreeItemId& item, int image); - void SetItemData(const wxTreeItemId& item, wxTreeItemData *data); + void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = TRUE); + + %addmethods { + // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData + // if needed. + wxPyTreeItemData* GetItemData(const wxTreeItemId& item) { + wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); + if (data == NULL) { + data = new wxPyTreeItemData(); + self->SetItemData(item, data); + } + return data; + } + + void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) { + 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) { + wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); + if (data == NULL) { + data = new wxPyTreeItemData(); + self->SetItemData(item, data); + } + return data->GetData(); + } + + void SetPyData(const wxTreeItemId& item, PyObject* obj) { + wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); + if (data == NULL) { + data = new wxPyTreeItemData(obj); + self->SetItemData(item, data); + } else + data->SetData(obj); + } + } + bool IsVisible(const wxTreeItemId& item); bool ItemHasChildren(const wxTreeItemId& item); @@ -273,22 +378,23 @@ public: wxTreeItemId AddRoot(const wxString& text, int image = -1, int selectedImage = -1, - wxTreeItemData *data = NULL); + wxPyTreeItemData *data = NULL); wxTreeItemId PrependItem(const wxTreeItemId& parent, const wxString& text, int image = -1, int selectedImage = -1, - wxTreeItemData *data = NULL); + wxPyTreeItemData *data = NULL); wxTreeItemId InsertItem(const wxTreeItemId& parent, const wxTreeItemId& idPrevious, const wxString& text, int image = -1, int selectedImage = -1, - wxTreeItemData *data = NULL); + wxPyTreeItemData *data = NULL); wxTreeItemId AppendItem(const wxTreeItemId& parent, const wxString& text, int image = -1, int selectedImage = -1, - wxTreeItemData *data = NULL); + wxPyTreeItemData *data = NULL); void Delete(const wxTreeItemId& item); + void DeleteChildren(const wxTreeItemId& item); void DeleteAllItems(); void Expand(const wxTreeItemId& item); @@ -311,9 +417,11 @@ public: // **** And this too // wxTreeItemCmpFunc *cmpFunction = NULL); + void SetItemBold(const wxTreeItemId& item, bool bold = TRUE); + bool IsBold(const wxTreeItemId& item) const; + wxTreeItemId HitTest(const wxPoint& point); }; -//#endif //---------------------------------------------------------------------- @@ -333,7 +441,7 @@ public: long style = 0, char* name = "tabCtrl"); - %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)" + %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" bool DeleteAllItems(); bool DeleteItem(int item); @@ -375,6 +483,69 @@ public: ///////////////////////////////////////////////////////////////////////////// // // $Log$ +// Revision 1.17 1999/04/30 03:29:18 RD +// wxPython 2.0b9, first phase (win32) +// Added gobs of stuff, see wxPython/README.txt for details +// +// Revision 1.16 1999/02/25 07:08:32 RD +// +// wxPython version 2.0b5 +// +// Revision 1.15 1999/02/20 09:02:56 RD +// Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a +// window handle. If you can get the window handle into the python code, +// it should just work... More news on this later. +// +// Added wxImageList, wxToolTip. +// +// Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the +// wxRegConfig class. +// +// As usual, some bug fixes, tweaks, etc. +// +// Revision 1.14 1999/01/30 07:30:10 RD +// +// Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc. +// +// Various cleanup, tweaks, minor additions, etc. to maintain +// compatibility with the current wxWindows. +// +// Revision 1.13 1998/12/17 14:07:34 RR +// +// Removed minor differences between wxMSW and wxGTK +// +// Revision 1.12 1998/12/16 22:10:52 RD +// +// Tweaks needed to be able to build wxPython with wxGTK. +// +// Revision 1.11 1998/12/15 20:41:16 RD +// Changed the import semantics from "from wxPython import *" to "from +// wxPython.wx import *" This is for people who are worried about +// namespace pollution, they can use "from wxPython import wx" and then +// prefix all the wxPython identifiers with "wx." +// +// Added wxTaskbarIcon for wxMSW. +// +// Made the events work for wxGrid. +// +// Added wxConfig. +// +// Added wxMiniFrame for wxGTK, (untested.) +// +// Changed many of the args and return values that were pointers to gdi +// objects to references to reflect changes in the wxWindows API. +// +// Other assorted fixes and additions. +// +// Revision 1.10 1998/11/25 08:45:23 RD +// +// Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon +// Added events for wxGrid +// Other various fixes and additions +// +// Revision 1.9 1998/11/16 00:00:54 RD +// Generic treectrl for wxPython/GTK compiles... +// // Revision 1.8 1998/11/11 04:40:20 RD // wxTreeCtrl now works (sort of) for wxPython-GTK. This is the new // TreeCtrl in src/gtk/treectrl.cpp not the old generic one.