]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: listbox.h | |
ff8bfdbb | 3 | // Purpose: wxListBox class declaration |
c801d85f | 4 | // Author: Robert Roebling |
58614078 RR |
5 | // Id: $Id$ |
6 | // Copyright: (c) 1998 Robert Roebling | |
ff8bfdbb | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
10 | ||
11 | #ifndef __GTKLISTBOXH__ | |
12 | #define __GTKLISTBOXH__ | |
13 | ||
12028905 | 14 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
34eac3a8 | 15 | #pragma interface "listbox.h" |
c801d85f KB |
16 | #endif |
17 | ||
c801d85f | 18 | #include "wx/list.h" |
c801d85f | 19 | |
b5f6b52a MB |
20 | class WXDLLIMPEXP_BASE wxSortedArrayString; |
21 | ||
c801d85f KB |
22 | //----------------------------------------------------------------------------- |
23 | // wxListBox | |
24 | //----------------------------------------------------------------------------- | |
25 | ||
2ee3ee1b | 26 | class wxListBox : public wxListBoxBase |
c801d85f | 27 | { |
fd0eed64 | 28 | public: |
2ee3ee1b | 29 | // ctors and such |
ff8bfdbb VZ |
30 | wxListBox(); |
31 | wxListBox( wxWindow *parent, wxWindowID id, | |
32 | const wxPoint& pos = wxDefaultPosition, | |
33 | const wxSize& size = wxDefaultSize, | |
34 | int n = 0, const wxString choices[] = (const wxString *) NULL, | |
35 | long style = 0, | |
36 | const wxValidator& validator = wxDefaultValidator, | |
37 | const wxString& name = wxListBoxNameStr ) | |
38 | { | |
88ac883a | 39 | #if wxUSE_CHECKLISTBOX |
ff8bfdbb | 40 | m_hasCheckBoxes = FALSE; |
88ac883a | 41 | #endif // wxUSE_CHECKLISTBOX |
ff8bfdbb VZ |
42 | Create(parent, id, pos, size, n, choices, style, validator, name); |
43 | } | |
584ad2a3 MB |
44 | wxListBox( wxWindow *parent, wxWindowID id, |
45 | const wxPoint& pos, | |
46 | const wxSize& size, | |
47 | const wxArrayString& choices, | |
48 | long style = 0, | |
49 | const wxValidator& validator = wxDefaultValidator, | |
50 | const wxString& name = wxListBoxNameStr ) | |
51 | { | |
52 | #if wxUSE_CHECKLISTBOX | |
53 | m_hasCheckBoxes = FALSE; | |
54 | #endif // wxUSE_CHECKLISTBOX | |
55 | Create(parent, id, pos, size, choices, style, validator, name); | |
56 | } | |
ff8bfdbb VZ |
57 | virtual ~wxListBox(); |
58 | ||
59 | bool Create(wxWindow *parent, wxWindowID id, | |
60 | const wxPoint& pos = wxDefaultPosition, | |
61 | const wxSize& size = wxDefaultSize, | |
62 | int n = 0, const wxString choices[] = (const wxString *) NULL, | |
63 | long style = 0, | |
64 | const wxValidator& validator = wxDefaultValidator, | |
65 | const wxString& name = wxListBoxNameStr); | |
584ad2a3 MB |
66 | bool Create(wxWindow *parent, wxWindowID id, |
67 | const wxPoint& pos, | |
68 | const wxSize& size, | |
69 | const wxArrayString& choices, | |
70 | long style = 0, | |
71 | const wxValidator& validator = wxDefaultValidator, | |
72 | const wxString& name = wxListBoxNameStr); | |
ff8bfdbb | 73 | |
2ee3ee1b VZ |
74 | // implement base class pure virtuals |
75 | virtual void Clear(); | |
76 | virtual void Delete(int n); | |
77 | ||
78 | virtual int GetCount() const; | |
79 | virtual wxString GetString(int n) const; | |
80 | virtual void SetString(int n, const wxString& s); | |
81 | virtual int FindString(const wxString& s) const; | |
82 | ||
83 | virtual bool IsSelected(int n) const; | |
84 | virtual void SetSelection(int n, bool select = TRUE); | |
85 | virtual int GetSelection() const; | |
86 | virtual int GetSelections(wxArrayInt& aSelections) const; | |
87 | ||
88 | virtual int DoAppend(const wxString& item); | |
89 | virtual void DoInsertItems(const wxArrayString& items, int pos); | |
90 | virtual void DoSetItems(const wxArrayString& items, void **clientData); | |
91 | ||
92 | virtual void DoSetFirstItem(int n); | |
93 | ||
6c8a980f VZ |
94 | virtual void DoSetItemClientData(int n, void* clientData); |
95 | virtual void* DoGetItemClientData(int n) const; | |
96 | virtual void DoSetItemClientObject(int n, wxClientData* clientData); | |
97 | virtual wxClientData* DoGetItemClientObject(int n) const; | |
2ee3ee1b VZ |
98 | |
99 | // implementation from now on | |
c801d85f | 100 | |
11e1c70d RR |
101 | void GtkAddItem( const wxString &item, int pos=-1 ); |
102 | int GtkGetIndex( GtkWidget *item ) const; | |
ff8bfdbb VZ |
103 | GtkWidget *GetConnectWidget(); |
104 | bool IsOwnGtkWindow( GdkWindow *window ); | |
105 | void ApplyWidgetStyle(); | |
5e014a0c | 106 | void OnInternalIdle(); |
ff8bfdbb VZ |
107 | |
108 | #if wxUSE_TOOLTIPS | |
4de6207a | 109 | void ApplyToolTip( GtkTooltips *tips, const wxChar *tip ); |
ff8bfdbb VZ |
110 | #endif // wxUSE_TOOLTIPS |
111 | ||
112 | GtkList *m_list; | |
11e1c70d | 113 | wxList m_clientList; |
88ac883a VZ |
114 | |
115 | #if wxUSE_CHECKLISTBOX | |
ff8bfdbb | 116 | bool m_hasCheckBoxes; |
88ac883a | 117 | #endif // wxUSE_CHECKLISTBOX |
c801d85f | 118 | |
bac95742 RR |
119 | int m_prevSelection; |
120 | bool m_blockEvent; | |
8161b5b9 | 121 | |
3ae4c570 VZ |
122 | virtual void FixUpMouseEvent(GtkWidget *widget, wxCoord& x, wxCoord& y); |
123 | ||
f68586e5 VZ |
124 | protected: |
125 | virtual wxSize DoGetBestSize() const; | |
126 | ||
8161b5b9 VZ |
127 | // return the string label for the given item |
128 | wxString GetRealLabel(struct _GList *item) const; | |
129 | ||
2ee3ee1b VZ |
130 | private: |
131 | // this array is only used for controls with wxCB_SORT style, so only | |
132 | // allocate it if it's needed (hence using pointer) | |
133 | wxSortedArrayString *m_strings; | |
134 | ||
135 | DECLARE_DYNAMIC_CLASS(wxListBox) | |
136 | }; | |
dcf924a3 | 137 | |
c801d85f | 138 | #endif // __GTKLISTBOXH__ |