QRgb pickScreenRGB(const QRect &rect) { QWidget *widget = QApplication::desktop(); #ifdef MACOSX // #Bugzilla 6514, possibly related to #QTBUG 23516 // Screen grabbing on a secondary screen seems to be broken on MAC // (see what happens using PixelTool), when no piece of the *primary* // screen is involved in the grab. As it seems to be very Qt-based, // the workaround is to trivially grab the smallest rect including the // requested one and a part of the primary screen. const QRect &screen0Geom = QApplication::desktop()->screenGeometry(0); int left = std::min(rect.left(), screen0Geom.right()); int top = std::min(rect.top(), screen0Geom.bottom()); int right = std::max(rect.right(), screen0Geom.left()); int bottom = std::max(rect.bottom(), screen0Geom.right()); QRect theRect(QPoint(left, top), QPoint(right, bottom)); #else const QRect &theRect = rect; #endif QImage img(QPixmap::grabWindow(widget->winId(), theRect.x(), theRect.y(), theRect.width(), theRect.height()) .toImage()); return meanColor( img, QRect(rect.left() - theRect.left(), rect.top() - theRect.top(), rect.width(), rect.height())); }
// Driver program to demonstrate overloaded functions int main() { // initialize rectangle to 30, 5 Rectangle theRect(30,5); std::cout << "DrawShape(): \n"; theRect.DrawShape(); std::cout << "\nDrawShape(40,2): \n"; theRect.DrawShape(40, 2); return 0; }
void CIndicator::drawRect(QPainter* painter) { painter->save(); QRectF theRect(m_rectTopLeft,m_rectBottomRight); painter->setPen(QPen(INDICATOR_FRAME_COLOR,INDICATOR_PEN_WIDTH)); painter->setBrush(QBrush(INDICATOR_FRAME_COLOR,Qt::Dense4Pattern)); painter->drawRect(theRect); painter->restore(); }
BbScene::BbScene(double w, double h, int pageNum, QObject *parent) : QGraphicsScene(parent), _pixmapItem(NULL) { _width = w; _height = h * pageNum; QRectF theRect(-w / 2, -h / 2, w, h); setSceneRect(theRect); }
void wxAuiSimpleTabArt::DrawBorder(wxDC& dc, wxWindow* wnd, const wxRect& rect) { int i, border_width = GetBorderWidth(wnd); wxRect theRect(rect); for (i = 0; i < border_width; ++i) { dc.DrawRectangle(theRect.x, theRect.y, theRect.width, theRect.height); theRect.Deflate(1); } }
void FlatAuiTabArt::DrawBorder(wxDC& dc, wxWindow* wnd, const wxRect& rect) { dc.SetPen(wxPen(wxColour(255,255,255))); int i, border_width = GetBorderWidth(wnd); wxRect theRect(rect); for (i = 0; i < border_width; ++i) { dc.DrawRectangle(theRect.x, theRect.y, theRect.width, theRect.height); theRect.Deflate(1); } }
/********************************************************************* main Args: <none> Returns: <none> This is the main line of the replicat program. All we do is make an application, make a window, and add a kitten to the window. We also patch the event queue to make sure the app quits properly. *********************************************************************/ int main(void) { BApplication app("application/x-vnd.Bastion-replicat"); BRect theRect(0,0,199,199); BWindow* win = new BWindow(theRect,"Replicat",B_TITLED_WINDOW,0); win->AddChild(new VuKitten(theRect)); win->AddCommonFilter(new BMessageFilter(B_QUIT_REQUESTED,f_quit)); win->MoveTo(75,50); win->Show(); app.Run(); return 0; }
void CProgressBar::drawRects(QPainter *painter) { painter->save(); painter->setPen(Qt::NoPen); painter->setRenderHints(QPainter::Antialiasing); qreal initX = PI_EXTRA_SPACE; qreal top = PI_EXTRA_SPACE; qreal bottom = height() - PI_EXTRA_SPACE; qreal rectWidth = (qreal)(width() - PI_RECT_COUNT * PI_EXTRA_SPACE)/PI_RECT_COUNT; for(int rectIndex = 0 ; rectIndex <= PI_RECT_COUNT ; rectIndex++) { QPointF topLeft(initX,top); QPointF bottomRight(initX + rectWidth,bottom); QRectF theRect(topLeft,bottomRight); if(rectIndex <= m_nCurrValue ) { QLinearGradient rectGradient(theRect.topLeft(),theRect.topRight()); rectGradient.setColorAt(0.0,QColor(85,120,0)); rectGradient.setColorAt(0.1,QColor(70,150,20)); rectGradient.setColorAt(0.5,QColor(70,220,20)); rectGradient.setColorAt(0.9,QColor(70,150,20)); rectGradient.setColorAt(1.0,QColor(85,120,0)); painter->setBrush(rectGradient); if(rectIndex == m_nCurrValue) { emit sig_Finished(); } } else { QLinearGradient rectGradient(theRect.topLeft(),theRect.topRight()); rectGradient.setColorAt(0.0,QColor(120,120,120)); rectGradient.setColorAt(0.1,QColor(160,160,160)); rectGradient.setColorAt(0.5,QColor(210,210,210)); rectGradient.setColorAt(0.9,QColor(160,160,160)); rectGradient.setColorAt(1.0,QColor(120,120,120)); painter->setBrush(rectGradient); } painter->drawRoundedRect(theRect,PI_ANGLE_RADIUS,PI_ANGLE_RADIUS); initX +=rectWidth + PI_EXTRA_SPACE; } painter->restore(); }
void BbScene::testAddRect() { QGraphicsRectItem* item = new QGraphicsRectItem; QPen thePen = BbUtil::createPen(5, Qt::red); item->setPen(thePen); double ww = getPageWidth() - 20; double hh = getPageHeight() - 20; QRectF theRect(-ww / 2, -hh / 2, ww, hh); item->setRect(theRect); addItem(item); }
void SAuiTabArt::DrawBorder(wxDC& dc, wxWindow* wnd, const wxRect& rect) { int height = ((wxAuiNotebook*)wnd)->GetTabCtrlHeight();// -3; wxRect theRect(rect); dc.DrawLine(theRect.x, theRect.y + height, theRect.x, theRect.y + theRect.height); dc.DrawLine(theRect.x + theRect.width - 1, theRect.y + height, theRect.x + theRect.width - 1, theRect.y + theRect.height); dc.DrawLine(theRect.x, theRect.y + theRect.height - 1, theRect.x + theRect.width, theRect.y + theRect.height - 1); dc.SetPen(wxPen((m_mainTabs && Global::win_version_major >= 10) ? col_w10_bg : m_baseColour)); dc.DrawLine(theRect.x, theRect.y, theRect.x, theRect.y + height); dc.DrawLine(theRect.x + theRect.width - 1, theRect.y, theRect.x + theRect.width - 1, theRect.y + height); dc.DrawLine(theRect.x, theRect.y, theRect.x + theRect.width, theRect.y); }