예제 #1
0
void
QvisColorGridWidget::drawItem(QPainter &paint, int index)
{
    if(index >= 0)
    {
        // Get the location of the index'th color box.
        int x, y, boxWidth, boxHeight;
        getItemRect(index, x, y, boxWidth, boxHeight);

        paint.setPen(palette().color(QPalette::Dark));
        paint.drawRect(x, y, boxWidth-1, boxHeight-1);
        paint.fillRect(x + 1, y + 1, boxWidth - 2, boxHeight - 2,
                       paletteColors[index]);

        if (showIndexHints)
        {
            if (.3*paletteColors[index].redF()   +
                    .5*paletteColors[index].greenF() +
                    .2*paletteColors[index].blueF()    < .3)
                paint.setPen(QColor(255,255,255));
            else
                paint.setPen(QColor(0,0,0));
            QString txt;
            if (numGridSquares == MAX_ELEMENT_NUMBER &&
                    index < MAX_ELEMENT_NUMBER)
                txt.sprintf("%s",element_names[index]);
            else
                txt.sprintf("%d",index);
            paint.drawText(QRect(x,y,boxWidth,boxHeight),
                           Qt::AlignHCenter | Qt::AlignVCenter,
                           txt);
        }
    }
}
예제 #2
0
/*
 * Get the text rectangle(below the icon) of an item
 */
void CNOutBarCtrl::getLabelRect(CRect &rc, int i)
{
	getItemRect(rc, i);
	
	if (largeIconView)
		rc.top += LARGE_ICON_H;
	else
		rc.left += SMALL_ICON_W + 2 + 5;
}
void TMenuView::trackMouse( TEvent& e )
{
    TPoint mouse = makeLocal( e.mouse.where );
    for( current = menu->items; current != 0; current = current->next )
        {
        TRect r = getItemRect( current );
        if( r.contains(mouse) )
            return;
        }
}
예제 #4
0
QPoint GTTreeWidget::getItemCenter(GUITestOpStatus &os, QTreeWidgetItem* item) {

    GT_CHECK_RESULT(item != NULL, "item is NULL", QPoint());

    QTreeWidget *treeWidget = item->treeWidget();
    GT_CHECK_RESULT(treeWidget != NULL, "treeWidget is NULL", QPoint());

    QPoint p = getItemRect(os, item).center();

    return treeWidget->viewport()->mapToGlobal(p);
}
예제 #5
0
void InventoryRenderer::highlightItem(ItemPosition pos, byte color) {
    if (pos == -1)
        return;

    Common::Rect r;
    getItemRect(pos, r);

    if (color != 12)
        color = 19;

    _surf.frameRect(r, color);
}
예제 #6
0
/*
 * Get the icon rectangle of an item
 */
