зеркало из https://github.com/mozilla/pjs.git
Support new gfx FontMetrics api
This commit is contained in:
Родитель
6c31539133
Коммит
834353a098
|
@ -119,11 +119,7 @@ nsresult nsCalCommandCanvas :: Init()
|
||||||
|
|
||||||
fm->GetWidth(text,width);
|
fm->GetWidth(text,width);
|
||||||
|
|
||||||
float f;
|
rect.width = width ;
|
||||||
|
|
||||||
GetWidget()->GetDeviceContext()->GetTwipsToDevUnits(f);
|
|
||||||
|
|
||||||
rect.width = width * f;
|
|
||||||
|
|
||||||
mStaticTextField->SetReadOnly(PR_TRUE);
|
mStaticTextField->SetReadOnly(PR_TRUE);
|
||||||
|
|
||||||
|
@ -206,13 +202,10 @@ nsresult nsCalCommandCanvas :: SetBounds(const nsRect &aBounds)
|
||||||
nsXPFCCanvas::SetBounds(aBounds);
|
nsXPFCCanvas::SetBounds(aBounds);
|
||||||
nsRect rect = aBounds;
|
nsRect rect = aBounds;
|
||||||
nscoord width = 0;
|
nscoord width = 0;
|
||||||
float f = 0.0;
|
|
||||||
|
|
||||||
|
|
||||||
if (mStaticTextField) {
|
if (mStaticTextField) {
|
||||||
|
|
||||||
mStaticTextField->GetDeviceContext()->GetTwipsToDevUnits(f);
|
|
||||||
|
|
||||||
nsString text("COMMAND: ");
|
nsString text("COMMAND: ");
|
||||||
|
|
||||||
nsFont font("Times", NS_FONT_STYLE_NORMAL,
|
nsFont font("Times", NS_FONT_STYLE_NORMAL,
|
||||||
|
@ -227,7 +220,7 @@ nsresult nsCalCommandCanvas :: SetBounds(const nsRect &aBounds)
|
||||||
|
|
||||||
fm->GetWidth(text,width);
|
fm->GetWidth(text,width);
|
||||||
|
|
||||||
rect.width = width * f;
|
rect.width = width ;
|
||||||
|
|
||||||
mStaticTextField->Invalidate(PR_FALSE);
|
mStaticTextField->Invalidate(PR_FALSE);
|
||||||
|
|
||||||
|
@ -240,8 +233,8 @@ nsresult nsCalCommandCanvas :: SetBounds(const nsRect &aBounds)
|
||||||
|
|
||||||
rect = aBounds;
|
rect = aBounds;
|
||||||
|
|
||||||
rect.x += (width*f);
|
rect.x += (width);
|
||||||
rect.width -= (width*f);
|
rect.width -= (width);
|
||||||
|
|
||||||
mTextField->Invalidate(PR_FALSE);
|
mTextField->Invalidate(PR_FALSE);
|
||||||
|
|
||||||
|
|
|
@ -289,19 +289,6 @@ nsEventStatus nsCalDayViewCanvas :: PaintForeground(nsIRenderingContext& aRender
|
||||||
|
|
||||||
aRenderingContext.GetFontMetrics()->GetHeight(fm_height);
|
aRenderingContext.GetFontMetrics()->GetHeight(fm_height);
|
||||||
|
|
||||||
nsIDeviceContext * dc ;
|
|
||||||
|
|
||||||
float f = 0.0;
|
|
||||||
|
|
||||||
dc = aRenderingContext.GetDeviceContext();
|
|
||||||
|
|
||||||
dc->GetTwipsToDevUnits(f);
|
|
||||||
|
|
||||||
fm_height *= f;
|
|
||||||
|
|
||||||
NS_RELEASE(dc);
|
|
||||||
|
|
||||||
|
|
||||||
if (rect.height > fm_height)
|
if (rect.height > fm_height)
|
||||||
{
|
{
|
||||||
// rndctx->SetColor(GetForegroundColor());
|
// rndctx->SetColor(GetForegroundColor());
|
||||||
|
|
|
@ -96,19 +96,6 @@ nsEventStatus nsCalTimebarTimeHeading :: PaintForeground(nsIRenderingContext& aR
|
||||||
aRenderingContext.GetFontMetrics()->GetHeight(height);
|
aRenderingContext.GetFontMetrics()->GetHeight(height);
|
||||||
aRenderingContext.GetFontMetrics()->GetWidth(*string,width);
|
aRenderingContext.GetFontMetrics()->GetWidth(*string,width);
|
||||||
|
|
||||||
nsIDeviceContext * dc ;
|
|
||||||
|
|
||||||
float f = 0.0;
|
|
||||||
|
|
||||||
dc = aRenderingContext.GetDeviceContext();
|
|
||||||
|
|
||||||
dc->GetTwipsToDevUnits(f);
|
|
||||||
|
|
||||||
NS_RELEASE(dc);
|
|
||||||
|
|
||||||
height *= f;
|
|
||||||
width *= f;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX: If we are too big, remove the Day of the week. Need a better algorithm
|
* XXX: If we are too big, remove the Day of the week. Need a better algorithm
|
||||||
* to use string who fits to begin with
|
* to use string who fits to begin with
|
||||||
|
@ -119,7 +106,6 @@ nsEventStatus nsCalTimebarTimeHeading :: PaintForeground(nsIRenderingContext& aR
|
||||||
pattern = "MMM dd\n";
|
pattern = "MMM dd\n";
|
||||||
GetTimeContext()->GetDTFirstVisible()->strftime(pattern, &string);
|
GetTimeContext()->GetDTFirstVisible()->strftime(pattern, &string);
|
||||||
aRenderingContext.GetFontMetrics()->GetWidth(*string,width);
|
aRenderingContext.GetFontMetrics()->GetWidth(*string,width);
|
||||||
width *= f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -91,19 +91,6 @@ nsEventStatus nsCalTimebarUserHeading :: PaintForeground(nsIRenderingContext& aR
|
||||||
aRenderingContext.GetFontMetrics()->GetHeight(height);
|
aRenderingContext.GetFontMetrics()->GetHeight(height);
|
||||||
aRenderingContext.GetFontMetrics()->GetWidth(mUserName,width);
|
aRenderingContext.GetFontMetrics()->GetWidth(mUserName,width);
|
||||||
|
|
||||||
nsIDeviceContext * dc ;
|
|
||||||
|
|
||||||
float f = 0.0;
|
|
||||||
|
|
||||||
dc = aRenderingContext.GetDeviceContext();
|
|
||||||
|
|
||||||
dc->GetTwipsToDevUnits(f);
|
|
||||||
|
|
||||||
NS_RELEASE(dc);
|
|
||||||
|
|
||||||
height *= f;
|
|
||||||
width *= f;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* center the text in our rect and draw it
|
* center the text in our rect and draw it
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -319,16 +319,6 @@ void nsCalMonthContextController::PaintMiniCalElement(
|
||||||
|
|
||||||
mRenderingContext->GetFontMetrics()->GetLeading(leading);
|
mRenderingContext->GetFontMetrics()->GetLeading(leading);
|
||||||
|
|
||||||
nsIDeviceContext * dc ;
|
|
||||||
|
|
||||||
float f = 0.0;
|
|
||||||
|
|
||||||
dc = mRenderingContext->GetDeviceContext();
|
|
||||||
|
|
||||||
dc->GetTwipsToDevUnits(f);
|
|
||||||
|
|
||||||
NS_RELEASE(dc);
|
|
||||||
|
|
||||||
iY = iYTop + leading;
|
iY = iYTop + leading;
|
||||||
|
|
||||||
mRenderingContext->DrawString(s, nsCRT::strlen(s), iX, iY, 100);
|
mRenderingContext->DrawString(s, nsCRT::strlen(s), iX, iY, 100);
|
||||||
|
@ -1688,17 +1678,6 @@ void nsCalMonthContextController::GetTextExtent(char *p, int iChars, int& iWidth
|
||||||
fm->GetWidth(p,(nscoord)iWidth);
|
fm->GetWidth(p,(nscoord)iWidth);
|
||||||
fm->GetHeight((nscoord)iHeight);
|
fm->GetHeight((nscoord)iHeight);
|
||||||
|
|
||||||
nsIDeviceContext * dc ;
|
|
||||||
|
|
||||||
float f = 0.0;
|
|
||||||
|
|
||||||
dc = mRenderingContext->GetDeviceContext();
|
|
||||||
|
|
||||||
dc->GetTwipsToDevUnits(f);
|
|
||||||
|
|
||||||
NS_RELEASE(dc);
|
|
||||||
|
|
||||||
iWidth *= f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1755,18 +1734,6 @@ void nsCalMonthContextController::GetFontInfo(
|
||||||
fm->GetWidth("0",m_iDigitWidth);
|
fm->GetWidth("0",m_iDigitWidth);
|
||||||
fm->GetHeight(m_iDigitHeight);
|
fm->GetHeight(m_iDigitHeight);
|
||||||
|
|
||||||
nsIDeviceContext * dc ;
|
|
||||||
|
|
||||||
float f = 0.0;
|
|
||||||
|
|
||||||
dc = mRenderingContext->GetDeviceContext();
|
|
||||||
|
|
||||||
dc->GetTwipsToDevUnits(f);
|
|
||||||
|
|
||||||
NS_RELEASE(dc);
|
|
||||||
|
|
||||||
m_iDigitWidth *= f;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The next few lines need to be replaced with some code that gets the
|
* The next few lines need to be replaced with some code that gets the
|
||||||
* strings for every day of the week and computes the max width...
|
* strings for every day of the week and computes the max width...
|
||||||
|
@ -1777,8 +1744,6 @@ void nsCalMonthContextController::GetFontInfo(
|
||||||
|
|
||||||
fm->GetWidth(sBuf,m_iMaxDOWColHdrWidth);
|
fm->GetWidth(sBuf,m_iMaxDOWColHdrWidth);
|
||||||
|
|
||||||
m_iMaxDOWColHdrWidth *= f;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Загрузка…
Ссылка в новой задаче