void Patch::drawButton() {

    ofPushStyle();

    portsSize(height - 8);

    ofFill();
    ofSetColor(color);
    if (hover) {
        ofSetColor(color - ofColor(20));
    }
    ofRect(x, y, width, height);

    ofSetColor(150);
    ofRect(x, y, height, height);

    drawPorts(height - 8);

    ofPopStyle();
}
Esempio n. 2
0
//! \brief Draw wire.
void Wire::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
        QWidget *widget)
{
    Q_UNUSED(widget);
    QPen savedPen;

    /* save painter */
    savedPen = painter->pen();

    if(option->state & QStyle::State_Selected) {
        painter->setPen(QPen(invertcolor(unselectedWire), wirewidth));
    }
    else {
        painter->setPen(QPen(unselectedWire, wirewidth));
    }

    QList<WireLine>::const_iterator it = m_wLines.constBegin();
    QList<WireLine>::const_iterator end = m_wLines.constEnd();

    while(it != end) {
        painter->drawLine(*it);
        ++it;
    }
    /*
       {
    //debugging purpose only.
    if(0) {
    painter->setPen(Qt::darkGreen);
    painter->drawPath(shape());
    }
    }*/

    /* restore pen */
    painter->setPen(savedPen);
    drawPorts(m_ports, painter, option);

}
Esempio n. 3
0
void QDebugView::paintEvent(QPaintEvent * /*event*/)
{
    if (g_pBoard == NULL) return;

    QPainter painter(this);
    painter.fillRect(0,0, this->width(), this->height(), Qt::white);

    QFont font = Common_GetMonospacedFont();
    painter.setFont(font);
    QFontMetrics fontmetrics(font);
    int cxChar = fontmetrics.averageCharWidth();
    int cyLine = fontmetrics.height();

    CProcessor* pDebugPU = g_pBoard->GetCPU();
    ASSERT(pDebugPU != NULL);
    WORD* arrR = m_wDebugCpuR;
    BOOL* arrRChanged = m_okDebugCpuRChanged;

    drawProcessor(painter, pDebugPU, cxChar * 2, 1 * cyLine, arrR, arrRChanged);

    // Draw stack
    drawMemoryForRegister(painter, 6, pDebugPU, 35 * cxChar, 1 * cyLine);

    drawPorts(painter, 57 * cxChar, 1 * cyLine);

    // Draw focus rect
    if (hasFocus())
    {
        QStyleOptionFocusRect option;
        option.initFrom(this);
        option.state |= QStyle::State_KeyboardFocusChange;
        option.backgroundColor = QColor(Qt::gray);
        option.rect = this->rect();
        style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this);
    }
}
void Patch::drawPatch() {

    ofPoint mouse(ofGetMouseX(), ofGetMouseY());

    ofPushStyle();

    portsSize(20);

    if (max_y > 0.0f) {
        height = max_y - y + 10;
    }



    title_box = font.getBBox(name + " - " + "uid: " + ofToString(uid), 16,
            (int) (x + 5), (int) (y - 3));
    title_box.y -= 5;
    title_box.height += 10;

    if (title_box.inside(mouse)) {
        ofSetColor(ofColor::steelBlue);
    } else {
        ofSetColor(text_color);
    }


    font.draw(name + " - " + "uid: " + ofToString(uid), 16,
            (int) (x + 5), (int) (y - 3));

    address_box = font.getBBox(address.str, 16,
            (int) (x + 5), (int) (y + height + 14));
    address_box.y -= 5;
    address_box.height += 10;

    if (address_box.inside(mouse)) {
        ofSetColor(ofColor::steelBlue);
    } else {
        ofSetColor(text_color);
    }

    font.draw(address.str, 16,
              (int) (x + 5), (int) (y + height + 14));

    ofFill();

    if (status == UNRESPONSIVE) {
        ofSetColor(ofColor::gray);
    } else {
        ofSetColor(color);
        if (hover) {
            ofSetColor(color - ofColor(20));
        }
    }

    ofRect(x, y, width, height);

    drawPorts(20);


    ofPopStyle();
}