Exemplo n.º 1
0
void
Monitor::NodeGenerator::calcLayout(TreeNode *t, int w, int h)
{
  static int xpos = 0;
  static int ypos = 0;

  // reset width and height of scene
  if (t == 0) {
    return;
  }

  QString text;

  if (isNodeValid(t, text)) {

    xpos = w * 100;
    ypos += 50;

    // create nodes to figure out width and height of layout
    Node node(text, xpos, ypos, t);
    sceneWidth_ = xpos + node.boundingRect().width();
    sceneHeight_ = ypos + node.boundingRect().width();

    ++w;
    for (int i = 0; i < t->size(); ++i) {
      calcLayout(t->operator[](i), w, ++h);
    }
  }
}
Exemplo n.º 2
0
void CardView::drawContents( QPainter *p, int clipx, int clipy,
                             int clipw, int cliph )
{
  Q3ScrollView::drawContents( p, clipx, clipy, clipw, cliph );

 if ( d->mLayoutDirty )
   calcLayout();

  // allow setting costum colors in the viewport pale
  QPalette pal = viewport()->palette();

  QRect clipRect( clipx, clipy, clipw, cliph );
  QRect cardRect;
  QRect sepRect;
  CardViewItem *item;
  CardViewSeparator *sep;

  // Now tell the cards to draw, if they are in the clip region
  Q3PtrListIterator<CardViewItem> iter( d->mItemList );
  for ( iter.toFirst(); iter.current(); ++iter) {
    item = *iter;
    cardRect.setRect( item->d->x, item->d->y, d->mItemWidth, item->height() );

    if ( clipRect.intersects( cardRect ) || clipRect.contains( cardRect ) ) {
      // Tell the card to paint
      p->save();
      p->translate( cardRect.x(), cardRect.y() );
      item->paintCard( p, pal );
      p->restore();
    }
  }

  // Followed by the separators if they are in the clip region
  Q3PtrListIterator<CardViewSeparator> sepIter( d->mSeparatorList );
  for ( sepIter.toFirst(); sepIter.current(); ++sepIter ) {
    sep = *sepIter;
    sepRect = sep->mRect;

    if ( clipRect.intersects( sepRect ) || clipRect.contains( sepRect ) ) {
      p->save();
      p->translate( sepRect.x(), sepRect.y() );
      sep->paintSeparator( p, pal );
      p->restore();
    }
  }
}