コード例 #1
0
  void ControlPage::drawCheck(FlashGraphics& flash) const {

    // check box

    if(_leadedChecked)
      drawCheck(flash,LEADED,FlashInfo::LEADCHECKED::OFFSET,FlashInfo::LEADCHECKED::LENGTH,0x00cd99,LEAD_FREE);
    else
      drawCheck(flash,LEAD_FREE,FlashInfo::LEADFREECHECKED::OFFSET,FlashInfo::LEADFREECHECKED::LENGTH,0x00c3d2,LEADED);
  }
コード例 #2
0
void QItemDelegate_QtDShell::__override_drawCheck(QPainter*  painter0, const QStyleOptionViewItem&  option1, const QRect&  rect2, int  state3, bool static_call) const
{
    if (static_call) {
        QItemDelegate::drawCheck((QPainter* )painter0, (const QStyleOptionViewItem& )option1, (const QRect& )rect2, (Qt::CheckState )state3);
    } else {
        drawCheck((QPainter* )painter0, (const QStyleOptionViewItem& )option1, (const QRect& )rect2, (Qt::CheckState )state3);
    }
}
コード例 #3
0
ファイル: drawview.C プロジェクト: kthxbyte/KDE1-Linaro
void DrawView::setNewCenterX( double new_center_x )
  {
  if ( center_x != new_center_x )
    {
    center_x = new_center_x;
    drawbuffer->fill( black );
    drawCheck();
    }
  }
コード例 #4
0
ファイル: drawview.C プロジェクト: kthxbyte/KDE1-Linaro
void DrawView::setNewBailout( double new_bailout )
  {
  if ( bail_out != new_bailout )
    {
    bail_out = new_bailout;
    drawbuffer->fill( black );
    drawCheck();
    }
  }
コード例 #5
0
ファイル: drawview.C プロジェクト: kthxbyte/KDE1-Linaro
void DrawView::setNewExtraX( double new_extra_x )
  {
  if ( param_1 != new_extra_x )
    {
    param_1 = new_extra_x;
    drawbuffer->fill( black );
    drawCheck();
    }
  }
コード例 #6
0
ファイル: drawview.C プロジェクト: kthxbyte/KDE1-Linaro
void DrawView::setNewExtraY( double new_extra_y )
  {
  if ( param_2 != new_extra_y )
    {
    param_2 = new_extra_y;
    drawbuffer->fill( black );
    drawCheck();
    }
  }
コード例 #7
0
ファイル: drawview.C プロジェクト: kthxbyte/KDE1-Linaro
void DrawView::setNewColorScheme( ColorScheme scheme )
  {
  if ( act_color_scheme != scheme )
    {
    act_color_scheme = scheme;
    drawbuffer->fill( black );
    drawCheck();
    }
  }
コード例 #8
0
ファイル: icondelegate.cpp プロジェクト: svn2github/texstudio
void IconDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
                          const QModelIndex &index) const
{
    Q_ASSERT(index.isValid());
    const QAbstractItemModel *model = index.model();
    Q_ASSERT(model);

    QStyleOptionViewItem opt = option;

    // set font
    QVariant value = model->data(index, Qt::FontRole);
    if (value.isValid())
        opt.font = qvariant_cast<QFont>(value);

    // set text alignment
    value = model->data(index, Qt::TextAlignmentRole);
    if (value.isValid())
        opt.displayAlignment = QFlag(value.toInt());

    // set text color
    value = model->data(index, Qt::TextColorRole);
    if (value.isValid() && qvariant_cast<QColor>(value).isValid())
        opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));

    // do layout
    value = model->data(index, Qt::DecorationRole);
    QPixmap pixmap = decoration(opt, value);
    QRect pixmapRect = pixmap.rect();

    QFontMetrics fontMetrics(opt.font);
    QString text = model->data(index, Qt::DisplayRole).toString();
    QRect textRect(0, 0, 0,0);
    //QRect textRect(0, 0, fontMetrics.width(text), fontMetrics.lineSpacing());

    value = model->data(index, Qt::CheckStateRole);
    QRect checkRect = check(opt, opt.rect, value);
    Qt::CheckState checkState = static_cast<Qt::CheckState>(value.toInt());

    doLayout(opt, &checkRect, &pixmapRect, &textRect, false);

    // draw the background color
    if (option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
        QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
                                  ? QPalette::Normal : QPalette::Disabled;
        painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
    } else {
        value = model->data(index, Qt::BackgroundColorRole);
        if (value.isValid() && qvariant_cast<QColor>(value).isValid())
            painter->fillRect(option.rect, qvariant_cast<QColor>(value));
    }

    // draw the item
    drawCheck(painter, opt, checkRect, checkState);
    drawDecoration(painter, opt, pixmapRect, pixmap);
//    drawDisplay(painter, opt, textRect, text);
    drawFocus(painter, opt, textRect);
}
コード例 #9
0
ファイル: drawview.C プロジェクト: kthxbyte/KDE1-Linaro
void DrawView::setNewCenterY( double new_center_y )
  {
  if (center_y != new_center_y )
    {
    center_y = new_center_y;
    drawbuffer->fill( black );
    drawCheck();
    }
  }
コード例 #10
0
ファイル: drawview.C プロジェクト: kthxbyte/KDE1-Linaro
void DrawView::setNewIter( int new_iter )
  {
  if ( max_iter != new_iter )
    {
    max_iter = new_iter;
    color_factor = MAXCOLOR / max_iter;
    drawbuffer->fill( black );
    drawCheck();
    }
  }
