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