check in RDF UTF8 drawing, reviewed by hyatt severl days ago

This commit is contained in:
ftang%netscape.com 1998-09-01 18:50:05 +00:00
parent 0a7a44060e
commit fbf00946c5
3 changed files with 70 additions and 9 deletions

View File

@ -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.

View File

@ -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;
}

View File

@ -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)