]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/radiobox.cpp
Disable some wxWebView tests that fail on the buildbot but not locally.
[wxWidgets.git] / src / gtk / radiobox.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
11e62fe6 2// Name: src/gtk/radiobox.cpp
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
f96aa4d9
RR
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
65571936 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
dcf924a3
RR
12
13#if wxUSE_RADIOBOX
14
1e6feb95
VZ
15#include "wx/radiobox.h"
16
aa1e6de9
VZ
17#if wxUSE_TOOLTIPS
18 #include "wx/tooltip.h"
19#endif
20
9e691f46 21#include "wx/gtk/private.h"
14b44999 22
3f26799e 23#include <gdk/gdkkeysyms.h>
14b44999
VS
24#if GTK_CHECK_VERSION(3,0,0)
25#include <gdk/gdkkeysyms-compat.h>
26#endif
3f26799e 27
dc26eeb3
VZ
28//-----------------------------------------------------------------------------
29// wxGTKRadioButtonInfo
30//-----------------------------------------------------------------------------
31// structure internally used by wxRadioBox to store its child buttons
32
33class wxGTKRadioButtonInfo : public wxObject
34{
35public:
36 wxGTKRadioButtonInfo( GtkRadioButton * abutton, const wxRect & arect )
37 : button( abutton ), rect( arect ) {}
38
39 GtkRadioButton * button;
40 wxRect rect;
41};
42
66bd6b93
RR
43//-----------------------------------------------------------------------------
44// data
45//-----------------------------------------------------------------------------
46
dc26eeb3 47#include "wx/listimpl.cpp"
178d7ec2 48WX_DEFINE_LIST( wxRadioBoxButtonsInfoList )
dc26eeb3 49
d7fa7eaa 50extern bool g_blockEventsOnDrag;
66bd6b93 51
c801d85f 52//-----------------------------------------------------------------------------
b4071e91 53// "clicked"
c801d85f
KB
54//-----------------------------------------------------------------------------
55
865bb325 56extern "C" {
e2762ff0 57static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBox *rb )
c801d85f 58{
a2053b27 59 if (!rb->m_hasVMT) return;
907789a0 60 if (g_blockEventsOnDrag) return;
29006414 61
385e8575 62 if (!gtk_toggle_button_get_active(button)) return;
29006414 63
907789a0
RR
64 wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, rb->GetId() );
65 event.SetInt( rb->GetSelection() );
29006414 66 event.SetString( rb->GetStringSelection() );
907789a0 67 event.SetEventObject( rb );
937013e0 68 rb->HandleWindowEvent(event);
6de97a3b 69}
865bb325 70}
c801d85f 71
2e0e025e
RR
72//-----------------------------------------------------------------------------
73// "key_press_event"
74//-----------------------------------------------------------------------------
75
865bb325 76extern "C" {
2e0e025e
RR
77static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxRadioBox *rb )
78{
2e0e025e
RR
79 if (!rb->m_hasVMT) return FALSE;
80 if (g_blockEventsOnDrag) return FALSE;
81
8228b893 82 if ( ((gdk_event->keyval == GDK_Tab) ||
5985c07c
RR
83 (gdk_event->keyval == GDK_ISO_Left_Tab)) &&
84 rb->GetParent() && (rb->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
85 {
86 wxNavigationKeyEvent new_event;
87 new_event.SetEventObject( rb->GetParent() );
88 // GDK reports GDK_ISO_Left_Tab for SHIFT-TAB
89 new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
90 // CTRL-TAB changes the (parent) window, i.e. switch notebook page
91 new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
92 new_event.SetCurrentFocus( rb );
937013e0 93 return rb->GetParent()->HandleWindowEvent(new_event);
5985c07c
RR
94 }
95
2e0e025e
RR
96 if ((gdk_event->keyval != GDK_Up) &&
97 (gdk_event->keyval != GDK_Down) &&
98 (gdk_event->keyval != GDK_Left) &&
99 (gdk_event->keyval != GDK_Right))
100 {
101 return FALSE;
102 }
2da61056 103
dc26eeb3
VZ
104 wxRadioBoxButtonsInfoList::compatibility_iterator node = rb->m_buttonsInfo.GetFirst();
105 while( node && GTK_WIDGET( node->GetData()->button ) != widget )
106 {
107 node = node->GetNext();
108 }
2e0e025e
RR
109 if (!node)
110 {
111 return FALSE;
112 }
2da61056 113
2e0e025e
RR
114 if ((gdk_event->keyval == GDK_Up) ||
115 (gdk_event->keyval == GDK_Left))
116 {
dc26eeb3
VZ
117 if (node == rb->m_buttonsInfo.GetFirst())
118 node = rb->m_buttonsInfo.GetLast();
2da61056 119 else
b1d4dd7a 120 node = node->GetPrevious();
2e0e025e
RR
121 }
122 else
123 {
dc26eeb3
VZ
124 if (node == rb->m_buttonsInfo.GetLast())
125 node = rb->m_buttonsInfo.GetFirst();
2da61056 126 else
b1d4dd7a 127 node = node->GetNext();
2e0e025e 128 }
2da61056 129
dc26eeb3 130 GtkWidget *button = (GtkWidget*) node->GetData()->button;
2da61056 131
2e0e025e 132 gtk_widget_grab_focus( button );
2da61056 133
2e0e025e
RR
134 return TRUE;
135}
865bb325 136}
2e0e025e 137
865bb325 138extern "C" {
bd2e08d0
VS
139static gint gtk_radiobutton_focus_out( GtkWidget * WXUNUSED(widget),
140 GdkEventFocus *WXUNUSED(event),
141 wxRadioBox *win )
f6bcfd97 142{
bd2e08d0
VS
143 // NB: This control is composed of several GtkRadioButton widgets and
144 // when focus changes from one of them to another in the same
145 // wxRadioBox, we get a focus-out event followed by focus-in for
146 // another GtkRadioButton owned by the same control. We don't want
147 // to generate two spurious wxEVT_SET_FOCUS events in this case,
148 // so we defer sending wx events until idle time.
149 win->GTKHandleFocusOut();
f6bcfd97 150
bd2e08d0
VS
151 // never stop the signal emission, it seems to break the kbd handling
152 // inside the radiobox
f6bcfd97
BP
153 return FALSE;
154}
865bb325 155}
f6bcfd97 156
865bb325 157extern "C" {
bd2e08d0
VS
158static gint gtk_radiobutton_focus_in( GtkWidget * WXUNUSED(widget),
159 GdkEventFocus *WXUNUSED(event),
160 wxRadioBox *win )
f6bcfd97 161{
bd2e08d0 162 win->GTKHandleFocusIn();
f6bcfd97 163
bd2e08d0
VS
164 // never stop the signal emission, it seems to break the kbd handling
165 // inside the radiobox
f6bcfd97
BP
166 return FALSE;
167}
865bb325 168}
f6bcfd97 169
dc26eeb3
VZ
170extern "C" {
171static void gtk_radiobutton_size_allocate( GtkWidget *widget,
172 GtkAllocation * alloc,
173 wxRadioBox *win )
174{
dc26eeb3
VZ
175 for ( wxRadioBoxButtonsInfoList::compatibility_iterator node = win->m_buttonsInfo.GetFirst();
176 node;
964c139b 177 node = node->GetNext())
dc26eeb3 178 {
964c139b 179 if (widget == GTK_WIDGET(node->GetData()->button))
dc26eeb3
VZ
180 {
181 const wxPoint origin = win->GetPosition();
182 wxRect rect = wxRect( alloc->x - origin.x, alloc->y - origin.y,
183 alloc->width, alloc->height );
184 node->GetData()->rect = rect;
185 break;
186 }
187 }
188}
189}
190
191
b4071e91
RR
192//-----------------------------------------------------------------------------
193// wxRadioBox
c801d85f
KB
194//-----------------------------------------------------------------------------
195
196IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl)
197
584ad2a3
MB
198bool wxRadioBox::Create( wxWindow *parent, wxWindowID id,
199 const wxString& title,
200 const wxPoint &pos, const wxSize &size,
201 const wxArrayString& choices, int majorDim,
202 long style, const wxValidator& validator,
203 const wxString &name )
204{
205 wxCArrayString chs(choices);
206
207 return Create( parent, id, title, pos, size, chs.GetCount(),
208 chs.GetStrings(), majorDim, style, validator, name );
209}
210
debe6624 211bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
907789a0 212 const wxPoint &pos, const wxSize &size,
29006414
VZ
213 int n, const wxString choices[], int majorDim,
214 long style, const wxValidator& validator,
215 const wxString &name )
c801d85f 216{
4dcaf11a
RR
217 if (!PreCreation( parent, pos, size ) ||
218 !CreateBase( parent, id, pos, size, style, validator, name ))
219 {
223d09f6 220 wxFAIL_MSG( wxT("wxRadioBox creation failed") );
b4efc9b9 221 return false;
4dcaf11a 222 }
6de97a3b 223
2e1f5012 224 m_widget = GTKCreateFrame(title);
9ff9d30c 225 g_object_ref(m_widget);
2e1f5012 226 wxControl::SetLabel(title);
378b042b
VZ
227 if ( HasFlag(wxNO_BORDER) )
228 {
229 // If we don't do this here, the wxNO_BORDER style is ignored in Show()
230 gtk_frame_set_shadow_type(GTK_FRAME(m_widget), GTK_SHADOW_NONE);
231 }
232
29006414 233
5eaac5b5
VZ
234 // majorDim may be 0 if all trailing parameters were omitted, so don't
235 // assert here but just use the correct value for it
27c78e45 236 SetMajorDim(majorDim == 0 ? n : majorDim, style);
29006414 237
8017ee9b 238
aa61d352
VZ
239 unsigned int num_of_cols = GetColumnCount();
240 unsigned int num_of_rows = GetRowCount();
11e62fe6 241
d3b9f782 242 GtkRadioButton *rbtn = NULL;
29006414 243
8017ee9b 244 GtkWidget *table = gtk_table_new( num_of_rows, num_of_cols, FALSE );
d504085d
RR
245 gtk_table_set_col_spacings( GTK_TABLE(table), 1 );
246 gtk_table_set_row_spacings( GTK_TABLE(table), 1 );
8017ee9b
RR
247 gtk_widget_show( table );
248 gtk_container_add( GTK_CONTAINER(m_widget), table );
11e62fe6 249
26333898 250 wxString label;
d3b9f782 251 GSList *radio_button_group = NULL;
8ebb2a1d 252 for (unsigned int i = 0; i < (unsigned int)n; i++)
c801d85f 253 {
26333898 254 if ( i != 0 )
07014b5a 255 radio_button_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON(rbtn) );
29006414 256
26333898 257 label.Empty();
86501081
VS
258 for ( wxString::const_iterator pc = choices[i].begin();
259 pc != choices[i].end(); ++pc )
26333898 260 {
223d09f6 261 if ( *pc != wxT('&') )
26333898
VZ
262 label += *pc;
263 }
264
07014b5a
VZ
265 rbtn = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, wxGTK_CONV( label ) ) );
266 gtk_widget_show( GTK_WIDGET(rbtn) );
29006414 267
07014b5a 268 g_signal_connect (rbtn, "key_press_event",
9fa72bd2 269 G_CALLBACK (gtk_radiobox_keypress_callback), this);
2da61056 270
dc26eeb3 271 m_buttonsInfo.Append( new wxGTKRadioButtonInfo( rbtn, wxRect() ) );
29006414 272
8017ee9b
RR
273 if (HasFlag(wxRA_SPECIFY_COLS))
274 {
275 int left = i%num_of_cols;
276 int right = (i%num_of_cols) + 1;
277 int top = i/num_of_cols;
278 int bottom = (i/num_of_cols)+1;
07014b5a 279 gtk_table_attach( GTK_TABLE(table), GTK_WIDGET(rbtn), left, right, top, bottom,
11e62fe6 280 GTK_FILL, GTK_FILL, 1, 1 );
8017ee9b
RR
281 }
282 else
283 {
284 int left = i/num_of_rows;
285 int right = (i/num_of_rows) + 1;
286 int top = i%num_of_rows;
287 int bottom = (i%num_of_rows)+1;
07014b5a 288 gtk_table_attach( GTK_TABLE(table), GTK_WIDGET(rbtn), left, right, top, bottom,
11e62fe6 289 GTK_FILL, GTK_FILL, 1, 1 );
8017ee9b
RR
290 }
291
07014b5a 292 ConnectWidget( GTK_WIDGET(rbtn) );
29006414 293
e343da37 294 if (!i)
07014b5a 295 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(rbtn), TRUE );
29006414 296
07014b5a 297 g_signal_connect (rbtn, "clicked",
9fa72bd2 298 G_CALLBACK (gtk_radiobutton_clicked_callback), this);
07014b5a 299 g_signal_connect (rbtn, "focus_in_event",
9fa72bd2 300 G_CALLBACK (gtk_radiobutton_focus_in), this);
07014b5a 301 g_signal_connect (rbtn, "focus_out_event",
9fa72bd2 302 G_CALLBACK (gtk_radiobutton_focus_out), this);
dc26eeb3
VZ
303 g_signal_connect (rbtn, "size_allocate",
304 G_CALLBACK (gtk_radiobutton_size_allocate), this);
6de97a3b 305 }
29006414 306
db434467
RR
307 m_parent->DoAddChild( this );
308
abdeb9e7 309 PostCreation(size);
29006414 310
b4efc9b9 311 return true;
6de97a3b 312}
c801d85f 313
f03fc89f 314wxRadioBox::~wxRadioBox()
d6d1892b 315{
dc26eeb3 316 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
907789a0
RR
317 while (node)
318 {
dc26eeb3 319 GtkWidget *button = GTK_WIDGET( node->GetData()->button );
907789a0 320 gtk_widget_destroy( button );
b1d4dd7a 321 node = node->GetNext();
907789a0 322 }
dc26eeb3 323 WX_CLEAR_LIST( wxRadioBoxButtonsInfoList, m_buttonsInfo );
d6d1892b
RR
324}
325
debe6624 326bool wxRadioBox::Show( bool show )
c801d85f 327{
b4efc9b9 328 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 329
f96ac56a
RR
330 if (!wxControl::Show(show))
331 {
332 // nothing to do
b4efc9b9 333 return false;
f96ac56a 334 }
c801d85f 335
c4ca49cd 336 if ( HasFlag(wxNO_BORDER) )
b0351fc9 337 gtk_widget_hide( m_widget );
e3e717ec 338
dc26eeb3 339 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
907789a0
RR
340 while (node)
341 {
dc26eeb3 342 GtkWidget *button = GTK_WIDGET( node->GetData()->button );
29006414 343
27c78e45
VZ
344 if (show)
345 gtk_widget_show( button );
346 else
347 gtk_widget_hide( button );
29006414 348
b1d4dd7a 349 node = node->GetNext();
907789a0 350 }
c801d85f 351
b4efc9b9 352 return true;
6de97a3b 353}
c801d85f 354
47908e25 355void wxRadioBox::SetSelection( int n )
c801d85f 356{
223d09f6 357 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 358
dc26eeb3 359 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.Item( n );
29006414 360
223d09f6 361 wxCHECK_RET( node, wxT("radiobox wrong index") );
29006414 362
dc26eeb3 363 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData()->button );
29006414 364
72a7edf0 365 GtkDisableEvents();
2da61056 366
e2762ff0 367 gtk_toggle_button_set_active( button, 1 );
2da61056 368
72a7edf0 369 GtkEnableEvents();
6de97a3b 370}
c801d85f
KB
371
372int wxRadioBox::GetSelection(void) const
373{
789f6795 374 wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid radiobox") );
29006414 375
907789a0 376 int count = 0;
29006414 377
dc26eeb3 378 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
907789a0
RR
379 while (node)
380 {
dc26eeb3 381 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData()->button );
385e8575 382 if (gtk_toggle_button_get_active(button)) return count;
907789a0 383 count++;
b1d4dd7a 384 node = node->GetNext();
907789a0 385 }
29006414 386
223d09f6 387 wxFAIL_MSG( wxT("wxRadioBox none selected") );
29006414 388
789f6795 389 return wxNOT_FOUND;
6de97a3b 390}
c801d85f 391
aa61d352 392wxString wxRadioBox::GetString(unsigned int n) const
c801d85f 393{
1a87edf2 394 wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid radiobox") );
29006414 395
dc26eeb3 396 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.Item( n );
29006414 397
1a87edf2 398 wxCHECK_MSG( node, wxEmptyString, wxT("radiobox wrong index") );
29006414 399
385e8575 400 GtkLabel* label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(node->GetData()->button)));
29006414 401
2b5f62a0 402 wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
2b5f62a0
VZ
403
404 return str;
6de97a3b 405}
c801d85f 406
d3904ceb 407void wxRadioBox::SetLabel( const wxString& label )
c801d85f 408{
223d09f6 409 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 410
b2ff89d6 411 GTKSetLabelForFrame(GTK_FRAME(m_widget), label);
6de97a3b 412}
c801d85f 413
aa61d352 414void wxRadioBox::SetString(unsigned int item, const wxString& label)
c801d85f 415{
223d09f6 416 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 417
dc26eeb3 418 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.Item( item );
29006414 419
223d09f6 420 wxCHECK_RET( node, wxT("radiobox wrong index") );
29006414 421
385e8575 422 GtkLabel* g_label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(node->GetData()->button)));
29006414 423
a7c12d28 424 gtk_label_set_text( g_label, wxGTK_CONV( label ) );
6de97a3b 425}
c801d85f 426
f03fc89f 427bool wxRadioBox::Enable( bool enable )
c801d85f 428{
f03fc89f 429 if ( !wxControl::Enable( enable ) )
b4efc9b9 430 return false;
29006414 431
dc26eeb3 432 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
907789a0
RR
433 while (node)
434 {
dc26eeb3 435 GtkButton *button = GTK_BUTTON( node->GetData()->button );
385e8575 436 GtkLabel *label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(button)));
9e691f46 437
907789a0 438 gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
9e691f46 439 gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
b1d4dd7a 440 node = node->GetNext();
907789a0 441 }
f03fc89f 442
b545684e 443 if (enable)
ad60f9e7 444 GTKFixSensitivity();
ad60f9e7 445
b4efc9b9 446 return true;
6de97a3b 447}
c801d85f 448
aa61d352 449bool wxRadioBox::Enable(unsigned int item, bool enable)
c801d85f 450{
1a87edf2 451 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 452
dc26eeb3 453 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.Item( item );
29006414 454
1a87edf2 455 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 456
dc26eeb3 457 GtkButton *button = GTK_BUTTON( node->GetData()->button );
385e8575 458 GtkLabel *label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(button)));
9e691f46 459
907789a0 460 gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
9e691f46 461 gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
1a87edf2
WS
462
463 return true;
6de97a3b 464}
c801d85f 465
aa61d352 466bool wxRadioBox::IsItemEnabled(unsigned int item) const
27c78e45
VZ
467{
468 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
469
dc26eeb3 470 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.Item( item );
27c78e45
VZ
471
472 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
473
dc26eeb3 474 GtkButton *button = GTK_BUTTON( node->GetData()->button );
27c78e45
VZ
475
476 // don't use GTK_WIDGET_IS_SENSITIVE() here, we want to return true even if
477 // the parent radiobox is disabled
ad47660f 478 return gtk_widget_get_sensitive(GTK_WIDGET(button));
27c78e45
VZ
479}
480
aa61d352 481bool wxRadioBox::Show(unsigned int item, bool show)
c801d85f 482{
789f6795 483 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 484
dc26eeb3 485 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.Item( item );
29006414 486
789f6795 487 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 488
dc26eeb3 489 GtkWidget *button = GTK_WIDGET( node->GetData()->button );
c801d85f 490
907789a0
RR
491 if (show)
492 gtk_widget_show( button );
493 else
494 gtk_widget_hide( button );
789f6795
WS
495
496 return true;
6de97a3b 497}
c801d85f 498
aa61d352 499bool wxRadioBox::IsItemShown(unsigned int item) const
c801d85f 500{
27c78e45 501 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 502
dc26eeb3 503 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.Item( item );
c801d85f 504
27c78e45 505 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 506
dc26eeb3 507 GtkButton *button = GTK_BUTTON( node->GetData()->button );
29006414 508
fc9ab22a 509 return gtk_widget_get_visible(GTK_WIDGET(button));
6de97a3b 510}
c801d85f 511
aa61d352 512unsigned int wxRadioBox::GetCount() const
c801d85f 513{
dc26eeb3 514 return m_buttonsInfo.GetCount();
6de97a3b 515}
c801d85f 516
72a7edf0 517void wxRadioBox::GtkDisableEvents()
953704c1 518{
dc26eeb3 519 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
953704c1
RR
520 while (node)
521 {
98264520
PC
522 g_signal_handlers_block_by_func(node->GetData()->button,
523 (gpointer)gtk_radiobutton_clicked_callback, this);
953704c1 524
b1d4dd7a 525 node = node->GetNext();
953704c1
RR
526 }
527}
528
72a7edf0 529void wxRadioBox::GtkEnableEvents()
953704c1 530{
dc26eeb3 531 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
953704c1
RR
532 while (node)
533 {
98264520
PC
534 g_signal_handlers_unblock_by_func(node->GetData()->button,
535 (gpointer)gtk_radiobutton_clicked_callback, this);
953704c1 536
b1d4dd7a 537 node = node->GetNext();
953704c1
RR
538 }
539}
540
f40fdaa3 541void wxRadioBox::DoApplyWidgetStyle(GtkRcStyle *style)
868a2826 542{
2e1f5012 543 GTKFrameApplyWidgetStyle(GTK_FRAME(m_widget), style);
81e88f5b 544
dc26eeb3 545 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
907789a0
RR
546 while (node)
547 {
dc26eeb3 548 GtkWidget *widget = GTK_WIDGET( node->GetData()->button );
29006414 549
f40fdaa3 550 gtk_widget_modify_style( widget, style );
385e8575 551 gtk_widget_modify_style(gtk_bin_get_child(GTK_BIN(widget)), style);
29006414 552
b1d4dd7a 553 node = node->GetNext();
907789a0 554 }
868a2826 555}
b4071e91 556
2e1f5012
VZ
557bool wxRadioBox::GTKWidgetNeedsMnemonic() const
558{
559 return true;
560}
561
562void wxRadioBox::GTKWidgetDoSetMnemonic(GtkWidget* w)
563{
564 GTKFrameSetMnemonicWidget(GTK_FRAME(m_widget), w);
565}
566
72a7edf0 567#if wxUSE_TOOLTIPS
558a94bd 568void wxRadioBox::GTKApplyToolTip(const char* tip)
72a7edf0 569{
aa1e6de9
VZ
570 // set this tooltip for all radiobuttons which don't have their own tips
571 unsigned n = 0;
dc26eeb3 572 for ( wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
aa1e6de9
VZ
573 node;
574 node = node->GetNext(), n++ )
72a7edf0 575 {
aa1e6de9
VZ
576 if ( !GetItemToolTip(n) )
577 {
7fc8b9a4 578 wxToolTip::GTKApply(GTK_WIDGET(node->GetData()->button), tip);
aa1e6de9 579 }
72a7edf0
RR
580 }
581}
aa1e6de9
VZ
582
583void wxRadioBox::DoSetItemToolTip(unsigned int n, wxToolTip *tooltip)
584{
585 wxCharBuffer buf;
586 if ( !tooltip )
587 tooltip = GetToolTip();
588 if ( tooltip )
589 buf = wxGTK_CONV(tooltip->GetTip());
590
7fc8b9a4 591 wxToolTip::GTKApply(GTK_WIDGET(m_buttonsInfo[n]->button), buf);
aa1e6de9
VZ
592}
593
72a7edf0
RR
594#endif // wxUSE_TOOLTIPS
595
ef5c70f9 596GdkWindow *wxRadioBox::GTKGetWindow(wxArrayGdkWindows& windows) const
b4071e91 597{
385e8575 598 windows.push_back(gtk_widget_get_window(m_widget));
29006414 599
dc26eeb3 600 wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
907789a0
RR
601 while (node)
602 {
dc26eeb3 603 GtkWidget *button = GTK_WIDGET( node->GetData()->button );
29006414 604
5b88a837 605 // don't put NULL pointers in the 'windows' array!
385e8575
PC
606 if (gtk_widget_get_window(button))
607 windows.push_back(gtk_widget_get_window(button));
29006414 608
b1d4dd7a 609 node = node->GetNext();
907789a0 610 }
29006414 611
ef5c70f9 612 return NULL;
b4071e91 613}
dcf924a3 614
9d522606
RD
615// static
616wxVisualAttributes
617wxRadioBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
618{
619 wxVisualAttributes attr;
bc0eb46c
VS
620 // NB: we need toplevel window so that GTK+ can find the right style
621 GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
9d522606 622 GtkWidget* widget = gtk_radio_button_new_with_label(NULL, "");
bc0eb46c 623 gtk_container_add(GTK_CONTAINER(wnd), widget);
9d522606 624 attr = GetDefaultAttributesFromGTKWidget(widget);
bc0eb46c 625 gtk_widget_destroy(wnd);
9d522606
RD
626 return attr;
627}
628
dc26eeb3
VZ
629int wxRadioBox::GetItemFromPoint(const wxPoint& point) const
630{
631 const wxPoint pt = ScreenToClient(point);
632 unsigned n = 0;
633 for ( wxRadioBoxButtonsInfoList::compatibility_iterator
634 node = m_buttonsInfo.GetFirst(); node; node = node->GetNext(), n++ )
635 {
22a35096 636 if ( m_buttonsInfo[n]->rect.Contains(pt) )
dc26eeb3
VZ
637 return n;
638 }
639
640 return wxNOT_FOUND;
641}
642
f6bcfd97 643#endif // wxUSE_RADIOBOX