]> git.saurik.com Git - wxWidgets.git/blob - include/wx/choice.h
Make storing non-trivial data in wxThreadSpecificInfo possible.
[wxWidgets.git] / include / wx / choice.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/choice.h
3 // Purpose: wxChoice class interface
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 26.07.99
7 // Copyright: (c) wxWidgets team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_CHOICE_H_BASE_
12 #define _WX_CHOICE_H_BASE_
13
14 // ----------------------------------------------------------------------------
15 // headers
16 // ----------------------------------------------------------------------------
17
18 #include "wx/defs.h"
19
20 #if wxUSE_CHOICE
21
22 #include "wx/ctrlsub.h" // the base class
23
24 // ----------------------------------------------------------------------------
25 // global data
26 // ----------------------------------------------------------------------------
27
28 extern WXDLLIMPEXP_DATA_CORE(const char) wxChoiceNameStr[];
29
30 // ----------------------------------------------------------------------------
31 // wxChoice allows to select one of a non-modifiable list of strings
32 // ----------------------------------------------------------------------------
33
34 class WXDLLIMPEXP_CORE wxChoiceBase : public wxControlWithItems
35 {
36 public:
37 wxChoiceBase() { }
38 virtual ~wxChoiceBase();
39
40 // all generic methods are in wxControlWithItems
41
42 // get the current selection: this can only be different from the normal
43 // selection if the popup items list is currently opened and the user
44 // selected some item in it but didn't close the list yet; otherwise (and
45 // currently always on platforms other than MSW) this is the same as
46 // GetSelection()
47 virtual int GetCurrentSelection() const { return GetSelection(); }
48
49 // set/get the number of columns in the control (as they're not supported on
50 // most platforms, they do nothing by default)
51 virtual void SetColumns(int WXUNUSED(n) = 1 ) { }
52 virtual int GetColumns() const { return 1 ; }
53
54 // emulate selecting the item event.GetInt()
55 void Command(wxCommandEvent& event);
56
57 // override wxItemContainer::IsSorted
58 virtual bool IsSorted() const { return HasFlag(wxCB_SORT); }
59
60 protected:
61 // The generic implementation doesn't determine the height correctly and
62 // doesn't account for the width of the arrow but does take into account
63 // the string widths, so the derived classes should override it and set the
64 // height and add the arrow width to the size returned by this version.
65 virtual wxSize DoGetBestSize() const;
66
67 private:
68 wxDECLARE_NO_COPY_CLASS(wxChoiceBase);
69 };
70
71 // ----------------------------------------------------------------------------
72 // include the platform-dependent class definition
73 // ----------------------------------------------------------------------------
74
75 #if defined(__WXUNIVERSAL__)
76 #include "wx/univ/choice.h"
77 #elif defined(__SMARTPHONE__) && defined(__WXWINCE__)
78 #include "wx/msw/wince/choicece.h"
79 #elif defined(__WXMSW__)
80 #include "wx/msw/choice.h"
81 #elif defined(__WXMOTIF__)
82 #include "wx/motif/choice.h"
83 #elif defined(__WXGTK20__)
84 #include "wx/gtk/choice.h"
85 #elif defined(__WXGTK__)
86 #include "wx/gtk1/choice.h"
87 #elif defined(__WXMAC__)
88 #include "wx/osx/choice.h"
89 #elif defined(__WXCOCOA__)
90 #include "wx/cocoa/choice.h"
91 #elif defined(__WXPM__)
92 #include "wx/os2/choice.h"
93 #endif
94
95 #endif // wxUSE_CHOICE
96
97 #endif // _WX_CHOICE_H_BASE_