Пример #1
0
void KColorButton::dragEnterEvent(QDragEnterEvent *event)
{
    event->accept(KColorDrag::canDecode(event) && isEnabled());
}
Пример #2
0
void MainView2D::createFixtureItem(quint32 fxID, quint16 headIndex, quint16 linkedIndex,
                                   QVector3D pos, bool mmCoords)
{
    if (isEnabled() == false)
        return;

    if (m_gridItem == NULL)
       initialize2DProperties();

    qDebug() << "[MainView2D] Creating fixture with ID" << fxID << headIndex << linkedIndex << "pos:" << pos;

    Fixture *fixture = m_doc->fixture(fxID);
    if (fixture == NULL)
        return;

    quint32 itemID = FixtureUtils::fixtureItemID(fxID, headIndex, linkedIndex);
    QLCFixtureMode *fxMode = fixture->fixtureMode();
    QQuickItem *newFixtureItem = qobject_cast<QQuickItem*>(fixtureComponent->create());
    quint32 itemFlags = m_monProps->fixtureFlags(fxID, headIndex, linkedIndex);

    newFixtureItem->setParentItem(m_gridItem);
    newFixtureItem->setProperty("itemID", itemID);

    if (itemFlags & MonitorProperties::HiddenFlag)
        newFixtureItem->setProperty("visible", false);

    if (fxMode != NULL && fixture->type() != QLCFixtureDef::Dimmer)
    {
        QLCPhysical phy = fxMode->physical();

        //qDebug() << "Current mode fixture heads:" << fxMode->heads().count();
        newFixtureItem->setProperty("headsNumber", fxMode->heads().count());

        if (fixture->channelNumber(QLCChannel::Pan, QLCChannel::MSB) != QLCChannel::invalid())
        {
            int panDeg = phy.focusPanMax();
            if (panDeg == 0) panDeg = 360;
            newFixtureItem->setProperty("panMaxDegrees", panDeg);
        }
        if (fixture->channelNumber(QLCChannel::Tilt, QLCChannel::MSB) != QLCChannel::invalid())
        {
            int tiltDeg = phy.focusTiltMax();
            if (tiltDeg == 0) tiltDeg = 270;
            newFixtureItem->setProperty("tiltMaxDegrees", tiltDeg);
        }
    }

    QPointF itemPos;
    QSizeF size = FixtureUtils::item2DDimension(fixture->type() == QLCFixtureDef::Dimmer ? NULL : fxMode,
                                                m_monProps->pointOfView());

    if (mmCoords == false && (pos.x() != 0 || pos.y() != 0))
    {
        float gridUnits = m_monProps->gridUnits() == MonitorProperties::Meters ? 1000.0 : 304.8;
        itemPos.setX((pos.x() * gridUnits) / m_cellPixels);
        itemPos.setY((pos.y() * gridUnits) / m_cellPixels);
    }

    if (m_monProps->containsItem(fxID, headIndex, linkedIndex))
    {
        itemPos = FixtureUtils::item2DPosition(m_monProps, m_monProps->pointOfView(), pos);
        newFixtureItem->setProperty("rotation",
                                    FixtureUtils::item2DRotation(m_monProps->pointOfView(),
                                                                 m_monProps->fixtureRotation(fxID, headIndex, linkedIndex)));
    }
    else
    {
        itemPos = FixtureUtils::available2DPosition(m_doc, m_monProps->pointOfView(),
                                                    QRectF(itemPos.x(), itemPos.y(), size.width(), size.height()));
        // add the new fixture to the Doc monitor properties
        QVector3D newPos = FixtureUtils::item3DPosition(m_monProps, itemPos, 1000.0);
        m_monProps->setFixturePosition(fxID, headIndex, linkedIndex, newPos);
        m_monProps->setFixtureFlags(fxID, headIndex, linkedIndex, 0);
        Tardis::instance()->enqueueAction(Tardis::FixtureSetPosition, itemID, QVariant(QVector3D(0, 0, 0)), QVariant(newPos));
    }

    newFixtureItem->setProperty("mmXPos", itemPos.x());
    newFixtureItem->setProperty("mmYPos", itemPos.y());
    newFixtureItem->setProperty("mmWidth", size.width());
    newFixtureItem->setProperty("mmHeight", size.height());
    newFixtureItem->setProperty("fixtureName", fixture->name());

    // and finally add the new item to the items map
    m_itemsMap[itemID] = newFixtureItem;

    QByteArray values;
    updateFixture(fixture, values);
}
Пример #3
0
void QgsSpinBox::changeEvent( QEvent *event )
{
  QSpinBox::changeEvent( event );
  mClearButton->setVisible( mShowClearButton && isEnabled() && value() != minimum() );
}
Пример #4
0
void ccHObject::draw(CC_DRAW_CONTEXT& context)
{
    if (!isEnabled())
        return;

    //are we currently drawing objects in 2D or 3D?
    bool draw3D = MACRO_Draw3D(context);

    //the entity must be either visible and selected, and of course it should be displayed in this context
    bool drawInThisContext = ((m_visible || m_selected) && m_currentDisplay == context._win);

    //no need to display anything but clouds and meshes in "element picking mode"
    drawInThisContext &= (( !MACRO_DrawPointNames(context) || isKindOf(CC_POINT_CLOUD) ) ||
                          ( !MACRO_DrawTriangleNames(context) || isKindOf(CC_MESH) ));

    //apply 3D 'temporary' transformation (for display only)
    if (draw3D && m_glTransEnabled)
    {
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
        glMultMatrixf(m_glTrans.data());
    }

    //draw entity
    if (m_visible && drawInThisContext)
    {
        if (( !m_selected || !MACRO_SkipSelected(context) ) &&
                ( m_selected || !MACRO_SkipUnselected(context) ))
        {
            //apply default color (in case of)
            glColor3ubv(context.pointsDefaultCol);

            drawMeOnly(context);

            //draw name in 3D (we display it in the 2D foreground layer in fact!)
            if (m_showNameIn3D && MACRO_Draw2D(context) && MACRO_Foreground(context) && !MACRO_DrawNames(context))
                drawNameIn3D(context);
        }
    }

    //draw entity's children
    for (Container::iterator it = m_children.begin(); it!=m_children.end(); ++it)
        (*it)->draw(context);

    //if the entity is currently selected, we draw its bounding-box
    if (m_selected && draw3D && drawInThisContext && !MACRO_DrawNames(context))
    {
        switch (m_selectionBehavior)
        {
        case SELECTION_AA_BBOX:
            drawBB(context.bbDefaultCol);
            break;
        case SELECTION_FIT_BBOX:
        {
            ccGLMatrix trans;
            ccBBox box = getFitBB(trans);
            if (box.isValid())
            {
                glMatrixMode(GL_MODELVIEW);
                glPushMatrix();
                glMultMatrixf(trans.data());
                box.draw(context.bbDefaultCol);
                glPopMatrix();
            }
        }
        break;
        case SELECTION_IGNORED:
            break;
        default:
            assert(false);
        }
    }

    if (draw3D && m_glTransEnabled)
        glPopMatrix();
}
void QGCRadioChannelDisplay::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    
    //Values range from 0-3000.
    //1500 is the middle, static servo value.
    QPainter painter(this);




    int fontHeight = painter.fontMetrics().height();
    int twiceFontHeight = fontHeight * 2;

    painter.setBrush(Qt::Dense4Pattern);
    painter.setPen(QColor::fromRgb(128,128,64));

    int curVal = m_value;
    if (curVal > m_max)  {
        curVal = m_max;
    }
    if (curVal < m_min) {
        curVal = m_min;
    }

    if (m_orientation == Qt::Vertical)
    {
        QLinearGradient gradientBrush(0, 0, this->width(), this->height());
        gradientBrush.setColorAt(1.0,DIMMEST_COLOR);
        gradientBrush.setColorAt(0.5,MIDBRIGHT_COLOR);
        gradientBrush.setColorAt(0.0, BRIGHTEST_COLOR);

        //draw border
        painter.drawRect(0,0,width()-1,(height()-1) - twiceFontHeight);
        painter.setPen(QColor::fromRgb(50,255,50));
        painter.setBrush(Qt::SolidPattern);

        //draw the text value of the widget, and its label
        painter.setPen(QColor::fromRgb(255,255,255));
        painter.drawText((width()/2.0) - (painter.fontMetrics().width(m_name)/2.0),((height()-3) - (fontHeight*1)),m_name);

        if (isEnabled()) {
            QString valStr = QString::number(m_value);
            painter.drawText((width()/2.0) - (painter.fontMetrics().width(valStr)/2.0),((height()-3) - (fontHeight * 0)),valStr);

            painter.setPen(QColor::fromRgb(128,128,64));
            painter.setBrush(gradientBrush);

            if (!m_showMinMax) {
                //draw just the value
                int newval = (height()-2-twiceFontHeight) * ((float)(curVal - m_min) / ((m_max-m_min)+1));
                int yVal = (height()-2-twiceFontHeight) - newval;
                painter.drawRect(1,yVal,width()-3,((height()-2) - yVal - twiceFontHeight));
            }
            else {
                //draw the value
                int newval = (height()-2-twiceFontHeight) * ((float)(curVal / 3001.0));
                int yVal = (height()-2-twiceFontHeight) - newval;
                painter.drawRect(1,yVal,width()-3,((height()-2) - yVal - twiceFontHeight));

                //draw min max indicator bars
                painter.setPen(QColor::fromRgb(255,0,0));
                painter.setBrush(Qt::NoBrush);

                int yMax = (height()-3 - twiceFontHeight) - (((height()-3-twiceFontHeight) * ((float)m_max / 3000.0)));
                int yMin = (height()-3 - twiceFontHeight) - (((height()-3-twiceFontHeight) * ((float)m_min / 3000.0)));
                painter.drawRect(2,yMax,width()-3,yMin - yMax);

                //draw min and max labels
                QString minstr = QString::number(m_min);
                painter.drawText((width() / 2.0) - (painter.fontMetrics().width("min")/2.0),yMin,"min");
                painter.drawText((width() / 2.0) - (painter.fontMetrics().width(minstr)/2.0),yMin + fontHeight,minstr);

                QString maxstr = QString::number(m_max);
                painter.drawText((width() / 2.0) - (painter.fontMetrics().width("max")/2.0),yMax,"max");
                painter.drawText((width() / 2.0) - (painter.fontMetrics().width(maxstr)/2.0),yMax + fontHeight,maxstr);

            }
        }
    }
    else //horizontal orientation
    {
        QLinearGradient hGradientBrush(0, 0, this->width(), this->height());
        hGradientBrush.setColorAt(0.0,DIMMEST_COLOR);
        hGradientBrush.setColorAt(0.5,MIDBRIGHT_COLOR);
        hGradientBrush.setColorAt(1.0, BRIGHTEST_COLOR);

        //draw the value
        painter.drawRect(0,0,width()-1,(height()-1) - twiceFontHeight);
        painter.setPen(QColor::fromRgb(50,255,50));
        painter.setBrush(hGradientBrush);

        //draw the value string
        painter.setPen(QColor::fromRgb(255,255,255));
        painter.drawText((width()/2.0) - (painter.fontMetrics().width(m_name)/2.0),((height()-3) - (fontHeight*1)),m_name);

        if (isEnabled()) {
            QString valstr = QString::number(m_value);
            painter.drawText((width()/2.0) - (painter.fontMetrics().width(valstr)/2.0),((height()-3) - (fontHeight * 0)),valstr);

            painter.setPen(QColor::fromRgb(0,128,0));
            painter.setBrush(hGradientBrush);

            if (!m_showMinMax) {
                //draw just the value
                painter.drawRect(1,1,(width()-3) * ((float)(curVal-m_min) / (m_max-m_min)),(height()-3) - twiceFontHeight);
            }
            else {
                //draw the value
                painter.drawRect(1,1,(width()-3) * ((float)curVal / 3000.0),(height()-3) - twiceFontHeight);

                 //draw the min and max bars
                painter.setBrush(Qt::NoBrush);
                painter.setPen(QColor::fromRgb(255,0,0));
                painter.drawRect(width() * ((float)m_min / 3000.0),2,((width()-1) * ((float)m_max / 3000.0)) - (width() * ((float)m_min / 3000.0)),(height()-5) - twiceFontHeight);

                //draw the min and max strings
                QString minstr = QString::number(m_min);
                painter.drawText((width() * ((float)m_min / 3000.0)) - (painter.fontMetrics().width("min")/2.0),((height()-3) - (painter.fontMetrics().height()*1)),"min");
                painter.drawText((width() * ((float)m_min / 3000.0)) - (painter.fontMetrics().width(minstr)/2.0),((height()-3) - (painter.fontMetrics().height() * 0)),minstr);

                QString maxstr = QString::number(m_max);
                painter.drawText((width() * ((float)m_max / 3000.0)) - (painter.fontMetrics().width("max")/2.0),((height()-3) - (painter.fontMetrics().height()*1)),"max");
                painter.drawText((width() * ((float)m_max / 3000.0)) - (painter.fontMetrics().width(maxstr)/2.0),((height()-3) - (painter.fontMetrics().height() * 0)),maxstr);
            }
        }
    }
}
Пример #6
0
void HalRgbLed::setBlueValue(int value) {
  if (isEnabled()) {
    analogWrite(LED_BLUE, 255-value);
    blueValue = value;
  }
}
Пример #7
0
void QStyleItem::initStyleOption()
{
    QString type = elementType();
    if (m_styleoption)
        m_styleoption->state = 0;

    switch (m_itemType) {
    case Button: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionButton();

            QStyleOptionButton *opt = qstyleoption_cast<QStyleOptionButton*>(m_styleoption);
            opt->text = text();
            opt->features = (activeControl() == "default") ?
                            QStyleOptionButton::DefaultButton :
                            QStyleOptionButton::None;
        }
        break;
    case ItemRow: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionViewItemV4();

            QStyleOptionViewItemV4 *opt = qstyleoption_cast<QStyleOptionViewItemV4*>(m_styleoption);
            opt->features = 0;
            if (activeControl() == "alternate")
                opt->features |= QStyleOptionViewItemV2::Alternate;
        }
        break;

    case Splitter: {
            if (!m_styleoption) {
                m_styleoption = new QStyleOption;
            }
        }
        break;

    case Item: {
            if (!m_styleoption) {
                m_styleoption = new QStyleOptionViewItemV4();
            }
            QStyleOptionViewItemV4 *opt = qstyleoption_cast<QStyleOptionViewItemV4*>(m_styleoption);
            opt->features = QStyleOptionViewItemV4::HasDisplay;
            opt->text = text();
            opt->textElideMode = Qt::ElideRight;
            QPalette pal = m_styleoption->palette;
            pal.setBrush(QPalette::Base, Qt::NoBrush);
            m_styleoption->palette = pal;
        }
        break;
    case Header: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionHeader();

            QStyleOptionHeader *opt = qstyleoption_cast<QStyleOptionHeader*>(m_styleoption);
            opt->text = text();
            opt->sortIndicator = activeControl() == "down" ?
                                 QStyleOptionHeader::SortDown
                                     : activeControl() == "up" ?
                                     QStyleOptionHeader::SortUp : QStyleOptionHeader::None;
            if (activeControl() == QLatin1String("beginning"))
                opt->position = QStyleOptionHeader::Beginning;
            else if (activeControl() == QLatin1String("end"))
                opt->position = QStyleOptionHeader::End;
            else if (activeControl() == QLatin1String("only"))
                opt->position = QStyleOptionHeader::OnlyOneSection;
            else
                opt->position = QStyleOptionHeader::Middle;

        }
        break;
    case ToolButton :{
            if (!m_styleoption)
                m_styleoption = new QStyleOptionToolButton();

            QStyleOptionToolButton *opt =
                    qstyleoption_cast<QStyleOptionToolButton*>(m_styleoption);
            opt->subControls = QStyle::SC_ToolButton;
            opt->state |= QStyle::State_AutoRaise;
            opt->activeSubControls = QStyle::SC_ToolButton;
        }
        break;
    case ToolBar: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionToolBar();
        }
        break;
    case Tab: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionTabV3();

            QStyleOptionTabV3 *opt =
                    qstyleoption_cast<QStyleOptionTabV3*>(m_styleoption);
            opt->text = text();
            opt->shape = info() == "South" ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
            if (activeControl() == QLatin1String("beginning"))
                opt->position = QStyleOptionTabV3::Beginning;
            else if (activeControl() == QLatin1String("end"))
                opt->position = QStyleOptionTabV3::End;
            else if (activeControl() == QLatin1String("only"))
                opt->position = QStyleOptionTabV3::OnlyOneTab;
            else
                opt->position = QStyleOptionTabV3::Middle;

        } break;

    case Menu: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionMenuItem();
        }
        break;
    case Frame: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionFrameV3();

            QStyleOptionFrameV3 *opt = qstyleoption_cast<QStyleOptionFrameV3*>(m_styleoption);
            opt->frameShape = QFrame::StyledPanel;
            opt->lineWidth = 1;
            opt->midLineWidth = 1;
        }
        break;
    case TabFrame: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionTabWidgetFrameV2();
            QStyleOptionTabWidgetFrameV2 *opt = qstyleoption_cast<QStyleOptionTabWidgetFrameV2*>(m_styleoption);
            opt->shape = (info() == "South") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
            if (minimum())
                opt->selectedTabRect = QRect(value(), 0, minimum(), height());
            opt->tabBarSize = QSize(minimum() , height());
            // oxygen style needs this hack
            opt->leftCornerWidgetSize = QSize(value(), 0);
        }
        break;
    case MenuItem:
    case ComboBoxItem:
        {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionMenuItem();

            QStyleOptionMenuItem *opt = qstyleoption_cast<QStyleOptionMenuItem*>(m_styleoption);
            opt->checked = false;
            opt->text = text();
            opt->palette = widget()->palette();
        }
        break;
    case CheckBox:
    case RadioButton:
        {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionButton();

            QStyleOptionButton *opt = qstyleoption_cast<QStyleOptionButton*>(m_styleoption);
            if (!on())
                opt->state |= QStyle::State_Off;
            opt->text = text();
        }
        break;
    case Edit: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionFrameV3();

            QStyleOptionFrameV3 *opt = qstyleoption_cast<QStyleOptionFrameV3*>(m_styleoption);
            opt->lineWidth = 1; // this must be non-zero
        }
        break;
    case ComboBox :{
            if (!m_styleoption)
                m_styleoption = new QStyleOptionComboBox();
            QStyleOptionComboBox *opt = qstyleoption_cast<QStyleOptionComboBox*>(m_styleoption);
            opt->currentText = text();
        }
        break;
    case SpinBox: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionSpinBox();

            QStyleOptionSpinBox *opt = qstyleoption_cast<QStyleOptionSpinBox*>(m_styleoption);
            opt->frame = true;
            if (value() & 0x1)
                opt->activeSubControls = QStyle::SC_SpinBoxUp;
            else if (value() & (1<<1))
                opt->activeSubControls = QStyle::SC_SpinBoxDown;
            opt->subControls = QStyle::SC_All;
            opt->stepEnabled = 0;
            if (value() & (1<<2))
                opt->stepEnabled |= QAbstractSpinBox::StepUpEnabled;
            if (value() & (1<<3))
                opt->stepEnabled |= QAbstractSpinBox::StepDownEnabled;
        }
        break;
    case Slider:
    case Dial:
        {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionSlider();

            QStyleOptionSlider *opt = qstyleoption_cast<QStyleOptionSlider*>(m_styleoption);
            opt->minimum = minimum();
            opt->maximum = maximum();
            // ### fixme - workaround for KDE inverted dial
            opt->sliderPosition = value();
            opt->singleStep = step();

            if (opt->singleStep)
            {
                qreal numOfSteps = (opt->maximum - opt->minimum) / opt->singleStep;

                // at least 5 pixels between tick marks
                if (numOfSteps && (width() / numOfSteps < 5))
                    opt->tickInterval = qRound((5*numOfSteps / width()) + 0.5)*step();
                else
                    opt->tickInterval = opt->singleStep;
            }
            else // default Qt-components implementation
                opt->tickInterval = opt->maximum != opt->minimum ? 1200 / (opt->maximum - opt->minimum) : 0;

            if (style() == QLatin1String("oxygen") && type == QLatin1String("dial"))
                opt->sliderValue  = maximum() - value();
            else
                opt->sliderValue = value();
            opt->subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle;
            opt->tickPosition = (activeControl() == "below") ?
                                QSlider::TicksBelow : (activeControl() == "above" ?
                                                       QSlider::TicksAbove:
                                                       QSlider::NoTicks);
            if (opt->tickPosition != QSlider::NoTicks)
                opt->subControls |= QStyle::SC_SliderTickmarks;

            opt->activeSubControls = QStyle::SC_None;
        }
        break;
    case ProgressBar: {
            if (QProgressBar *bar= qobject_cast<QProgressBar*>(widget())){
                bar->setMaximum(maximum());
                bar->setMinimum(minimum());
                if (maximum() != minimum())
                    bar->setValue(1);
            }
            if (!m_styleoption)
                m_styleoption = new QStyleOptionProgressBarV2();

            QStyleOptionProgressBarV2 *opt = qstyleoption_cast<QStyleOptionProgressBarV2*>(m_styleoption);
            opt->orientation = horizontal() ? Qt::Horizontal : Qt::Vertical;
            opt->minimum = minimum();
            opt->maximum = maximum();
            opt->progress = value();
        }
        break;
    case GroupBox: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionGroupBox();

            QStyleOptionGroupBox *opt = qstyleoption_cast<QStyleOptionGroupBox*>(m_styleoption);
            opt->text = text();
            opt->lineWidth = 1;
            opt->subControls = QStyle::SC_GroupBoxLabel;
            if (sunken()) // Qt draws an ugly line here so I ignore it
                opt->subControls |= QStyle::SC_GroupBoxFrame;
            else
                opt->features |= QStyleOptionFrameV2::Flat;
            if (activeControl() == "checkbox")
                opt->subControls |= QStyle::SC_GroupBoxCheckBox;

            if (QGroupBox *group= qobject_cast<QGroupBox*>(widget())) {
                group->setTitle(text());
                group->setCheckable(opt->subControls & QStyle::SC_GroupBoxCheckBox);
            }
        }
        break;
    case ScrollBar: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionSlider();

            QStyleOptionSlider *opt = qstyleoption_cast<QStyleOptionSlider*>(m_styleoption);
            opt->minimum = minimum();
            opt->maximum = maximum();
            opt->pageStep = horizontal() ? width() : height();
            opt->orientation = horizontal() ? Qt::Horizontal : Qt::Vertical;
            opt->sliderPosition = value();
            opt->sliderValue = value();
            opt->activeSubControls = (activeControl() == QLatin1String("up"))
                                     ? QStyle::SC_ScrollBarSubLine :
                                     (activeControl() == QLatin1String("down")) ?
                                     QStyle::SC_ScrollBarAddLine:
                                     QStyle::SC_ScrollBarSlider;

            opt->sliderValue = value();
            opt->subControls = QStyle::SC_All;

            QScrollBar *bar = qobject_cast<QScrollBar *>(widget());
            bar->setMaximum(maximum());
            bar->setMinimum(minimum());
            bar->setValue(value());
        }
        break;
    default:
        break;
    }

    if (!m_styleoption)
        m_styleoption = new QStyleOption();

    m_styleoption->rect = QRect(m_paintMargins, m_paintMargins, width() - 2* m_paintMargins, height() - 2 * m_paintMargins);

    if (isEnabled())
        m_styleoption->state |= QStyle::State_Enabled;
    if (m_active)
        m_styleoption->state |= QStyle::State_Active;
    if (m_sunken)
        m_styleoption->state |= QStyle::State_Sunken;
    if (m_raised)
        m_styleoption->state |= QStyle::State_Raised;
    if (m_selected)
        m_styleoption->state |= QStyle::State_Selected;
    if (m_focus)
        m_styleoption->state |= QStyle::State_HasFocus;
    if (m_on)
        m_styleoption->state |= QStyle::State_On;
    if (m_hover)
        m_styleoption->state |= QStyle::State_MouseOver;
    if (m_horizontal)
        m_styleoption->state |= QStyle::State_Horizontal;

    if (widget()) {
        widget()->ensurePolished();
        if (type == QLatin1String("tab") && style() != QLatin1String("mac")) {
            // Some styles actually check the beginning and end position
            // using widget geometry, so we have to trick it
            widget()->setGeometry(0, 0, width(), height());
            if (activeControl() != "beginning")
                m_styleoption->rect.translate(1, 0); // Don't position at start of widget
            if (activeControl() != "end")
                widget()->resize(200, height());
        }
#ifdef Q_WS_WIN
        else widget()->resize(width(), height());
#endif

        widget()->setEnabled(isEnabled());
        m_styleoption->fontMetrics = widget()->fontMetrics();
        if (!m_styleoption->palette.resolve())
            m_styleoption->palette = widget()->palette();
        if (m_hint.contains("mac.mini")) {
            widget()->setAttribute(Qt::WA_MacMiniSize);
        } else if (m_hint.contains("mac.small")) {
            widget()->setAttribute(Qt::WA_MacSmallSize);
        }
    }
}
bool AudioPlayer::set_value(std::string value)
{
    if (!isEnabled()) return true;

    std::string val = value;

    cInfoDom("output") << "AudioPlayer(" << get_param("id") << "): got action \"" << val << "\"";

    //list of all available player functions
    if (val == "play")
        Play();
    else if (val == "pause")
        Pause();
    else if (val == "stop")
        Stop();
    else if (val == "next")
        Next();
    else if (val == "previous")
        Previous();
    else if (val == "power on")
        Power(true);
    else if (val == "power off")
        Power(false);
    else if (val.compare(0, 6, "sleep ") == 0)
    {
        val.erase(0, 6);
        Sleep(atoi(val.c_str()));
    }
    else if (val.compare(0, 5, "sync ") == 0)
    {
        val.erase(0, 5);
        Synchronize(val.c_str(), true);
    }
    else if (val.compare(0, 7, "unsync ") == 0)
    {
        val.erase(0, 7);
        Synchronize(val.c_str(), false);
    }
    else if (val.compare(0, 5, "play ") == 0)
    {
        val.erase(0, 5);
        playlist_play_items(val);
    }
    else if (val.compare(0, 4, "add ") == 0)
    {
        val.erase(0, 4);
        playlist_add_items(val);
    }
    else if (val.compare(0, 11, "volume set ") == 0)
    {
        val.erase(0, 11);
        int vol;
        from_string(val, vol);

        set_volume(vol);
    }
    else if (val.compare(0, 10, "volume up ") == 0)
    {
        val.erase(0, 10);
        AudioPlayerData data;
        data.svalue = val;

        get_volume(sigc::mem_fun(*this, &AudioPlayer::get_volume_cb), data);
    }
    else if (val.compare(0, 12, "volume down ") == 0)
    {
        val.erase(0, 12);
        AudioPlayerData data;
        data.svalue = "-" + val;

        get_volume(sigc::mem_fun(*this, &AudioPlayer::get_volume_cb), data);
    }

    EventManager::create(CalaosEvent::EventIOChanged,
                         { { "id", get_param("id") },
                           { "state", value } });

    return true;
}
Пример #9
0
//! called if an event happened.
bool CGUIModalScreen::OnEvent(const SEvent& event)
{
    if (!isEnabled() || !isVisible() )
        return IGUIElement::OnEvent(event);

    switch(event.EventType)
	{
	case EET_GUI_EVENT:
		switch(event.GUIEvent.EventType)
		{
		case EGET_ELEMENT_FOCUSED:
			if ( event.GUIEvent.Caller == this && isMyChild(event.GUIEvent.Element) )
			{
				Environment->removeFocus(0);	// can't setFocus otherwise at it still has focus here
				Environment->setFocus(event.GUIEvent.Element);
				MouseDownTime = os::Timer::getTime();
				return true;
			}			
			if ( !canTakeFocus(event.GUIEvent.Caller))
			{
				if ( !Children.empty() )
					Environment->setFocus(*(Children.begin()));
				else
					Environment->setFocus(this);
			}
			IGUIElement::OnEvent(event);
			return false;
		case EGET_ELEMENT_FOCUS_LOST:
			if ( !canTakeFocus(event.GUIEvent.Element))
            {
            	if ( isMyChild(event.GUIEvent.Caller) )
				{
					if ( !Children.empty() )
						Environment->setFocus(*(Children.begin()));
					else
						Environment->setFocus(this);
				}
				else
				{
					MouseDownTime = os::Timer::getTime();
				}
				return true;
			}
			else
			{
				return IGUIElement::OnEvent(event);
			}
		case EGET_ELEMENT_CLOSED:
			// do not interfere with children being removed
			return IGUIElement::OnEvent(event);
		default:
			break;
		}
		break;
	case EET_MOUSE_INPUT_EVENT:
		if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
		{
			MouseDownTime = os::Timer::getTime();
        }
	default:
		break;
	}

	IGUIElement::OnEvent(event);	// anyone knows why events are passed on here? Causes p.e. problems when this is child of a CGUIWindow.

	return true; // absorb everything else
}
Пример #10
0
void QToolBoxButton::drawButton( QPainter *p )
{
    QStyle::SFlags flags = QStyle::Style_Default;
    const QColorGroup &cg = colorGroup();

    if ( isEnabled() )
	flags |= QStyle::Style_Enabled;
    if ( selected )
	flags |= QStyle::Style_Selected;
    if ( hasFocus() )
	flags |= QStyle::Style_HasFocus;
    if (isDown())
	flags |= QStyle::Style_Down;
    style().drawControl( QStyle::CE_ToolBoxTab, p, parentWidget(), rect(), cg, flags );

    QPixmap pm = icon.pixmap( QIconSet::Small, isEnabled() ? QIconSet::Normal : QIconSet::Disabled );

    QRect cr = style().subRect( QStyle::SR_ToolBoxTabContents, this );
    QRect tr, ir;
    int ih = 0;
    if ( pm.isNull() ) {
	tr = cr;
	tr.addCoords( 4, 0, -8, 0 );
    } else {
	int iw = pm.width() + 4;
	ih = pm.height();
	ir = QRect( cr.left() + 4, cr.top(), iw + 2, ih );
	tr = QRect( ir.right(), cr.top(), cr.width() - ir.right() - 4, cr.height() );
    }

    if ( selected && style().styleHint( QStyle::SH_ToolBox_SelectedPageTitleBold ) ) {
	QFont f( p->font() );
	f.setBold( TRUE );
	p->setFont( f );
    }

    QString txt;
    if ( p->fontMetrics().width(label) < tr.width() ) {
	txt = label;
    } else {
	txt = label.left( 1 );
	int ew = p->fontMetrics().width( "..." );
	int i = 1;
	while ( p->fontMetrics().width( txt ) + ew +
		p->fontMetrics().width( label[i] )  < tr.width() )
	    txt += label[i++];
	txt += "...";
    }

    if ( ih )
	p->drawPixmap( ir.left(), (height() - ih) / 2, pm );

    QToolBox *tb = (QToolBox*)parentWidget();

    const QColor* fill = 0;
    if ( selected &&
	 style().styleHint( QStyle::SH_ToolBox_SelectedPageTitleBold ) &&
	 tb->backgroundMode() != NoBackground )
	fill = &cg.color( QPalette::foregroundRoleFromMode( tb->backgroundMode() ) );

    int alignment = AlignLeft | AlignVCenter | ShowPrefix;
    if (!style().styleHint(QStyle::SH_UnderlineAccelerator, this))
	alignment |= NoAccel;
    style().drawItem( p, tr, alignment, cg,
		      isEnabled(), 0, txt, -1, fill );

    if ( !txt.isEmpty() && hasFocus() )
	style().drawPrimitive( QStyle::PE_FocusRect, p, tr, cg );
}
Пример #11
0
//------------------------------------------------------------------------------
// serialize
//------------------------------------------------------------------------------
std::ostream& TargetData::serialize(std::ostream& sout, const int i, const bool slotsOnly) const
{
    int j = 0;
    if ( !slotsOnly ) {
        sout << "( " << getFactoryName() << std::endl;
        j = 4;
    }

    BaseClass::serialize(sout,i+j,true);

    indent(sout,i+j);
    sout << "enabled: " << (isEnabled() ? "true" : "false")  << std::endl;

    indent(sout,i+j);
    sout << "completed: " << (isCompleted() ? "true" : "false")  << std::endl;

    {
        const Basic::String* s = getWpnType();
        if (s != 0) {
            indent(sout,i+j);
            sout << "weaponType: " << s  << std::endl;
        }
    }

    indent(sout,i+j);
    sout << "quantity: " << getQuantity()  << std::endl;

    indent(sout,i+j);
    sout << "manualAssign: " <<  (getManualAssign() ? "true" : "false")  << std::endl;

    {
        unsigned int st = getStickType();
        if (st == MIDPOINT) {
            indent(sout,i+j);
            sout << "stickType: " << "MIDPOINT" << std::endl;
        }
        else if (st == LEADING_EDGE) {
            indent(sout,i+j);
            sout << "stickType: " << "LEADING_EDGE" << std::endl;
        }
    }

    indent(sout,i+j);
    sout << "stickDistance:  ( Feet " << getStickDistance()  << " )"  << std::endl;

    indent(sout,i+j);
    sout << "interval: ( MilliSeconds " << getInterval()  << " )"     << std::endl;

    indent(sout,i+j);
    sout << "maxMissDistance: ( Feet " << getMaxMissDistance()  << " )"  << std::endl;

    indent(sout,i+j);
    sout << "armDelay: ( Seconds " << getArmDelay()  << " )"     << std::endl;

    indent(sout,i+j);
    sout << "angle: ( Degrees  " << getAngle()  << " )"        << std::endl;

    indent(sout,i+j);
    sout << "azimuth: ( Degrees " << getAzimuth()  << " )"      << std::endl;

    indent(sout,i+j);
    sout << "velocity: " << getVelocity()     << std::endl;

    if ( !slotsOnly ) {
        indent(sout,i);
        sout << ")" << std::endl;
    }
    return sout;
}
Пример #12
0
//! called if an event happened.
bool CGUIFileOpenDialog::OnEvent(const SEvent& event)
{
	if (isEnabled())
	{
		switch(event.EventType)
		{
		case EET_GUI_EVENT:
			switch(event.GUIEvent.EventType)
			{
			case EGET_ELEMENT_FOCUS_LOST:
				Dragging = false;
				break;
			case EGET_BUTTON_CLICKED:
				if (event.GUIEvent.Caller == CloseButton ||
					event.GUIEvent.Caller == CancelButton)
				{
					sendCancelEvent();
					remove();
					return true;
				}
				else
				if (event.GUIEvent.Caller == OKButton )
				{
					if ( FileDirectory != L"" )
					{
						sendSelectedEvent( EGET_DIRECTORY_SELECTED );
					}
					if ( FileName != L"" )
					{
						sendSelectedEvent( EGET_FILE_SELECTED );
						remove();
						return true;
					}
				}
				break;

			case EGET_LISTBOX_CHANGED:
				{
					s32 selected = FileBox->getSelected();
					if (FileList && FileSystem)
					{
						if (FileList->isDirectory(selected))
						{
							FileName = L"";
							FileDirectory = FileList->getFullFileName(selected);
						}
						else
						{
							FileDirectory = L"";
							FileName = FileList->getFullFileName(selected);
						}
						return true;
					}
				}
				break;

			case EGET_LISTBOX_SELECTED_AGAIN:
				{
					const s32 selected = FileBox->getSelected();
					if (FileList && FileSystem)
					{
						if (FileList->isDirectory(selected))
						{
							FileDirectory = FileList->getFullFileName(selected);
							FileSystem->changeWorkingDirectoryTo(FileList->getFileName(selected));
							fillListBox();
							FileName = "";
						}
						else
						{
							FileName = FileList->getFullFileName(selected);
						}
						return true;
					}
				}
				break;
			case EGET_EDITBOX_ENTER:
				if (event.GUIEvent.Caller == FileNameText)
				{
					io::path dir( FileNameText->getText () );
					if ( FileSystem->changeWorkingDirectoryTo( dir ) )
					{
						fillListBox();
						FileName = L"";
					}
					return true;
				}
			break;
			default:
				break;
			}
			break;
		case EET_MOUSE_INPUT_EVENT:
			switch(event.MouseInput.Event)
			{
			case EMIE_MOUSE_WHEEL:
				return FileBox->OnEvent(event);
			case EMIE_LMOUSE_PRESSED_DOWN:
				DragStart.X = event.MouseInput.X;
				DragStart.Y = event.MouseInput.Y;
				Dragging = true;
				Environment->setFocus(this);
				return true;
			case EMIE_LMOUSE_LEFT_UP:
				Dragging = false;
				return true;
			case EMIE_MOUSE_MOVED:

				if ( !event.MouseInput.isLeftPressed () )
					Dragging = false;

				if (Dragging)
				{
					// gui window should not be dragged outside its parent
					if (Parent)
						if (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 ||
							event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 ||
							event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 ||
							event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1)

							return true;

					move(core::position2d<s32>(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y));
					DragStart.X = event.MouseInput.X;
					DragStart.Y = event.MouseInput.Y;
					return true;
				}
				break;
			default:
				break;
			}
		default:
			break;
		}
	}

	return IGUIElement::OnEvent(event);
}
Пример #13
0
void QDockWidgetTitleButton::enterEvent(QEvent *event)
{
    if (isEnabled()) update();
    QAbstractButton::enterEvent(event);
}
Пример #14
0
bool ButtonBase::onProcessMessage(Message* msg)
{
  switch (msg->type()) {

    case kFocusEnterMessage:
    case kFocusLeaveMessage:
      if (isEnabled()) {
        if (m_behaviorType == kButtonWidget) {
          // Deselect the widget (maybe the user press the key, but
          // before release it, changes the focus).
          if (isSelected())
            setSelected(false);
        }

        // TODO theme specific stuff
        invalidate();
      }
      break;

    case kKeyDownMessage: {
      KeyMessage* keymsg = static_cast<KeyMessage*>(msg);
      KeyScancode scancode = keymsg->scancode();

      if (isEnabled() && isVisible()) {
        bool mnemonicPressed =
          ((msg->altPressed() || msg->cmdPressed()) &&
           isMnemonicPressed(keymsg));

        // For kButtonWidget
        if (m_behaviorType == kButtonWidget) {
          // Has focus and press enter/space
          if (hasFocus()) {
            if ((scancode == kKeyEnter) ||
                (scancode == kKeyEnterPad) ||
                (scancode == kKeySpace)) {
              setSelected(true);
              return true;
            }
          }

          // Check if the user pressed mnemonic.
          if (mnemonicPressed) {
            setSelected(true);
            return true;
          }
          // Magnetic widget catches ENTERs
          else if (isFocusMagnet() &&
                   ((scancode == kKeyEnter) ||
                    (scancode == kKeyEnterPad))) {
            manager()->setFocus(this);

            // Dispatch focus movement messages (because the buttons
            // process them)
            manager()->dispatchMessages();

            setSelected(true);
            return true;
          }
        }
        // For kCheckWidget or kRadioWidget
        else {
          /* if the widget has the focus and the user press space or
             if the user press Alt+the underscored letter of the button */
          if ((hasFocus() && (scancode == kKeySpace)) || mnemonicPressed) {
            if (m_behaviorType == kCheckWidget) {
              // Swap the select status
              setSelected(!isSelected());
              invalidate();
            }
            else if (m_behaviorType == kRadioWidget) {
              if (!isSelected()) {
                setSelected(true);
              }
            }
            return true;
          }
        }
      }
      break;
    }

    case kKeyUpMessage:
      if (isEnabled()) {
        if (m_behaviorType == kButtonWidget) {
          if (isSelected()) {
            generateButtonSelectSignal();
            return true;
          }
        }
      }
      break;

    case kMouseDownMessage:
      switch (m_behaviorType) {

        case kButtonWidget:
          if (isEnabled()) {
            setSelected(true);

            m_pressedStatus = isSelected();
            captureMouse();
          }
          return true;

        case kCheckWidget:
          if (isEnabled()) {
            setSelected(!isSelected());

            m_pressedStatus = isSelected();
            captureMouse();
          }
          return true;

        case kRadioWidget:
          if (isEnabled()) {
            if (!isSelected()) {
              m_handleSelect = false;
              setSelected(true);
              m_handleSelect = true;

              m_pressedStatus = isSelected();
              captureMouse();
            }
          }
          return true;
      }
      break;

    case kMouseUpMessage:
      if (hasCapture()) {
        releaseMouse();

        if (hasMouseOver()) {
          switch (m_behaviorType) {

            case kButtonWidget:
              generateButtonSelectSignal();
              break;

            case kCheckWidget:
              {
                // Fire onClick() event
                Event ev(this);
                onClick(ev);

                invalidate();
              }
              break;

            case kRadioWidget:
              {
                setSelected(false);
                setSelected(true);

                // Fire onClick() event
                Event ev(this);
                onClick(ev);
              }
              break;
          }
        }
        return true;
      }
      break;

    case kMouseMoveMessage:
      if (isEnabled() && hasCapture()) {
        bool hasMouse = hasMouseOver();

        m_handleSelect = false;

        // Switch state when the mouse go out
        if ((hasMouse && isSelected() != m_pressedStatus) ||
            (!hasMouse && isSelected() == m_pressedStatus)) {
          if (hasMouse)
            setSelected(m_pressedStatus);
          else
            setSelected(!m_pressedStatus);
        }

        m_handleSelect = true;
      }
      break;

    case kMouseEnterMessage:
    case kMouseLeaveMessage:
      // TODO theme stuff
      if (isEnabled())
        invalidate();
      break;
  }

  return Widget::onProcessMessage(msg);
}
Пример #15
0
void HalRgbLed::setRedValue(int value) {
  if (isEnabled()) {
    analogWrite(LED_RED, 255-value);
    redValue = value;
  }
}
Пример #16
0
MsgRouting
AwtCheckbox::OwnerDrawItem(UINT /*ctrlId*/, DRAWITEMSTRUCT& drawInfo)
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);

    if (env->EnsureLocalCapacity(4) < 0) {
        return mrConsume;
    }

    jobject self = GetPeer(env);
    jobject target = env->GetObjectField(self, AwtObject::targetID);

    HDC hDC = drawInfo.hDC;
    RECT rect = drawInfo.rcItem;
    int checkSize;
    UINT nState;
    SIZE size;

    jobject font = GET_FONT(target, self);
    jstring str = (jstring)env->GetObjectField(target, AwtCheckbox::labelID);
    size = AwtFont::getMFStringSize(hDC, font, str);

    jobject group = env->GetObjectField(target, AwtCheckbox::groupID);
    if (group != NULL)
        nState = DFCS_BUTTONRADIO;
    else
        nState = DFCS_BUTTONCHECK;

    if (GetState())
        nState |= DFCS_CHECKED;
    else
        nState &= ~DFCS_CHECKED;

    if (drawInfo.itemState & ODS_SELECTED)
        nState |= DFCS_PUSHED;

    if (drawInfo.itemAction & ODA_DRAWENTIRE) {
        VERIFY(::FillRect (hDC, &rect, GetBackgroundBrush()));
    }

    /* draw check mark */
    checkSize = GetCheckSize();
    RECT boxRect;

    boxRect.left = (GetRTL()) ? rect.right - checkSize : rect.left;
    boxRect.top = (rect.bottom - rect.top - checkSize)/2;
    boxRect.right = boxRect.left + checkSize;
    boxRect.bottom = boxRect.top + checkSize;
    ::DrawFrameControl(hDC, &boxRect, DFC_BUTTON, nState);

    /*
     * draw string
     *
     * 4 is a heuristic number
     */
    rect.left = rect.left + checkSize + checkSize/4;
    if (drawInfo.itemAction & ODA_DRAWENTIRE) {
        BOOL bEnabled = isEnabled();

        int x = (GetRTL()) ? rect.right - (checkSize + checkSize / 4 + size.cx)
                           : rect.left;
        int y = (rect.top + rect.bottom - size.cy) / 2;
        if (bEnabled) {
            AwtComponent::DrawWindowText(hDC, font, str, x, y);
        } else {
            AwtComponent::DrawGrayText(hDC, font, str, x, y);
        }
    }

    /* Draw focus rect */
    RECT focusRect;
    const int margin = 2; /*  2 is a heuristic number */

    focusRect.left = (GetRTL()) ? rect.right - checkSize - checkSize / 4 -
                                      2 * margin - size.cx
                                : rect.left - margin;
    focusRect.top = (rect.top+rect.bottom-size.cy)/2;
    focusRect.right = (GetRTL()) ? rect.right - checkSize - checkSize / 4 +
                                      margin
                                 : focusRect.left + size.cx + 2 * margin;
    focusRect.bottom = focusRect.top + size.cy;

    /*  draw focus rect */
    if ((drawInfo.itemState & ODS_FOCUS) &&
        ((drawInfo.itemAction & ODA_FOCUS)||
         (drawInfo.itemAction &ODA_DRAWENTIRE))) {
        VERIFY(::DrawFocusRect(hDC, &focusRect));
    }
    /*  erase focus rect */
    else if (!(drawInfo.itemState & ODS_FOCUS) &&
             (drawInfo.itemAction & ODA_FOCUS)) {
        VERIFY(::DrawFocusRect(hDC, &focusRect));
    }

    /*  Notify any subclasses */
    rect = drawInfo.rcItem;
    DoCallback("handlePaint", "(IIII)V", rect.left, rect.top,
               rect.right-rect.left, rect.bottom-rect.top);

    env->DeleteLocalRef(target);
    env->DeleteLocalRef(font);
    env->DeleteLocalRef(str);
    env->DeleteLocalRef(group);

    return mrConsume;
}
Пример #17
0
void HalRgbLed::setGreenValue(int value) {
  if (isEnabled()) {
    analogWrite(LED_GREEN, 255-value);
    greenValue = value;
  }
}
Пример #18
0
/*!
  \brief Draw the contents inside the frame
 
  QColorGroup::Background is the background color outside of the frame.
  QColorGroup::Base is the background color inside the frame.
  QColorGroup::Foreground is the background color inside the scale.

  \param painter Painter
  \sa QwtDial::boundingRect, QwtDial::contentsRect,
    QwtDial::scaleContentsRect, QWidget::setPalette
*/
void QwtDial::drawContents(QPainter *painter) const
{
    if ( backgroundMode() == NoBackground || 
        colorGroup().brush(QColorGroup::Base) != 
            colorGroup().brush(QColorGroup::Background) )
    {
        // Don´t use QPainter::drawEllipse. There are some pixels
        // different compared to the region in the mask, leaving
        // them in background color.

        painter->save();
        painter->setPen(Qt::NoPen);
        painter->setBrush(colorGroup().brush(QColorGroup::Base));

        // Even if we want to fill the contentsRect only, we fill the
        // complete boundingRect. The frame will be painted later
        // above, but we want to have the base color below it
        // because round objects doesn´t cover all pixels.

        QRect br = boundingRect();
#if QT_VERSION < 300
#ifdef _WS_WIN32_
        // Qt-230-NC draws ellipses not as nicely as Qt-2.3.x on X Windows
        br.setTop(br.top()-1);
        br.setLeft(br.left()-1);
        br.setBottom(br.bottom()+1);
        br.setRight(br.right()+1);
#endif
#endif
        painter->setClipRegion(QRegion(painter->xForm(br), QRegion::Ellipse));
        painter->drawRect(br);
        painter->restore();
    }


    const QRect insideScaleRect = scaleContentsRect();
    if ( colorGroup().brush(QColorGroup::Foreground) !=
        colorGroup().brush(QColorGroup::Base) )
    {
        painter->save();
        painter->setPen(Qt::NoPen);
        painter->setBrush(colorGroup().brush(QColorGroup::Foreground));

        painter->setClipRegion(
            QRegion(painter->xForm(insideScaleRect), QRegion::Ellipse));
        painter->drawRect(insideScaleRect);
        painter->restore();
    }

    const QPoint center = insideScaleRect.center();
    const int radius = insideScaleRect.width() / 2;

    painter->save();
    drawScaleContents(painter, center, radius);
    painter->restore();

    double direction = d_origin;

    if (isValid())
    {
        direction = d_origin + d_minScaleArc;
        if ( maxValue() > minValue() && d_maxScaleArc > d_minScaleArc )
        {
            const double ratio = 
                (value() - minValue()) / (maxValue() - minValue());
            direction += ratio * (d_maxScaleArc - d_minScaleArc);
        }

        if ( direction >= 360.0 )
            direction -= 360.0;
    }

    double origin = d_origin;
    if ( mode() == RotateScale )
    {
        origin -= direction - d_origin;
        direction = d_origin;
    }

    painter->save();
    drawScale(painter, center, radius, origin, d_minScaleArc, d_maxScaleArc);
    painter->restore();

    if ( isValid() )
    {
        QPalette::ColorGroup cg;
        if ( isEnabled() )
            cg = hasFocus() ? QPalette::Active : QPalette::Inactive;
        else
            cg = QPalette::Disabled;

        painter->save();
        drawNeedle(painter, center, radius, direction, cg);
        painter->restore();
    }
}
Пример #19
0
void CountsVisitor::apply(osg::Drawable* draw)
{
    apply(draw->getStateSet());

    pushStateSet(draw->getStateSet());

    if(_countUserMode)
    {
        if(isSet(_userMode, _stateStack.back().get()))
        {
            if(isEnabled(_userMode, _stateStack.back().get()))
                _drawUserModeOn++;
            else
                _drawUserModeOff++;
        }
        else
            _drawUserModeNotSet++;
    }

    _totalDrawables++;
    osg::Geometry* geom;
    if (dynamic_cast<osgText::Text*>(draw) != NULL)
    {
        _texts++;
        osg::ref_ptr<osg::Object> rp = (osg::Object*)draw;
        _uTexts.insert(rp);
    }
    else if ((geom = dynamic_cast<osg::Geometry*>(draw)) != NULL)
    {
        _geometries++;
        osg::ref_ptr<osg::Object> rp = (osg::Object*)geom;
        _uGeometries.insert(rp);

        //if (!geom->areFastPathsUsed())
        //    _slowPathGeometries++;

        if(geom->getNumPrimitiveSets() > 0)
        {
            unsigned int idx;
            for(idx=0; idx < geom->getNumPrimitiveSets(); idx++)
            {
                osg::PrimitiveSet* ps = geom->getPrimitiveSet(idx);
                _vertices += ps->getNumIndices();
            }
        }
        else
            _nullGeometries++;
        osg::ref_ptr<osg::Object> rpv = (osg::Object*)(geom->getVertexArray());
        _uVertices.insert(rpv);

        if(geom->getNumPrimitiveSets() > 0)
        {
            _primitiveSets += geom->getNumPrimitiveSets();
            osg::Geometry::PrimitiveSetList& psl = geom->getPrimitiveSetList();
            osg::Geometry::PrimitiveSetList::const_iterator pslit;
            for(pslit = psl.begin(); pslit != psl.end(); ++pslit)
            {
                osg::ref_ptr<osg::Object> rpps = (osg::Object*)(pslit->get());
                _uPrimitiveSets.insert(rpps);
                const osg::DrawArrays* da = dynamic_cast< const osg::DrawArrays* >(pslit->get());
                if(da)
                {
                    _drawArrays++;
                    osg::ref_ptr<osg::Object> rpda = (osg::Object*)(da);
                    _uDrawArrays.insert(rpda);
                }
            }
        }
    }
    else
    {
        _drawables++;
        osg::ref_ptr<osg::Object> rp = (osg::Object*)draw;
        _uDrawables.insert(rp);
    }

    popStateSet();
}
void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners, const std::function<bool(EventListener*)>& onEvent)
{
    bool shouldStopPropagation = false;
    auto fixedPriorityListeners = listeners->getFixedPriorityListeners();
    auto sceneGraphPriorityListeners = listeners->getSceneGraphPriorityListeners();
    
    ssize_t i = 0;
    // priority < 0
    if (fixedPriorityListeners)
    {
        CCASSERT(listeners->getGt0Index() <= static_cast<ssize_t>(fixedPriorityListeners->size()), "Out of range exception!");
        
        if (!fixedPriorityListeners->empty())
        {
            for (; i < listeners->getGt0Index(); ++i)
            {
                auto l = fixedPriorityListeners->at(i);
                if (l->isEnabled() && !l->isPaused() && l->isRegistered() && onEvent(l))
                {
                    shouldStopPropagation = true;
                    break;
                }
            }
        }
    }
    
    if (sceneGraphPriorityListeners)
    {
        if (!shouldStopPropagation)
        {
            // priority == 0, scene graph priority
            for (auto& l : *sceneGraphPriorityListeners)
            {
                if (l->isEnabled() && !l->isPaused() && l->isRegistered() && onEvent(l))
                {
                    shouldStopPropagation = true;
                    break;
                }
            }
        }
    }

    if (fixedPriorityListeners)
    {
        if (!shouldStopPropagation)
        {
            // priority > 0
            ssize_t size = fixedPriorityListeners->size();
            for (; i < size; ++i)
            {
                auto l = fixedPriorityListeners->at(i);
                
                if (l->isEnabled() && !l->isPaused() && l->isRegistered() && onEvent(l))
                {
                    shouldStopPropagation = true;
                    break;
                }
            }
        }
    }
}
Пример #21
0
void CMoveOnGridComp::update(float dt)
{
    if (!isEnabled()) return;
    
#ifdef DEBUG
    if (m_ownerRole->getMark())
    {
        CWarriorRoleCompBase::update(dt);
    }
    else
#endif
    {
        CWarriorRoleCompBase::update(dt);
    }
    m_idleSleepTime -= dt;

    
    switch (m_subState)
    {
        case MOVE_SUB_STATE_IDLE:
            m_ownerRole->playAnimation(ROLE_ANIMATION_IDLE);
            m_ownerRole->unlockState();

            if (m_idleSleepTime < 0)
            {
                THINK_AND_BREAK();
                findPathIfNeeded(true);
            }
            break;
        case MOVE_SUB_STATE_PATH_FIND:
        {
            m_ownerRole->playAnimation(ROLE_ANIMATION_IDLE);
            m_ownerRole->unlockState();

            if (m_idleSleepTime < 0)
            {
                THINK_AND_BREAK();
                findPathIfNeeded(false);
            }
            break;
        }
        case MOVE_SUB_STATE_PATH_FINDING:
            m_ownerRole->playAnimation(ROLE_ANIMATION_IDLE);
            break;
        case MOVE_SUB_STATE_PATH_FOUND:
        {
            THINK_AND_BREAK();
            if (!m_ownerRole->getMovetarget().equals(m_moveTarget))
            {
                m_subState = MOVE_SUB_STATE_IDLE;
                break;
            }
            if (m_paths.size() > 0)
            {
                CBackgroundManager* bkg = m_ownerRole->getBackGround();
                CC_ASSERT(bkg);
                const Point& pos = m_paths.back();
                if (pos.equals(m_ownerRole->getLogicGrid()->getGridPos()))
                {
                    m_paths.pop_back();
                    break;
                }

                if (bkg->isRoleCanBePlacedOnPos(m_ownerRole, pos, true))
                {
                    
                    CLogicGrid* pGrid = m_ownerRole->getLogicGrid();
                    const Point& curPos = pGrid->getGridPos();

                    float speed = m_ownerRole->getSpeed();
                    m_moveTotalTime = pos.getDistance(curPos) / speed;
                    CC_ASSERT(!FLT_EQUAL(m_moveTotalTime, 0.f));
                    m_moveElapseTime = 0.f;
                    m_moveFrom = bkg->gridToWorldPoint(curPos);
                    m_moveTo = bkg->gridToWorldPoint(pos);
                    
                    Point diff = m_moveTo - m_moveFrom;
                    if (diff.x > 0)
                    {
                        if (diff.y > 0)
                        {
                            m_ownerRole->setFaceTo(FACE_TO_RIGHT_UP);
                        }
                        else
                        {
                            m_ownerRole->setFaceTo(FACE_TO_RIGHT_DOWN);
                        }
                    }
                    else if (diff.x < 0)
                    {
                        if (diff.y > 0)
                        {
                            m_ownerRole->setFaceTo(FACE_TO_LEFT_UP);
                        }
                        else
                        {
                            m_ownerRole->setFaceTo(FACE_TO_LEFT_DOWN);
                        }
                    }
                    m_ownerRole->playAnimation(ROLE_ANIMATION_MOVE);
                    m_ownerRole->lockState();
                    
                    m_subState = MOVE_SUB_STATE_MOVING;
                }
                else
                {
                    bkg->isRoleCanBePlacedOnPos(m_ownerRole, pos, true);
                    m_subState = MOVE_SUB_STATE_PATH_FIND;
//                    m_idleSleepTime = 2.f;
                }
            }
            else
            {
                m_subState = MOVE_SUB_STATE_IDLE;
            }
            break;
        }
        case MOVE_SUB_STATE_MOVING:
        {
            m_moveElapseTime += dt;
            float alpha = m_moveElapseTime / m_moveTotalTime;
            
            if (FLT_GE(alpha, 1.f))
            {
                alpha = 1.f;
                m_paths.pop_back();
                m_subState = MOVE_SUB_STATE_PATH_FOUND;
                
                m_ownerRole->unlockState();
            }
            else if (FLT_GE(alpha, .5))
            {
                CBackgroundManager* bkg = m_ownerRole->getBackGround();
                CC_ASSERT(bkg);
                if (!bkg->placeRole(m_ownerRole, m_paths.back()))
                {
                    m_subState = MOVE_SUB_STATE_ROLL_BACK;
                }
            }


            Point newPos = m_moveFrom.lerp(m_moveTo, alpha);
            m_ownerRole->setSpritePosition(newPos);

            break;
        }
        case MOVE_SUB_STATE_ROLL_BACK:
        {
            CBackgroundManager* bkg = m_ownerRole->getBackGround();
            CC_ASSERT(bkg);
            bkg->placeRole(m_ownerRole, m_ownerRole->getLogicGrid()->getGridPos());
            m_ownerRole->playAnimation(ROLE_ANIMATION_IDLE);
            m_subState = MOVE_SUB_STATE_PATH_FIND;
            m_ownerRole->unlockState();
            break;
        }
        default:
            break;
    }
}
Пример #22
0
void KItemListHeaderWidget::paintRole(QPainter* painter,
                                      const QByteArray& role,
                                      const QRectF& rect,
                                      int orderIndex,
                                      QWidget* widget) const
{
    // The following code is based on the code from QHeaderView::paintSection().
    // Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    QStyleOptionHeader option;
    option.section = orderIndex;
    option.state = QStyle::State_None | QStyle::State_Raised | QStyle::State_Horizontal;
    if (isEnabled()) {
        option.state |= QStyle::State_Enabled;
    }
    if (window() && window()->isActiveWindow()) {
        option.state |= QStyle::State_Active;
    }
    if (m_hoveredRoleIndex == orderIndex) {
        option.state |= QStyle::State_MouseOver;
    }
    if (m_pressedRoleIndex == orderIndex) {
        option.state |= QStyle::State_Sunken;
    }
    if (m_model->sortRole() == role) {
        option.sortIndicator = (m_model->sortOrder() == Qt::AscendingOrder) ?
                                QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp;
    }
    option.rect = rect.toRect();

    bool paintBackgroundForEmptyArea = false;

    if (m_columns.count() == 1) {
        option.position = QStyleOptionHeader::OnlyOneSection;
    } else if (orderIndex == 0) {
        option.position = QStyleOptionHeader::Beginning;
    } else if (orderIndex == m_columns.count() - 1) {
        // We are just painting the header for the last column. Check if there
        // is some empty space to the right which needs to be filled.
        if (rect.right() < size().width()) {
            option.position = QStyleOptionHeader::Middle;
            paintBackgroundForEmptyArea = true;
        } else {
            option.position = QStyleOptionHeader::End;
        }
    } else {
        option.position = QStyleOptionHeader::Middle;
    }

    option.orientation = Qt::Horizontal;
    option.selectedPosition = QStyleOptionHeader::NotAdjacent;
    option.text = m_model->roleDescription(role);

    style()->drawControl(QStyle::CE_Header, &option, painter, widget);

    if (paintBackgroundForEmptyArea) {
        option.state = QStyle::State_None | QStyle::State_Raised | QStyle::State_Horizontal;
        option.section = m_columns.count();
        option.sortIndicator = QStyleOptionHeader::None;

        qreal backgroundRectX = rect.x() + rect.width();
        QRectF backgroundRect(backgroundRectX, 0.0, size().width() - backgroundRectX, rect.height());
        option.rect = backgroundRect.toRect();
        option.position = QStyleOptionHeader::End;
        option.text = QString();

        style()->drawControl(QStyle::CE_Header, &option, painter, widget);
    }
}
Пример #23
0
OsStatus MpidAndroid::enableDevice(unsigned samplesPerFrame, 
                                   unsigned samplesPerSec, 
                                   MpFrameTime currentFrameTime)
{
   OsStatus status = OS_SUCCESS;

   // If the device is not valid, let the user know it's bad.
   if (!isDeviceValid())
   {
      return OS_INVALID;  // perhaps new OsState of OS_RESOURCE_INVALID?
   }

   if (isEnabled())
   {
      return OS_NAME_IN_USE;
   }

   LOGI("MpidAndroid::enableDevice()");

   // Start accessing non-atomic member variables
   AutoMutex autoLock(mLock);

   if (mState != DRIVER_IDLE) {
      LOGW("MpidAndroid::enableDevice() wrong state %d\n", mState);
      return OS_INVALID_STATE;
   }

   // Set some wave header stat information.
   mSamplesPerFrame = samplesPerFrame;
   mSamplesPerSec = samplesPerSec;
   mCurrentFrameTime = currentFrameTime;

   if (probeSampleRate(mSamplesPerSec, mSamplesPerFrame, mpSampleRatesList, mSampleRatesListLen)) {
      LOGV("MpidAndroid::enableDevice() INIT OK, time: %"PRId64"\n", ns2ms(systemTime()));
   } else {
      LOGW("MpidAndroid::enableDevice() INIT FAILED!!!\n");
      return OS_INVALID_ARGUMENT;
   }

   if (mState != DRIVER_INIT) {
      LOGW("MpidAndroid::enableDevice() wrong state: %d\n", mState);
      return OS_INVALID_STATE;
   }

   // Allocate internal buffer
   assert(mSamplesPerFrameInternal > 0);
   mpBufInternal = new MpAudioSample[mSamplesPerFrameInternal];
   assert(mpBufInternal != NULL);
   mBufInternalSamples = 0;

   // Create resampler
   if (mSamplesPerSecInternal != mSamplesPerSec)
   {
      OsSysLog::add(FAC_MP, PRI_ERR, "mSamplesPerSecInternal: %d mSamplesPerSec: %d\n", mSamplesPerSecInternal, mSamplesPerSec);
      LOGV("mSamplesPerSecInternal: %d mSamplesPerSec: %d\n", mSamplesPerSecInternal, mSamplesPerSec);
      mpResampler = MpResamplerBase::createResampler(1, mSamplesPerSecInternal, mSamplesPerSec);
      mpResampleBuf = new MpAudioSample[mSamplesPerFrame];
      assert(mpResampler != NULL && mpResampleBuf != NULL);
   }

   mState = DRIVER_STARTING;
   mLock.unlock();
   int startStatus = mpAudioRecord->start();
   if(startStatus != NO_ERROR)
   {
      OsSysLog::add(FAC_MP, PRI_ERR, "MpidAndroid::enableDevice AudioRecord::start returned error: %d", startStatus);
      LOGE("MpidAndroid::enableDevice AudioRecord::start returned error: %d", startStatus);
      switch(startStatus)
      {
      case INVALID_OPERATION:
           status = OS_LIMIT_REACHED;
      break;
      default:
           status = OS_FAILED;
      break;
      }

      mState = DRIVER_IDLE;
      mIsEnabled = FALSE;
      return(status);
   }

   mLock.lock();
   if (mState == DRIVER_STARTING) {
      LOGV("MpidAndroid::enableDevice() waiting for start callback");
      status_t lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3));
      if (lStatus != NO_ERROR) {
         LOGE("MpidAndroid::enableDevice() callback timed out, status %d", lStatus);
         mState = DRIVER_IDLE;
         mIsEnabled = FALSE;
         return OS_WAIT_TIMEOUT;
      }
   } else {
      LOGW("MpidAndroid::enableDevice() state %d\n", mState);
   }
   LOGV("MpidAndroid::enableDevice() started, time %"PRId64"\n", ns2ms(systemTime()));

   // Indicate driver has been started.
   mIsEnabled = TRUE;

   return status;
}
Пример #24
0
void comboUC::Event(BSEventUC &event)
{
	if( !isMouseEnabled() && event.Type > BEUCEventMouseBegin && event.Type < BEUCEventMouseEnd ) {
		if( m_pParent != NULL ) m_pParent->Event(event);
		else containerUC::Event(event);
		return;
	}

	if( event.Type == BEUCEventSetFocus ) 
	{
		invalidate();
	}
	if( event.Type == BEUCEventKillFocus ) 
	{
		invalidate();
	}
	if( event.Type == BEUCEventButtonDown )
	{
		if( isEnabled() ) {
			activate();
			m_uButtonState |= UCSTATE_PUSHED | UCSTATE_CAPTURED;
		}
		return;
	}
	if( event.Type == BEUCEventButtonUp )
	{
		if( (m_uButtonState & UCSTATE_CAPTURED) != 0 ) {
			m_uButtonState &= ~ UCSTATE_CAPTURED;
			invalidate();
		}
		return;
	}
	if( event.Type == BEUCEventMouseMove )
	{
		return;
	}
	if( event.Type == BEUCEventKeyDown )
	{
		switch( event.chKey ) {
		case VK_F4:
			activate();
			return;
		case VK_UP:
			selectItem(findSelectable(m_iCurSel - 1, false));
			return;
		case VK_DOWN:
			selectItem(findSelectable(m_iCurSel + 1, true));
			return;
		case VK_PRIOR:
			selectItem(findSelectable(m_iCurSel - 1, false));
			return;
		case VK_NEXT:
			selectItem(findSelectable(m_iCurSel + 1, true));
			return;
		case VK_HOME:
			selectItem(findSelectable(0, false));
			return;
		case VK_END:
			selectItem(findSelectable(getCount() - 1, true));
			return;
		}
	}
	if( event.Type == BEUCEventScrollWheel )
	{
		bool bDownward = LOWORD(event.wParam) == SB_LINEDOWN;
		selectItem(findSelectable(m_iCurSel + (bDownward ? 1 : -1), bDownward));
		return;
	}
	if( event.Type == BEUCEventContextMenu )
	{
		return;
	}
	if( event.Type == BEUCEventMouseEnter )
	{
		if( ::PtInRect(&m_rcItem, event.ptMouse ) ) {
			if( (m_uButtonState & UCSTATE_HOT) == 0  )
				m_uButtonState |= UCSTATE_HOT;
			invalidate();
		}
		return;
	}
	if( event.Type == BEUCEventMouseLeave )
	{
		if( (m_uButtonState & UCSTATE_HOT) != 0 ) {
			m_uButtonState &= ~UCSTATE_HOT;
			invalidate();
		}
		return;
	}
	controlUC::Event(event);
}
Пример #25
0
void KoDockWidgetTitleBarButton::leaveEvent(QEvent *event)
{
    if (isEnabled()) update();
    QAbstractButton::leaveEvent(event);
}
Пример #26
0
void comboUC::paintStatusImage(HDC hdc)
{
	if( isFocused() ) m_uButtonState |= UCSTATE_FOCUSED;
	else m_uButtonState &= ~ UCSTATE_FOCUSED;
	if( !isEnabled() ) m_uButtonState |= UCSTATE_DISABLED;
	else m_uButtonState &= ~ UCSTATE_DISABLED;

	Gdiplus::Graphics grap(hdc);
	RECT rcSrc = {0};
	if( (m_uButtonState & UCSTATE_DISABLED) != 0 ) {
		if (getDisabledImage(rcSrc))
		{
			gtc::drawer::drawImage(grap, m_pImage, m_rcItem, rcSrc);
			return;
		}
		//if( !m_sDisabledImage.IsEmpty() ) {
		//	if( !DrawImage(hDC, (LPCTSTR)m_sDisabledImage) ) m_sDisabledImage.Empty();
		//	else return;
		//}
	}
	else if( (m_uButtonState & UCSTATE_PUSHED) != 0 ) {
		if (getPushedImage(rcSrc))
		{
			gtc::drawer::drawImage(grap, m_pImage, m_rcItem, rcSrc);
			return;
		}
		//if( !m_sPushedImage.IsEmpty() ) {
		//	if( !DrawImage(hDC, (LPCTSTR)m_sPushedImage) ) m_sPushedImage.Empty();
		//	else return;
		//}
	}
	else if( (m_uButtonState & UCSTATE_HOT) != 0 ) {
		if (getHotImage(rcSrc))
		{
			gtc::drawer::drawImage(grap, m_pImage, m_rcItem, rcSrc);
			return;
		}
		//if( !m_sHotImage.IsEmpty() ) {
		//	if( !DrawImage(hDC, (LPCTSTR)m_sHotImage) ) m_sHotImage.Empty();
		//	else return;
		//}
	}
	else if( (m_uButtonState & UCSTATE_FOCUSED) != 0 ) {
		if (getFocusedImage(rcSrc))
		{
			gtc::drawer::drawImage(grap, m_pImage, m_rcItem, rcSrc);
			return;
		}
		//if( !m_sFocusedImage.IsEmpty() ) {
		//	if( !DrawImage(hDC, (LPCTSTR)m_sFocusedImage) ) m_sFocusedImage.Empty();
		//	else return;
		//}
	}
	if (getNormalImage(rcSrc))
	{
		gtc::drawer::drawImage(grap, m_pImage, m_rcItem, rcSrc);
	}
	//if( !m_sNormalImage.IsEmpty() ) {
	//	if( !DrawImage(hDC, (LPCTSTR)m_sNormalImage) ) m_sNormalImage.Empty();
	//	else return;
	//}
}
Пример #27
0
void QgsSpinBox::setShowClearButton( const bool showClearButton )
{
  mShowClearButton = showClearButton;
  mClearButton->setVisible( mShowClearButton && isEnabled() && value() != minimum() );
}
Пример #28
0
void comboUC::setEnabled(bool bEnable /*= true*/)
{
	containerUC::setEnabled(bEnable);
	if( !isEnabled() ) m_uButtonState = 0;
}
Пример #29
0
void QgsSpinBox::changed( const int& value )
{
  mClearButton->setVisible( mShowClearButton && isEnabled() && value != minimum() );
}
Пример #30
0
void PointerCoordinates::draw(StelCore *core)
{
	if (!isEnabled())
		return;

	const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000, StelCore::RefractionAuto);
	StelPainter sPainter(prj);
	sPainter.setColor(textColor[0], textColor[1], textColor[2], 1.f);
	font.setPixelSize(getFontSize());
	sPainter.setFont(font);

	QPoint p = StelMainView::getInstance().getMousePos(); // get screen coordinates of mouse cursor
	Vec3d mousePosition;
	float wh = prj->getViewportWidth()/2.; // get half of width of the screen
	float hh = prj->getViewportHeight()/2.; // get half of height of the screen
	float mx = p.x()-wh; // point 0 in center of the screen, axis X directed to right
	float my = p.y()-hh; // point 0 in center of the screen, axis Y directed to bottom
	// calculate position of mouse cursor via position of center of the screen (and invert axis Y)
	// If coordinates are invalid, don't draw them.
	bool coordsValid=false;
	coordsValid = prj->unProject(prj->getViewportPosX()+wh+mx, prj->getViewportPosY()+hh+1-my, mousePosition);
	{ // Nick Fedoseev patch
		Vec3d win;
		prj->project(mousePosition,win);
		float dx = prj->getViewportPosX()+wh+mx - win.v[0];
		float dy = prj->getViewportPosY()+hh+1-my - win.v[1];
		coordsValid = prj->unProject(prj->getViewportPosX()+wh+mx+dx, prj->getViewportPosY()+hh+1-my+dy, mousePosition);
	}
	if (!coordsValid)
		return;

	bool withDecimalDegree = StelApp::getInstance().getFlagShowDecimalDegrees();
	bool useOldAzimuth = StelApp::getInstance().getFlagOldAzimuthUsage();

	QString coordsSystem, cxt, cyt;
	double cx, cy;
	switch (getCurrentCoordinateSystem())
	{
		case RaDecJ2000:
		{
			StelUtils::rectToSphe(&cx,&cy,mousePosition); // Calculate RA/DE (J2000.0) and show it...
			coordsSystem = qc_("RA/Dec (J2000.0)", "abbreviated in the plugin");
			if (withDecimalDegree)
			{
				cxt = StelUtils::radToDecDegStr(cx, 5, false, true);
				cyt = StelUtils::radToDecDegStr(cy);
			}
			else
			{
				cxt = StelUtils::radToHmsStr(cx, true);
				cyt = StelUtils::radToDmsStr(cy, true);
			}
			break;
		}
		case RaDec:
		{
			StelUtils::rectToSphe(&cx,&cy,core->j2000ToEquinoxEqu(mousePosition)); // Calculate RA/DE and show it...
			coordsSystem = qc_("RA/Dec", "abbreviated in the plugin");
			if (withDecimalDegree)
			{
				cxt = StelUtils::radToDecDegStr(cx, 5, false, true);
				cyt = StelUtils::radToDecDegStr(cy);
			}
			else
			{
				cxt = StelUtils::radToHmsStr(cx, true);
				cyt = StelUtils::radToDmsStr(cy, true);
			}
			break;
		}
		case AltAzi:
		{
			StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(mousePosition, StelCore::RefractionAuto));
			float direction = 3.; // N is zero, E is 90 degrees
			if (useOldAzimuth)
				direction = 2.;
			cy = direction*M_PI - cy;
			if (cy > M_PI*2)
				cy -= M_PI*2;

			coordsSystem = qc_("Az/Alt", "abbreviated in the plugin");
			if (withDecimalDegree)
			{
				cxt = StelUtils::radToDecDegStr(cy);
				cyt = StelUtils::radToDecDegStr(cx);
			}
			else
			{
				cxt = StelUtils::radToDmsStr(cy);
				cyt = StelUtils::radToDmsStr(cx);
			}
			break;
		}
		case Galactic:
		{
			StelUtils::rectToSphe(&cx,&cy,core->j2000ToGalactic(mousePosition)); // Calculate galactic position and show it...
			coordsSystem = qc_("Gal. Long/Lat", "abbreviated in the plugin");
			if (withDecimalDegree)
			{
				cxt = StelUtils::radToDecDegStr(cx);
				cyt = StelUtils::radToDecDegStr(cy);
			}
			else
			{
				cxt = StelUtils::radToDmsStr(cx, true);
				cyt = StelUtils::radToDmsStr(cy, true);
			}
			break;
		}
		case Ecliptic:
		{
			double lambda, beta;
			StelUtils::rectToSphe(&cx,&cy,core->j2000ToEquinoxEqu(mousePosition));
			StelUtils::equToEcl(cx, cy, core->getCurrentPlanet()->getRotObliquity(core->getJDE()), &lambda, &beta); // Calculate ecliptic position and show it...
			if (lambda<0) lambda+=2.0*M_PI;
			coordsSystem = qc_("Ecl. Long/Lat", "abbreviated in the plugin");
			if (withDecimalDegree)
			{
				cxt = StelUtils::radToDecDegStr(lambda);
				cyt = StelUtils::radToDecDegStr(beta);
			}
			else
			{
				cxt = StelUtils::radToDmsStr(lambda, true);
				cyt = StelUtils::radToDmsStr(beta, true);
			}
			break;
		}
		case EclipticJ2000:
		{
			double lambda, beta;
			StelUtils::rectToSphe(&cx,&cy, mousePosition);
			StelUtils::equToEcl(cx, cy, core->getCurrentPlanet()->getRotObliquity(2451545.0), &lambda, &beta); // Calculate ecliptic position and show it...
			if (lambda<0) lambda+=2.0*M_PI;
			coordsSystem = qc_("Ecl. Long/Lat (J2000.0)", "abbreviated in the plugin");
			if (withDecimalDegree)
			{
				cxt = StelUtils::radToDecDegStr(lambda);
				cyt = StelUtils::radToDecDegStr(beta);
			}
			else
			{
				cxt = StelUtils::radToDmsStr(lambda, true);
				cyt = StelUtils::radToDmsStr(beta, true);
			}
			break;
		}
		case HourAngle:
		{
			Vec3d v = core->j2000ToAltAz(mousePosition, StelCore::RefractionAuto);
			StelUtils::rectToSphe(&cx,&cy,Mat4d::zrotation(-core->getLocalSiderealTime())*core->altAzToEquinoxEqu(v, StelCore::RefractionOff));
			cx = 2.*M_PI-cx;
			coordsSystem = qc_("HA/Dec", "abbreviated in the plugin");
			if (withDecimalDegree)
			{
				double ha_sidereal = cx*12/M_PI;
				if (ha_sidereal>24.)
					ha_sidereal -= 24.;
				cxt = QString("%1h").arg(ha_sidereal, 0, 'f', 5);
				cyt = StelUtils::radToDecDegStr(cy);

			}
			else
			{
				cxt = StelUtils::radToHmsStr(cx);
				cyt = StelUtils::radToDmsStr(cy);
			}
			break;		
		}
	}

	QString coordsText = QString("%1: %2/%3").arg(coordsSystem).arg(cxt).arg(cyt);
	sPainter.drawText(getCoordinatesPlace(coordsText).first, getCoordinatesPlace(coordsText).second, coordsText);
}