1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: wx/gtk/listbox.h 3 // Purpose: wxListBox class declaration 4 // Author: Robert Roebling 5 // Id: $Id: listbox.h 51659 2008-02-11 16:03:23Z VZ $ 6 // Copyright: (c) 1998 Robert Roebling 7 // Licence: wxWindows licence 8 ///////////////////////////////////////////////////////////////////////////// 9 10 #ifndef __GTKLISTBOXH__ 11 #define __GTKLISTBOXH__ 12 13 //----------------------------------------------------------------------------- 14 // wxListBox 15 //----------------------------------------------------------------------------- 16 17 class WXDLLIMPEXP_CORE wxListBox : public wxListBoxBase 18 { 19 public: 20 // ctors and such wxListBox()21 wxListBox() 22 { 23 Init(); 24 } 25 wxListBox( wxWindow *parent, wxWindowID id, 26 const wxPoint& pos = wxDefaultPosition, 27 const wxSize& size = wxDefaultSize, 28 int n = 0, const wxString choices[] = (const wxString *) NULL, 29 long style = 0, 30 const wxValidator& validator = wxDefaultValidator, 31 const wxString& name = wxListBoxNameStr ) 32 { 33 Init(); 34 Create(parent, id, pos, size, n, choices, style, validator, name); 35 } 36 wxListBox( wxWindow *parent, wxWindowID id, 37 const wxPoint& pos, 38 const wxSize& size, 39 const wxArrayString& choices, 40 long style = 0, 41 const wxValidator& validator = wxDefaultValidator, 42 const wxString& name = wxListBoxNameStr ) 43 { 44 Init(); 45 Create(parent, id, pos, size, choices, style, validator, name); 46 } 47 virtual ~wxListBox(); 48 49 bool Create(wxWindow *parent, wxWindowID id, 50 const wxPoint& pos = wxDefaultPosition, 51 const wxSize& size = wxDefaultSize, 52 int n = 0, const wxString choices[] = (const wxString *) NULL, 53 long style = 0, 54 const wxValidator& validator = wxDefaultValidator, 55 const wxString& name = wxListBoxNameStr); 56 bool Create(wxWindow *parent, wxWindowID id, 57 const wxPoint& pos, 58 const wxSize& size, 59 const wxArrayString& choices, 60 long style = 0, 61 const wxValidator& validator = wxDefaultValidator, 62 const wxString& name = wxListBoxNameStr); 63 64 // implement base class pure virtuals 65 virtual void Clear(); 66 virtual void Delete(unsigned int n); 67 68 virtual unsigned int GetCount() const; 69 virtual wxString GetString(unsigned int n) const; 70 virtual void SetString(unsigned int n, const wxString& s); 71 virtual int FindString(const wxString& s, bool bCase = false) const; 72 73 virtual bool IsSelected(int n) const; 74 virtual int GetSelection() const; 75 virtual int GetSelections(wxArrayInt& aSelections) const; 76 77 virtual void EnsureVisible(int n); 78 79 static wxVisualAttributes 80 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); 81 82 // implementation from now on 83 84 GtkWidget *GetConnectWidget(); 85 86 #if wxUSE_TOOLTIPS 87 void ApplyToolTip( GtkTooltips *tips, const wxChar *tip ); 88 #endif // wxUSE_TOOLTIPS 89 90 struct _GtkTreeView *m_treeview; 91 struct _GtkListStore *m_liststore; 92 93 #if wxUSE_CHECKLISTBOX 94 bool m_hasCheckBoxes; 95 #endif // wxUSE_CHECKLISTBOX 96 97 bool m_blockEvent; 98 99 struct _GtkTreeEntry* GtkGetEntry(int pos) const; 100 void GtkInsertItems(const wxArrayString& items, 101 void** clientData, unsigned int pos); 102 void GtkDeselectAll(); 103 void GtkSetSelection(int n, const bool select, const bool blockEvent); 104 105 protected: 106 virtual wxSize DoGetBestSize() const; 107 virtual void DoApplyWidgetStyle(GtkRcStyle *style); 108 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; 109 110 virtual void DoSetSelection(int n, bool select); 111 virtual int DoAppend(const wxString& item); 112 virtual void DoInsertItems(const wxArrayString& items, unsigned int pos); 113 virtual void DoSetItems(const wxArrayString& items, void **clientData); 114 virtual void DoSetFirstItem(int n); 115 virtual void DoSetItemClientData(unsigned int n, void* clientData); 116 virtual void* DoGetItemClientData(unsigned int n) const; 117 virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData); 118 virtual wxClientData* DoGetItemClientObject(unsigned int n) const; 119 virtual int DoListHitTest(const wxPoint& point) const; 120 121 private: 122 void Init(); //common construction 123 124 // common part of DoSetFirstItem() and EnsureVisible() 125 void DoScrollToCell(int n, float alignY, float alignX); 126 127 DECLARE_DYNAMIC_CLASS(wxListBox) 128 }; 129 130 #endif // __GTKLISTBOXH__ 131