]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/listbox.h
added some trivial macros for exception handling
[wxWidgets.git] / include / wx / mac / listbox.h
CommitLineData
0dbd6262
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: listbox.h
3// Purpose: wxListBox class
a31a5f85 4// Author: Stefan Csomor
0dbd6262 5// Modified by:
a31a5f85 6// Created: 1998-01-01
0dbd6262 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
e40298d5 9// Licence: wxWindows licence
0dbd6262
SC
10/////////////////////////////////////////////////////////////////////////////
11
e7549107 12
0dbd6262
SC
13#ifndef _WX_LISTBOX_H_
14#define _WX_LISTBOX_H_
15
12028905 16#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
e7549107 17 #pragma interface "listbox.h"
0dbd6262
SC
18#endif
19
e7549107
SC
20// ----------------------------------------------------------------------------
21// simple types
22// ----------------------------------------------------------------------------
ed39ff57
MB
23#include "wx/dynarray.h"
24
0dbd6262 25
e7549107
SC
26#if wxUSE_OWNER_DRAWN
27 class WXDLLEXPORT wxOwnerDrawn;
0dbd6262 28
e7549107 29 // define the array of list box items
cba5db5f 30 #include "wx/dynarray.h"
0dbd6262 31
e7549107
SC
32 WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray);
33#endif // wxUSE_OWNER_DRAWN
34
35// forward decl for GetSelections()
36class wxArrayInt;
0dbd6262
SC
37
38// List box item
519cb848
SC
39
40WX_DEFINE_ARRAY( char * , wxListDataArray ) ;
41
e7549107
SC
42// ----------------------------------------------------------------------------
43// List box control
44// ----------------------------------------------------------------------------
45
46class WXDLLEXPORT wxListBox : public wxListBoxBase
0dbd6262 47{
e7549107
SC
48public:
49 // ctors and such
50 wxListBox();
51 wxListBox(wxWindow *parent, wxWindowID id,
52 const wxPoint& pos = wxDefaultPosition,
53 const wxSize& size = wxDefaultSize,
54 int n = 0, const wxString choices[] = NULL,
55 long style = 0,
56 const wxValidator& validator = wxDefaultValidator,
57 const wxString& name = wxListBoxNameStr)
58 {
59 Create(parent, id, pos, size, n, choices, style, validator, name);
60 }
61
62 bool Create(wxWindow *parent, wxWindowID id,
63 const wxPoint& pos = wxDefaultPosition,
64 const wxSize& size = wxDefaultSize,
65 int n = 0, const wxString choices[] = NULL,
66 long style = 0,
67 const wxValidator& validator = wxDefaultValidator,
68 const wxString& name = wxListBoxNameStr);
69
70 virtual ~wxListBox();
60149370
GD
71 virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL);
72
e7549107
SC
73 // implement base class pure virtuals
74 virtual void Clear();
75 virtual void Delete(int n);
76
77 virtual int GetCount() const;
78 virtual wxString GetString(int n) const;
79 virtual void SetString(int n, const wxString& s);
80 virtual int FindString(const wxString& s) const;
81
82 virtual bool IsSelected(int n) const;
83 virtual void SetSelection(int n, bool select = TRUE);
84 virtual int GetSelection() const;
85 virtual int GetSelections(wxArrayInt& aSelections) const;
86
87 virtual int DoAppend(const wxString& item);
88 virtual void DoInsertItems(const wxArrayString& items, int pos);
89 virtual void DoSetItems(const wxArrayString& items, void **clientData);
90
91 virtual void DoSetFirstItem(int n);
92
93 virtual void DoSetItemClientData(int n, void* clientData);
94 virtual void* DoGetItemClientData(int n) const;
95 virtual void DoSetItemClientObject(int n, wxClientData* clientData);
96 virtual wxClientData* DoGetItemClientObject(int n) const;
e40298d5 97 virtual void DoSetSize(int x, int y,int width, int height,int sizeFlags = wxSIZE_AUTO ) ;
e7549107
SC
98
99 // wxCheckListBox support
100#if wxUSE_OWNER_DRAWN
101 // plug-in for derived classes
102 virtual wxOwnerDrawn *CreateItem(size_t n);
103
104 // allows to get the item and use SetXXX functions to set it's appearance
105 wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
106
107 // get the index of the given item
108 int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
109#endif // wxUSE_OWNER_DRAWN
110
e7549107
SC
111 // Windows callbacks
112
d84afea9 113 virtual void SetupColours();
69b85ca4 114 virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
e40298d5 115 virtual bool MacCanFocus() const { return true ; }
5fcf715b 116 void OnChar(wxKeyEvent& event);
e7549107 117
d84afea9
GD
118 void* m_macList ;
119 wxArrayString m_stringArray ;
120 wxListDataArray m_dataArray ;
121 wxArrayInt m_selectionPreImage ;
122 void MacSetRedraw( bool doDraw ) ;
e7549107 123protected:
d84afea9
GD
124 void MacDestroy() ;
125 void MacDelete( int n ) ;
c4e41ce3
SC
126 void MacInsert( int n , const wxString& item) ;
127 void MacAppend( const wxString& item) ;
128 void MacSet( int n , const wxString& item ) ;
d84afea9
GD
129 void MacClear() ;
130 void MacSetSelection( int n , bool select ) ;
131 int MacGetSelection() const ;
132 int MacGetSelections(wxArrayInt& aSelections) const ;
133 bool MacIsSelected( int n ) const ;
134 void MacScrollTo( int n ) ;
135 void OnSize( const wxSizeEvent &size ) ;
136 void MacDoClick() ;
137 void MacDoDoubleClick() ;
519cb848 138
e7549107
SC
139 // do we have multiple selections?
140 bool HasMultipleSelection() const;
141
142 // free memory (common part of Clear() and dtor)
4b651a46
GD
143 // prevent collision with some BSD definitions of macro Free()
144 void FreeData();
e7549107
SC
145
146 int m_noItems;
147 int m_selected;
e40298d5
JS
148 wxString m_typeIn ;
149 long m_lastTypeIn ;
e7549107 150
05adb9d2 151 virtual wxSize DoGetBestSize() const;
e7549107
SC
152
153#if wxUSE_OWNER_DRAWN
154 // control items
155 wxListBoxItemsArray m_aItems;
156#endif
157
158private:
159 DECLARE_DYNAMIC_CLASS(wxListBox)
d84afea9 160 DECLARE_EVENT_TABLE()
0dbd6262
SC
161};
162
163#endif
164 // _WX_LISTBOX_H_