diff --git a/include/wx/defs.h b/include/wx/defs.h index 9b26ae22f0..70d15fa789 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1295,7 +1295,8 @@ enum wxBorder wxBORDER_SIMPLE = 0x02000000, wxBORDER_RAISED = 0x04000000, wxBORDER_SUNKEN = 0x08000000, - wxBORDER_DOUBLE = 0x10000000, + wxBORDER_DOUBLE = 0x10000000, /* deprecated */ + wxBORDER_THEME = 0x10000000, /* a mask to extract border style from the combination of flags */ wxBORDER_MASK = 0x1f200000 diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 44a2b1c9e9..2cff9870d5 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -30,6 +30,10 @@ #include "wx/image.h" +#if defined(__WXMSW__) && wxUSE_UXTHEME +#include "wx/msw/uxtheme.h" +#endif + #define WXMAX(a,b) ((a)>(b)?(a):(b)) // ---------------------------------------------------------------------------- @@ -321,11 +325,16 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { -#ifdef __WXGTK__ - if ( !wxTextCtrlBase::Create(parent, id, pos, size, wxSUNKEN_BORDER | (style & ~wxBORDER_MASK), validator, name) ) -#else - if ( !wxTextCtrlBase::Create(parent, id, pos, size, wxSIMPLE_BORDER | (style & ~wxBORDER_MASK), validator, name) ) + int borderStyle = wxBORDER_SIMPLE; + +#if defined(__WXMSW__) && wxUSE_UXTHEME && !(defined(__POCKETPC__) || defined(__SMARTPHONE__)) + if (wxUxThemeEngine::GetIfActive()) + borderStyle = wxBORDER_THEME; +#elif defined(__WXGTK__) + borderStyle = wxBORDER_SUNKEN; #endif + + if ( !wxTextCtrlBase::Create(parent, id, pos, size, borderStyle | (style & ~wxBORDER_MASK), validator, name) ) { return false; } diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 31cc2f55c9..0698458378 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -303,6 +303,10 @@ bool wxTextCtrl::Create(wxWindow *parent, #ifdef __WXWINCE__ if ((style & wxBORDER_MASK) == 0) style |= wxBORDER_SIMPLE; +#else + // Standard text control already handles theming + if ((style & (wxTE_RICH|wxTE_RICH2)) && ((style & wxBORDER_MASK) == wxBORDER_DEFAULT)) + style |= wxBORDER_THEME; #endif // base initialization diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 50250464a4..ca7970714e 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -120,6 +120,18 @@ #endif #endif +#if wxUSE_UXTHEME + #include "wx/msw/uxtheme.h" + #define EP_EDITTEXT 1 + #define ETS_NORMAL 1 + #define ETS_HOT 2 + #define ETS_SELECTED 3 + #define ETS_DISABLED 4 + #define ETS_FOCUSED 5 + #define ETS_READONLY 6 + #define ETS_ASSIST 7 +#endif + #if defined(TME_LEAVE) && defined(WM_MOUSELEAVE) && wxUSE_DYNLIB_CLASS #define HAVE_TRACKMOUSEEVENT #endif // everything needed for TrackMouseEvent() @@ -1378,6 +1390,7 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const case wxBORDER_NONE: case wxBORDER_SIMPLE: + case wxBORDER_THEME: break; case wxBORDER_STATIC: @@ -1393,9 +1406,9 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const style &= ~WS_BORDER; break; - case wxBORDER_DOUBLE: - *exstyle |= WS_EX_DLGMODALFRAME; - break; +// case wxBORDER_DOUBLE: +// *exstyle |= WS_EX_DLGMODALFRAME; +// break; } // wxUniv doesn't use Windows dialog navigation functions at all @@ -3234,6 +3247,95 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l } break; #endif // __WXWINCE__ + +#if wxUSE_UXTHEME + // If we want the default themed border then we need to draw it ourselves + case WM_NCCALCSIZE: + { + wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive(); + if (theme && GetBorder() == wxBORDER_THEME) + { + // first ask the widget to calculate the border size + rc.result = MSWDefWindowProc(message, wParam, lParam); + processed = true; + + // now alter the client size making room for drawing a themed border + NCCALCSIZE_PARAMS *csparam = NULL; + RECT rect; + if (wParam) + { + csparam = (NCCALCSIZE_PARAMS*)lParam; + rect = csparam->rgrc[0]; + } + else + { + rect = *((RECT*)lParam); + } + wxUxThemeHandle hTheme(this, L"EDIT"); + RECT rcClient = { 0, 0, 0, 0 }; + wxClientDC dc(this); + + if (theme->GetThemeBackgroundContentRect( + hTheme, GetHdcOf(dc), EP_EDITTEXT, ETS_NORMAL, + &rect, &rcClient) == S_OK) + { + InflateRect(&rcClient, -1, -1); + if (wParam) + csparam->rgrc[0] = rcClient; + else + *((RECT*)lParam) = rcClient; + rc.result = WVR_REDRAW; + } + } + } + break; + + case WM_NCPAINT: + { + wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive(); + if (theme && GetBorder() == wxBORDER_THEME) + { + // first ask the widget to paint its non-client area, such as scrollbars, etc. + rc.result = MSWDefWindowProc(message, wParam, lParam); + processed = true; + + wxUxThemeHandle hTheme(this, L"EDIT"); + wxWindowDC dc(this); + + // Clip the DC so that you only draw on the non-client area + RECT rcBorder; + wxCopyRectToRECT(GetSize(), rcBorder); + + RECT rcClient; + theme->GetThemeBackgroundContentRect( + hTheme, GetHdcOf(dc), EP_EDITTEXT, ETS_NORMAL, &rcBorder, &rcClient); + InflateRect(&rcClient, -1, -1); + + ::ExcludeClipRect(GetHdcOf(dc), rcClient.left, rcClient.top, + rcClient.right, rcClient.bottom); + + // Make sure the background is in a proper state + if (theme->IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL)) + { + theme->DrawThemeParentBackground(GetHwnd(), GetHdcOf(dc), &rcBorder); + } + + // Draw the border + int nState; + if ( !IsEnabled() ) + nState = ETS_DISABLED; + // should we check this? + //else if ( ::GetWindowLong(GetHwnd(), GWL_STYLE) & ES_READONLY) + // nState = ETS_READONLY; + else + nState = ETS_NORMAL; + theme->DrawThemeBackground(hTheme, GetHdcOf(dc), EP_EDITTEXT, nState, &rcBorder, NULL); + } + } + break; + +#endif // wxUSE_UXTHEME + } if ( !processed ) @@ -5791,7 +5893,7 @@ static inline bool wxIsKeyDown(WXWORD vk) switch (vk) { case VK_LBUTTON: - if (GetSystemMetrics(SM_SWAPBUTTON)) vk = VK_RBUTTON; + if (GetSystemMetrics(SM_SWAPBUTTON)) vk = VK_RBUTTON; break; case VK_RBUTTON: if (GetSystemMetrics(SM_SWAPBUTTON)) vk = VK_LBUTTON;