#include "wx/control.h"
+#if wxUSE_NOTEBOOK
+ #include "wx/notebook.h"
+#endif // wxUSE_NOTEBOOK
+
#include "wx/msw/private.h"
+#include "wx/msw/uxtheme.h"
#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
#include <commctrl.h>
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
-BEGIN_EVENT_TABLE(wxControl, wxWindow)
- EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground)
-END_EVENT_TABLE()
-
// ============================================================================
// wxControl implementation
// ============================================================================
{
// take size according to layout
wxSize bestSize(
-#ifdef __SMARTPHONE__
+#if defined(__SMARTPHONE__) && defined(__WXWINCE__)
0,GetCharHeight()
-#else !__SMARTPHONE__
+#else
GetSystemMetrics(is_vertical ? SM_CXVSCROLL : SM_CXHSCROLL),
GetSystemMetrics(is_vertical ? SM_CYVSCROLL : SM_CYHSCROLL)
-#endif __SMARTPHONE__/!__SMARTPHONE__
+#endif
);
// correct size as for undocumented MSW variants cases (WinCE and perhaps others)
}
#endif // Win95
-void wxControl::OnEraseBackground(wxEraseEvent& event)
+WXHBRUSH wxControl::MSWControlColorSolid(WXHDC pDC, wxColour colBg)
{
- // notice that this 'dumb' implementation may cause flicker for some of the
- // controls in which case they should intercept wxEraseEvent and process it
- // themselves somehow
-
- RECT rect;
- ::GetClientRect(GetHwnd(), &rect);
-
- HBRUSH hBrush = ::CreateSolidBrush(wxColourToRGB(GetBackgroundColour()));
+ HDC hdc = (HDC)pDC;
+ if ( m_hasFgCol )
+ ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
- HDC hdc = GetHdcOf((*event.GetDC()));
+ if ( colBg.Ok() )
+ {
+ ::SetBkColor(hdc, wxColourToRGB(colBg));
-#ifndef __WXWINCE__
- int mode = ::SetMapMode(hdc, MM_TEXT);
-#endif
+ wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBg, wxSOLID);
- ::FillRect(hdc, &rect, hBrush);
- ::DeleteObject(hBrush);
+ return (WXHBRUSH)brush->GetResourceHandle();
+ }
-#ifndef __WXWINCE__
- ::SetMapMode(hdc, mode);
-#endif
+ return 0;
}
-WXHBRUSH wxControl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
-#if wxUSE_CTL3D
- WXUINT message,
- WXWPARAM wParam,
- WXLPARAM lParam
-#else
- WXUINT WXUNUSED(message),
- WXWPARAM WXUNUSED(wParam),
- WXLPARAM WXUNUSED(lParam)
-#endif
- )
+WXHBRUSH wxControl::MSWControlColor(WXHDC pDC)
{
-#if wxUSE_CTL3D
- if ( m_useCtl3D )
- {
- HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
- return (WXHBRUSH) hbrush;
- }
-#endif // wxUSE_CTL3D
+ WXHBRUSH hbr = MSWControlColorSolid(pDC, m_hasBgCol ? m_backgroundColour
+ : wxNullColour);
+ if ( hbr )
+ return hbr;
- HDC hdc = (HDC)pDC;
- wxColour colBack = GetBackgroundColour();
+ ::SetBkMode((HDC)pDC, TRANSPARENT);
- ::SetBkColor(hdc, wxColourToRGB(colBack));
- ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
+#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
- wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
+ return ::GetStockObject(NULL_BRUSH);
+}
- return (WXHBRUSH)brush->GetResourceHandle();
+WXHBRUSH wxControl::MSWControlColorDisabled(WXHDC pDC)
+{
+ return MSWControlColorSolid
+ (
+ pDC,
+ wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)
+ );
}
// ---------------------------------------------------------------------------