X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/afe1376994794ee99b2906c30318c8ea53f7b8ec..a4535b9f391bbe8453f70784bc77a06f3426e858:/include/wx/univ/listbox.h diff --git a/include/wx/univ/listbox.h b/include/wx/univ/listbox.h index 6ab126f1de..a5ef8d0d87 100644 --- a/include/wx/univ/listbox.h +++ b/include/wx/univ/listbox.h @@ -96,35 +96,37 @@ public: const wxString& name = wxListBoxNameStr); // implement the listbox interface defined by wxListBoxBase - virtual void Clear(); - virtual void Delete(int n); + virtual void DoClear(); + virtual void DoDeleteOneItem(unsigned int n); - virtual int GetCount() const - { return (int)m_strings->GetCount(); } - virtual wxString GetString(int n) const + virtual unsigned int GetCount() const + { return (unsigned int)m_strings->GetCount(); } + virtual wxString GetString(unsigned int n) const { return m_strings->Item(n); } - virtual void SetString(int n, const wxString& s); + virtual void SetString(unsigned int n, const wxString& s); virtual int FindString(const wxString& s, bool bCase = false) const { return m_strings->Index(s, bCase); } virtual bool IsSelected(int n) const { return m_selections.Index(n) != wxNOT_FOUND; } - virtual void DoSetSelection(int n, bool select); virtual int GetSelection() const; virtual int GetSelections(wxArrayInt& aSelections) const; protected: - virtual int DoAppendOnly(const wxString& item); - virtual int DoAppend(const wxString& item); - virtual void DoInsertItems(const wxArrayString& items, int pos); - virtual void DoSetItems(const wxArrayString& items, void **clientData); + virtual void DoSetSelection(int n, bool select); + + virtual int DoInsertItems(const wxArrayStringsAdapter& items, + unsigned int pos, + void **clientData, + wxClientDataType type); + + // universal wxComboBox implementation internally uses wxListBox + friend class WXDLLEXPORT wxComboBox; virtual void DoSetFirstItem(int n); - virtual void DoSetItemClientData(int n, void* clientData); - virtual void* DoGetItemClientData(int n) const; - virtual void DoSetItemClientObject(int n, wxClientData* clientData); - virtual wxClientData* DoGetItemClientObject(int n) const; + virtual void DoSetItemClientData(unsigned int n, void* clientData); + virtual void* DoGetItemClientData(unsigned int n) const; public: // override some more base class methods @@ -183,6 +185,12 @@ public: long numArg = 0l, const wxString& strArg = wxEmptyString); + static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef); + virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef) + { + return GetStdInputHandler(handlerDef); + } + // idle processing virtual void OnInternalIdle(); @@ -196,15 +204,17 @@ protected: virtual void DoDraw(wxControlRenderer *renderer); virtual wxBorder GetDefaultBorder() const; + // special hook for wxCheckListBox which allows it to update its internal + // data when a new item is inserted into the listbox + virtual void OnItemInserted(unsigned int WXUNUSED(pos)) { } + + // common part of all ctors void Init(); // event handlers void OnSize(wxSizeEvent& event); - // common part of Clear() and DoSetItems(): clears everything - virtual void DoClear(); - // refresh the given item(s) or everything void RefreshItems(int from, int count); void RefreshItem(int n); @@ -291,60 +301,4 @@ private: DECLARE_DYNAMIC_CLASS(wxListBox) }; -// ---------------------------------------------------------------------------- -// wxStdListboxInputHandler: handles mouse and kbd in a single or multi -// selection listbox -// ---------------------------------------------------------------------------- - -class WXDLLEXPORT wxStdListboxInputHandler : public wxStdInputHandler -{ -public: - // if pressing the mouse button in a multiselection listbox should toggle - // the item under mouse immediately, then specify true as the second - // parameter (this is the standard behaviour, under GTK the item is toggled - // only when the mouse is released in the multi selection listbox) - wxStdListboxInputHandler(wxInputHandler *inphand, - bool toggleOnPressAlways = true); - - // base class methods - virtual bool HandleKey(wxInputConsumer *consumer, - const wxKeyEvent& event, - bool pressed); - virtual bool HandleMouse(wxInputConsumer *consumer, - const wxMouseEvent& event); - virtual bool HandleMouseMove(wxInputConsumer *consumer, - const wxMouseEvent& event); - -protected: - // return the item under mouse, 0 if the mouse is above the listbox or - // GetCount() if it is below it - int HitTest(const wxListBox *listbox, const wxMouseEvent& event); - - // parts of HitTest(): first finds the pseudo (because not in range) index - // of the item and the second one adjusts it if necessary - that is if the - // third one returns false - int HitTestUnsafe(const wxListBox *listbox, const wxMouseEvent& event); - int FixItemIndex(const wxListBox *listbox, int item); - bool IsValidIndex(const wxListBox *listbox, int item); - - // init m_btnCapture and m_actionMouse - wxControlAction SetupCapture(wxListBox *lbox, - const wxMouseEvent& event, - int item); - - wxRenderer *m_renderer; - - // the button which initiated the mouse capture (currently 0 or 1) - int m_btnCapture; - - // the action to perform when the mouse moves while we capture it - wxControlAction m_actionMouse; - - // the ctor parameter toggleOnPressAlways (see comments near it) - bool m_toggleOnPressAlways; - - // do we track the mouse outside the window when it is captured? - bool m_trackMouseOutside; -}; - #endif // _WX_UNIV_LISTBOX_H_