コード例 #11
0
void NodeTableDelegate::paint ( QPainter* painter, 
                                const QStyleOptionViewItem& option,
                                const QModelIndex& index ) const
{
    if ( index.column() != 2 ) {
        QStyleOptionViewItem opt = option;
        
        // since we draw the grid ourselves
        QItemDelegate::paint( painter, opt, index );
    } 
    else 
    {
        QPalette::ColorGroup cg = option.state& QStyle::State_Enabled ? 
                                  QPalette::Normal : QPalette::Disabled;
        if ( option.state & QStyle::State_Selected )
            painter->fillRect( option.rect, 
                               option.palette.color( cg, 
                                                     QPalette::Highlight ) );
     
        QRect checkBoxRect1 = getCheckBoxDrawArea( option );
        QRect checkBoxRect2 = getCheckBoxDrawArea( option, false );

        // define area in which axis labels will be painted
        QRect strRect1 = 
            checkBoxRect1.adjusted( Global::checkBoxLen + 1, 0, 0, 0 );
        QRect strRect2 = 
            checkBoxRect2.adjusted( Global::checkBoxLen + 1, 0, 0, 0 );
        
        bool checked1, checked2;
        getCheckStates( checked1, checked2, index );

        drawCheck( painter, option, checkBoxRect1, checked1 ? Qt::Checked : 
                                                              Qt::Unchecked );
        drawDisplay( painter, option, strRect1, "X" );
        drawCheck( painter, option, checkBoxRect2, checked2 ? Qt::Checked :
                                                              Qt::Unchecked );
        drawDisplay( painter, option, strRect2, "Y" );

        // since we draw the grid ourselves
        drawFocus( painter, option, option.rect ); 
    }
}
コード例 #12
0
void
AttributeDelegate::paint(QPainter *painter,
                        const QStyleOptionViewItem &option,
                        const QModelIndex &index) const
{
  switch (index.column())
  {

    case AttributesModel::REQUIRED:
    {
      bool enabled = index.data().toBool();

      drawCheck(painter, option, option.rect, enabled ? Qt::Checked : Qt::Unchecked);
      drawFocus(painter, option, option.rect);
      return;
    }

    case AttributesModel::ABSTRACT:
    {
      QModelIndex typeIndex = index.model()->index(index.row(), AttributesModel::TYPE);
      QString type = typeIndex.data().toString();

      if (type == "element" || type == "inline_lo_element" || type == "lo_element")
      {
        bool enabled = index.data().toBool();
        drawCheck(painter, option, option.rect, enabled ? Qt::Checked : Qt::Unchecked);
        drawFocus(painter, option, option.rect);
      }
      return;
    }

    default:
    case AttributesModel::TYPE:
  {
      QItemDelegate::paint(painter, option, index);
      return;
  }

  }

}
コード例 #13
0
void CheckboxDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    bool value = index.data(Qt::EditRole).toBool();
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    QSize size = check(option, option.rect, Qt::Checked).size();
#else
    QSize size = doCheck(option, option.rect, Qt::Checked).size();
#endif

    QRect checkboxRect = QStyle::alignedRect(option.direction, Qt::AlignCenter, size, option.rect);
    drawCheck(painter, option, checkboxRect, (value ? Qt::Checked : Qt::Unchecked));
}
コード例 #14
0
ファイル: drawview.C プロジェクト: kthxbyte/KDE1-Linaro
void DrawView::mouseReleaseEvent( QMouseEvent *e )
  {
  int this_button;
  int my_left, my_right, my_top, my_bottom;

  this_button = e->button() & MouseButtonMask;

  switch ( this_button )
    {
    case LeftButton:
         if ( my_button == LeftButton )
           {
           point_2 = e->pos();
           my_left = QMIN( point_1.x(), point_2.x() );
           my_right = QMAX( point_1.x(), point_2.x() );
           my_top = QMIN( point_1.y(), point_2.y() );
           my_bottom = QMAX( point_1.y(), point_2.y() );
           if ( ( my_top != my_bottom ) && ( my_left != my_right ) )
             {
             center_x = center_x - my_width / 2.0 +
                        fract_ratio * my_left +
                        ( fract_ratio * ( my_right - my_left ) ) / 2.0;
             center_y = center_y - my_height / 2.0 +
                        fract_ratio * ( my_top - KFRACT_SIZE_DIFF_TOP ) +
                        ( fract_ratio * ( my_bottom - my_top ) ) / 2.0;
             my_width = ( my_width * ( my_right - my_left ) ) / width();
             my_height = ( my_width * ( height() - KFRACT_SIZE_DIFF_TOP ) ) / 
                                                                     width();
             fract_ratio = my_width / width();
             drawbuffer->fill( black );
             drawCheck();
             }
           else
             {
             bitBlt( this, my_left, my_top,
                     drawbuffer, my_left, my_top, my_right - my_left + 1,
                                                  my_bottom - my_top + 1,
                     CopyROP, FALSE );
             }
           }
         my_button = NoButton;
         break;
    case MidButton:
         my_button &= ~MidButton;
         break;
    case RightButton:
         my_button &= ~RightButton;
         break;
    default:
         break;
    }
  }
コード例 #15
0
ファイル: thumbnailview_p.cpp プロジェクト: Camelek/qtmoko
void ThumbnailDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    Q_ASSERT(index.isValid());
    const QContentSetModel *model = qobject_cast< const QContentSetModel * >( index.model() );
    Q_ASSERT(model);

    QStyleOptionViewItem opt = option;

    // set text alignment
    opt.displayAlignment = Qt::AlignCenter;

    // do layout
    QContent content = model->content( index );
    QPixmap pixmap;

    if( content.fileKnown() ) {
        pixmap = repository_->thumbnail( ThumbnailRequest( index, content.file(), option.decorationSize, content.lastUpdated() ) );
    }
    if( pixmap.isNull() ) {
        QIcon icon = qvariant_cast<QIcon>(model->data(index, Qt::DecorationRole));
        pixmap = icon.pixmap( option.decorationSize );
    }
    QRect pixmapRect = QRect(0, 0, option.decorationSize.width(),
                           option.decorationSize.height());

    QFontMetrics fontMetrics(opt.font);
    QString text = model->data(index, Qt::DisplayRole).toString();
    QRect textRect(0, 0, option.decorationSize.width(), fontMetrics.lineSpacing());

    QVariant value = model->data(index, Qt::CheckStateRole);
    QRect checkRect = check(opt, opt.rect, value);
    Qt::CheckState checkState = static_cast<Qt::CheckState>(value.toInt());

    doLayout(opt, &checkRect, &pixmapRect, &textRect, false);

    // draw the background color
    if (option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
        QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
                                  ? QPalette::Normal : QPalette::Disabled;
        painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
    } else {
        value = model->data(index, Qt::BackgroundColorRole);
        if (value.isValid() && qvariant_cast<QColor>(value).isValid())
            painter->fillRect(option.rect, qvariant_cast<QColor>(value));
    }

    // draw the item
    drawCheck(painter, opt, checkRect, checkState);
    drawDecoration(painter, opt, pixmapRect, pixmap);
    drawDisplay(painter, opt, textRect, text);
    drawFocus(painter, opt, textRect);
}
コード例 #16
0
ファイル: drawview.C プロジェクト: kthxbyte/KDE1-Linaro
void DrawView::magnify( QPoint center, double mag_factor )
  {
  center_x += fract_ratio * center.x() - my_width / 2.0;
  center_y += fract_ratio * ( center.y() - KFRACT_SIZE_DIFF_TOP ) - 
                                                  my_height / 2.0;
  my_width *= mag_factor;
// We do it this way in order to get the X/Y ration straight regardless how
// often we zoom in or out.
  my_height = ( my_width * ( height() - KFRACT_SIZE_DIFF_TOP ) ) / width();
  fract_ratio = my_width / width();
  drawbuffer->fill( black );
  drawCheck();
  }
