1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/listbox.h
3 // Purpose: wxListBox class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_LISTBOX_H_
13 #define _WX_LISTBOX_H_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
18 #include "wx/dynarray.h"
19 #include "wx/arrstr.h"
21 // forward decl for GetSelections()
26 WX_DEFINE_ARRAY( char * , wxListDataArray
) ;
28 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 class WXDLLEXPORT wxListBox
: public wxListBoxBase
37 wxListBox(wxWindow
*parent
, wxWindowID id
,
38 const wxPoint
& pos
= wxDefaultPosition
,
39 const wxSize
& size
= wxDefaultSize
,
40 int n
= 0, const wxString choices
[] = NULL
,
42 const wxValidator
& validator
= wxDefaultValidator
,
43 const wxString
& name
= wxListBoxNameStr
)
45 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
47 wxListBox(wxWindow
*parent
, wxWindowID id
,
50 const wxArrayString
& choices
,
52 const wxValidator
& validator
= wxDefaultValidator
,
53 const wxString
& name
= wxListBoxNameStr
)
55 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
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
,
63 const wxValidator
& validator
= wxDefaultValidator
,
64 const wxString
& name
= wxListBoxNameStr
);
65 bool Create(wxWindow
*parent
, wxWindowID id
,
68 const wxArrayString
& choices
,
70 const wxValidator
& validator
= wxDefaultValidator
,
71 const wxString
& name
= wxListBoxNameStr
);
74 virtual void Refresh(bool eraseBack
= true, const wxRect
*rect
= NULL
);
76 // implement base class pure virtuals
78 virtual void Delete(unsigned int n
);
80 virtual unsigned int GetCount() const;
81 virtual wxString
GetString(unsigned int n
) const;
82 virtual void SetString(unsigned int n
, const wxString
& s
);
83 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
85 virtual bool IsSelected(int n
) const;
86 virtual int GetSelection() const;
87 virtual int GetSelections(wxArrayInt
& aSelections
) const;
89 // wxCheckListBox support
90 static wxVisualAttributes
91 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
95 void OnChar(wxKeyEvent
& event
);
99 wxArrayString m_stringArray
;
100 wxListDataArray m_dataArray
;
102 // as we are getting the same events for human and API selection we have to suppress
103 // events in the latter case
104 bool MacIsSelectionSuppressed() const { return m_suppressSelection
; }
106 virtual void DoSetSelection(int n
, bool select
);
107 virtual int DoAppend(const wxString
& item
);
108 virtual void DoInsertItems(const wxArrayString
& items
, unsigned int pos
);
109 virtual void DoSetItems(const wxArrayString
& items
, void **clientData
);
110 virtual void DoSetFirstItem(int n
);
111 virtual void DoSetItemClientData(unsigned int n
, void* clientData
);
112 virtual void* DoGetItemClientData(unsigned int n
) const;
113 virtual void DoSetItemClientObject(unsigned int n
, wxClientData
* clientData
);
114 virtual wxClientData
* DoGetItemClientObject(unsigned int n
) const;
115 virtual void DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
116 virtual int DoListHitTest(const wxPoint
& point
) const;
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
) ;
123 void MacDeselectAll() ;
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
) ;
129 bool MacSuppressSelection( bool suppress
) ;
131 // free memory (common part of Clear() and dtor)
132 // prevent collision with some BSD definitions of macro Free()
135 unsigned int m_noItems
;
137 bool m_suppressSelection
;
141 virtual wxSize
DoGetBestSize() const;
144 DECLARE_DYNAMIC_CLASS(wxListBox
)
145 DECLARE_EVENT_TABLE()
148 #endif // _WX_LISTBOX_H_