X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f048e32fcd5260f33fbebdafbe1a0deeda175419..3f399a69cceccea1f955dab85af0c21b361c78a0:/src/msw/radiobox.cpp?ds=sidebyside diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index d33f534cf2..fe2d803e2c 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -32,19 +32,21 @@ #include "wx/bitmap.h" #include "wx/brush.h" #include "wx/radiobox.h" + #include "wx/log.h" #endif #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 // 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. @@ -53,7 +55,15 @@ // 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. + +// For some reason, the background colour is set wrongly in WIN16 mode +// if we use the new method. + +#ifdef __WIN16__ +#define RADIOBTN_PARENT_IS_RADIOBOX 0 +#else #define RADIOBTN_PARENT_IS_RADIOBOX 1 +#endif // --------------------------------------------------------------------------- // private functions @@ -181,7 +191,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; @@ -195,6 +205,7 @@ bool wxRadioBox::Create(wxWindow *parent, return FALSE; // and now create the buttons + m_noItems = n; #if RADIOBTN_PARENT_IS_RADIOBOX HWND hwndParent = GetHwnd(); #else @@ -657,7 +668,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); @@ -686,6 +697,44 @@ 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) + { + 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; + } + + return wxControl::MSWWindowProc(nMsg, wParam, lParam); +} + // --------------------------------------------------------------------------- // window proc for radio buttons // --------------------------------------------------------------------------- @@ -708,7 +757,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;