当前位置: 首页>>代码示例>>C++>>正文


C++ QPainter::setBackgroundColor方法代码示例

本文整理汇总了C++中QPainter::setBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::setBackgroundColor方法的具体用法?C++ QPainter::setBackgroundColor怎么用?C++ QPainter::setBackgroundColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPainter的用法示例。


在下文中一共展示了QPainter::setBackgroundColor方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: draw

void SubjectCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  QColor bckgrnd = p.backgroundColor();

  p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);

  QColor co = color(used_color);
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);  
  
  p.setBackgroundColor(co);
  p.setFont(the_canvas()->get_font(UmlNormalBoldFont));
  
  if (used_color != UmlTransparent)
    p.fillRect(r, co);
  
  if (fp != 0)
    fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	    " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	    svg_color(used_color), 
	    r.x(), r.y(), r.width() - 1, r.height() - 1);

  p.drawRect(r);
  
  r.setTop(r.top() + (int) (2*the_canvas()->zoom()));
  p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, name);
  if (fp != 0) {
    draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, name,
	      p.font(), fp);
    fputs("</g>\n", fp);
  }
    
  p.setBackgroundColor(bckgrnd);
  
  if (selected())
    show_mark(p, rect());
}
开发者ID:SciBoy,项目名称:douml,代码行数:41,代码来源:SubjectCanvas.cpp

示例2: CreatePixmap

QPixmap QSettingColorTableItem::CreatePixmap() const
{
	if (m_pSetting == NULL || (m_pSetting->GetType() & 0xF) != Setting::SettingTypeColor)
		return QPixmap();
	else
	{
		QPixmap bmpImage(sizeHint().height() - 4, sizeHint().height() - 4);
		QPainter dcImage;
		QColor clrBackground(m_pSetting->GetValue().strValue);
		dcImage.begin(&bmpImage, table()->viewport());
		dcImage.setBackgroundColor(clrBackground.isValid() ? clrBackground : QColor(0, 0, 0));
		dcImage.eraseRect(bmpImage.rect());
		dcImage.drawRect(bmpImage.rect());
		dcImage.end();
		return bmpImage;
	}
}
开发者ID:vigneshananth,项目名称:Groovenet-Qt4,代码行数:17,代码来源:QSettingColorTableItem.cpp

示例3: drawContent

void WSpacePlot::drawContent(QPainter &p,bool) {

  QBrush brush;
  QColor color;
  int hue, selectHue, s, v;
  
  paintColor.getHsv(hue,s,v);
  colorGroup().highlight().getHsv(selectHue,s,v);
  
  QArray<SpaceCell>::Iterator it;
  QArray<SpaceCell>::Iterator end=cellData.end();

  if (drawGrid) {
    p.eraseRect(p.window());
    for (it=cellData.begin(); it!=end; ++it) {
      if (it->attr & selected) {
	p.fillRect(it->rect,colorGroup().highlight());
	p.setPen(colorGroup().highlight().light());
      } else p.setPen(colorGroup().mid());
      p.drawRect(it->rect);
    } 
  } else {   

    p.setBackgroundMode(OpaqueMode);
    p.setBackgroundColor(QColor(64,64,64));
    p.fillRect(p.window(),QBrush(black,Dense6Pattern));
    
    for (it=cellData.begin(); it!=end; ++it)
      if (it->visible) 
	if (it->attr&normal) {
	  
	  float val=clampf(dataRange.scaleValue(it->data));
	  
	  if (finite(val)) {
	    
	    if (it->attr & selected) 
	      color.setHsv(selectHue,128,int((0.5+0.5*val)*255));
	    else
	      color.setHsv(hue,255,int(val*255));
	    
	    p.fillRect(it->rect,color);	
	    
	    if (it->attr&marked) {
	      if (it->attr&selected) 
		color.setHsv(hue,255,int(val*255));
	      else 
		color.setHsv(selectHue,128,int((0.5+0.5*val)*255));	    
	      p.setPen(color);
	      p.drawRect(it->rect);
	    }
	  } else 
	    p.fillRect(it->rect,QBrush(paintColor,DiagCrossPattern));
	} 
  }
  
  if (hasFocus() && QRect(QPoint(0,0),viewSize).contains(currCell)) {
    p.setRasterOp(XorROP);
    p.setPen(white);
    p.drawRect(cellData[currCell.x()+currCell.y()*viewSize.width()].rect);
    p.setRasterOp(CopyROP);
  }
  
  if (!cellLabelRect.isEmpty()) {
    p.setBackgroundMode(TransparentMode);
    p.setPen(QToolTip::palette().active().text());
    p.fillRect(cellLabelRect,QToolTip::palette().active().background());
    p.drawRect(cellLabelRect);
    p.drawText(cellLabelRect,AlignCenter,cellLabelString);
  }
}
开发者ID:jeez,项目名称:iqr,代码行数:70,代码来源:wSpacePlot.cpp

