Esempio n. 1
0
void ImageView::paintEvent(QPaintEvent* event) {
  // if the image is scaled and we have a high quality cached image
  if(imageItem_ && scaleFactor_ != 1.0 && !cachedPixmap_.isNull()) {
    // rectangle of the whole image in viewport coordinate
    QRect viewportImageRect = sceneToViewport(imageItem_->rect());
    // the visible part of the image.
    QRect desiredCachedRect = viewportToScene(viewportImageRect.intersected(viewport()->rect()));
    // check if the cached area is what we need and if the cache is out of date
    if(cachedSceneRect_ == desiredCachedRect) {
      // rect of the image area that needs repaint, in viewport coordinate
      QRect repaintImageRect = viewportImageRect.intersected(event->rect());
      // see if the part asking for repaint is contained by our cache.
      if(cachedRect_.contains(repaintImageRect)) {
        QPainter painter(viewport());
        painter.fillRect(event->rect(), backgroundBrush());
        painter.drawPixmap(repaintImageRect, cachedPixmap_);
        return;
      }
    }
  }
  if(!image_.isNull()) { // we don't have a cache yet or it's out of date already, generate one
    queueGenerateCache();
  }
  QGraphicsView::paintEvent(event);
}
Esempio n. 2
0
PoseMeshScene::PoseMeshScene(QObject *parent)
: QGraphicsScene(parent)
{    
   double graphicsWidth  = 512;
   double graphicsHeight = 1024;   

   // This rectangle will be a visual representation 
   // of the bounds that the map can be dragged in  
   mCanvasRect.setLeft(0);
   mCanvasRect.setTop(0);
   mCanvasRect.setWidth(graphicsWidth);
   mCanvasRect.setHeight(graphicsHeight);   

   mVerticalMeshOffset = mCanvasRect.y() + 64;

   QBrush canvasBrush(QColor(192, 192, 255));

   QGraphicsRectItem *canvasItem = addRect(mCanvasRect, QPen(), canvasBrush);  
   canvasItem->setZValue(-100.0f);
   canvasItem->setEnabled(false);

   QBrush backgroundBrush(QPixmap(":/images/checker.png"));  
   setBackgroundBrush(backgroundBrush);

   CreateTest();
}
/**
 * Event: OnPaint
 *
 * Render the Notification Window
 */
