本文整理汇总了C++中TDC::SelectObject方法的典型用法代码示例。如果您正苦于以下问题:C++ TDC::SelectObject方法的具体用法?C++ TDC::SelectObject怎么用?C++ TDC::SelectObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDC
的用法示例。
在下文中一共展示了TDC::SelectObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawDisabledButton
void DrawDisabledButton(TDC& dc, const TRect& rc)
{
// create a monochrome memory DC
//
TMemoryDC ddc;
TBitmap bmp(ddc, rc.Width(), rc.Height());
ddc.SelectObject(bmp);
// build a mask
//
ddc.PatBlt(0, 0, rc.Width(), rc.Height(), WHITENESS);
dc.SetBkColor(TColor::Sys3dFace);
ddc.BitBlt(0, 0, rc.Width(), rc.Height(), dc, rc.left, rc.top, SRCCOPY);
dc.SetBkColor(TColor::Sys3dHilight);
ddc.BitBlt(0, 0, rc.Width(), rc.Height(), dc, rc.left, rc.top, SRCPAINT);
// Copy the image from the toolbar into the memory DC
// and draw it (grayed) back into the toolbar.
//
dc.FillRect(rc, TBrush(TColor::Sys3dFace));
dc.SetBkColor(RGB(0, 0, 0));
dc.SetTextColor(RGB(255, 255, 255));
TBrush brShadow(TColor::Sys3dShadow);
TBrush brHilight(TColor::Sys3dHilight);
dc.SelectObject(brHilight);
dc.BitBlt(rc.left+1, rc.top+1, rc.Width(), rc.Height(), ddc, 0, 0, 0x00E20746L);
dc.SelectObject(brShadow);
dc.BitBlt(rc.left, rc.top, rc.Width(), rc.Height(), ddc, 0, 0, 0x00E20746L);
// reset DCs
//
dc.RestoreBrush();
dc.RestoreBrush();
ddc.RestoreBitmap();
}
示例2: brsh
//
/// Paints a 2-color single pixel-thick frame. Bevel corners get their own color.
//
void
TUIBorder::PaintFrameC(TDC& dc, const TRect& fr, uint flags, const TColor& tlColor, const TColor& brColor, const TColor& bcColor)
{
if (flags & (Top | Left)) {
TBrush brsh(tlColor);
dc.SelectObject(brsh);
if (flags & Top) {
dc.PatBlt(fr.left, fr.top, fr.Width()-2, 1);
dc.SetPixel(fr.right-1, fr.top, bcColor);
}
if (flags & Left)
dc.PatBlt(fr.left, fr.top+1, 1, fr.Height()-2);
dc.RestoreBrush();
}
if (flags & (Bottom | Right)) {
TBrush brsh(brColor);
dc.SelectObject(brsh);
if (flags & Bottom) {
dc.SetPixel(fr.left, fr.bottom-1, bcColor);
dc.PatBlt(fr.left+1, fr.bottom-1, fr.Width(), 1);
}
if (flags & Right)
dc.PatBlt(fr.right-1, fr.top, 1, fr.Height()-1);
dc.RestoreBrush();
}
}
示例3: DrawIconicGauge
///////////////////////////////////////////////////////////////
// TLevelProgressDialog
// --------------------
//
void DrawIconicGauge(TDC &dc, int yPosition, int Width, int Height, int Value)
{
TBrush BleueBrush(TColor(0,0,255));
TPen BleuePen (TColor(0,0,255));
// TBrush GrayBrush (TColor(200,200,200));
TPen WhitePen (TColor(255,255,255));
TPen GrayPen (TColor(100,100,100));
// TPen GrayPen (TColor(0,0,0));
// Draw upper left white border
dc.SelectObject(GrayPen);
dc.MoveTo(0, yPosition + Height - 1);
dc.LineTo(0, yPosition);
dc.LineTo(Width - 1, yPosition);
// Draw lower right border
dc.SelectObject(WhitePen);
dc.LineTo(Width - 1, yPosition + Height - 1);
dc.LineTo(0, yPosition + Height - 1);
// Draw gauge
dc.SelectObject(BleueBrush);
dc.SelectObject(BleuePen);
dc.Rectangle(1, yPosition + 1, (Width - 1) * Value / 100, yPosition + Height - 1);
dc.RestoreObjects();
}
示例4: pen
void TSensorView::Grid3D(TDC& dc)
{
if(m_bGrid)
{
TPen pen(TColor(192,192,192),0);
dc.SelectObject(pen);
for (int y = 0; y <= m_ySize ; y++)
{
MOVE(dc,Project2D(0,y,1));
LINE(dc,Project2D(0,y,0));
LINE(dc,Project2D(m_xSize,y,0));
}
for (int x = 0; x <= m_xSize; x++)
{
MOVE(dc,Project2D(x,0,1));
LINE(dc,Project2D(x,0,0));
LINE(dc,Project2D(x,m_ySize,0));
}
for (SHORTREAL z = 0; z < 1.05; z += (SHORTREAL) 0.1)
{
MOVE(dc,Project2D(0,m_ySize,z));
LINE(dc,Project2D(0,0,z));
LINE(dc,Project2D(m_xSize,0,z));
}
dc.RestorePen();
}
}
示例5: LineViewer
void TSensorView::LineViewer(TDC& dc,PSHORTREAL pData)
{
m_xSize = m_nDimSize[0]-1;
m_ySize = m_nDimSize[1]-1;
m_yAdd = (int) (500L * m_ySize / m_xSize / 2);
dc.SetWindowExt(TSize(m_xSize * 2 + m_ySize,500 + m_yAdd));
Grid3D(dc);
if(m_nDimSize[1] == 1)
for(int x = 0; x < m_nDimSize[0]; x++)
{
TPoint pt = Project2D(x,0,pData[x]);
if (x)
LINE(dc,pt);
else
MOVE(dc,pt);
}
else
{
TBrush br(SYSCOLOR(COLOR_BTNFACE));
dc.SelectObject(br);
for (int y = 0; y < m_nDimSize[1]-1; y++)
for (int x = 0; x < m_nDimSize[0]-1; x++)
{
TPoint pt[4] =
{
Project2D(x,y,pData[x + (LONGINT) m_nDimSize[0] * y]),
Project2D(x+1,y,pData[x+1 + (LONGINT) m_nDimSize[0] * y]),
Project2D(x+1,y+1,pData[x+1 + (LONGINT) m_nDimSize[0] * (y+1)]),
Project2D(x,y+1,pData[x + (LONGINT) m_nDimSize[0] * (y+1)])
};
POLY(dc,pt,4);
}
}
dc.RestorePen();
}
示例6:
//
/// 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();
}
示例7: 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();
}
示例8: ColumnViewer
void TSensorView::ColumnViewer(TDC& dc,PSHORTREAL pData)
{
m_xSize = m_nDimSize[0];
m_ySize = m_nDimSize[1];
m_yAdd = (int) (500L * m_ySize / m_xSize / 2);
dc.SetWindowExt(TSize(m_xSize * 2 + m_ySize,500 + m_yAdd));
Grid3D(dc);
TBrush brGray(SYSCOLOR(COLOR_BTNFACE)),
brWhite(SYSCOLOR(COLOR_BTNHIGHLIGHT)),
brDark(SYSCOLOR(COLOR_BTNSHADOW));
for (int y = 0; y < m_nDimSize[1]; y++)
for (int x = 0; x < m_nDimSize[0]; x++)
{
SHORTREAL r = pData[x + (LONGINT) m_nDimSize[0] * y];
TPoint pt[4] =
{
Project2D(x,y+1,r),
Project2D(x+1,y+1,r),
Project2D(x+1,y,r),
Project2D(x,y,r)
};
dc.SelectObject(brWhite);
POLY(dc,pt,4);
SHORTREAL r2 = y == m_nDimSize[1]-1
? 0
: pData[x + (LONGINT) m_nDimSize[0] * (y+1)];
if(r2 < r)
{
pt[2] = Project2D(x+1,y+1,r2);
pt[3] = Project2D(x,y+1,r2);
dc.SelectObject(brGray);
POLY(dc,pt,4);
}
r2 = x == m_nDimSize[0]-1 ? 0
: pData[x+1 + (LONGINT) m_nDimSize[0] * y];
if (r2 < r)
{
pt[0] = Project2D(x+1,y,r);
pt[2] = Project2D(x+1,y+1,r2);
pt[3] = Project2D(x+1,y,r2);
dc.SelectObject(brDark);
POLY(dc,pt,4);
}
}
dc.RestoreBrush();
}
示例9:
void
TGaugeGadget::Paint(TDC& dc, bool erase, TRect &rect)
{
// Select the approprate font
dc.SelectObject(Window->GetFont());
TGauge::Paint(dc, erase, rect);
dc.RestoreFont();
}
示例10: 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();
}
示例11: part
//
/// Puts the font into the device context and calls PaintGadgets.
///
/// Respond to virtual TWindow Paint call. Call our own virtual PaintGadgets
/// to actually perform the painting of the gadgets
//
void
TGadgetWindow::Paint(TDC& dc, bool erase, TRect& rect)
{
if (IsBackgroundThemed())
{
TThemePart part(GetHandle(), (LPCWSTR) L"REBAR", 0, 0);
part.DrawBackground(dc, GetClientRect(), rect);
erase = false;
}
dc.SelectObject(*Font);
PaintGadgets(dc, erase, rect);
#if defined(__TRACE) || defined(__WARN)
// Highlight the tools of this gadgetwindow for debugging purposes.
// Especially useful for docking windows which undergo internal state
// changes
//
TProfile iniFile(_T("Diagnostics"), _T(OWL_INI));
bool useDiagColor = iniFile.GetInt(_T("DiagToolbarBorders")) != 0;
if (useDiagColor && Tooltip && Tooltip->IsWindow()) {
uint count = Tooltip->GetToolCount();
if (count) {
TPen redPen(TColor(0xff, 0, 0));
dc.SelectObject(redPen);
TToolInfo ti;
while (count) {
if (Tooltip->EnumTools(--count, ti)) {
dc.MoveTo(ti.rect.left, ti.rect.top);
dc.LineTo(ti.rect.right,ti.rect.top);
dc.LineTo(ti.rect.right,ti.rect.bottom);
dc.LineTo(ti.rect.left, ti.rect.bottom);
dc.LineTo(ti.rect.left, ti.rect.top);
}
}
dc.RestorePen();
}
}
#endif
}
示例12: 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();
}
示例13: GetClientRect
//
/// Adjusts the message bar and paints a highlight line. Then, PaintGadgets either
/// paints the hint text if any is set or calls TGadgetWindow::PaintGadgets to
/// repaint each gadget.
//
void
TMessageBar::PaintGadgets(TDC& dc, bool erase, TRect& rect)
{
if (HighlightLine && rect.top == 0)
dc.TextRect(0, 0, rect.right, TUIMetric::CyBorder, TColor::Sys3dHilight);
if (!HintText.empty())
{
TRect clientRect = GetClientRect();
int y = (clientRect.bottom - GetFontHeight()) / 2;
if (HighlightLine)
clientRect.top += TUIMetric::CyBorder;
dc.SelectObject(GetFont());
dc.SetBkColor(TColor::Sys3dFace);
dc.ExtTextOut(5, y, ETO_OPAQUE, &clientRect, HintText, static_cast<int>(HintText.length()));
}
else
{
TGadgetWindow::PaintGadgets(dc, erase, rect);
}
}
示例14: Paint
void TFuncSpecView::Paint(TDC& dc, bool erase, TRect& rect)
{
TSwitchMinApp* theApp = TYPESAFE_DOWNCAST(GetApplication(), TSwitchMinApp);
if (theApp) {
// Only paint if we're printing and we have something to paint, otherwise do nothing.
//
if (theApp->Printing && theApp->Printer && !rect.IsEmpty()) {
// Use pageSize to get the size of the window to render into. For a Window it's the client area,
// for a printer it's the printer DC dimensions and for print preview it's the layout window.
//
TSize pageSize(rect.right - rect.left, rect.bottom - rect.top);
TPrintDialog::TData& printerData = theApp->Printer->GetSetup();
// Get area we can draw in
TRect drawingArea(swdoc->PaintHeader(dc, rect, "", 0, 0, false), rect.BottomRight());
TEXTMETRIC tm;
dc.SelectObject(TFont("Arial", -12));
if (!dc.GetTextMetrics(tm)) {
dc.SelectObject(TFont("Arial", -12));
dc.GetTextMetrics(tm);
}
int fHeight=tm.tmHeight+tm.tmExternalLeading;
unsigned long inputs=swdoc->GetSystem()->GetInputs();
XPosVector xpos;
uint divider;
char* data;
Print_CreateWidths(xpos, divider, dc);
if (xpos.back().x < rect.Size().cx) { // put space in structure to stretch across page
uint spacing=(rect.Size().cx - xpos.back().x)/(xpos.size()+1);
uint space_inc=spacing;
for(XPosVector::size_type i=0; i<xpos.size(); i++) {
if (i==inputs) { // after inputs section, increase divider
divider += space_inc;
space_inc += spacing;
}
xpos[i].x += space_inc;
space_inc += spacing;
}
}
data=new char[xpos.size()];
unsigned long PagesDown=1+pow(2,inputs)/( (drawingArea.Size().cy/fHeight) - 2); // 2 lines for header and horz divider
unsigned long PagesAcross=1+xpos.back().x/drawingArea.Size().cx;
unsigned long Pages=1+PagesDown*PagesAcross;
// Compute the number of pages to print.
//
printerData.MinPage = 1;
printerData.MaxPage = Pages;
int fromPage = printerData.FromPage == -1 ? 1 : printerData.FromPage;
int toPage = printerData.ToPage == -1 ? 1 : printerData.ToPage;
int currentPage = fromPage;
TPoint p;
dc.SelectObject(TPen(TColor::Black));
while (currentPage <= toPage) {
swdoc->PaintHeader(dc, rect, "Specification", currentPage, Pages, true);
if (currentPage==1) Print_Summary(dc, drawingArea);
else {
// Calculate origin of line by page number
// x
int col=((currentPage-2) ) % PagesAcross;
p.x=drawingArea.left - col * drawingArea.Size().cx;
// y
int row=floor((currentPage-2)/PagesAcross);
p.y=drawingArea.top/* - row * drawingArea.Size().cy*/;
// Calculate starting and ending input states
CELL_TYPE state, stateEnd;
state=(row*(drawingArea.Size().cy-fHeight))/fHeight;
stateEnd=state+(drawingArea.Size().cy-fHeight)/fHeight;
if (stateEnd >= (pow(2,inputs)-1) ) stateEnd=pow(2,inputs)-1;
//
// Draw header and lines
// Vertical
if ( ((p.x+divider) > drawingArea.left) && ((p.x+divider)<drawingArea.right) ) {
dc.MoveTo(p.x+divider, p.y);
dc.LineTo(p.x+divider, p.y+((stateEnd-state)+3)*fHeight);
}
// Labels
for(XPosVector::size_type i=0; i<xpos.size(); i++)
dc.TextOut(TPoint(xpos[i].x, p.y), xpos[i].s.c_str());
p.y += fHeight;
// Horizontal
dc.MoveTo(drawingArea.left, p.y + fHeight/2);
dc.LineTo(p.x+xpos.back().x, p.y + fHeight/2);
//.........这里部分代码省略.........
示例15: f
//
/// This is a static function that performs the actual drawing of edges for a
/// UIBorder or an external client. It uses the system ::DrawEdge if available.
//
bool
TUIBorder::DrawEdge(TDC& dc, const TRect& frame, uint edge, uint flags)
{
static int hasDrawEdge = true;
// Try once to see if the API call is available. If not, do ourselves.
//
if (hasDrawEdge) {
if (::DrawEdge(dc, (LPRECT)&frame, edge, flags))
return true;
if (::GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
hasDrawEdge = false;
else
return false;
}
// ::DrawEdge is not available, do the drawing ourselves
//
TRect f(frame); // working frame rectangle
// If mono is set, draw a thin, flat, black (windowFrame) frame
//
if (flags & Mono) {
if (edge & EdgeOuter) {
PaintFrame(dc, f, flags, TColor::SysWindowFrame, TColor::SysWindowFrame);
f.Inflate(-1,-1);
}
if (flags & Fill) { // !CQ repeated code--nest else?
TBrush brsh(TColor::SysWindow);
dc.SelectObject(brsh);
dc.PatBlt(f);
dc.RestoreBrush();
}
return true;
}
// If flat is set, draw a thin, flat, shadow frame
//
if (flags & Flat) {
if (edge & EdgeOuter) {
PaintFrame(dc, f, flags, TColor::Sys3dShadow, TColor::Sys3dShadow);
f.Inflate(-1,-1);
}
if (flags & Fill) { // !CQ repeated code--nest else?
TBrush brsh(TColor::Sys3dFace);
dc.SelectObject(brsh);
dc.PatBlt(f);
dc.RestoreBrush();
}
return true;
}
// Draw outer edge if indicated, adjusting rect afterwards
//
if (edge & EdgeOuter) {
static TColor tlColors[] = {
TColor::Sys3dLight, // EdgeRaised
TColor::Sys3dHilight, // EdgeRaised + Soft
TColor::Sys3dShadow, // EdgeSunken
TColor::Sys3dDkShadow, // EdgeSunken + Soft
};
static TColor brColors[] = {
TColor::Sys3dDkShadow, // EdgeRaised
TColor::Sys3dDkShadow, // EdgeRaised + Soft
TColor::Sys3dHilight, // EdgeSunken
TColor::Sys3dHilight, // EdgeSunken + Soft
};
int ci = ((edge & SunkenOuter) ? 2 : 0) | ((flags & Soft) ? 1 : 0);
PaintFrame(dc, f, flags, tlColors[ci], brColors[ci]);
f.Inflate(-1,-1);
}
// Draw inner edge if indicated, adjusting rect afterwards
//
if (edge & EdgeInner) {
static TColor tlColors[] = {
TColor::Sys3dHilight, // EdgeRaised
TColor::Sys3dLight, // EdgeRaised + Soft
TColor::Sys3dDkShadow, // EdgeSunken
TColor::Sys3dShadow, // EdgeSunken + Soft
};
static TColor brColors[] = {
TColor::Sys3dShadow, // EdgeRaised
TColor::Sys3dShadow, // EdgeRaised + Soft
TColor::Sys3dLight, // EdgeSunken
TColor::Sys3dLight, // EdgeSunken + Soft
};
int ci = ((edge & SunkenOuter) ? 2 : 0) | ((flags & Soft) ? 1 : 0);
PaintFrame(dc, f, flags, tlColors[ci], brColors[ci]);
f.Inflate(-1,-1);
}
// Fill interior if indicated
//
if (flags & Fill) {
TBrush brsh(TColor::Sys3dFace);
//.........这里部分代码省略.........