From: Ryan Norton Date: Sun, 7 Nov 2004 13:01:59 +0000 (+0000) Subject: fix for [ 1055191 ] wxTextCtrl::GetStyle() wrong attr and extended stat bar in text... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/093dee5e9d6574cf2c4e4c6764b7a40573ae4a4d?hp=7012506a8397dc9afb7e7c00376b3da035c3b70a fix for [ 1055191 ] wxTextCtrl::GetStyle() wrong attr and extended stat bar in text ctrl sample with rich text to show font attributes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30341 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/text/text.cpp b/samples/text/text.cpp index 2b6f3701e4..c5f32c8d0e 100644 --- a/samples/text/text.cpp +++ b/samples/text/text.cpp @@ -1696,6 +1696,21 @@ void RichTextFrame::OnIdle(wxIdleEvent& WXUNUSED(event)) (const wxChar*) facename, attr.GetTextColour().Red(), attr.GetTextColour().Green(), attr.GetTextColour().Blue(), (const wxChar*) alignment); + + if (attr.HasFont()) + { + if (attr.GetFont().GetWeight() == wxBOLD) + msg += wxT(" BOLD"); + else if (attr.GetFont().GetWeight() == wxNORMAL) + msg += wxT(" NORMAL"); + + if (attr.GetFont().GetStyle() == wxITALIC) + msg += wxT(" ITALIC"); + + if (attr.GetFont().GetUnderlined()) + msg += wxT(" UNDERLINED"); + } + SetStatusText(msg); } #endif // wxUSE_STATUSBAR diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 36b2359fbe..25aecb4bdf 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -2496,6 +2496,7 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style) (void) ::SendMessage(GetHwnd(), EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf) ; + LOGFONT lf; lf.lfHeight = cf.yHeight; lf.lfWidth = 0; @@ -2503,17 +2504,32 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style) lf.lfClipPrecision = 0; lf.lfEscapement = 0; wxStrcpy(lf.lfFaceName, cf.szFaceName); + + //NOTE: we _MUST_ set each of these values to _something_ since we + //do not call wxZeroMemory on the LOGFONT lf if (cf.dwEffects & CFE_ITALIC) lf.lfItalic = TRUE; + else + lf.lfItalic = FALSE; + lf.lfOrientation = 0; lf.lfPitchAndFamily = cf.bPitchAndFamily; lf.lfQuality = 0; + if (cf.dwEffects & CFE_STRIKEOUT) lf.lfStrikeOut = TRUE; + else + lf.lfStrikeOut = FALSE; + if (cf.dwEffects & CFE_UNDERLINE) lf.lfUnderline = TRUE; + else + lf.lfUnderline = FALSE; + if (cf.dwEffects & CFE_BOLD) lf.lfWeight = FW_BOLD; + else + lf.lfWeight = FW_NORMAL; wxFont font = wxCreateFontFromLogFont(& lf); if (font.Ok())