]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/radiobox.cpp
fixed typo in previous commit which, instead of fixing the bug in wxSizerflags::Align...
[wxWidgets.git] / src / gtk1 / 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
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
fab591c5 201 m_widget = gtk_frame_new( wxGTK_CONV( title ) );
29006414 202
5eaac5b5
VZ
203 // majorDim may be 0 if all trailing parameters were omitted, so don't
204 // assert here but just use the correct value for it
27c78e45 205 SetMajorDim(majorDim == 0 ? n : majorDim, style);
29006414 206
8017ee9b 207
27c78e45
VZ
208 int num_of_cols = GetColumnCount();
209 int num_of_rows = GetRowCount();
11e62fe6 210
907789a0 211 GtkRadioButton *m_radio = (GtkRadioButton*) NULL;
29006414 212
8017ee9b 213 GtkWidget *table = gtk_table_new( num_of_rows, num_of_cols, FALSE );
d504085d
RR
214 gtk_table_set_col_spacings( GTK_TABLE(table), 1 );
215 gtk_table_set_row_spacings( GTK_TABLE(table), 1 );
8017ee9b
RR
216 gtk_widget_show( table );
217 gtk_container_add( GTK_CONTAINER(m_widget), table );
11e62fe6 218
26333898 219 wxString label;
d3b4d113
RR
220 GSList *radio_button_group = (GSList *) NULL;
221 for (int i = 0; i < n; i++)
c801d85f 222 {
26333898
VZ
223 if ( i != 0 )
224 radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) );
29006414 225
26333898
VZ
226 label.Empty();
227 for ( const wxChar *pc = choices[i]; *pc; pc++ )
228 {
223d09f6 229 if ( *pc != wxT('&') )
26333898
VZ
230 label += *pc;
231 }
232
fab591c5 233 m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, wxGTK_CONV( label ) ) );
8017ee9b 234 gtk_widget_show( GTK_WIDGET(m_radio) );
29006414 235
2e0e025e
RR
236 gtk_signal_connect( GTK_OBJECT(m_radio), "key_press_event",
237 GTK_SIGNAL_FUNC(gtk_radiobox_keypress_callback), (gpointer)this );
2da61056 238
d3b4d113 239 m_boxes.Append( (wxObject*) m_radio );
29006414 240
8017ee9b
RR
241 if (HasFlag(wxRA_SPECIFY_COLS))
242 {
243 int left = i%num_of_cols;
244 int right = (i%num_of_cols) + 1;
245 int top = i/num_of_cols;
246 int bottom = (i/num_of_cols)+1;
11e62fe6
WS
247 gtk_table_attach( GTK_TABLE(table), GTK_WIDGET(m_radio), left, right, top, bottom,
248 GTK_FILL, GTK_FILL, 1, 1 );
8017ee9b
RR
249 }
250 else
251 {
252 int left = i/num_of_rows;
253 int right = (i/num_of_rows) + 1;
254 int top = i%num_of_rows;
255 int bottom = (i%num_of_rows)+1;
11e62fe6
WS
256 gtk_table_attach( GTK_TABLE(table), GTK_WIDGET(m_radio), left, right, top, bottom,
257 GTK_FILL, GTK_FILL, 1, 1 );
8017ee9b
RR
258 }
259
d3b4d113 260 ConnectWidget( GTK_WIDGET(m_radio) );
29006414 261
d3b4d113 262 if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE );
29006414
VZ
263
264 gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
354aa1e3 265 GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
29006414 266
f6bcfd97
BP
267 gtk_signal_connect( GTK_OBJECT(m_radio), "focus_in_event",
268 GTK_SIGNAL_FUNC(gtk_radiobutton_focus_in), (gpointer)this );
269
270 gtk_signal_connect( GTK_OBJECT(m_radio), "focus_out_event",
271 GTK_SIGNAL_FUNC(gtk_radiobutton_focus_out), (gpointer)this );
6de97a3b 272 }
29006414 273
db434467
RR
274 m_parent->DoAddChild( this );
275
db434467
RR
276 SetLabel( title );
277
abdeb9e7 278 PostCreation(size);
29006414 279
b4efc9b9 280 return true;
6de97a3b 281}
c801d85f 282
f03fc89f 283wxRadioBox::~wxRadioBox()
d6d1892b 284{
222ed1d6 285 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
286 while (node)
287 {
b1d4dd7a 288 GtkWidget *button = GTK_WIDGET( node->GetData() );
907789a0 289 gtk_widget_destroy( button );
b1d4dd7a 290 node = node->GetNext();
907789a0 291 }
d6d1892b
RR
292}
293
debe6624 294bool wxRadioBox::Show( bool show )
c801d85f 295{
b4efc9b9 296 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 297
f96ac56a
RR
298 if (!wxControl::Show(show))
299 {
300 // nothing to do
b4efc9b9 301 return false;
f96ac56a 302 }
c801d85f 303
c4ca49cd 304 if ( HasFlag(wxNO_BORDER) )
b0351fc9 305 gtk_widget_hide( m_widget );
e3e717ec 306
222ed1d6 307 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
308 while (node)
309 {
b1d4dd7a 310 GtkWidget *button = GTK_WIDGET( node->GetData() );
29006414 311
27c78e45
VZ
312 if (show)
313 gtk_widget_show( button );
314 else
315 gtk_widget_hide( button );
29006414 316
b1d4dd7a 317 node = node->GetNext();
907789a0 318 }
c801d85f 319
b4efc9b9 320 return true;
6de97a3b 321}
c801d85f 322
b292e2f5
RR
323void wxRadioBox::SetFocus()
324{
223d09f6 325 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 326
b292e2f5 327 if (m_boxes.GetCount() == 0) return;
29006414 328
222ed1d6 329 wxList::compatibility_iterator node = m_boxes.GetFirst();
b292e2f5
RR
330 while (node)
331 {
b1d4dd7a 332 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() );
b292e2f5 333 if (button->active)
29006414 334 {
b292e2f5 335 gtk_widget_grab_focus( GTK_WIDGET(button) );
29006414
VZ
336 return;
337 }
b1d4dd7a 338 node = node->GetNext();
b292e2f5 339 }
b292e2f5
RR
340}
341
47908e25 342void wxRadioBox::SetSelection( int n )
c801d85f 343{
223d09f6 344 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 345
222ed1d6 346 wxList::compatibility_iterator node = m_boxes.Item( n );
29006414 347
223d09f6 348 wxCHECK_RET( node, wxT("radiobox wrong index") );
29006414 349
b1d4dd7a 350 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() );
29006414 351
72a7edf0 352 GtkDisableEvents();
2da61056 353
e2762ff0 354 gtk_toggle_button_set_active( button, 1 );
2da61056 355
72a7edf0 356 GtkEnableEvents();
6de97a3b 357}
c801d85f
KB
358
359int wxRadioBox::GetSelection(void) const
360{
789f6795 361 wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid radiobox") );
29006414 362
907789a0 363 int count = 0;
29006414 364
222ed1d6 365 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
366 while (node)
367 {
b1d4dd7a 368 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() );
907789a0
RR
369 if (button->active) return count;
370 count++;
b1d4dd7a 371 node = node->GetNext();
907789a0 372 }
29006414 373
223d09f6 374 wxFAIL_MSG( wxT("wxRadioBox none selected") );
29006414 375
789f6795 376 return wxNOT_FOUND;
6de97a3b 377}
c801d85f 378
47908e25 379wxString wxRadioBox::GetString( int n ) const
c801d85f 380{
1a87edf2 381 wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid radiobox") );
29006414 382
222ed1d6 383 wxList::compatibility_iterator node = m_boxes.Item( n );
29006414 384
1a87edf2 385 wxCHECK_MSG( node, wxEmptyString, wxT("radiobox wrong index") );
29006414 386
b1d4dd7a 387 GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->GetData()) );
29006414 388
2b5f62a0
VZ
389#ifdef __WXGTK20__
390 wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
391#else
392 wxString str( label->label );
393#endif
394
395 return str;
6de97a3b 396}
c801d85f 397
d3904ceb 398void wxRadioBox::SetLabel( const wxString& label )
c801d85f 399{
223d09f6 400 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 401
907789a0 402 wxControl::SetLabel( label );
29006414 403
fab591c5 404 gtk_frame_set_label( GTK_FRAME(m_widget), wxGTK_CONV( wxControl::GetLabel() ) );
6de97a3b 405}
c801d85f 406
2da61056 407void wxRadioBox::SetString( int item, const wxString& label )
c801d85f 408{
223d09f6 409 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 410
222ed1d6 411 wxList::compatibility_iterator node = m_boxes.Item( item );
29006414 412
223d09f6 413 wxCHECK_RET( node, wxT("radiobox wrong index") );
29006414 414
b1d4dd7a 415 GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(node->GetData()) );
29006414 416
fab591c5 417 gtk_label_set( g_label, wxGTK_CONV( label ) );
6de97a3b 418}
c801d85f 419
f03fc89f 420bool wxRadioBox::Enable( bool enable )
c801d85f 421{
f03fc89f 422 if ( !wxControl::Enable( enable ) )
b4efc9b9 423 return false;
29006414 424
222ed1d6 425 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
426 while (node)
427 {
b1d4dd7a 428 GtkButton *button = GTK_BUTTON( node->GetData() );
9e691f46
VZ
429 GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
430
907789a0 431 gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
9e691f46 432 gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
b1d4dd7a 433 node = node->GetNext();
907789a0 434 }
f03fc89f 435
b4efc9b9 436 return true;
6de97a3b 437}
c801d85f 438
1a87edf2 439bool wxRadioBox::Enable( int item, bool enable )
c801d85f 440{
1a87edf2 441 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 442
222ed1d6 443 wxList::compatibility_iterator node = m_boxes.Item( item );
29006414 444
1a87edf2 445 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 446
b1d4dd7a 447 GtkButton *button = GTK_BUTTON( node->GetData() );
9e691f46
VZ
448 GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
449
907789a0 450 gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
9e691f46 451 gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
1a87edf2
WS
452
453 return true;
6de97a3b 454}
c801d85f 455
27c78e45
VZ
456bool wxRadioBox::IsItemEnabled(int item) const
457{
458 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
459
460 wxList::compatibility_iterator node = m_boxes.Item( item );
461
462 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
463
464 GtkButton *button = GTK_BUTTON( node->GetData() );
465
466 // don't use GTK_WIDGET_IS_SENSITIVE() here, we want to return true even if
467 // the parent radiobox is disabled
468 return GTK_WIDGET_SENSITIVE(GTK_WIDGET(button));
469}
470
789f6795 471bool wxRadioBox::Show( int item, bool show )
c801d85f 472{
789f6795 473 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 474
222ed1d6 475 wxList::compatibility_iterator node = m_boxes.Item( item );
29006414 476
789f6795 477 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 478
b1d4dd7a 479 GtkWidget *button = GTK_WIDGET( node->GetData() );
c801d85f 480
907789a0
RR
481 if (show)
482 gtk_widget_show( button );
483 else
484 gtk_widget_hide( button );
789f6795
WS
485
486 return true;
6de97a3b 487}
c801d85f 488
27c78e45 489bool wxRadioBox::IsItemShown(int item) const
c801d85f 490{
27c78e45 491 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 492
27c78e45 493 wxList::compatibility_iterator node = m_boxes.Item( item );
c801d85f 494
27c78e45 495 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 496
27c78e45 497 GtkButton *button = GTK_BUTTON( node->GetData() );
29006414 498
27c78e45 499 return GTK_WIDGET_VISIBLE(GTK_WIDGET(button));
6de97a3b 500}
c801d85f 501
2da61056 502int wxRadioBox::GetCount() const
c801d85f 503{
b1d4dd7a 504 return m_boxes.GetCount();
6de97a3b 505}
c801d85f 506
72a7edf0 507void wxRadioBox::GtkDisableEvents()
953704c1 508{
222ed1d6 509 wxList::compatibility_iterator node = m_boxes.GetFirst();
953704c1
RR
510 while (node)
511 {
b1d4dd7a 512 gtk_signal_disconnect_by_func( GTK_OBJECT(node->GetData()),
953704c1
RR
513 GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
514
b1d4dd7a 515 node = node->GetNext();
953704c1
RR
516 }
517}
518
72a7edf0 519void wxRadioBox::GtkEnableEvents()
953704c1 520{
222ed1d6 521 wxList::compatibility_iterator node = m_boxes.GetFirst();
953704c1
RR
522 while (node)
523 {
b1d4dd7a 524 gtk_signal_connect( GTK_OBJECT(node->GetData()), "clicked",
953704c1
RR
525 GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
526
b1d4dd7a 527 node = node->GetNext();
953704c1
RR
528 }
529}
530
f40fdaa3 531void wxRadioBox::DoApplyWidgetStyle(GtkRcStyle *style)
868a2826 532{
f40fdaa3 533 gtk_widget_modify_style( m_widget, style );
29006414 534
81e88f5b
RR
535#ifdef __WXGTK20__
536 gtk_widget_modify_style(GTK_FRAME(m_widget)->label_widget, style);
537#endif
538
222ed1d6 539 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
540 while (node)
541 {
b1d4dd7a 542 GtkWidget *widget = GTK_WIDGET( node->GetData() );
29006414 543
f40fdaa3
VS
544 gtk_widget_modify_style( widget, style );
545 gtk_widget_modify_style( BUTTON_CHILD(node->GetData()), style );
29006414 546
b1d4dd7a 547 node = node->GetNext();
907789a0 548 }
868a2826 549}
b4071e91 550
72a7edf0
RR
551#if wxUSE_TOOLTIPS
552void wxRadioBox::ApplyToolTip( GtkTooltips *tips, const wxChar *tip )
553{
222ed1d6 554 wxList::compatibility_iterator node = m_boxes.GetFirst();
72a7edf0
RR
555 while (node)
556 {
b1d4dd7a 557 GtkWidget *widget = GTK_WIDGET( node->GetData() );
72a7edf0 558 gtk_tooltips_set_tip( tips, widget, wxConvCurrent->cWX2MB(tip), (gchar*) NULL );
b1d4dd7a 559 node = node->GetNext();
72a7edf0
RR
560 }
561}
562#endif // wxUSE_TOOLTIPS
563
b4071e91
RR
564bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window )
565{
27c78e45
VZ
566 if (window == m_widget->window)
567 return true;
29006414 568
222ed1d6 569 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
570 while (node)
571 {
b1d4dd7a 572 GtkWidget *button = GTK_WIDGET( node->GetData() );
29006414 573
27c78e45
VZ
574 if (window == button->window)
575 return true;
29006414 576
b1d4dd7a 577 node = node->GetNext();
907789a0 578 }
29006414 579
b4efc9b9 580 return false;
b4071e91 581}
dcf924a3 582
f6bcfd97
BP
583void wxRadioBox::OnInternalIdle()
584{
585 if ( m_lostFocus )
586 {
b4efc9b9
WS
587 m_hasFocus = false;
588 m_lostFocus = false;
f6bcfd97
BP
589
590 wxFocusEvent event( wxEVT_KILL_FOCUS, GetId() );
591 event.SetEventObject( this );
592
593 (void)GetEventHandler()->ProcessEvent( event );
594 }
d7fa7eaa
RR
595
596 if (g_delayedFocus == this)
597 {
598 if (GTK_WIDGET_REALIZED(m_widget))
599 {
600 g_delayedFocus = NULL;
601 SetFocus();
602 }
603 }
f6bcfd97
BP
604}
605
9d522606
RD
606// static
607wxVisualAttributes
608wxRadioBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
609{
610 wxVisualAttributes attr;
bc0eb46c
VS
611 // NB: we need toplevel window so that GTK+ can find the right style
612 GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
9d522606 613 GtkWidget* widget = gtk_radio_button_new_with_label(NULL, "");
bc0eb46c 614 gtk_container_add(GTK_CONTAINER(wnd), widget);
9d522606 615 attr = GetDefaultAttributesFromGTKWidget(widget);
bc0eb46c 616 gtk_widget_destroy(wnd);
9d522606
RD
617 return attr;
618}
619
f6bcfd97 620#endif // wxUSE_RADIOBOX