1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef __GTKCHOICEH__
11 #define __GTKCHOICEH__
13 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
14 #pragma interface "choice.h"
17 class WXDLLIMPEXP_BASE wxSortedArrayString
;
18 class WXDLLIMPEXP_BASE wxArrayString
;
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 class wxChoice
: public wxChoiceBase
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
,
33 const wxValidator
& validator
= wxDefaultValidator
,
34 const wxString
& name
= wxChoiceNameStr
)
36 m_strings
= (wxSortedArrayString
*)NULL
;
38 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
40 wxChoice( wxWindow
*parent
, wxWindowID id
,
43 const wxArrayString
& choices
,
45 const wxValidator
& validator
= wxDefaultValidator
,
46 const wxString
& name
= wxChoiceNameStr
)
48 m_strings
= (wxSortedArrayString
*)NULL
;
50 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
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
,
58 const wxValidator
& validator
= wxDefaultValidator
,
59 const wxString
& name
= wxChoiceNameStr
);
60 bool Create( wxWindow
*parent
, wxWindowID id
,
63 const wxArrayString
& choices
,
65 const wxValidator
& validator
= wxDefaultValidator
,
66 const wxString
& name
= wxChoiceNameStr
);
68 // implement base class pure virtuals
72 int GetSelection() const;
73 void SetSelection( int n
);
75 virtual int GetCount() const;
76 int FindString( const wxString
& string
) const;
77 wxString
GetString( int n
) const;
78 void SetString( int n
, const wxString
& string
);
80 static wxVisualAttributes
81 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
84 wxList m_clientList
; // contains the client data for the items
86 void DoApplyWidgetStyle(GtkRcStyle
*style
);
87 virtual int DoAppend(const wxString
& item
);
88 virtual int DoInsert(const wxString
& item
, int pos
);
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;
95 virtual wxSize
DoGetBestSize() const;
97 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
100 // common part of Create() and DoAppend()
101 int GtkAddHelper(GtkWidget
*menu
, int pos
, const wxString
& item
);
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
;
107 // this circumvents a GTK+ 2.0 bug so that the selection is
108 // invalidated properly
109 int m_selection_hack
;
111 DECLARE_DYNAMIC_CLASS(wxChoice
)
115 #endif // __GTKCHOICEH__