示例4: draw

void DeploymentNodeCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);

  const int three = (int) (3 * the_canvas()->zoom());  
  QColor bckgrnd = p.backgroundColor();
  const QPixmap * px = 
    ProfiledStereotypes::diagramPixmap(browser_node->get_data()->get_stereotype(), the_canvas()->zoom());
  
  if (px != 0) {
    p.setBackgroundMode(::Qt::TransparentMode);
    
    int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();
    
    p.drawPixmap(lft, r.y(), *px);
    if (fp != 0)
      // pixmap not really exported in SVG
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);
    
    r.setTop(r.top() + px->height());
    p.setFont(the_canvas()->get_font(UmlNormalBoldFont));
  }
  else {  
    UmlColor c;
    
    if (itscolor != UmlDefaultColor)
      c = itscolor;
    else {
      if (used_color == UmlDefaultColor)
	used_color = the_canvas()->browser_diagram()->get_color(UmlDeploymentNode);
      c = used_color;
    }
    
    QColor co = color(c);
    const int added = (int) (DEPLOYMENTNODE_CANVAS_ADDED * the_canvas()->zoom());
    Q3PointArray a(7);
    
    r.setTop(r.top() + added);
    r.setRight(r.right() - added);
    
    a.setPoint(0, r.left(), r.top());
    a.setPoint(1, r.left() + added, r.top() - added);
    a.setPoint(2, r.right() + added, r.top() - added);
    a.setPoint(3, r.right() + added, r.bottom() - added);
    a.setPoint(4, r.right(), r.bottom());
    a.setPoint(5, r.right(), r.top());
    a.setPoint(6, r.left(), r.top());
    
    if (c == UmlTransparent) {
      p.setBackgroundMode(::Qt::TransparentMode);
      p.setBackgroundColor(co);
      p.drawPolyline(a);
      
      if (fp != 0) {
	fprintf(fp, "\t<rect fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		r.x(), r.y(), r.width() - 1, r.height() - 1);
	draw_poly(fp, a, UmlTransparent);
      }
    }
    else {
      QBrush brsh = p.brush();
      
      p.setBackgroundMode(::Qt::OpaqueMode);
      p.fillRect(r, co);
      p.setBrush(co);
      p.drawPolygon(a, TRUE, 0, 6);
      p.setBrush(brsh);
      p.setBackgroundColor(co);
      
      if (fp != 0) {
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(c),
		r.x(), r.y(), r.width() - 1, r.height() - 1);
	draw_poly(fp, a, c);
      }
    }
    
    p.drawRect(r);
    p.drawLine(r.topRight(), a.point(2));
    
    if (fp != 0)
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      r.right(), r.top(), a.point(2).x(), a.point(2).y());
    
    QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
    const char * st = browser_node->get_data()->get_short_stereotype();
    QString s;
    
    r.setTop(r.top() + three);
    p.setFont(the_canvas()->get_font(UmlNormalFont));  
//.........这里部分代码省略.........
开发者ID:SciBoy,项目名称:douml,代码行数:101,代码来源:DeploymentNodeCanvas.cpp

示例5: draw

void ArtifactCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  const BasicData * data = browser_node->get_data();
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);
  
  const QPixmap * px = 
    ProfiledStereotypes::diagramPixmap(browser_node->get_data()->get_stereotype(), the_canvas()->zoom());
  
  if (px != 0) {
    p.setBackgroundMode(::Qt::TransparentMode);
    
    int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();
    
    p.drawPixmap(lft, r.y(), *px);
    if (fp != 0)
      // pixmap not really exported in SVG
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);
    
    r.moveBy(0, px->height());
    p.setFont(the_canvas()->get_font(UmlNormalBoldFont));
    p.drawText(r, ::Qt::AlignHCenter, browser_node->get_name());
    
    if (fp != 0) {
      draw_text(r, ::Qt::AlignHCenter, browser_node->get_name(), p.font(), fp);
      fputs("</g>\n", fp);
    }
  }
  else {  
    QColor bckgrnd = p.backgroundColor();
    
    p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);
    
    QColor co = color(used_color);
    
    p.setBackgroundColor(co);
    
    // <<artifact>>/stereotype on 2*font_height with the icon on the right
    // the icon height = 2*font_height
    // the icon width = 3*height/4
    // name on font_height+4 points
    const int four = (int) (4 * the_canvas()->zoom());
    QFontMetrics fm(the_canvas()->get_font(UmlNormalBoldFont));
    const int he = fm.height();
    if (used_color != UmlTransparent) {
      const int shadow = the_canvas()->shadow();
      
      if (shadow != 0) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
	
	p.fillRect (r.right(), r.top() + shadow,
		    shadow, r.height() - 1,
		    ::Qt::darkGray);
	p.fillRect (r.left() + shadow, r.bottom(),
		    r.width() - 1, shadow,
		    ::Qt::darkGray);
	
	if (fp != 0) {
	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);
	  
	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
	}
      }
    }
    
    QRect re = r;
    
    if (used_color != UmlTransparent) {
      p.fillRect(r, co);
      
      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(used_color), 
		r.x(), r.y(), r.width() - 1, r.height() - 1);
    }
    else if (fp != 0)
      fprintf(fp, "\t<rect fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      r.x(), r.y(), r.width() - 1, r.height() - 1);
    
    p.drawRect(r);
    
    r.setHeight(he*2);
    p.setFont(the_canvas()->get_font(UmlNormalFont));
    if (data->get_stereotype()[0]) {
      p.drawText(r, ::Qt::AlignCenter,
//.........这里部分代码省略.........
开发者ID:kralf,项目名称:bouml,代码行数:101,代码来源:ArtifactCanvas.cpp

示例6: draw

void NoteCanvas::draw(QPainter & p)
{
    if (! visible()) return;

    p.setRenderHint(QPainter::Antialiasing, true);
    QRect r = rect();
    QBrush brsh = p.brush();
    QColor bckgrnd = p.backgroundColor();
    QPen fgcolor = p.pen();
    Q3PointArray a(7);

    used_color = (itscolor == UmlDefaultColor)
                 ? the_canvas()->browser_diagram()->get_color(UmlNote)
                 : itscolor;

    QColor co = color(used_color);

    const int corner_size = (int)(NOTE_MARGIN * the_canvas()->zoom());

    a.setPoint(0, r.left(), r.top());
    a.setPoint(1, r.right() - corner_size, r.top());
    a.setPoint(2, r.right() - corner_size, r.top() + corner_size);
    a.setPoint(3, r.right(), r.top() + corner_size);
    a.setPoint(4, r.right(), r.bottom());
    a.setPoint(5, r.left(), r.bottom());
    a.setPoint(6, r.left(), r.top());

    FILE * fp = svg();

    if (fp != 0)
        fputs("<g>\n", fp);

    if (used_color == UmlTransparent) {
        p.setBackgroundMode(::Qt::TransparentMode);
        p.setBackgroundColor(co);
        p.drawPolyline(a);

        if (fp != 0)
            draw_poly(fp, a, UmlTransparent);
    }
    else {
        p.setBackgroundMode(::Qt::OpaqueMode);
        p.setBrush(co);
        p.drawPolygon(a, TRUE, 0, 6);
        p.setBrush(brsh);
        p.setBackgroundColor(co);

        if (fp != 0)
            draw_poly(fp, a, used_color);
    }

    p.drawLine(r.right() - corner_size, r.top(),
               r.right(), r.top() + corner_size);

    if (fp != 0)
        fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
                " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
                r.right() - corner_size, r.top(), r.right(), r.top() + corner_size);

    p.setFont(the_canvas()->get_font(itsfont));

    if (fg_c != UmlTransparent)
        p.setPen(color(fg_c));

    p.drawText(r.left() + corner_size, r.top() + corner_size,
               r.width() - 2 * corner_size, r.height() - 2 * corner_size,
               ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap,
               note);

    if (fp != 0) {
        draw_text(r.left() + corner_size, r.top() + corner_size,
                  r.width() - 2 * corner_size, r.height() - 2 * corner_size,
                  ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap,
                  note, p.font(), fp, fg_c);
        fputs("</g>\n", fp);
    }

    p.setFont(the_canvas()->get_font(UmlNormalFont));
    p.setBackgroundColor(bckgrnd);
    p.setPen(fgcolor);

    if (selected())
        show_mark(p, r);
}
开发者ID:harmegnies,项目名称:douml,代码行数:84,代码来源:NoteCanvas.cpp

示例7: draw

void PackageCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  const BasicData * data = browser_node->get_data();  
  const QPixmap * px = 
    ProfiledStereotypes::diagramPixmap(data->get_stereotype(),
				       the_canvas()->zoom());
  FILE * fp = svg();
  
  if (fp != 0)
    fputs("<g>\n", fp);

  if (px != 0) {
    p.setBackgroundMode(::Qt::TransparentMode);
    
    
    int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();
    
    p.drawPixmap(lft, r.y(), *px);
    if (fp != 0)
      // pixmap not really exported in SVG
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);
    
    r.moveBy(0, px->height());
    p.setFont(the_canvas()->get_font(UmlNormalBoldFont));
    p.drawText(r, ::Qt::AlignHCenter, browser_node->get_name());
    
    // pixmap not yet exported in SVG
    if (fp != 0)
      draw_text(r, ::Qt::AlignHCenter, browser_node->get_name(),
		p.font(), fp);
    p.setFont(the_canvas()->get_font(UmlNormalFont));
  }
  else {
    QColor bckgrnd = p.backgroundColor();
    QColor co = color(used_color);
    
    p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);
    p.setBackgroundColor(co);
    p.setFont(the_canvas()->get_font(UmlNormalFont));
    
    QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
    const int four = (int) (4 * the_canvas()->zoom());
    const int he = fm.height();
    const int shadow = the_canvas()->shadow();
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      r.setRight(r.right() - shadow);
      r.setBottom(r.bottom() - shadow);
    }
    
    r.setWidth(r.width() * 2 / 5);
    r.setHeight(he + four);
    if (used_color != UmlTransparent)
      p.fillRect(r, co);
    
    if (fp != 0)
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(used_color), 
	      r.x(), r.y(), r.width() - 1, r.height() - 1);
    
    p.drawRect(r);
    
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      p.fillRect (r.right(), r.top() + shadow,
		  shadow, r.height() - 1 - shadow,
		  ::Qt::darkGray);
      
      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		QColor(::Qt::darkGray).rgb()&0xffffff,
		r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - shadow - 1);
    }
    
    const char * name = browser_node->get_name();
    
    if (in_tab) {
      p.drawText(r, ::Qt::AlignCenter, name);
      if (fp != 0)
	draw_text(r, ::Qt::AlignCenter, name,
		  p.font(), fp);
    }
    
    r = rect();
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      r.setRight(r.right() - shadow);
      r.setBottom(r.bottom() - shadow);
    }
    
    r.setTop(r.top() + he + four - 1);
    if (used_color != UmlTransparent)
      p.fillRect(r, co);
    
    if (fp != 0)
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
//.........这里部分代码省略.........
开发者ID:kralf,项目名称:bouml,代码行数:101,代码来源:PackageCanvas.cpp

