m_radioHeight[item] = wxDefaultCoord;
::SetWindowText((*m_radioButtons)[item], label.c_str());
+
+ InvalidateBestSize();
}
void wxRadioBox::SetSelection(int N)
BOOL ret = ::ShowWindow((*m_radioButtons)[item], show ? SW_SHOW : SW_HIDE);
- return (ret != 0) == show;
+ bool changed = (ret != 0) == show;
+ if( changed )
+ InvalidateBestSize();
+ return changed;
}
WX_FORWARD_STD_METHODS_TO_SUBWINDOWS(wxRadioBox, wxStaticBox, m_radioButtons)
wxSize wxRadioBox::DoGetBestSize() const
{
- return GetTotalButtonSize(GetMaxButtonSize());
+ wxSize best = GetTotalButtonSize(GetMaxButtonSize());
+ CacheBestSize(best);
+ return best;
}
// Restored old code.
height = heightOld;
}
- ::MoveWindow(GetHwnd(), xx, yy, width, height, TRUE);
+ DoMoveWindow(xx, yy, width, height);
// Now position all the buttons: the current button will be put at
// wxPoint(x_offset, y_offset) and the new row/column will start at
}
}
+// ----------------------------------------------------------------------------
+// radio box drawing
+// ----------------------------------------------------------------------------
+
+#ifndef __WXWINCE__
+
+WXHRGN wxRadioBox::MSWGetRegionWithoutChildren()
+{
+ RECT rc;
+ ::GetWindowRect(GetHwnd(), &rc);
+ HRGN hrgn = ::CreateRectRgn(rc.left, rc.top, rc.right + 1, rc.bottom + 1);
+
+ const size_t count = GetCount();
+ for ( size_t i = 0; i < count; ++i )
+ {
+ ::GetWindowRect((*m_radioButtons)[i], &rc);
+ AutoHRGN hrgnchild(::CreateRectRgnIndirect(&rc));
+ ::CombineRgn(hrgn, hrgn, hrgnchild, RGN_DIFF);
+ }
+
+ return (WXHRGN)hrgn;
+}
+
+WXLRESULT
+wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+ // FIXME: Without this, the radiobox corrupts other controls as it moves
+ // in a dynamic layout. Refreshing causes flicker, but it's better than
+ // leaving droppings. Note that for some reason, wxStaticBox doesn't need
+ // this (perhaps because it has no real children?)
+ if ( nMsg == WM_MOVE )
+ {
+ WXLRESULT res = wxControl::MSWWindowProc(nMsg, wParam, lParam);
+ wxRect rect = GetRect();
+ GetParent()->Refresh(true, & rect);
+ return res;
+ }
+
+ return wxStaticBox::MSWWindowProc(nMsg, wParam, lParam);
+}
+
+#endif // __WXWINCE__
+
// ---------------------------------------------------------------------------
// window proc for radio buttons
// ---------------------------------------------------------------------------
if ( processed )
return 0;
-
- break;
}
+ break;
#endif // !__WXWINCE__
}
return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn, hwnd, message, wParam, lParam);
}
-WXHRGN wxRadioBox::MSWGetRegionWithoutChildren()
-{
- RECT rc;
- ::GetWindowRect(GetHwnd(), &rc);
- HRGN hrgn = ::CreateRectRgn(rc.left, rc.top, rc.right + 1, rc.bottom + 1);
-
- const size_t count = GetCount();
- for ( size_t i = 0; i < count; ++i )
- {
- ::GetWindowRect((*m_radioButtons)[i], &rc);
- AutoHRGN hrgnchild(::CreateRectRgnIndirect(&rc));
- ::CombineRgn(hrgn, hrgn, hrgnchild, RGN_DIFF);
- }
-
- return (WXHRGN)hrgn;
-}
-
-WXLRESULT wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
-{
-#ifndef __WXWINCE__
- if ( nMsg == WM_PRINTCLIENT )
- {
- // first check to see if a parent window knows how to paint us better
- for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
- if ( win->MSWPrintChild(this, wParam, lParam) )
- return true;
-
- // nope, so lets do it ourselves
- RECT rc;
- WXHBRUSH hbr = DoMSWControlColor((HDC)wParam, wxNullColour);
- if ( !hbr )
- {
- wxBrush *brush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
- hbr = (WXHBRUSH)brush->GetResourceHandle();
- }
-
- ::GetClientRect(GetHwnd(), &rc);
- ::FillRect((HDC)wParam, &rc, (HBRUSH)hbr);
-
- return true;
- }
-#endif
- // __WXWINCE__
-
- return wxStaticBox::MSWWindowProc(nMsg, wParam, lParam);
-}
#endif // wxUSE_RADIOBOX