예제 #1
0
void MVScrollBar::drawPart(int part,ibool down)
/****************************************************************************
*
* Function:		MVScrollBar::drawPart
* Parameters:	part	- Code of the part to draw
*				down	- True if part is down
*
* Description:	Draws the part in the state 'down'.
*
****************************************************************************/
{
	switch (part) {
		case sbLeftArrow:
			drawLeftArrow(down);
			break;
		case sbRightArrow:
			drawRightArrow(down);
			break;
		case sbPageLeft:
		case sbPageRight:
		case sbThumb:
			drawThumb(down ? part : -1);
			break;
		}
}
예제 #2
0
void MVScrollBar::update()
/****************************************************************************
*
* Function:		MVScrollBar::update
*
* Description:	Updates the state of the scroll bar thumb, if the scroll
*				bar is visible.
*
****************************************************************************/
{
	if ((flags & sbInteracting) || !(flags & sbDirty))
		return;

	if ((state & sfVisible) && (state & sfExposed)) {
		setupOwnerViewport();
		MS_obscure();
		if (flags & sbDirtyLeft)
			drawLeftArrow(false);
		if (flags & sbDirtyRight)
			drawRightArrow(false);
		if (flags & sbDirtyThumb)
			drawThumb(-1);
		MS_show();
		resetViewport();
		}
}
예제 #3
0
//! Draw the slider into the specified rectangle.
void QwtSlider::drawSlider(QPainter *p, const QRect &r)
{
    QRect cr(r);

    if (d_bgStyle & BgTrough)
    {
        qDrawShadePanel(p, r.x(), r.y(),
            r.width(), r.height(),
            colorGroup(), TRUE, d_borderWidth,0);

        cr.setRect(r.x() + d_borderWidth,
            r.y() + d_borderWidth,
            r.width() - 2 * d_borderWidth,
            r.height() - 2 * d_borderWidth);

        p->fillRect(cr.x(), cr.y(), cr.width(), cr.height(), 
            colorGroup().brush(QColorGroup::Mid));
    }

    if ( d_bgStyle & BgSlot)
    {
        int ws = 4;
        int ds = d_thumbLength / 2 - 4;
        if ( ds < 1 )
            ds = 1;

        QRect rSlot;
        if (orientation() == Qt::Horizontal)
        {
            if ( cr.height() & 1 )
                ws++;
            rSlot = QRect(cr.x() + ds, 
                    cr.y() + (cr.height() - ws) / 2,
                    cr.width() - 2 * ds, ws);
        }
        else
        {
            if ( cr.width() & 1 )
                ws++;
            rSlot = QRect(cr.x() + (cr.width() - ws) / 2, 
                    cr.y() + ds,
                    ws, cr.height() - 2 * ds);
        }
        p->fillRect(rSlot.x(), rSlot.y(), rSlot.width(), rSlot.height(),
            colorGroup().brush(QColorGroup::Dark));
        qDrawShadePanel(p, rSlot.x(), rSlot.y(),
            rSlot.width(), rSlot.height(), colorGroup(), TRUE, 1 ,0);

    }

    if ( isValid() )
        drawThumb(p, cr, xyPosition(value()));
}
예제 #4
0
void MVScrollBar::changeValue(int part)
/****************************************************************************
*
* Function:		MVScrollBar::changeValue
* Parameters:	part	- Scroll bar arrow hit
*
* Description:	Adjusts the scroll bar value depending on which part of
*				the scroll bar was hit.
*
****************************************************************************/
{
	int	oldValue = value;

	switch (part) {
		case sbLeftArrow:
			value -= arrowStep;
			break;
		case sbRightArrow:
			value += arrowStep;
			break;
		case sbPageLeft:
			value -= pageStep;
			break;
		case sbPageRight:
			value += pageStep;
			break;
		}
	if (value < minVal)	value = minVal;
	if (value > maxVal)	value = maxVal;

	if (oldValue != value) {
		moveThumb();
		drawThumb(part);

		// We need to redraw the opposite arrow if the arrow just became
		// active again.
		if (oldValue == minVal)
			drawLeftArrow(false);
		if (oldValue == maxVal)
			drawRightArrow(false);

		MV_message(owner,evBroadcast,cmScrollBarChanged,this);
		}
}
예제 #5
0
void MVScrollBar::changeValue(const MVPoint& global)
/****************************************************************************
*
* Function:		MVScrollBar::changeValue
* Parameters:	global	- New location of the mouse cursor
*
* Description:	Converts the mouse cursor location into a new value for
*				the scroll bar thumb, repositions the thumb and redraws
*				it.
*
****************************************************************************/
{
	MVPoint p(global);
	globalToLocal(p);

	int		left,right,start;
	int	oldValue = value;

	if (vertical) {
		start = p.y - 7;
		left = leftArrow.bottom();
		right = rightArrow.top();
		}
	else {
		start = p.x - 7;
		left = leftArrow.right();
		right = rightArrow.left();
		}

	if (start < left)		start = left;
	if (start > right-(_MV_sysScrollBarWidth+1))
		start = right-(_MV_sysScrollBarWidth+1);

	value = ((2*(maxVal-minVal)*(long)(start-left))
			/ (right-left-(_MV_sysScrollBarWidth+1))+1)/2;

	if (oldValue != value) {
		moveThumb();
		drawThumb(sbThumb);
		MV_message(owner,evBroadcast,cmScrollBarChanged,this);
		}
}
예제 #6
0
void MVScrollBar::draw(const MVRect&)
/****************************************************************************
*
* Function:		MVScrollBar::draw
* Parameters:	clip	- Clipping rectangle to use when drawing
*
* Description:	Draws the scroll bar in the current state.
*
****************************************************************************/
{
	if (flags & sbInteracting)
		return;

	// Draw the main body of the scroll bar inset into the screen
	MS_obscure();
	MV_setBorderColors(getColor(scHighlight),getColor(scShadow));
	MV_drawBorder(bounds,MV_BDR_INSET,1);

	drawLeftArrow(false);
	drawRightArrow(false);
	drawThumb(-1);
	MS_show();
}
예제 #7
0
/**
 * Updates the thumb according to the current list position.
 */
