]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/radiobox.cpp
minor cleanup 2 - reformatting
[wxWidgets.git] / src / gtk1 / radiobox.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
3cbab641 2// Name: src/gtk1/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
3cbab641 21#include "wx/gtk1/private.h"
3f26799e
RR
22#include <gdk/gdkkeysyms.h>
23
3cbab641 24#include "wx/gtk1/win_gtk.h"
c801d85f 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
2e0e025e 89 gtk_signal_emit_stop_by_name( GTK_OBJECT(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
aa61d352
VZ
209 unsigned int num_of_cols = GetColumnCount();
210 unsigned 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
VZ
224 if ( i != 0 )
225 radio_button_group = gtk_radio_button_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
2e0e025e
RR
237 gtk_signal_connect( GTK_OBJECT(m_radio), "key_press_event",
238 GTK_SIGNAL_FUNC(gtk_radiobox_keypress_callback), (gpointer)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
d3b4d113 263 if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE );
29006414
VZ
264
265 gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
354aa1e3 266 GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
29006414 267
f6bcfd97
BP
268 gtk_signal_connect( GTK_OBJECT(m_radio), "focus_in_event",
269 GTK_SIGNAL_FUNC(gtk_radiobutton_focus_in), (gpointer)this );
270
271 gtk_signal_connect( GTK_OBJECT(m_radio), "focus_out_event",
272 GTK_SIGNAL_FUNC(gtk_radiobutton_focus_out), (gpointer)this );
6de97a3b 273 }
29006414 274
db434467
RR
275 m_parent->DoAddChild( this );
276
abdeb9e7 277 PostCreation(size);
29006414 278
b4efc9b9 279 return true;
6de97a3b 280}
c801d85f 281
f03fc89f 282wxRadioBox::~wxRadioBox()
d6d1892b 283{
222ed1d6 284 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
285 while (node)
286 {
b1d4dd7a 287 GtkWidget *button = GTK_WIDGET( node->GetData() );
907789a0 288 gtk_widget_destroy( button );
b1d4dd7a 289 node = node->GetNext();
907789a0 290 }
d6d1892b
RR
291}
292
aa61d352 293bool wxRadioBox::Show(bool show)
c801d85f 294{
b4efc9b9 295 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 296
f96ac56a
RR
297 if (!wxControl::Show(show))
298 {
299 // nothing to do
b4efc9b9 300 return false;
f96ac56a 301 }
c801d85f 302
c4ca49cd 303 if ( HasFlag(wxNO_BORDER) )
b0351fc9 304 gtk_widget_hide( m_widget );
e3e717ec 305
222ed1d6 306 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
307 while (node)
308 {
b1d4dd7a 309 GtkWidget *button = GTK_WIDGET( node->GetData() );
29006414 310
27c78e45
VZ
311 if (show)
312 gtk_widget_show( button );
313 else
314 gtk_widget_hide( button );
29006414 315
b1d4dd7a 316 node = node->GetNext();
907789a0 317 }
c801d85f 318
b4efc9b9 319 return true;
6de97a3b 320}
c801d85f 321
b292e2f5
RR
322void wxRadioBox::SetFocus()
323{
223d09f6 324 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 325
b292e2f5 326 if (m_boxes.GetCount() == 0) return;
29006414 327
222ed1d6 328 wxList::compatibility_iterator node = m_boxes.GetFirst();
b292e2f5
RR
329 while (node)
330 {
b1d4dd7a 331 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() );
b292e2f5 332 if (button->active)
29006414 333 {
b292e2f5 334 gtk_widget_grab_focus( GTK_WIDGET(button) );
29006414
VZ
335 return;
336 }
b1d4dd7a 337 node = node->GetNext();
b292e2f5 338 }
b292e2f5
RR
339}
340
47908e25 341void wxRadioBox::SetSelection( int n )
c801d85f 342{
223d09f6 343 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 344
222ed1d6 345 wxList::compatibility_iterator node = m_boxes.Item( n );
29006414 346
223d09f6 347 wxCHECK_RET( node, wxT("radiobox wrong index") );
29006414 348
b1d4dd7a 349 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() );
29006414 350
72a7edf0 351 GtkDisableEvents();
2da61056 352
e2762ff0 353 gtk_toggle_button_set_active( button, 1 );
2da61056 354
72a7edf0 355 GtkEnableEvents();
6de97a3b 356}
c801d85f
KB
357
358int wxRadioBox::GetSelection(void) const
359{
789f6795 360 wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid radiobox") );
29006414 361
907789a0 362 int count = 0;
29006414 363
222ed1d6 364 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
365 while (node)
366 {
b1d4dd7a 367 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() );
907789a0
RR
368 if (button->active) return count;
369 count++;
b1d4dd7a 370 node = node->GetNext();
907789a0 371 }
29006414 372
223d09f6 373 wxFAIL_MSG( wxT("wxRadioBox none selected") );
29006414 374
789f6795 375 return wxNOT_FOUND;
6de97a3b 376}
c801d85f 377
aa61d352 378wxString wxRadioBox::GetString(unsigned int n) const
c801d85f 379{
1a87edf2 380 wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid radiobox") );
29006414 381
222ed1d6 382 wxList::compatibility_iterator node = m_boxes.Item( n );
29006414 383
1a87edf2 384 wxCHECK_MSG( node, wxEmptyString, wxT("radiobox wrong index") );
29006414 385
b1d4dd7a 386 GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->GetData()) );
29006414 387
2b5f62a0 388 wxString str( label->label );
2b5f62a0
VZ
389
390 return str;
6de97a3b 391}
c801d85f 392
d3904ceb 393void wxRadioBox::SetLabel( const wxString& label )
c801d85f 394{
223d09f6 395 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 396
b2ff89d6 397 GTKSetLabelForFrame(GTK_FRAME(m_widget), label);
6de97a3b 398}
c801d85f 399
aa61d352 400void wxRadioBox::SetString(unsigned int item, const wxString& label)
c801d85f 401{
223d09f6 402 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 403
222ed1d6 404 wxList::compatibility_iterator node = m_boxes.Item( item );
29006414 405
223d09f6 406 wxCHECK_RET( node, wxT("radiobox wrong index") );
29006414 407
b1d4dd7a 408 GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(node->GetData()) );
29006414 409
fab591c5 410 gtk_label_set( g_label, wxGTK_CONV( label ) );
6de97a3b 411}
c801d85f 412
f03fc89f 413bool wxRadioBox::Enable( bool enable )
c801d85f 414{
f03fc89f 415 if ( !wxControl::Enable( enable ) )
b4efc9b9 416 return false;
29006414 417
222ed1d6 418 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
419 while (node)
420 {
b1d4dd7a 421 GtkButton *button = GTK_BUTTON( node->GetData() );
9e691f46
VZ
422 GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
423
907789a0 424 gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
9e691f46 425 gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
b1d4dd7a 426 node = node->GetNext();
907789a0 427 }
f03fc89f 428
b4efc9b9 429 return true;
6de97a3b 430}
c801d85f 431
aa61d352 432bool wxRadioBox::Enable(unsigned int item, bool enable)
c801d85f 433{
1a87edf2 434 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 435
222ed1d6 436 wxList::compatibility_iterator node = m_boxes.Item( item );
29006414 437
1a87edf2 438 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 439
b1d4dd7a 440 GtkButton *button = GTK_BUTTON( node->GetData() );
9e691f46
VZ
441 GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
442
907789a0 443 gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
9e691f46 444 gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
1a87edf2
WS
445
446 return true;
6de97a3b 447}
c801d85f 448
aa61d352 449bool wxRadioBox::IsItemEnabled(unsigned int item) const
27c78e45
VZ
450{
451 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
452
453 wxList::compatibility_iterator node = m_boxes.Item( item );
454
455 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
456
457 GtkButton *button = GTK_BUTTON( node->GetData() );
458
459 // don't use GTK_WIDGET_IS_SENSITIVE() here, we want to return true even if
460 // the parent radiobox is disabled
461 return GTK_WIDGET_SENSITIVE(GTK_WIDGET(button));
462}
463
aa61d352 464bool wxRadioBox::Show(unsigned int item, bool show)
c801d85f 465{
789f6795 466 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 467
222ed1d6 468 wxList::compatibility_iterator node = m_boxes.Item( item );
29006414 469
789f6795 470 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 471
b1d4dd7a 472 GtkWidget *button = GTK_WIDGET( node->GetData() );
c801d85f 473
907789a0
RR
474 if (show)
475 gtk_widget_show( button );
476 else
477 gtk_widget_hide( button );
789f6795
WS
478
479 return true;
6de97a3b 480}
c801d85f 481
aa61d352 482bool wxRadioBox::IsItemShown(unsigned int item) const
c801d85f 483{
27c78e45 484 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 485
27c78e45 486 wxList::compatibility_iterator node = m_boxes.Item( item );
c801d85f 487
27c78e45 488 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 489
27c78e45 490 GtkButton *button = GTK_BUTTON( node->GetData() );
29006414 491
27c78e45 492 return GTK_WIDGET_VISIBLE(GTK_WIDGET(button));
6de97a3b 493}
c801d85f 494
aa61d352 495unsigned int wxRadioBox::GetCount() const
c801d85f 496{
b1d4dd7a 497 return m_boxes.GetCount();
6de97a3b 498}
c801d85f 499
72a7edf0 500void wxRadioBox::GtkDisableEvents()
953704c1 501{
222ed1d6 502 wxList::compatibility_iterator node = m_boxes.GetFirst();
953704c1
RR
503 while (node)
504 {
b1d4dd7a 505 gtk_signal_disconnect_by_func( GTK_OBJECT(node->GetData()),
953704c1
RR
506 GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
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 {
b1d4dd7a 517 gtk_signal_connect( GTK_OBJECT(node->GetData()), "clicked",
953704c1
RR
518 GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
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 );
29006414 527
222ed1d6 528 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
529 while (node)
530 {
b1d4dd7a 531 GtkWidget *widget = GTK_WIDGET( node->GetData() );
29006414 532
f40fdaa3
VS
533 gtk_widget_modify_style( widget, style );
534 gtk_widget_modify_style( BUTTON_CHILD(node->GetData()), style );
29006414 535
b1d4dd7a 536 node = node->GetNext();
907789a0 537 }
868a2826 538}
b4071e91 539
72a7edf0
RR
540#if wxUSE_TOOLTIPS
541void wxRadioBox::ApplyToolTip( GtkTooltips *tips, const wxChar *tip )
542{
222ed1d6 543 wxList::compatibility_iterator node = m_boxes.GetFirst();
72a7edf0
RR
544 while (node)
545 {
b1d4dd7a 546 GtkWidget *widget = GTK_WIDGET( node->GetData() );
72a7edf0 547 gtk_tooltips_set_tip( tips, widget, wxConvCurrent->cWX2MB(tip), (gchar*) NULL );
b1d4dd7a 548 node = node->GetNext();
72a7edf0
RR
549 }
550}
551#endif // wxUSE_TOOLTIPS
552
b4071e91
RR
553bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window )
554{
27c78e45
VZ
555 if (window == m_widget->window)
556 return true;
29006414 557
222ed1d6 558 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
559 while (node)
560 {
b1d4dd7a 561 GtkWidget *button = GTK_WIDGET( node->GetData() );
29006414 562
27c78e45
VZ
563 if (window == button->window)
564 return true;
29006414 565
b1d4dd7a 566 node = node->GetNext();
907789a0 567 }
29006414 568
b4efc9b9 569 return false;
b4071e91 570}
dcf924a3 571
f6bcfd97
BP
572void wxRadioBox::OnInternalIdle()
573{
574 if ( m_lostFocus )
575 {
b4efc9b9
WS
576 m_hasFocus = false;
577 m_lostFocus = false;
f6bcfd97
BP
578
579 wxFocusEvent event( wxEVT_KILL_FOCUS, GetId() );
580 event.SetEventObject( this );
581
582 (void)GetEventHandler()->ProcessEvent( event );
583 }
d7fa7eaa
RR
584
585 if (g_delayedFocus == this)
586 {
587 if (GTK_WIDGET_REALIZED(m_widget))
588 {
589 g_delayedFocus = NULL;
590 SetFocus();
591 }
592 }
f6bcfd97
BP
593}
594
9d522606
RD
595// static
596wxVisualAttributes
597wxRadioBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
598{
599 wxVisualAttributes attr;
bc0eb46c
VS
600 // NB: we need toplevel window so that GTK+ can find the right style
601 GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
9d522606 602 GtkWidget* widget = gtk_radio_button_new_with_label(NULL, "");
bc0eb46c 603 gtk_container_add(GTK_CONTAINER(wnd), widget);
9d522606 604 attr = GetDefaultAttributesFromGTKWidget(widget);
bc0eb46c 605 gtk_widget_destroy(wnd);
9d522606
RD
606 return attr;
607}
608
f6bcfd97 609#endif // wxUSE_RADIOBOX