void CWndControl::Paint(const QRect& windowRect, const QRect& parentRect) { if (!HasFlag(WBS_NODRAWFRAME)) PaintFrame(); const QRect viewport = m_render2D->Viewport(); const QRect clientRect(GetClientRect(false).topLeft() + windowRect.topLeft(), m_clientRect.size()); QRect viewRect, childViewRect; viewRect = clientRect; if (viewRect.left() < viewport.left()) viewRect.setLeft(viewport.left()); if (viewRect.top() < viewport.top()) viewRect.setTop(viewport.top()); if (viewRect.right() > viewport.right()) viewRect.setRight(viewport.right()); if (viewRect.bottom() > viewport.bottom()) viewRect.setBottom(viewport.bottom()); if (!HasFlag(WBS_CHILD)) { m_render2D->SetViewport(viewRect); m_render2D->SetOrigin(clientRect.topLeft()); EraseBackground(); } if (m_controls.GetSize() > 0) { QRect rect; CWndControl* child; for (int i = 0; i < m_controls.GetSize(); i++) { child = m_controls[i]; if (child->HasFlag(WBS_CHILD)) { rect = child->GetWindowRect(true); if (child->HasFlag(WBS_DOCKING)) { rect = QRect(windowRect.topLeft() + rect.topLeft(), rect.size()); if (viewport.intersects(rect)) { childViewRect = rect; if (childViewRect.left() < viewport.left()) childViewRect.setLeft(viewport.left()); if (childViewRect.top() < viewport.top()) childViewRect.setTop(viewport.top()); if (childViewRect.right() > viewport.right()) childViewRect.setRight(viewport.right()); if (childViewRect.bottom() > viewport.bottom()) childViewRect.setBottom(viewport.bottom()); m_render2D->SetOrigin(rect.topLeft()); m_render2D->SetViewport(childViewRect); child->Paint(rect, viewport); } } else { rect = QRect(clientRect.topLeft() + rect.topLeft(), rect.size()); if (viewport.intersects(rect)) { childViewRect = rect; if (childViewRect.left() < viewport.left()) childViewRect.setLeft(viewport.left()); if (childViewRect.top() < viewport.top()) childViewRect.setTop(viewport.top()); if (childViewRect.right() > viewport.right()) childViewRect.setRight(viewport.right()); if (childViewRect.bottom() > viewport.bottom()) childViewRect.setBottom(viewport.bottom()); m_render2D->SetOrigin(rect.topLeft()); m_render2D->SetViewport(childViewRect); child->Paint(rect, viewport); } } } } } m_render2D->SetOrigin(clientRect.topLeft()); m_render2D->SetViewport(viewRect); Draw(); if (s_selection.GetSize() > 0 && m_controls.GetSize() > 0) { QRect rect; CWndControl* child; for (int i = 0; i < m_controls.GetSize(); i++) { child = m_controls[i]; if (child->HasFlag(WBS_CHILD)) { rect = child->GetWindowRect(true); if (child->HasFlag(WBS_DOCKING)) { rect = QRect(windowRect.topLeft() + rect.topLeft(), rect.size()); child->RenderSelection(rect, viewport); } else { rect = QRect(clientRect.topLeft() + rect.topLeft(), rect.size()); child->RenderSelection(rect, viewport); } } } } }
void TUIBorder::Paint3H(TDC& dc, const TRect& frame) { PaintFrame(dc, frame, TColor::Sys3dHilight, TColor::Sys3dHilight); }
// /// 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; }
void TUIBorder::PaintWT(TDC& dc, const TRect& frame) { PaintFrame(dc, frame, TColor::SysWindowText, TColor::SysWindowText); }
virtual void PaintBarH(Option_t * option) { /** Copied from https://root.cern.ch/root/html/src/THistPainter.cxx.html#s5vHLC Added option ("RTOL") to draw histograms from right to left */ Int_t nch = strlen(option)+1; char choption[nch]; strlcpy(choption,option,nch); for (Int_t i=0;i<nch;i++) choption[i] = toupper(choption[i]); bool inverseHorizontally = strstr(choption, "RTOL"); if (! inverseHorizontally) { THistPainter::PaintBarH(option); } else { /* Begin_html <a href="#HP10">Draw a bar char in a rotated pad (X vertical, Y horizontal).</a> End_html */ gPad->SetVertical(kFALSE); PaintInitH(); TAxis *xaxis = fXaxis; TAxis *yaxis = fYaxis; if (!strcmp(xaxis->GetName(),"xaxis")) { fXaxis = yaxis; fYaxis = xaxis; } PaintFrame(); Int_t bar = 0;//Hoption.Bar - 20; Double_t xmin,xmax,ymin,ymax,umin,umax,w; Double_t offset = fH->GetBarOffset(); Double_t width = fH->GetBarWidth(); TBox box; Int_t hcolor = fH->GetFillColor(); if (hcolor == gPad->GetFrameFillColor()) ++hcolor; Int_t hstyle = fH->GetFillStyle(); box.SetFillColor(hcolor); box.SetFillStyle(hstyle); for (Int_t bin=fYaxis->GetFirst();bin<=fYaxis->GetLast();bin++) { ymin = gPad->YtoPad(fYaxis->GetBinLowEdge(bin)); ymax = gPad->YtoPad(fYaxis->GetBinUpEdge(bin)); xmin = (inverseHorizontally ? -gPad->XtoPad(fH->GetBinContent(bin)) : gPad->GetUxmin()); xmax = (inverseHorizontally ? gPad->GetUxmax() : gPad->XtoPad(fH->GetBinContent(bin))); if (xmax < gPad->GetUxmin()) continue; if (xmax > gPad->GetUxmax()) xmax = gPad->GetUxmax(); if (xmin < gPad->GetUxmin()) xmin = gPad->GetUxmin(); if (gStyle->GetHistMinimumZero() && xmin < 0) xmin=TMath::Min(0.,gPad->GetUxmax()); w = (ymax-ymin)*width; ymin += offset*(ymax-ymin); ymax = ymin + w; if (bar < 1) { box.PaintBox(xmin,ymin,xmax,ymax); } else { umin = ymin + bar*(ymax-ymin)/10.; umax = ymax - bar*(ymax-ymin)/10.; box.SetFillColor(TColor::GetColorDark(hcolor)); //dark box.PaintBox(xmin,ymin,xmax,umin); box.SetFillColor(hcolor); box.PaintBox(xmin,umin,xmax,umax); box.SetFillColor(TColor::GetColorBright(hcolor)); //bright box.PaintBox(xmin,umax,xmax,ymax); } } PaintTitle(); // Draw box with histogram statistics and/or fit parameters if (false) { //if (Hoption.Same != 1 && !fH->TestBit(TH1::kNoStats)) { // bit set via TH1::SetStats TIter next(fFunctions); TObject *obj = 0; while ((obj = next())) { if (obj->InheritsFrom(TF1::Class())) break; obj = 0; } PaintStat(gStyle->GetOptStat(),(TF1*)obj); } PaintAxis(kFALSE); fXaxis = xaxis; fYaxis = yaxis; } }