]> git.saurik.com Git - wxWidgets.git/blame - src/msw/radiobox.cpp
*** empty log message ***
[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
2bda0e17
KB
150 SubclassWin((WXHWND)m_hWnd);
151
2bda0e17
KB
152 // Some radio boxes test consecutive id.
153 (void)NewControlId() ;
154 m_radioButtons = new WXHWND[n];
155 m_radioWidth = new int[n] ;
156 m_radioHeight = new int[n] ;
157 int i;
158 for (i = 0; i < n; i++)
159 {
160 m_radioWidth[i] = m_radioHeight[i] = -1 ;
161 long groupStyle = 0;
162 if (i == 0 && style==0)
163 groupStyle = WS_GROUP;
164 long newId = NewControlId();
165 long msStyle = groupStyle | RADIO_FLAGS;
166
167 m_radioButtons[i] = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, choices[i],
168 msStyle,0,0,0,0,
169 the_handle, (HMENU)newId, wxGetInstance(), NULL);
170#if CTL3D
171 if (want3D)
172 {
173 Ctl3dSubclassCtl((HWND) m_hWnd);
174 m_useCtl3D = TRUE;
175 }
176#endif
177 if (GetFont())
178 {
179 SendMessage((HWND)m_radioButtons[i],WM_SETFONT,
180 (WPARAM)GetFont()->GetResourceHandle(),0L);
181 }
182 m_subControls.Append((wxObject *)newId);
183 }
184
185 // Create a dummy radio control to end the group.
186 (void)CreateWindowEx(0, RADIO_CLASS, "", WS_GROUP|RADIO_FLAGS, 0,0,0,0, the_handle, (HMENU)NewControlId(), wxGetInstance(), NULL);
187
188 SetSelection(0);
189
190 SetSize(x, y, width, height);
191
192 return TRUE;
193}
194
195#if 0
debe6624 196bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
2bda0e17 197 const wxPoint& pos, const wxSize& size,
debe6624
JS
198 int n, const wxBitmap *choices[],
199 int majorDim, long style,
2bda0e17
KB
200 const wxValidator& val, const wxString& name)
201{
202 m_selectedButton = -1;
203 m_noRowsOrCols = 0;
204 m_noItems = n;
205
206 SetName(name);
207 SetValidator(val);
208
209 parent->AddChild(this);
210 m_backgroundColour = parent->GetDefaultBackgroundColour() ;
211 m_foregroundColour = parent->GetDefaultForegroundColour() ;
212
213 m_windowStyle = (long&)style;
214
215 int x = pos.x;
216 int y = pos.y;
217 int width = size.x;
218 int height = size.y;
219
220 if (id == -1)
221 m_windowId = NewControlId();
222 else
223 m_windowId = id;
224
225
226 m_noRowsOrCols = majorDim;
227 if (majorDim==0)
228 m_majorDim = n ;
229 m_majorDim = majorDim ;
230 HWND the_handle ;
231
232 long msStyle = GROUP_FLAGS;
233
234 bool want3D;
235 WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
236 // Even with extended styles, need to combine with WS_BORDER
237 // for them to look right.
238 if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
239 (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)))
240 msStyle |= WS_BORDER;
241
242 m_hWnd = (WXHWND) CreateWindowEx((DWORD) exStyle, GROUP_CLASS, (title == "" ? NULL : (const char *)title),
243 msStyle,
244 0,0,0,0,
245 (HWND) parent->GetHWND(), (HMENU) m_windowId, wxGetInstance(), NULL) ;
246
2bda0e17
KB
247 the_handle = (HWND) parent->GetHWND();
248
249#if CTL3D
250 if (want3D)
251 {
252 Ctl3dSubclassCtl((HWND) m_hWnd);
253 m_useCtl3D = TRUE;
254 }
255#endif
256
257 SetFont(* parent->GetFont());
258
259 // Subclass again for purposes of dialog editing mode
260 SubclassWin((WXHWND)m_hWnd);
261
262 (void)NewControlId() ;
263 m_radioButtons = new WXHWND[n];
264 m_radioWidth = new int[n] ;
265 m_radioHeight = new int[n] ;
266
267 int i;
268 for (i = 0; i < n; i++)
269 {
270 long groupStyle = 0;
271 if (i == 0 && style==0)
272 groupStyle = WS_GROUP;
273 long newId = NewControlId();
274 m_radioWidth[i] = ((wxBitmap *)choices[i])->GetWidth();
275 m_radioHeight[i] = ((wxBitmap *)choices[i])->GetHeight();
276 char tmp[32] ;
277 sprintf(tmp,"Toggle%d",i) ;
278 long msStyle = groupStyle | RADIO_FLAGS;
279 m_radioButtons[i] = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, tmp,
280 msStyle,0,0,0,0,
281 the_handle, (HMENU)newId, wxhInstance, NULL);
282#if CTL3D
283 if (want3D)
284 {
285 Ctl3dSubclassCtl((HWND) m_hWnd);
286 m_useCtl3D = TRUE;
287 }
288#endif
289 m_subControls.Append((wxObject *)newId);
290 }
291 // Create a dummy radio control to end the group.
292 (void)CreateWindowEx(0, RADIO_CLASS, "", WS_GROUP|RADIO_FLAGS, 0,0,0,0, the_handle, (HMENU)NewControlId(), wxGetInstance(), NULL);
293
294 SetSelection(0);
295
296 SetSize(x, y, width, height);
297
298 return TRUE;
299}
300#endif
301
302wxRadioBox::~wxRadioBox(void)
303{
304 m_isBeingDeleted = TRUE;
1eb20d4a 305
2bda0e17
KB
306 if (m_radioButtons)
307 {
308 int i;
309 for (i = 0; i < m_noItems; i++)
310 DestroyWindow((HWND) m_radioButtons[i]);
311 delete[] m_radioButtons;
312 }
313 if (m_radioWidth)
314 delete[] m_radioWidth ;
315 if (m_radioHeight)
316 delete[] m_radioHeight ;
317 if (m_hWnd)
318 ::DestroyWindow((HWND) m_hWnd) ;
319 m_hWnd = 0 ;
320
321}
322
debe6624 323wxString wxRadioBox::GetLabel(int item) const
2bda0e17
KB
324{
325 GetWindowText((HWND)m_radioButtons[item], wxBuffer, 300);
326 return wxString(wxBuffer);
327}
328
debe6624 329void wxRadioBox::SetLabel(int item, const wxString& label)
2bda0e17
KB
330{
331 m_radioWidth[item] = m_radioHeight[item] = -1 ;
332 SetWindowText((HWND)m_radioButtons[item], (const char *)label);
333}
334
debe6624 335void wxRadioBox::SetLabel(int item, wxBitmap *bitmap)
2bda0e17
KB
336{
337/*
338 m_radioWidth[item] = bitmap->GetWidth() + FB_MARGIN ;
339 m_radioHeight[item] = bitmap->GetHeight() + FB_MARGIN ;
340*/
341}
342
343int wxRadioBox::FindString(const wxString& s) const
344{
345 int i;
346 for (i = 0; i < m_noItems; i++)
347 {
348 GetWindowText((HWND) m_radioButtons[i], wxBuffer, 1000);
349 if (s == wxBuffer)
350 return i;
351 }
352 return -1;
353}
354
debe6624 355void wxRadioBox::SetSelection(int N)
2bda0e17
KB
356{
357 if ((N < 0) || (N >= m_noItems))
358 return;
359
360// Following necessary for Win32s, because Win32s translate BM_SETCHECK
361 if (m_selectedButton >= 0 && m_selectedButton < m_noItems)
362 SendMessage((HWND) m_radioButtons[m_selectedButton], BM_SETCHECK, 0, 0L);
363
364 SendMessage((HWND) m_radioButtons[N], BM_SETCHECK, 1, 0L);
365 m_selectedButton = N;
366}
367
368// Get single selection, for single choice list items
369int wxRadioBox::GetSelection(void) const
370{
371 return m_selectedButton;
372}
373
374// Find string for position
debe6624 375wxString wxRadioBox::GetString(int N) const
2bda0e17
KB
376{
377 GetWindowText((HWND) m_radioButtons[N], wxBuffer, 1000);
378 return wxString(wxBuffer);
379}
380
debe6624 381void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags)
2bda0e17
KB
382{
383 int currentX, currentY;
384 GetPosition(&currentX, &currentY);
385 int xx = x;
386 int yy = y;
387
388 if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
389 xx = currentX;
390 if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
391 yy = currentY;
392
81d66cf3
JS
393 AdjustForParentClientOrigin(xx, yy, sizeFlags);
394
2bda0e17
KB
395 char buf[400];
396
397 int y_offset = yy;
398 int x_offset = xx;
debe6624 399 int current_width, cyf;
2bda0e17
KB
400
401 int cx1,cy1 ;
402 wxGetCharSize(m_hWnd, &cx1, &cy1, GetFont());
403 // Attempt to have a look coherent with other platforms:
404 // We compute the biggest toggle dim, then we align all
405 // items according this value.
406 int maxWidth = -1;
407 int maxHeight = -1 ;
408
409 int i;
410 for (i = 0 ; i < m_noItems; i++)
411 {
412 int eachWidth;
413 int eachHeight ;
414 if (m_radioWidth[i]<0)
415 {
416 // It's a labelled toggle
417 GetWindowText((HWND) m_radioButtons[i], buf, 300);
418 GetTextExtent(buf, &current_width, &cyf,NULL,NULL, GetFont());
419 eachWidth = (int)(current_width + RADIO_SIZE);
420 eachHeight = (int)((3*cyf)/2);
421 }
422 else
423 {
424 eachWidth = m_radioWidth[i] ;
425 eachHeight = m_radioHeight[i] ;
426 }
427 if (maxWidth<eachWidth) maxWidth = eachWidth ;
428 if (maxHeight<eachHeight) maxHeight = eachHeight ;
429 }
430
431 if (m_hWnd)
432 {
433 int totWidth ;
434 int totHeight;
435
436 int nbHor,nbVer;
437
cd91632c 438 if (m_windowStyle & wxRA_HORIZONTAL)
2bda0e17
KB
439 {
440 nbVer = m_majorDim ;
441 nbHor = (m_noItems+m_majorDim-1)/m_majorDim ;
442 }
443 else
444 {
445 nbHor = m_majorDim ;
446 nbVer = (m_noItems+m_majorDim-1)/m_majorDim ;
447 }
448
449 // this formula works, but I don't know why.
450 // Please, be sure what you do if you modify it!!
451 if (m_radioWidth[0]<0)
452 totHeight = (nbVer * maxHeight) + cy1/2 ;
453 else
454 totHeight = nbVer * (maxHeight+cy1/2) ;
455 totWidth = nbHor * (maxWidth+cx1) ;
456
457#if (!CTL3D)
458 // Requires a bigger group box in plain Windows
459 MoveWindow((HWND) m_hWnd,x_offset,y_offset,totWidth+cx1,totHeight+(3*cy1)/2,TRUE) ;
460#else
461 MoveWindow((HWND) m_hWnd,x_offset,y_offset,totWidth+cx1,totHeight+cy1,TRUE) ;
462#endif
463 x_offset += cx1;
464 y_offset += cy1;
465 }
466
467#if (!CTL3D)
468 y_offset += (int)(cy1/2); // Fudge factor since buttons overlapped label
469 // JACS 2/12/93. CTL3D draws group label quite high.
470#endif
471 int startX = x_offset ;
472 int startY = y_offset ;
473
474 for ( i = 0 ; i < m_noItems; i++)
475 {
476 // Bidimensional radio adjustment
477 if (i&&((i%m_majorDim)==0)) // Why is this omitted for i = 0?
478 {
cd91632c 479 if (m_windowStyle & wxRA_HORIZONTAL)
2bda0e17
KB
480 {
481 y_offset = startY;
482 x_offset += maxWidth + cx1 ;
483 }
484 else
485 {
486 x_offset = startX ;
487 y_offset += maxHeight ;
488 if (m_radioWidth[0]>0)
489 y_offset += cy1/2 ;
490 }
491 }
492 int eachWidth ;
493 int eachHeight ;
494 if (m_radioWidth[i]<0)
495 {
496 // It's a labeled item
497 GetWindowText((HWND) m_radioButtons[i], buf, 300);
498 GetTextExtent(buf, &current_width, &cyf,NULL,NULL,GetFont());
499
500 // How do we find out radio button bitmap size!!
501 // By adjusting them carefully, manually :-)
502 eachWidth = (int)(current_width + RADIO_SIZE);
503 eachHeight = (int)((3*cyf)/2);
504 }
505 else
506 {
507 eachWidth = m_radioWidth[i] ;
508 eachHeight = m_radioHeight[i] ;
509 }
510
511 MoveWindow((HWND) m_radioButtons[i],x_offset,y_offset,eachWidth,eachHeight,TRUE);
cd91632c 512 if (m_windowStyle & wxRA_HORIZONTAL)
2bda0e17
KB
513 {
514 y_offset += maxHeight;
515 if (m_radioWidth[0]>0)
516 y_offset += cy1/2 ;
517 }
518 else
519 x_offset += maxWidth + cx1;
520 }
521}
522
523void wxRadioBox::GetSize(int *width, int *height) const
524{
525 RECT rect;
526 rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
527
528 if (m_hWnd)
529 wxFindMaxSize(m_hWnd, &rect);
530
531 int i;
532 for (i = 0; i < m_noItems; i++)
533 wxFindMaxSize(m_radioButtons[i], &rect);
534
535 *width = rect.right - rect.left;
536 *height = rect.bottom - rect.top;
537}
538
539void wxRadioBox::GetPosition(int *x, int *y) const
540{
541 wxWindow *parent = GetParent();
542 RECT rect;
543 rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
544
545 int i;
546 for (i = 0; i < m_noItems; i++)
547 wxFindMaxSize(m_radioButtons[i], &rect);
548
549 if (m_hWnd)
550 wxFindMaxSize(m_hWnd, &rect);
551
552 // Since we now have the absolute screen coords,
553 // if there's a parent we must subtract its top left corner
554 POINT point;
555 point.x = rect.left;
556 point.y = rect.top;
557 if (parent)
558 {
559 ::ScreenToClient((HWND) parent->GetHWND(), &point);
560 }
81d66cf3
JS
561 // We may be faking the client origin.
562 // So a window that's really at (0, 30) may appear
563 // (to wxWin apps) to be at (0, 0).
564 if (GetParent())
565 {
566 wxPoint pt(GetParent()->GetClientAreaOrigin());
567 point.x -= pt.x;
568 point.y -= pt.y;
569 }
2bda0e17
KB
570
571 *x = point.x;
572 *y = point.y;
573}
574
575wxString wxRadioBox::GetLabel(void) const
576{
577 if (m_hWnd)
578 {
579 GetWindowText((HWND) m_hWnd, wxBuffer, 300);
580 return wxString(wxBuffer);
581 }
582 else return wxString("");
583}
584
585void wxRadioBox::SetLabel(const wxString& label)
586{
587 if (m_hWnd && label)
588 SetWindowText((HWND) m_hWnd, label);
589}
590
591void wxRadioBox::SetFocus(void)
592{
2bda0e17
KB
593 if (m_noItems > 0)
594 {
595 if (m_selectedButton == -1)
596 ::SetFocus((HWND) m_radioButtons[0]);
597 else
598 ::SetFocus((HWND) m_radioButtons[m_selectedButton]);
599 }
2bda0e17
KB
600
601}
602
debe6624 603bool wxRadioBox::Show(bool show)
2bda0e17
KB
604{
605 int cshow;
606 if (show)
607 cshow = SW_SHOW;
608 else
609 cshow = SW_HIDE;
610 if (m_hWnd)
611 ShowWindow((HWND) m_hWnd, cshow);
612 int i;
613 for (i = 0; i < m_noItems; i++)
614 ShowWindow((HWND) m_radioButtons[i], cshow);
615 return TRUE;
616}
617
618// Enable a specific button
debe6624 619void wxRadioBox::Enable(int item, bool enable)
2bda0e17
KB
620{
621 if (item<0)
622 wxWindow::Enable(enable) ;
623 else if (item < m_noItems)
624 ::EnableWindow((HWND) m_radioButtons[item], enable);
625}
626
627// Enable all controls
debe6624 628void wxRadioBox::Enable(bool enable)
2bda0e17
KB
629{
630 wxControl::Enable(enable);
1eb20d4a 631
2bda0e17
KB
632 int i;
633 for (i = 0; i < m_noItems; i++)
634 ::EnableWindow((HWND) m_radioButtons[i], enable);
635}
636
637// Show a specific button
debe6624 638void wxRadioBox::Show(int item, bool show)
2bda0e17
KB
639{
640 if (item<0)
641 wxRadioBox::Show(show) ;
642 else if (item < m_noItems)
643 {
644 int cshow;
645 if (show)
646 cshow = SW_SHOW;
647 else
648 cshow = SW_HIDE;
649 ShowWindow((HWND) m_radioButtons[item], cshow);
650 }
651}
652
debe6624 653WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
2bda0e17
KB
654 WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
655{
656#if CTL3D
657 if ( m_useCtl3D )
658 {
659 HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
660 return (WXHBRUSH) hbrush;
661 }
662#endif
663
664 if (GetParent()->GetTransparentBackground())
665 SetBkMode((HDC) pDC, TRANSPARENT);
666 else
667 SetBkMode((HDC) pDC, OPAQUE);
668
669 ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
670 ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
671
672 wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
673
674 // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
675 // has a zero usage count.
676// backgroundBrush->RealizeResource();
677 return (WXHBRUSH) backgroundBrush->GetResourceHandle();
678}
679
680// For single selection items only
681wxString wxRadioBox::GetStringSelection (void) const
682{
683 int sel = GetSelection ();
684 if (sel > -1)
685 return this->GetString (sel);
686 else
687 return wxString("");
688}
689
690bool wxRadioBox::SetStringSelection (const wxString& s)
691{
692 int sel = FindString (s);
693 if (sel > -1)
694 {
695 SetSelection (sel);
696 return TRUE;
697 }
698 else
699 return FALSE;
700}
701
2bda0e17
KB
702bool wxRadioBox::ContainsHWND(WXHWND hWnd) const
703{
704 int i;
705 for (i = 0; i < Number(); i++)
706 if (GetRadioButtons()[i] == hWnd)
707 return TRUE;
708 return FALSE;
709}
710
711void wxRadioBox::Command (wxCommandEvent & event)
712{
713 SetSelection (event.m_commandInt);
714 ProcessCommand (event);
715}
716
983162bd
JS
717long wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
718{
719 if (nMsg == WM_NCHITTEST)
720 {
721 int xPos = LOWORD(lParam); // horizontal position of cursor
722 int yPos = HIWORD(lParam); // vertical position of cursor
723
724 ScreenToClient(&xPos, &yPos);
725
726 // Make sure you can drag by the top of the groupbox, but let
727 // other (enclosed) controls get mouse events also
728 if (yPos < 10)
729 return (long)HTCLIENT;
730 }
731
732 return wxControl::MSWWindowProc(nMsg, wParam, lParam);
733}
2bda0e17 734