Ejemplo n.º 1
0
void DoubleSlider::paintEvent(QPaintEvent *)
{
  QPainter painter(this);
  QStyleOptionSlider option;
  option.initFrom(this);
  option.maximum = maximum();
  option.minimum = minimum();
  option.sliderPosition = v1;
  style()->drawComplexControl(QStyle::CC_Slider, &option, &painter, this);
  QRect handle1 = style()->subControlRect(QStyle::CC_Slider, &option, QStyle::SC_SliderHandle, this);

  option.sliderPosition = v2;
  option.subControls = QStyle::SC_SliderHandle;
  style()->drawComplexControl(QStyle::CC_Slider, &option, &painter, this);
  QRect handle2 = style()->subControlRect(QStyle::CC_Slider, &option, QStyle::SC_SliderHandle, this);
  QPen p;
  p.setColor(QColor(0, 0, 200, 150));
  p.setWidth(handle1.height()-6);
  p.setCapStyle(Qt::FlatCap);
  painter.setPen(p);
  QRect groove = style()->subControlRect(QStyle::CC_Slider, &option, QStyle::SC_SliderGroove, this);
  int wi = handle1.width();
  painter.drawLine(handle1.x()+wi, handle1.height()/2,  handle2.x(), handle1.height()/2);

   painter.end();
}
Ejemplo n.º 2
0
static void ScrollbarThumbElementDraw(
    void *clientData, void *elementRecord, Tk_Window tkwin,
    Drawable d, Ttk_Box b, unsigned state)
{
    if (qApp == NULL) NULL_Q_APP;
    if (state & TTK_STATE_DISABLED) return;
    NULL_PROXY_ORIENTED_WIDGET(TileQt_QScrollBar_Widget);
    Tcl_MutexLock(&tileqtMutex);
    //QPixmap      pixmap(b.width, b.height);
    QPixmap      pixmap = QPixmap::grabWindow(Tk_WindowId(tkwin));
    QPainter     painter(&pixmap);
#ifdef TILEQT_QT_VERSION_4
    wc->TileQt_QScrollBar_Widget->resize(b.width, b.height);
    wc->TileQt_QScrollBar_Widget->setValue(0);
    if (orient == TTK_ORIENT_HORIZONTAL) {
      wc->TileQt_QScrollBar_Widget->setOrientation(Qt::Horizontal);
    } else {
      wc->TileQt_QScrollBar_Widget->setOrientation(Qt::Vertical);
    }
    QStyleOptionSlider option;
    option.initFrom(wc->TileQt_QScrollBar_Widget); option.state |= 
      (QStyle::StateFlag) TileQt_StateTableLookup(scrollbar_statemap, state);
    option.subControls = QStyle::SC_ScrollBarGroove;
    wc->TileQt_Style->drawComplexControl(QStyle::CC_ScrollBar, &option,
                                  &painter, wc->TileQt_QScrollBar_Widget);
#endif /* TILEQT_QT_VERSION_4 */
    // printf("x=%d, y=%d, w=%d, h=%d\n", b.x, b.y, b.width, b.height);
    TileQt_CopyQtPixmapOnToDrawable(pixmap, d, tkwin,
                                    0, 0, b.width, b.height, b.x, b.y);
    Tcl_MutexUnlock(&tileqtMutex);
}
Ejemplo n.º 3
0
static void ScrollbarDownArrowElementDraw(
    void *clientData, void *elementRecord, Tk_Window tkwin,
    Drawable d, Ttk_Box b, unsigned state)
{
    if (qApp == NULL) NULL_Q_APP;
    NULL_PROXY_ORIENTED_WIDGET(TileQt_QScrollBar_Widget);
    Tcl_MutexLock(&tileqtMutex);
    QPixmap      pixmap(b.width, b.height);
    QPainter     painter(&pixmap);
    TILEQT_PAINT_BACKGROUND(b.width, b.height);
#ifdef TILEQT_QT_VERSION_4
    wc->TileQt_QScrollBar_Widget->resize(b.width, b.height);
    wc->TileQt_QScrollBar_Widget->setValue(0);
    if (orient == TTK_ORIENT_HORIZONTAL) {
      wc->TileQt_QScrollBar_Widget->setOrientation(Qt::Horizontal);
    } else {
      wc->TileQt_QScrollBar_Widget->setOrientation(Qt::Vertical);
    }
    QStyleOptionSlider option;
    option.initFrom(wc->TileQt_QScrollBar_Widget); option.state |= 
      (QStyle::StateFlag) TileQt_StateTableLookup(scrollbar_statemap, state);
    option.subControls = QStyle::SC_ScrollBarAddLine;
    wc->TileQt_Style->drawComplexControl(QStyle::CC_ScrollBar, &option,
                                  &painter, wc->TileQt_QScrollBar_Widget);
#endif /* TILEQT_QT_VERSION_4 */
    TileQt_CopyQtPixmapOnToDrawable(pixmap, d, tkwin,
                                    0, 0, b.width, b.height, b.x, b.y);
    Tcl_MutexUnlock(&tileqtMutex);
#ifdef TILEQT_SCROLLBAR_SIZE_DEBUG
    printf("ScrollbarDownArrowElementDraw: width=%d, height=%d, orient=%d\n",
            b.width, b.height, orient); fflush(0);
#endif /* TILEQT_SCROLLBAR_SIZE_DEBUG */
}
Ejemplo n.º 4
0
static void ScrollbarDownArrowElementGeometry(
    void *clientData, void *elementRecord, Tk_Window tkwin,
    int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
    if (qApp == NULL) NULL_Q_APP;
    NULL_PROXY_ORIENTED_WIDGET(TileQt_QScrollBar_Widget);
    Tcl_MutexLock(&tileqtMutex);
    if (orient == TTK_ORIENT_HORIZONTAL) {
      wc->TileQt_QScrollBar_Widget->setOrientation(Qt::Horizontal);
    } else {
      wc->TileQt_QScrollBar_Widget->setOrientation(Qt::Vertical);
    }
#ifdef TILEQT_QT_VERSION_4
    QStyleOptionSlider option;
    option.initFrom(wc->TileQt_QScrollBar_Widget);
    QRect rc = wc->TileQt_Style->subControlRect(QStyle::CC_ScrollBar,
          &option, QStyle::SC_ScrollBarAddLine, wc->TileQt_QScrollBar_Widget);
#endif /* TILEQT_QT_VERSION_4 */
    if (rc.isValid()) {
      *widthPtr = rc.width();
      *heightPtr = rc.height();
      /* Qt Style Fixes: */
      // printf("%s\n", wc->TileQt_Style->name());
      if (TileQt_ThemeIs(wc, "keramik") || TileQt_ThemeIs(wc, "thinkeramik") ||
          TileQt_ThemeIs(wc, "shinekeramik")) {
        // Keramic & ThinKeramic are buggy: Their subcontrol metrics are for 2
        // buttons, not one. Find the smallest dimension, and return a
        // rectangle.
        if (orient == TTK_ORIENT_HORIZONTAL) {
          *heightPtr = 17;
          *widthPtr  = 34;
        } else {
          *heightPtr = 34;
          *widthPtr  = 17;
        }
      } else if (TileQt_ThemeIs(wc, "sgi") ||
                 TileQt_ThemeIs(wc, "compact") ||
                 TileQt_ThemeIs(wc, "platinum") ||
                 TileQt_ThemeIs(wc, "motifplus") ||
                 TileQt_ThemeIs(wc, "cde") ||
                 TileQt_ThemeIs(wc, "motif") ||
                 TileQt_ThemeIs(wc, "windows")) {
        // These styles are buggy?: Some times one dimension is returned as 10,
        // others as 21.
        if (*widthPtr < *heightPtr) *widthPtr  = *heightPtr;
        if (*heightPtr < *widthPtr) *heightPtr = *widthPtr;
      }
    }
    Tcl_MutexUnlock(&tileqtMutex);
    *paddingPtr = Ttk_UniformPadding(0);
#ifdef TILEQT_SCROLLBAR_SIZE_DEBUG
   printf("ScrollbarDownArrowElementGeometry: width=%d, height=%d, orient=%d\n",
            *widthPtr, *heightPtr, orient); fflush(0);
#endif /* TILEQT_SCROLLBAR_SIZE_DEBUG */
}
QStyleOptionSlider MyIntervalSliderOptions::copyOptions() const
{
	QStyleOptionSlider opt;
	opt.initFrom(slider);
	opt.maximum = slider->maximum();
	opt.minimum = slider->minimum();
	opt.orientation = slider->orientation();
	opt.pageStep = slider->pageStep();
	opt.singleStep = slider->singleStep();
	return opt;
}
void GTUtilsMSAEditorSequenceArea::scrollToPosition(HI::GUITestOpStatus &os, const QPoint &position) {
    MSAEditorSequenceArea *msaSeqArea = qobject_cast<MSAEditorSequenceArea*>(GTWidget::findWidget(os, "msa_editor_sequence_area", GTUtilsMdi::activeWindow(os)));
    GT_CHECK(NULL != msaSeqArea, "MSA Editor sequence area is not found");
    GT_CHECK(msaSeqArea->isInRange(position), "Position is out of range");

    // scroll down
    GScrollBar* vBar = msaSeqArea->getVBar();
    GT_CHECK(NULL != vBar, "Vertical scroll bar is not found");

    QStyleOptionSlider vScrollBarOptions;
    vScrollBarOptions.initFrom(vBar);

    while (!msaSeqArea->isSeqVisible(position.y(), false)) {
        const QRect sliderSpaceRect = vBar->style()->subControlRect(QStyle::CC_ScrollBar, &vScrollBarOptions, QStyle::SC_ScrollBarGroove, vBar);
        const QPoint bottomEdge(sliderSpaceRect.width() / 2, sliderSpaceRect.y() + sliderSpaceRect.height());

        GTMouseDriver::moveTo(vBar->mapToGlobal(bottomEdge) - QPoint(0, 1));
        GTMouseDriver::click();
    }

    // scroll right
    GScrollBar* hBar = msaSeqArea->getHBar();
    GT_CHECK(NULL != hBar, "Horisontal scroll bar is not found");

    QStyleOptionSlider hScrollBarOptions;
    hScrollBarOptions.initFrom(hBar);

    while (!msaSeqArea->isPosVisible(position.x(), false)) {
        const QRect sliderSpaceRect = hBar->style()->subControlRect(QStyle::CC_ScrollBar, &hScrollBarOptions, QStyle::SC_ScrollBarGroove, hBar);
        const QPoint rightEdge(sliderSpaceRect.x() + sliderSpaceRect.width(), sliderSpaceRect.height() / 2);

        GTMouseDriver::moveTo(hBar->mapToGlobal(rightEdge) - QPoint(1, 0));
        GTMouseDriver::click();
    }

    SAFE_POINT(msaSeqArea->isVisible(position, false), "The position is still invisible after scrolling", );
}
Ejemplo n.º 7
0
QStyleOptionSlider GTScrollBar::initScrollbarOptions(GUITestOpStatus &os, QScrollBar *scrollbar) {
    GT_CHECK_RESULT(scrollbar != NULL, "scrollbar is NULL", QStyleOptionSlider());
    QStyleOptionSlider options;
    options.initFrom(scrollbar);
    options.sliderPosition = scrollbar->sliderPosition();
    options.maximum = scrollbar->maximum();
    options.minimum = scrollbar->minimum();
    options.singleStep = scrollbar->singleStep();
    options.pageStep = scrollbar->pageStep();
    options.orientation = scrollbar->orientation();
    options.sliderValue = options.sliderPosition;
    options.upsideDown = false;
    options.state = QStyle::State_Sunken | QStyle::State_Enabled;

    return options;
}
Ejemplo n.º 8
0
static QStyleOptionSlider* styleOptionSlider(ScrollbarThemeClient* scrollbar, QWidget* widget = 0)
{
    static QStyleOptionSlider opt;
    if (widget)
        opt.initFrom(widget);
    else
        opt.state |= QStyle::State_Active;

    opt.state &= ~QStyle::State_HasFocus;

    opt.rect = scrollbar->frameRect();
    if (scrollbar->enabled())
        opt.state |= QStyle::State_Enabled;
    if (scrollbar->controlSize() != RegularScrollbar)
        opt.state |= QStyle::State_Mini;
    opt.orientation = (scrollbar->orientation() == VerticalScrollbar) ? Qt::Vertical : Qt::Horizontal;

    if (scrollbar->orientation() == HorizontalScrollbar)
        opt.state |= QStyle::State_Horizontal;
    else
        opt.state &= ~QStyle::State_Horizontal;

    opt.sliderValue = scrollbar->value();
    opt.sliderPosition = opt.sliderValue;
    opt.pageStep = scrollbar->pageStep();
    opt.singleStep = scrollbar->lineStep();
    opt.minimum = 0;
    opt.maximum = qMax(0, scrollbar->maximum());
    ScrollbarPart pressedPart = scrollbar->pressedPart();
    ScrollbarPart hoveredPart = scrollbar->hoveredPart();
    if (pressedPart != NoPart) {
        opt.activeSubControls = scPart(scrollbar->pressedPart());
        if (pressedPart == BackButtonStartPart || pressedPart == ForwardButtonStartPart
            || pressedPart == BackButtonEndPart || pressedPart == ForwardButtonEndPart
            || pressedPart == ThumbPart)
            opt.state |= QStyle::State_Sunken;
    } else
        opt.activeSubControls = scPart(hoveredPart);
    if (hoveredPart != NoPart)
        opt.state |= QStyle::State_MouseOver;
    return &opt;
}
Ejemplo n.º 9
0
// TODO: get rid of this in Qt 4.3
QStyleOptionSlider QxtStarsPrivate::getStyleOption() const
{
    const QxtStars* p = &qxt_p();
    QStyleOptionSlider opt;
    opt.initFrom(p);
    opt.subControls = QStyle::SC_None;
    opt.activeSubControls = QStyle::SC_None;
    opt.orientation = p->orientation();
    opt.maximum = p->maximum();
    opt.minimum = p->minimum();
    opt.upsideDown = (p->orientation() == Qt::Horizontal) ?
                     (p->invertedAppearance() != (opt.direction == Qt::RightToLeft)) : (!p->invertedAppearance());
    opt.direction = Qt::LeftToRight; // we use the upsideDown option instead
    opt.sliderPosition = p->sliderPosition();
    opt.sliderValue = p->value();
    opt.singleStep = p->singleStep();
    opt.pageStep = p->pageStep();
    if (p->orientation() == Qt::Horizontal)
        opt.state |= QStyle::State_Horizontal;
    return opt;
}
Ejemplo n.º 10
0
static void ScrollbarTroughElementDraw(
    void *clientData, void *elementRecord, Tk_Window tkwin,
    Drawable d, Ttk_Box b, unsigned state)
{
    if (qApp == NULL) NULL_Q_APP;
    NULL_PROXY_ORIENTED_WIDGET(TileQt_QScrollBar_Widget);
    Tcl_MutexLock(&tileqtMutex);
    /* We draw the whole scrollbar at once, but without the slider! */
    int width, height;
    //TileQt_QScrollBar_Widget->resize(b.width, b.height);
    if (orient == TTK_ORIENT_HORIZONTAL) {
      width = 2*b.width; height = b.height;
      wc->TileQt_QScrollBar_Widget->setOrientation(Qt::Horizontal);
    } else {
      width = b.width; height = 2*b.height;
      wc->TileQt_QScrollBar_Widget->setOrientation(Qt::Vertical);
    }
#ifdef TILEQT_SCROLLBAR_SIZE_DEBUG
    printf("ScrollbarTroughElementDraw: width=%d, height=%d, orient=%d\n",
            width, height, orient); fflush(0);
#endif /* TILEQT_SCROLLBAR_SIZE_DEBUG */
    wc->TileQt_QScrollBar_Widget->resize(width, height);
    wc->TileQt_QScrollBar_Widget->setValue(0);
    QPixmap      pixmap(width, height);
    QPainter     painter(&pixmap);
    TILEQT_PAINT_BACKGROUND(width, height);

#ifdef TILEQT_QT_VERSION_4
    QStyleOptionSlider option;
    option.initFrom(wc->TileQt_QScrollBar_Widget); option.state |= 
      (QStyle::StateFlag) TileQt_StateTableLookup(scrollbar_statemap, state);
    wc->TileQt_Style->drawComplexControl(QStyle::CC_ScrollBar, &option,
                                  &painter, wc->TileQt_QScrollBar_Widget);
#endif /* TILEQT_QT_VERSION_4 */
    // printf("x=%d, y=%d, w=%d, h=%d\n", b.x, b.y, b.width, b.height);
    TileQt_CopyQtPixmapOnToDrawable(pixmap, d, tkwin,
                                    width-b.width, height-b.height,
                                    b.width, b.height, b.x, b.y);
    Tcl_MutexUnlock(&tileqtMutex);
}
void GTUtilsMSAEditorSequenceArea::scrollToBottom(HI::GUITestOpStatus &os) {
    MSAEditorSequenceArea *msaSeqArea = qobject_cast<MSAEditorSequenceArea*>(GTWidget::findWidget(os, "msa_editor_sequence_area", GTUtilsMdi::activeWindow(os)));
    GT_CHECK(NULL != msaSeqArea, "MSA Editor sequence area is not found");

    // scroll down
    GScrollBar* vBar = msaSeqArea->getVBar();
#ifdef Q_OS_MAC
    vBar->setValue(vBar->maximum());
    return;
#endif
    GT_CHECK(NULL != vBar, "Vertical scroll bar is not found");

    QStyleOptionSlider vScrollBarOptions;
    vScrollBarOptions.initFrom(vBar);

    while (vBar->value() != vBar->maximum()) {
        const QRect sliderSpaceRect = vBar->style()->subControlRect(QStyle::CC_ScrollBar, &vScrollBarOptions, QStyle::SC_ScrollBarGroove, vBar);
        const QPoint bottomEdge(sliderSpaceRect.width() / 2 + 10, sliderSpaceRect.y() + sliderSpaceRect.height());

        GTMouseDriver::moveTo(vBar->mapToGlobal(bottomEdge) - QPoint(0, 1));
        GTMouseDriver::click();
    }
}
Ejemplo n.º 12
0
void ShadowSlider::paintEvent(QPaintEvent * ev)
{
    QSlider::paintEvent(ev);
    QStyleOptionSlider option;

    option.initFrom(this);
    option.dialWrapping = false;
    option.maximum = this->maximum();
    option.minimum = this->minimum();
    option.notchTarget = 0;
    option.orientation = this->orientation();
    option.pageStep = 0;
    option.sliderPosition = m_shadow_position;
    option.sliderValue = m_shadow_position;
    option.tickInterval = 0;
    option.tickPosition = QSlider::NoTicks;
    option.upsideDown = this->orientation() == Qt::Vertical && ! this->invertedAppearance();
    option.subControls = QStyle::SC_DialHandle;

    QPainter painter(this);
    painter.setOpacity(0.5);
    this->style()->drawComplexControl(QStyle::CC_Slider, &option, &painter, this);
}
Ejemplo n.º 13
0
/// XXX
void MiamStyle::drawScrollBar(QPainter *p, const QWidget *widget) const
{
	QStyleOptionSlider scrollbar;
	scrollbar.palette = QApplication::palette();

	const QScrollBar *sc = qobject_cast<const QScrollBar *>(widget);
	scrollbar.initFrom(sc);


	QRect subLineRect = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, &scrollbar, QStyle::SC_ScrollBarSubLine, sc);
	QRect addLineRect = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, &scrollbar, QStyle::SC_ScrollBarAddLine, sc);
	QRect sliderRect = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, &scrollbar, QStyle::SC_ScrollBarSlider, sc);

	//qDebug() << subLineRect << sliderRect << addLineRect;


	if (sc->orientation() == Qt::Vertical) {
		subLineRect.adjust(0, 0, -1, 0);
		addLineRect.adjust(0, 0, -1, 0);
		sliderRect.adjust(0, 0, -1, 0);
	} else {
		subLineRect.adjust(0, 0, 0, -1);
		addLineRect.adjust(0, 0, 0, -1);
		sliderRect.adjust(0, 0, 0, -1);
	}

	p->setPen(Qt::NoPen);
	p->setBrush(scrollbar.palette.window());
	p->drawRect(sc->rect());

	p->setBrush(scrollbar.palette.base().color().darker(125));
	p->drawRect(sliderRect);

	// Highlight
	p->save();
	QPoint pos = sc->mapFromGlobal(QCursor::pos());
	p->setPen(scrollbar.palette.highlight().color());

	if (!sc->isSliderDown()) {
		p->setBrush(scrollbar.palette.highlight().color().lighter());
		if (subLineRect.contains(pos)) {
			p->drawRect(subLineRect);
		} else if (sliderRect.contains(pos)) {
			p->drawRect(sliderRect);
		} else if (addLineRect.contains(pos)) {
			p->drawRect(addLineRect);
		}
	} else {
		p->setBrush(scrollbar.palette.highlight().color());
		//if (_isDown == 0) {
		//	p->drawRect(subLineRect);
		//} else if (_isDown == 1) {
		//	p->drawRect(sliderRect);
		//} else if (_isDown == 2) {
		//	p->drawRect(addLineRect);
		//}
	}
	p->restore();

	// Draw sort indicator
	static const QPointF upArrow[3] = {
		QPointF(0.0, 1.0),
		QPointF(1.0, 0.0),
		QPointF(2.0, 1.0)
	};
	static const QPointF downArrow[3] = {
		QPointF(0.0, 0.0),
		QPointF(2.0, 0.0),
		QPointF(1.0, 1.0)
	};
	static const QPointF leftArrow[3] = {
		QPointF(0.0, 1.0),
		QPointF(1.0, 0.0),
		QPointF(1.0, 2.0)
	};
	static const QPointF rightArrow[3] = {
		QPointF(0.0, 0.0),
		QPointF(1.0, 1.0),
		QPointF(0.0, 2.0)
	};

	// Arrows
	p->save();
	if (scrollbar.palette.windowText().color().value() < 128) {
		p->setPen(scrollbar.palette.dark().color());
		p->setBrush(scrollbar.palette.dark());
	} else {
		p->setPen(scrollbar.palette.mid().color());
		p->setBrush(scrollbar.palette.mid());
	}

	QTransform t;
	float ratio = (float) subLineRect.height() / 4.0;
	t.scale(ratio, ratio);

	if (sc->orientation() == Qt::Vertical) {
		QPolygonF up, down;
		up.append(t.map(upArrow[0]));
		up.append(t.map(upArrow[1]));
		up.append(t.map(upArrow[2]));
		down.append(t.map(downArrow[0]));
		down.append(t.map(downArrow[1]));
		down.append(t.map(downArrow[2]));
		p->translate(subLineRect.width() / 4.0, subLineRect.height() / 3.0);
		p->drawPolygon(up);
		p->translate(0, addLineRect.y());
		p->drawPolygon(down);
	} else {
		QPolygonF left, right;
		left.append(t.map(leftArrow[0]));
		left.append(t.map(leftArrow[1]));
		left.append(t.map(leftArrow[2]));
		right.append(t.map(rightArrow[0]));
		right.append(t.map(rightArrow[1]));
		right.append(t.map(rightArrow[2]));
		p->translate(subLineRect.height() / 3.0, subLineRect.width() / 4.0);
		p->drawPolygon(left);
		p->translate(addLineRect.x(), 0);
		p->drawPolygon(right);
	}
	p->restore();
}