// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
-// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Copyright: (c) Julian Smart
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ===========================================================================
// headers
// ---------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "radiobox.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
+/*
+ selection
+ content
+ label
+ dimension
+ item
+*/
+
// there are two possible ways to create the radio buttons: either as children
// of the radiobox or as siblings of it - allow playing with both variants for
// now, eventually we will choose the best one for our purposes
return FALSE;
}
-#if WXWIN_COMPATIBILITY
-wxRadioBox::wxRadioBox(wxWindow *parent, wxFunction func, const char *title,
- int x, int y, int width, int height,
- int n, char **choices,
- int majorDim, long style, const char *name)
-{
- wxString *choices2 = new wxString[n];
- for ( int i = 0; i < n; i ++) choices2[i] = choices[i];
- Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), n, choices2, majorDim, style,
- wxDefaultValidator, name);
- Callback(func);
- delete choices2;
-}
-
-#endif // WXWIN_COMPATIBILITY
-
// Radio box item
wxRadioBox::wxRadioBox()
{
// Create a dummy radio control to end the group.
(void)::CreateWindow(_T("BUTTON"),
- _T(""),
+ wxEmptyString,
WS_GROUP | BS_AUTORADIOBUTTON | WS_CHILD,
0, 0, 0, 0, hwndParent,
(HMENU)NewControlId(), wxGetInstance(), NULL);
::SendMessage((HWND) m_radioButtons[m_selectedButton], BM_SETCHECK, 0, 0L);
::SendMessage((HWND)m_radioButtons[N], BM_SETCHECK, 1, 0L);
- ::SetFocus((HWND)m_radioButtons[N]);
m_selectedButton = N;
}
int extraHeight = cy1;
+ /* We'll assume the adjustments below are OK for Win 3.1 too
#if defined(CTL3D) && !CTL3D
// Requires a bigger group box in plain Windows
extraHeight *= 3;
extraHeight /= 2;
#endif
-
+ */
+
int height = GetNumVer() * sizeBtn.y + cy1/2 + extraHeight;
int width = GetNumHor() * (sizeBtn.x + cx1) + cx1;
+ // Add extra space under the label, if it exists.
+ if (!wxControl::GetLabel().IsEmpty())
+ height += cy1/2;
+
// and also wide enough for its label
int widthLabel;
GetTextExtent(GetTitle(), &widthLabel, NULL);
x_offset += cx1;
y_offset += cy1;
-#if defined(CTL3D) && (!CTL3D)
- y_offset += (int)(cy1/2); // Fudge factor since buttons overlapped label
- // JACS 2/12/93. CTL3D draws group label quite high.
-#endif
+ // Add extra space under the label, if it exists.
+ if (!wxControl::GetLabel().IsEmpty())
+ y_offset += cy1/2;
int startX = x_offset;
int startY = y_offset;
{
if (m_noItems > 0)
{
- if (m_selectedButton == -1)
- ::SetFocus((HWND) m_radioButtons[0]);
- else
- ::SetFocus((HWND) m_radioButtons[m_selectedButton]);
+ ::SetFocus((HWND)m_radioButtons[m_selectedButton == -1
+ ? 0
+ : m_selectedButton]);
}
}
void wxRadioBox::Command(wxCommandEvent & event)
{
SetSelection (event.m_commandInt);
+ SetFocus();
ProcessCommand (event);
}
// radiobox pointer in GWL_USERDATA for radio buttons must be updated too!
void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn)
{
- // No GWL_USERDATA in Win16, so omit this subclassing.
-#ifdef __WIN32__
HWND hwndBtn = (HWND)hWndBtn;
if ( !s_wndprocRadioBtn )
::SetWindowLong(hwndBtn, GWL_WNDPROC, (long)wxRadioBtnWndProc);
::SetWindowLong(hwndBtn, GWL_USERDATA, (long)this);
-#endif // __WIN32__
}
void wxRadioBox::SendNotificationEvent()
#endif // wxUSE_CTL3D
HDC hdc = (HDC)pDC;
- if (GetParent()->GetTransparentBackground())
- SetBkMode(hdc, TRANSPARENT);
- else
- SetBkMode(hdc, OPAQUE);
-
wxColour colBack = GetBackgroundColour();
if (!IsEnabled())
case WM_NOTIFY:
{
NMHDR* hdr = (NMHDR *)lParam;
- if ( (int)hdr->code == TTN_NEEDTEXT )
+ if ( hdr->code == TTN_NEEDTEXT )
{
wxRadioBox *radiobox = (wxRadioBox *)
::GetWindowLong(hwnd, GWL_USERDATA);
if ( selNew != selOld )
{
radiobox->SetSelection(selNew);
+ radiobox->SetFocus();
// emulate the button click
radiobox->SendNotificationEvent();
bool processed = TRUE;
+ // HELPINFO doesn't seem to be supported on WinCE.
+#ifndef __WXWINCE__
HELPINFO* info = (HELPINFO*) lParam;
// Don't yet process menu help events, just windows
if (info->iContextType == HELPINFO_WINDOW)
+#endif
{
wxWindow* subjectOfHelp = radiobox;
bool eventProcessed = FALSE;
while (subjectOfHelp && !eventProcessed)
{
- wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(), wxPoint(info->MousePos.x, info->MousePos.y) ) ; // info->iCtrlId);
+ wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(),
+#ifdef __WXWINCE__
+ wxPoint(0, 0)
+#else
+ wxPoint(info->MousePos.x, info->MousePos.y)
+#endif
+ ) ; // info->iCtrlId);
helpEvent.SetEventObject(radiobox);
eventProcessed = radiobox->GetEventHandler()->ProcessEvent(helpEvent);
}
processed = eventProcessed;
}
+#ifndef __WXWINCE__
else if (info->iContextType == HELPINFO_MENUITEM)
{
wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId) ;
helpEvent.SetEventObject(radiobox);
processed = radiobox->GetEventHandler()->ProcessEvent(helpEvent);
}
- else processed = FALSE;
-
+ else
+ processed = FALSE;
+#endif
if (processed)
return 0;