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