From be329a3de37ac678871cfcce9291b15c4f27d5a2 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 1 Jun 2001 19:26:57 +0000 Subject: [PATCH] Allowed MSW wxTrextCtrl styling to also set the background colour, added wxUSE_RICHEDIT2 so this can be disabled for compilers that don't have the right structures. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10407 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/setup0.h | 10 ++++++++-- src/msw/textctrl.cpp | 18 +++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h index 68530812af..716e3ede3d 100644 --- a/include/wx/msw/setup0.h +++ b/include/wx/msw/setup0.h @@ -682,9 +682,15 @@ // Recommended setting: 1, only set it to 0 if your compiler doesn't have // or can't compile #if defined(__WIN95__) && !defined(__TWIN32__) && !defined(__GNUWIN32_OLD__) -#define wxUSE_RICHEDIT 1 +#define wxUSE_RICHEDIT 1 + +// TODO: This should be ifdef'ed for any compilers that don't support +// RichEdit 2.0 but do have RichEdit 1.0... +#define wxUSE_RICHEDIT2 1 + #else -#define wxUSE_RICHEDIT 0 +#define wxUSE_RICHEDIT 0 +#define wxUSE_RICHEDIT2 0 #endif // Set this to 1 to enable support for the owner-drawn menu and listboxes. This diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index eb624126c2..62850ac1d1 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -1233,10 +1233,11 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) // the rich text control doesn't handle setting background colour, so don't // even try if it's the only thing we want to change - if ( !style.HasFont() && !style.HasTextColour() ) + if ( wxRichEditModule::GetLoadedVersion() < 2 && + !style.HasFont() && !style.HasTextColour() ) { - // nothing to do: return TRUE if there was really nothing to doand - // FALSE fi we failed to set bg colour + // nothing to do: return TRUE if there was really nothing to do and + // FALSE if we failed to set bg colour return !style.HasBackgroundColour(); } @@ -1260,7 +1261,11 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) SendMessage(GetHwnd(), EM_SETSEL, (WPARAM) start, (LPARAM) end); // initialize CHARFORMAT struct +#if wxUSE_RICHEDIT2 + CHARFORMAT2 cf; +#else CHARFORMAT cf; +#endif wxZeroMemory(cf); cf.cbSize = sizeof(cf); @@ -1307,6 +1312,13 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) cf.crTextColor = wxColourToRGB(style.GetTextColour()); } +#if wxUSE_RICHEDIT2 + if ( wxRichEditModule::GetLoadedVersion() > 1 && style.HasBackgroundColour() ) + { + cf.dwMask |= CFM_BACKCOLOR; + cf.crBackColor = wxColourToRGB(style.GetBackgroundColour()); + } +#endif // do format the selection bool ok = ::SendMessage(GetHwnd(), EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf) != 0; -- 2.45.2