void CNOutBarCtrl::getIconRect(CRect &rc, int i)
{
	getItemRect(rc, i);
	
	if (largeIconView) {
		rc.left += (rc.Width() - LARGE_ICON_W) / 2;
		rc.right = rc.left + LARGE_ICON_W;
		rc.bottom = rc.top + LARGE_ICON_H;
	} else {
		rc.top += (rc.Height() - SMALL_ICON_H) / 2;
		rc.bottom = rc.top + SMALL_ICON_H;
		rc.left += 2;
		rc.right = rc.left + SMALL_ICON_W;
	}
}
예제 #7
0
void InventoryRenderer::drawItem(ItemPosition pos, ItemName name) {
    Common::Rect r;
    getItemRect(pos, r);
    byte* d = (byte*)_surf.getBasePtr(r.left, r.top);
    drawItem(name, d, _surf.pitch);
}
ushort TMenuView::execute()
{
    Boolean    autoSelect = False;
    menuAction action;
    char   ch;
    ushort result = 0;
    TMenuItem *itemShown = 0;
    TMenuItem *p;
    TMenuView *target;
    TRect  r;
    TEvent e;

    current = menu->deflt;
    do  {
        action = doNothing;
        getEvent(e);
        switch (e.what)
            {
            case  evMouseDown:
                if( mouseInView(e.mouse.where) || mouseInOwner(e) )
                    {
                    trackMouse(e);
                    if( size.y == 1 )
                        autoSelect = True;
                    }
                else
                    action =  doReturn;
                break;
            case  evMouseUp:
                trackMouse(e);
                if( mouseInOwner(e) )
                    current = menu->deflt;
                else if( current != 0 && current->name != 0 )
                    action = doSelect;
                else
                    action = doReturn;
                break;
            case  evMouseMove:
                if( e.mouse.buttons != 0 )
                    {
                    trackMouse(e);
                    if( !(mouseInView(e.mouse.where) || mouseInOwner(e)) &&
                        mouseInMenus(e) )
                        action = doReturn;
                    }
                break;
            case  evKeyDown:
                switch( ctrlToArrow(e.keyDown.keyCode) )
                    {
                    case  kbUp:
                    case  kbDown:
                        if( size.y != 1 )
                            trackKey(Boolean(ctrlToArrow(e.keyDown.keyCode) == kbDown));
                        else if( e.keyDown.keyCode == kbDown )
                            autoSelect =  True;
                        break;
                    case  kbLeft:
                    case  kbRight:
                        if( parentMenu == 0 )
                            trackKey(Boolean(ctrlToArrow(e.keyDown.keyCode) == kbRight));
                        else
                            action =  doReturn;
                        break;
                    case  kbHome:
                    case  kbEnd:
                        if( size.y != 1 )
                            {
                            current = menu->items;
                            if( e.keyDown.keyCode == kbEnd )
                                trackKey(False);
                            }
                        break;
                    case  kbEnter:
                        if( size.y == 1 )
                            autoSelect =  True;
                        action = doSelect;
                        break;
                    case  kbEsc:
                        action = doReturn;
                        if( parentMenu == 0 || parentMenu->size.y != 1 )
                            clearEvent(e);
                        break;
                    default:
                        target = this;
                        ch = getAltChar(e.keyDown.keyCode);
                        if( ch == 0 )
                            ch = e.keyDown.charScan.charCode;
                        else
                            target = topMenu();
                        p = target->findItem(ch);
                        if( p == 0 )
                            {
                            p = topMenu()->hotKey(e.keyDown.keyCode);
                            if( p != 0 && commandEnabled(p->command) )
                                {
                                result = p->command;
                                action = doReturn;
                                }
                            }
                        else if( target == this )
                            {
                            if( size.y == 1 )
                                autoSelect = True;
                            action = doSelect;
                            current = p;
                            }
                        else if( parentMenu != target ||
                                 parentMenu->current != p )
                                action = doReturn;
                    }
                break;
            case  evCommand:
                if( e.message.command == cmMenu )
                    {
                    autoSelect = False;
                    if (parentMenu != 0 )
                        action = doReturn;
                    }
                else
                    action = doReturn;
                break;
            }

        if( itemShown != current )
            {
            itemShown =  current;
            drawView();
            }

        if( (action == doSelect || (action == doNothing && autoSelect)) &&
            current != 0 &&
            current->name != 0 )
                if( current->command == 0 )
                    {
                    if( (e.what & (evMouseDown | evMouseMove)) != 0 )
                        putEvent(e);
                    r = getItemRect( current );
                    r.a.x = r.a.x + origin.x;
                    r.a.y = r.b.y + origin.y;
                    r.b = owner->size;
                    if( size.y == 1 )
                        r.a.x--;
                    target = topMenu()->newSubView(r, current->subMenu,this);
                    result = owner->execView(target);
                    destroy( target );
                    }
                else if( action == doSelect )
                    result = current->command;

        if( result != 0 && commandEnabled(result) )
            {
            action =  doReturn;
            clearEvent(e);
            }
        } while( action != doReturn );

    if( e.what != evNothing &&
        (parentMenu != 0 || e.what == evCommand))
            putEvent(e);
    if( current != 0 )
        {
        menu->deflt = current;
        current = 0;
        drawView();
        }
    return result;
}