]> git.saurik.com Git - wxWidgets.git/blame - src/msw/radiobox.cpp
the modal dialogs restore the focus to the control which had it before the
[wxWidgets.git] / src / msw / radiobox.cpp
CommitLineData
2bda0e17
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: radiobox.cpp
3// Purpose: wxRadioBox
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "radiobox.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
24#include <stdio.h>
25#include "wx/setup.h"
26#include "wx/radiobox.h"
27#endif
28
29#include "wx/msw/private.h"
30
31#if !USE_SHARED_LIBRARY
32IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
33#endif
34
debe6624 35bool wxRadioBox::MSWCommand(WXUINT param, WXWORD id)
2bda0e17
KB
36{
37 if (param == BN_CLICKED)
38 {
39#ifdef __WIN32__
40 int i;
41 for (i = 0; i < m_noItems; i++)
42 if (id == GetWindowLong((HWND) m_radioButtons[i], GWL_ID))
43 m_selectedButton = i;
44#else
45 int i;
46 for (i = 0; i < m_noItems; i++)
47 if (id == GetWindowWord((HWND) m_radioButtons[i], GWW_ID))
48 m_selectedButton = i;
49#endif
50
51 wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId);
52 event.SetInt( m_selectedButton );
53 event.SetEventObject( this );
54 ProcessCommand(event);
55 return TRUE;
56 }
57 else return FALSE;
58}
59
60#if WXWIN_COMPATIBILITY
61wxRadioBox::wxRadioBox(wxWindow *parent, wxFunction func, const char *title,
62 int x, int y, int width, int height,
63 int n, char **choices,
64 int majorDim, long style, const char *name)
65{
66 wxString *choices2 = new wxString[n];
67 for ( int i = 0; i < n; i ++) choices2[i] = choices[i];
68 Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), n, choices2, majorDim, style,
69 wxDefaultValidator, name);
70 Callback(func);
71 delete choices2;
72}
73
74#endif
75
76// Radio box item
77wxRadioBox::wxRadioBox(void)
78{
79 m_selectedButton = -1;
80 m_noItems = 0;
81 m_noRowsOrCols = 0;
82 m_radioButtons = NULL;
83 m_majorDim = 0 ;
84 m_radioWidth = NULL ;
85 m_radioHeight = NULL ;
86}
87
debe6624 88bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
2bda0e17 89 const wxPoint& pos, const wxSize& size,
debe6624
JS
90 int n, const wxString choices[],
91 int majorDim, long style,
2bda0e17
KB
92 const wxValidator& val, const wxString& name)
93{
94 m_selectedButton = -1;
95 m_noItems = n;
96
97 SetName(name);
98 SetValidator(val);
99
100 parent->AddChild(this);
101 m_backgroundColour = parent->GetDefaultBackgroundColour() ;
102 m_foregroundColour = parent->GetDefaultForegroundColour() ;
103
104 m_windowStyle = (long&)style;
105
106 int x = pos.x;
107 int y = pos.y;
108 int width = size.x;
109 int height = size.y;
110
111 if (id == -1)
112 m_windowId = NewControlId();
113 else
114 m_windowId = id;
115
116 m_noRowsOrCols = majorDim;
117 if (majorDim==0)
118 m_majorDim = n ;
1eb20d4a
RD
119 else // Seemed to make sense to put this 'else' here... (RD)
120 m_majorDim = majorDim ;
2bda0e17
KB
121
122 long msStyle = GROUP_FLAGS;
123
124 bool want3D;
125 WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
126 // Even with extended styles, need to combine with WS_BORDER
127 // for them to look right.
128 if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
129 (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
130 msStyle |= WS_BORDER;
131
132
133 m_hWnd = (WXHWND) CreateWindowEx((DWORD) exStyle, GROUP_CLASS, (title == "" ? NULL : (const char *)title),
134 msStyle,
135 0,0,0,0,
136 (HWND) parent->GetHWND(), (HMENU) m_windowId, wxGetInstance(), NULL) ;
137
138 HWND the_handle = (HWND) parent->GetHWND() ;
139
140#if CTL3D
141 if (want3D)
142 {
143 Ctl3dSubclassCtl((HWND) m_hWnd);
144 m_useCtl3D = TRUE;
145 }
146#endif
147
148 SetFont(* parent->GetFont());
149
150 // Subclass again for purposes of dialog editing mode
151 SubclassWin((WXHWND)m_hWnd);
152
153/* Label will be the same as button font now.
154 if (labelFont)
155 {
156 labelFont->RealizeResource();
157 if (labelFont->GetResourceHandle())
158 SendMessage(ms_handle,WM_SETFONT,
159 (WPARAM)labelFont->GetResourceHandle(),0L);
160 }
161*/
162
163 // Some radio boxes test consecutive id.
164 (void)NewControlId() ;
165 m_radioButtons = new WXHWND[n];
166 m_radioWidth = new int[n] ;
167 m_radioHeight = new int[n] ;
168 int i;
169 for (i = 0; i < n; i++)
170 {
171 m_radioWidth[i] = m_radioHeight[i] = -1 ;
172 long groupStyle = 0;
173 if (i == 0 && style==0)
174 groupStyle = WS_GROUP;
175 long newId = NewControlId();
176 long msStyle = groupStyle | RADIO_FLAGS;
177
178 m_radioButtons[i] = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, choices[i],
179 msStyle,0,0,0,0,
180 the_handle, (HMENU)newId, wxGetInstance(), NULL);
181#if CTL3D
182 if (want3D)
183 {
184 Ctl3dSubclassCtl((HWND) m_hWnd);
185 m_useCtl3D = TRUE;
186 }
187#endif
188 if (GetFont())
189 {
190 SendMessage((HWND)m_radioButtons[i],WM_SETFONT,
191 (WPARAM)GetFont()->GetResourceHandle(),0L);
192 }
193 m_subControls.Append((wxObject *)newId);
194 }
195
196 // Create a dummy radio control to end the group.
197 (void)CreateWindowEx(0, RADIO_CLASS, "", WS_GROUP|RADIO_FLAGS, 0,0,0,0, the_handle, (HMENU)NewControlId(), wxGetInstance(), NULL);
198
199 SetSelection(0);
200
201 SetSize(x, y, width, height);
202
203 return TRUE;
204}
205
206#if 0
debe6624 207bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
2bda0e17 208 const wxPoint& pos, const wxSize& size,
debe6624
JS
209 int n, const wxBitmap *choices[],
210 int majorDim, long style,
2bda0e17
KB
211 const wxValidator& val, const wxString& name)
212{
213 m_selectedButton = -1;
214 m_noRowsOrCols = 0;
215 m_noItems = n;
216
217 SetName(name);
218 SetValidator(val);
219
220 parent->AddChild(this);
221 m_backgroundColour = parent->GetDefaultBackgroundColour() ;
222 m_foregroundColour = parent->GetDefaultForegroundColour() ;
223
224 m_windowStyle = (long&)style;
225
226 int x = pos.x;
227 int y = pos.y;
228 int width = size.x;
229 int height = size.y;
230
231 if (id == -1)
232 m_windowId = NewControlId();
233 else
234 m_windowId = id;
235
236
237 m_noRowsOrCols = majorDim;
238 if (majorDim==0)
239 m_majorDim = n ;
240 m_majorDim = majorDim ;
241 HWND the_handle ;
242
243 long msStyle = GROUP_FLAGS;
244
245 bool want3D;
246 WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
247 // Even with extended styles, need to combine with WS_BORDER
248 // for them to look right.
249 if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
250 (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
251 msStyle |= WS_BORDER;
252
253 m_hWnd = (WXHWND) CreateWindowEx((DWORD) exStyle, GROUP_CLASS, (title == "" ? NULL : (const char *)title),
254 msStyle,
255 0,0,0,0,
256 (HWND) parent->GetHWND(), (HMENU) m_windowId, wxGetInstance(), NULL) ;
257
258/*
259 if (labelFont)
260 {
261 labelFont->RealizeResource();
262 if (labelFont->GetResourceHandle())
263 SendMessage(ms_handle,WM_SETFONT,
264 (WPARAM)labelFont->GetResourceHandle(),0L);
265 }
266*/
267 the_handle = (HWND) parent->GetHWND();
268
269#if CTL3D
270 if (want3D)
271 {
272 Ctl3dSubclassCtl((HWND) m_hWnd);
273 m_useCtl3D = TRUE;
274 }
275#endif
276
277 SetFont(* parent->GetFont());
278
279 // Subclass again for purposes of dialog editing mode
280 SubclassWin((WXHWND)m_hWnd);
281
282 (void)NewControlId() ;
283 m_radioButtons = new WXHWND[n];
284 m_radioWidth = new int[n] ;
285 m_radioHeight = new int[n] ;
286
287 int i;
288 for (i = 0; i < n; i++)
289 {
290 long groupStyle = 0;
291 if (i == 0 && style==0)
292 groupStyle = WS_GROUP;
293 long newId = NewControlId();
294 m_radioWidth[i] = ((wxBitmap *)choices[i])->GetWidth();
295 m_radioHeight[i] = ((wxBitmap *)choices[i])->GetHeight();
296 char tmp[32] ;
297 sprintf(tmp,"Toggle%d",i) ;
298 long msStyle = groupStyle | RADIO_FLAGS;
299 m_radioButtons[i] = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, tmp,
300 msStyle,0,0,0,0,
301 the_handle, (HMENU)newId, wxhInstance, NULL);
302#if CTL3D
303 if (want3D)
304 {
305 Ctl3dSubclassCtl((HWND) m_hWnd);
306 m_useCtl3D = TRUE;
307 }
308#endif
309 m_subControls.Append((wxObject *)newId);
310 }
311 // Create a dummy radio control to end the group.
312 (void)CreateWindowEx(0, RADIO_CLASS, "", WS_GROUP|RADIO_FLAGS, 0,0,0,0, the_handle, (HMENU)NewControlId(), wxGetInstance(), NULL);
313
314 SetSelection(0);
315
316 SetSize(x, y, width, height);
317
318 return TRUE;
319}
320#endif
321
322wxRadioBox::~wxRadioBox(void)
323{
324 m_isBeingDeleted = TRUE;
1eb20d4a 325
2bda0e17
KB
326 if (m_radioButtons)
327 {
328 int i;
329 for (i = 0; i < m_noItems; i++)
330 DestroyWindow((HWND) m_radioButtons[i]);
331 delete[] m_radioButtons;
332 }
333 if (m_radioWidth)
334 delete[] m_radioWidth ;
335 if (m_radioHeight)
336 delete[] m_radioHeight ;
337 if (m_hWnd)
338 ::DestroyWindow((HWND) m_hWnd) ;
339 m_hWnd = 0 ;
340
341}
342
debe6624 343wxString wxRadioBox::GetLabel(int item) const
2bda0e17
KB
344{
345 GetWindowText((HWND)m_radioButtons[item], wxBuffer, 300);
346 return wxString(wxBuffer);
347}
348
debe6624 349void wxRadioBox::SetLabel(int item, const wxString& label)
2bda0e17
KB
350{
351 m_radioWidth[item] = m_radioHeight[item] = -1 ;
352 SetWindowText((HWND)m_radioButtons[item], (const char *)label);
353}
354
debe6624 355void wxRadioBox::SetLabel(int item, wxBitmap *bitmap)
2bda0e17
KB
356{
357/*
358 m_radioWidth[item] = bitmap->GetWidth() + FB_MARGIN ;
359 m_radioHeight[item] = bitmap->GetHeight() + FB_MARGIN ;
360*/
361}
362
363int wxRadioBox::FindString(const wxString& s) const
364{
365 int i;
366 for (i = 0; i < m_noItems; i++)
367 {
368 GetWindowText((HWND) m_radioButtons[i], wxBuffer, 1000);
369 if (s == wxBuffer)
370 return i;
371 }
372 return -1;
373}
374
debe6624 375void wxRadioBox::SetSelection(int N)
2bda0e17
KB
376{
377 if ((N < 0) || (N >= m_noItems))
378 return;
379
380// Following necessary for Win32s, because Win32s translate BM_SETCHECK
381 if (m_selectedButton >= 0 && m_selectedButton < m_noItems)
382 SendMessage((HWND) m_radioButtons[m_selectedButton], BM_SETCHECK, 0, 0L);
383
384 SendMessage((HWND) m_radioButtons[N], BM_SETCHECK, 1, 0L);
385 m_selectedButton = N;
386}
387
388// Get single selection, for single choice list items
389int wxRadioBox::GetSelection(void) const
390{
391 return m_selectedButton;
392}
393
394// Find string for position
debe6624 395wxString wxRadioBox::GetString(int N) const
2bda0e17
KB
396{
397 GetWindowText((HWND) m_radioButtons[N], wxBuffer, 1000);
398 return wxString(wxBuffer);
399}
400
debe6624 401void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags)
2bda0e17
KB
402{
403 int currentX, currentY;
404 GetPosition(&currentX, &currentY);
405 int xx = x;
406 int yy = y;
407
408 if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
409 xx = currentX;
410 if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
411 yy = currentY;
412
81d66cf3
JS
413 AdjustForParentClientOrigin(xx, yy, sizeFlags);
414
2bda0e17
KB
415 char buf[400];
416
417 int y_offset = yy;
418 int x_offset = xx;
debe6624 419 int current_width, cyf;
2bda0e17
KB
420
421 int cx1,cy1 ;
422 wxGetCharSize(m_hWnd, &cx1, &cy1, GetFont());
423 // Attempt to have a look coherent with other platforms:
424 // We compute the biggest toggle dim, then we align all
425 // items according this value.
426 int maxWidth = -1;
427 int maxHeight = -1 ;
428
429 int i;
430 for (i = 0 ; i < m_noItems; i++)
431 {
432 int eachWidth;
433 int eachHeight ;
434 if (m_radioWidth[i]<0)
435 {
436 // It's a labelled toggle
437 GetWindowText((HWND) m_radioButtons[i], buf, 300);
438 GetTextExtent(buf, &current_width, &cyf,NULL,NULL, GetFont());
439 eachWidth = (int)(current_width + RADIO_SIZE);
440 eachHeight = (int)((3*cyf)/2);
441 }
442 else
443 {
444 eachWidth = m_radioWidth[i] ;
445 eachHeight = m_radioHeight[i] ;
446 }
447 if (maxWidth<eachWidth) maxWidth = eachWidth ;
448 if (maxHeight<eachHeight) maxHeight = eachHeight ;
449 }
450
451 if (m_hWnd)
452 {
453 int totWidth ;
454 int totHeight;
455
456 int nbHor,nbVer;
457
458 if (m_windowStyle & wxRA_VERTICAL)
459 {
460 nbVer = m_majorDim ;
461 nbHor = (m_noItems+m_majorDim-1)/m_majorDim ;
462 }
463 else
464 {
465 nbHor = m_majorDim ;
466 nbVer = (m_noItems+m_majorDim-1)/m_majorDim ;
467 }
468
469 // this formula works, but I don't know why.
470 // Please, be sure what you do if you modify it!!
471 if (m_radioWidth[0]<0)
472 totHeight = (nbVer * maxHeight) + cy1/2 ;
473 else
474 totHeight = nbVer * (maxHeight+cy1/2) ;
475 totWidth = nbHor * (maxWidth+cx1) ;
476
477#if (!CTL3D)
478 // Requires a bigger group box in plain Windows
479 MoveWindow((HWND) m_hWnd,x_offset,y_offset,totWidth+cx1,totHeight+(3*cy1)/2,TRUE) ;
480#else
481 MoveWindow((HWND) m_hWnd,x_offset,y_offset,totWidth+cx1,totHeight+cy1,TRUE) ;
482#endif
483 x_offset += cx1;
484 y_offset += cy1;
485 }
486
487#if (!CTL3D)
488 y_offset += (int)(cy1/2); // Fudge factor since buttons overlapped label
489 // JACS 2/12/93. CTL3D draws group label quite high.
490#endif
491 int startX = x_offset ;
492 int startY = y_offset ;
493
494 for ( i = 0 ; i < m_noItems; i++)
495 {
496 // Bidimensional radio adjustment
497 if (i&&((i%m_majorDim)==0)) // Why is this omitted for i = 0?
498 {
499 if (m_windowStyle & wxRA_VERTICAL)
500 {
501 y_offset = startY;
502 x_offset += maxWidth + cx1 ;
503 }
504 else
505 {
506 x_offset = startX ;
507 y_offset += maxHeight ;
508 if (m_radioWidth[0]>0)
509 y_offset += cy1/2 ;
510 }
511 }
512 int eachWidth ;
513 int eachHeight ;
514 if (m_radioWidth[i]<0)
515 {
516 // It's a labeled item
517 GetWindowText((HWND) m_radioButtons[i], buf, 300);
518 GetTextExtent(buf, &current_width, &cyf,NULL,NULL,GetFont());
519
520 // How do we find out radio button bitmap size!!
521 // By adjusting them carefully, manually :-)
522 eachWidth = (int)(current_width + RADIO_SIZE);
523 eachHeight = (int)((3*cyf)/2);
524 }
525 else
526 {
527 eachWidth = m_radioWidth[i] ;
528 eachHeight = m_radioHeight[i] ;
529 }
530
531 MoveWindow((HWND) m_radioButtons[i],x_offset,y_offset,eachWidth,eachHeight,TRUE);
532 if (m_windowStyle & wxRA_VERTICAL)
533 {
534 y_offset += maxHeight;
535 if (m_radioWidth[0]>0)
536 y_offset += cy1/2 ;
537 }
538 else
539 x_offset += maxWidth + cx1;
540 }
541}
542
543void wxRadioBox::GetSize(int *width, int *height) const
544{
545 RECT rect;
546 rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
547
548 if (m_hWnd)
549 wxFindMaxSize(m_hWnd, &rect);
550
551 int i;
552 for (i = 0; i < m_noItems; i++)
553 wxFindMaxSize(m_radioButtons[i], &rect);
554
555 *width = rect.right - rect.left;
556 *height = rect.bottom - rect.top;
557}
558
559void wxRadioBox::GetPosition(int *x, int *y) const
560{
561 wxWindow *parent = GetParent();
562 RECT rect;
563 rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
564
565 int i;
566 for (i = 0; i < m_noItems; i++)
567 wxFindMaxSize(m_radioButtons[i], &rect);
568
569 if (m_hWnd)
570 wxFindMaxSize(m_hWnd, &rect);
571
572 // Since we now have the absolute screen coords,
573 // if there's a parent we must subtract its top left corner
574 POINT point;
575 point.x = rect.left;
576 point.y = rect.top;
577 if (parent)
578 {
579 ::ScreenToClient((HWND) parent->GetHWND(), &point);
580 }
81d66cf3
JS
581 // We may be faking the client origin.
582 // So a window that's really at (0, 30) may appear
583 // (to wxWin apps) to be at (0, 0).
584 if (GetParent())
585 {
586 wxPoint pt(GetParent()->GetClientAreaOrigin());
587 point.x -= pt.x;
588 point.y -= pt.y;
589 }
2bda0e17
KB
590
591 *x = point.x;
592 *y = point.y;
593}
594
595wxString wxRadioBox::GetLabel(void) const
596{
597 if (m_hWnd)
598 {
599 GetWindowText((HWND) m_hWnd, wxBuffer, 300);
600 return wxString(wxBuffer);
601 }
602 else return wxString("");
603}
604
605void wxRadioBox::SetLabel(const wxString& label)
606{
607 if (m_hWnd && label)
608 SetWindowText((HWND) m_hWnd, label);
609}
610
611void wxRadioBox::SetFocus(void)
612{
613/*
614 if (m_noItems > 0)
615 ::SetFocus((HWND) m_radioButtons[0]);
616*/
617/* Begin Alberts Patch 26. 5. 1997*/
618 if (m_noItems > 0)
619 {
620 if (m_selectedButton == -1)
621 ::SetFocus((HWND) m_radioButtons[0]);
622 else
623 ::SetFocus((HWND) m_radioButtons[m_selectedButton]);
624 }
625/* Ende Alberts Patch*/
626
627}
628
debe6624 629bool wxRadioBox::Show(bool show)
2bda0e17
KB
630{
631 int cshow;
632 if (show)
633 cshow = SW_SHOW;
634 else
635 cshow = SW_HIDE;
636 if (m_hWnd)
637 ShowWindow((HWND) m_hWnd, cshow);
638 int i;
639 for (i = 0; i < m_noItems; i++)
640 ShowWindow((HWND) m_radioButtons[i], cshow);
641 return TRUE;
642}
643
644// Enable a specific button
debe6624 645void wxRadioBox::Enable(int item, bool enable)
2bda0e17
KB
646{
647 if (item<0)
648 wxWindow::Enable(enable) ;
649 else if (item < m_noItems)
650 ::EnableWindow((HWND) m_radioButtons[item], enable);
651}
652
653// Enable all controls
debe6624 654void wxRadioBox::Enable(bool enable)
2bda0e17
KB
655{
656 wxControl::Enable(enable);
1eb20d4a 657
2bda0e17
KB
658 int i;
659 for (i = 0; i < m_noItems; i++)
660 ::EnableWindow((HWND) m_radioButtons[i], enable);
661}
662
663// Show a specific button
debe6624 664void wxRadioBox::Show(int item, bool show)
2bda0e17
KB
665{
666 if (item<0)
667 wxRadioBox::Show(show) ;
668 else if (item < m_noItems)
669 {
670 int cshow;
671 if (show)
672 cshow = SW_SHOW;
673 else
674 cshow = SW_HIDE;
675 ShowWindow((HWND) m_radioButtons[item], cshow);
676 }
677}
678
debe6624 679WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
2bda0e17
KB
680 WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
681{
682#if CTL3D
683 if ( m_useCtl3D )
684 {
685 HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
686 return (WXHBRUSH) hbrush;
687 }
688#endif
689
690 if (GetParent()->GetTransparentBackground())
691 SetBkMode((HDC) pDC, TRANSPARENT);
692 else
693 SetBkMode((HDC) pDC, OPAQUE);
694
695 ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
696 ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
697
698 wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
699
700 // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
701 // has a zero usage count.
702// backgroundBrush->RealizeResource();
703 return (WXHBRUSH) backgroundBrush->GetResourceHandle();
704}
705
706// For single selection items only
707wxString wxRadioBox::GetStringSelection (void) const
708{
709 int sel = GetSelection ();
710 if (sel > -1)
711 return this->GetString (sel);
712 else
713 return wxString("");
714}
715
716bool wxRadioBox::SetStringSelection (const wxString& s)
717{
718 int sel = FindString (s);
719 if (sel > -1)
720 {
721 SetSelection (sel);
722 return TRUE;
723 }
724 else
725 return FALSE;
726}
727
728/*
729void wxRadioBox::SetLabelFont(wxFont *font)
730{
731 // Decrement the usage count of the old label font
732 // (we may be able to free it up)
733 if (labelFont)
734 labelFont->ReleaseResource();
735
736 labelFont = font;
737
738 // Increment usage count
739 if (font)
740 font->UseResource();
741
742 HWND hWnd = GetHWND();
743 if (hWnd != 0)
744 {
745 if (font)
746 {
747 font->RealizeResource();
1eb20d4a 748
2bda0e17
KB
749 if (font->GetResourceHandle())
750 SendMessage(hWnd, WM_SETFONT,
751 (WPARAM)font->GetResourceHandle(),TRUE);
752 }
753 }
754}
755
756*/
757
758bool wxRadioBox::ContainsHWND(WXHWND hWnd) const
759{
760 int i;
761 for (i = 0; i < Number(); i++)
762 if (GetRadioButtons()[i] == hWnd)
763 return TRUE;
764 return FALSE;
765}
766
767void wxRadioBox::Command (wxCommandEvent & event)
768{
769 SetSelection (event.m_commandInt);
770 ProcessCommand (event);
771}
772
773