// /// 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(); } }
// /// 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); }
// /// Using a TPrintPreviewDC, 'print' the current page (PageNum) of Printout /// onto the window DC provided /// /// Displays the page in the preview window. To determine the preview page's /// attributes (line width, and so on), Paint calls several of TPrintout's member /// functions. Then, to adjust the printer object for previewing, Paint determines /// if the page fits in the preview window or if clipping is necessary. Finally, /// Paint passes clipping and banding information to TPrintout's PrintPage function, /// which is called to display the page in the preview window. // void TPreviewPage::Paint(TDC& dc, bool, TRect& clip) { TPrintPreviewDC pdc(dc, PrintDC, GetClientRect(), clip); Printout.SetPrintParams(&pdc, PrintExtent); if (Printout.HasPage(PageNum)) { Printout.BeginPrinting(); Printout.BeginDocument(PageNum, PageNum, pfBoth); // Change clip rect into the shared logical coordinate space, & print // pdc.SDPtoLP(clip); Printout.PrintPage(PageNum, clip, pfBoth); Printout.EndDocument(); Printout.EndPrinting(); } else dc.PatBlt(0, 0, Attr.W, Attr.H, WHITENESS); }
// /// 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); dc.SelectObject(brsh); dc.PatBlt(f); dc.RestoreBrush(); } // !CQ not really usefull since frame is not returned // if (flags & Adjust) // frame = f; return true; }