]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: choice.h | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
dbf858b5 | 5 | // Id: $Id$ |
01111366 | 6 | // Copyright: (c) 1998 Robert Roebling |
65571936 | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
c801d85f KB |
10 | #ifndef __GTKCHOICEH__ |
11 | #define __GTKCHOICEH__ | |
12 | ||
12028905 | 13 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
9abe166a | 14 | #pragma interface "choice.h" |
c801d85f KB |
15 | #endif |
16 | ||
b5f6b52a | 17 | class WXDLLIMPEXP_BASE wxSortedArrayString; |
584ad2a3 | 18 | class WXDLLIMPEXP_BASE wxArrayString; |
b5f6b52a | 19 | |
c801d85f KB |
20 | //----------------------------------------------------------------------------- |
21 | // wxChoice | |
22 | //----------------------------------------------------------------------------- | |
23 | ||
20123d49 | 24 | class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase |
c801d85f | 25 | { |
fd0eed64 | 26 | public: |
29006414 VZ |
27 | wxChoice(); |
28 | wxChoice( wxWindow *parent, wxWindowID id, | |
29 | const wxPoint& pos = wxDefaultPosition, | |
30 | const wxSize& size = wxDefaultSize, | |
31 | int n = 0, const wxString choices[] = (const wxString *) NULL, | |
32 | long style = 0, | |
33 | const wxValidator& validator = wxDefaultValidator, | |
34 | const wxString& name = wxChoiceNameStr ) | |
35 | { | |
e01c8145 VZ |
36 | m_strings = (wxSortedArrayString *)NULL; |
37 | ||
29006414 VZ |
38 | Create(parent, id, pos, size, n, choices, style, validator, name); |
39 | } | |
584ad2a3 MB |
40 | wxChoice( wxWindow *parent, wxWindowID id, |
41 | const wxPoint& pos, | |
42 | const wxSize& size, | |
43 | const wxArrayString& choices, | |
44 | long style = 0, | |
45 | const wxValidator& validator = wxDefaultValidator, | |
46 | const wxString& name = wxChoiceNameStr ) | |
47 | { | |
48 | m_strings = (wxSortedArrayString *)NULL; | |
49 | ||
50 | Create(parent, id, pos, size, choices, style, validator, name); | |
51 | } | |
29006414 VZ |
52 | ~wxChoice(); |
53 | bool Create( wxWindow *parent, wxWindowID id, | |
54 | const wxPoint& pos = wxDefaultPosition, | |
55 | const wxSize& size = wxDefaultSize, | |
56 | int n = 0, const wxString choices[] = (wxString *) NULL, | |
57 | long style = 0, | |
58 | const wxValidator& validator = wxDefaultValidator, | |
59 | const wxString& name = wxChoiceNameStr ); | |
584ad2a3 MB |
60 | bool Create( wxWindow *parent, wxWindowID id, |
61 | const wxPoint& pos, | |
62 | const wxSize& size, | |
63 | const wxArrayString& choices, | |
64 | long style = 0, | |
65 | const wxValidator& validator = wxDefaultValidator, | |
66 | const wxString& name = wxChoiceNameStr ); | |
c801d85f | 67 | |
9abe166a | 68 | // implement base class pure virtuals |
29006414 | 69 | void Delete(int n); |
9abe166a VZ |
70 | void Clear(); |
71 | ||
72 | int GetSelection() const; | |
73 | void SetSelection( int n ); | |
29006414 | 74 | |
9abe166a | 75 | virtual int GetCount() const; |
6c8a980f | 76 | int FindString( const wxString& string ) const; |
29006414 | 77 | wxString GetString( int n ) const; |
6c8a980f | 78 | void SetString( int n, const wxString& string ); |
29006414 | 79 | |
9d522606 RD |
80 | static wxVisualAttributes |
81 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
82 | ||
20e05ffb | 83 | protected: |
e01c8145 | 84 | wxList m_clientList; // contains the client data for the items |
29006414 | 85 | |
f40fdaa3 | 86 | void DoApplyWidgetStyle(GtkRcStyle *style); |
9abe166a | 87 | virtual int DoAppend(const wxString& item); |
243dbf1a | 88 | virtual int DoInsert(const wxString& item, int pos); |
9abe166a | 89 | |
6c8a980f VZ |
90 | virtual void DoSetItemClientData( int n, void* clientData ); |
91 | virtual void* DoGetItemClientData( int n ) const; | |
92 | virtual void DoSetItemClientObject( int n, wxClientData* clientData ); | |
93 | virtual wxClientData* DoGetItemClientObject( int n ) const; | |
d6538e2c | 94 | |
f68586e5 VZ |
95 | virtual wxSize DoGetBestSize() const; |
96 | ||
3a97d2db | 97 | virtual bool IsOwnGtkWindow( GdkWindow *window ); |
9d522606 | 98 | |
738f9e5a | 99 | private: |
e01c8145 | 100 | // common part of Create() and DoAppend() |
243dbf1a | 101 | int GtkAddHelper(GtkWidget *menu, int pos, const wxString& item); |
e01c8145 VZ |
102 | |
103 | // this array is only used for controls with wxCB_SORT style, so only | |
104 | // allocate it if it's needed (hence using pointer) | |
105 | wxSortedArrayString *m_strings; | |
106 | ||
5f3565a2 | 107 | public: |
16edee16 RR |
108 | // this circumvents a GTK+ 2.0 bug so that the selection is |
109 | // invalidated properly | |
110 | int m_selection_hack; | |
5f3565a2 RR |
111 | |
112 | private: | |
738f9e5a | 113 | DECLARE_DYNAMIC_CLASS(wxChoice) |
c801d85f KB |
114 | }; |
115 | ||
ce4169a4 | 116 | |
c801d85f | 117 | #endif // __GTKCHOICEH__ |