示例8: draw

void UcClassCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
  QFontMetrics fim(the_canvas()->get_font(UmlNormalItalicFont));
  QColor bckgrnd = p.backgroundColor();
  double zoom = the_canvas()->zoom();
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);

  p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);

  QColor co = color(used_color);
  
  if (used_view_mode == asClass) {
    if (used_color != UmlTransparent) {
      const int shadow = the_canvas()->shadow();

      if (shadow != 0) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
	
	p.fillRect (r.right(), r.top() + shadow,
		    shadow, r.height() - 1,
		    ::Qt::darkGray);
	p.fillRect (r.left() + shadow, r.bottom(),
		    r.width() - 1, shadow,
		    ::Qt::darkGray);

	if (fp != 0) {
	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);

	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
	}
      }
    }
    
    p.setBackgroundColor(co);
  
    if (used_color != UmlTransparent) {
      p.fillRect(r, co);

      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(used_color), 
		r.x(), r.y(), r.width() - 1, r.height() - 1);
    }
    else if (fp != 0)
      fprintf(fp, "\t<rect fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      r.x(), r.y(), r.width() - 1, r.height() - 1);

    p.drawRect(r);
  }
  
  const ClassData * data = ((ClassData *) browser_node->get_data());
  const int two = (int) (2 * zoom);
  int he = fm.height() + two;
  
  if (data->get_n_formalparams() != 0)
    r.setTop(r.top() + fm.height());
  
  switch (used_view_mode) {
  case asInterface:
    draw_interface_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (INTERFACE_SIZE * zoom) + two);
    break;
  case asControl:
    draw_control_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (CONTROL_HEIGHT * zoom) + two);
    break;
  case asBoundary:
    draw_boundary_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (BOUNDARY_HEIGHT * zoom) + two);
    break;
  case asEntity:
    draw_entity_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (ENTITY_SIZE * zoom) + two);
    break;
  case asActor:
    {
      QRect ra = r;
      
      ra.setHeight((int) (ACTOR_SIZE * zoom));
      ra.setLeft(ra.left() + 
		 (int) ((ra.width() - ACTOR_SIZE * zoom)/2));
      ra.setWidth(ra.height());
      draw_actor(&p, ra);
    }
    r.setTop(r.top() + (int) (ACTOR_SIZE * zoom) + two);