LRESULT NotificationWindow::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
  PAINTSTRUCT ps;
  BeginPaint(&ps);
  {
    MyGdiplusHelper gdi_plus_autostart;
    {
      // get draw area
      RECT clientRect;
      ::GetClientRect(m_hWnd, &clientRect);
      // create Gdiplus Graphics object
      Gdiplus::Graphics graphics(m_hWnd, FALSE);
      graphics.SetClip(Gdiplus::Rect(clientRect.left, clientRect.top, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top));

      // draw a background
      Gdiplus::SolidBrush backgroundBrush(Gdiplus::Color(DEFAULT_ALPHA, 255, 255, 255));
      graphics.FillRectangle(&backgroundBrush, clientRect.left, clientRect.top, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);

      // shrink draw area 
      int inset = 4;
      clientRect.left += inset;
      clientRect.top += inset;
      clientRect.right -= inset;
      clientRect.bottom -= inset;

      // whack a logo TODO
      //Bitmap* bitmap = new Bitmap(m_icon.c_str(), FALSE);
      int bitmapWidth = 0;//bitmap->GetWidth(); 
      int bitmapHeight = 15;//bitmap->GetHeight(); 
      //graphics->DrawImage(bitmap, clientRect.left, clientRect.top, 
      //bitmapWidth, bitmapHeight); 

      // draw a separator
      Gdiplus::Pen blackPen(Gdiplus::Color(0, 0, 0), 1.0f);
      graphics.DrawLine(&blackPen, clientRect.left, clientRect.top + bitmapHeight + inset, clientRect.right, clientRect.top + bitmapHeight + inset);

      // setup text properties
      Gdiplus::Font titleFont(L"Verdana", 10, Gdiplus::FontStyleBold);
      Gdiplus::Font textFont(L"Verdana", 10, Gdiplus::FontStyleRegular);
      Gdiplus::RectF titleRect((float)clientRect.left + inset + bitmapWidth, (float)clientRect.top, (float)clientRect.right, 20.0f);
      Gdiplus::RectF textRect((float)clientRect.left,
        (float)clientRect.top + bitmapHeight + (inset * 2),
        (float)clientRect.right,
        (float)clientRect.bottom - bitmapHeight - (inset * 2));
      Gdiplus::StringFormat format;
      format.SetTrimming(Gdiplus::StringTrimmingEllipsisCharacter);
      format.SetFormatFlags(Gdiplus::StringFormatFlagsLineLimit);
      Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0));

      // draw the message
      graphics.DrawString(m_title.c_str(), (int)m_title.length(), &titleFont, titleRect, &format, &blackBrush);
      graphics.DrawString(m_message.c_str(), (int)m_message.length(), &textFont, textRect, &format, &blackBrush);
    }
  }

  EndPaint(&ps);
  bHandled = TRUE;

  return 0;
}
Esempio n. 4
0
void SCgScene::renderToImage(QPainter *painter, const QRectF &target, const QRectF &source, Qt::AspectRatioMode aspectRatioMode)
{
    QBrush brush = backgroundBrush();
    setBackgroundBrush(QBrush(Qt::NoBrush));
    render(painter, target, source, aspectRatioMode);
    setBackgroundBrush(brush);
}
void OnDraw(HDC hdc)
{
	Gdiplus::Graphics graphics(hdc);

	RECT rect;
	GetClientRect(g_hWnd, &rect);

	Gdiplus::Color backgroundColor(OriginalBackgroundColor);
	if (!g_useOriginalColor)
	{
		backgroundColor = OtherBackgroundColor;
	}

	Gdiplus::SolidBrush backgroundBrush(backgroundColor);
	graphics.FillRectangle(&backgroundBrush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);

	const TCHAR* message = _T("Click the buttons with your eyes! Look at a button and press the space bar to click. ")
		_T("(Make sure the window has input focus.)");
	Gdiplus::Font font(_T("Arial"), 10);
	Gdiplus::SolidBrush textBrush(Gdiplus::Color::Black);
	Gdiplus::RectF textRect((Gdiplus::REAL)10, 
							(Gdiplus::REAL)(ButtonTop + ButtonHeight + 20), 
							(Gdiplus::REAL)(rect.right - 20), 
							(Gdiplus::REAL)(rect.bottom - rect.top));
	Gdiplus::StringFormat textFormat;
	graphics.DrawString(message, (INT)_tcslen(message), &font, textRect, &textFormat, &textBrush);
}
void OnDraw(HDC hdc)
{
	Gdiplus::Graphics graphics(hdc);

	RECT rect;
	GetClientRect(g_hWnd, &rect);

	Gdiplus::Color backgroundColor(OriginalBackgroundColor);
	if (!g_useOriginalColor)
	{
		backgroundColor = OtherBackgroundColor;
	}

	Gdiplus::SolidBrush backgroundBrush(backgroundColor);
	graphics.FillRectangle(&backgroundBrush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);

	const TCHAR* message = _T("Click the buttons with your eyes! Look at a button and use the Direct Click key -- ")
		_T("typically the Applications key, the one next to the right Ctrl key, with a picture of a menu on it.");
	Gdiplus::Font font(_T("Arial"), 10);
	Gdiplus::SolidBrush textBrush(Gdiplus::Color::Black);
	Gdiplus::RectF textRect((Gdiplus::REAL)10, 
							(Gdiplus::REAL)(ButtonTop + ButtonHeight + 20), 
							(Gdiplus::REAL)(rect.right - 20), 
							(Gdiplus::REAL)(rect.bottom - rect.top));
	Gdiplus::StringFormat textFormat;
	graphics.DrawString(message, _tcslen(message), &font, textRect, &textFormat, &textBrush);
}
Esempio n. 7
0
void ImageView::drawBackground(QPainter *p, const QRectF &)
{
    p->save();
    p->resetTransform();
    p->drawTiledPixmap(viewport()->rect(), backgroundBrush().texture());
    p->restore();
}
Esempio n. 8
0
void CContourView::OnDrawtriangle()
{
    // TODO: Add your command handler code here
    CClientDC dc( this );
    CRect therect;
    this->GetClientRect( &therect );


    //***************************************
    //** Clear memDC's bitmap...
    CBrush backgroundBrush( ( COLORREF )::GetSysColor( COLOR_WINDOW ) );
    CBrush* pOldBrush = m_memDC.SelectObject( &backgroundBrush );
    m_memDC.PatBlt( 0, 0, m_cxBitmap, m_cyBitmap, PATCOPY );
    m_memDC.SelectObject( pOldBrush )->DeleteObject();
    //** end clear
    //***************************************

    m_pTriangle->InitialTriangle(); //Read source data...

    //设立坐标系
    m_memDC.SetMapMode( MM_ISOTROPIC );
    m_memDC.SetWindowExt( ( int )( m_pTriangle->xmax - m_pTriangle->xmin ), ( int )( m_pTriangle->ymax - m_pTriangle->ymin ) );
    m_memDC.SetViewportExt( ( int )( ( m_pTriangle->xmax - m_pTriangle->xmin ) / tmpRatio ), ( int )( ( m_pTriangle->ymax - m_pTriangle->ymin ) / tmpRatio ) );
    dc.SetMapMode( MM_ISOTROPIC );
    dc.SetWindowExt( ( int )( m_pTriangle->xmax - m_pTriangle->xmin ), ( int )( m_pTriangle->ymax - m_pTriangle->ymin ) );
    dc.SetViewportExt( ( int )( ( m_pTriangle->xmax - m_pTriangle->xmin ) / tmpRatio ), ( int )( ( m_pTriangle->ymax - m_pTriangle->ymin ) / tmpRatio ) );
    //两个坐标系统的重合点为原点为(0,0)

    // 写内存影像平面
    m_pTriangle->DrawTriangle( &m_memDC );
    //for (int i=1600; i<2140; i+=45)
    double zValues[4];
    zValues[0] = 1570;
    zValues[1] = 1590;
    zValues[2] = 1610;
    zValues[3] = 1630;
    for ( int i = 0; i < 4; i++ )
    {
        //m_pTriangle->CreateContourEx(&m_memDC, i);
        m_pTriangle->CreateContourEx( &m_memDC, zValues[i] );
    }


    SIZE sizeTotal;
    sizeTotal.cx = ( int )( m_pTriangle->xmax - m_pTriangle->xmin );
    sizeTotal.cy = ( int )( m_pTriangle->ymax - m_pTriangle->ymin );
    this->SetLogScrollSizes( sizeTotal, tmpRatio );
    ResizeParentToFit();


    //***************************************
    //**把影像从内存DC传递到设备DC
    dc.BitBlt( m_memDC.GetWindowOrg().x, m_memDC.GetWindowOrg().y, m_cxBitmap * tmpRatio, m_cyBitmap * tmpRatio, &m_memDC, m_memDC.GetWindowOrg().x, m_memDC.GetWindowOrg().y, SRCCOPY );
    //**
    //***************************************

    SCROLLINFO  scrollinfo;
    this->GetScrollInfo( SB_VERT, &scrollinfo );
}
Esempio n. 9
0
void StartScene::setServerLogBackground() {
    if (server_log) {
        // make its background the same as background, looks transparent
        QPalette palette;
        palette.setBrush(QPalette::Base, backgroundBrush());
        server_log->setPalette(palette);
    }
}
Esempio n. 10
0
QVariant ChatLineModelItem::timestampData(int role) const
{
    switch (role) {
    case ChatLineModel::DisplayRole:
        return _styledMsg.decoratedTimestamp();
    case ChatLineModel::EditRole:
        return _styledMsg.timestamp();
    case ChatLineModel::BackgroundRole:
        return backgroundBrush(UiStyle::Timestamp);
    case ChatLineModel::SelectedBackgroundRole:
        return backgroundBrush(UiStyle::Timestamp, true);
    case ChatLineModel::FormatRole:
        return QVariant::fromValue<UiStyle::FormatList>(UiStyle::FormatList()
                << qMakePair((quint16)0, (quint32) UiStyle::formatType(_styledMsg.type()) | UiStyle::Timestamp));
    }
    return QVariant();
}
Esempio n. 11
0
QVariant ChatLineModelItem::senderData(int role) const
{
    switch (role) {
    case ChatLineModel::DisplayRole:
        return _styledMsg.decoratedSender();
    case ChatLineModel::EditRole:
        return _styledMsg.plainSender();
    case ChatLineModel::BackgroundRole:
        return backgroundBrush(Bb10UiStyle::Sender);
    case ChatLineModel::SelectedBackgroundRole:
        return backgroundBrush(Bb10UiStyle::Sender, true);
    case ChatLineModel::FormatRole:
        return QVariant::fromValue<Bb10UiStyle::FormatList>(Bb10UiStyle::FormatList()
                                                        << qMakePair((quint16)0, (quint32) Bb10UiStyle::formatType(_styledMsg.type()) | Bb10UiStyle::Sender));
    }
    return QVariant();
}
Esempio n. 12
0
void LegendItem::serialize(QJsonObject& plotSettings) const
{
    plotSettings.insert("legendVisibility", QJsonValue::fromVariant(isVisible()));
    plotSettings.insert("legendHorPos", QJsonValue::fromVariant(getHorPos()));
    plotSettings.insert("legendVerPos", QJsonValue::fromVariant(getVerPos()));
    plotSettings.insert("legendBackgroundOpacity", QJsonValue::fromVariant(backgroundBrush().color().alpha()));
    plotSettings.insert("legendFont", QJsonValue::fromVariant(font()));
    plotSettings.insert("legendColumns", QJsonValue::fromVariant(maxColumns()));
}
Esempio n. 13
0
QVariant ChatLineModelItem::contentsData(int role) const
{
    switch (role) {
    case ChatLineModel::DisplayRole:
    case ChatLineModel::EditRole:
        return _styledMsg.plainContents();
    case ChatLineModel::BackgroundRole:
        return backgroundBrush(UiStyle::Contents);
    case ChatLineModel::SelectedBackgroundRole:
        return backgroundBrush(UiStyle::Contents, true);
    case ChatLineModel::FormatRole:
        return QVariant::fromValue<UiStyle::FormatList>(_styledMsg.contentsFormatList());
    case ChatLineModel::WrapListRole:
        if (_wrapList.isEmpty())
            computeWrapList();
        return QVariant::fromValue<ChatLineModel::WrapList>(_wrapList);
    }
    return QVariant();
}
Esempio n. 14
0
File: view.cpp Progetto: jhgorse/kst
void View::save(QXmlStreamWriter &xml) {
  QList<QGraphicsItem*> items = scene()->items(Qt::AscendingOrder);
  xml.writeAttribute("width", QVariant(sceneRect().width()).toString());
  xml.writeAttribute("height", QVariant(sceneRect().height()).toString());
  xml.writeAttribute("color", backgroundBrush().color().name());
  xml.writeAttribute("style", QVariant((int)backgroundBrush().style()).toString());
  if (backgroundBrush().gradient()) {
    QString stopList;
    foreach(const QGradientStop &stop, backgroundBrush().gradient()->stops()) {
      qreal point = (qreal)stop.first;
      QColor color = (QColor)stop.second;

      stopList += QString::number(point);
      stopList += ',';
      stopList += color.name();
      stopList += ',';
    }
    xml.writeAttribute("gradient", stopList);
  }
Esempio n. 15
0
int QGraphicsScene::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 16)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 16;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QBrush*>(_v) = backgroundBrush(); break;
        case 1: *reinterpret_cast< QBrush*>(_v) = foregroundBrush(); break;
        case 2: *reinterpret_cast< ItemIndexMethod*>(_v) = itemIndexMethod(); break;
        case 3: *reinterpret_cast< QRectF*>(_v) = sceneRect(); break;
        case 4: *reinterpret_cast< int*>(_v) = bspTreeDepth(); break;
        case 5: *reinterpret_cast< QPalette*>(_v) = palette(); break;
        case 6: *reinterpret_cast< QFont*>(_v) = font(); break;
        case 7: *reinterpret_cast< bool*>(_v) = isSortCacheEnabled(); break;
        case 8: *reinterpret_cast< bool*>(_v) = stickyFocus(); break;
        }
        _id -= 9;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setBackgroundBrush(*reinterpret_cast< QBrush*>(_v)); break;
        case 1: setForegroundBrush(*reinterpret_cast< QBrush*>(_v)); break;
        case 2: setItemIndexMethod(*reinterpret_cast< ItemIndexMethod*>(_v)); break;
        case 3: setSceneRect(*reinterpret_cast< QRectF*>(_v)); break;
        case 4: setBspTreeDepth(*reinterpret_cast< int*>(_v)); break;
        case 5: setPalette(*reinterpret_cast< QPalette*>(_v)); break;
        case 6: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 7: setSortCacheEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 8: setStickyFocus(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 9;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 9;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Esempio n. 16
0
void CContourView::OnDraw( CDC* pDC )
{
    CContourDoc* pDoc = GetDocument();
    ASSERT_VALID( pDoc );

    // TODO: add draw code for native data here

    /////////////////////////////////////////////////////
    // 无效矩形区域不在内存平面上,修改内存片面的起始位置。
    // 实际修改内存SetWindowOrg()。
    // 在内存平面上,viewportorg永远为0,而windowsorg随时都会改变
    // 在窗口dc上,windowsorg永远为0, 而viewportorg随着滚动条改变
    // 在内存平面的右边或下边
    RECT rectClipBox;
    int theRet = pDC->GetClipBox( &rectClipBox );
    if ( theRet == ERROR || theRet == NULLREGION )
        return;
    CPoint ptWinOrg = m_memDC.GetWindowOrg();

    if( rectClipBox.left < ptWinOrg.x ||
            rectClipBox.right > ptWinOrg.x + m_cxBitmap * tmpRatio ||
            rectClipBox.top < ptWinOrg.y ||
            rectClipBox.bottom > ptWinOrg.y + m_cyBitmap * tmpRatio )
    {
        //设置内存平面新的窗口原点,使裁剪矩形的正中间位于内存位图正的中间
        m_memDC.SetWindowOrg( max( ( rectClipBox.left + rectClipBox.right ) / 2 - m_cxBitmap * tmpRatio / 2, 0 ),
                              max( ( rectClipBox.top + rectClipBox.bottom ) / 2 - m_cyBitmap * tmpRatio / 2, 0 ) );

        //***************************************
        //** Clear memDC's bitmap...
        CBrush backgroundBrush( ( COLORREF )::GetSysColor( COLOR_WINDOW ) );
        CBrush* pOldBrush = m_memDC.SelectObject( &backgroundBrush );
        ptWinOrg = m_memDC.GetWindowOrg(); //重新获得内存平面的新的窗口起始点
        m_memDC.PatBlt( ptWinOrg.x, ptWinOrg.y, m_cxBitmap * tmpRatio, m_cyBitmap * tmpRatio, PATCOPY );
        m_memDC.SelectObject( pOldBrush )->DeleteObject();
        //** end clear
        //***************************************

        // 重画内存位图
        m_pTriangle->DrawTriangle( &m_memDC );
        for ( int i = 1600; i < 2140; i += 45 )
            m_pTriangle->CreateContourEx( pDC, i );
    }
    // 内存平面的起始位置修改完毕!
    //////////////////////////////////////////////////////


    if( m_memDC.GetSafeHdc() != NULL && m_pTriangle->mydc != NULL )
    {
        CPoint pt3;
        pt3 = m_memDC.GetWindowOrg();
        pDC->BitBlt( pt3.x, pt3.y, m_cxBitmap * tmpRatio, m_cyBitmap * tmpRatio, &m_memDC, pt3.x, pt3.y, SRCCOPY );
    }

}
void FormEditorGraphicsView::drawBackground(QPainter *painter, const QRectF &rectangle)
{
    painter->save();
    painter->setBrushOrigin(0, 0);

    painter->fillRect(rectangle.intersected(rootItemRect()), backgroundBrush());
    // paint rect around editable area
    painter->setPen(Qt::black);
    painter->drawRect( rootItemRect());
    painter->restore();
}
void FormEditorGraphicsView::drawBackground(QPainter *painter, const QRectF &rect)
{
    painter->save();
    painter->setBrushOrigin(0, 0);
    painter->fillRect(rect.intersected(sceneRect()), backgroundBrush());
    // paint rect around editable area
    painter->setPen(Qt::black);
    QRectF frameRect = sceneRect().adjusted(0, 0, 0, 0);
    painter->drawRect(frameRect);
    painter->restore();
}
void
QvisParallelCoordinatesWidget::redrawScene(QPainter *painter)
{
    double sceneWidth = (double)width();
    double sceneHeight = (double)height();
    double leftAxisX = sceneWidth * AXIS_LEFT_MARGIN;
    double axisSpacing = (sceneWidth*(1.0-AXIS_LEFT_MARGIN-AXIS_RIGHT_MARGIN)) /
        (double)(axisCount-1);
    double tickSpacing = (sceneHeight*(1.0-AXIS_BOTTOM_MARGIN-AXIS_TOP_MARGIN)) /
        (double)(TICKS_PER_AXIS+1);
    
    QBrush backgroundBrush(QColor(255,255,255));
    qDrawShadePanel(painter,
        0, 0, width(), height(), palette(), true, 2, &backgroundBrush);
        
    axisBottomY = (int)(sceneHeight*(1.0-AXIS_BOTTOM_MARGIN) + 0.5);
    axisTopY    = (int)(sceneHeight*AXIS_TOP_MARGIN + 0.5);
    
    axesXPos.clear();
    
    for (int axisNum = 0; axisNum < axisCount; axisNum++)
    {
        axesXPos.push_back((int)(leftAxisX + (double)axisNum*axisSpacing + 0.5));
    }
    
    ticksYPos.clear();
    
    for (int tickNum = 1; tickNum <= TICKS_PER_AXIS; tickNum++)
    {
        ticksYPos.push_back((int)(axisTopY + (double)tickNum*tickSpacing + 0.5));
    }
    
    double axisLen = (double)(axisBottomY - axisTopY);
    double dashAndGapLen = axisLen / ((double)DASHES_PER_AXIS - DASH_GAP_FRACTION);
    double dashTopYPos = (double)axisTopY;
    int dashLen = (int)(dashAndGapLen * (1.0-DASH_GAP_FRACTION));
        
    dashesTopYPos.clear(); dashesBotYPos.clear();
    
    for (int dashNum = 0; dashNum < DASHES_PER_AXIS; dashNum++)
    {
        dashesTopYPos.push_back((int)dashTopYPos);
        dashesBotYPos.push_back((int)dashTopYPos + dashLen);
        
        dashTopYPos += dashAndGapLen;
    }
    
    dashesBotYPos[DASHES_PER_AXIS-1] = axisBottomY;

    drawDataCurves(painter);
    drawAxes(painter);
    drawAxisTitles(painter);
}
Esempio n. 20
0
void CornerWidget::paintEvent(QPaintEvent* event)
{
	Q_UNUSED(event);

	QPainter painter(this);
	QBrush backgroundBrush(m_backgroundColor);
	QPen backgroundPen(m_backgroundColor);
	painter.setBrush(backgroundBrush);
	painter.setPen(backgroundPen);
	painter.drawRect(rect());
	painter.drawPixmap(m_pixmap.rect(), m_pixmap, m_pixmap.rect());
}
Esempio n. 21
0
/**
 * This is a utility method to copy all the attributes of this
 * TextItem to \a other TextItem.
 */
void TextItem::copyAttributesTo(TextItem *other) const
{
    other->setDefaultTextColor(defaultTextColor());
    other->setHoverBrush(hoverBrush());
    other->setAcceptHoverEvents(acceptHoverEvents());
    other->setAlignment(alignment());
    other->setFont(font());
    other->setBold(bold());
    other->setItalic(italic());
    other->setUnderline(underline());
    other->setBackgroundBrush(backgroundBrush());
}
Esempio n. 22
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);


    // Brush
    QBrush backgroundBrush(Qt::cyan, Qt::Dense6Pattern);


    // Scene and View
    scene = new QGraphicsScene(this);

    view = new myView(scene);
    view->setParent(this);
    view->setBackgroundBrush(backgroundBrush);

    view->display = new GUI;
    view->display->scene = scene;
    view->display->setPos(view->gameManager.board.currentPos);

    ui->layout->addWidget(view);
    view->show();


    // Label Font
    QFont f( "Helvetica Neue", 16);
    ui->strengthLabel->setFont(f);
    ui->toPlayLabel->setFont(f);
    updateToPlayLabel();


    // Search Thread
    search = new searchThread();
    search->view = view;
    connect(view, SIGNAL(moveSearch()), this, SLOT(moveSearch()));
    connect(view, SIGNAL(updateToPlayLabel()), this, SLOT(updateToPlayLabel()));
    connect(search, SIGNAL(finished()), this, SLOT(finishSearch()));

    searchLeftTimer = new QTimer(this);
    searchLeftTimer->setInterval(1000);
    connect(searchLeftTimer, SIGNAL(timeout()), this, SLOT(updateSearchLeft()) );

    // New Game Pop Up
    newGamePU = new newGamePopUp(this);
    connect(newGamePU, SIGNAL(colorChosen(int)), this, SLOT(getColorChoice(int)));


    view->ready = 1;

}
Esempio n. 23
0
void ProjectExplorerWindow::UpdateFilterButtonImage()
{

    const wxColor chromaKey(0xFF, 0x9B, 0x77);

    wxBitmap bitmap(18, 17, 24);

    wxMemoryDC dc;
    dc.SelectObject(bitmap);

    wxBrush backgroundBrush( chromaKey );

    dc.SetBackground( backgroundBrush );
    dc.Clear();

    if (m_filterFlags & FilterFlag_Temporary && !(m_filterFlags & FilterFlag_Unversioned))
    {
        dc.DrawBitmap( m_filterImageList->GetBitmap(1), 0, 0, true );
    }
    else if (m_filterFlags & FilterFlag_Unversioned && m_filterFlags & FilterFlag_Temporary)
    {
        dc.DrawBitmap( m_filterImageList->GetBitmap(2), 0, 0, true );
    }
    else
    {
        dc.DrawBitmap( m_filterImageList->GetBitmap(0), 0, 0, true );
    }

    if (m_filterFlags & FilterFlag_CheckedIn)
    {
        dc.DrawBitmap( m_filterImageList->GetBitmap(3), 0, 0, true );
    }

    if (m_filterFlags & FilterFlag_CheckedOut)
    {
        dc.DrawBitmap( m_filterImageList->GetBitmap(4), 0, 0, true );
    }

    wxBitmap temp;
    dc.SelectObject(temp);

    // Create a mask for the bitmap to mark the transparent areas.
    wxMask* mask = new wxMask( bitmap, chromaKey );
    bitmap.SetMask( mask );

    m_filterButton->SetBitmapLabel(bitmap);
    
}
Esempio n. 24
0
void QGridView::paintEmptyArea( QPainter *p, int cx ,int cy, int cw, int ch)
{
    if ( gridSize().width() >= contentsWidth() && gridSize().height() >= contentsHeight() )
	return;
    // Region of the rect we should draw
    contentsToViewport( cx, cy, cx, cy );
    QRegion reg( QRect( cx, cy, cw, ch ) );
    // Subtract the table from it
    reg = reg.subtract( QRect( contentsToViewport( QPoint( 0, 0 ) ), gridSize() ) );

    // And draw the rectangles (transformed as needed)
    QMemArray<QRect> r = reg.rects();
    const QBrush &brush = backgroundBrush();
    for ( int i = 0; i < (int)r.count(); ++i)
	p->fillRect( r[ i ], brush );
}
Esempio n. 25
0
	virtual void paintEvent(QPaintEvent*)
	{
		QPainter painter(this);

		QLinearGradient gradient(0, 0, 0, height());
		gradient.setColorAt(0.0, ColourPalette::kColour6);
		gradient.setColorAt(0.5, ColourPalette::kColour7);
		gradient.setColorAt(1.0, ColourPalette::kColour8);
		QBrush backgroundBrush(gradient);

		painter.fillRect(rect(), backgroundBrush);

		painter.setPen(ColourPalette::kColour4);
		painter.drawText(m_textRect, Qt::AlignVCenter | Qt::AlignLeft, m_text);

		painter.drawPixmap(width() - m_logo.width() - 24, (height() - m_logo.height()) / 2, m_logo);
	}
