]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/choice.h
small makefile.vc fixes.
[wxWidgets.git] / include / wx / choice.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/choice.h
3// Purpose: wxChoice class interface
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 26.07.99
7// RCS-ID: $Id$
8// Copyright: (c) wxWindows team
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_CHOICE_H_BASE_
13#define _WX_CHOICE_H_BASE_
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19#ifdef __GNUG__
20 #pragma interface "choiccmn.h"
21#endif
22
23#include "wx/control.h" // the base class
24
25// ----------------------------------------------------------------------------
26// global data
27// ----------------------------------------------------------------------------
28
29WXDLLEXPORT_DATA(extern const wxChar*) wxChoiceNameStr;
30
31// ----------------------------------------------------------------------------
32// wxChoice allows to select one of a non-modifiable list of strings
33// ----------------------------------------------------------------------------
34
35class WXDLLEXPORT wxChoiceBase : public wxControl
36{
37public:
38 // ctor
39 wxChoiceBase() { m_clientDataItemsType = ClientData_None; }
40
41 // add a new item to the list
42 // no client data
43 void Append(const wxString& item) { DoAppend(item); }
44 // with client data which belongs to the caller
45 void Append(const wxString &item, void* clientData)
46 { DoAppend(item); SetClientData(GetCount() - 1, clientData); }
47 // with client data which will be deleted by the control
48 void Append(const wxString &item, wxClientData* clientData)
49 { DoAppend(item); SetClientObject(GetCount() - 1, clientData); }
50
51 // delete items from the list
52 // one item
53 virtual void Delete(int n) = 0;
54 // all of them
55 virtual void Clear() = 0;
56
57 // selection (at most one item may be selected in wxChoice)
58 // get the index of currently selected item or -1
59 virtual int GetSelection() const = 0;
60 // get the text of the currently selected item or empty string
61 virtual wxString GetStringSelection() const;
62
63 // set selectionto current item
64 virtual void SetSelection(int n) = 0;
65 // set selection to the current item, returns TRUE if ok
66 virtual bool SetStringSelection(const wxString& sel);
67
68 // accessors to the list of strings
69 // get the number of items in the list of strings
70 virtual int GetCount() const = 0;
71
72 // find string in the list, return wxNOT_FOUND if not found
73 virtual int FindString(const wxString& s) const = 0;
74 // get the string with the specified index
75 virtual wxString GetString(int n) const = 0;
76
77 // set/get the number of columns in the control (as they're not supporte on
78 // most platforms, they do nothing by default)
79 virtual void SetColumns(int WXUNUSED(n) = 1 ) { }
80 virtual int GetColumns() const { return 1 ; }
81
82 // client data
83 // untyped (isn't deleted by the control)
84 void SetClientData( int n, void* clientData );
85 void* GetClientData( int n ) const;
86 // typed (is owned and deleted by the control)
87 void SetClientObject( int n, wxClientData* clientData );
88 wxClientData* GetClientObject( int n ) const;
89
90 // emulate selecting the item event.GetInt() from the control
91 virtual void Command(wxCommandEvent &event);
92
93 // deprecated functions, heer for backwards compatibility only
94 int Number() const { return GetCount(); }
95
96private:
97 // pure virtuals to implement in the derived classes
98 virtual void DoAppend(const wxString& item) = 0;
99
100 virtual void DoSetClientData( int n, void* clientData ) = 0;
101 virtual void* DoGetClientData( int n ) const = 0;
102 virtual void DoSetClientObject( int n, wxClientData* clientData ) = 0;
103 virtual wxClientData* DoGetClientObject( int n ) const = 0;
104
105 // the type of the client data for the items
106 wxClientDataType m_clientDataItemsType;
107 // the above pure virtuals hide these virtuals in wxWindowBase
108 virtual void DoSetClientData(void* clientData ) { wxWindowBase::DoSetClientData(clientData); };
109 virtual void* DoGetClientData() const { return(wxWindowBase::DoGetClientData()); };
110 virtual void DoSetClientObject( wxClientData* clientData ) { wxWindowBase::DoSetClientObject(clientData); };
111 virtual wxClientData* DoGetClientObject() const { return(wxWindowBase::DoGetClientObject()); };
112};
113
114// ----------------------------------------------------------------------------
115// include the platform-dependent class definition
116// ----------------------------------------------------------------------------
117
118#if defined(__WXMSW__)
119 #include "wx/msw/choice.h"
120#elif defined(__WXMOTIF__)
121 #include "wx/motif/choice.h"
122#elif defined(__WXGTK__)
123 #include "wx/gtk/choice.h"
124#elif defined(__WXQT__)
125 #include "wx/qt/choice.h"
126#elif defined(__WXMAC__)
127 #include "wx/mac/choice.h"
128#elif defined(__WXPM__)
129 #include "wx/os2/choice.h"
130#elif defined(__WXSTUBS__)
131 #include "wx/stubs/choice.h"
132#endif
133
134#endif
135 // _WX_CHOICE_H_BASE_