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