]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/gtk1/choice.h
don't pass NULL pointer to printf(), this crashes Solaris printf
[wxWidgets.git] / include / wx / gtk1 / choice.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: 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#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
14 #pragma interface "choice.h"
15#endif
16
17class WXDLLIMPEXP_BASE wxSortedArrayString;
18class WXDLLIMPEXP_BASE wxArrayString;
19
20//-----------------------------------------------------------------------------
21// wxChoice
22//-----------------------------------------------------------------------------
23
24class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase
25{
26public:
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 {
36 m_strings = (wxSortedArrayString *)NULL;
37
38 Create(parent, id, pos, size, n, choices, style, validator, name);
39 }
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 }
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 );
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 );
67
68 // implement base class pure virtuals
69 void Delete(int n);
70 void Clear();
71
72 int GetSelection() const;
73#if wxABI_VERSION >= 20602
74 int GetCurrentSelection() const { return GetSelection(); }
75#endif
76 void SetSelection( int n );
77
78 virtual int GetCount() const;
79 int FindString( const wxString& string ) const;
80 wxString GetString( int n ) const;
81 void SetString( int n, const wxString& string );
82
83 static wxVisualAttributes
84 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
85
86protected:
87 wxList m_clientList; // contains the client data for the items
88
89 void DoApplyWidgetStyle(GtkRcStyle *style);
90 virtual int DoAppend(const wxString& item);
91 virtual int DoInsert(const wxString& item, int pos);
92
93 virtual void DoSetItemClientData( int n, void* clientData );
94 virtual void* DoGetItemClientData( int n ) const;
95 virtual void DoSetItemClientObject( int n, wxClientData* clientData );
96 virtual wxClientData* DoGetItemClientObject( int n ) const;
97
98 virtual wxSize DoGetBestSize() const;
99
100 virtual bool IsOwnGtkWindow( GdkWindow *window );
101
102private:
103 // common part of Create() and DoAppend()
104 int GtkAddHelper(GtkWidget *menu, int pos, const wxString& item);
105
106 // this array is only used for controls with wxCB_SORT style, so only
107 // allocate it if it's needed (hence using pointer)
108 wxSortedArrayString *m_strings;
109
110public:
111 // this circumvents a GTK+ 2.0 bug so that the selection is
112 // invalidated properly
113 int m_selection_hack;
114
115private:
116 DECLARE_DYNAMIC_CLASS(wxChoice)
117};
118
119
120#endif // __GTKCHOICEH__