summaryrefslogtreecommitdiff
path: root/libs/mTextControl/src
diff options
context:
space:
mode:
Diffstat (limited to 'libs/mTextControl/src')
-rw-r--r--libs/mTextControl/src/FormattedTextDraw.cpp76
-rw-r--r--libs/mTextControl/src/FormattedTextDraw.h14
-rw-r--r--libs/mTextControl/src/services.cpp26
3 files changed, 58 insertions, 58 deletions
diff --git a/libs/mTextControl/src/FormattedTextDraw.cpp b/libs/mTextControl/src/FormattedTextDraw.cpp
index e89ab6ad1d..e093048160 100644
--- a/libs/mTextControl/src/FormattedTextDraw.cpp
+++ b/libs/mTextControl/src/FormattedTextDraw.cpp
@@ -156,6 +156,8 @@ HRESULT CFormattedTextDraw::putRTFText(char *newVal)
if (!m_spTextServices)
return S_FALSE;
+ m_bNative = true;
+
STREAMDATATEXT streamData = {};
streamData.isUnicode = false;
streamData.ansi = newVal;
@@ -176,23 +178,25 @@ HRESULT CFormattedTextDraw::putRTFText(char *newVal)
HRESULT CFormattedTextDraw::Draw(HDC hdcDraw, RECT *prc)
{
- LOGFONT lf;
- GetObject(GetCurrentObject(hdcDraw, OBJ_FONT), sizeof(lf), &lf);
-
- LRESULT lResult;
- CHARFORMAT cf;
- cf.cbSize = sizeof(cf);
- cf.dwMask = CFM_FACE/*|CFM_COLOR*/ | CFM_CHARSET | CFM_SIZE |
- (lf.lfWeight >= FW_BOLD ? CFM_BOLD : 0) |
- (lf.lfItalic ? CFM_ITALIC : 0) |
- (lf.lfUnderline ? CFM_UNDERLINE : 0) |
- (lf.lfStrikeOut ? CFM_STRIKEOUT : 0);
- cf.dwEffects = CFE_BOLD | CFE_ITALIC | CFE_STRIKEOUT | CFE_UNDERLINE;
- cf.crTextColor = GetTextColor(hdcDraw);
- cf.bCharSet = lf.lfCharSet;
- cf.yHeight = 1440 * abs(lf.lfHeight) / GetDeviceCaps(hdcDraw, LOGPIXELSY);
- wcsncpy_s(cf.szFaceName, lf.lfFaceName, _TRUNCATE);
- m_spTextServices->TxSendMessage(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf, &lResult);
+ if (!m_bNative) {
+ LOGFONT lf;
+ GetObject(GetCurrentObject(hdcDraw, OBJ_FONT), sizeof(lf), &lf);
+
+ LRESULT lResult;
+ CHARFORMAT cf;
+ cf.cbSize = sizeof(cf);
+ cf.dwMask = CFM_FACE/*|CFM_COLOR*/ | CFM_CHARSET | CFM_SIZE |
+ (lf.lfWeight >= FW_BOLD ? CFM_BOLD : 0) |
+ (lf.lfItalic ? CFM_ITALIC : 0) |
+ (lf.lfUnderline ? CFM_UNDERLINE : 0) |
+ (lf.lfStrikeOut ? CFM_STRIKEOUT : 0);
+ cf.dwEffects = CFE_BOLD | CFE_ITALIC | CFE_STRIKEOUT | CFE_UNDERLINE;
+ cf.crTextColor = GetTextColor(hdcDraw);
+ cf.bCharSet = lf.lfCharSet;
+ cf.yHeight = 1440 * abs(lf.lfHeight) / GetDeviceCaps(hdcDraw, LOGPIXELSY);
+ wcsncpy_s(cf.szFaceName, lf.lfFaceName, _TRUNCATE);
+ m_spTextServices->TxSendMessage(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf, &lResult);
+ }
m_spTextServices->TxDraw(
DVASPECT_CONTENT, // Draw Aspect
@@ -220,27 +224,29 @@ HRESULT CFormattedTextDraw::get_NaturalSize(HDC hdcDraw, long *Width, long *Heig
if (iCaps == 0)
return S_FALSE;
- LOGFONT lf;
- GetObject(GetCurrentObject(hdcDraw, OBJ_FONT), sizeof(lf), &lf);
-
- LRESULT lResult;
- CHARFORMAT cf;
- cf.cbSize = sizeof(cf);
- cf.dwMask = CFM_FACE/*|CFM_COLOR*/ | CFM_CHARSET | CFM_SIZE |
- (lf.lfWeight >= FW_BOLD ? CFM_BOLD : 0) |
- (lf.lfItalic ? CFM_ITALIC : 0) |
- (lf.lfUnderline ? CFM_UNDERLINE : 0) |
- (lf.lfStrikeOut ? CFM_STRIKEOUT : 0);
- cf.dwEffects = CFE_BOLD | CFE_ITALIC | CFE_STRIKEOUT | CFE_UNDERLINE;
- cf.crTextColor = GetTextColor(hdcDraw);
- cf.bCharSet = lf.lfCharSet;
- cf.yHeight = 1440 * abs(lf.lfHeight) / iCaps;
- wcsncpy_s(cf.szFaceName, lf.lfFaceName, _TRUNCATE);
-
if (!m_spTextServices)
return S_FALSE;
- m_spTextServices->TxSendMessage(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf, &lResult);
+ if (!m_bNative) {
+ LOGFONT lf;
+ GetObject(GetCurrentObject(hdcDraw, OBJ_FONT), sizeof(lf), &lf);
+
+ LRESULT lResult;
+ CHARFORMAT cf;
+ cf.cbSize = sizeof(cf);
+ cf.dwMask = CFM_FACE/*|CFM_COLOR*/ | CFM_CHARSET | CFM_SIZE |
+ (lf.lfWeight >= FW_BOLD ? CFM_BOLD : 0) |
+ (lf.lfItalic ? CFM_ITALIC : 0) |
+ (lf.lfUnderline ? CFM_UNDERLINE : 0) |
+ (lf.lfStrikeOut ? CFM_STRIKEOUT : 0);
+ cf.dwEffects = CFE_BOLD | CFE_ITALIC | CFE_STRIKEOUT | CFE_UNDERLINE;
+ cf.crTextColor = GetTextColor(hdcDraw);
+ cf.bCharSet = lf.lfCharSet;
+ cf.yHeight = 1440 * abs(lf.lfHeight) / iCaps;
+ wcsncpy_s(cf.szFaceName, lf.lfFaceName, _TRUNCATE);
+
+ m_spTextServices->TxSendMessage(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf, &lResult);
+ }
*Height = 1;
diff --git a/libs/mTextControl/src/FormattedTextDraw.h b/libs/mTextControl/src/FormattedTextDraw.h
index f9ff25f2b6..edfcac0d2f 100644
--- a/libs/mTextControl/src/FormattedTextDraw.h
+++ b/libs/mTextControl/src/FormattedTextDraw.h
@@ -17,17 +17,18 @@
class CFormattedTextDraw : public ITextHost, public MZeroedObject
{
HWND m_hwndParent;
- RECT m_rcClient; // Client Rect
- RECT m_rcViewInset; // view rect inset
- SIZEL m_sizelExtent; // Extent array
+ RECT m_rcClient; // Client Rect
+ RECT m_rcViewInset; // view rect inset
+ SIZEL m_sizelExtent; // Extent array
- int nPixelsPerInchX; // Pixels per logical inch along width
- int nPixelsPerInchY; // Pixels per logical inch along height
+ int nPixelsPerInchX; // Pixels per logical inch along width
+ int nPixelsPerInchY; // Pixels per logical inch along height
CHARFORMAT2W m_CF;
PARAFORMAT2 m_PF;
- uint32_t m_dwPropertyBits; // Property bits
+ uint32_t m_dwPropertyBits; // Property bits
+ bool m_bNative = false; // Doesn't generate RTF itself, uses external plain RTF
ITextServices *m_spTextServices;
ITextDocument *m_spTextDocument;
@@ -45,6 +46,7 @@ public:
__forceinline ITextServices *getTextService() { return m_spTextServices; };
__forceinline ITextDocument *getTextDocument() { return m_spTextDocument; };
+ __forceinline bool isNative() const { return m_bNative; }
__forceinline void setParentWnd(HWND hwnd, RECT rect) { m_hwndParent = hwnd; m_rcClient = rect; }
// IUnknown
diff --git a/libs/mTextControl/src/services.cpp b/libs/mTextControl/src/services.cpp
index 1575b716dd..8c6e06d165 100644
--- a/libs/mTextControl/src/services.cpp
+++ b/libs/mTextControl/src/services.cpp
@@ -85,16 +85,6 @@ MTEXTCONTROL_DLL(TextObject *) MTextCreateW(HANDLE userHandle, const char *szPro
MText_InitFormatting0(result->ftd, result->options);
result->ftd->putTextW((wchar_t *)text);
MText_InitFormatting1(result);
-
- /*
- LRESULT res;
- CMStringA buf;
- EDITSTREAM es = { 0 };
- es.dwCookie = (DWORD_PTR)&buf;
- es.pfnCallback = &EditStreamOutCallback;
- result->ftd->getTextService()->TxSendMessage(EM_STREAMOUT, SF_RTF, (LPARAM)&es, &res);
-
- Netlib_Logf(0, "Rtf created: %s", buf.c_str());*/
return result;
}
@@ -145,14 +135,16 @@ MTEXTCONTROL_DLL(int) MTextDisplay(HDC dc, POINT pos, SIZE sz, TextObject *text)
if (!text || !dc)
return 0;
- COLORREF cl = GetTextColor(dc);
+ if (!text->ftd->isNative()) {
+ COLORREF cl = GetTextColor(dc);
- LRESULT lResult;
- CHARFORMAT cf = { 0 };
- cf.cbSize = sizeof(cf);
- cf.dwMask = CFM_COLOR;
- cf.crTextColor = cl;
- text->ftd->getTextService()->TxSendMessage(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf, &lResult);
+ LRESULT lResult;
+ CHARFORMAT cf = { 0 };
+ cf.cbSize = sizeof(cf);
+ cf.dwMask = CFM_COLOR;
+ cf.crTextColor = cl;
+ text->ftd->getTextService()->TxSendMessage(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf, &lResult);
+ }
SetBkMode(dc, TRANSPARENT);