X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a3870b2ff595ba4bb4f0397ace77ceeb9628e94d..af51080d149236d28af5484096a1b5eda43b5ae0:/include/wx/univ/listbox.h?ds=sidebyside diff --git a/include/wx/univ/listbox.h b/include/wx/univ/listbox.h index 03f87df5c0..acc660541a 100644 --- a/include/wx/univ/listbox.h +++ b/include/wx/univ/listbox.h @@ -12,11 +12,13 @@ #ifndef _WX_UNIV_LISTBOX_H_ #define _WX_UNIV_LISTBOX_H_ -#ifdef __GNUG__ - #pragma implementation "univlistbox.h" +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) + #pragma interface "univlistbox.h" #endif #include "wx/scrolwin.h" // for wxScrollHelper +#include "wx/dynarray.h" +#include "wx/arrstr.h" // ---------------------------------------------------------------------------- // the actions supported by this control @@ -50,7 +52,7 @@ // wxListBox: a list of selectable items // ---------------------------------------------------------------------------- -class wxListBox : public wxListBoxBase, public wxScrollHelper +class WXDLLEXPORT wxListBox : public wxListBoxBase, public wxScrollHelper { public: // ctors and such @@ -68,6 +70,14 @@ public: Create(parent, id, pos, size, n, choices, style, validator, name); } + wxListBox(wxWindow *parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + const wxArrayString& choices, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxListBoxNameStr ); virtual ~wxListBox(); @@ -79,16 +89,24 @@ public: long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxListBoxNameStr); + bool Create(wxWindow *parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + const wxArrayString& choices, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxListBoxNameStr); // implement the listbox interface defined by wxListBoxBase virtual void Clear(); virtual void Delete(int n); - virtual int GetCount() const { return (int)m_strings.GetCount(); } - virtual wxString GetString(int n) const { return m_strings[n]; } + virtual int GetCount() const { return (int)m_strings->GetCount(); } + virtual wxString GetString(int n) const { return (*m_strings)[n]; } virtual void SetString(int n, const wxString& s); virtual int FindString(const wxString& s) const - { return m_strings.Index(s); } + { return IsSorted() ? m_stringsSorted->Index(s) : m_strings->Index(s); } virtual bool IsSelected(int n) const { return m_selections.Index(n) != wxNOT_FOUND; } @@ -129,10 +147,10 @@ public: void Activate(int item = -1); // select or unselect the specified or current (if -1) item - void Select(bool sel = TRUE, int item = -1); + void DoSelect(int item = -1, bool sel = TRUE); // more readable wrapper - void Unselect(int item) { Select(FALSE, item); } + void DoUnselect(int item) { DoSelect(item, FALSE); } // select an item and send a notification about it void SelectAndNotify(int item); @@ -165,8 +183,8 @@ public: long numArg = 0l, const wxString& strArg = wxEmptyString); - // let wxColourScheme choose the right colours for us - virtual bool IsContainerWindow() const { return TRUE; } + // idle processing + virtual void OnInternalIdle(); protected: // geometry @@ -182,7 +200,6 @@ protected: void Init(); // event handlers - void OnIdle(wxIdleEvent& event); void OnSize(wxSizeEvent& event); // common part of Clear() and DoSetItems(): clears everything @@ -221,8 +238,14 @@ protected: void UpdateItems(); // the array containing all items (it is sorted if the listbox has - // wxLB_SORT style) - wxArrayString m_strings; + // wxLB_SORT style). Note the evil trick: the pointers share the + // same location, hence we use m_strings when we don't care if the + // array is sorted or not, m_stringsSorted when we do + union + { + wxArrayString* m_strings; + wxSortedArrayString* m_stringsSorted; + }; // this array contains the indices of the selected items (for the single // selection listboxes only the first element of it is used and contains @@ -290,12 +313,12 @@ public: bool toggleOnPressAlways = TRUE); // base class methods - virtual bool HandleKey(wxControl *control, + virtual bool HandleKey(wxInputConsumer *consumer, const wxKeyEvent& event, bool pressed); - virtual bool HandleMouse(wxControl *control, + virtual bool HandleMouse(wxInputConsumer *consumer, const wxMouseEvent& event); - virtual bool HandleMouseMove(wxControl *control, + virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event); protected: