1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListBox class interface
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_LISTBOX_H_BASE_
13 #define _WX_LISTBOX_H_BASE_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
20 #pragma interface "listboxbase.h"
27 #include "wx/ctrlsub.h" // base class
29 // forward declarations are enough here
30 class WXDLLEXPORT wxArrayInt
;
31 class WXDLLEXPORT wxArrayString
;
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 WXDLLEXPORT_DATA(extern const wxChar
*) wxListBoxNameStr
;
39 // ----------------------------------------------------------------------------
40 // wxListBox interface is defined by the class wxListBoxBase
41 // ----------------------------------------------------------------------------
43 class WXDLLEXPORT wxListBoxBase
: public wxControlWithItems
46 // all generic methods are in wxControlWithItems, except for the following
47 // ones which are not yet implemented by wxChoice/wxCombobox
49 void Insert(const wxString
& item
, int pos
)
50 { DoInsert(item
, pos
); }
51 void Insert(const wxString
& item
, int pos
, void *clientData
)
52 { DoInsert(item
, pos
); SetClientData(pos
, clientData
); }
53 void Insert(const wxString
& item
, int pos
, wxClientData
*clientData
)
54 { DoInsert(item
, pos
); SetClientObject(pos
, clientData
); }
56 void InsertItems(int nItems
, const wxString
*items
, int pos
);
57 void InsertItems(const wxArrayString
& items
, int pos
)
58 { DoInsertItems(items
, pos
); }
60 void Set(int n
, const wxString
* items
, void **clientData
= NULL
);
61 void Set(const wxArrayString
& items
, void **clientData
= NULL
)
62 { DoSetItems(items
, clientData
); }
64 // multiple selection logic
65 virtual bool IsSelected(int n
) const = 0;
66 virtual void SetSelection(int n
, bool select
= TRUE
) = 0;
67 virtual void Select(int n
) { SetSelection(n
, TRUE
); }
68 void Deselect(int n
) { SetSelection(n
, FALSE
); }
70 virtual bool SetStringSelection(const wxString
& s
, bool select
= TRUE
);
72 // works for single as well as multiple selection listboxes (unlike
73 // GetSelection which only works for listboxes with single selection)
74 virtual int GetSelections(wxArrayInt
& aSelections
) const = 0;
76 // Set the specified item at the first visible item or scroll to max
78 void SetFirstItem(int n
) { DoSetFirstItem(n
); }
79 void SetFirstItem(const wxString
& s
);
81 // emulate selecting or deselecting the item event.GetInt() (depending on
82 // event.GetExtraLong())
83 void Command(wxCommandEvent
& event
);
85 // compatibility - these functions are deprecated, use the new ones
87 bool Selected(int n
) const { return IsSelected(n
); }
90 // NB: due to wxGTK implementation details, DoInsert() is implemented
91 // using DoInsertItems() and not the other way round
92 void DoInsert(const wxString
& item
, int pos
)
93 { InsertItems(1, &item
, pos
); }
95 // to be implemented in derived classes
96 virtual void DoInsertItems(const wxArrayString
& items
, int pos
) = 0;
97 virtual void DoSetItems(const wxArrayString
& items
, void **clientData
) = 0;
99 virtual void DoSetFirstItem(int n
) = 0;
102 // ----------------------------------------------------------------------------
103 // include the platform-specific class declaration
104 // ----------------------------------------------------------------------------
106 #if defined(__WXMSW__)
107 #include "wx/msw/listbox.h"
108 #elif defined(__WXMOTIF__)
109 #include "wx/motif/listbox.h"
110 #elif defined(__WXGTK__)
111 #include "wx/gtk/listbox.h"
112 #elif defined(__WXQT__)
113 #include "wx/qt/listbox.h"
114 #elif defined(__WXMAC__)
115 #include "wx/mac/listbox.h"
116 #elif defined(__WXPM__)
117 #include "wx/os2/listbox.h"
118 #elif defined(__WXSTUBS__)
119 #include "wx/stubs/listbox.h"
122 #endif // wxUSE_LISTBOX
125 // _WX_LISTBOX_H_BASE_