1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk1/choice.h
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 #define __GTKCHOICEH__
12 class WXDLLIMPEXP_FWD_BASE wxSortedArrayString
;
13 class WXDLLIMPEXP_FWD_BASE wxArrayString
;
15 //-----------------------------------------------------------------------------
17 //-----------------------------------------------------------------------------
19 class WXDLLIMPEXP_CORE wxChoice
: public wxChoiceBase
23 wxChoice( wxWindow
*parent
, wxWindowID id
,
24 const wxPoint
& pos
= wxDefaultPosition
,
25 const wxSize
& size
= wxDefaultSize
,
26 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
28 const wxValidator
& validator
= wxDefaultValidator
,
29 const wxString
& name
= wxChoiceNameStr
)
33 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
35 wxChoice( wxWindow
*parent
, wxWindowID id
,
38 const wxArrayString
& choices
,
40 const wxValidator
& validator
= wxDefaultValidator
,
41 const wxString
& name
= wxChoiceNameStr
)
45 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
48 bool Create( wxWindow
*parent
, wxWindowID id
,
49 const wxPoint
& pos
= wxDefaultPosition
,
50 const wxSize
& size
= wxDefaultSize
,
51 int n
= 0, const wxString choices
[] = NULL
,
53 const wxValidator
& validator
= wxDefaultValidator
,
54 const wxString
& name
= wxChoiceNameStr
);
55 bool Create( wxWindow
*parent
, wxWindowID id
,
58 const wxArrayString
& choices
,
60 const wxValidator
& validator
= wxDefaultValidator
,
61 const wxString
& name
= wxChoiceNameStr
);
63 // implement base class pure virtuals
64 void DoDeleteOneItem(unsigned int n
);
67 int GetSelection() const;
68 virtual void SetSelection(int n
);
70 virtual unsigned int GetCount() const;
71 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
72 virtual wxString
GetString(unsigned int n
) const;
73 virtual void SetString(unsigned int n
, const wxString
& string
);
75 static wxVisualAttributes
76 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
79 wxList m_clientList
; // contains the client data for the items
81 void DoApplyWidgetStyle(GtkRcStyle
*style
);
82 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
84 void **clientData
, wxClientDataType type
);
86 virtual void DoSetItemClientData(unsigned int n
, void* clientData
);
87 virtual void* DoGetItemClientData(unsigned int n
) const;
89 virtual wxSize
DoGetBestSize() const;
91 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
94 // DoInsertItems() helper
95 int GtkAddHelper(GtkWidget
*menu
, unsigned int pos
, const wxString
& item
);
97 // this array is only used for controls with wxCB_SORT style, so only
98 // allocate it if it's needed (hence using pointer)
99 wxSortedArrayString
*m_strings
;
102 // this circumvents a GTK+ 2.0 bug so that the selection is
103 // invalidated properly
104 int m_selection_hack
;
107 DECLARE_DYNAMIC_CLASS(wxChoice
)
111 #endif // __GTKCHOICEH__