1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef __GTKCHOICEH__
11 #define __GTKCHOICEH__
13 class WXDLLIMPEXP_BASE wxSortedArrayString
;
14 class WXDLLIMPEXP_BASE wxArrayString
;
16 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
20 class WXDLLIMPEXP_CORE wxChoice
: public wxChoiceBase
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
,
29 const wxValidator
& validator
= wxDefaultValidator
,
30 const wxString
& name
= wxChoiceNameStr
)
32 m_strings
= (wxSortedArrayString
*)NULL
;
34 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
36 wxChoice( wxWindow
*parent
, wxWindowID id
,
39 const wxArrayString
& choices
,
41 const wxValidator
& validator
= wxDefaultValidator
,
42 const wxString
& name
= wxChoiceNameStr
)
44 m_strings
= (wxSortedArrayString
*)NULL
;
46 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
49 bool Create( wxWindow
*parent
, wxWindowID id
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
52 int n
= 0, const wxString choices
[] = (wxString
*) NULL
,
54 const wxValidator
& validator
= wxDefaultValidator
,
55 const wxString
& name
= wxChoiceNameStr
);
56 bool Create( wxWindow
*parent
, wxWindowID id
,
59 const wxArrayString
& choices
,
61 const wxValidator
& validator
= wxDefaultValidator
,
62 const wxString
& name
= wxChoiceNameStr
);
64 // implement base class pure virtuals
68 int GetSelection() const;
69 #if wxABI_VERSION >= 20602
70 int GetCurrentSelection() const { return GetSelection(); }
72 void SetSelection( int n
);
74 virtual int GetCount() const;
75 int FindString( const wxString
& string
) const;
76 wxString
GetString( int n
) const;
77 void SetString( int n
, const wxString
& string
);
79 static wxVisualAttributes
80 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
83 wxList m_clientList
; // contains the client data for the items
85 void DoApplyWidgetStyle(GtkRcStyle
*style
);
86 virtual int DoAppend(const wxString
& item
);
87 virtual int DoInsert(const wxString
& item
, int pos
);
89 virtual void DoSetItemClientData( int n
, void* clientData
);
90 virtual void* DoGetItemClientData( int n
) const;
91 virtual void DoSetItemClientObject( int n
, wxClientData
* clientData
);
92 virtual wxClientData
* DoGetItemClientObject( int n
) const;
94 virtual wxSize
DoGetBestSize() const;
96 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
99 // common part of Create() and DoAppend()
100 int GtkAddHelper(GtkWidget
*menu
, int pos
, const wxString
& item
);
102 // this array is only used for controls with wxCB_SORT style, so only
103 // allocate it if it's needed (hence using pointer)
104 wxSortedArrayString
*m_strings
;
107 // this circumvents a GTK+ 2.0 bug so that the selection is
108 // invalidated properly
109 int m_selection_hack
;
112 DECLARE_DYNAMIC_CLASS(wxChoice
)
116 #endif // __GTKCHOICEH__