Esempio n. 26
0
KdmClock::KdmClock( QWidget *parent, const char *name )
	: inherited( parent, name )
{
	// start timer
	QTimer *timer = new QTimer( this );
	connect( timer, SIGNAL(timeout()), SLOT(timeout()) );
	timer->start( 1000 );

	// reading rc file
	//KConfig *config = kapp->config();

	//config->setGroup( "Option" );
	mDate = false;//config->readNumEntry( "date", FALSE );
	mSecond = true;//config->readNumEntry( "second", TRUE );
	mDigital = false;//config->readNumEntry( "digital", FALSE );
	mBorder = false;//config->readNumEntry( "border", FALSE );

	//config->setGroup( "Font" );
	mFont.setFamily( QString::fromLatin1("Utopia")/*config->readEntry( "Family", "Utopia")*/ );
	mFont.setPointSize( 51/*config->readNumEntry( "Point Size", 51)*/ );
	mFont.setWeight( 75/*config->readNumEntry( "Weight", 75)*/ );
	mFont.setItalic( TRUE/*config->readNumEntry( "Italic",TRUE )*/ );
	mFont.setBold( TRUE/*config->readNumEntry( "Bold",TRUE )*/ );

	setFixedSize( 100, 100 );

	if (mBorder) {
		setLineWidth( 1 );
		setFrameStyle( Box|Plain );
		//setFrameStyle( WinPanel|Sunken );
	}

/*
	if (!mDigital) {
		if (height() < width())
			resize( height(), height() );
		else
			resize( width() ,width() );
	}
*/

	//setBackgroundOrigin( WindowOrigin );
	mBackgroundBrush = backgroundBrush();
	setBackgroundMode( NoBackground );
	repaint();
}
Esempio n. 27
0
bool GroundLayer::render( GeoPainter *painter,
                              ViewportParams *viewParams,
                              const QString &renderPos,
                              GeoSceneLayer *layer )
{
    Q_UNUSED( renderPos )
    Q_UNUSED( layer )

    QBrush backgroundBrush( m_color );
    QPen backgroundPen( Qt::NoPen );

    painter->setBrush( backgroundBrush );
    painter->setPen( backgroundPen );
    painter->drawPath( viewParams->mapShape() );

    return true;
}
Esempio n. 28
0
void UmlCanvas::resize(CanvasFormat f)
{

    setSceneRect(0, 0,(int)(formatSize[f].w * zoom_value),
                     (int)(formatSize[f].h * zoom_value));
    width100percent = formatSize[f].w;
    height100percent = formatSize[f].h;
    update_limits();

    // force redisplay else phantoms may appears
    QBrush bBrush = backgroundBrush();
    bBrush.setColor(::Qt::lightGray);
    setBackgroundBrush(bBrush);
    //setBackgroundColor(::Qt::lightGray);
    update();
    bBrush.setColor(::Qt::white);
    //setBackgroundColor(::Qt::white);
    setBackgroundBrush(bBrush);
    update();
}
Esempio n. 29
0
void RullerSlider::paintEvent(QPaintEvent* event)
{
	Q_UNUSED(event);

	QPainter painter(this);
	QColor backgroundColor(245, 245, 200);
	QBrush backgroundBrush(backgroundColor);
	QPen backgroundPen(backgroundColor);
	QPen mainTickPen(Qt::black);
	QPen secondTickPen(Qt::lightGray);

	double scale = rullerScale();
	double spacing = (orientation() == Qt::Horizontal ? 0.01 : 0.00005);
	int lastStep = int(double(value() + pageStep())/(scale*spacing)) + 1;
	int firstStep = int(double(value())/(scale*spacing)) - 1;

	painter.setBrush(backgroundBrush);
	painter.setPen(backgroundPen);
	painter.drawRect(rect());
	painter.setPen(secondTickPen);
	for (double x = double(lastStep)*spacing; x >= double(firstStep)*spacing; x -= spacing)
	{
		double pos = x*scale - double(value());
		drawGraduation(painter, pos, 0.4);
		if (abs((int(round(x/spacing)) % 10)) == 5)
			drawGraduation(painter, pos, 0.65);
		else if ((int(round(x/spacing)) % 10) == 0)
		{
			painter.setPen(mainTickPen);
			drawGraduation(painter, pos, 0.8);
			QString text;
			text.setNum(round(x*1000.));
			QRectF textRect(0., 0., 0., 0.);
			textRect.moveCenter(QPointF(pos + 2., height()/2.));
			textRect = painter.boundingRect(textRect, Qt::AlignLeft | Qt::AlignVCenter, text);
			painter.drawText(textRect, Qt::AlignCenter, text);
			painter.setPen(secondTickPen);
		}
	}
}
Esempio n. 30
0
void ImageView::paintEvent(QPaintEvent* event)
{
  if (m_item && m_scaleFactor != 1.0 && !m_cachedPixmap.isNull()) {
    const QRect viewportImageRect = sceneToViewport(m_item->rect());
    const QRect desiredCachedRect = viewportToScene(viewportImageRect.intersected(viewport()->rect()));

    if (m_cachedSceneRect == desiredCachedRect) {
      const QRect repaintImageRect = viewportImageRect.intersected(event->rect());
      if (m_cachedRect.contains(repaintImageRect)) {
        QPainter painter(viewport());
        painter.fillRect(event->rect(), backgroundBrush());
        painter.drawPixmap(repaintImageRect, m_cachedPixmap);
        return;
      }
    }
  }

  if (!m_image.isNull())
    queueGenerateCache();

  QGraphicsView::paintEvent(event);
}