X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d14a1e28567de23c586bc80017073d0c39f8d18f..49bffb1482cd2a6a30b38280f6c9bffc72dbfe42:/wxPython/src/_listctrl.i diff --git a/wxPython/src/_listctrl.i b/wxPython/src/_listctrl.i index 2d10a2b987..c1619a8708 100644 --- a/wxPython/src/_listctrl.i +++ b/wxPython/src/_listctrl.i @@ -18,9 +18,8 @@ %{ #include - const wxChar* wxListCtrlNameStr = _T("wxListCtrl"); - DECLARE_DEF_STRING(ListCtrlNameStr); %} +MAKE_CONST_WXSTRING2(ListCtrlNameStr, _T("wxListCtrl")); //--------------------------------------------------------------------------- %newgroup @@ -179,6 +178,7 @@ public: //--------------------------------------------------------------------------- %newgroup + // wxListItem: the item or column info, used to exchange data with wxListCtrl class wxListItem : public wxObject { public: @@ -265,7 +265,7 @@ public: long GetIndex(); int GetColumn(); wxPoint GetPoint(); - %pythoncode { GetPostiion = GetPoint } + %pythoncode { GetPosition = GetPoint } const wxString& GetLabel(); const wxString& GetText(); int GetImage(); @@ -341,7 +341,7 @@ EVT_LIST_ITEM_FOCUSED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_FOCUSED static int wxCALLBACK wxPyListCtrl_SortItems(long item1, long item2, long funcPtr) { int retval = 0; PyObject* func = (PyObject*)funcPtr; - wxPyBeginBlockThreads(); + bool blocked = wxPyBeginBlockThreads(); PyObject* args = Py_BuildValue("(ii)", item1, item2); PyObject* result = PyEval_CallObject(func, args); @@ -351,7 +351,7 @@ EVT_LIST_ITEM_FOCUSED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_FOCUSED Py_DECREF(result); } - wxPyEndBlockThreads(); + wxPyEndBlockThreads(blocked); return retval; } %} @@ -401,8 +401,8 @@ IMP_PYCALLBACK_LISTATTR_LONG(wxPyListCtrl, wxListCtrl, OnGetItemAttr); %name(ListCtrl)class wxPyListCtrl : public wxControl { public: - %addtofunc wxPyListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, ListCtrl)" - %addtofunc wxPyListCtrl() "" + %pythonAppend wxPyListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, ListCtrl)" + %pythonAppend wxPyListCtrl() "" wxPyListCtrl(wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, @@ -427,7 +427,7 @@ public: bool SetBackgroundColour(const wxColour& col); // Gets information about this column - %addtofunc GetColumn "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap + %pythonAppend GetColumn "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap %extend { wxListItem* GetColumn(int col) { wxListItem item; @@ -470,7 +470,7 @@ public: #endif // Gets information about the item - %addtofunc GetItem "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap + %pythonAppend GetItem "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap %extend { wxListItem* GetItem(long itemId, int col=0) { wxListItem* info = new wxListItem; @@ -542,7 +542,7 @@ public: wxSize GetItemSpacing() const; #ifndef __WXMSW__ - void SetItemSpacing( int spacing, bool isSmall = FALSE ); + void SetItemSpacing( int spacing, bool isSmall = False ); #endif // Gets the number of selected items in the list control @@ -559,7 +559,7 @@ public: long GetTopItem() const ; // Add or remove a single window style - void SetSingleStyle(long style, bool add = TRUE) ; + void SetSingleStyle(long style, bool add = True) ; // Set the whole window style void SetWindowStyleFlag(long style) ; @@ -578,10 +578,14 @@ public: // is there a way to tell SWIG to disown this??? - %addtofunc AssignImageList "args[1].thisown = 0"; + %apply SWIGTYPE *DISOWN { wxImageList *imageList }; void AssignImageList(wxImageList *imageList, int which); - - // returns true if it is a virtual list control + %clear wxImageList *imageList; + + // are we in report mode? + bool InReportView() const; + + // returns True if it is a virtual list control bool IsVirtual() const; // refresh items selectively (only useful for virtual list controls) @@ -621,7 +625,7 @@ public: // Find an item whose label matches this string, starting from the item after 'start' // or the beginning if 'start' is -1. - long FindItem(long start, const wxString& str, bool partial = FALSE); + long FindItem(long start, const wxString& str, bool partial = False); // Find an item whose data matches this data, starting from the item after 'start' // or the beginning if 'start' is -1. @@ -631,9 +635,12 @@ public: // the item after 'start' or the beginning if 'start' is -1. %name(FindItemAtPos) long FindItem(long start, const wxPoint& pt, int direction); - // Determines which item (if any) is at the specified point, - // giving details in the second return value (see wxLIST_HITTEST_... flags above) - long HitTest(const wxPoint& point, int& OUTPUT); + + DocDeclAStr( + long, HitTest(const wxPoint& point, int& OUTPUT), + "HitTest(Point point) -> (item, where)", + "Determines which item (if any) is at the specified point,\n" + "giving details in the second return value (see wxLIST_HITTEST_... flags.)"); // Inserts an item, returning the index of the new item if successful, // -1 otherwise. @@ -677,18 +684,18 @@ public: %# Some helpers... def Select(self, idx, on=1): '''[de]select an item''' - if on: state = wxLIST_STATE_SELECTED + if on: state = wx.LIST_STATE_SELECTED else: state = 0 - self.SetItemState(idx, state, wxLIST_STATE_SELECTED) + self.SetItemState(idx, state, wx.LIST_STATE_SELECTED) def Focus(self, idx): '''Focus and show the given item''' - self.SetItemState(idx, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED) + self.SetItemState(idx, wx.LIST_STATE_FOCUSED, wx.LIST_STATE_FOCUSED) self.EnsureVisible(idx) def GetFocusedItem(self): '''get the currently focused item or -1 if none''' - return self.GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED) + return self.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_FOCUSED) def GetFirstSelected(self, *args): '''return first selected item, or -1 when none''' @@ -696,22 +703,22 @@ public: def GetNextSelected(self, item): '''return subsequent selected items, or -1 when no more''' - return self.GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) + return self.GetNextItem(item, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) def IsSelected(self, idx): - '''return TRUE if the item is selected''' - return self.GetItemState(idx, wxLIST_STATE_SELECTED) != 0 + '''return True if the item is selected''' + return self.GetItemState(idx, wx.LIST_STATE_SELECTED) != 0 def SetColumnImage(self, col, image): item = self.GetColumn(col) - # preserve all other attributes too - item.SetMask( wxLIST_MASK_STATE | - wxLIST_MASK_TEXT | - wxLIST_MASK_IMAGE | - wxLIST_MASK_DATA | - wxLIST_SET_ITEM | - wxLIST_MASK_WIDTH | - wxLIST_MASK_FORMAT ) + %# preserve all other attributes too + item.SetMask( wx.LIST_MASK_STATE | + wx.LIST_MASK_TEXT | + wx.LIST_MASK_IMAGE | + wx.LIST_MASK_DATA | + wx.LIST_SET_ITEM | + wx.LIST_MASK_WIDTH | + wx.LIST_MASK_FORMAT ) item.SetImage(image) self.SetColumn(col, item) @@ -722,7 +729,7 @@ public: '''Append an item to the list control. The entry parameter should be a sequence with an item for each column''' if len(entry): - if wx.wxUSE_UNICODE: + if wx.USE_UNICODE: cvtfunc = unicode else: cvtfunc = str @@ -745,7 +752,7 @@ public: // or zero if the two items are equivalent. bool SortItems(PyObject* func) { if (!PyCallable_Check(func)) - return FALSE; + return False; return self->SortItems((wxListCtrlCompare)wxPyListCtrl_SortItems, (long)func); } } @@ -760,6 +767,9 @@ public: #endif } } + + static wxVisualAttributes + GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); }; @@ -772,8 +782,8 @@ public: class wxListView : public wxPyListCtrl { public: - %addtofunc wxListView "self._setOORInfo(self)" - %addtofunc wxListView() "" + %pythonAppend wxListView "self._setOORInfo(self)" + %pythonAppend wxListView() "" wxListView( wxWindow *parent, wxWindowID id = -1, @@ -793,7 +803,7 @@ public: const wxString& name = wxPyListCtrlNameStr); // [de]select an item - void Select(long n, bool on = TRUE); + void Select(long n, bool on = True); // focus and show the given item void Focus(long index); @@ -805,7 +815,7 @@ public: long GetNextSelected(long item) const; long GetFirstSelected() const; - // return TRUE if the item is selected + // return True if the item is selected bool IsSelected(long index); void SetColumnImage(int col, int image);