]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/radiobox.cpp
Typos
[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
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
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
debe6624 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
47908e25 378wxString wxRadioBox::GetString( 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
VZ
388#ifdef __WXGTK20__
389 wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
390#else
391 wxString str( label->label );
392#endif
393
394 return str;
6de97a3b 395}
c801d85f 396
d3904ceb 397void wxRadioBox::SetLabel( const wxString& label )
c801d85f 398{
223d09f6 399 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 400
b2ff89d6 401 GTKSetLabelForFrame(GTK_FRAME(m_widget), label);
6de97a3b 402}
c801d85f 403
2da61056 404void wxRadioBox::SetString( int item, const wxString& label )
c801d85f 405{
223d09f6 406 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 407
222ed1d6 408 wxList::compatibility_iterator node = m_boxes.Item( item );
29006414 409
223d09f6 410 wxCHECK_RET( node, wxT("radiobox wrong index") );
29006414 411
b1d4dd7a 412 GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(node->GetData()) );
29006414 413
fab591c5 414 gtk_label_set( g_label, wxGTK_CONV( label ) );
6de97a3b 415}
c801d85f 416
f03fc89f 417bool wxRadioBox::Enable( bool enable )
c801d85f 418{
f03fc89f 419 if ( !wxControl::Enable( enable ) )
b4efc9b9 420 return false;
29006414 421
222ed1d6 422 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
423 while (node)
424 {
b1d4dd7a 425 GtkButton *button = GTK_BUTTON( node->GetData() );
9e691f46
VZ
426 GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
427
907789a0 428 gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
9e691f46 429 gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
b1d4dd7a 430 node = node->GetNext();
907789a0 431 }
f03fc89f 432
b4efc9b9 433 return true;
6de97a3b 434}
c801d85f 435
1a87edf2 436bool wxRadioBox::Enable( int item, bool enable )
c801d85f 437{
1a87edf2 438 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 439
222ed1d6 440 wxList::compatibility_iterator node = m_boxes.Item( item );
29006414 441
1a87edf2 442 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 443
b1d4dd7a 444 GtkButton *button = GTK_BUTTON( node->GetData() );
9e691f46
VZ
445 GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
446
907789a0 447 gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
9e691f46 448 gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
1a87edf2
WS
449
450 return true;
6de97a3b 451}
c801d85f 452
27c78e45
VZ
453bool wxRadioBox::IsItemEnabled(int item) const
454{
455 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
456
457 wxList::compatibility_iterator node = m_boxes.Item( item );
458
459 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
460
461 GtkButton *button = GTK_BUTTON( node->GetData() );
462
463 // don't use GTK_WIDGET_IS_SENSITIVE() here, we want to return true even if
464 // the parent radiobox is disabled
465 return GTK_WIDGET_SENSITIVE(GTK_WIDGET(button));
466}
467
789f6795 468bool wxRadioBox::Show( int item, bool show )
c801d85f 469{
789f6795 470 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 471
222ed1d6 472 wxList::compatibility_iterator node = m_boxes.Item( item );
29006414 473
789f6795 474 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 475
b1d4dd7a 476 GtkWidget *button = GTK_WIDGET( node->GetData() );
c801d85f 477
907789a0
RR
478 if (show)
479 gtk_widget_show( button );
480 else
481 gtk_widget_hide( button );
789f6795
WS
482
483 return true;
6de97a3b 484}
c801d85f 485
27c78e45 486bool wxRadioBox::IsItemShown(int item) const
c801d85f 487{
27c78e45 488 wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
29006414 489
27c78e45 490 wxList::compatibility_iterator node = m_boxes.Item( item );
c801d85f 491
27c78e45 492 wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
29006414 493
27c78e45 494 GtkButton *button = GTK_BUTTON( node->GetData() );
29006414 495
27c78e45 496 return GTK_WIDGET_VISIBLE(GTK_WIDGET(button));
6de97a3b 497}
c801d85f 498
2da61056 499int wxRadioBox::GetCount() const
c801d85f 500{
b1d4dd7a 501 return m_boxes.GetCount();
6de97a3b 502}
c801d85f 503
72a7edf0 504void wxRadioBox::GtkDisableEvents()
953704c1 505{
222ed1d6 506 wxList::compatibility_iterator node = m_boxes.GetFirst();
953704c1
RR
507 while (node)
508 {
b1d4dd7a 509 gtk_signal_disconnect_by_func( GTK_OBJECT(node->GetData()),
953704c1
RR
510 GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
511
b1d4dd7a 512 node = node->GetNext();
953704c1
RR
513 }
514}
515
72a7edf0 516void wxRadioBox::GtkEnableEvents()
953704c1 517{
222ed1d6 518 wxList::compatibility_iterator node = m_boxes.GetFirst();
953704c1
RR
519 while (node)
520 {
b1d4dd7a 521 gtk_signal_connect( GTK_OBJECT(node->GetData()), "clicked",
953704c1
RR
522 GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
523
b1d4dd7a 524 node = node->GetNext();
953704c1
RR
525 }
526}
527
f40fdaa3 528void wxRadioBox::DoApplyWidgetStyle(GtkRcStyle *style)
868a2826 529{
f40fdaa3 530 gtk_widget_modify_style( m_widget, style );
29006414 531
81e88f5b
RR
532#ifdef __WXGTK20__
533 gtk_widget_modify_style(GTK_FRAME(m_widget)->label_widget, style);
534#endif
535
222ed1d6 536 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
537 while (node)
538 {
b1d4dd7a 539 GtkWidget *widget = GTK_WIDGET( node->GetData() );
29006414 540
f40fdaa3
VS
541 gtk_widget_modify_style( widget, style );
542 gtk_widget_modify_style( BUTTON_CHILD(node->GetData()), style );
29006414 543
b1d4dd7a 544 node = node->GetNext();
907789a0 545 }
868a2826 546}
b4071e91 547
72a7edf0
RR
548#if wxUSE_TOOLTIPS
549void wxRadioBox::ApplyToolTip( GtkTooltips *tips, const wxChar *tip )
550{
222ed1d6 551 wxList::compatibility_iterator node = m_boxes.GetFirst();
72a7edf0
RR
552 while (node)
553 {
b1d4dd7a 554 GtkWidget *widget = GTK_WIDGET( node->GetData() );
72a7edf0 555 gtk_tooltips_set_tip( tips, widget, wxConvCurrent->cWX2MB(tip), (gchar*) NULL );
b1d4dd7a 556 node = node->GetNext();
72a7edf0
RR
557 }
558}
559#endif // wxUSE_TOOLTIPS
560
b4071e91
RR
561bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window )
562{
27c78e45
VZ
563 if (window == m_widget->window)
564 return true;
29006414 565
222ed1d6 566 wxList::compatibility_iterator node = m_boxes.GetFirst();
907789a0
RR
567 while (node)
568 {
b1d4dd7a 569 GtkWidget *button = GTK_WIDGET( node->GetData() );
29006414 570
27c78e45
VZ
571 if (window == button->window)
572 return true;
29006414 573
b1d4dd7a 574 node = node->GetNext();
907789a0 575 }
29006414 576
b4efc9b9 577 return false;
b4071e91 578}
dcf924a3 579
f6bcfd97
BP
580void wxRadioBox::OnInternalIdle()
581{
582 if ( m_lostFocus )
583 {
b4efc9b9
WS
584 m_hasFocus = false;
585 m_lostFocus = false;
f6bcfd97
BP
586
587 wxFocusEvent event( wxEVT_KILL_FOCUS, GetId() );
588 event.SetEventObject( this );
589
590 (void)GetEventHandler()->ProcessEvent( event );
591 }
d7fa7eaa
RR
592
593 if (g_delayedFocus == this)
594 {
595 if (GTK_WIDGET_REALIZED(m_widget))
596 {
597 g_delayedFocus = NULL;
598 SetFocus();
599 }
600 }
f6bcfd97
BP
601}
602
9d522606
RD
603// static
604wxVisualAttributes
605wxRadioBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
606{
607 wxVisualAttributes attr;
bc0eb46c
VS
608 // NB: we need toplevel window so that GTK+ can find the right style
609 GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
9d522606 610 GtkWidget* widget = gtk_radio_button_new_with_label(NULL, "");
bc0eb46c 611 gtk_container_add(GTK_CONTAINER(wnd), widget);
9d522606 612 attr = GetDefaultAttributesFromGTKWidget(widget);
bc0eb46c 613 gtk_widget_destroy(wnd);
9d522606
RD
614 return attr;
615}
616
f6bcfd97 617#endif // wxUSE_RADIOBOX