]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/radiobox.cpp
Trying to commit wxDirDialog patch.
[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
e4db172a
WS
17#ifndef WX_PRECOMP
18 #include "wx/log.h"
19#endif
20
c801d85f
KB
21#include "wx/dialog.h"
22#include "wx/frame.h"
83624f79 23
9e691f46 24#include "wx/gtk/private.h"
3f26799e
RR
25#include <gdk/gdkkeysyms.h>
26
c801d85f
KB
27#include "wx/gtk/win_gtk.h"
28
66bd6b93
RR
29//-----------------------------------------------------------------------------
30// data
31//-----------------------------------------------------------------------------
32
d7fa7eaa
RR
33extern bool g_blockEventsOnDrag;
34extern wxWindowGTK *g_delayedFocus;
66bd6b93 35
c801d85f 36//-----------------------------------------------------------------------------
b4071e91 37// "clicked"
c801d85f
KB
38//-----------------------------------------------------------------------------
39
865bb325 40extern "C" {
e2762ff0 41static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBox *rb )
c801d85f 42{
acfd422a
RR
43 if (g_isIdle) wxapp_install_idle_handler();
44
a2053b27 45 if (!rb->m_hasVMT) return;
907789a0 46 if (g_blockEventsOnDrag) return;
29006414 47
e2762ff0 48 if (!button->active) return;
29006414 49
907789a0
RR
50 wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, rb->GetId() );
51 event.SetInt( rb->GetSelection() );
29006414 52 event.SetString( rb->GetStringSelection() );
907789a0
RR
53 event.SetEventObject( rb );
54 rb->GetEventHandler()->ProcessEvent(event);
6de97a3b 55}
865bb325 56}
c801d85f 57
2e0e025e
RR
58//-----------------------------------------------------------------------------
59// "key_press_event"
60//-----------------------------------------------------------------------------
61
865bb325 62extern "C" {
2e0e025e
RR
63static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxRadioBox *rb )
64{
65 if (g_isIdle)
66 wxapp_install_idle_handler();
67
68 if (!rb->m_hasVMT) return FALSE;
69 if (g_blockEventsOnDrag) return FALSE;
70
8228b893 71 if ( ((gdk_event->keyval == GDK_Tab) ||
5985c07c
RR
72 (gdk_event->keyval == GDK_ISO_Left_Tab)) &&
73 rb->GetParent() && (rb->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
74 {
75 wxNavigationKeyEvent new_event;
76 new_event.SetEventObject( rb->GetParent() );
77 // GDK reports GDK_ISO_Left_Tab for SHIFT-TAB
78 new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
79 // CTRL-TAB changes the (parent) window, i.e. switch notebook page
80 new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
81 new_event.SetCurrentFocus( rb );
82 return rb->GetParent()->GetEventHandler()->ProcessEvent( new_event );
83 }
84
2e0e025e
RR
85 if ((gdk_event->keyval != GDK_Up) &&
86 (gdk_event->keyval != GDK_Down) &&
87 (gdk_event->keyval != GDK_Left) &&
88 (gdk_event->keyval != GDK_Right))
89 {
90 return FALSE;
91 }
2da61056 92
222ed1d6 93 wxList::compatibility_iterator node = rb->m_boxes.Find( (wxObject*) widget );
2e0e025e
RR
94 if (!node)
95 {
96 return FALSE;
97 }
2da61056 98
9fa72bd2 99 g_signal_stop_emission_by_name (widget, "key_press_event");
2da61056 100
2e0e025e
RR
101 if ((gdk_event->keyval == GDK_Up) ||
102 (gdk_event->keyval == GDK_Left))
103 {
b1d4dd7a
RL
104 if (node == rb->m_boxes.GetFirst())
105 node = rb->m_boxes.GetLast();
2da61056 106 else
b1d4dd7a 107 node = node->GetPrevious();
2e0e025e
RR
108 }
109 else
110 {
b1d4dd7a
RL
111 if (node == rb->m_boxes.GetLast())
112 node = rb->m_boxes.GetFirst();
2da61056 113 else
b1d4dd7a 114 node = node->GetNext();
2e0e025e 115 }
2da61056 116
b1d4dd7a 117 GtkWidget *button = (GtkWidget*) node->GetData();
2da61056 118
2e0e025e 119 gtk_widget_grab_focus( button );
2da61056 120
2e0e025e
RR
121 return TRUE;
122}
865bb325 123}
2e0e025e 124
865bb325 125extern "C" {
f6bcfd97
BP
126static gint gtk_radiobutton_focus_in( GtkWidget *widget,
127 GdkEvent *WXUNUSED(event),
128 wxRadioBox *win )
129{
130 if ( win->m_lostFocus )
131 {
132 // no, we didn't really lose it
133 win->m_lostFocus = FALSE;
134 }
135 else if ( !win->m_hasFocus )
136 {
b4efc9b9 137 win->m_hasFocus = true;
f6bcfd97
BP
138
139 wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
140 event.SetEventObject( win );
141
142 // never stop the signal emission, it seems to break the kbd handling
143 // inside the radiobox
144 (void)win->GetEventHandler()->ProcessEvent( event );
145 }
146
147 return FALSE;
148}
865bb325 149}
f6bcfd97 150
865bb325 151extern "C" {
f6bcfd97
BP
152static gint gtk_radiobutton_focus_out( GtkWidget *widget,
153 GdkEvent *WXUNUSED(event),
154 wxRadioBox *win )
155{
cc1fcb95
JS
156 // wxASSERT_MSG( win->m_hasFocus, _T("got focus out without any focus in?") );
157 // Replace with a warning, else we dump core a lot!
158 // if (!win->m_hasFocus)
159 // wxLogWarning(_T("Radiobox got focus out without any focus in.") );
f6bcfd97
BP
160
161 // we might have lost the focus, but may be not - it may have just gone to
162 // another button in the same radiobox, so we'll check for it in the next
b4efc9b9
WS
163 // idle iteration (leave m_hasFocus == true for now)
164 win->m_lostFocus = true;
f6bcfd97
BP
165
166 return FALSE;
167}
865bb325 168}
f6bcfd97 169
b4071e91
RR
170//-----------------------------------------------------------------------------
171// wxRadioBox
c801d85f
KB
172//-----------------------------------------------------------------------------
173
174IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl)
175
f6bcfd97 176void wxRadioBox::Init()
c801d85f 177{
b4efc9b9
WS
178 m_needParent = true;
179 m_acceptsFocus = true;
f6bcfd97
BP
180
181 m_hasFocus =
b4efc9b9 182 m_lostFocus = false;
6de97a3b 183}
c801d85f 184
584ad2a3
MB
185bool wxRadioBox::Create( wxWindow *parent, wxWindowID id,
186 const wxString& title,
187 const wxPoint &pos, const wxSize &size,
188 const wxArrayString& choices, int majorDim,
189 long style, const wxValidator& validator,
190 const wxString &name )
191{
192 wxCArrayString chs(choices);
193
194 return Create( parent, id, title, pos, size, chs.GetCount(),
195 chs.GetStrings(), majorDim, style, validator, name );
196}
197
debe6624 198bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
907789a0 199 const wxPoint &pos, const wxSize &size,
29006414
VZ
200 int n, const wxString choices[], int majorDim,
201 long style, const wxValidator& validator,
202 const wxString &name )
c801d85f 203{
4dcaf11a
RR
204 if (!PreCreation( parent, pos, size ) ||
205 !CreateBase( parent, id, pos, size, style, validator, name ))
206 {
223d09f6 207 wxFAIL_MSG( wxT("wxRadioBox creation failed") );
b4efc9b9 208 return false;
4dcaf11a 209 }
6de97a3b 210
2e1f5012
VZ
211 m_widget = GTKCreateFrame(title);
212 wxControl::SetLabel(title);
29006414 213
5eaac5b5
VZ
214 // majorDim may be 0 if all trailing parameters were omitted, so don't
215 // assert here but just use the correct value for it
27c78e45 216 SetMajorDim(majorDim == 0 ? n : majorDim, style);
29006414 217
8017ee9b 218
aa61d352
VZ
219 unsigned int num_of_cols = GetColumnCount();
220 unsigned int num_of_rows = GetRowCount();
11e62fe6 221
907789a0 222 GtkRadioButton *m_radio = (GtkRadioButton*) NULL;
29006414 223
8017ee9b 224 GtkWidget *table = gtk_table_new( num_of_rows, num_of_cols, FALSE );
d504085d
RR
225 gtk_table_set_col_spacings( GTK_TABLE(table), 1 );
226 gtk_table_set_row_spacings( GTK_TABLE(table), 1 );
8017ee9b
RR
227 gtk_widget_show( table );
228 gtk_container_add( GTK_CONTAINER(m_widget), table );
11e62fe6 229
26333898 230 wxString label;
d3b4d113 231 GSList *radio_button_group = (GSList *) NULL;
8ebb2a1d 232 for (unsigned int i = 0; i < (unsigned int)n; i++)
c801d85f 233 {
26333898 234 if ( i != 0 )
78e017d8 235 radio_button_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON(m_radio) );
29006414 236
26333898
VZ
237 label.Empty();
238 for ( const wxChar *pc = choices[i]; *pc; pc++ )
239 {
223d09f6 240 if ( *pc != wxT('&') )
26333898
VZ
241 label += *pc;
242 }
243
fab591c5 244 m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, wxGTK_CONV( label ) ) );
8017ee9b 245 gtk_widget_show( GTK_WIDGET(m_radio) );
29006414 246
9fa72bd2
MR
247 g_signal_connect (m_radio, "key_press_event",
248 G_CALLBACK (gtk_radiobox_keypress_callback), this);
2da61056 249
d3b4d113 250 m_boxes.Append( (wxObject*) m_radio );
29006414 251
8017ee9b
RR
252 if (HasFlag(wxRA_SPECIFY_COLS))
253 {
254 int left = i%num_of_cols;
255 int right = (i%num_of_cols) + 1;
256 int top = i/num_of_cols;
257 int bottom = (i/num_of_cols)+1;
11e62fe6
WS
258 gtk_table_attach( GTK_TABLE(table), GTK_WIDGET(m_radio), left, right, top, bottom,
259 GTK_FILL, GTK_FILL, 1, 1 );
8017ee9b
RR
260 }
261 else
262 {
263 int left = i/num_of_rows;
264 int right = (i/num_of_rows) + 1;
265 int top = i%num_of_rows;
266 int bottom = (i%num_of_rows)+1;
11e62fe6
WS
267 gtk_table_attach( GTK_TABLE(table), GTK_WIDGET(m_radio), left, right, top, bottom,
268 GTK_FILL, GTK_FILL, 1, 1 );
8017ee9b
RR
269 }
270
d3b4d113 271 ConnectWidget( GTK_WIDGET(m_radio) );
29006414 272
e343da37
MR
273 if (!i)
274 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(m_radio), TRUE );
29006414 275
9fa72bd2
MR
276 g_signal_connect (m_radio, "clicked",
277 G_CALLBACK (gtk_radiobutton_clicked_callback), this);
278 g_signal_connect (m_radio, "focus_in_event",
279 G_CALLBACK (gtk_radiobutton_focus_in), this);
280 g_signal_connect (m_radio, "focus_out_event",
281 G_CALLBACK (gtk_radiobutton_focus_out), this);
6de97a3b 282 }
29006414 283
db434467
RR
284 m_parent->DoAddChild( this );
285
abdeb9e7 286 PostCreation(size);
29006414 287
b4efc9b9 288 return true;
6de97a3b 289}
c801d85f 290
f03fc89f 291wxRadioBox::~wxRadioBox()
d6d1892b 292{
222ed1d6 293 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
294 while (node)
295 {
b1d4dd7a 296 GtkWidget *button = GTK_WIDGET( node->GetData() );
907789a0 297 gtk_widget_destroy( button );
b1d4dd7a 298 node = node->GetNext();
907789a0 299 }
d6d1892b
RR
300}
301
debe6624 302bool wxRadioBox::Show( bool show )
c801d85f 303{
b4efc9b9 304 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 305
f96ac56a
RR
306 if (!wxControl::Show(show))
307 {
308 // nothing to do
b4efc9b9 309 return false;
f96ac56a 310 }
c801d85f 311
c4ca49cd 312 if ( HasFlag(wxNO_BORDER) )
b0351fc9 313 gtk_widget_hide( m_widget );
e3e717ec 314
222ed1d6 315 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
316 while (node)
317 {
b1d4dd7a 318 GtkWidget *button = GTK_WIDGET( node->GetData() );
29006414 319
27c78e45
VZ
320 if (show)
321 gtk_widget_show( button );
322 else
323 gtk_widget_hide( button );
29006414 324
b1d4dd7a 325 node = node->GetNext();
907789a0 326 }
c801d85f 327
b4efc9b9 328 return true;
6de97a3b 329}
c801d85f 330
b292e2f5
RR
331void wxRadioBox::SetFocus()
332{
223d09f6 333 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 334
b292e2f5 335 if (m_boxes.GetCount() == 0) return;
29006414 336
222ed1d6 337 wxList::compatibility_iterator node = m_boxes.GetFirst();
b292e2f5
RR
338 while (node)
339 {
b1d4dd7a 340 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() );
b292e2f5 341 if (button->active)
29006414 342 {
b292e2f5 343 gtk_widget_grab_focus( GTK_WIDGET(button) );
29006414
VZ
344 return;
345 }
b1d4dd7a 346 node = node->GetNext();
b292e2f5 347 }
b292e2f5
RR
348}
349
47908e25 350void wxRadioBox::SetSelection( int n )
c801d85f 351{
223d09f6 352 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 353
222ed1d6 354 wxList::compatibility_iterator node = m_boxes.Item( n );
29006414 355
223d09f6 356 wxCHECK_RET( node, wxT("radiobox wrong index") );
29006414 357
b1d4dd7a 358 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() );
29006414 359
72a7edf0 360 GtkDisableEvents();
2da61056 361
e2762ff0 362 gtk_toggle_button_set_active( button, 1 );
2da61056 363
72a7edf0 364 GtkEnableEvents();
6de97a3b 365}
c801d85f
KB
366
367int wxRadioBox::GetSelection(void) const
368{
789f6795 369 wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid radiobox") );
29006414 370
907789a0 371 int count = 0;
29006414 372
222ed1d6 373 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
374 while (node)
375 {
b1d4dd7a 376 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() );
907789a0
RR
377 if (button->active) return count;
378 count++;
b1d4dd7a 379 node = node->GetNext();
907789a0 380 }
29006414 381
223d09f6 382 wxFAIL_MSG( wxT("wxRadioBox none selected") );
29006414 383
789f6795 384 return wxNOT_FOUND;
6de97a3b 385}
c801d85f 386
aa61d352 387wxString wxRadioBox::GetString(unsigned int n) const
c801d85f 388{
1a87edf2 389 wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid radiobox") );
29006414 390
222ed1d6 391 wxList::compatibility_iterator node = m_boxes.Item( n );
29006414 392
1a87edf2 393 wxCHECK_MSG( node, wxEmptyString, wxT("radiobox wrong index") );
29006414 394
afa7bd1e 395 GtkLabel *label = GTK_LABEL(GTK_BIN(node->GetData())->child);
29006414 396
2b5f62a0 397 wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
2b5f62a0
VZ
398
399 return str;
6de97a3b 400}
c801d85f 401
d3904ceb 402void wxRadioBox::SetLabel( const wxString& label )
c801d85f 403{
223d09f6 404 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 405
b2ff89d6 406 GTKSetLabelForFrame(GTK_FRAME(m_widget), label);
6de97a3b 407}
c801d85f 408
aa61d352 409void wxRadioBox::SetString(unsigned int item, const wxString& label)
c801d85f 410{
223d09f6 411 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 412
222ed1d6 413 wxList::compatibility_iterator node = m_boxes.Item( item );
29006414 414
223d09f6 415 wxCHECK_RET( node, wxT("radiobox wrong index") );
29006414 416
afa7bd1e 417 GtkLabel *g_label = GTK_LABEL(GTK_BIN(node->GetData())->child);
29006414 418
a7c12d28 419 gtk_label_set_text( g_label, wxGTK_CONV( label ) );
6de97a3b 420}
c801d85f 421
f03fc89f 422bool wxRadioBox::Enable( bool enable )
c801d85f 423{
f03fc89f 424 if ( !wxControl::Enable( enable ) )
b4efc9b9 425 return false;
29006414 426
222ed1d6 427 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
428 while (node)
429 {
b1d4dd7a 430 GtkButton *button = GTK_BUTTON( node->GetData() );
afa7bd1e 431 GtkLabel *label = GTK_LABEL(GTK_BIN(button)->child);
9e691f46 432
907789a0 433 gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
9e691f46 434 gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
b1d4dd7a 435 node = node->GetNext();
907789a0 436 }
f03fc89f 437
b4efc9b9 438 return true;
6de97a3b 439}
c801d85f 440
aa61d352 441bool wxRadioBox::Enable(unsigned int item, bool enable)
c801d85f 442{
1a87edf2 443 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 444
222ed1d6 445 wxList::compatibility_iterator node = m_boxes.Item( item );
29006414 446
1a87edf2 447 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 448
b1d4dd7a 449 GtkButton *button = GTK_BUTTON( node->GetData() );
afa7bd1e 450 GtkLabel *label = GTK_LABEL(GTK_BIN(button)->child);
9e691f46 451
907789a0 452 gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
9e691f46 453 gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
1a87edf2
WS
454
455 return true;
6de97a3b 456}
c801d85f 457
aa61d352 458bool wxRadioBox::IsItemEnabled(unsigned int item) const
27c78e45
VZ
459{
460 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
461
462 wxList::compatibility_iterator node = m_boxes.Item( item );
463
464 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
465
466 GtkButton *button = GTK_BUTTON( node->GetData() );
467
468 // don't use GTK_WIDGET_IS_SENSITIVE() here, we want to return true even if
469 // the parent radiobox is disabled
470 return GTK_WIDGET_SENSITIVE(GTK_WIDGET(button));
471}
472
aa61d352 473bool wxRadioBox::Show(unsigned int item, bool show)
c801d85f 474{
789f6795 475 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 476
222ed1d6 477 wxList::compatibility_iterator node = m_boxes.Item( item );
29006414 478
789f6795 479 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 480
b1d4dd7a 481 GtkWidget *button = GTK_WIDGET( node->GetData() );
c801d85f 482
907789a0
RR
483 if (show)
484 gtk_widget_show( button );
485 else
486 gtk_widget_hide( button );
789f6795
WS
487
488 return true;
6de97a3b 489}
c801d85f 490
aa61d352 491bool wxRadioBox::IsItemShown(unsigned int item) const
c801d85f 492{
27c78e45 493 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 494
27c78e45 495 wxList::compatibility_iterator node = m_boxes.Item( item );
c801d85f 496
27c78e45 497 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 498
27c78e45 499 GtkButton *button = GTK_BUTTON( node->GetData() );
29006414 500
27c78e45 501 return GTK_WIDGET_VISIBLE(GTK_WIDGET(button));
6de97a3b 502}
c801d85f 503
aa61d352 504unsigned int wxRadioBox::GetCount() const
c801d85f 505{
b1d4dd7a 506 return m_boxes.GetCount();
6de97a3b 507}
c801d85f 508
72a7edf0 509void wxRadioBox::GtkDisableEvents()
953704c1 510{
222ed1d6 511 wxList::compatibility_iterator node = m_boxes.GetFirst();
953704c1
RR
512 while (node)
513 {
9fa72bd2
MR
514 g_signal_handlers_disconnect_by_func (node->GetData(),
515 (gpointer) gtk_radiobutton_clicked_callback,
516 this);
953704c1 517
b1d4dd7a 518 node = node->GetNext();
953704c1
RR
519 }
520}
521
72a7edf0 522void wxRadioBox::GtkEnableEvents()
953704c1 523{
222ed1d6 524 wxList::compatibility_iterator node = m_boxes.GetFirst();
953704c1
RR
525 while (node)
526 {
9fa72bd2
MR
527 g_signal_connect (node->GetData(), "clicked",
528 G_CALLBACK (gtk_radiobutton_clicked_callback), this);
953704c1 529
b1d4dd7a 530 node = node->GetNext();
953704c1
RR
531 }
532}
533
f40fdaa3 534void wxRadioBox::DoApplyWidgetStyle(GtkRcStyle *style)
868a2826 535{
2e1f5012 536 GTKFrameApplyWidgetStyle(GTK_FRAME(m_widget), style);
81e88f5b 537
222ed1d6 538 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
539 while (node)
540 {
b1d4dd7a 541 GtkWidget *widget = GTK_WIDGET( node->GetData() );
29006414 542
f40fdaa3 543 gtk_widget_modify_style( widget, style );
afa7bd1e 544 gtk_widget_modify_style(GTK_BIN(widget)->child, style);
29006414 545
b1d4dd7a 546 node = node->GetNext();
907789a0 547 }
868a2826 548}
b4071e91 549
2e1f5012
VZ
550bool wxRadioBox::GTKWidgetNeedsMnemonic() const
551{
552 return true;
553}
554
555void wxRadioBox::GTKWidgetDoSetMnemonic(GtkWidget* w)
556{
557 GTKFrameSetMnemonicWidget(GTK_FRAME(m_widget), w);
558}
559
72a7edf0
RR
560#if wxUSE_TOOLTIPS
561void wxRadioBox::ApplyToolTip( GtkTooltips *tips, const wxChar *tip )
562{
222ed1d6 563 wxList::compatibility_iterator node = m_boxes.GetFirst();
72a7edf0
RR
564 while (node)
565 {
b1d4dd7a 566 GtkWidget *widget = GTK_WIDGET( node->GetData() );
72a7edf0 567 gtk_tooltips_set_tip( tips, widget, wxConvCurrent->cWX2MB(tip), (gchar*) NULL );
b1d4dd7a 568 node = node->GetNext();
72a7edf0
RR
569 }
570}
571#endif // wxUSE_TOOLTIPS
572
b4071e91
RR
573bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window )
574{
27c78e45
VZ
575 if (window == m_widget->window)
576 return true;
29006414 577
222ed1d6 578 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
579 while (node)
580 {
b1d4dd7a 581 GtkWidget *button = GTK_WIDGET( node->GetData() );
29006414 582
27c78e45
VZ
583 if (window == button->window)
584 return true;
29006414 585
b1d4dd7a 586 node = node->GetNext();
907789a0 587 }
29006414 588
b4efc9b9 589 return false;
b4071e91 590}
dcf924a3 591
f6bcfd97
BP
592void wxRadioBox::OnInternalIdle()
593{
594 if ( m_lostFocus )
595 {
b4efc9b9
WS
596 m_hasFocus = false;
597 m_lostFocus = false;
f6bcfd97
BP
598
599 wxFocusEvent event( wxEVT_KILL_FOCUS, GetId() );
600 event.SetEventObject( this );
601
602 (void)GetEventHandler()->ProcessEvent( event );
603 }
d7fa7eaa
RR
604
605 if (g_delayedFocus == this)
606 {
607 if (GTK_WIDGET_REALIZED(m_widget))
608 {
609 g_delayedFocus = NULL;
610 SetFocus();
611 }
612 }
f6bcfd97
BP
613}
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
f6bcfd97 629#endif // wxUSE_RADIOBOX