]>
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 | ||
24 | // List box item | |
25 | ||
26 | WX_DEFINE_ARRAY( char * , wxListDataArray ) ; | |
27 | ||
28 | // ---------------------------------------------------------------------------- | |
29 | // List box control | |
30 | // ---------------------------------------------------------------------------- | |
31 | ||
32 | class WXDLLEXPORT wxListBox : public wxListBoxBase | |
33 | { | |
34 | public: | |
35 | // ctors and such | |
36 | wxListBox(); | |
37 | wxListBox(wxWindow *parent, wxWindowID id, | |
38 | const wxPoint& pos = wxDefaultPosition, | |
39 | const wxSize& size = wxDefaultSize, | |
40 | int n = 0, const wxString choices[] = NULL, | |
41 | long style = 0, | |
42 | const wxValidator& validator = wxDefaultValidator, | |
43 | const wxString& name = wxListBoxNameStr) | |
44 | { | |
45 | Create(parent, id, pos, size, n, choices, style, validator, name); | |
46 | } | |
47 | wxListBox(wxWindow *parent, wxWindowID id, | |
48 | const wxPoint& pos, | |
49 | const wxSize& size, | |
50 | const wxArrayString& choices, | |
51 | long style = 0, | |
52 | const wxValidator& validator = wxDefaultValidator, | |
53 | const wxString& name = wxListBoxNameStr) | |
54 | { | |
55 | Create(parent, id, pos, size, choices, style, validator, name); | |
56 | } | |
57 | ||
58 | bool Create(wxWindow *parent, wxWindowID id, | |
59 | const wxPoint& pos = wxDefaultPosition, | |
60 | const wxSize& size = wxDefaultSize, | |
61 | int n = 0, const wxString choices[] = NULL, | |
62 | long style = 0, | |
63 | const wxValidator& validator = wxDefaultValidator, | |
64 | const wxString& name = wxListBoxNameStr); | |
65 | bool Create(wxWindow *parent, wxWindowID id, | |
66 | const wxPoint& pos, | |
67 | const wxSize& size, | |
68 | const wxArrayString& choices, | |
69 | long style = 0, | |
70 | const wxValidator& validator = wxDefaultValidator, | |
71 | const wxString& name = wxListBoxNameStr); | |
72 | ||
73 | virtual ~wxListBox(); | |
8228b893 | 74 | virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL); |
de1b0aeb | 75 | |
8cf73271 SC |
76 | // implement base class pure virtuals |
77 | virtual void Clear(); | |
78 | virtual void Delete(int n); | |
79 | ||
8228b893 | 80 | virtual size_t GetCount() const; |
8cf73271 SC |
81 | virtual wxString GetString(int n) const; |
82 | virtual void SetString(int n, const wxString& s); | |
853dcc57 | 83 | virtual int FindString(const wxString& s, bool bCase = false) const; |
8cf73271 SC |
84 | |
85 | virtual bool IsSelected(int n) const; | |
8cf73271 SC |
86 | virtual int GetSelection() const; |
87 | virtual int GetSelections(wxArrayInt& aSelections) const; | |
88 | ||
8cf73271 | 89 | // wxCheckListBox support |
b6a20a20 RD |
90 | static wxVisualAttributes |
91 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
de1b0aeb | 92 | |
8cf73271 | 93 | // Windows callbacks |
ca80fdee | 94 | #ifndef __WXMAC_OSX__ |
8cf73271 | 95 | void OnChar(wxKeyEvent& event); |
366e4202 | 96 | #endif |
8cf73271 SC |
97 | |
98 | void* m_macList ; | |
99 | wxArrayString m_stringArray ; | |
100 | wxListDataArray m_dataArray ; | |
de1b0aeb | 101 | |
fe3dc505 SC |
102 | // as we are getting the same events for human and API selection we have to suppress |
103 | // events in the latter case | |
de1b0aeb | 104 | bool MacIsSelectionSuppressed() const { return m_suppressSelection ; } |
8cf73271 | 105 | protected: |
6f02a879 VZ |
106 | virtual void DoSetSelection(int n, bool select); |
107 | virtual int DoAppend(const wxString& item); | |
108 | virtual void DoInsertItems(const wxArrayString& items, int pos); | |
109 | virtual void DoSetItems(const wxArrayString& items, void **clientData); | |
110 | virtual void DoSetFirstItem(int n); | |
111 | virtual void DoSetItemClientData(int n, void* clientData); | |
112 | virtual void* DoGetItemClientData(int n) const; | |
113 | virtual void DoSetItemClientObject(int n, wxClientData* clientData); | |
114 | virtual wxClientData* DoGetItemClientObject(int n) const; | |
115 | virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); | |
c00fed0e | 116 | virtual int DoListHitTest(const wxPoint& point) const; |
6f02a879 | 117 | |
8cf73271 SC |
118 | void MacDelete( int n ) ; |
119 | void MacInsert( int n , const wxString& item) ; | |
120 | void MacAppend( const wxString& item) ; | |
121 | void MacSet( int n , const wxString& item ) ; | |
122 | void MacClear() ; | |
fe3dc505 | 123 | void MacDeselectAll() ; |
8cf73271 SC |
124 | void MacSetSelection( int n , bool select ) ; |
125 | int MacGetSelection() const ; | |
126 | int MacGetSelections(wxArrayInt& aSelections) const ; | |
127 | bool MacIsSelected( int n ) const ; | |
128 | void MacScrollTo( int n ) ; | |
de1b0aeb | 129 | bool MacSuppressSelection( bool suppress ) ; |
8cf73271 SC |
130 | |
131 | // free memory (common part of Clear() and dtor) | |
de1b0aeb | 132 | // prevent collision with some BSD definitions of macro Free() |
8cf73271 SC |
133 | void FreeData(); |
134 | ||
8228b893 | 135 | size_t m_noItems; |
8cf73271 | 136 | int m_selected; |
fe3dc505 | 137 | bool m_suppressSelection ; |
8cf73271 SC |
138 | wxString m_typeIn ; |
139 | long m_lastTypeIn ; | |
140 | ||
141 | virtual wxSize DoGetBestSize() const; | |
142 | ||
8cf73271 SC |
143 | private: |
144 | DECLARE_DYNAMIC_CLASS(wxListBox) | |
145 | DECLARE_EVENT_TABLE() | |
146 | }; | |
147 | ||
de1b0aeb | 148 | #endif // _WX_LISTBOX_H_ |