1 /////////////////////////////////////////////////////////////////////////////// 
   8 // Copyright:   (c) AUTHOR 
   9 // Licence:     wxWindows licence 
  10 /////////////////////////////////////////////////////////////////////////////// 
  13 #pragma implementation "listbox.h" 
  16 #include "wx/listbox.h" 
  18 #include "wx/dynarray.h" 
  21   IMPLEMENT_DYNAMIC_CLASS(wxListBox
, wxControl
) 
  23 // ============================================================================ 
  24 // list box control implementation 
  25 // ============================================================================ 
  28 wxListBox::wxListBox() 
  34 bool wxListBox::Create(wxWindow 
*parent
, wxWindowID id
, 
  37                        int n
, const wxString choices
[], 
  39                        const wxValidator
& validator
, 
  46   SetValidator(validator
); 
  48   if (parent
) parent
->AddChild(this); 
  50   wxSystemSettings settings
; 
  51   SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW
)); 
  53   m_windowId 
= ( id 
== -1 ) ? (int)NewControlId() : id
; 
  55   // TODO create listbox 
  60 wxListBox::~wxListBox() 
  64 void wxListBox::SetupColours() 
  66   SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW
)); 
  69 void wxListBox::SetFirstItem(int N
) 
  74 void wxListBox::SetFirstItem(const wxString
& s
) 
  79 void wxListBox::Delete(int N
) 
  85 void wxListBox::Append(const wxString
& item
) 
  92 void wxListBox::Append(const wxString
& item
, char *Client_data
) 
  99 void wxListBox::Set(int n
, const wxString 
*choices
, char** clientData
) 
 106 int wxListBox::FindString(const wxString
& s
) const 
 112 void wxListBox::Clear() 
 118 void wxListBox::SetSelection(int N
, bool select
) 
 123 bool wxListBox::Selected(int N
) const 
 129 void wxListBox::Deselect(int N
) 
 134 char *wxListBox::GetClientData(int N
) const 
 140 void wxListBox::SetClientData(int N
, char *Client_data
) 
 145 // Return number of selections and an array of selected integers 
 146 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const 
 151     if ((m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED)) 
 154         for ( int n = 0; n < no_sel; n++ ) 
 159     else  // single-selection listbox 
 169 // Get single selection, for single choice list items 
 170 int wxListBox::GetSelection() const 
 176 // Find string for position 
 177 wxString 
wxListBox::GetString(int N
) const 
 183 void wxListBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
) 
 188 void wxListBox::InsertItems(int nItems
, const wxString items
[], int pos
) 
 195 void wxListBox::SetString(int N
, const wxString
& s
) 
 200 int wxListBox::Number () const 
 205 // For single selection items only 
 206 wxString 
wxListBox::GetStringSelection () const 
 208   int sel 
= GetSelection (); 
 210     return this->GetString (sel
); 
 215 bool wxListBox::SetStringSelection (const wxString
& s
, bool flag
) 
 217   int sel 
= FindString (s
); 
 220       SetSelection (sel
, flag
); 
 227 void wxListBox::Command (wxCommandEvent 
& event
) 
 229   if (event
.m_extraLong
) 
 230     SetSelection (event
.m_commandInt
); 
 233       Deselect (event
.m_commandInt
); 
 236   ProcessCommand (event
);