本文整理汇总了C++中TDC::RestoreFont方法的典型用法代码示例。如果您正苦于以下问题:C++ TDC::RestoreFont方法的具体用法?C++ TDC::RestoreFont怎么用?C++ TDC::RestoreFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDC
的用法示例。
在下文中一共展示了TDC::RestoreFont方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//
/// Retrieves information about this font when selected in the specified dc.
//
void
TFont::GetTextMetrics(TEXTMETRIC& tm, TDC& dc) const
{
dc.SelectObject(*this);
dc.GetTextMetrics(tm);
dc.RestoreFont();
}
示例2:
void
TGaugeGadget::Paint(TDC& dc, bool erase, TRect &rect)
{
// Select the approprate font
dc.SelectObject(Window->GetFont());
TGauge::Paint(dc, erase, rect);
dc.RestoreFont();
}
示例3: face
//
/// Paint the text gadget by painting gadget borders, & then painting text in
/// the InnerRect. Empty or 0 text blanks the gadget.
//
/// Calls TGadget::PaintBorder to paint the border. Calls TGadget::GetInnerRect to
/// calculate the area of the text gadget's rectangle. If the text is left-aligned,
/// Paint calls dc.GetTextExtent to compute the width and height of a line of the
/// text. To set the background color, Paint calls dc.GetSysColor and sets the
/// default background color to face shading (COLOR_BTNFACE). To set the button text
/// color, Paint calls dc.SetTextColor and sets the default button text color to
/// COLOR_BTNTEXT. To draw the text, Paint calls dc.ExtTextOut and passes the
/// parameters ETO_CLIPPED (so the text is clipped to fit the rectangle) and
/// ETO_OPAQUE (so the rectangle is filled with the current background color).
//
void
TTextGadget::Paint(TDC& dc)
{
PaintBorder(dc);
TRect innerRect;
GetInnerRect(innerRect);
if (!Font)
dc.SelectObject(GetGadgetWindow()->GetFont());
else
dc.SelectObject(*Font);
TColor textColor = GetEnabledColor();
if(!GetEnabled())
textColor = TColor::Sys3dHilight;
bool transparent = GetGadgetWindow()->GetFlatStyle() & TGadgetWindow::FlatXPTheme;
if(!Text){
if (!transparent)
{
TColor color = dc.SetBkColor(TColor::Sys3dFace);
dc.ExtTextOut(0,0, ETO_OPAQUE, &innerRect, _T(""), 0);
dc.SetBkColor(color);
}
}
else
{
// Create a UI Face object for this button & let it paint the button face
//
uint align[] = {DT_LEFT, DT_CENTER, DT_RIGHT};
uint format = DT_SINGLELINE | DT_VCENTER | align[Align];
TUIFace face(innerRect, Text, BkgndColor, format);
TPoint dstPt(innerRect.TopLeft());
dc.SetBkColor(BkgndColor);
TColor oldTxColor = dc.SetTextColor(textColor);
if (!GetEnabled())
face.Paint(dc, dstPt, TUIFace::Disabled, false, !transparent);
else
face.Paint(dc, dstPt, TUIFace::Normal, false, !transparent);
dc.SetTextColor(oldTxColor);
}
dc.RestoreFont();
}
示例4: if
//
/// Override TWindow virtual member function to paint the control.
//
void
TUrlLink::Paint(TDC& dc, bool /*erase*/, TRect& /*rect*/)
{
TPointer<TFont> tmpFnt; // Object wrapping font handle
TAPointer<tchar> text; // Pointer to caption dynamic buffer
// Select the font
if(!LinkFont){
HFONT hFont = HFONT(::SendMessage(::GetParent(*this), WM_GETFONT, 0, 0));
if (!hFont)
hFont = HFONT(GetStockObject(ANSI_VAR_FONT));
if (hFont)
tmpFnt = new TFont(hFont);
}
if (LinkFont) {
CHECK(LinkFont->IsGDIObject());
dc.SelectObject(*LinkFont);
}
else if (tmpFnt) {
CHECK(((TFont&)tmpFnt).IsGDIObject());
dc.SelectObject((TFont&)tmpFnt);
}
int len = GetWindowTextLength();
text = new tchar[len+1];
GetWindowText(text, len+1);
TRect textRect;
GetClientRect(textRect);
TColor textColor = LinkColor;
if (bOverControl)
textColor = HoverColor;
else if (bVisited)
textColor = VisitedColor;
TColor oldColor = dc.SetTextColor(textColor);
int oldMode = dc.SetBkMode(TRANSPARENT);
dc.DrawText(&text[0], len, textRect, 0);
dc.SetBkMode(oldMode);
dc.SetTextColor(oldColor);
// Restore font
if (LinkFont || tmpFnt)
dc.RestoreFont();
}
示例5: Paint
/////////////////////////////////////////////////////////////////////
// TInfoControl
// ------------
//
void TInfoControl::Paint (TDC& dc, BOOL erase, TRect& rect)
{
TControl::Paint(dc, erase, rect);
TRect cRect = GetClientRect();
// Select font
dc.SelectObject (*StaticFont);
dc.SetBkMode (TRANSPARENT);
// Draw each text line
if ( TextLineTab != NULL )
{
for (int i = 0 ; i < NumLines ; i++)
{
if (TextLineTab[i] != NULL && TextLineTab[i]->Text != NULL)
{
int x;
dc.SetTextColor ( TMapDC::GetColor16(TextLineTab[i]->Color));
dc.SetTextAlign( TextLineTab[i]->Align);
switch (TextLineTab[i]->Align & (TA_CENTER |TA_LEFT |TA_RIGHT))
{
case TA_LEFT:
x = 0;
break;
case TA_CENTER:
x = cRect.Width() / 2;
break;
case TA_RIGHT:
x = cRect.Width() - 1;
break;
}
dc.TextOut( x, FontHeight * i, TextLineTab[i]->Text);
}
}
}
dc.RestoreFont();
}
示例6: if
//
/// Paint Text
//
void
TButtonTextGadget::PaintText(TDC& dc, TRect& rect, const tstring& text)
{
dc.SelectObject(GetFont());
TColor textColor = TColor::SysBtnText;
if(!GetEnabled())
textColor = TColor::Sys3dHilight;
else if((GetGadgetWindow()->GetFlatStyle()&TGadgetWindow::FlatHotText) && IsHaveMouse())
textColor = TColor::LtBlue;
TColor oldTxColor = dc.SetTextColor(textColor);
uint format = DT_SINGLELINE|DT_NOCLIP|DT_END_ELLIPSIS;
switch(Align){
case aLeft:
format |= DT_LEFT;
break;
case aRight:
format |= DT_RIGHT;
break;
case aCenter:
format |= DT_CENTER;
break;
}
switch(LayoutStyle){
case lTextLeft:
case lTextRight:
format |= DT_VCENTER;
break;
case lTextTop:
format |= DT_VCENTER;//DT_BOTTOM;
break;
case lTextBottom:
format |= DT_VCENTER;//DT_TOP;
break;
}
// Create a UI Face object for this button & let it paint the button face
//
TPoint dstPt(rect.TopLeft());
if (GetButtonState() == Down && GetEnabled() &&
GetGadgetWindow()->GetFlatStyle()&TGadgetWindow::FlatStandard)
{
if(IsHaveMouse())
{
if(IsPressed())
{
const int dx = (format & DT_CENTER) ? 2 : 1;
const int dy = (format & DT_VCENTER) ? 2 : 1;
rect.Offset(dx, dy);
}
TUIFace(rect, text, TColor::Sys3dFace,format).Paint(dc, dstPt,
TUIFace::Normal, true, true);
}
else
{
TUIFace face(rect, text, TColor::Sys3dFace,format);
if(GetGadgetWindow()->GadgetGetCaptured()==this)
face.Paint(dc, dstPt, TUIFace::Normal, true);
else
face.Paint(dc, dstPt, TUIFace::Down, IsPressed(), false);
}
}
else
{
TUIFace face(rect, text, TColor::Sys3dFace,format);
if (!GetEnabled())
face.Paint(dc, dstPt, TUIFace::Disabled, false, false);
else if (GetButtonState() == Indeterminate)
face.Paint(dc, dstPt, TUIFace::Indeterm, IsPressed(), false);
else if (GetButtonState() == Down) // Down and not flat
face.Paint(dc, dstPt, TUIFace::Down, IsPressed(), false);
else
face.Paint(dc, dstPt, TUIFace::Normal, IsPressed(), false);
}
dc.SetTextColor(oldTxColor);
dc.RestoreFont();
}
示例7: Paint
//.........这里部分代码省略.........
if (size.cx > xlab_width)
xlab_width = size.cx ;
if (size.cy > xlab_height)
xlab_height = size.cy ;
}
for (i=0 ; i<ynticks ; i++) {
sprintf ( msg , "%*.*lf", yndigits, ynfrac, ymin + i * ydif ) ;
GetTextExtentPoint ( dc , msg , strlen(msg) , &size ) ;
if (size.cx > ylab_width)
ylab_width = size.cx ;
if (size.cy > ylab_height)
ylab_height = size.cy ;
}
tick_height = xlab_height / 2 ;
}
else {
tick_height = rect.bottom / 64 + 2 ;
font = NULL ;
}
/*
Last check on label display. Are X-axis labels to wide?
*/
if ((xlab_width * xnticks) > (3 * rect.right / 4)) {
font_height = 0 ;
xlab_height = xlab_width = ylab_height = ylab_width = 0 ;
xlab_lw = xlab_rw = 0 ;
tick_height = rect.bottom / 64 + 2 ;
if (font != NULL) {
dc.RestoreFont () ;
delete font ;
font = NULL ;
}
}
/*
Compute the graph extent based on these label metrics
*/
rstart = tick_height + xlab_height + 1 ; // Ticks, X tick labels
rstop = rect.bottom - ylab_height/2 - 2 ; // Top half of topmost label
if (xlab_lw / 2 > ylab_width) // If left half of X label biggest
cstart = xlab_lw / 2 + 1 ; // Use it for offset
else
cstart = ylab_width + 2 ; // Otherwise Y labels determine it
cstop = rect.right - xlab_rw / 2 - 2 ; // Leave room for rightmost label
/*
Compute scales for data and ticks
*/
xscale = (double) (cstop - cstart) / (xmax - xmin) ;
xfac = (rightx - leftx) / (n-1) ;
yscale = (double) (rstop - rstart) / (ymax - ymin) ;
xtickscale = (double) (cstop-cstart) / (double) (xnticks-1) ;
ytickscale = (double) (rstop-rstart) / (double) (ynticks-1) ;
/*