]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/gtk1/choice.h | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // Id: $Id$ | |
6 | // Copyright: (c) 1998 Robert Roebling | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifndef __GTKCHOICEH__ | |
11 | #define __GTKCHOICEH__ | |
12 | ||
13 | class WXDLLIMPEXP_FWD_BASE wxSortedArrayString; | |
14 | class WXDLLIMPEXP_FWD_BASE wxArrayString; | |
15 | ||
16 | //----------------------------------------------------------------------------- | |
17 | // wxChoice | |
18 | //----------------------------------------------------------------------------- | |
19 | ||
20 | class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase | |
21 | { | |
22 | public: | |
23 | wxChoice(); | |
24 | wxChoice( wxWindow *parent, wxWindowID id, | |
25 | const wxPoint& pos = wxDefaultPosition, | |
26 | const wxSize& size = wxDefaultSize, | |
27 | int n = 0, const wxString choices[] = (const wxString *) NULL, | |
28 | long style = 0, | |
29 | const wxValidator& validator = wxDefaultValidator, | |
30 | const wxString& name = wxChoiceNameStr ) | |
31 | { | |
32 | m_strings = NULL; | |
33 | ||
34 | Create(parent, id, pos, size, n, choices, style, validator, name); | |
35 | } | |
36 | wxChoice( wxWindow *parent, wxWindowID id, | |
37 | const wxPoint& pos, | |
38 | const wxSize& size, | |
39 | const wxArrayString& choices, | |
40 | long style = 0, | |
41 | const wxValidator& validator = wxDefaultValidator, | |
42 | const wxString& name = wxChoiceNameStr ) | |
43 | { | |
44 | m_strings = NULL; | |
45 | ||
46 | Create(parent, id, pos, size, choices, style, validator, name); | |
47 | } | |
48 | virtual ~wxChoice(); | |
49 | bool Create( wxWindow *parent, wxWindowID id, | |
50 | const wxPoint& pos = wxDefaultPosition, | |
51 | const wxSize& size = wxDefaultSize, | |
52 | int n = 0, const wxString choices[] = NULL, | |
53 | long style = 0, | |
54 | const wxValidator& validator = wxDefaultValidator, | |
55 | const wxString& name = wxChoiceNameStr ); | |
56 | bool Create( wxWindow *parent, wxWindowID id, | |
57 | const wxPoint& pos, | |
58 | const wxSize& size, | |
59 | const wxArrayString& choices, | |
60 | long style = 0, | |
61 | const wxValidator& validator = wxDefaultValidator, | |
62 | const wxString& name = wxChoiceNameStr ); | |
63 | ||
64 | // implement base class pure virtuals | |
65 | void DoDeleteOneItem(unsigned int n); | |
66 | void DoClear(); | |
67 | ||
68 | int GetSelection() const; | |
69 | virtual void SetSelection(int n); | |
70 | ||
71 | virtual unsigned int GetCount() const; | |
72 | virtual int FindString(const wxString& s, bool bCase = false) const; | |
73 | virtual wxString GetString(unsigned int n) const; | |
74 | virtual void SetString(unsigned int n, const wxString& string); | |
75 | ||
76 | static wxVisualAttributes | |
77 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
78 | ||
79 | protected: | |
80 | wxList m_clientList; // contains the client data for the items | |
81 | ||
82 | void DoApplyWidgetStyle(GtkRcStyle *style); | |
83 | virtual int DoInsertItems(const wxArrayStringsAdapter& items, | |
84 | unsigned int pos, | |
85 | void **clientData, wxClientDataType type); | |
86 | ||
87 | virtual void DoSetItemClientData(unsigned int n, void* clientData); | |
88 | virtual void* DoGetItemClientData(unsigned int n) const; | |
89 | ||
90 | virtual wxSize DoGetBestSize() const; | |
91 | ||
92 | virtual bool IsOwnGtkWindow( GdkWindow *window ); | |
93 | ||
94 | private: | |
95 | // DoInsertItems() helper | |
96 | int GtkAddHelper(GtkWidget *menu, unsigned int pos, const wxString& item); | |
97 | ||
98 | // this array is only used for controls with wxCB_SORT style, so only | |
99 | // allocate it if it's needed (hence using pointer) | |
100 | wxSortedArrayString *m_strings; | |
101 | ||
102 | public: | |
103 | // this circumvents a GTK+ 2.0 bug so that the selection is | |
104 | // invalidated properly | |
105 | int m_selection_hack; | |
106 | ||
107 | private: | |
108 | DECLARE_DYNAMIC_CLASS(wxChoice) | |
109 | }; | |
110 | ||
111 | ||
112 | #endif // __GTKCHOICEH__ |