コード例 #17
0
ファイル: drawview.C プロジェクト: kthxbyte/KDE1-Linaro
void DrawView::setNewWidth( double new_width )
  {
  if ( my_width != new_width )
    {
    my_width = new_width;
// We do it this way in order to get the X/Y ration straight regardless how
// often we zoom in or out.
    my_height = ( my_width * ( height() - KFRACT_SIZE_DIFF_TOP ) ) / width();
    fract_ratio = my_width / width();
    drawbuffer->fill( black );
    drawCheck();
    }
  }
コード例 #18
0
void TimeEditDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
                         const QModelIndex &index) const
{
    QDateTime dtval = index.model()->data(index, Qt::DisplayRole).toDateTime();

    QString indexvalue = tr("Date not set");
    if(dtval.isValid())
    {
        indexvalue = dtval.toString(timeformat);
    }
    Q_ASSERT(index.isValid());
    QStyleOptionViewItemV3 opt = setOptions(index, option);
    const QStyleOptionViewItemV2 *v2 = qstyleoption_cast<const QStyleOptionViewItemV2 *>(&option);
    opt.features = v2 ? v2->features
                    : QStyleOptionViewItemV2::ViewItemFeatures(QStyleOptionViewItemV2::None);
    const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const QStyleOptionViewItemV3 *>(&option);
    opt.locale = v3 ? v3->locale : QLocale();
    opt.widget = v3 ? v3->widget : 0;
    // prepare
    painter->save();
    painter->setClipRect(opt.rect);
    // get the data and the rectangles
    QVariant value;
    QPixmap pixmap;
    QRect decorationRect;
    value = index.data(Qt::DecorationRole);
    QString text;
    QRect displayRect;
    value = index.data(Qt::DisplayRole);
    if (value.isValid()) {
        text = indexvalue;
        displayRect = textRectangle(painter, option.rect, opt.font, text);
    }
    QRect checkRect;
    Qt::CheckState checkState = Qt::Unchecked;
    value = index.data(Qt::CheckStateRole);
    if (value.isValid()) {
        checkState = static_cast<Qt::CheckState>(value.toInt());
        //checkRect = check(opt, opt.rect, value);
    }
    // do the layout
    doLayout(opt, &checkRect, &decorationRect, &displayRect, false);
    // draw the item
    drawBackground(painter, opt, index);
    drawCheck(painter, opt, checkRect, checkState);
    drawDecoration(painter, opt, decorationRect, pixmap);
    drawDisplay(painter, opt, displayRect, text);
    drawFocus(painter, opt, displayRect);
    // done
    painter->restore();
}
コード例 #19
0
ファイル: uiSettings.c プロジェクト: Emulai/ICT289-Project
void drawAnglePresets(GLshort percUnitW, GLshort percUnitH)
{
    int i,j;
    GLshort gapW = ((percUnitW*20)-30)/4;
    GLshort gapH = ((percUnitH*20)-30)/4;

    //set angle area box
    uiS.anglesBL[0] = percUnitW*55;
    uiS.anglesBL[1] = percUnitH*60;
    uiS.anglesTR[0] = percUnitW*75;
    uiS.anglesTR[1] = percUnitH*75;

    //draw angle area box
    glBegin(GL_LINE_LOOP);
        glVertex2sv(uiS.anglesBL);
        glVertex2s(uiS.anglesTR[0], uiS.anglesBL[1]);
        glVertex2sv(uiS.anglesTR);
        glVertex2s(uiS.anglesBL[0], uiS.anglesTR[1]);
    glEnd();

    for (i=0; i<3;i++){
        for (j=0;j<3;j++){
            //set angle preset location
            uiS.anglesPS[0][i*3+j] = percUnitW*60+i*gapW; // x
            uiS.anglesPS[1][i*3+j] = percUnitH*63+j*gapH; // y
            // draw radio button for angle preset
            drawHollowCircle(uiS.anglesPS[0][i*3+j], uiS.anglesPS[1][i*3+j], 10);
            if(!tmpState.angleRand){
                if(tmpState.angle == (i*3)+j+1){
                        drawFilledCircle(uiS.anglesPS[0][i*3+j], uiS.anglesPS[1][i*3+j], 8);
                }
            }
            else{
                //if random angle selected draw cross
                drawCheck(uiS.randAng[0], uiS.randAng[1]);
                //also need to draw a cross through the circles box to indicate out of use
                glBegin(GL_LINES);
                    glVertex2sv(uiS.anglesBL);
                    glVertex2sv(uiS.anglesTR);
                glEnd();
                glBegin(GL_LINES);
                    glVertex2s(uiS.anglesTR[0], uiS.anglesBL[1]);
                    glVertex2s(uiS.anglesBL[0], uiS.anglesTR[1]);
                glEnd();
            } // end if
        }// end for
    }// end for
}// end drawPresetAngles
コード例 #20
0
void TwitterAccountsDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
  if ( checkBoxColumns.contains( index.column() ) ) {
    Qt::CheckState state;
    if ( index.model()->data( index, Qt::DisplayRole ).toBool() )
      state = Qt::Checked;
    else
      state = Qt::Unchecked;

    drawDisplay( painter, option, option.rect, " " );
    drawFocus( painter, option, option.rect );
    drawCheck( painter, option, QRect( option.rect.x()+15, option.rect.y()+3 , option.rect.height()-5, option.rect.height()-5 ), state );
  } else {
    QItemDelegate::paint(painter, option, index);
  }
}
コード例 #21
0
// draw
//---------------------------------------------------------------------------
void CheckBox::draw(Surface &dest)
{
    iRect bounds;

    getBounds(bounds);

    if (state) {
        drawCheckBox(dest);
        drawCheck(dest);
    } else {
        drawCheckBox(dest);
    }

    drawLabel(dest);

} // end CheckBox::draw
コード例 #22
0
  bool ControlPage::handleOk() {

    if(_captive) {
      _captive=false;
      drawSelection(true);
    }
    else {

      switch(_selectedButton) {

        case PROPORTIONAL:
        case INTEGER:
        case DERIVATIVE:
          _captive^=true;       // move into/out of the captive state where left/right are directed to these buttons
          drawSelection(true);
          break;

        case LEADED:
        case LEAD_FREE:
          {
            // change the selected profile to leaded/unleaded

            FlashGraphics flash(_panel);

            _leadedChecked=_selectedButton==LEADED;
            drawCheck(flash);
          }
          break;

        case REFLOW:
          if(_broken) {
            handleBroken();
            break;
          }
          else
            return true;      // trigger this class to exit

        default:
          break;
      }
    }

    // no exit from the page

    return false;
  }
