]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/listbox.h
added wxRect::GetTopRight/BottomLeft() for consistency with the existing GetTopLeft...
[wxWidgets.git] / include / wx / mac / carbon / listbox.h
CommitLineData
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()
22class wxArrayInt;
23
c82af6ee
SC
24// exposed for subclasses like wxCheckListBox
25
26class wxMacListControl
27{
28public:
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;
54933611 44
c82af6ee
SC
45 virtual void MacSetClientData( unsigned int n, void * data) = 0;
46 virtual void * MacGetClientData( unsigned int) const = 0;
54933611 47
7c2b7791 48 virtual ~wxMacListControl() { }
c82af6ee 49};
ba5b8a68 50
8cf73271
SC
51// List box item
52
12cb7591 53WX_DEFINE_ARRAY( char* , wxListDataArray );
8cf73271
SC
54
55// ----------------------------------------------------------------------------
56// List box control
57// ----------------------------------------------------------------------------
58
59class WXDLLEXPORT wxListBox : public wxListBoxBase
60{
61public:
62 // ctors and such
63 wxListBox();
12cb7591
DS
64
65 wxListBox(
66 wxWindow *parent,
c82af6ee 67 wxWindowID winid,
12cb7591
DS
68 const wxPoint& pos = wxDefaultPosition,
69 const wxSize& size = wxDefaultSize,
70 int n = 0, const wxString choices[] = NULL,
71 long style = 0,
72 const wxValidator& validator = wxDefaultValidator,
73 const wxString& name = wxListBoxNameStr)
8cf73271 74 {
c82af6ee 75 Create(parent, winid, pos, size, n, choices, style, validator, name);
8cf73271 76 }
12cb7591
DS
77
78 wxListBox(
79 wxWindow *parent,
c82af6ee 80 wxWindowID winid,
12cb7591
DS
81 const wxPoint& pos,
82 const wxSize& size,
83 const wxArrayString& choices,
84 long style = 0,
85 const wxValidator& validator = wxDefaultValidator,
86 const wxString& name = wxListBoxNameStr)
8cf73271 87 {
c82af6ee 88 Create(parent, winid, pos, size, choices, style, validator, name);
8cf73271
SC
89 }
90
12cb7591
DS
91 bool Create(
92 wxWindow *parent,
c82af6ee 93 wxWindowID winid,
12cb7591
DS
94 const wxPoint& pos = wxDefaultPosition,
95 const wxSize& size = wxDefaultSize,
96 int n = 0,
97 const wxString choices[] = NULL,
98 long style = 0,
99 const wxValidator& validator = wxDefaultValidator,
100 const wxString& name = wxListBoxNameStr);
101
102 bool Create(
103 wxWindow *parent,
c82af6ee 104 wxWindowID winid,
12cb7591
DS
105 const wxPoint& pos,
106 const wxSize& size,
107 const wxArrayString& choices,
108 long style = 0,
109 const wxValidator& validator = wxDefaultValidator,
110 const wxString& name = wxListBoxNameStr);
8cf73271
SC
111
112 virtual ~wxListBox();
de1b0aeb 113
8cf73271 114 // implement base class pure virtuals
12cb7591 115 virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL);
8cf73271 116 virtual void Clear();
aa61d352 117 virtual void Delete(unsigned int n);
8cf73271 118
aa61d352
VZ
119 virtual unsigned int GetCount() const;
120 virtual wxString GetString(unsigned int n) const;
121 virtual void SetString(unsigned int n, const wxString& s);
853dcc57 122 virtual int FindString(const wxString& s, bool bCase = false) const;
8cf73271
SC
123
124 virtual bool IsSelected(int n) const;
8cf73271
SC
125 virtual int GetSelection() const;
126 virtual int GetSelections(wxArrayInt& aSelections) const;
127
c82af6ee
SC
128 virtual void EnsureVisible(int n);
129
8cf73271 130 // wxCheckListBox support
b6a20a20
RD
131 static wxVisualAttributes
132 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
54933611 133
c82af6ee
SC
134 wxMacListControl* GetPeer() const;
135
8cf73271 136protected:
54933611 137 // from wxItemContainer
6f02a879 138 virtual int DoAppend(const wxString& item);
aa61d352
VZ
139 virtual void DoSetItemClientData(unsigned int n, void* clientData);
140 virtual void* DoGetItemClientData(unsigned int n) const;
141 virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData);
142 virtual wxClientData* DoGetItemClientObject(unsigned int n) const;
c82af6ee
SC
143
144 // from wxListBoxBase
145 virtual void DoSetSelection(int n, bool select);
146 virtual void DoInsertItems(const wxArrayString& items, unsigned int pos);
147 virtual void DoSetItems(const wxArrayString& items, void **clientData);
148 virtual void DoSetFirstItem(int n);
c00fed0e 149 virtual int DoListHitTest(const wxPoint& point) const;
6f02a879 150
8cf73271 151 // free memory (common part of Clear() and dtor)
de1b0aeb 152 // prevent collision with some BSD definitions of macro Free()
8cf73271
SC
153 void FreeData();
154
c82af6ee 155 virtual wxSize DoGetBestSize() const;
8cf73271 156
8cf73271
SC
157private:
158 DECLARE_DYNAMIC_CLASS(wxListBox)
159 DECLARE_EVENT_TABLE()
160};
161
de1b0aeb 162#endif // _WX_LISTBOX_H_