/*!
  \brief Return a minimum size hint
*/
QSize QwtArrowButton::minimumSizeHint() const
{
    const QSize asz = arrowSize(Qt::RightArrow, QSize());

    QSize sz(
        2 * Margin + (MaxNum - 1) * Spacing + MaxNum * asz.width(),
        2 * Margin + asz.height()
    );

    if ( d_data->arrowType == Qt::UpArrow || d_data->arrowType == Qt::DownArrow )
        sz.transpose();

#if QT_VERSION >= 0x040000
    QStyleOption styleOption;
    styleOption.init(this);

    const QSize hsz = style()->sizeFromContents(QStyle::CT_PushButton,
                      &styleOption, sz, this);
#if QT_VERSION < 0x040300
    if ( hsz.width() != 80 ) // avoid a bug in the Cleanlooks style
#endif
        sz = hsz;

#else
    sz = style().sizeFromContents(QStyle::CT_PushButton, this, sz);
#endif

    return sz;
}
void LocationEditor::RenderModeBuilding()
{
	if (m_selectionId != -1)
	{
		Building *building = g_app->m_location->GetBuilding(m_selectionId);

        if( building->m_shape )
        {
            Matrix34 mat( building->m_front, g_upVector, building->m_pos );
            Vector3 centrePos = building->m_shape->CalculateCentre( mat );
            float radius = building->m_shape->CalculateRadius( mat, centrePos );
            RenderSphere( centrePos, radius, RGBAColour(255,255,255,255) );
        }
        else
        {
            building->RenderHitCheck();
        }

		if (m_tool == ToolLink)
		{
			Vector3     height(0,10,0);
			Vector3     mousePos(g_app->m_userInput->GetMousePos3d());
			Vector3     arrowDir(mousePos - building->m_pos);
			Vector3     arrowSize(0,3,0);

			glEnable    ( GL_LINE_SMOOTH );
			glDisable   ( GL_DEPTH_TEST );
			glLineWidth ( 1.0 );
			glColor3f   ( 1.0, 0.5, 0.5 );
			glBegin( GL_LINES );
				glVertex3dv( (building->m_pos+height).GetData() );
				glVertex3dv( (mousePos).GetData() );

				glVertex3dv( (mousePos).GetData() );
				glVertex3dv( (mousePos-arrowDir*0.1+arrowSize).GetData() );

				glVertex3dv( (mousePos).GetData() );
				glVertex3dv( (mousePos-arrowDir*0.1-arrowSize).GetData() );
			glEnd();
			glDisable   ( GL_LINE_SMOOTH );
			glEnable    ( GL_DEPTH_TEST );
		}
		
		CHECK_OPENGL_STATE();
    }
}
Beispiel #3
0
/*!
  \brief Return a minimum size hint
*/
QSize QwtArrowButton::minimumSizeHint() const
{
    const QSize asz = arrowSize( Qt::RightArrow, QSize() );

    QSize sz(
        2 * Margin + ( MaxNum - 1 ) * Spacing + MaxNum * asz.width(),
        2 * Margin + asz.height()
    );

    if ( d_data->arrowType == Qt::UpArrow || d_data->arrowType == Qt::DownArrow )
        sz.transpose();

    QStyleOption styleOption;
    styleOption.init( this );

    sz = style()->sizeFromContents( QStyle::CT_PushButton,
        &styleOption, sz, this );

    return sz;
}
Beispiel #4
0
/*!
  \brief Draw the button label
  \sa The Qt Manual on QPushButton
*/
void QwtArrowButton::drawButtonLabel(QPainter *p)
{
    const bool isVertical = d_data->arrowType == Qt::UpArrow ||
        d_data->arrowType == Qt::DownArrow;

    const QRect r = labelRect();
    QSize boundingSize = labelRect().size();
    if ( isVertical )
        boundingSize.transpose();
        
    const int w = 
        (boundingSize.width() - (MaxNum - 1) * Spacing) / MaxNum;

    QSize arrow = arrowSize(Qt::RightArrow, 
        QSize(w, boundingSize.height()));

    if ( isVertical )
        arrow.transpose();

    QRect contentsSize; // aligned rect where to paint all arrows
    if ( d_data->arrowType == Qt::LeftArrow || d_data->arrowType == Qt::RightArrow )
    {
        contentsSize.setWidth(d_data->num * arrow.width() 
            + (d_data->num - 1) * Spacing);
        contentsSize.setHeight(arrow.height());
    }
    else
    {
        contentsSize.setWidth(arrow.width());
        contentsSize.setHeight(d_data->num * arrow.height() 
            + (d_data->num - 1) * Spacing);
    }

    QRect arrowRect(contentsSize);
    arrowRect.moveCenter(r.center());
    arrowRect.setSize(arrow);

    p->save();
    for (int i = 0; i < d_data->num; i++)
    {
        drawArrow(p, arrowRect, d_data->arrowType);

        int dx = 0;
        int dy = 0;

        if ( isVertical )
            dy = arrow.height() + Spacing;
        else
            dx = arrow.width() + Spacing;

#if QT_VERSION >= 0x040000
        arrowRect.translate(dx, dy);
#else
        arrowRect.moveBy(dx, dy);
#endif
    }
    p->restore();

    if ( hasFocus() )
    {
#if QT_VERSION >= 0x040000
        QStyleOptionFocusRect option;
        option.init(this);
        option.backgroundColor = palette().color(QPalette::Background);

        style()->drawPrimitive(QStyle::PE_FrameFocusRect, 
            &option, p, this);
#else
        const QRect focusRect =  
            style().subRect(QStyle::SR_PushButtonFocusRect, this);
        style().drawPrimitive(QStyle::PE_FocusRect, p,
            focusRect, colorGroup());
#endif
    }
}
Beispiel #5
0
// --------------------------------------------------------------------------
//!
// --------------------------------------------------------------------------
tCurrentInfoDialog::tCurrentInfoDialog( tAt5CurrentsQuickInfoObject* pAt5Obj, QWidget* pParent )
: tDialog( tDialog::Full, pParent ), 
m_pDateLineEdit( NULL ), 
m_pDateLabel( NULL ),
m_pCurrentInfoObj( pAt5Obj )
{
    setWindowTitle( tr("Currents") + " - " + pAt5Obj->Name() );

    QGridLayout* pLayout = new QGridLayout();
    SoftKeyBar()->ExplicitHide();

    m_ActiveDate = QDate::currentDate();

    if ( tUiConfig::Instance()->CanSupportTouch() )
    {
        QHBoxLayout* pDateLayout = new QHBoxLayout();

        tPushButton* pPreviousDayButton = new tPushButton( style()->standardIcon( QStyle::SP_ArrowLeft ), "", this );
        pPreviousDayButton->setFixedWidth( style()->pixelMetric( NPM( tNOSStyle::NPM_DatePickerPrevNextButtonWidth ) ) );
        pPreviousDayButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
        pPreviousDayButton->setFocusPolicy( Qt::NoFocus );
        Connect( pPreviousDayButton, SIGNAL( clicked() ), this, SLOT( OnPreviousDay() ) );
        pDateLayout->addWidget( pPreviousDayButton );

        m_pDateLineEdit = new tDateLineEdit( m_ActiveDate, tSystemSettings::Instance()->DateFormatString(), this );
        m_pDateLineEdit->SetTitle( tr("Tide Date") );
        m_pDateLineEdit->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
        m_pDateLineEdit->setFocusPolicy( Qt::NoFocus );
        Connect( m_pDateLineEdit, SIGNAL( ValueChanged() ), this, SLOT( OnCalendarInput() ) );
        pDateLayout->addWidget( m_pDateLineEdit );

        tPushButton* pNextDayButton = new tPushButton( style()->standardIcon( QStyle::SP_ArrowRight ), "", this );
        pNextDayButton->setFixedWidth( style()->pixelMetric( NPM( tNOSStyle::NPM_DatePickerPrevNextButtonWidth ) ) );
        pNextDayButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
        pNextDayButton->setFocusPolicy( Qt::NoFocus );
        Connect( pNextDayButton, SIGNAL( clicked() ), this, SLOT( OnNextDay() ) );
        pDateLayout->addWidget( pNextDayButton );

        pLayout->addLayout( pDateLayout, 0, 0, 1, 3, Qt::AlignCenter ); 
    }
    else
    {
        // Add date time label
        m_pDateLabel = new QLabel( m_ActiveDate.toString( tSystemSettings::Instance()->DateFormatString() ) );
        pLayout->addWidget( m_pDateLabel, 0, 0 );

        QSize arrowSize(14,14);
        QLabel* pPreviousDayArrow = new QLabel( this );
        pPreviousDayArrow->setPixmap( style()->standardIcon(QStyle::SP_ArrowUp).pixmap(arrowSize) );
        pPreviousDayArrow->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
        pPreviousDayArrow->setMaximumSize( arrowSize );
        QLabel* pNextDayArrow = new QLabel( this );
        pNextDayArrow->setPixmap( style()->standardIcon(QStyle::SP_ArrowDown).pixmap(arrowSize) );
        pNextDayArrow->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
        pNextDayArrow->setMaximumSize( arrowSize );
        QLabel* pPreviousDayLabel = new QLabel( this );
        pPreviousDayLabel->setText( tr("Previous day") );
        QLabel* pNextDayLabel = new QLabel( this );
        pNextDayLabel->setText( tr("Next day") );

        pLayout->addWidget( pPreviousDayArrow, 0, 2 );   
        pLayout->addWidget( pNextDayArrow, 2, 2 );   
        pLayout->addWidget( pPreviousDayLabel, 0, 1, Qt::AlignRight );   
        pLayout->addWidget( pNextDayLabel, 2, 1, Qt::AlignRight );   
    }

    m_pGraph = new tCurrentGraph( this );
    m_pGraph->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    m_pGraph->installEventFilter( this );
    Connect( m_pGraph, SIGNAL( NextPrevDay( bool ) ), this, SLOT( OnNextPrevDay( bool ) ) );
    pLayout->addWidget( m_pGraph, 1, 0, 1, 3 );   

    setLayout( pLayout );

    // Start the update timer
    m_pUpdateTimer = new QTimer( this );
    m_pUpdateTimer->setSingleShot( false );
    m_pUpdateTimer->setInterval( 60 * 1000 ); // x * 1000 ms = x seconds
    Connect( m_pUpdateTimer, SIGNAL( timeout() ), this, SLOT( OnUpdateTimer() ) );
    m_pUpdateTimer->start();

    // Initial update
    UpdateDialog();
}