Ejemplo n.º 1
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();
		}
}
Ejemplo n.º 2
0
void MVListBase::drawCell(int i,int j)
/****************************************************************************
*
* Function:     MVListBase::drawCell
* Parameters:   i,j - Location of the cell to draw
*
* Description:  Draws the cell, clipped to the bounds of the list. This
*               routine assumes that the list is entirely visible.
*
****************************************************************************/
{
    MS_obscure();

    if (visible.includes(i,j)) {
        // Compute the bounding box for the cell
        int dx = (i-visible.left()) * cellSize.x;
        int dy = (j-visible.top()) * cellSize.y;

        MVRect r(bounds.left()+leftIndent+dx,
                 bounds.top()+topIndent+dy,
                 bounds.left()+leftIndent+dx+cellSize.x,
                 bounds.top()+topIndent+dy+cellSize.y);
        r &= MVRect(bounds.left()+leftIndent,
                    bounds.top()+topIndent,
                    bounds.right()-rightIndent,
                    bounds.bottom()-botIndent);
        if (!r.isEmpty()) {
            dc.setClipRect(r);
            drawCell(i,j,r);
            }
        }

    MS_show();
}
Ejemplo n.º 3
0
void MVListBase::vScrollTo(int j,ibool redraw)
/****************************************************************************
*
* Function:     MVListBase::vScrollTo
* Parameters:   j       - New cell to scroll to in vertical direction
*               redraw  - True if list should be redrawn
*
* Description:  Scrolls the list to start at the new cell 'j' in the
*               vertical direction, redrawing all necessary cells to do
*               this.
*
]****************************************************************************/
{
    if (visible.top() != j) {
        // Setup the viewport for redrawing the list directly, and redraw
        // it.
        MVRect   v(visible & range);
        MVRect  b(bounds.left()+leftIndent,
                  bounds.top()+topIndent,
                  bounds.left()+leftIndent+cellSize.x*(visible.right()-visible.left()),
                  bounds.top()+topIndent+cellSize.y*(visible.bottom()-visible.top()));
        int     dy = (v.top() - j) * cellSize.y;

        if (b.right() > (bounds.right()-rightIndent))
            b.right() = bounds.right()-rightIndent;
        if (b.bottom() > (bounds.bottom()-botIndent))
            b.bottom() = bounds.bottom()-botIndent;

        visible.moveTo(hScroll ? hScroll->getValue() : 0,j);
        vScroll->setValue(j);

        if (redraw) {
            CHECK(owner != NULL);
            setupOwnerViewport();
            MS_obscure();

            if (j < v.top()) {
                b.bottom() -= dy;
                if (!b.isEmpty())
                    dc.bitBlt(dc,b,b.left(),bounds.top()+topIndent+dy,MGL_REPLACE_MODE);
                for (int y = j; y < v.top(); y++)
                    for (int x = v.left(); x < v.right(); x++)
                        drawCell(x,y);
                }
            else {
                b.top() -= dy;
                if (!b.isEmpty())
                    dc.bitBlt(dc,b,b.left(),bounds.top()+topIndent,MGL_REPLACE_MODE);
                j -= v.top();
                for (int y = 0; y < j; y++)
                    for (int x = v.left(); x < v.right(); x++)
                        drawCell(x,v.bottom()+y);
                }
            MS_show();
            resetViewport();
            }
        }
}
Ejemplo n.º 4
0
void MVScrollBar::drawThumb(int which)
/****************************************************************************
*
* Function:		MVScrollBar::drawThumb
* Parameters:	which	- Which part of bar to highlight.
*
* Description:	Draws the thumb portion of the scroll bar, highlighting
*				the specific portion of the scroll bar.
*
****************************************************************************/
{
	MS_obscure();
	if (maxVal == minVal) {
		dc.setColor(getColor(scScrollBarInterior));
		dc.fillRect(thumb);
		}
	else {
		attributes_t attr;
		dc.getAttributes(attr);

		dc.setColor(getColor(scScrollBarInterior));
		dc.setPenStyle(MGL_BITMAP_OPAQUE);
		dc.setPenBitmapPattern(0,MGL_GRAY_FILL);
		dc.usePenBitmapPattern(0);

		if (vertical) {
			dc.setBackColor(getColor(
				which == (int)sbPageLeft ? scSelectScrollBar : scUnselectScrollBar));
			dc.fillRect(thumb.left(),leftArrow.bottom(),
				thumb.right(),thumb.top());
			dc.setBackColor(getColor(
				which == (int)sbPageRight ? scSelectScrollBar : scUnselectScrollBar));
			dc.fillRect(thumb.left(),thumb.bottom(),
				thumb.right(),rightArrow.top());
			}
		else {
			dc.setBackColor(getColor(
				which == (int)sbPageLeft ? scSelectScrollBar : scUnselectScrollBar));
			dc.fillRect(leftArrow.right(),thumb.top(),
				thumb.left(),thumb.bottom());
			dc.setBackColor(getColor(
				which == (int)sbPageRight ? scSelectScrollBar : scUnselectScrollBar));
			dc.fillRect(thumb.right(),thumb.top(),
				rightArrow.left(),thumb.bottom());
			}

		dc.setPenStyle(MGL_BITMAP_SOLID);
		dc.fillRect(thumb);
		MV_drawBorder(thumb,(which == (int)sbThumb ? MV_BDR_INSET : MV_BDR_OUTSET),1);

		dc.restoreAttributes(attr);
		}
	MS_show();

	flags &= ~sbDirtyThumb;
}
Ejemplo n.º 5
0
void MVListBase::hScrollTo(int i,ibool redraw)
/****************************************************************************
*
* Function:     MVListBase::hScrollTo
* Parameters:   i       - New cell to scroll to in horizontal direction
*               redraw  - True if list should be redrawn
*
* Description:  Scrolls the list to start at the new cell 'i' in the
*               horizontal direction, redrawing all necessary cells to do
*               this.
*
****************************************************************************/
{
    if (visible.left() != i) {
        // Setup the viewport for redrawing the list directly, and redraw
        // it.
        MVRect  v(visible & range);
        MVRect  b(bounds.left()+leftIndent,
                  bounds.top()+topIndent,
                  bounds.right()-rightIndent,
                  bounds.bottom()-botIndent);
        int     dx = (v.left() - i) * cellSize.x;

        visible.moveTo(i,vScroll ? vScroll->getValue() : 0);
        hScroll->setValue(i);

        if (redraw) {
            CHECK(owner != NULL);
            setupOwnerViewport();
            MS_obscure();

            if (i < v.left()) {
                b.right() -= dx;
                if (!b.isEmpty())
                    dc.bitBlt(dc,b,bounds.left()+leftIndent+dx,b.top(),MGL_REPLACE_MODE);
                for (int y = v.top(); y < v.bottom(); y++)
                    for (int x = i; x < v.left(); x++)
                        drawCell(x,y);
                }
            else {
                b.left() -= dx;
                if (!b.isEmpty())
                    dc.bitBlt(dc,b,bounds.left()+leftIndent,b.top(),MGL_REPLACE_MODE);
                i -= v.left();
                for (int y = v.top(); y < v.bottom(); y++)
                    for (int x = 0; x < i; x++)
                        drawCell(v.right() + x,y);
                }
            MS_show();
            resetViewport();
            }
        }
}
Ejemplo n.º 6
0
void MVListBase::refresh()
/****************************************************************************
*
* Function:     MVListBase::refresh
*
* Description:  Refreshes the list by refreshing each of the visible cells.
*
****************************************************************************/
{
    MVRect   v(visible & range);

    MS_obscure();
    for (int i = v.left(); i < v.right(); i++)
        for (int j = v.top(); j < v.bottom(); j++)
            refreshCell(i,j);
    MS_show();
}
Ejemplo n.º 7
0
void MVRenderArea::paint()
/****************************************************************************
*
* Function:     MVRenderArea::paint
*
* Description:  This function paints the view with the current clip
*               region. We set the viewport to the coordinate space for
*               the view and then call the render function clipping to
*               each of the clip rectangles in the clip region.
*
****************************************************************************/
{
    MS_obscure();
    setupViewport();
    clipAndRenderView = this;
    clipRgn.traverse(clipAndRender);
    resetViewport();
    MS_show();
}
Ejemplo n.º 8
0
void MVScrollBar::drawRightArrow(ibool down)
/****************************************************************************
*
* Function:		MVScrollBar::drawRightArrow
* Parameters:	down	- True if arrow is pressed down
*
* Description:	Draw's the right/bottom arrow portion of the scroll bar. Assume
*				the outer border for the scroll bar exists, and the
*				border colors are set up.
*
****************************************************************************/
{
	MS_obscure();
	dc.setColor(getColor(scScrollBarInterior));
	dc.fillRect(rightArrow);
	MV_drawBorder(rightArrow,down ? MV_BDR_INSET : MV_BDR_OUTSET,1);
	dc.setColor(getColor(
		value < maxVal ? scActiveScrollArrow : scInactiveScrollArrow));

	int cx = down + (rightArrow.left() + rightArrow.right()-1)/2;
	int cy = down + (rightArrow.top() + rightArrow.bottom()-1)/2;

	if (vertical) {
		// Draw the bottom arrow

		dc.line(cx-3,cy-1,cx,cy+2);
		dc.line(cx+1,cy+2,cx+4,cy-1);
		dc.line(cx-2,cy-1,cx,cy+1);
		dc.line(cx+1,cy+1,cx+3,cy-1);
		}
	else {
		// Draw the right arrow

		dc.line(cx-1,cy-3,cx+2,cy);
		dc.line(cx+2,cy+1,cx-1,cy+4);
		dc.line(cx-1,cy-2,cx+1,cy);
		dc.line(cx+1,cy+1,cx-1,cy+3);
		}
	MS_show();
	flags &= ~sbDirtyRight;
}
Ejemplo n.º 9
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();
}
Ejemplo n.º 10
0
void MVListBase::draw(const MVRect&)
/****************************************************************************
*
* Function:     MVListBase::draw
* Parameters:   clip    - Clipping rectangle to use when drawing
*
* Description:  Draws the representation of the list.
*
****************************************************************************/
{
    MS_obscure();

    MVRect  clipBounds(bounds.left()+leftIndent,
                       bounds.top()+topIndent,
                       bounds.right()-rightIndent,
                       bounds.bottom()-rightIndent);

    // Clear the background for the list
    dc.setColor(getColor(scListInterior));
    dc.fillRect(bounds);
    MV_setBorderColors(getColor(scShadow),getColor(scHighlight));
    MV_drawBorder(bounds,MV_BDR_OUTSET,1);
    MV_setBorderColors(getColor(scBlack),getColor(scButtonFace));
    MV_drawBorder(bounds.insetBy(1,1),MV_BDR_OUTSET,1);

    // Draw each of the items in the list. Note that we set up the clip
    // rectangle to clip everything to the bounds of the list correctly,
    // and that we only draw those items that are visible and within the
    // range of selectable items.
    MVRect  v(visible & range);
    MVRect  start(bounds.left()+leftIndent,
                  bounds.top()+topIndent,
                  bounds.left()+leftIndent+cellSize.x,
                  bounds.top()+topIndent+cellSize.y);

    for (int i = v.left(); i < v.right(); i++) {
        MVRect r(start);
        for (int j = v.top(); j < v.bottom(); j++) {
            MVRect c(r);
            c &= clipBounds;
            if (!c.isEmpty()) {
                dc.setClipRect(c);
                drawCell(i,j,r);
                }
            r.top() += cellSize.y;  r.bottom() += cellSize.y;
            }
        start.left() += cellSize.x; start.right() += cellSize.x;
        }

    if (range.isEmpty()) {
        // There is nothing to draw in the list (it is currently empty),
        // but if the list is selected then we should draw a dotted outline
        // around the first empty cell to ensure the user knows when the
        // list is selected.
        if ((state & sfFocused)) {
            attributes_t attr;
            dc.getAttributes(attr);
            dc.setColor(getColor(scListCell));
            dc.setPenStyle(MGL_BITMAP_TRANSPARENT);
            dc.setPenBitmapPattern(0,MGL_GRAY_FILL);
            dc.usePenBitmapPattern(0);
            drawRect(bounds.left()+leftIndent,
                     bounds.top()+topIndent,
                     bounds.left()+leftIndent+cellSize.x,
                     bounds.top()+topIndent+cellSize.y);
            dc.restoreAttributes(attr);
            }
        }

    MS_show();
}
Ejemplo n.º 11
0
wxScreenDC::~wxScreenDC()
{
    MS_show();
}