style |= WS_VISIBLE;
}
- // choose the position for the control
+ // choose the position for the control: we have a problem with default size
+ // here as we can't calculate the best size before the control exists
+ // (DoGetBestSize() may need to use m_hWnd), so just choose the minimal
+ // possible but non 0 size because 0 window width/height result in problems
+ // elsewhere
int x = pos.x == wxDefaultCoord ? 0 : pos.x,
y = pos.y == wxDefaultCoord ? 0 : pos.y,
- w = size.x == wxDefaultCoord ? 0 : size.x,
- h = size.y == wxDefaultCoord ? 0 : size.y;
+ w = size.x == wxDefaultCoord ? 1 : size.x,
+ h = size.y == wxDefaultCoord ? 1 : size.y;
// ... and adjust it to account for a possible parent frames toolbar
AdjustForParentClientOrigin(x, y);
}
#endif // Win95
-WXHBRUSH wxControl::MSWControlColorSolid(WXHDC pDC, wxColour colBg)
+WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg)
{
HDC hdc = (HDC)pDC;
if ( m_hasFgCol )
+ {
::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
+ }
+ // use the background colour override if a valid colour is given
+ WXHBRUSH hbr;
if ( colBg.Ok() )
{
- ::SetBkColor(hdc, wxColourToRGB(colBg));
-
+ // draw children with the same colour as the parent
wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBg, wxSOLID);
- return (WXHBRUSH)brush->GetResourceHandle();
+ hbr = (WXHBRUSH)brush->GetResourceHandle();
+ }
+ else // use our own background colour and recurse upwards if necessary
+ {
+ hbr = MSWGetBgBrush(pDC);
}
- return 0;
+ return hbr;
}
WXHBRUSH wxControl::MSWControlColor(WXHDC pDC)
{
- WXHBRUSH hbr = MSWControlColorSolid(pDC, m_hasBgCol ? m_backgroundColour
- : wxNullColour);
- if ( hbr )
- return hbr;
-
+ // by default consider that the controls text shouldn't erase the
+ // background under it (this is true for all static controls, check boxes,
+ // radio buttons, ...
::SetBkMode((HDC)pDC, TRANSPARENT);
-#if wxUSE_UXTHEME && wxUSE_NOTEBOOK
- if ( wxUxThemeEngine::GetIfActive() )
- {
- for ( wxWindow *win = this; win; win = win->GetParent() )
- {
- wxNotebook *nbook = wxDynamicCast(win, wxNotebook);
- if ( nbook )
- {
- // return value may be NULL but it is ok: if the first parent
- // notebook doesn't use themes, then we don't have to process
- // this message at all, so let default processing take place
- return nbook->GetThemeBackgroundBrush(pDC, this);
- }
- }
- }
-#endif // wxUSE_UXTHEME
-
- // let the control deal with background itself
- return 0;
+ return DoMSWControlColor(pDC, wxNullColour);
}
WXHBRUSH wxControl::MSWControlColorDisabled(WXHDC pDC)
{
- return MSWControlColorSolid
- (
- pDC,
- wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)
- );
+ return DoMSWControlColor(pDC,
+ wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
}
// ---------------------------------------------------------------------------