]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/mac/carbon/listbox.h
added wx_truncate_cast and use it (sometimes instead of wx_static_cast) to explicitel...
[wxWidgets.git] / include / wx / mac / carbon / listbox.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: listbox.h
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
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12
13#ifndef _WX_LISTBOX_H_
14#define _WX_LISTBOX_H_
15
16#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
17 #pragma interface "listbox.h"
18#endif
19
20// ----------------------------------------------------------------------------
21// simple types
22// ----------------------------------------------------------------------------
23#include "wx/dynarray.h"
24#include "wx/arrstr.h"
25
26// forward decl for GetSelections()
27class wxArrayInt;
28
29// List box item
30
31WX_DEFINE_ARRAY( char * , wxListDataArray ) ;
32
33// ----------------------------------------------------------------------------
34// List box control
35// ----------------------------------------------------------------------------
36
37class WXDLLEXPORT wxListBox : public wxListBoxBase
38{
39public:
40 // ctors and such
41 wxListBox();
42 wxListBox(wxWindow *parent, wxWindowID id,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 int n = 0, const wxString choices[] = NULL,
46 long style = 0,
47 const wxValidator& validator = wxDefaultValidator,
48 const wxString& name = wxListBoxNameStr)
49 {
50 Create(parent, id, pos, size, n, choices, style, validator, name);
51 }
52 wxListBox(wxWindow *parent, wxWindowID id,
53 const wxPoint& pos,
54 const wxSize& size,
55 const wxArrayString& choices,
56 long style = 0,
57 const wxValidator& validator = wxDefaultValidator,
58 const wxString& name = wxListBoxNameStr)
59 {
60 Create(parent, id, pos, size, choices, style, validator, name);
61 }
62
63 bool Create(wxWindow *parent, wxWindowID id,
64 const wxPoint& pos = wxDefaultPosition,
65 const wxSize& size = wxDefaultSize,
66 int n = 0, const wxString choices[] = NULL,
67 long style = 0,
68 const wxValidator& validator = wxDefaultValidator,
69 const wxString& name = wxListBoxNameStr);
70 bool Create(wxWindow *parent, wxWindowID id,
71 const wxPoint& pos,
72 const wxSize& size,
73 const wxArrayString& choices,
74 long style = 0,
75 const wxValidator& validator = wxDefaultValidator,
76 const wxString& name = wxListBoxNameStr);
77
78 virtual ~wxListBox();
79 virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL);
80
81 // implement base class pure virtuals
82 virtual void Clear();
83 virtual void Delete(int n);
84
85 virtual int GetCount() const;
86 virtual wxString GetString(int n) const;
87 virtual void SetString(int n, const wxString& s);
88 virtual int FindString(const wxString& s) const;
89
90 virtual bool IsSelected(int n) const;
91 virtual void DoSetSelection(int n, bool select);
92 virtual int GetSelection() const;
93 virtual int GetSelections(wxArrayInt& aSelections) const;
94
95 virtual int DoAppend(const wxString& item);
96 virtual void DoInsertItems(const wxArrayString& items, int pos);
97 virtual void DoSetItems(const wxArrayString& items, void **clientData);
98
99 virtual void DoSetFirstItem(int n);
100
101 virtual void DoSetItemClientData(int n, void* clientData);
102 virtual void* DoGetItemClientData(int n) const;
103 virtual void DoSetItemClientObject(int n, wxClientData* clientData);
104 virtual wxClientData* DoGetItemClientObject(int n) const;
105 virtual void DoSetSize(int x, int y,int width, int height,int sizeFlags = wxSIZE_AUTO ) ;
106
107 // wxCheckListBox support
108 static wxVisualAttributes
109 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
110
111 // Windows callbacks
112#ifndef __WXMAC_OSX__
113 void OnChar(wxKeyEvent& event);
114#endif
115
116 void* m_macList ;
117 wxArrayString m_stringArray ;
118 wxListDataArray m_dataArray ;
119
120 // as we are getting the same events for human and API selection we have to suppress
121 // events in the latter case
122 bool MacIsSelectionSuppressed() const { return m_suppressSelection ; }
123protected:
124 void MacDelete( int n ) ;
125 void MacInsert( int n , const wxString& item) ;
126 void MacAppend( const wxString& item) ;
127 void MacSet( int n , const wxString& item ) ;
128 void MacClear() ;
129 void MacDeselectAll() ;
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 bool MacSuppressSelection( bool suppress ) ;
136
137 // free memory (common part of Clear() and dtor)
138 // prevent collision with some BSD definitions of macro Free()
139 void FreeData();
140
141 int m_noItems;
142 int m_selected;
143 bool m_suppressSelection ;
144 wxString m_typeIn ;
145 long m_lastTypeIn ;
146
147 virtual wxSize DoGetBestSize() const;
148
149private:
150 DECLARE_DYNAMIC_CLASS(wxListBox)
151 DECLARE_EVENT_TABLE()
152};
153
154#endif // _WX_LISTBOX_H_