From a047aff270905b377a81657a90f92eb3297157d0 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 7 Aug 2007 19:22:43 +0000 Subject: [PATCH] Added wxBORDER_THEME, wxWindow::GetDefaultBorderForControl(), wxWindow::CanApplyThemeBorder(). wxTextCtrl and wxSearchCtrl now get the correct border on wxMSW, and the wxRichTextCtrl sample also now demonstrates correct borders. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47927 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/bookctrl.h | 3 + include/wx/defs.h | 3 +- include/wx/msw/button.h | 3 + include/wx/msw/checkbox.h | 3 + include/wx/msw/choice.h | 3 + include/wx/msw/datectrl.h | 3 + include/wx/msw/gauge95.h | 3 + include/wx/msw/listbox.h | 3 + include/wx/msw/radiobox.h | 3 + include/wx/msw/scrolbar.h | 3 + include/wx/msw/slider95.h | 2 + include/wx/msw/spinbutt.h | 3 + include/wx/msw/statbmp.h | 3 + include/wx/msw/statbox.h | 3 + include/wx/msw/textctrl.h | 3 + include/wx/msw/tglbtn.h | 3 + include/wx/msw/toplevel.h | 3 + include/wx/msw/treectrl.h | 3 + include/wx/msw/window.h | 5 + include/wx/richtext/richtextstyles.h | 7 +- include/wx/vlbox.h | 2 + include/wx/window.h | 8 ++ samples/richtext/richtext.cpp | 4 +- src/generic/srchctlg.cpp | 6 ++ src/generic/vlbox.cpp | 5 + src/msw/control.cpp | 9 +- src/msw/textctrl.cpp | 16 +++- src/msw/window.cpp | 132 ++++++++++++++++++++++++++- src/richtext/richtextctrl.cpp | 8 ++ src/richtext/richtextstyles.cpp | 15 ++- 30 files changed, 241 insertions(+), 29 deletions(-) diff --git a/include/wx/bookctrl.h b/include/wx/bookctrl.h index 181946ae04..15dd227715 100644 --- a/include/wx/bookctrl.h +++ b/include/wx/bookctrl.h @@ -233,6 +233,9 @@ public: // we don't want focus for ourselves virtual bool AcceptsFocus() const { return false; } + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + protected: // flags for DoSetSelection() enum diff --git a/include/wx/defs.h b/include/wx/defs.h index b19d4d14d7..43c15e50f3 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1406,7 +1406,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/include/wx/msw/button.h b/include/wx/msw/button.h index 33d8272b2b..f7c34eae62 100644 --- a/include/wx/msw/button.h +++ b/include/wx/msw/button.h @@ -58,6 +58,9 @@ public: virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item); virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + private: void MakeOwnerDrawn(); diff --git a/include/wx/msw/checkbox.h b/include/wx/msw/checkbox.h index c61399154e..c1b17cd5cf 100644 --- a/include/wx/msw/checkbox.h +++ b/include/wx/msw/checkbox.h @@ -47,6 +47,9 @@ public: virtual bool SetForegroundColour(const wxColour& colour); virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item); + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/msw/choice.h b/include/wx/msw/choice.h index 3d004d2ab6..cff06ed33e 100644 --- a/include/wx/msw/choice.h +++ b/include/wx/msw/choice.h @@ -85,6 +85,9 @@ public: virtual bool MSWShouldPreProcessMessage(WXMSG *pMsg); virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + protected: // common part of all ctors void Init() { m_lastAcceptedSelection = wxID_NONE; } diff --git a/include/wx/msw/datectrl.h b/include/wx/msw/datectrl.h index c4078c6f68..c5d43d93a2 100644 --- a/include/wx/msw/datectrl.h +++ b/include/wx/msw/datectrl.h @@ -57,6 +57,9 @@ public: virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/msw/gauge95.h b/include/wx/msw/gauge95.h index 70390a9584..d595242620 100644 --- a/include/wx/msw/gauge95.h +++ b/include/wx/msw/gauge95.h @@ -58,6 +58,9 @@ public: WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/msw/listbox.h b/include/wx/msw/listbox.h index 13daa8a232..3c48ad4edf 100644 --- a/include/wx/msw/listbox.h +++ b/include/wx/msw/listbox.h @@ -133,6 +133,9 @@ public: return GetCompositeControlsDefaultAttributes(variant); } + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + protected: virtual void DoSetSelection(int n, bool select); diff --git a/include/wx/msw/radiobox.h b/include/wx/msw/radiobox.h index 45cb608755..c4e5b280a3 100644 --- a/include/wx/msw/radiobox.h +++ b/include/wx/msw/radiobox.h @@ -115,6 +115,9 @@ public: // it to behave normally virtual bool AcceptsFocus() const { return wxControl::AcceptsFocus(); } + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + void SetLabelFont(const wxFont& WXUNUSED(font)) {} void SetButtonFont(const wxFont& font) { SetFont(font); } diff --git a/include/wx/msw/scrolbar.h b/include/wx/msw/scrolbar.h index b1dc497e11..72073e490f 100644 --- a/include/wx/msw/scrolbar.h +++ b/include/wx/msw/scrolbar.h @@ -58,6 +58,9 @@ public: virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/msw/slider95.h b/include/wx/msw/slider95.h index 70ce173c71..5702f1824a 100644 --- a/include/wx/msw/slider95.h +++ b/include/wx/msw/slider95.h @@ -83,6 +83,8 @@ public: // we should let background show through the slider (and its labels) virtual bool HasTransparentBackground() { return true; } + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } void Command(wxCommandEvent& event); virtual bool MSWOnScroll(int orientation, WXWORD wParam, diff --git a/include/wx/msw/spinbutt.h b/include/wx/msw/spinbutt.h index 56e69f30b8..f57277f4eb 100644 --- a/include/wx/msw/spinbutt.h +++ b/include/wx/msw/spinbutt.h @@ -57,6 +57,9 @@ public: // a wxSpinButton can't do anything useful with focus, only wxSpinCtrl can virtual bool AcceptsFocus() const { return false; } + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/msw/statbmp.h b/include/wx/msw/statbmp.h index 883b52ae37..7086e812dd 100644 --- a/include/wx/msw/statbmp.h +++ b/include/wx/msw/statbmp.h @@ -54,6 +54,9 @@ public: virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + protected: virtual wxBorder GetDefaultBorder() const; virtual wxSize DoGetBestSize() const; diff --git a/include/wx/msw/statbox.h b/include/wx/msw/statbox.h index 34bf7ccc12..8d48ba933e 100644 --- a/include/wx/msw/statbox.h +++ b/include/wx/msw/statbox.h @@ -40,6 +40,9 @@ public: virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/msw/textctrl.h b/include/wx/msw/textctrl.h index 8b3c71f485..09dc91bd0d 100644 --- a/include/wx/msw/textctrl.h +++ b/include/wx/msw/textctrl.h @@ -170,6 +170,9 @@ public: virtual bool AcceptsFocus() const; + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const; + // callbacks void OnDropFiles(wxDropFilesEvent& event); void OnChar(wxKeyEvent& event); // Process 'enter' if required diff --git a/include/wx/msw/tglbtn.h b/include/wx/msw/tglbtn.h index a6dc795486..9c3ef03c93 100644 --- a/include/wx/msw/tglbtn.h +++ b/include/wx/msw/tglbtn.h @@ -48,6 +48,9 @@ public: virtual void Command(wxCommandEvent& event); virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + protected: virtual wxSize DoGetBestSize() const; virtual wxBorder GetDefaultBorder() const; diff --git a/include/wx/msw/toplevel.h b/include/wx/msw/toplevel.h index 48e7e512e4..82379ad36d 100644 --- a/include/wx/msw/toplevel.h +++ b/include/wx/msw/toplevel.h @@ -107,6 +107,9 @@ public: // window proc for the frames WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + protected: // common part of all ctors void Init(); diff --git a/include/wx/msw/treectrl.h b/include/wx/msw/treectrl.h index 117a79090c..cfb43004a0 100644 --- a/include/wx/msw/treectrl.h +++ b/include/wx/msw/treectrl.h @@ -210,6 +210,9 @@ public: void SetState(const wxTreeItemId& node, int state); int GetState(const wxTreeItemId& node); + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + protected: // SetImageList helper void SetAnyImageList(wxImageList *imageList, int which); diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index 0a3600676c..2b56566a73 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -433,6 +433,11 @@ public: // check if a native double-buffering applies for this window virtual bool IsDoubleBuffered() const; + // this allows you to implement standard control borders without + // repeating the code in different classes that are not derived from + // wxControl + virtual wxBorder GetDefaultBorderForControl() const; + // synthesize a wxEVT_LEAVE_WINDOW event and set m_mouseInWindow to false void GenerateMouseLeave(); diff --git a/include/wx/richtext/richtextstyles.h b/include/wx/richtext/richtextstyles.h index 96659e7f9d..d87b5bc3c5 100644 --- a/include/wx/richtext/richtextstyles.h +++ b/include/wx/richtext/richtextstyles.h @@ -580,12 +580,7 @@ public: m_value = -1; } - virtual bool Create( wxWindow* parent ) - { - return wxRichTextStyleListBox::Create(parent, wxID_ANY, - wxPoint(0,0), wxDefaultSize, - wxSIMPLE_BORDER); - } + virtual bool Create( wxWindow* parent ); virtual wxWindow *GetControl() { return this; } diff --git a/include/wx/vlbox.h b/include/wx/vlbox.h index 62c145e4e2..2301f7c651 100644 --- a/include/wx/vlbox.h +++ b/include/wx/vlbox.h @@ -201,6 +201,8 @@ public: static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); + virtual wxBorder GetDefaultBorder() const { return GetDefaultBorderForControl(); } + protected: // the derived class must implement this function to actually draw the item // with the given index on the provided DC diff --git a/include/wx/window.h b/include/wx/window.h index 9e3ace3a7d..53aad4df97 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -1221,6 +1221,9 @@ public: // area (normal windows can't, but e.g. menubar or statusbar can): virtual bool CanBeOutsideClientArea() const { return false; } + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return true; } + protected: // event handling specific to wxWindow virtual bool TryValidator(wxEvent& event); @@ -1381,6 +1384,11 @@ protected: // specified) border for the window class virtual wxBorder GetDefaultBorder() const; + // this allows you to implement standard control borders without + // repeating the code in different classes that are not derived from + // wxControl + virtual wxBorder GetDefaultBorderForControl() const { return wxWindowBase::GetDefaultBorder(); } + // Get the default size for the new window if no explicit size given. TLWs // have their own default size so this is just for non top-level windows. static int WidthDefault(int w) { return w == wxDefaultCoord ? 20 : w; } diff --git a/samples/richtext/richtext.cpp b/samples/richtext/richtext.cpp index e76ed01d8c..ec71a3da79 100644 --- a/samples/richtext/richtext.cpp +++ b/samples/richtext/richtext.cpp @@ -682,13 +682,13 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos, toolBar->Realize(); - wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, GetClientSize(), wxSP_NO_XP_THEME|wxSP_3D|wxSP_LIVE_UPDATE); + wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, GetClientSize(), wxSP_LIVE_UPDATE); wxFont textFont = wxFont(12, wxROMAN, wxNORMAL, wxNORMAL); wxFont boldFont = wxFont(12, wxROMAN, wxNORMAL, wxBOLD); wxFont italicFont = wxFont(12, wxROMAN, wxITALIC, wxNORMAL); - m_richTextCtrl = new wxRichTextCtrl(splitter, ID_RICHTEXT_CTRL, wxEmptyString, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxNO_BORDER|wxWANTS_CHARS); + m_richTextCtrl = new wxRichTextCtrl(splitter, ID_RICHTEXT_CTRL, wxEmptyString, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxWANTS_CHARS); wxFont font(12, wxROMAN, wxNORMAL, wxNORMAL); m_richTextCtrl->SetFont(font); diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 5953983109..f9ac1a41dd 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -325,6 +325,12 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, style &= ~wxBORDER_MASK; #ifdef __WXGTK__ style |= wxBORDER_SUNKEN; +#elif defined(__WXMSW__) + // Don't set the style explicitly, let GetDefaultBorder() work it out, unless + // we will get a sunken border (e.g. on Windows 200) in which case we must + // override with a simple border. + if (GetDefaultBorder() == wxBORDER_SUNKEN) + style |= wxBORDER_SIMPLE; #else style |= wxBORDER_SIMPLE; #endif diff --git a/src/generic/vlbox.cpp b/src/generic/vlbox.cpp index d9d03f063f..9c9b8d06c8 100644 --- a/src/generic/vlbox.cpp +++ b/src/generic/vlbox.cpp @@ -77,6 +77,11 @@ bool wxVListBox::Create(wxWindow *parent, long style, const wxString& name) { +#ifdef __WXMSW__ + if ((style & wxBORDER_MASK) == wxDEFAULT) + style |= wxBORDER_THEME; +#endif + style |= wxWANTS_CHARS | wxFULL_REPAINT_ON_RESIZE; if ( !wxVScrolledWindow::Create(parent, id, pos, size, style, name) ) return false; diff --git a/src/msw/control.cpp b/src/msw/control.cpp index 99c79bcaa3..2f1ae919e7 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -228,14 +228,7 @@ bool wxControl::MSWCreateControl(const wxChar *classname, wxBorder wxControl::GetDefaultBorder() const { - // we want to automatically give controls a sunken style (confusingly, - // it may not really mean sunken at all as we map it to WS_EX_CLIENTEDGE - // which is not sunken at all under Windows XP -- rather, just the default) -#if defined(__POCKETPC__) || defined(__SMARTPHONE__) - return wxBORDER_SIMPLE; -#else - return wxBORDER_SUNKEN; -#endif + return GetDefaultBorderForControl(); } WXDWORD wxControl::MSWGetStyle(long style, WXDWORD *exstyle) const diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 567a889620..974fa7a30d 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -301,11 +301,6 @@ bool wxTextCtrl::Create(wxWindow *parent, const wxValidator& validator, const wxString& name) { -#ifdef __WXWINCE__ - if ((style & wxBORDER_MASK) == 0) - style |= wxBORDER_SIMPLE; -#endif - // base initialization if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return false; @@ -316,6 +311,17 @@ bool wxTextCtrl::Create(wxWindow *parent, return true; } +// returns true if the platform should explicitly apply a theme border +bool wxTextCtrl::CanApplyThemeBorder() const +{ +#ifdef __WXWINCE__ + return false; +#else + // Standard text control already handles theming + return ((GetWindowStyle() & (wxTE_RICH|wxTE_RICH2)) != 0); +#endif +} + bool wxTextCtrl::MSWCreateText(const wxString& value, const wxPoint& pos, const wxSize& size) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index e3531202d3..e177b1a120 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -121,6 +121,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() @@ -1274,6 +1286,27 @@ void wxWindowMSW::MSWUpdateStyle(long flagsOld, long exflagsOld) } } +wxBorder wxWindowMSW::GetDefaultBorderForControl() const +{ + // we want to automatically give controls a sunken style (confusingly, + // it may not really mean sunken at all as we map it to WS_EX_CLIENTEDGE + // which is not sunken at all under Windows XP -- rather, just the default) + +#if defined(__POCKETPC__) || defined(__SMARTPHONE__) + return wxBORDER_SIMPLE; +#else +#if wxUSE_UXTHEME + if (CanApplyThemeBorder()) + { + wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive(); + if (theme) + return wxBORDER_THEME; + } +#endif + return wxBORDER_SUNKEN; +#endif +} + WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const { // translate common wxWidgets styles to Windows ones @@ -1328,6 +1361,7 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const case wxBORDER_NONE: case wxBORDER_SIMPLE: + case wxBORDER_THEME: break; case wxBORDER_STATIC: @@ -1343,9 +1377,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 @@ -2542,7 +2576,7 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l } } break; - +#if 0 case WM_ENTERSIZEMOVE: { processed = HandleEnterSizeMove(); @@ -2554,7 +2588,7 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l processed = HandleExitSizeMove(); } break; - +#endif case WM_SIZING: { LPRECT pRect = (LPRECT)lParam; @@ -3200,6 +3234,94 @@ 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 + default: // try a custom message handler const MSWMessageHandlers::const_iterator diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index bf06f72f30..b23a95f949 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -129,6 +129,14 @@ wxRichTextCtrl::wxRichTextCtrl(wxWindow* parent, bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { + // Try to make this only necessary in 2.8 +#if 0 +#ifdef __WXMSW__ + if ((style & wxBORDER_MASK) == wxDEFAULT) + style |= wxBORDER_THEME; +#endif +#endif + if (!wxTextCtrlBase::Create(parent, id, pos, size, style|wxFULL_REPAINT_ON_RESIZE, validator, name)) diff --git a/src/richtext/richtextstyles.cpp b/src/richtext/richtextstyles.cpp index 0b8782c756..5fa16bb54e 100644 --- a/src/richtext/richtextstyles.cpp +++ b/src/richtext/richtextstyles.cpp @@ -822,7 +822,7 @@ bool wxRichTextStyleListCtrl::Create(wxWindow* parent, wxWindowID id, const wxPo bool showSelector = ((style & wxRICHTEXTSTYLELIST_HIDE_TYPE_SELECTOR) == 0); - m_styleListBox = new wxRichTextStyleListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, showSelector ? wxSIMPLE_BORDER : wxNO_BORDER); + m_styleListBox = new wxRichTextStyleListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, showSelector ? wxBORDER_DEFAULT : wxBORDER_NONE); wxBoxSizer* boxSizer = new wxBoxSizer(wxVERTICAL); @@ -837,7 +837,7 @@ bool wxRichTextStyleListCtrl::Create(wxWindow* parent, wxWindowID id, const wxPo m_styleChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices); boxSizer->Add(m_styleListBox, 1, wxALL|wxEXPAND, 5); - boxSizer->Add(m_styleChoice, 0, wxALL|wxEXPAND, 5); + boxSizer->Add(m_styleChoice, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 5); } else { @@ -998,6 +998,17 @@ BEGIN_EVENT_TABLE(wxRichTextStyleComboPopup, wxRichTextStyleListBox) EVT_LEFT_DOWN(wxRichTextStyleComboPopup::OnMouseClick) END_EVENT_TABLE() +bool wxRichTextStyleComboPopup::Create( wxWindow* parent ) +{ + int borderStyle = GetDefaultBorder(); + if (borderStyle == wxBORDER_SUNKEN) + borderStyle = wxBORDER_SIMPLE; + + return wxRichTextStyleListBox::Create(parent, wxID_ANY, + wxPoint(0,0), wxDefaultSize, + borderStyle); +} + void wxRichTextStyleComboPopup::SetStringValue( const wxString& s ) { m_value = SetStyleSelection(s); -- 2.45.2