Ejemplo n.º 1
0
void PaintedSlider::paintEvent(WPaintDevice *paintDevice)
{
  if (slider_->tickPosition()) {
    WPainter painter(paintDevice);

    int w, h;

    if (slider_->orientation() == Horizontal) {
      w = (int)width().toPixels();
      h = (int)height().toPixels();
    } else {
      w = (int)height().toPixels();
      h = (int)width().toPixels();

      painter.translate(0, w);
      painter.rotate(-90);
    }

    int tickInterval = slider_->tickInterval();
    int r = range();

    if (tickInterval == 0)
      tickInterval = r / 2;

    double tickStep = ((double)w - (HANDLE_WIDTH - 10)) / (r / tickInterval);

    if (tickStep <= 0)
      return;

    WPen pen;
    pen.setColor(WColor(0xd7, 0xd7, 0xd7));
    pen.setCapStyle(FlatCap);
    pen.setWidth(1);
    painter.setPen(pen);

    int y1 = h / 4;
    int y2 = h / 2 - 4;
    int y3 = h / 2 + 4;
    int y4 = h - h/4;

    for (unsigned i = 0; ; ++i) {
      int x = (HANDLE_WIDTH - 10)/2 + (int) (i * tickStep);

      if (x > w - (HANDLE_WIDTH - 10)/2)
	break;

      if (slider_->tickPosition() & WSlider::TicksAbove)
	painter.drawLine(x + 0.5, y1, x + 0.5, y2);
      if (slider_->tickPosition() & WSlider::TicksBelow)
	painter.drawLine(x + 0.5, y3, x + 0.5, y4);
    }
  }
}
Ejemplo n.º 2
0
void PaintBrush::paintEvent(WPaintDevice *paintDevice)
{
  WPainter painter(paintDevice);
  painter.setRenderHint(WPainter::Antialiasing);
  
  WPen pen;
  pen.setWidth(3);
  pen.setColor(color_);
  pen.setCapStyle(FlatCap);
  pen.setJoinStyle(MiterJoin);
  painter.setPen(pen);
  painter.drawPath(path_);

  path_ = WPainterPath(path_.currentPosition());
}
Ejemplo n.º 3
0
WPen WDataSeries::pen() const
{
  if (customFlags_.test(CustomFlag::Pen))
    return pen_;
  else
    if (chart_)
      if (type_ == SeriesType::Bar)
	return chart_->palette()
	  ->borderPen(chart_->seriesIndexOf(*this));
      else
	return chart_->palette()
	  ->strokePen(chart_->seriesIndexOf(*this));
    else {
      WPen defaultPen;
      defaultPen.setCapStyle(PenCapStyle::Round);
      defaultPen.setJoinStyle(PenJoinStyle::Round);
      return defaultPen;
    }
}
Ejemplo n.º 4
0
void WSlider::paintTick(WPainter& painter, int value, int x, int y)
{
  if (!tickPosition_.empty()) {
    int h = 0;

    if (orientation_ == Orientation::Horizontal)
      h = (int)painter.device()->height().toPixels();
    else
      h = (int)painter.device()->width().toPixels();

    WPen pen;
    pen.setColor(WColor(0xd7, 0xd7, 0xd7));
    pen.setCapStyle(PenCapStyle::Flat);
    pen.setWidth(1);
    painter.setPen(pen);

    int y1 = h / 4;
    int y2 = h / 2 - 4;
    int y3 = h / 2 + 4;
    int y4 = h - h/4;

    switch (orientation_) {
    case Orientation::Horizontal:
      if (tickPosition_.test(WSlider::TickPosition::TicksAbove))
	painter.drawLine(x + 0.5, y1, x + 0.5, y2);
      if (tickPosition_.test(WSlider::TickPosition::TicksBelow))
	painter.drawLine(x + 0.5, y3, x + 0.5, y4);

      break;
    case Orientation::Vertical:
      if (tickPosition_.test(WSlider::TickPosition::TicksAbove))
	painter.drawLine(y1, y + 0.5, y2, y + 0.5);
      if (tickPosition_.test(WSlider::TickPosition::TicksBelow))
	painter.drawLine(y3, y + 0.5, y4, y + 0.5);
    }
  }
}