コード例 #23
0
ファイル: drawview.C プロジェクト: kthxbyte/KDE1-Linaro
void DrawView::resizeEvent( QResizeEvent * )
  {

  my_width *= ( double ) width() / old_size_x;
  my_height = ( double ) ( my_width * ( height() - KFRACT_SIZE_DIFF_TOP ) ) / 
                                                                   width();
  old_size_x = width();
  old_size_y = height() - KFRACT_SIZE_DIFF_TOP;
  delete my_map;
  my_map = new int[ old_size_x * old_size_y * sizeof( int )];
  CHECK_PTR( my_map );
  delete paint_buf;
  delete drawbuffer;
  drawbuffer = new QPixmap( old_size_x, old_size_y + KFRACT_SIZE_DIFF_TOP );
  CHECK_PTR( drawbuffer );
  drawbuffer->fill( black );
  paint_buf = new QPainter( drawbuffer );
  CHECK_PTR( paint_buf );
  points_drawn = 0;
  drawCheck();
  }
コード例 #24
0
ファイル: TasksViewDelegate.cpp プロジェクト: OlivierJG/Charm
void TasksViewDelegate::paint( QPainter *painter,
                               const QStyleOptionViewItem &option,
                               const QModelIndex &index ) const
{
    painter->save();

    // Nasty QTreeView clips the painting to the editor geometry!
    // We don't want that....
    painter->setClipRect( option.rect );

    drawBackground( painter, option, index );

    const QVariant checkStateVariant = index.data(Qt::CheckStateRole);
    const Qt::CheckState checkState = static_cast<Qt::CheckState>(checkStateVariant.toInt());

    Layout layout = doLayout( option, index );

    const QRect textRect(option.rect.left(),
                         option.rect.top(),
                         option.rect.width() - layout.cbRect.width(),
                         layout.height);

    // Prepare QStyleOptionViewItem with the wanted alignments
    QStyleOptionViewItem modifiedOption = option;
    modifiedOption.displayAlignment = Qt::AlignLeft | Qt::AlignVCenter;
    modifiedOption.decorationAlignment = Qt::AlignLeft | Qt::AlignVCenter;

    // Draw text (task id+name)
    const QString taskName = index.data(Qt::DisplayRole).toString();
    QString elidedTask = elidedTaskName( taskName, painter->font(),
                                         textRect.width() );
    drawDisplay(painter, modifiedOption, textRect, elidedTask);

    // Draw checkbox
    drawCheck(painter, option, layout.cbRect, checkState);
    painter->restore();
}
コード例 #25
0
ファイル: qitemdelegate.cpp プロジェクト: phen89/rtqt
/*!
    Renders the delegate using the given \a painter and style \a option for
    the item specified by \a index.

    When reimplementing this function in a subclass, you should update the area
    held by the option's \l{QStyleOption::rect}{rect} variable, using the
    option's \l{QStyleOption::state}{state} variable to determine the state of
    the item to be displayed, and adjust the way it is painted accordingly.

    For example, a selected item may need to be displayed differently to
    unselected items, as shown in the following code:

    \snippet examples/itemviews/pixelator/pixeldelegate.cpp 2
    \dots

    After painting, you should ensure that the painter is returned to its
    the state it was supplied in when this function was called. For example,
    it may be useful to call QPainter::save() before painting and
    QPainter::restore() afterwards.

    \sa QStyle::State
*/
void QItemDelegate::paint(QPainter *painter,
                          const QStyleOptionViewItem &option,
                          const QModelIndex &index) const
{
    Q_D(const QItemDelegate);
    Q_ASSERT(index.isValid());

    QStyleOptionViewItemV4 opt = setOptions(index, option);

    const QStyleOptionViewItemV2 *v2 = qstyleoption_cast<const QStyleOptionViewItemV2 *>(&option);
    opt.features = v2 ? v2->features
                    : QStyleOptionViewItemV2::ViewItemFeatures(QStyleOptionViewItemV2::None);
    const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const QStyleOptionViewItemV3 *>(&option);
    opt.locale = v3 ? v3->locale : QLocale();
    opt.widget = v3 ? v3->widget : 0;

    // prepare
    painter->save();
    if (d->clipPainting)
        painter->setClipRect(opt.rect);

    // get the data and the rectangles

    QVariant value;

    QPixmap pixmap;
    QRect decorationRect;
    value = index.data(Qt::DecorationRole);
    if (value.isValid()) {
        // ### we need the pixmap to call the virtual function
        pixmap = decoration(opt, value);
        if (value.type() == QVariant::Icon) {
            d->tmp.icon = qvariant_cast<QIcon>(value);
            d->tmp.mode = d->iconMode(option.state);
            d->tmp.state = d->iconState(option.state);
            const QSize size = d->tmp.icon.actualSize(option.decorationSize,
                                                      d->tmp.mode, d->tmp.state);
            decorationRect = QRect(QPoint(0, 0), size);
        } else {
            d->tmp.icon = QIcon();
            decorationRect = QRect(QPoint(0, 0), pixmap.size());
        }
    } else {
        d->tmp.icon = QIcon();
        decorationRect = QRect();
    }

    QString text;
    QRect displayRect;
    value = index.data(Qt::DisplayRole);
    if (value.isValid() && !value.isNull()) {
        text = QItemDelegatePrivate::valueToText(value, opt);
        displayRect = textRectangle(painter, d->textLayoutBounds(opt), opt.font, text);
    }

    QRect checkRect;
    Qt::CheckState checkState = Qt::Unchecked;
    value = index.data(Qt::CheckStateRole);
    if (value.isValid()) {
        checkState = static_cast<Qt::CheckState>(value.toInt());
        checkRect = check(opt, opt.rect, value);
    }

    // do the layout

    doLayout(opt, &checkRect, &decorationRect, &displayRect, false);

    // draw the item

    drawBackground(painter, opt, index);
    drawCheck(painter, opt, checkRect, checkState);
    drawDecoration(painter, opt, decorationRect, pixmap);
    drawDisplay(painter, opt, displayRect, text);
    drawFocus(painter, opt, displayRect);

    // done
    painter->restore();
}
コード例 #26
0
ファイル: texenv.c プロジェクト: BioTesseract/Desktop
static void
drawSample(int x, int y, int w, int h,
  struct formatInfo *format, struct envModeInfo *envMode)
{
  glViewport(x, y, w, h);
  glScissor(x, y, w, h);

