]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/listbox.h
As per wx-dev, split the sort arrow options out to a separate parameter.
[wxWidgets.git] / include / wx / gtk1 / listbox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk1/listbox.h
3 // Purpose: wxListBox class declaration
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef __GTKLISTBOXH__
11 #define __GTKLISTBOXH__
12
13 #include "wx/list.h"
14
15 class WXDLLIMPEXP_BASE wxSortedArrayString;
16
17 //-----------------------------------------------------------------------------
18 // wxListBox
19 //-----------------------------------------------------------------------------
20
21 class WXDLLIMPEXP_CORE wxListBox : public wxListBoxBase
22 {
23 public:
24 // ctors and such
25 wxListBox();
26 wxListBox( wxWindow *parent, wxWindowID id,
27 const wxPoint& pos = wxDefaultPosition,
28 const wxSize& size = wxDefaultSize,
29 int n = 0, const wxString choices[] = (const wxString *) NULL,
30 long style = 0,
31 const wxValidator& validator = wxDefaultValidator,
32 const wxString& name = wxListBoxNameStr )
33 {
34 #if wxUSE_CHECKLISTBOX
35 m_hasCheckBoxes = false;
36 #endif // wxUSE_CHECKLISTBOX
37 Create(parent, id, pos, size, n, choices, style, validator, name);
38 }
39 wxListBox( wxWindow *parent, wxWindowID id,
40 const wxPoint& pos,
41 const wxSize& size,
42 const wxArrayString& choices,
43 long style = 0,
44 const wxValidator& validator = wxDefaultValidator,
45 const wxString& name = wxListBoxNameStr )
46 {
47 #if wxUSE_CHECKLISTBOX
48 m_hasCheckBoxes = false;
49 #endif // wxUSE_CHECKLISTBOX
50 Create(parent, id, pos, size, choices, style, validator, name);
51 }
52 virtual ~wxListBox();
53
54 bool Create(wxWindow *parent, wxWindowID id,
55 const wxPoint& pos = wxDefaultPosition,
56 const wxSize& size = wxDefaultSize,
57 int n = 0, const wxString choices[] = (const wxString *) NULL,
58 long style = 0,
59 const wxValidator& validator = wxDefaultValidator,
60 const wxString& name = wxListBoxNameStr);
61 bool Create(wxWindow *parent, wxWindowID id,
62 const wxPoint& pos,
63 const wxSize& size,
64 const wxArrayString& choices,
65 long style = 0,
66 const wxValidator& validator = wxDefaultValidator,
67 const wxString& name = wxListBoxNameStr);
68
69 // implement base class pure virtuals
70 virtual void Clear();
71 virtual void Delete(unsigned int n);
72
73 virtual unsigned int GetCount() const;
74 virtual wxString GetString(unsigned int n) const;
75 virtual void SetString(unsigned int n, const wxString& s);
76 virtual int FindString(const wxString& s, bool bCase = false) const;
77
78 virtual bool IsSelected(int n) const;
79 virtual void DoSetSelection(int n, bool select);
80 virtual int GetSelection() const;
81 virtual int GetSelections(wxArrayInt& aSelections) const;
82
83 virtual int DoAppend(const wxString& item);
84 virtual void DoInsertItems(const wxArrayString& items, unsigned int pos);
85 virtual void DoSetItems(const wxArrayString& items, void **clientData);
86
87 virtual void DoSetFirstItem(int n);
88
89 virtual void DoSetItemClientData(unsigned int n, void* clientData);
90 virtual void* DoGetItemClientData(unsigned int n) const;
91 virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData);
92 virtual wxClientData* DoGetItemClientObject(unsigned int n) const;
93
94 static wxVisualAttributes
95 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
96
97 // implementation from now on
98
99 void GtkAddItem( const wxString &item, int pos=-1 );
100 int GtkGetIndex( GtkWidget *item ) const;
101 GtkWidget *GetConnectWidget();
102 bool IsOwnGtkWindow( GdkWindow *window );
103 void DoApplyWidgetStyle(GtkRcStyle *style);
104 void OnInternalIdle();
105
106 #if wxUSE_TOOLTIPS
107 void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
108 #endif // wxUSE_TOOLTIPS
109
110 GtkList *m_list;
111 wxList m_clientList;
112
113 #if wxUSE_CHECKLISTBOX
114 bool m_hasCheckBoxes;
115 #endif // wxUSE_CHECKLISTBOX
116
117 int m_prevSelection;
118 bool m_blockEvent;
119
120 virtual void FixUpMouseEvent(GtkWidget *widget, wxCoord& x, wxCoord& y);
121
122 protected:
123 virtual wxSize DoGetBestSize() const;
124
125 // return the string label for the given item
126 wxString GetRealLabel(struct _GList *item) const;
127
128 // Widgets that use the style->base colour for the BG colour should
129 // override this and return true.
130 virtual bool UseGTKStyleBase() const { return true; }
131
132 private:
133 // this array is only used for controls with wxCB_SORT style, so only
134 // allocate it if it's needed (hence using pointer)
135 wxSortedArrayString *m_strings;
136
137 DECLARE_DYNAMIC_CLASS(wxListBox)
138 };
139
140 #endif // __GTKLISTBOXH__