1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG interface defs for wxListBox and wxCheckListBox
 
   7 // Created:     10-June-1998
 
   9 // Copyright:   (c) 2003 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  16 //---------------------------------------------------------------------------
 
  19 #include <wx/checklst.h>
 
  23 MAKE_CONST_WXSTRING(ListBoxNameStr);
 
  26 //---------------------------------------------------------------------------
 
  29 MustHaveApp(wxListBox);
 
  31 class wxListBox : public wxControlWithItems
 
  34     %pythonAppend wxListBox         "self._setOORInfo(self)"
 
  35     %pythonAppend wxListBox()       ""
 
  37     wxListBox(wxWindow* parent, wxWindowID id=-1,
 
  38               const wxPoint& pos = wxDefaultPosition,
 
  39               const wxSize& size = wxDefaultSize,
 
  40               const wxArrayString& choices = wxPyEmptyStringArray,              
 
  42               const wxValidator& validator = wxDefaultValidator,
 
  43               const wxString& name = wxPyListBoxNameStr);
 
  44     %RenameCtor(PreListBox, wxListBox());
 
  46     bool Create(wxWindow* parent, wxWindowID id=-1,
 
  47                 const wxPoint& pos = wxDefaultPosition,
 
  48                 const wxSize& size = wxDefaultSize,
 
  49                 const wxArrayString& choices = wxPyEmptyStringArray,
 
  51                 const wxValidator& validator = wxDefaultValidator,
 
  52                 const wxString& name = wxPyListBoxNameStr);
 
  54     // all generic methods are in wxControlWithItems...
 
  57         void Insert(const wxString& item, int pos, PyObject* clientData=NULL) {
 
  59                 wxPyClientData* data = new wxPyClientData(clientData);
 
  60                 self->Insert(item, pos, data);
 
  62                 self->Insert(item, pos);
 
  66     void InsertItems(const wxArrayString& items, int pos);
 
  67     void Set(const wxArrayString& items/*, void **clientData = NULL */);
 
  69     // multiple selection logic
 
  70     virtual bool IsSelected(int n) const;
 
  71     virtual void SetSelection(int n, bool select = true);
 
  72     virtual void Select(int n);
 
  74     void DeselectAll(int itemToLeaveSelected = -1);
 
  76     virtual bool SetStringSelection(const wxString& s, bool select = true);
 
  78     // works for single as well as multiple selection listboxes (unlike
 
  79     // GetSelection which only works for listboxes with single selection)
 
  80     //virtual int GetSelections(wxArrayInt& aSelections) const;
 
  82         PyObject* GetSelections() {
 
  84             self->GetSelections(lst);
 
  85             PyObject *tup = PyTuple_New(lst.GetCount());
 
  86             for(size_t i=0; i<lst.GetCount(); i++) {
 
  87                 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
 
  93     // set the specified item at the first visible item or scroll to max
 
  95     void SetFirstItem(int n);
 
  96     %Rename(SetFirstItemStr,  void, SetFirstItem(const wxString& s));
 
  98     // ensures that the given item is visible scrolling the listbox if
 
 100     virtual void EnsureVisible(int n);
 
 102     // a combination of Append() and EnsureVisible(): appends the item to the
 
 103     // listbox and ensures that it is visible i.e. not scrolled out of view
 
 104     void AppendAndEnsureVisible(const wxString& s);
 
 106     // return True if this listbox is sorted
 
 107     bool IsSorted() const;
 
 111         void SetItemForegroundColour(int item, const wxColour& c) {
 
 113                  if (self->GetWindowStyle() & wxLB_OWNERDRAW)
 
 114                      self->GetItem(item)->SetTextColour(c);
 
 117         void SetItemBackgroundColour(int item, const wxColour& c) {
 
 119                  if (self->GetWindowStyle() & wxLB_OWNERDRAW)
 
 120                      self->GetItem(item)->SetBackgroundColour(c);
 
 123         void SetItemFont(int item, const wxFont& f) {
 
 125                  if (self->GetWindowStyle() & wxLB_OWNERDRAW)
 
 126                      self->GetItem(item)->SetFont(f);
 
 131     static wxVisualAttributes
 
 132     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
 
 136 //---------------------------------------------------------------------------
 
 140 MustHaveApp(wxCheckListBox);
 
 142 // wxCheckListBox: a listbox whose items may be checked
 
 143 class wxCheckListBox : public wxListBox
 
 146     %pythonAppend wxCheckListBox         "self._setOORInfo(self)"
 
 147     %pythonAppend wxCheckListBox()       ""
 
 149     wxCheckListBox(wxWindow *parent, wxWindowID id=-1,
 
 150                    const wxPoint& pos = wxDefaultPosition,
 
 151                    const wxSize& size = wxDefaultSize,
 
 152                    const wxArrayString& choices = wxPyEmptyStringArray,
 
 154                    const wxValidator& validator = wxDefaultValidator,
 
 155                    const wxString& name = wxPyListBoxNameStr);
 
 156     %RenameCtor(PreCheckListBox, wxCheckListBox());
 
 158     bool Create(wxWindow *parent, wxWindowID id=-1,
 
 159                 const wxPoint& pos = wxDefaultPosition,
 
 160                 const wxSize& size = wxDefaultSize,
 
 161                 const wxArrayString& choices = wxPyEmptyStringArray,
 
 163                 const wxValidator& validator = wxDefaultValidator,
 
 164                 const wxString& name = wxPyListBoxNameStr);
 
 166     bool  IsChecked(int index);
 
 167     void  Check(int index, int check = true);
 
 169 #if defined(__WXMSW__) || defined(__WXGTK__)
 
 173     // return the index of the item at this position or wxNOT_FOUND
 
 174     int HitTest(const wxPoint& pt) const;
 
 175     %Rename(HitTestXY, int, HitTest(wxCoord x, wxCoord y) const);
 
 178 //---------------------------------------------------------------------------