  glClearColor(0.1, 0.1, 0.1, 1.0);
  glClear(GL_COLOR_BUFFER_BIT);

  begin2D(w, h);
  drawString(format->name, 10, h - 15, labelInfoColor);
  drawString(envMode->name, 10, 5, labelInfoColor);
  end2D();

  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, envMode->mode);
  glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, envColors[envColor]);

  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

  loadTexture(textureWidth, textureHeight, format);

  if (drawBackground) {
    drawCheck(15, 15, lightCheck, darkCheck);
  }
  if (drawBlended) {
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
  }
  if (drawSmooth) {
    glShadeModel(GL_SMOOTH);
  }
  if (drawTextured) {
    glEnable(GL_TEXTURE_2D);
  }
  glBegin(GL_QUADS);
  glColor4f(1.0, 0.0, 0.0, 1.0);
  glTexCoord2f(0.0, 0.0);
  glVertex2f(-0.8, -0.8);
  glColor4f(0.0, 1.0, 0.0, 1.0);
  glTexCoord2f(1.0, 0.0);
  glVertex2f(0.8, -0.8);
  glColor4f(0.0, 0.0, 1.0, 1.0);
  glTexCoord2f(1.0, 1.0);
  glVertex2f(0.8, 0.8);
  glColor4f(1.0, 1.0, 1.0, 1.0);
  glTexCoord2f(0.0, 1.0);
  glVertex2f(-0.8, 0.8);
  glEnd();

  glDisable(GL_BLEND);
  glShadeModel(GL_FLAT);
  glDisable(GL_TEXTURE_2D);

  if (displayLevelInfo) {
    GLint width, height, border, components;
#if GL_EXT_texture
    GLint redSize, greenSize, blueSize, alphaSize;
    GLint luminanceSize, intensitySize;
#endif
    char buf[255];

    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
      GL_TEXTURE_WIDTH, &width);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
      GL_TEXTURE_HEIGHT, &height);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
      GL_TEXTURE_BORDER, &border);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
      GL_TEXTURE_COMPONENTS, &components);
#if GL_EXT_texture
    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
      GL_TEXTURE_RED_SIZE_EXT, &redSize);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
      GL_TEXTURE_GREEN_SIZE_EXT, &greenSize);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
      GL_TEXTURE_BLUE_SIZE_EXT, &blueSize);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
      GL_TEXTURE_ALPHA_SIZE_EXT, &alphaSize);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
      GL_TEXTURE_LUMINANCE_SIZE_EXT, &luminanceSize);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
      GL_TEXTURE_INTENSITY_SIZE_EXT, &intensitySize);
#endif

    begin2D(w, h);
    sprintf(buf, "dimensions: %d x %d", width, height);
    drawStringOutline(buf, 15, h / 2 + 20, labelLevelColor0, labelLevelColor1);

    sprintf(buf, "border: %d", border);
    drawStringOutline(buf, 15, h / 2 + 10, labelLevelColor0, labelLevelColor1);

    sprintf(buf, "components: 0x%04X", components);
    drawStringOutline(buf, 15, h / 2, labelLevelColor0, labelLevelColor1);

    sprintf(buf, "sizes:");
    drawStringOutline(buf, 15, h / 2 - 10, labelLevelColor0, labelLevelColor1);

#if GL_EXT_texture
    sprintf(buf, "  %d/%d/%d/%d/%d/%d",
      redSize, greenSize, blueSize, alphaSize,
      luminanceSize, intensitySize);
    drawStringOutline(buf, 15, h / 2 - 20, labelLevelColor0, labelLevelColor1);
