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