//.........这里部分代码省略.........
开发者ID:kralf,项目名称:bouml,代码行数:101,代码来源:UcClassCanvas.cpp

示例9: drawButton

/*!\reimp
*/
void QRadioButton::drawButton( QPainter *paint )
{
    QPainter	*p = paint;
    const QColorGroup & g = colorGroup();
    int		 x, y;

    QFontMetrics fm = fontMetrics();
    QSize lsz = fm.size(ShowPrefix, text());
    QSize sz = style().exclusiveIndicatorSize();
    x = text().isEmpty() ? 1 : 0;
    y = (height() - lsz.height() + fm.height() - sz.height())/2;

#ifndef QT_NO_TEXTSTREAM
#define SAVE_RADIOBUTTON_PIXMAPS
#endif

#if defined(SAVE_RADIOBUTTON_PIXMAPS)
    QString pmkey;				// pixmap key
    int kf = 0;
    if ( isDown() )
	kf |= 1;
    if ( isOn() )
	kf |= 2;
    if ( isEnabled() )
	kf |= 4;
    QTextOStream os(&pmkey);
    os << "$qt_radio_" << style().className() << "_"
			 << palette().serialNumber() << "_" << kf;
    QPixmap *pm = QPixmapCache::find( pmkey );
    if ( pm ) {					// pixmap exists
	drawButtonLabel( p );
	p->drawPixmap( x, y, *pm );
	return;
    }
    bool use_pm = TRUE;
    QPainter pmpaint;
    int wx, wy;
    if ( use_pm ) {
	pm = new QPixmap( sz );			// create new pixmap
	CHECK_PTR( pm );
	pmpaint.begin( pm );
	p = &pmpaint;				// draw in pixmap
	wx=x;  wy=y;				// save x,y coords
	x = y = 0;
	p->setBackgroundColor( g.background() );
    }
#endif

#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)

    style().drawExclusiveIndicator(p, x, y, sz.width(), sz.height(), g, isOn(), isDown(), isEnabled() );

#if defined(SAVE_RADIOBUTTON_PIXMAPS)
    if ( use_pm ) {
	pmpaint.end();
	if ( backgroundPixmap() || backgroundMode() == X11ParentRelative ) {
	    QBitmap bm( pm->size() );
	    bm.fill( color0 );
	    pmpaint.begin( &bm );
	    style().drawExclusiveIndicatorMask( &pmpaint, 0, 0, bm.width(), bm.height(), isOn() );
	    pmpaint.end();
	    pm->setMask( bm );
	}
	p = paint;				// draw in default device
	p->drawPixmap( wx, wy, *pm );
	if (!QPixmapCache::insert(pmkey, pm) )	// save in cache
	    delete pm;
    }
#endif
    drawButtonLabel( p );
}
开发者ID:kthxbyte,项目名称:QT2-Linaro,代码行数:73,代码来源:qradiobutton.cpp


注:本文中的QPainter::setBackgroundColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。