// /// Paints a close box on the tiny caption bar. You can override the default box if /// you want to design your own close box. // void TTinyCaption::PaintCloseBox(TDC& dc, TRect& boxRect, bool pressed) { // Fill the box with light gray & draw bevel if possible // PaintButton(dc, boxRect, pressed); if (pressed) boxRect.Offset(1,1); // Do something different to differentiate from standard system menu-- // draw a recessed black box glyph about half the button size, centered // int glyphWidth = boxRect.Width() > 7 ? boxRect.Width()-boxRect.Width()/2-1 : boxRect.Width()-3; int glyphHeight = boxRect.Height() > 7 ? boxRect.Height()-boxRect.Height()/2-1 : boxRect.Height()-3; if (glyphWidth > 1 && glyphHeight > 1) { TRect glyphRect(0, 0, glyphWidth, glyphHeight); glyphRect.Offset(boxRect.left + (boxRect.Width()-glyphWidth-1)/2, boxRect.top + (boxRect.Height()-glyphHeight-1)/2); dc.TextRect(glyphRect, TColor::Sys3dShadow); glyphRect.Offset(1,1); dc.TextRect(glyphRect, TColor::Sys3dHilight); glyphRect.BottomRight().Offset(-1,-1); dc.TextRect(glyphRect, TColor::SysBtnText); } }
// /// Paints the system box. // void TTinyCaption::PaintSysBox(TDC& dc, TRect& boxRect, bool /*pressed*/) { // Dont paint over the left & top borders // boxRect.left++; boxRect.top++; // Fill the box with 3d face // dc.TextRect(boxRect, TColor::Sys3dFace); // Draw the ventilator (sysmenu) box, with shadow // TPoint begPt = boxRect.TopLeft().OffsetBy(2, (boxRect.Height()-3)/2); TRect ventRect(begPt, TSize(boxRect.Width()-5, 3)); // Draw shadow down and right 1 // dc.TextRect(ventRect.left+1, ventRect.top+1, ventRect.right+1, ventRect.bottom+1, TColor::Sys3dShadow); // Draw ventilator rectangle // TBrush btnTextBr(TColor::SysBtnText); dc.FrameRect(ventRect, btnTextBr); // Draw white interior of ventilator // dc.TextRect(ventRect.left+1, ventRect.top+1, ventRect.right-1, ventRect.top+2, TColor::Sys3dHilight); dc.TextRect(boxRect.right, boxRect.top, boxRect.right+1, boxRect.bottom, TColor::SysBtnText); }
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(); }
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(); }
// /// 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(); }
// /// 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(); } }
void TSensorView::GreyViewer(TDC& dc,PSHORTREAL pData) { dc.SetWindowExt(TSize(m_nDimSize[0],m_nDimSize[1])); for (int y = 0; y < m_nDimSize[1]; y++) { int xStart = 0, x = 0; int clrLast, clrThis; while(x < m_nDimSize[0]) { SHORTREAL r = pData[x + y * (LONGINT) m_nDimSize[0]]; if (r > 1) r = 1; else if (r < 0) r = 0; clrThis = (int) (pow(r,m_dBright) * 255); if(!x) clrLast = clrThis; else if(clrThis != clrLast) { TBrush br(TColor(clrLast,clrLast,clrLast)); TRect rect(xStart,y,x,y+1); dc.FillRect(rect,br); xStart = x; clrLast = clrThis; } x++; } TBrush br(TColor(clrLast,clrLast,clrLast)); TRect rect(xStart,y,x,y+1); dc.FillRect(rect,br); } Grid2D(dc); }
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(); } }
// MFC style function, that draws a filled rect. Is this faster??? void FillSolidRect(TDC& dc, int x, int y, int cx, int cy, TColor clr) { TColor oldColor = dc.SetBkColor(clr); TRect rect(x, y, x + cx, y + cy); dc.ExtTextOut(0, 0, ETO_OPAQUE, &rect, _T(""), 0, 0); dc.SetBkColor(oldColor); }
void TGaugeGadget::Paint(TDC& dc, bool erase, TRect &rect) { // Select the approprate font dc.SelectObject(Window->GetFont()); TGauge::Paint(dc, erase, rect); dc.RestoreFont(); }
// /// Returns the extent of a given string using this particular font in a /// particular DC. // TSize TFont::GetTextExtent(TDC& dc, const tstring& text) const { dc.SelectObject(*this); TSize size = dc.GetTextExtent(text, static_cast<int>(text.length())); // TODO: Widen parameter type to avoid this narrowing cast. dc.RestoreFont(); return size; }
void TCheckBox::calc_size() { int cx,cy; TDC *dc = m_parent->get_dc(); // If the parent was a TComboBox, then it won't have a DC ready... if (dc != NULL) { dc->get_text_extent(get_text(),cx,cy,m_font); resize(int(1.05*cx)+30,int(1.05*cy)); } }
void TFuncSpecView::Print_CreateWidths(TFuncSpecView::XPosVector& xpos, uint& divider, TDC& dc) const { xpos.erase(xpos.begin(), xpos.end()); uint x=0; string text; char pch[64]; ostrstream os(pch, 64); XPosInfo xinfo; // Calculate for inputs unsigned long inputs=swdoc->GetSystem()->GetInputs(); while (inputs--) { xinfo.x=x; // create input symbol os.seekp(0); os << 'x' << inputs << " " << ends; xinfo.s=pch; xpos.push_back(xinfo); // move x position x += dc.GetTextExtent(pch, strlen(pch)).cx; } // Calculate for divider divider=x; x += (divider - xpos.back().x); // Calculate for outputs swmin::FunctionSet::iterator i=swdoc->GetSystem()->GetFuncsConst()->begin(), e=swdoc->GetSystem()->GetFuncsConst()->end(); while (i!=e) { xinfo.x=x; // create output symbol os.seekp(0); os << (*i).id << " " << ends; xinfo.s=pch; xpos.push_back(xinfo); // move x position x += dc.GetTextExtent(pch, strlen(pch)).cx; i++; } xinfo.x=x; xinfo.s=""; xpos.push_back(xinfo); // save ending x-position }
int IniFile::ReadAndFillTDC(){ std::ifstream ini( sFileName.c_str() ); std::stringstream parser; std::string token, value, line, group; iError = INI_OK; // Loading the file into the parser if( ini ){ parser << ini.rdbuf(); ini.close(); } else { iError = INI_ERROR_CANNOT_OPEN_READ_FILE; return iError; } group = ""; TdcMap mapTDC; MapVector mapVector; while( std::getline( parser, line ) && ( iError == INI_OK ) ){ // Check if the line is comment if( !CheckIfComment( line ) ){ // Check for group if( !CheckIfGroup( line, group ) ){ // Check for token if( CheckIfToken( line, token, value ) ){ // Make the key in format group.key if the group is not empty //if( group.size() > 1 ) token = group + "." + token; mData[ token ] = value; } else { iError = INI_ERROR_WRONG_FORMAT; return iError; } } else{ mapVector.push_back(mData); mData.clear(); } } } mapVector.push_back(mData); for(int i=3 ; i<mapVector.size() ; i++){ TDC tempTDC; tempTDC.SetName(mapVector[i]["Name"]); //std::cout<<"TriggerWindowWidth : "<<mapVector[i]["TriggerWindowWidth"]<<std::endl; tempTDC.SetTriggerWindowWidth(std::stoi(mapVector[i]["TriggerWindowWidth"], nullptr,10 )); tempTDC.SetTriggerWindowOffset(std::stoi(mapVector[i]["TriggerWindowOffset"], nullptr,10 )); tempTDC.SetTriggerExtraSearchMargin(std::stoi(mapVector[i]["TriggerExtraSearchMargin"], nullptr,10 )); tempTDC.SetTriggerRejectMargin(std::stoi(mapVector[i]["TriggerRejectMargin"], nullptr,10 )); tempTDC.SetEnableTriggerTimeSubstraction(std::stoi(mapVector[i]["EnableTriggerTimeSubstraction"], nullptr,10 )); tempTDC.SetIndividualLSB(std::stoi(mapVector[i]["IndividualLSB"], nullptr,10 )); fTdcVector.push_back(tempTDC); //std::cout<<"Tdc-NName : "<<mapVector[i]["Name"]<<std::endl; //std::cout<<"TDC-NAME : "<<mapVector[i]["Name"]<<std::endl; } std::cout<<"Num of Groups in INI file : "<<mapVector.size()<<std::endl; }
void FillMaskRect(TDC& dc, TRect rect) { THatch8x8Brush br(THatch8x8Brush::Hatch11F1, TColor::Sys3dHilight, TColor::Sys3dFace); dc.FillRect(rect, br); }
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(); }
// /// Draws the cel at index onto the DC at position x and y. // bool TCelArray::BitBlt(int index, TDC& dstDC, int x, int y, uint32 rop) { TMemoryDC srcDC(*Bitmap); TRect cr = CelRect(index,-1); dstDC.BitBlt(x, y, cr.Width(), cr.Height(), srcDC, cr.left, cr.top, rop); return true; }
void TSensorView::ColorViewer(TDC& dc,PSHORTREAL pData) { int zMax = m_nDimSize[m_nDim-1], xMax = m_nDim > 1 ? m_nDimSize[0] : 1, yMax = m_nDim > 2 ? m_nDimSize[1] : 1; dc.SetWindowExt(TSize(xMax,yMax)); for (int y = 0; y < yMax; y++) { int xStart = 0, x = 0; TColor clrLast, clrThis; while(x < xMax) { int Color[3] = {0,0,0}; for (int z = 0; z < zMax; z++) { SHORTREAL r = pData[x + y * (LONGINT) xMax + z * (LONGINT) xMax * (LONGINT) yMax]; if (r > 1) r = 1; else if (r < 0) r = 0; Color[z] = (int) (pow(r,m_dBright) * 255); } clrThis = TColor(Color[0],Color[1],Color[2]); if(!x) clrLast = clrThis; else if(clrThis != clrLast) { TBrush br(clrLast); TRect rect(xStart,y,x,y+1); dc.FillRect(rect,br); xStart = x; clrLast = clrThis; } x++; } TBrush br(clrLast); TRect rect(xStart,y,x,y+1); dc.FillRect(rect,br); } Grid2D(dc); }
// /// Draws the image of the cel onto the DC. // bool TCelArray::BitBlt(int index, TDC& dstDC, int x, int y, int /*dx*/, int /*dy*/, const TColor& /*bgClr*/, const TColor& /*fgClr*/) { TMemoryDC srcDC(*Bitmap); TRect cr = CelRect(index,-1); dstDC.BitBlt(x, y, cr.Width(), cr.Height(), srcDC, cr.left, cr.top); return true; }
// /// Draws the image of the cel onto the DC. // bool TCelArray::StretchBlt(int index, TDC& dstDC, const TRect& dstRect, uint32 rop) { TMemoryDC srcDC(*Bitmap); TRect cr = CelRect(index,-1); dstDC.StretchBlt(dstRect.left,dstRect.top, dstRect.Width(),dstRect.Height(), srcDC, cr.left, cr.top, cr.Width(), cr.Height(), rop); return true; }
void TSensorView::Grid2D(TDC& dc) { if(m_bGrid) { TPen pen(TColor(0,0,0),0); dc.SelectObject(pen); for (int y = 0; y <= m_nDimSize[1] ; y++) { MOVE(dc,TPoint(0,y)); LINE(dc,TPoint(m_nDimSize[0],y)); } for (int x = 0; x <= m_nDimSize[0]; x++) { MOVE(dc,TPoint(x,0)); LINE(dc,TPoint(x,m_nDimSize[1])); } dc.RestorePen(); } }
void TFuncSpecView::Print_Line(TDC& dc, TPoint origin, const TFuncSpecView::XPosVector& xpos, char* data) const { XPosVector::size_type i, count=xpos.size()-1; // subtract one for end marker char text[]="+"; for(i=0; i<count; i++) { text[0]=data[i]; dc.TextOut(origin.OffsetBy(xpos[i].x, 0), text, 1); } }
// /// 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(); }
// /// 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); } }
// /// If TScroller_AutoOrg is true (default condition), BeginView automatically /// offsets the origin of the logical coordinates of the client area by XPos, YPos /// during a paint operation. If AutoOrg is false (for example, when the scroller is /// larger than 32,767 units), you must set the offset manually. // void TScroller::BeginView(TDC& dc, TRect& rect) { long xOrg = XPos * XUnit; long yOrg = YPos * YUnit; if (AutoOrg && xOrg <= INT_MAX && yOrg <= INT_MAX) { TPoint offset(int(-xOrg), int(-yOrg)); dc.SetViewportOrg(offset); rect -= offset; } }
// /// Called by Paint to repaint all of the gadgets, PaintGadgets iterates through the /// list of gadgets, determines the gadget's area, and repaints each gadget. /// /// You can override this function to implement a specific look (for example, /// separator line, raised, and so on). // void TGadgetWindow::PaintGadgets(TDC& dc, bool, TRect& rect) { TPoint viewport = dc.GetViewportOrg(); for (TGadget* gadget = Gadgets; gadget; gadget = gadget->Next) { if (gadget->GetBounds().Touches(rect)) { dc.SetViewportOrg((TPoint&)gadget->GetBounds()); // If the gadget is a sloppy painter & needs clipping support, set the // clip rect before painting, otherwise just paint. Most gadgets don't // need this help // if (gadget->Clip) { TRegion savedClipRgn; dc.GetClipRgn(savedClipRgn); dc.IntersectClipRect(gadget->GetBounds()); gadget->Paint(dc); dc.SelectClipRgn(savedClipRgn); } else gadget->Paint(dc); } } dc.SetViewportOrg(viewport); }
// /// Paints a maximize box on the tiny caption bar. // void TTinyCaption::PaintMaxBox(TDC& dc, TRect& boxRect, bool pressed) { // Fill the box with light gray & draw bevel if possible // PaintButton(dc, boxRect, pressed); if (pressed) boxRect.Offset(1,1); // Down triangle // int bh = boxRect.Height(); int bw = boxRect.Width(); if (IsZoomed()) { TPoint begPt = boxRect.BottomLeft().OffsetBy((bw+1)/4, -bh*3/8); TPoint endPt = begPt.OffsetBy((bw+1)/2, 0); while (begPt.x < endPt.x) { dc.MoveTo(begPt); dc.LineTo(endPt); begPt.Offset(1,1); endPt.Offset(-1,1); } } // Up triangle // { TPoint begPt = boxRect.TopLeft().OffsetBy((bw+1)/4, IsZoomed() ? bh*3/8 : bh*2/3); TPoint endPt = begPt.OffsetBy((bw+1)/2, 0); while (begPt.x < endPt.x) { dc.MoveTo(begPt); dc.LineTo(endPt); begPt.Offset(1, -1); endPt.Offset(-1, -1); } } }
// /// Paints a minimize box on the tiny caption bar. // void TTinyCaption::PaintMinBox(TDC& dc, TRect& boxRect, bool pressed) { // Fill the box with light gray & draw bevel if possible // PaintButton(dc, boxRect, pressed); if (pressed) boxRect.Offset(1,1); int bh = boxRect.Height(); int bw = boxRect.Width(); TPoint begPt = boxRect.TopLeft().OffsetBy((bw+1)/4, (bh+2)/3); TPoint endPt = begPt.OffsetBy((bw+1)/2,0); while (begPt.x < endPt.x) { dc.MoveTo(begPt); dc.LineTo(endPt); begPt.Offset(1,1); endPt.Offset(-1,1); } }
// /// 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(); }
// /// WM_PAINT handler of RichEdit PagePreview window. Displays a preview of the page /// if the printout can handle it. Otherwise, simply fills the window with a white /// background. // void TRichEditPagePreview::Paint(TDC& dc, bool, TRect& /*clip*/) { TRect client; GetClientRect(client); TPreviewDCBase pdc(dc, PrintDC); Printout.SetPrintParams(&pdc, PrintExtent); if (Printout.HasPage(PageNum)) { Printout.BeginPrinting(); Printout.BeginDocument(PageNum, PageNum, pfBoth); Printout.PrintPage(PageNum, client, pfBoth); Printout.EndDocument(); Printout.EndPrinting(); } else dc.PatBlt(client, WHITENESS); }