Beispiel #1
0
//! draws the element and its children
void ListBox::draw( gfx::Engine& painter )
{
  if ( !visible() )
		return;

  if( isFlag( drawBackground ) )
  {
    if( _d->background.valid() )
      painter.draw( _d->background, &absoluteClippingRectRef() );
    else
      painter.draw( _d->backgroundNb, absoluteRect().lefttop(), &absoluteClippingRectRef() );
  }

  Point scrollBarOffset( 0, -_d->scrollBar->value() );
  Rect frameRect = _itemsRect();
  frameRect += _d->margin.lefttop();
  frameRect.rbottom() = frameRect.top() + _d->itemHeight;
  const Point& widgetLeftup = absoluteRect().lefttop();

  Rect clipRect = absoluteClippingRectRef();
  clipRect.UpperLeftCorner += Point( 3, 3 );
  clipRect.LowerRightCorner -= Point( 3, 3 );

  for( unsigned int i = 0; i < _d->items.size();  i++ )
  {
    ListBoxItem& refItem = _d->items[ i ];

    int mnY = frameRect.bottom() - _d->scrollBar->value();
    int mxY = frameRect.top() - _d->scrollBar->value();

    mnY += std::max( 0, refItem.icon().height() - frameRect.height() );

    bool overBorder = (mnY < 0 && mxY < 0 ) || (mnY > (int)height() && mxY > (int)height() );
    if( !overBorder )
    {
      if( refItem.icon().isValid() )
      {
        _drawItemIcon( painter, refItem, widgetLeftup + frameRect.lefttop() + scrollBarOffset, &clipRect );
      }

      if( refItem.picture().isValid() )
      {
        _drawItemText( painter, refItem, widgetLeftup + frameRect.lefttop() + scrollBarOffset, &clipRect  );
      }

     /* if( !refItem.url().empty() )
      {
        Point r = frameRect.rightbottom();
        r += Point( 0, -_d->scrollBar->value() );
        //_d->background->fill( currentFont.color(), textRect + Point( 0, -_d->scrollBar->position() ) + refItem.offset() );
        Point offset = localToScreen( lefttop() );
        painter.drawLine( 0xff00ff00, r - Point( frameRect.width(), 0 ) + offset, r + offset );
      } */
    }

    frameRect += Point( 0, _d->itemHeight );
  }

	Widget::draw( painter );
}
Beispiel #2
0
/* here will be helper functions for minimap generation */
void Menu::draw(gfx::Engine& painter)
{
    if( !visible() )
        return;

    if( _d->bg.batch.valid() )
        painter.draw( _d->bg.batch, &absoluteClippingRectRef() );
    else
        painter.draw( _d->bg.pics, absoluteRect().lefttop(), &absoluteClippingRectRef() );

    Widget::draw( painter );
}
Beispiel #3
0
void TopMenu::draw(gfx::Engine& engine )
{
  if( !visible() )
    return;

  _d->updateDate();

  if( _d->background.valid() )
    engine.draw( _d->background, &absoluteClippingRectRef() );
  else
    engine.draw( _d->backgroundNb, absoluteRect().lefttop(), &absoluteClippingRectRef() );

  MainMenu::draw( engine );
}
Beispiel #4
0
//! draws the element and its children
void GroupBox::draw(gfx::Engine& painter )
{
  if (!visible())
      return;

  if( _d->backgroundImage.isValid() )
  {
    painter.draw( _d->backgroundImage, absoluteRect().UpperLeftCorner, &absoluteClippingRectRef() );
  }
  else
  {
    painter.draw( _d->background, absoluteRect().UpperLeftCorner, &absoluteClippingRectRef() );
  }

  Widget::draw( painter );
}
Beispiel #5
0
//! draws the element and its children
void PushButton::draw( gfx::Engine& painter )
{
  if (!visible())
    return;

  __D_REF(_d,PushButton);
  // todo:	move sprite up and text down if the pressed state has a sprite
  //			  draw sprites for focused and mouse-over
  const ButtonState& state = _d.buttonStates[_d.state.current];

  if (isBodyVisible()) {
    DrawState pipe(painter, absoluteRect().lefttop(), &absoluteClippingRectRef());
    pipe.draw(state.background)
        .fallback(state.batch.body)
        .fallback(state.batch.fallback);
  }

  if (_d.text.visible && _d.text.picture.isValid()) {
    painter.draw(_d.text.picture, screenLeft(), screenTop(), &absoluteClippingRectRef());
  }

  drawIcon(painter);

  Widget::draw(painter);
}
void LegionTargetWindow::draw(gfx::Engine& engine )
{
  EmpireMapWindow::draw( engine );

  if( _d->location.x() > 0 )
  {
    engine.draw( _d->locationPic, _d->location + _offset() );
  }
}
Beispiel #7
0
void TopMenu::draw(gfx::Engine& engine )
{
  if( !visible() )
    return;

  _d->updateDate();

  engine.draw( _d->background, absoluteRect().UpperLeftCorner, &absoluteClippingRectRef() );

  MainMenu::draw( engine );
}
Beispiel #8
0
void PushButton::drawIcon(gfx::Engine& painter)
{
  __D_REF(_d,PushButton);
  const ButtonState& bstate = _d.buttonStates[ _d.state.current ];

  if (!bstate.icon.picture.isValid())
      return;

  Point pos = localToScreen(_d.iconRect).lefttop();
  MaskState lock(painter, _d.iconMask);
  painter.draw(bstate.icon.picture, pos + bstate.icon.offset);
}
Beispiel #9
0
void Console::draw( gfx::Engine& painter )
{
  if( !font().isValid() )
  {
    Widget::draw( painter );
    return;
  }

  if( visible() )															// render only if the console is visible
  {
    if( toggle_visible_ != NONE )
    {
      if( toggle_visible_ == DOWNLIGTH )
      {
        if (_opacity > 5) _opacity -= 9;
        else setVisible(false);
        _d->dirty = true;
      }
      else
      {
        if (_opacity < 0xff)	_opacity += 3;
        else toggle_visible_ = NONE;
        _d->dirty = true;
      }
    }

    Rect textRect, shellRect;										//we calculate where the message log shall be printed and where the prompt shall be printed
    calculatePrintRects(textRect,shellRect);

    if(_d->dirty)
    {
      Decorator::drawLines(_d->bg, ColorList::red, relativeRect().lines());
      _d->bg.fill(ColorList::blue);

      unsigned int maxLines, lineHeight;											//now, render the messages
      int fontHeight=0;
      if (!calculateLimits(maxLines,lineHeight,fontHeight))
      {
        return;
      }

      Rect lineRect( textRect.left(),						//calculate the line rectangle
                     textRect.top(),
                     textRect.right(),
                     textRect.bottom() + lineHeight);

      for (unsigned int index = 0; index < console_messages_.size(); index++)
      {
        unsigned int rindex = (_d->curIndex + index) % console_messages_.size();
        const std::string& line = console_messages_[rindex];
        font().draw(_d->bg, line, lineRect.lefttop(), false, false);
        lineRect += Point(0, lineHeight);						//update line rectangle
      }

      std::string shellText = "$>" + currentCommand_;

      font().draw( _d->bg, shellText, shellRect.lefttop(), false, false);	//draw the prompt string

      _d->dirty = false;
      _d->bg.update();
      _d->bg.setAlpha(_opacity/3*2);
    }

    painter.draw( _d->bg, absoluteRect().lefttop() );

    if( DateTime::elapsedTime() % 700 < 350 )
    {
      NColor color = ColorList::white;
      color.setAlpha(_opacity/2);
      painter.fillRect( color, Rect(0, 0, _d->commandCursorWidth,shellRect.height()*0.8)
                        +absoluteRect().leftbottom() + Point(_d->commandTextSize.width(), -shellRect.height()) );
    }
  }

  Widget::draw( painter );
}