]>
Commit | Line | Data |
---|---|---|
8cf73271 | 1 | ///////////////////////////////////////////////////////////////////////////// |
853dcc57 | 2 | // Name: wx/mac/carbon/listbox.h |
8cf73271 SC |
3 | // Purpose: wxListBox class |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Stefan Csomor | |
65571936 | 9 | // Licence: wxWindows licence |
8cf73271 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
8cf73271 SC |
12 | #ifndef _WX_LISTBOX_H_ |
13 | #define _WX_LISTBOX_H_ | |
14 | ||
8cf73271 SC |
15 | // ---------------------------------------------------------------------------- |
16 | // simple types | |
17 | // ---------------------------------------------------------------------------- | |
18 | #include "wx/dynarray.h" | |
19 | #include "wx/arrstr.h" | |
20 | ||
8cf73271 SC |
21 | // forward decl for GetSelections() |
22 | class wxArrayInt; | |
23 | ||
c82af6ee SC |
24 | // exposed for subclasses like wxCheckListBox |
25 | ||
26 | class wxMacListControl | |
27 | { | |
28 | public: | |
29 | virtual void MacDelete( unsigned int n ) = 0; | |
30 | virtual void MacInsert( unsigned int n, const wxString& item ) = 0; | |
31 | virtual void MacInsert( unsigned int n, const wxArrayString& items ) = 0; | |
32 | // returns index of newly created line | |
33 | virtual int MacAppend( const wxString& item ) = 0; | |
34 | virtual void MacSetString( unsigned int n, const wxString& item ) = 0; | |
35 | virtual void MacClear() = 0; | |
36 | virtual void MacDeselectAll() = 0; | |
37 | virtual void MacSetSelection( unsigned int n, bool select ) = 0; | |
38 | virtual int MacGetSelection() const = 0; | |
39 | virtual int MacGetSelections( wxArrayInt& aSelections ) const = 0; | |
40 | virtual bool MacIsSelected( unsigned int n ) const = 0; | |
41 | virtual void MacScrollTo( unsigned int n ) = 0; | |
42 | virtual wxString MacGetString( unsigned int n) const = 0; | |
43 | virtual unsigned int MacGetCount() const = 0; | |
44 | ||
45 | virtual void MacSetClientData( unsigned int n, void * data) = 0; | |
46 | virtual void * MacGetClientData( unsigned int) const = 0; | |
47 | }; | |
ba5b8a68 | 48 | |
8cf73271 SC |
49 | // List box item |
50 | ||
12cb7591 | 51 | WX_DEFINE_ARRAY( char* , wxListDataArray ); |
8cf73271 SC |
52 | |
53 | // ---------------------------------------------------------------------------- | |
54 | // List box control | |
55 | // ---------------------------------------------------------------------------- | |
56 | ||
57 | class WXDLLEXPORT wxListBox : public wxListBoxBase | |
58 | { | |
59 | public: | |
60 | // ctors and such | |
61 | wxListBox(); | |
12cb7591 DS |
62 | |
63 | wxListBox( | |
64 | wxWindow *parent, | |
c82af6ee | 65 | wxWindowID winid, |
12cb7591 DS |
66 | const wxPoint& pos = wxDefaultPosition, |
67 | const wxSize& size = wxDefaultSize, | |
68 | int n = 0, const wxString choices[] = NULL, | |
69 | long style = 0, | |
70 | const wxValidator& validator = wxDefaultValidator, | |
71 | const wxString& name = wxListBoxNameStr) | |
8cf73271 | 72 | { |
c82af6ee | 73 | Create(parent, winid, pos, size, n, choices, style, validator, name); |
8cf73271 | 74 | } |
12cb7591 DS |
75 | |
76 | wxListBox( | |
77 | wxWindow *parent, | |
c82af6ee | 78 | wxWindowID winid, |
12cb7591 DS |
79 | const wxPoint& pos, |
80 | const wxSize& size, | |
81 | const wxArrayString& choices, | |
82 | long style = 0, | |
83 | const wxValidator& validator = wxDefaultValidator, | |
84 | const wxString& name = wxListBoxNameStr) | |
8cf73271 | 85 | { |
c82af6ee | 86 | Create(parent, winid, pos, size, choices, style, validator, name); |
8cf73271 SC |
87 | } |
88 | ||
12cb7591 DS |
89 | bool Create( |
90 | wxWindow *parent, | |
c82af6ee | 91 | wxWindowID winid, |
12cb7591 DS |
92 | const wxPoint& pos = wxDefaultPosition, |
93 | const wxSize& size = wxDefaultSize, | |
94 | int n = 0, | |
95 | const wxString choices[] = NULL, | |
96 | long style = 0, | |
97 | const wxValidator& validator = wxDefaultValidator, | |
98 | const wxString& name = wxListBoxNameStr); | |
99 | ||
100 | bool Create( | |
101 | wxWindow *parent, | |
c82af6ee | 102 | wxWindowID winid, |
12cb7591 DS |
103 | const wxPoint& pos, |
104 | const wxSize& size, | |
105 | const wxArrayString& choices, | |
106 | long style = 0, | |
107 | const wxValidator& validator = wxDefaultValidator, | |
108 | const wxString& name = wxListBoxNameStr); | |
8cf73271 SC |
109 | |
110 | virtual ~wxListBox(); | |
de1b0aeb | 111 | |
8cf73271 | 112 | // implement base class pure virtuals |
12cb7591 | 113 | virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL); |
8cf73271 | 114 | virtual void Clear(); |
aa61d352 | 115 | virtual void Delete(unsigned int n); |
8cf73271 | 116 | |
aa61d352 VZ |
117 | virtual unsigned int GetCount() const; |
118 | virtual wxString GetString(unsigned int n) const; | |
119 | virtual void SetString(unsigned int n, const wxString& s); | |
853dcc57 | 120 | virtual int FindString(const wxString& s, bool bCase = false) const; |
8cf73271 SC |
121 | |
122 | virtual bool IsSelected(int n) const; | |
8cf73271 SC |
123 | virtual int GetSelection() const; |
124 | virtual int GetSelections(wxArrayInt& aSelections) const; | |
125 | ||
c82af6ee SC |
126 | virtual void EnsureVisible(int n); |
127 | ||
8cf73271 | 128 | // wxCheckListBox support |
b6a20a20 RD |
129 | static wxVisualAttributes |
130 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
12cb7591 | 131 | |
c82af6ee SC |
132 | wxMacListControl* GetPeer() const; |
133 | ||
8cf73271 | 134 | protected: |
c82af6ee | 135 | // from wxItemContainer |
6f02a879 | 136 | virtual int DoAppend(const wxString& item); |
aa61d352 VZ |
137 | virtual void DoSetItemClientData(unsigned int n, void* clientData); |
138 | virtual void* DoGetItemClientData(unsigned int n) const; | |
139 | virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData); | |
140 | virtual wxClientData* DoGetItemClientObject(unsigned int n) const; | |
c82af6ee SC |
141 | |
142 | // from wxListBoxBase | |
143 | virtual void DoSetSelection(int n, bool select); | |
144 | virtual void DoInsertItems(const wxArrayString& items, unsigned int pos); | |
145 | virtual void DoSetItems(const wxArrayString& items, void **clientData); | |
146 | virtual void DoSetFirstItem(int n); | |
c00fed0e | 147 | virtual int DoListHitTest(const wxPoint& point) const; |
6f02a879 | 148 | |
8cf73271 | 149 | // free memory (common part of Clear() and dtor) |
de1b0aeb | 150 | // prevent collision with some BSD definitions of macro Free() |
8cf73271 SC |
151 | void FreeData(); |
152 | ||
c82af6ee | 153 | virtual wxSize DoGetBestSize() const; |
8cf73271 | 154 | |
8cf73271 SC |
155 | private: |
156 | DECLARE_DYNAMIC_CLASS(wxListBox) | |
157 | DECLARE_EVENT_TABLE() | |
158 | }; | |
159 | ||
de1b0aeb | 160 | #endif // _WX_LISTBOX_H_ |