#endif
    end2D();
  }
}
コード例 #27
0
ファイル: uiSettings.c プロジェクト: Emulai/ICT289-Project
void displayUISettings()
{
    // getting window dimensions
    GLshort w=glutGet(GLUT_WINDOW_WIDTH);
    uiS.height=glutGet(GLUT_WINDOW_HEIGHT);
    GLshort percUnitW = w/100;
    GLshort percUnitH = uiS.height/100;

    glDisable(GL_DEPTH_TEST);
    glClear(GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_PROJECTION);
    glPushMatrix(); //to prepare for return to 3D
    glLoadIdentity();
    gluOrtho2D(0,w,0,uiS.height);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    //UI background 20% of screen gap from edges
    glColor3f(1,1,1); //white
    glBegin(GL_QUADS);
        glVertex2s(percUnitW*20,percUnitH*20);
        glVertex2s(w-percUnitW*20,percUnitH*20);
        glVertex2s(w-percUnitW*20,uiS.height-percUnitH*20);
        glVertex2s(percUnitW*20,uiS.height-percUnitH*20);
    glEnd();

    glColor3f(0,0,1);
    displayText("SETTINGS:", percUnitW*22, percUnitH*78, 'l');

    //draw chosen colour if not random
    if(!tmpState.colourRand){
        uiS.chosenClr[0] = percUnitW*25;
        uiS.chosenClr[1] = percUnitH*55;
        glColor3fv(tmpState.colour);
        glBegin(GL_QUADS);
            glVertex2sv(uiS.chosenClr);
            glVertex2s(uiS.chosenClr[0]+20, uiS.chosenClr[1]);
            glVertex2s(uiS.chosenClr[0]+20, uiS.chosenClr[1]+20);
            glVertex2s(uiS.chosenClr[0], uiS.chosenClr[1]+20);
        glEnd();
        displayText("Chosen Colour", uiS.chosenClr[0]+25, uiS.chosenClr[1]+2, 'm');
    }

    //for colourpicker triangle
    drawColourPicker(percUnitW, percUnitH);
    //check box for selection of random colour
    uiS.randClr[0]=percUnitW*35;
    uiS.randClr[1]=percUnitH*55;
    drawCheckBox(uiS.randClr[0],uiS.randClr[1],"Random Colour");
    //if random colour selected draw cross
    if(tmpState.colourRand){
        drawCheck(uiS.randClr[0],uiS.randClr[1]);
    }

    //for selection of angle: draw a box then distribute evenly within 9 circles of radius 10, in 3 rows of 3, filled in for chosen angle
    drawAnglePresets(percUnitW, percUnitH);

    //check box for selection of random angle
    uiS.randAng[0] = percUnitW*60;
    uiS.randAng[1] = percUnitH*55;
    drawCheckBox(uiS.randAng[0], uiS.randAng[1] ,"Random Angle");

    //slider bar for selection of lift charge/intial velocity
    uiS.velocityL[0]= percUnitW*23;
    uiS.velocityL[1]= percUnitH*42;
    uiS.velocityR[0]= percUnitW*65;
    uiS.velocityR[1]= percUnitH*42;
    snprintf(uiS.velocityMnTxt, 6, "%4.1f", tmpState.velocityMin);
    snprintf(uiS.velocityMxTxt, 6, "%4.1f", tmpState.velocityMax);
    displayText("Lift Charge giving initial velocity in m/s:", uiS.velocityL[0]-20, uiS.velocityL[1]+15, 'm');
    drawSlider(uiS.velocityL, uiS.velocityR);
    displayText(uiS.velocityMnTxt, uiS.velocityL[0]-30, uiS.velocityL[1]-4, 'm');
    displayText(uiS.velocityMxTxt, uiS.velocityR[0]+5, uiS.velocityR[1]-4, 'm');

    //x coords of chosen velocity determined by (chosenValue - minValue)*((xRight - xLeft)/(maxValue-minValue)) + xLeft
    uiS.velocityChX = ((tmpState.velocityCh - tmpState.velocityMin)*(((float)uiS.velocityR[0]-(float)uiS.velocityL[0])/(tmpState.velocityMax-tmpState.velocityMin))+(float)uiS.velocityL[0]);
    drawMarker(uiS.velocityChX, uiS.velocityL[1]);
    snprintf(uiS.velocityChTxt, 6, "%3.1f", tmpState.velocityCh);
    displayText(uiS.velocityChTxt, uiS.velocityChX-10, uiS.velocityL[1]-17, 'm');

    //slider bar for selection of fuser timer
    uiS.fuseL[0]= percUnitW*23;
    uiS.fuseL[1]= percUnitH*32;
    uiS.fuseR[0]= percUnitW*65;
    uiS.fuseR[1]= percUnitH*32;
    snprintf(uiS.fuseMnTxt, 6, "%5.1f", tmpState.fuseMin);
    snprintf(uiS.fuseMxTxt, 6, "%5.1f", tmpState.fuseMax);
    displayText("Fuse timer from launch to explosion in milliseconds:", uiS.fuseL[0]-20, uiS.fuseL[1]+15, 'm');
    drawSlider(uiS.fuseL, uiS.fuseR);
    displayText(uiS.fuseMnTxt, uiS.fuseL[0]-40, uiS.fuseL[1]-4, 'm');
    displayText(uiS.fuseMxTxt, uiS.fuseR[0]+5, uiS.fuseR[1]-4, 'm');

    //x coords of chosen fuse determined by (chosenValue - minValue)*((xRight - xLeft)/(maxValue-minValue)) + xLeft
    uiS.fuseChX = ((tmpState.fuseCh - tmpState.fuseMin)*(((float)uiS.fuseR[0]-(float)uiS.fuseL[0])/(tmpState.fuseMax-tmpState.fuseMin))+(float)uiS.fuseL[0]);
    drawMarker(uiS.fuseChX, uiS.fuseL[1]);
    snprintf(uiS.fuseChTxt, 6, "%5.1f", tmpState.fuseCh);
    displayText(uiS.fuseChTxt, uiS.fuseChX-10, uiS.fuseL[1]-17, 'm');


    //save button
    uiS.saveBL[0] = percUnitW*70;
    uiS.saveBL[1] = percUnitH*31;
    uiS.saveTR[0] = percUnitW*79;
    uiS.saveTR[1] = percUnitH*39;
    glColor3f(0, 0.5, 0);
    glBegin(GL_QUADS);
        glVertex2sv(uiS.saveBL);
        glVertex2s(uiS.saveTR[0], uiS.saveBL[1]);
        glVertex2sv(uiS.saveTR);
        glVertex2s(uiS.saveBL[0], uiS.saveTR[1]);
    glEnd();
    displayText("Save", uiS.saveBL[0]+5, uiS.saveBL[1]+5,'l');
    //underline S
    glLineWidth(2);
    glBegin(GL_LINES);
        glVertex2s(uiS.saveBL[0]+6,uiS.saveBL[1]+3);
        glVertex2s(uiS.saveBL[0]+18,uiS.saveBL[1]+3);
    glEnd();
    glLineWidth(1);

    //cancel button
    uiS.cancelBL[0] = percUnitW*70;
    uiS.cancelBL[1] = percUnitH*22;
    uiS.cancelTR[0] = percUnitW*79;
    uiS.cancelTR[1] = percUnitH*30;
    glColor3f(0.6, 0, 0);
    glBegin(GL_QUADS);
        glVertex2sv(uiS.cancelBL);
        glVertex2s(uiS.cancelTR[0], uiS.cancelBL[1]);
        glVertex2sv(uiS.cancelTR);
        glVertex2s(uiS.cancelBL[0], uiS.cancelTR[1]);
    glEnd();
    displayText("Cancel", uiS.cancelBL[0]+5, uiS.cancelBL[1]+5,'l');
    //underline C
    glLineWidth(2);
    glBegin(GL_LINES);
        glVertex2s(uiS.cancelBL[0]+6,uiS.cancelBL[1]+3);
        glVertex2s(uiS.cancelBL[0]+18,uiS.cancelBL[1]+3);
    glEnd();
    glLineWidth(1);

    // returning to 3D
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);

    glEnable(GL_DEPTH_TEST);
}
コード例 #28
0
  void ControlPage::drawSelectionAndCheck(FlashGraphics& flash,bool draw) {

    drawSelection(draw);
    drawCheck(flash);
  }
