From d40148503c5e6f936d6199c035e2cf1ecfaee063 Mon Sep 17 00:00:00 2001 From: "ftang%netscape.com" Date: Tue, 1 Sep 1998 18:50:05 +0000 Subject: [PATCH] check in RDF UTF8 drawing, reviewed by hyatt severl days ago git-svn-id: svn://10.0.0.236/trunk@8984 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/cmd/winfe/navbar.cpp | 16 +++++----- mozilla/cmd/winfe/usertlbr.cpp | 58 +++++++++++++++++++++++++++++++++- mozilla/cmd/winfe/usertlbr.h | 5 +++ 3 files changed, 70 insertions(+), 9 deletions(-) diff --git a/mozilla/cmd/winfe/navbar.cpp b/mozilla/cmd/winfe/navbar.cpp index 4a41cd5d38c..79f50950c4a 100644 --- a/mozilla/cmd/winfe/navbar.cpp +++ b/mozilla/cmd/winfe/navbar.cpp @@ -186,7 +186,7 @@ void CNavTitleBar::OnPaint( ) HFONT hOldFont = (HFONT)::SelectObject(dc.m_hDC, font); CRect sizeRect(titleBarRect); - int height = ::DrawText(dc.m_hDC, titleText, titleText.GetLength(), &sizeRect, DT_CALCRECT | DT_WORDBREAK); + int height = CIntlWin::DrawText(CS_UTF8, dc.m_hDC, titleText.GetBuffer(0), titleText.GetLength(), &sizeRect, DT_CALCRECT | DT_WORDBREAK); if (sizeRect.Width() > rect.Width() - 9) { @@ -207,7 +207,7 @@ void CNavTitleBar::OnPaint( ) COLORREF oldColor; oldColor = dc.SetTextColor(m_ForegroundColor); - dc.DrawText((LPCSTR)titleText, -1, &sizeRect, nFormat); + CIntlWin::DrawText(CS_UTF8, dc.m_hDC, titleText.GetBuffer(0), -1, &sizeRect, nFormat); // Draw the control strip text. CFont smallArialFont; @@ -227,7 +227,7 @@ void CNavTitleBar::OnPaint( ) // modeText = (char*)data; CRect addRect(controlStripRect); - int smallHeight = ::DrawText(dc.m_hDC, addText, addText.GetLength(), &addRect, DT_CALCRECT | DT_WORDBREAK); + int smallHeight = CIntlWin::DrawText(CS_UTF8, dc.m_hDC, addText.GetBuffer(0), addText.GetLength(), &addRect, DT_CALCRECT | DT_WORDBREAK); if (addRect.Width() > rect.Width() - 9) { @@ -254,7 +254,7 @@ void CNavTitleBar::OnPaint( ) // modeText = (char*)data; CRect modeRect(controlStripRect); - smallHeight = ::DrawText(dc.m_hDC, modeText, modeText.GetLength(), &modeRect, DT_CALCRECT | DT_WORDBREAK); + smallHeight = CIntlWin::DrawText(CS_UTF8,dc.m_hDC, modeText.GetBuffer(0), modeText.GetLength(), &modeRect, DT_CALCRECT | DT_WORDBREAK); if (modeRect.Width() > rect.Width() - 9) { @@ -282,7 +282,7 @@ void CNavTitleBar::OnPaint( ) closeText = (char*)data; CRect closeRect(controlStripRect); - ::DrawText(dc.m_hDC, closeText, closeText.GetLength(), &closeRect, DT_CALCRECT | DT_WORDBREAK); + CIntlWin::DrawText(CS_UTF8, dc.m_hDC, closeText.GetBuffer(0), closeText.GetLength(), &closeRect, DT_CALCRECT | DT_WORDBREAK); int closeWidth = closeRect.Width(); @@ -309,9 +309,9 @@ void CNavTitleBar::OnPaint( ) // Draw the text dc.SetTextColor(m_ControlStripForegroundColor); - dc.DrawText((LPCSTR)closeText, -1, &closeRect, nFormat); - dc.DrawText((LPCSTR)modeText, -1, &modeRect, nFormat); - dc.DrawText((LPCSTR)addText, -1, &addRect, nFormat); + CIntlWin::DrawText(CS_UTF8, dc.m_hDC, closeText.GetBuffer(0), -1, &closeRect, nFormat); + CIntlWin::DrawText(CS_UTF8, dc.m_hDC, modeText.GetBuffer(0), -1, &modeRect, nFormat); + CIntlWin::DrawText(CS_UTF8, dc.m_hDC, addText.GetBuffer(0), -1, &addRect, nFormat); // See if we're supposed to draw a framing rect. diff --git a/mozilla/cmd/winfe/usertlbr.cpp b/mozilla/cmd/winfe/usertlbr.cpp index dc61cd1a597..4f4c837a9a1 100644 --- a/mozilla/cmd/winfe/usertlbr.cpp +++ b/mozilla/cmd/winfe/usertlbr.cpp @@ -24,6 +24,8 @@ #include "xp_ncent.h" #include "rdfliner.h" #include "urlbar.h" +#include "intlwin.h" +#include "libi18n.h" extern "C" { #include "xpgetstr.h" @@ -150,10 +152,44 @@ int CRDFToolbarButton::Create(CWnd *pParent, int nToolbarStyle, CSize noviceButt { m_bookmark = bookmark; + int16 localecsid = CIntlWin::GetSystemLocaleCsid(); + + // Ad Hoc I18N Fix + // Untill we draw the status bar by ourself + // The pStatusText come in CRDFToolbarButton is always UTF8 + // The pStatusText pass to CToolbarButton is the locale csid + LPSTR pLocaleStatusText = (LPSTR) + INTL_ConvertLineWithoutAutoDetect( + CS_UTF8, + localecsid, + (unsigned char*)pStatusText, + XP_STRLEN(pStatusText) + ); + + // Ad Hoc I18N Fix + // Untill we bring back the real implementation of + // tooltip.cpp + // The pToolTipText come in CRDFToolbarButton is always UTF8 + // The pToolTipText pass to CToolbarButton is the locale csid + LPSTR pLocaleToolTipText = (LPSTR) + INTL_ConvertLineWithoutAutoDetect( + CS_UTF8, + localecsid, + (unsigned char*)pToolTipText, + XP_STRLEN(pToolTipText) + ); + + // For pButtonText, + // We do not convert it to the limited locale csid because we can + // Draw the text by ourself to overcome the OS limitation. + BOOL bResult = CToolbarButton::Create(pParent, nToolbarStyle, noviceButtonSize, advancedButtonSize, - pButtonText, pToolTipText, pStatusText, 0, 0, + pButtonText, pLocaleToolTipText, pLocaleStatusText, 0, 0, bitmapSize, TRUE, 0, nMaxTextChars, nMinTextChars, dwButtonStyle); + XP_FREEIF(pLocaleStatusText); + XP_FREEIF(pLocaleToolTipText); + if(bResult) { SetNode(pNode); @@ -1141,6 +1177,25 @@ void CRDFToolbarButton::DrawButtonBitmap(HDC hDC, CRect rcImg) } } + HFONT CRDFToolbarButton::GetFont(HDC hDC) + { + return CToolbarButton::GetFont(hDC); + } + + int CRDFToolbarButton::DrawText(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT uFormat) + { + // XP_ASSERT(IsUTF8Text(lpString, nCount)); + // In RDF, everything is UTF8 + return CIntlWin::DrawText(CS_UTF8, hDC, (char*)lpString, nCount, lpRect, uFormat ); + } + +BOOL CRDFToolbarButton::GetTextExtentPoint32(HDC hDC, LPCSTR lpString, int nCount, LPSIZE lpSize) + { + // XP_ASSERT(IsUTF8Text(lpString, nCount)); + // In RDF, everything is UTF8 + return CIntlWin::GetTextExtentPoint(CS_UTF8, hDC, (char*)lpString, nCount, lpSize); + } + /////////////////////////////////////////////////////////////////////////// // Class CRDFSeparatorButton /////////////////////////////////////////////////////////////////////////// @@ -1487,6 +1542,7 @@ int CRDFToolbar::Create(CWnd *pParent) } SetButtonsSameWidth(fixedSize); + return result; } diff --git a/mozilla/cmd/winfe/usertlbr.h b/mozilla/cmd/winfe/usertlbr.h index b666adaf57d..758396b1dc9 100644 --- a/mozilla/cmd/winfe/usertlbr.h +++ b/mozilla/cmd/winfe/usertlbr.h @@ -130,6 +130,11 @@ protected: virtual void GetPicturesModeTextRect(CRect &rect); virtual void DrawButtonText(HDC hDC, CRect rcTxt, CSize sizeTxt, CString strTxt); + + virtual HFONT GetFont(HDC hDC); + virtual int DrawText(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT uFormat); + virtual BOOL GetTextExtentPoint32(HDC hDC, LPCSTR lpString, int nCount, LPSIZE lpSize); + protected: // Generated message map functions //{{AFX_MSG(CRDFToolbarButton)