X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c92d798f9d11d15acb4af65f7fc03187ea9eee7c..06298235850b7e576ef77a9a95b521534f18a4d9:/src/msw/radiobox.cpp diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index 5daf5146d3..857106acb0 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -38,14 +38,15 @@ #include "wx/msw/private.h" #if wxUSE_TOOLTIPS + +#ifndef __GNUWIN32__ #include +#endif #include "wx/tooltip.h" #endif // wxUSE_TOOLTIPS -#if !USE_SHARED_LIBRARY - IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) -#endif +IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) // VZ: the new behaviour is to create the radio buttons as children of the // radiobox instead of creating them as children of the radiobox' parent. @@ -54,7 +55,8 @@ // and allows tooltips to work with radioboxes, so there should be no // reason to revert to the backward compatible behaviour - but I still // leave this possibility just in case. -#define RADIOBTN_PARENT_IS_RADIOBOX 1 + +#define RADIOBTN_PARENT_IS_RADIOBOX 0 // --------------------------------------------------------------------------- // private functions @@ -154,7 +156,7 @@ wxRadioBox::wxRadioBox(wxWindow *parent, wxFunction func, const char *title, delete choices2; } -#endif +#endif // WXWIN_COMPATIBILITY // Radio box item wxRadioBox::wxRadioBox() @@ -182,7 +184,7 @@ bool wxRadioBox::Create(wxWindow *parent, { // initialize members m_selectedButton = -1; - m_noItems = n; + m_noItems = 0; m_majorDim = majorDim == 0 ? n : majorDim; m_noRowsOrCols = majorDim; @@ -192,10 +194,12 @@ bool wxRadioBox::Create(wxWindow *parent, return FALSE; // create the static box - if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, title, 0) ) + if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX | WS_GROUP, + pos, size, title, 0) ) return FALSE; // and now create the buttons + m_noItems = n; #if RADIOBTN_PARENT_IS_RADIOBOX HWND hwndParent = GetHwnd(); #else @@ -219,7 +223,7 @@ bool wxRadioBox::Create(wxWindow *parent, { m_radioWidth[i] = m_radioHeight[i] = -1; - long styleBtn = BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE; + long styleBtn = BS_AUTORADIOBUTTON | WS_TABSTOP | WS_CHILD | WS_VISIBLE; if ( i == 0 && style == 0 ) styleBtn |= WS_GROUP; @@ -358,9 +362,9 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) int xx = x; int yy = y; - if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + if (x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) xx = currentX; - if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + if (y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) yy = currentY; #if RADIOBTN_PARENT_IS_RADIOBOX @@ -658,7 +662,7 @@ bool wxRadioBox::ContainsHWND(WXHWND hWnd) const return FALSE; } -void wxRadioBox::Command (wxCommandEvent & event) +void wxRadioBox::Command(wxCommandEvent & event) { SetSelection (event.m_commandInt); ProcessCommand (event); @@ -687,24 +691,61 @@ void wxRadioBox::SendNotificationEvent() ProcessCommand(event); } +bool wxRadioBox::SetFont(const wxFont& font) +{ + if ( !wxControl::SetFont(font) ) + { + // nothing to do + return FALSE; + } + + // also set the font of our radio buttons + WXHFONT hfont = wxFont(font).GetResourceHandle(); + for ( int n = 0; n < m_noItems; n++ ) + { + ::SendMessage((HWND)m_radioButtons[n], WM_SETFONT, (WPARAM)hfont, 0L); + } + + return TRUE; +} + long wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { - // This is required for the radiobox to be sensitive to mouse input, - // e.g. for Dialog Editor. - if (nMsg == WM_NCHITTEST) + switch ( nMsg ) { - int xPos = LOWORD(lParam); // horizontal position of cursor - int yPos = HIWORD(lParam); // vertical position of cursor + case WM_CTLCOLORSTATIC: + // set the colour of the radio buttons to be the same as ours + { + HDC hdc = (HDC)wParam; - ScreenToClient(&xPos, &yPos); + const wxColour& colBack = GetBackgroundColour(); + ::SetBkColor(hdc, wxColourToRGB(colBack)); + ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour())); - // Make sure you can drag by the top of the groupbox, but let - // other (enclosed) controls get mouse events also - if (yPos < 10) - return (long)HTCLIENT; - } + wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID); + + return (WXHBRUSH)brush->GetResourceHandle(); + } - return wxControl::MSWWindowProc(nMsg, wParam, lParam); + // This is required for the radiobox to be sensitive to mouse input, + // e.g. for Dialog Editor. + case WM_NCHITTEST: + { + int xPos = LOWORD(lParam); // horizontal position of cursor + int yPos = HIWORD(lParam); // vertical position of cursor + + ScreenToClient(&xPos, &yPos); + + // Make sure you can drag by the top of the groupbox, but let + // other (enclosed) controls get mouse events also + if (yPos < 10) + return (long)HTCLIENT; + } + // fall through + + default: + return wxControl::MSWWindowProc(nMsg, wParam, lParam); + } } // --------------------------------------------------------------------------- @@ -729,7 +770,7 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd, wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") ); -#if wxUSE_TOOLTIPS +#if wxUSE_TOOLTIPS && !defined(__GNUWIN32__) if ( msg == WM_NOTIFY ) { NMHDR* hdr = (NMHDR *)lParam;