void ScrollBar::draw()
{
	Surface::draw();
	drawTrack();
	drawThumb();
}
예제 #8
0
/*! 
   Draw the slider into the specified rectangle.

   \param painter Painter
   \param r Rectangle
*/
void QwtSlider::drawSlider(QPainter *painter, const QRect &r)
{
    QRect cr(r);

    if (d_data->bgStyle & BgTrough)
    {
        qDrawShadePanel(painter, r.x(), r.y(),
            r.width(), r.height(),
#if QT_VERSION < 0x040000
            colorGroup(), 
#else
            palette(), 
#endif
            true, d_data->borderWidth,0);

        cr.setRect(r.x() + d_data->borderWidth,
            r.y() + d_data->borderWidth,
            r.width() - 2 * d_data->borderWidth,
            r.height() - 2 * d_data->borderWidth);

        painter->fillRect(cr.x(), cr.y(), cr.width(), cr.height(), 
#if QT_VERSION < 0x040000
            colorGroup().brush(QColorGroup::Mid)
#else
            palette().brush(QPalette::Mid)
#endif
        );
    }

    if ( d_data->bgStyle & BgSlot)
    {
        int ws = 4;
        int ds = d_data->thumbLength / 2 - 4;
        if ( ds < 1 )
            ds = 1;

        QRect rSlot;
        if (orientation() == Qt::Horizontal)
        {
            if ( cr.height() & 1 )
                ws++;
            rSlot = QRect(cr.x() + ds, 
                    cr.y() + (cr.height() - ws) / 2,
                    cr.width() - 2 * ds, ws);
        }
        else
        {
            if ( cr.width() & 1 )
                ws++;
            rSlot = QRect(cr.x() + (cr.width() - ws) / 2, 
                    cr.y() + ds,
                    ws, cr.height() - 2 * ds);
        }
        painter->fillRect(rSlot.x(), rSlot.y(), rSlot.width(), rSlot.height(),
#if QT_VERSION < 0x040000
            colorGroup().brush(QColorGroup::Dark)
#else
            palette().brush(QPalette::Dark)
#endif
        );
        qDrawShadePanel(painter, rSlot.x(), rSlot.y(),
            rSlot.width(), rSlot.height(), 
#if QT_VERSION < 0x040000
            colorGroup(), 
#else
            palette(), 
#endif
            true, 1 ,0);

    }

    if ( isValid() )
        drawThumb(painter, cr, xyPosition(value()));
}