]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/radiobox.cpp
Fixed broken compilation due to Ove's last nice changes :-(
[wxWidgets.git] / src / gtk1 / radiobox.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: radiobox.cpp
3// Purpose:
4// Author: Robert Roebling
f96aa4d9
RR
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
29006414 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
c801d85f
KB
10#ifdef __GNUG__
11#pragma implementation "radiobox.h"
12#endif
13
14#include "wx/radiobox.h"
dcf924a3
RR
15
16#if wxUSE_RADIOBOX
17
c801d85f
KB
18#include "wx/dialog.h"
19#include "wx/frame.h"
83624f79 20
3f26799e
RR
21#include <gdk/gdk.h>
22#include <gtk/gtk.h>
23#include <gdk/gdkkeysyms.h>
24
c801d85f
KB
25#include "wx/gtk/win_gtk.h"
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
69ffe1d2 38extern bool g_blockEventsOnDrag;
66bd6b93 39
c801d85f 40//-----------------------------------------------------------------------------
b4071e91 41// "clicked"
c801d85f
KB
42//-----------------------------------------------------------------------------
43
66bd6b93 44static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb )
c801d85f 45{
acfd422a
RR
46 if (g_isIdle) wxapp_install_idle_handler();
47
a2053b27 48 if (!rb->m_hasVMT) return;
907789a0 49 if (g_blockEventsOnDrag) return;
29006414 50
907789a0
RR
51 if (rb->m_alreadySent)
52 {
53 rb->m_alreadySent = FALSE;
54 return;
55 }
47908e25 56
907789a0 57 rb->m_alreadySent = TRUE;
29006414 58
907789a0
RR
59 wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, rb->GetId() );
60 event.SetInt( rb->GetSelection() );
29006414 61 event.SetString( rb->GetStringSelection() );
907789a0
RR
62 event.SetEventObject( rb );
63 rb->GetEventHandler()->ProcessEvent(event);
6de97a3b 64}
c801d85f 65
2e0e025e
RR
66//-----------------------------------------------------------------------------
67// "key_press_event"
68//-----------------------------------------------------------------------------
69
70static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxRadioBox *rb )
71{
72 if (g_isIdle)
73 wxapp_install_idle_handler();
74
75 if (!rb->m_hasVMT) return FALSE;
76 if (g_blockEventsOnDrag) return FALSE;
77
78 if ((gdk_event->keyval != GDK_Up) &&
79 (gdk_event->keyval != GDK_Down) &&
80 (gdk_event->keyval != GDK_Left) &&
81 (gdk_event->keyval != GDK_Right))
82 {
83 return FALSE;
84 }
85
86 wxNode *node = rb->m_boxes.Find( (wxObject*) widget );
87 if (!node)
88 {
89 return FALSE;
90 }
91
92 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
93
94 if ((gdk_event->keyval == GDK_Up) ||
95 (gdk_event->keyval == GDK_Left))
96 {
97 if (node == rb->m_boxes.First())
98 node = rb->m_boxes.Last();
99 else
100 node = node->Previous();
101 }
102 else
103 {
104 if (node == rb->m_boxes.Last())
105 node = rb->m_boxes.First();
106 else
107 node = node->Next();
108 }
109
110 GtkWidget *button = (GtkWidget*) node->Data();
111
112 gtk_widget_grab_focus( button );
113
114 return TRUE;
115}
116
f6bcfd97
BP
117static gint gtk_radiobutton_focus_in( GtkWidget *widget,
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 {
128 win->m_hasFocus = TRUE;
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
135 (void)win->GetEventHandler()->ProcessEvent( event );
136 }
137
138 return FALSE;
139}
140
141static gint gtk_radiobutton_focus_out( GtkWidget *widget,
142 GdkEvent *WXUNUSED(event),
143 wxRadioBox *win )
144{
145 wxASSERT_MSG( win->m_hasFocus, _T("got focus out without any focus in?") );
146
147 // we might have lost the focus, but may be not - it may have just gone to
148 // another button in the same radiobox, so we'll check for it in the next
149 // idle iteration (leave m_hasFocus == TRUE for now)
150 win->m_lostFocus = TRUE;
151
152 return FALSE;
153}
154
b4071e91
RR
155//-----------------------------------------------------------------------------
156// wxRadioBox
c801d85f
KB
157//-----------------------------------------------------------------------------
158
159IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl)
160
f6bcfd97 161void wxRadioBox::Init()
c801d85f 162{
f6bcfd97
BP
163 m_alreadySent = FALSE;
164 m_needParent = TRUE;
165 m_acceptsFocus = TRUE;
166
167 m_hasFocus =
168 m_lostFocus = FALSE;
6de97a3b 169}
c801d85f 170
debe6624 171bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
907789a0 172 const wxPoint &pos, const wxSize &size,
29006414
VZ
173 int n, const wxString choices[], int majorDim,
174 long style, const wxValidator& validator,
175 const wxString &name )
c801d85f 176{
4dcaf11a
RR
177 if (!PreCreation( parent, pos, size ) ||
178 !CreateBase( parent, id, pos, size, style, validator, name ))
179 {
223d09f6 180 wxFAIL_MSG( wxT("wxRadioBox creation failed") );
4dcaf11a
RR
181 return FALSE;
182 }
6de97a3b 183
b019151f 184 m_widget = gtk_frame_new( title.mbc_str() );
29006414 185
d3b4d113 186 m_majorDim = majorDim;
29006414 187
907789a0 188 GtkRadioButton *m_radio = (GtkRadioButton*) NULL;
29006414 189
26333898 190 wxString label;
d3b4d113
RR
191 GSList *radio_button_group = (GSList *) NULL;
192 for (int i = 0; i < n; i++)
c801d85f 193 {
26333898
VZ
194 if ( i != 0 )
195 radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) );
29006414 196
26333898
VZ
197 label.Empty();
198 for ( const wxChar *pc = choices[i]; *pc; pc++ )
199 {
223d09f6 200 if ( *pc != wxT('&') )
26333898
VZ
201 label += *pc;
202 }
203
204 m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, label.mbc_str() ) );
29006414 205
2e0e025e
RR
206 gtk_signal_connect( GTK_OBJECT(m_radio), "key_press_event",
207 GTK_SIGNAL_FUNC(gtk_radiobox_keypress_callback), (gpointer)this );
208
d3b4d113 209 m_boxes.Append( (wxObject*) m_radio );
29006414 210
d3b4d113 211 ConnectWidget( GTK_WIDGET(m_radio) );
29006414 212
d3b4d113 213 if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE );
29006414
VZ
214
215 gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
354aa1e3 216 GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
29006414 217
f6bcfd97
BP
218 gtk_signal_connect( GTK_OBJECT(m_radio), "focus_in_event",
219 GTK_SIGNAL_FUNC(gtk_radiobutton_focus_in), (gpointer)this );
220
221 gtk_signal_connect( GTK_OBJECT(m_radio), "focus_out_event",
222 GTK_SIGNAL_FUNC(gtk_radiobutton_focus_out), (gpointer)this );
223
da048e3d 224 gtk_pizza_put( GTK_PIZZA(m_parent->m_wxwindow),
e3e717ec 225 GTK_WIDGET(m_radio),
f03fc89f 226 m_x+10, m_y+10+(i*24), 10, 10 );
6de97a3b 227 }
29006414 228
db434467
RR
229 m_parent->DoAddChild( this );
230
231 PostCreation();
7e2b55cd
RR
232
233 ApplyWidgetStyle();
db434467 234
db434467
RR
235 SetLabel( title );
236
237 SetFont( parent->GetFont() );
238
d3b4d113 239 wxSize ls = LayoutItems();
29006414 240
a56fcaaf
RR
241 GtkRequisition req;
242 req.width = 2;
243 req.height = 2;
2afa14f2 244 (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request ) (m_widget, &req );
a56fcaaf
RR
245 if (req.width > ls.x) ls.x = req.width;
246
907789a0 247 wxSize newSize = size;
d3b4d113
RR
248 if (newSize.x == -1) newSize.x = ls.x;
249 if (newSize.y == -1) newSize.y = ls.y;
907789a0 250 SetSize( newSize.x, newSize.y );
29006414 251
907789a0
RR
252 SetBackgroundColour( parent->GetBackgroundColour() );
253 SetForegroundColour( parent->GetForegroundColour() );
f96aa4d9 254
907789a0 255 Show( TRUE );
29006414 256
907789a0 257 return TRUE;
6de97a3b 258}
c801d85f 259
f03fc89f 260wxRadioBox::~wxRadioBox()
d6d1892b 261{
907789a0
RR
262 wxNode *node = m_boxes.First();
263 while (node)
264 {
265 GtkWidget *button = GTK_WIDGET( node->Data() );
266 gtk_widget_destroy( button );
267 node = node->Next();
268 }
d6d1892b
RR
269}
270
54517652 271void wxRadioBox::DoSetSize( int x, int y, int width, int height, int sizeFlags )
3f659fd6 272{
54517652
RR
273 wxWindow::DoSetSize( x, y, width, height, sizeFlags );
274
d3b4d113
RR
275 LayoutItems();
276}
277
278wxSize wxRadioBox::LayoutItems()
279{
bbe0af5b
RR
280 int x = 7;
281 int y = 15;
29006414 282
e3e717ec
VZ
283 if ( m_majorDim == 0 )
284 {
285 // avoid dividing by 0 below
223d09f6 286 wxFAIL_MSG( wxT("dimension of radiobox should not be 0!") );
e3e717ec
VZ
287
288 m_majorDim = 1;
289 }
290
d3b4d113 291 int num_per_major = (m_boxes.GetCount() - 1) / m_majorDim +1;
29006414 292
d3b4d113 293 wxSize res( 0, 0 );
29006414 294
e9158f7d
RR
295 int num_of_cols = 0;
296 int num_of_rows = 0;
297 if (HasFlag(wxRA_SPECIFY_COLS))
d3b4d113 298 {
e9158f7d
RR
299 num_of_cols = m_majorDim;
300 num_of_rows = num_per_major;
301 }
302 else
303 {
304 num_of_cols = num_per_major;
305 num_of_rows = m_majorDim;
306 }
307
308 if ( HasFlag(wxRA_SPECIFY_COLS) ||
309 (HasFlag(wxRA_SPECIFY_ROWS) && (num_of_cols > 1)) )
310 {
311 for (int j = 0; j < num_of_cols; j++)
29006414 312 {
bbe0af5b 313 y = 15;
29006414 314
d3b4d113 315 int max_len = 0;
e9158f7d
RR
316 wxNode *node = m_boxes.Nth( j*num_of_rows );
317 for (int i1 = 0; i1< num_of_rows; i1++)
29006414 318 {
d3b4d113 319 GtkWidget *button = GTK_WIDGET( node->Data() );
165b6ee0
VS
320
321 GtkRequisition req;
322 req.width = 2;
323 req.height = 2;
2afa14f2 324 (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(button) )->size_request )
165b6ee0
VS
325 (button, &req );
326
327 if (req.width > max_len) max_len = req.width;
29006414 328
da048e3d 329 gtk_pizza_move( GTK_PIZZA(m_parent->m_wxwindow), button, m_x+x, m_y+y );
165b6ee0 330 y += req.height;
29006414
VZ
331
332 node = node->Next();
333 if (!node) break;
334 }
335
336 // we don't know the max_len before
337
e9158f7d
RR
338 node = m_boxes.Nth( j*num_of_rows );
339 for (int i2 = 0; i2< num_of_rows; i2++)
29006414 340 {
d3b4d113 341 GtkWidget *button = GTK_WIDGET( node->Data() );
29006414 342
da048e3d 343 gtk_pizza_resize( GTK_PIZZA(m_parent->m_wxwindow), button, max_len, 20 );
29006414
VZ
344
345 node = node->Next();
346 if (!node) break;
347 }
348
349 if (y > res.y) res.y = y;
350
351 x += max_len + 2;
d3b4d113 352 }
29006414
VZ
353
354 res.x = x+4;
165b6ee0 355 res.y += 4;
e5403d7c 356 }
d3b4d113 357 else
e5403d7c 358 {
d3b4d113
RR
359 int max = 0;
360
361 wxNode *node = m_boxes.First();
362 while (node)
363 {
165b6ee0
VS
364 GtkWidget *button = GTK_WIDGET( node->Data() );
365
366 GtkRequisition req;
367 req.width = 2;
368 req.height = 2;
2afa14f2 369 (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(button) )->size_request )
165b6ee0 370 (button, &req );
29006414 371
165b6ee0 372 if (req.width > max) max = req.width;
29006414 373
d3b4d113
RR
374 node = node->Next();
375 }
29006414 376
d3b4d113
RR
377 node = m_boxes.First();
378 while (node)
379 {
380 GtkWidget *button = GTK_WIDGET( node->Data() );
29006414 381
da048e3d 382 gtk_pizza_set_size( GTK_PIZZA(m_parent->m_wxwindow), button, m_x+x, m_y+y, max, 20 );
d3b4d113 383 x += max;
29006414 384
d3b4d113
RR
385 node = node->Next();
386 }
29006414 387 res.x = x+4;
3417c2cd 388 res.y = 40;
e5403d7c 389 }
29006414 390
d3b4d113 391 return res;
3f659fd6
RR
392}
393
debe6624 394bool wxRadioBox::Show( bool show )
c801d85f 395{
223d09f6 396 wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid radiobox") );
29006414 397
f96ac56a
RR
398 if (!wxControl::Show(show))
399 {
400 // nothing to do
401 return FALSE;
402 }
c801d85f 403
ba2a0103 404 if ((m_windowStyle & wxNO_BORDER) != 0)
b0351fc9 405 gtk_widget_hide( m_widget );
e3e717ec 406
907789a0
RR
407 wxNode *node = m_boxes.First();
408 while (node)
409 {
410 GtkWidget *button = GTK_WIDGET( node->Data() );
29006414 411
907789a0 412 if (show) gtk_widget_show( button ); else gtk_widget_hide( button );
29006414 413
907789a0
RR
414 node = node->Next();
415 }
c801d85f 416
907789a0 417 return TRUE;
6de97a3b 418}
c801d85f 419
47908e25 420int wxRadioBox::FindString( const wxString &s ) const
c801d85f 421{
223d09f6 422 wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid radiobox") );
29006414 423
907789a0 424 int count = 0;
29006414 425
907789a0
RR
426 wxNode *node = m_boxes.First();
427 while (node)
428 {
429 GtkButton *button = GTK_BUTTON( node->Data() );
29006414 430
907789a0
RR
431 GtkLabel *label = GTK_LABEL( button->child );
432 if (s == label->label) return count;
433 count++;
29006414 434
907789a0
RR
435 node = node->Next();
436 }
29006414 437
907789a0 438 return -1;
6de97a3b 439}
c801d85f 440
b292e2f5
RR
441void wxRadioBox::SetFocus()
442{
223d09f6 443 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 444
b292e2f5 445 if (m_boxes.GetCount() == 0) return;
29006414 446
b292e2f5
RR
447 wxNode *node = m_boxes.First();
448 while (node)
449 {
450 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
451 if (button->active)
29006414 452 {
b292e2f5 453 gtk_widget_grab_focus( GTK_WIDGET(button) );
29006414
VZ
454 return;
455 }
b292e2f5
RR
456 node = node->Next();
457 }
29006414 458
b292e2f5
RR
459}
460
47908e25 461void wxRadioBox::SetSelection( int n )
c801d85f 462{
223d09f6 463 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 464
907789a0 465 wxNode *node = m_boxes.Nth( n );
29006414 466
223d09f6 467 wxCHECK_RET( node, wxT("radiobox wrong index") );
29006414 468
907789a0 469 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
29006414 470
72a7edf0 471 GtkDisableEvents();
953704c1 472
907789a0 473 gtk_toggle_button_set_state( button, 1 );
953704c1 474
72a7edf0 475 GtkEnableEvents();
6de97a3b 476}
c801d85f
KB
477
478int wxRadioBox::GetSelection(void) const
479{
223d09f6 480 wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid radiobox") );
29006414 481
907789a0 482 int count = 0;
29006414 483
907789a0
RR
484 wxNode *node = m_boxes.First();
485 while (node)
486 {
487 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
488 if (button->active) return count;
489 count++;
490 node = node->Next();
491 }
29006414 492
223d09f6 493 wxFAIL_MSG( wxT("wxRadioBox none selected") );
29006414 494
907789a0 495 return -1;
6de97a3b 496}
c801d85f 497
47908e25 498wxString wxRadioBox::GetString( int n ) const
c801d85f 499{
223d09f6 500 wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid radiobox") );
29006414 501
907789a0 502 wxNode *node = m_boxes.Nth( n );
29006414 503
223d09f6 504 wxCHECK_MSG( node, wxT(""), wxT("radiobox wrong index") );
29006414 505
907789a0
RR
506 GtkButton *button = GTK_BUTTON( node->Data() );
507 GtkLabel *label = GTK_LABEL( button->child );
29006414 508
907789a0 509 return wxString( label->label );
6de97a3b 510}
c801d85f 511
d3904ceb 512wxString wxRadioBox::GetLabel( int item ) const
c801d85f 513{
223d09f6 514 wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid radiobox") );
29006414 515
907789a0 516 return GetString( item );
6de97a3b 517}
c801d85f 518
d3904ceb 519void wxRadioBox::SetLabel( const wxString& label )
c801d85f 520{
223d09f6 521 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 522
907789a0 523 wxControl::SetLabel( label );
29006414 524
b019151f 525 gtk_frame_set_label( GTK_FRAME(m_widget), wxControl::GetLabel().mbc_str() );
6de97a3b 526}
c801d85f 527
d3904ceb 528void wxRadioBox::SetLabel( int item, const wxString& label )
c801d85f 529{
223d09f6 530 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 531
907789a0 532 wxNode *node = m_boxes.Nth( item );
29006414 533
223d09f6 534 wxCHECK_RET( node, wxT("radiobox wrong index") );
29006414 535
907789a0
RR
536 GtkButton *button = GTK_BUTTON( node->Data() );
537 GtkLabel *g_label = GTK_LABEL( button->child );
29006414 538
b019151f 539 gtk_label_set( g_label, label.mbc_str() );
6de97a3b 540}
c801d85f 541
debe6624 542void wxRadioBox::SetLabel( int WXUNUSED(item), wxBitmap *WXUNUSED(bitmap) )
c801d85f 543{
223d09f6 544 wxFAIL_MSG(wxT("wxRadioBox::SetLabel not implemented."));
6de97a3b 545}
c801d85f 546
f03fc89f 547bool wxRadioBox::Enable( bool enable )
c801d85f 548{
f03fc89f
VZ
549 if ( !wxControl::Enable( enable ) )
550 return FALSE;
29006414 551
907789a0
RR
552 wxNode *node = m_boxes.First();
553 while (node)
554 {
555 GtkButton *button = GTK_BUTTON( node->Data() );
556 GtkWidget *label = button->child;
557 gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
558 gtk_widget_set_sensitive( label, enable );
559 node = node->Next();
560 }
f03fc89f
VZ
561
562 return TRUE;
6de97a3b 563}
c801d85f 564
d3904ceb 565void wxRadioBox::Enable( int item, bool enable )
c801d85f 566{
223d09f6 567 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 568
907789a0 569 wxNode *node = m_boxes.Nth( item );
29006414 570
223d09f6 571 wxCHECK_RET( node, wxT("radiobox wrong index") );
29006414 572
907789a0
RR
573 GtkButton *button = GTK_BUTTON( node->Data() );
574 GtkWidget *label = button->child;
575 gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
576 gtk_widget_set_sensitive( label, enable );
6de97a3b 577}
c801d85f 578
d3904ceb 579void wxRadioBox::Show( int item, bool show )
c801d85f 580{
223d09f6 581 wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
29006414 582
907789a0 583 wxNode *node = m_boxes.Nth( item );
29006414 584
223d09f6 585 wxCHECK_RET( node, wxT("radiobox wrong index") );
29006414 586
907789a0 587 GtkWidget *button = GTK_WIDGET( node->Data() );
c801d85f 588
907789a0
RR
589 if (show)
590 gtk_widget_show( button );
591 else
592 gtk_widget_hide( button );
6de97a3b 593}
c801d85f 594
9c884972 595wxString wxRadioBox::GetStringSelection() const
c801d85f 596{
223d09f6 597 wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid radiobox") );
29006414 598
907789a0
RR
599 wxNode *node = m_boxes.First();
600 while (node)
c801d85f 601 {
907789a0
RR
602 GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
603 if (button->active)
604 {
605 GtkLabel *label = GTK_LABEL( GTK_BUTTON(button)->child );
606 return label->label;
607 }
608 node = node->Next();
6de97a3b 609 }
29006414 610
223d09f6
KB
611 wxFAIL_MSG( wxT("wxRadioBox none selected") );
612 return wxT("");
6de97a3b 613}
c801d85f 614
907789a0 615bool wxRadioBox::SetStringSelection( const wxString &s )
c801d85f 616{
223d09f6 617 wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid radiobox") );
29006414 618
907789a0
RR
619 int res = FindString( s );
620 if (res == -1) return FALSE;
621 SetSelection( res );
29006414 622
907789a0 623 return TRUE;
6de97a3b 624}
c801d85f 625
9c884972 626int wxRadioBox::Number() const
c801d85f 627{
907789a0 628 return m_boxes.Number();
6de97a3b 629}
c801d85f 630
9c884972 631int wxRadioBox::GetNumberOfRowsOrCols() const
c801d85f 632{
907789a0 633 return 1;
6de97a3b 634}
c801d85f 635
debe6624 636void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) )
c801d85f 637{
223d09f6 638 wxFAIL_MSG(wxT("wxRadioBox::SetNumberOfRowsOrCols not implemented."));
6de97a3b 639}
c801d85f 640
72a7edf0 641void wxRadioBox::GtkDisableEvents()
953704c1
RR
642{
643 wxNode *node = m_boxes.First();
644 while (node)
645 {
646 gtk_signal_disconnect_by_func( GTK_OBJECT(node->Data()),
647 GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
648
649 node = node->Next();
650 }
651}
652
72a7edf0 653void wxRadioBox::GtkEnableEvents()
953704c1
RR
654{
655 wxNode *node = m_boxes.First();
656 while (node)
657 {
658 gtk_signal_connect( GTK_OBJECT(node->Data()), "clicked",
659 GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
660
661 node = node->Next();
662 }
663}
664
58614078 665void wxRadioBox::ApplyWidgetStyle()
868a2826 666{
907789a0 667 SetWidgetStyle();
29006414 668
907789a0 669 gtk_widget_set_style( m_widget, m_widgetStyle );
29006414 670
907789a0
RR
671 wxNode *node = m_boxes.First();
672 while (node)
673 {
674 GtkWidget *widget = GTK_WIDGET( node->Data() );
675 gtk_widget_set_style( widget, m_widgetStyle );
29006414 676
907789a0
RR
677 GtkButton *button = GTK_BUTTON( node->Data() );
678 gtk_widget_set_style( button->child, m_widgetStyle );
29006414 679
907789a0
RR
680 node = node->Next();
681 }
868a2826 682}
b4071e91 683
72a7edf0
RR
684#if wxUSE_TOOLTIPS
685void wxRadioBox::ApplyToolTip( GtkTooltips *tips, const wxChar *tip )
686{
687 wxNode *node = m_boxes.First();
688 while (node)
689 {
690 GtkWidget *widget = GTK_WIDGET( node->Data() );
691 gtk_tooltips_set_tip( tips, widget, wxConvCurrent->cWX2MB(tip), (gchar*) NULL );
692 node = node->Next();
693 }
694}
695#endif // wxUSE_TOOLTIPS
696
b4071e91
RR
697bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window )
698{
907789a0 699 if (window == m_widget->window) return TRUE;
29006414 700
907789a0
RR
701 wxNode *node = m_boxes.First();
702 while (node)
703 {
704 GtkWidget *button = GTK_WIDGET( node->Data() );
29006414 705
907789a0 706 if (window == button->window) return TRUE;
29006414 707
907789a0
RR
708 node = node->Next();
709 }
29006414 710
907789a0 711 return FALSE;
b4071e91 712}
dcf924a3 713
f6bcfd97
BP
714void wxRadioBox::OnInternalIdle()
715{
716 if ( m_lostFocus )
717 {
718 m_hasFocus = FALSE;
719 m_lostFocus = FALSE;
720
721 wxFocusEvent event( wxEVT_KILL_FOCUS, GetId() );
722 event.SetEventObject( this );
723
724 (void)GetEventHandler()->ProcessEvent( event );
725 }
726}
727
728#endif // wxUSE_RADIOBOX
729