1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        wx/gtk/radiobox.h
3 // Purpose:
4 // Author:      Robert Roebling
5 // Id:          $Id: radiobox.h 40815 2006-08-25 12:59:28Z VZ $
6 // Copyright:   (c) 1998 Robert Roebling
7 // Licence:     wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9 
10 #ifndef _WX_GTK_RADIOBOX_H_
11 #define _WX_GTK_RADIOBOX_H_
12 
13 #include "wx/bitmap.h"
14 
15 class WXDLLIMPEXP_CORE wxGTKRadioButtonInfo;
16 
17 #include "wx/list.h"
18 
19 WX_DECLARE_EXPORTED_LIST(wxGTKRadioButtonInfo, wxRadioBoxButtonsInfoList);
20 
21 
22 //-----------------------------------------------------------------------------
23 // wxRadioBox
24 //-----------------------------------------------------------------------------
25 
26 class WXDLLIMPEXP_CORE wxRadioBox : public wxControl,
27                                     public wxRadioBoxBase
28 {
29 public:
30     // ctors and dtor
wxRadioBox()31     wxRadioBox() { Init(); }
32     wxRadioBox(wxWindow *parent,
33                wxWindowID id,
34                const wxString& title,
35                const wxPoint& pos = wxDefaultPosition,
36                const wxSize& size = wxDefaultSize,
37                int n = 0,
38                const wxString choices[] = (const wxString *) NULL,
39                int majorDim = 1,
40                long style = wxRA_HORIZONTAL,
41                const wxValidator& val = wxDefaultValidator,
42                const wxString& name = wxRadioBoxNameStr)
43     {
44         Init();
45 
46         Create( parent, id, title, pos, size, n, choices, majorDim, style, val, name );
47     }
48 
49     wxRadioBox(wxWindow *parent,
50                wxWindowID id,
51                const wxString& title,
52                const wxPoint& pos,
53                const wxSize& size,
54                const wxArrayString& choices,
55                int majorDim = 1,
56                long style = wxRA_HORIZONTAL,
57                const wxValidator& val = wxDefaultValidator,
58                const wxString& name = wxRadioBoxNameStr)
59     {
60         Init();
61 
62         Create( parent, id, title, pos, size, choices, majorDim, style, val, name );
63     }
64 
65     bool Create(wxWindow *parent,
66                 wxWindowID id,
67                 const wxString& title,
68                 const wxPoint& pos = wxDefaultPosition,
69                 const wxSize& size = wxDefaultSize,
70                 int n = 0,
71                 const wxString choices[] = (const wxString *) NULL,
72                 int majorDim = 0,
73                 long style = wxRA_HORIZONTAL,
74                 const wxValidator& val = wxDefaultValidator,
75                 const wxString& name = wxRadioBoxNameStr);
76     bool Create(wxWindow *parent,
77                 wxWindowID id,
78                 const wxString& title,
79                 const wxPoint& pos,
80                 const wxSize& size,
81                 const wxArrayString& choices,
82                 int majorDim = 0,
83                 long style = wxRA_HORIZONTAL,
84                 const wxValidator& val = wxDefaultValidator,
85                 const wxString& name = wxRadioBoxNameStr);
86 
87     virtual ~wxRadioBox();
88 
89 
90     // implement wxItemContainerImmutable methods
91     virtual unsigned int GetCount() const;
92 
93     virtual wxString GetString(unsigned int n) const;
94     virtual void SetString(unsigned int n, const wxString& s);
95 
96     virtual void SetSelection(int n);
97     virtual int GetSelection() const;
98 
99 
100     // implement wxRadioBoxBase methods
101     virtual bool Show(unsigned int n, bool show = true);
102     virtual bool Enable(unsigned int n, bool enable = true);
103 
104     virtual bool IsItemEnabled(unsigned int n) const;
105     virtual bool IsItemShown(unsigned int n) const;
106 
107 
108     // override some base class methods to operate on radiobox itself too
109     virtual bool Show( bool show = true );
110     virtual bool Enable( bool enable = true );
111 
112     virtual void SetLabel( const wxString& label );
113 
114     static wxVisualAttributes
115     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
116 
117     virtual int GetItemFromPoint( const wxPoint& pt ) const;
118 #if wxUSE_HELP
119     // override virtual wxWindow::GetHelpTextAtPoint to use common platform independent
120     // wxRadioBoxBase::DoGetHelpTextAtPoint from the platform independent
121     // base class-interface wxRadioBoxBase.
GetHelpTextAtPoint(const wxPoint & pt,wxHelpEvent::Origin origin)122     virtual wxString GetHelpTextAtPoint(const wxPoint & pt, wxHelpEvent::Origin origin) const
123     {
124         return wxRadioBoxBase::DoGetHelpTextAtPoint( this, pt, origin );
125     }
126 #endif // wxUSE_HELP
127 
128     // implementation
129     // --------------
130 
131     void SetFocus();
132     void GtkDisableEvents();
133     void GtkEnableEvents();
134 #if wxUSE_TOOLTIPS
135     void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
136 #endif // wxUSE_TOOLTIPS
137 
138     virtual void OnInternalIdle();
139 
140     bool                        m_hasFocus,
141                                 m_lostFocus;
142     wxRadioBoxButtonsInfoList   m_buttonsInfo;
143 
144 protected:
145 #if wxUSE_TOOLTIPS
146     virtual void DoSetItemToolTip(unsigned int n, wxToolTip *tooltip);
147 #endif
148 
149     virtual void DoApplyWidgetStyle(GtkRcStyle *style);
150     virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
151 
152     virtual bool GTKWidgetNeedsMnemonic() const;
153     virtual void GTKWidgetDoSetMnemonic(GtkWidget* w);
154 
155     // common part of all ctors
156     void Init();
157 
158 private:
159     DECLARE_DYNAMIC_CLASS(wxRadioBox)
160 };
161 
162 #endif // _WX_GTK_RADIOBOX_H_
163