コード例 #29
0
ファイル: cg200.c プロジェクト: jasongi/teapot
/*
 =======================================================================================================================
    Display function. Where the magic happens and everything is drawn.
 =======================================================================================================================
 */
void display(void)
{
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	/* adjust for zoom value */
	gluPerspective(50 * zoom, (float) glutGet(GLUT_WINDOW_WIDTH) / (float) glutGet(GLUT_WINDOW_HEIGHT), 0.001, 40.0);
	glMatrixMode(GL_MODELVIEW);

	/* do rotation things */
	alpha = alpha + (float) inc;
	if(alpha > (float) 360.0) alpha -= (float) 360.0;
	beta = beta + (float) inc2;
	if(beta > (float) 360.0) beta -= (float) 360.0;

	/* normalise any normals which aren't in unit form */
	glEnable(GL_NORMALIZE);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	/* draw the fog */
	fog();
	glPushMatrix();

	/* translate whole scene so we can actually see it */
	glTranslatef((float) 0.0, -(float) 0.5, -(float) 5);

	/* rotate by rotation values */
	glRotatef(beta, (float) 1.0, (float) 0.0, (float) 0.0);
	glRotatef(-alpha, (float) 0.0, (float) 1.0, (float) 0.0);

	/* it was a bit big... */
	glScalef(0.50, 0.50, 0.50);

	/* set shade mode */
	glShadeModel(shademode);
	glPushMatrix();

	/* draw the floor */
	glScalef(scale * 5, scale * 5, scale * 5);
	glRotatef(180, 0, 1.0, 1.0);
	drawCheck(20, 20, BLUE, YELLOW);	/* draw ground */
	glPopMatrix();

	/* set up the lights */
	glTranslatef(0.3, 0, 1.25);
	glEnable(GL_LIGHTING);

	/* this is a positioned light */
	glEnable(GL_LIGHT0);

	/* this is a directed light */
	glEnable(GL_LIGHT1);

	/* this is a spotlight (not initiated til later) */
	glEnable(GL_LIGHT2);

	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	/* set the ambient light */
	GLfloat ambientColor[] = { 0.2, 0.2, 0.2, 1.0 };
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor);

	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	GLfloat lightColor0[] = { 0.5, 0.5, 0.5, 1.0 };
	GLfloat lightPos0[] = { 0.0f, 1.5f, -1.0f, 0.0f };
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0);
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);

	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	GLfloat lightColor1[] = { 0.8f, 0.8f, 0.8f, 1.0f };
	GLfloat lightPos1[] = { 1.0f, 2.0f, -2.0f, 0.0f };
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	glLightfv(GL_LIGHT1, GL_DIFFUSE, lightColor1);
	glLightfv(GL_LIGHT1, GL_POSITION, lightPos1);

	/* draw the table */
	glPushMatrix();
	glTranslatef(-0.3, 0, -1.25);
	glRotatef(180, 0, 1.0, 1.0);

	/*~~~~~~~~~~~~~~~~~~~~~~~*/
	float	cylbase = 0.60;
	float	cyltop = 0.15;
	float	cylheight = 1.0;
	float	tableheight = 0.10;
	float	tablecirc = 0.90;
	/*~~~~~~~~~~~~~~~~~~~~~~~*/

	setMaterial(finTable);
	setColor(TABLE2);
	gluCylinder(quadratic, cylbase, cyltop, cylheight, splines * LOD, splines * LOD);
	glTranslatef(0, 0, cylheight);
	gluDisk(quadratic, 0.0, cyltop, splines * LOD, splines * LOD);
	gluCylinder(quadratic, tablecirc, tablecirc, tableheight, splines * LOD, splines * LOD);
	gluDisk(quadratic, 0.0, tablecirc, splines * LOD, splines * LOD);
	glTranslatef(0, 0, tableheight);
	gluDisk(quadratic, 0.0, tablecirc, splines * LOD, splines * LOD);
	setMaterial(finDefault);
	glPopMatrix();
	glPushMatrix();

	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	/* initiate the spotlight */
	GLfloat light_ambient2[] = { 0.0, 0.0, 0.0, 1.0 };
	GLfloat light_diffuse2[] = { 0.0, 0.3, 0, 1.0 };
	GLfloat light_specular2[] = { 0.0, 0.3, 0, 1.0 };
	GLfloat lightPos2[] = { 0.0f, 3.0f, 0.0f, 0.0f };
	GLfloat spot_direction[] = { 0, -1.0, 0 };
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	glLightfv(GL_LIGHT2, GL_AMBIENT, light_ambient2);
	glLightfv(GL_LIGHT2, GL_DIFFUSE, light_diffuse2);
	glLightfv(GL_LIGHT2, GL_SPECULAR, light_specular2);
	glLightf(GL_LIGHT2, GL_SPOT_CUTOFF, 30.0);
	glLightfv(GL_LIGHT2, GL_POSITION, lightPos2);
	glLightfv(GL_LIGHT2, GL_SPOT_DIRECTION, spot_direction);

	/* draw the chairs and rotate them around the table */
	glRotatef(270, 0.0, 1.0, 0.0);
	glTranslatef(-1.5, 0, 1.5);
	glPushMatrix();
	glRotatef(90, 0, 1.0, 0.0);
	chair();
	glPopMatrix();
	glPushMatrix();
	glTranslatef(0.3, 0, -1.25);
	glRotatef(90, 0, 1.0, 0.0);
	glTranslatef(-0.3, 0, 1.25);
	glRotatef(90, 0, 1.0, 0.0);
	chair();
	glPopMatrix();
	glPushMatrix();
	glTranslatef(0.3, 0, -1.25);
	glRotatef(180, 0, 1.0, 0.0);
	glTranslatef(-0.3, 0, 1.25);
	glRotatef(90, 0, 1.0, 0.0);
	chair();
	glPopMatrix();
	glPushMatrix();
	glTranslatef(0.3, 0, -1.25);
	glRotatef(270, 0, 1.0, 0.0);
	glTranslatef(-0.3, 0, 1.25);
	glRotatef(90, 0, 1.0, 0.0);
	chair();
	glPopMatrix();

	/* draw the cups/forks and rotate around the table */
	glPushMatrix();
	glTranslatef(0.35, 1.1, -0.25);
	cups();
	glPushMatrix();
	glTranslatef(-0.05, 0, -1.0);
	glRotatef(90, 0, 1.0, 0);
	glTranslatef(0.05, 0, 1.0);
	cups();
	glPopMatrix();
	glPushMatrix();
	glTranslatef(-0.05, 0, -1.0);
	glRotatef(180, 0, 1.0, 0);
	glTranslatef(0.05, 0, 1.0);
	cups();
	glPopMatrix();
	glPushMatrix();
	glTranslatef(-0.05, 0, -1.0);
	glRotatef(270, 0, 1.0, 0);
	glTranslatef(0.05, 0, 1.0);
	cups();
	glPopMatrix();
	glPopMatrix();

	/* draw the teapot */
	glPushMatrix();

	/* put on table */
	glTranslatef(0.3, 1.3, -1.25);

	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	/* trans values for animation */
	static int		rotateval = 1;
	static int		rotatevalx = 0;
	static float	transvaly = 0;
	static float	transvalx = 0;
	/* clock values for animation */
	static int		beginslow = 0;
	static int		slowclock = 0;
	static int		pourclock = 0;
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	/* only animate when playing */
	if(ani_play)
	{
		{
			/*~~~*/
			int ii;
			/*~~~*/

			for(ii = 0; ii < speed; ii++)
			{
				{

					/* section where teapot slows */
					if((beginslow))
					{
						{
							if(((20 - slowclock / 10) > 0))
							{
								rotateval = rotateval + (20 - slowclock / 10);
								slowclock++;
							}
							else
							{
								{

									/* section where teapot is pouring */
									if(pourclock < 90)
									{
										{
											rotatevalx = pourclock / 2;
											transvaly = ((double) pourclock) / (double) 200;
											transvalx = ((double) pourclock) / (double) 400;
										}
									}
									else if(pourclock < 135)
									{	/* teapot in mid air */
										rotatevalx = 45;
										transvaly = 90.0 / 200;
										transvalx = 90.0 / 400;
									}
									else if(pourclock < 225)
									{
										{	/* teapot is being set down */
											rotatevalx = 45 - (pourclock - 135) / 2;
											transvaly = 90.0 / 200 - ((double) pourclock - 135) / (double) 200;
											transvalx = 90.0 / 400 - ((double) pourclock - 135) / (double) 400;
										}
									}
									else if(pourclock < 300)
									{		/* teapot is back on table */
										rotatevalx = 0;
										transvaly = 0;
										transvalx = 0;
									}
									else
									{
										{	/* reset variables for next play */
											ani_play = 0;
											ani_clock = 0;
											rotateval = 1;
											ani_direction = 0;
											slowclock = 0;
											pourclock = -speed;
											beginslow = 0;
											rotatevalx = 0;
											transvaly = 0;
											transvalx = 0;
										}
									}

									pourclock++;
								}
							}
						}
					}
					else if(ani_clock < 200)
					{			/* teapot is speeding up it's spin */
						rotateval = rotateval + ani_clock / 10;
					}
					else if(ani_clock < 500)
					{
						{		/* teapot is at constant spin */
							rotateval = rotateval + 20;
							if(ani_clock == 300)
							{	/* choose the cup it will stop at */
								ani_direction = rand() % 4 + 1;
							}
						}
					}

					if(rotateval > 360) rotateval -= 360;
					if
					(
						(!beginslow)
					&&	(ani_direction != 0)
					&&	(
							(
								(rotateval >= ani_direction * 90 - SLOWMAGIC - 20)
							&&	(rotateval <= ani_direction * 90 - SLOWMAGIC)
							)
						||	(
									(rotateval >= ani_direction * 90 - SLOWMAGIC + 340)
								&&	(rotateval <= ani_direction * 90 - SLOWMAGIC + 360)
								)
						)
					)
					{			/* choose opportune moment to slow down */
						beginslow = 1;
						rotateval = ani_direction * 90 - SLOWMAGIC + 360;
						if(rotateval > 360) rotateval -= 360;
					}

					ani_clock++;
				}
			}
		}	/* apply transformations */
	}

	glRotatef(rotateval, 0, 1.0, 0);
	glTranslatef(transvalx, transvaly, 0);
	glRotatef(-rotatevalx, 0, 0, 1.0);

	/* apply texture */
	glBindTexture(GL_TEXTURE_2D, texture[1]);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glEnable(GL_TEXTURE_2D);

	/* apply finish */
	setMaterial(finPot);
	glutSolidTeapot(0.2);
	setMaterial(finDefault);
	glDisable(GL_TEXTURE_2D);
	glPopMatrix();
	glPopMatrix();
	glPopMatrix();

	/* 3D stuff is done */
	glFlush();

	/* draw text overlay */
	glDisable(GL_NORMALIZE);
	glDisable(GL_LIGHTING);
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(0, glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT), 0, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();

	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	char	speedstring[20];
	char	str[500] = "<Z> and <z>: zoom in/out\n<X> or <x>: Start/Stop X rotation\n<Y> or <y> Start/Stop Y Rotation\n<A> or <a>: Start animation\n<F> or <f>: Speed up animation\n<S> or <s>: Slow down animation\n<T> or <t>: Pause animation\n<C> or <c>: Resume the animation\n<p>: switch the rendering to the flat shaded polygonization.\n<P> switch the rendering to the smooth shaded polygonization.\n<q> or <Q>: change fog mode\nspeed: ";
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	sprintf(speedstring, "%d", speed);
	strcat(str, speedstring);
	strcat(str, "\nLOD: ");
	sprintf(speedstring, "%d", LOD);
	strcat(str, speedstring);
	strcat(str, "\nFog Mode: ");
	switch(fogfilter)
	{
		{
		case 0: strcat(str, "GL_EXP"); break;
		case 1: strcat(str, "GL_EXP2"); break;
		case 2: strcat(str, "GL_LINEAR"); break;
		case 3: strcat(str, "NO FOG"); break;
		}
	}

	bitmap_output(30, 30, str, GLUT_BITMAP_HELVETICA_12);
	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();

	/* draw transparent box for text */
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(0, glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT), 0, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glColor4f((float) 0, (float) 0, (float) 0, (float) 0.6);
	glRecti(30 - 10, 30 - 20, 40 + 350, 30 + 250);
	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glFlush();
	glutSwapBuffers();
}