]> git.saurik.com Git - wxWidgets.git/blame - include/wx/choice.h
SetIcon added
[wxWidgets.git] / include / wx / choice.h
CommitLineData
8d99be5f
VZ
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
34138703
JS
12#ifndef _WX_CHOICE_H_BASE_
13#define _WX_CHOICE_H_BASE_
c801d85f 14
8d99be5f
VZ
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19#ifdef __GNUG__
a3015c54 20 #pragma interface "choiccmn.h"
8d99be5f
VZ
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};
108
109// ----------------------------------------------------------------------------
110// include the platform-dependent class definition
111// ----------------------------------------------------------------------------
112
2049ba38 113#if defined(__WXMSW__)
8d99be5f 114 #include "wx/msw/choice.h"
2049ba38 115#elif defined(__WXMOTIF__)
8d99be5f 116 #include "wx/motif/choice.h"
2049ba38 117#elif defined(__WXGTK__)
8d99be5f 118 #include "wx/gtk/choice.h"
b4e76e0d 119#elif defined(__WXQT__)
8d99be5f 120 #include "wx/qt/choice.h"
34138703 121#elif defined(__WXMAC__)
8d99be5f 122 #include "wx/mac/choice.h"
1777b9bb
DW
123#elif defined(__WXPM__)
124 #include "wx/os2/choice.h"
34138703 125#elif defined(__WXSTUBS__)
8d99be5f 126 #include "wx/stubs/choice.h"
c801d85f
KB
127#endif
128
129#endif
34138703 130 // _WX_CHOICE_H_BASE_