Exemplo n.º 1
0
void Manager::updateTitleBuffer()
{
   bool active = isActive();

   Static * s = Static::instance();

   TQRect tr = titleSpacer_->tqgeometry();

   if (tr.width() == 0 || tr.height() == 0)
      titleBuf_.resize(8, 8);
   else
      titleBuf_.resize(tr.size());

   TQPainter p(&titleBuf_);

   p.drawPixmap(0, 0, s->titleTextLeft(active));

   p.drawTiledPixmap(3, 0, tr.width() - 6, Static::instance()->titleHeight(),
                     s->titleTextMid(active));

   p.setPen(options()->color(KDecorationOptions::ColorFont, active));

   p.setFont(options()->font(active));

   p.drawText(4, 2, tr.width() - 8, Static::instance()->titleHeight() - 4,
              AlignCenter, caption());

   p.drawPixmap(tr.width() - 3, 0, s->titleTextRight(active));
}
Exemplo n.º 2
0
void IppReportDlg::slotUser1()
{
	KPrinter	printer;
	printer.setFullPage(true);
	printer.setDocName(caption());
	if (printer.setup(this))
	{
		TQPainter	painter(&printer);
		TQPaintDeviceMetrics	metrics(&printer);

		// report is printed using TQSimpleRichText
		TQSimpleRichText	rich(m_edit->text(), font());
		rich.setWidth(&painter, metrics.width());
		int	margin = (int)(1.5 / 2.54 * metrics.logicalDpiY());	// 1.5 cm
		TQRect	r(margin, margin, metrics.width()-2*margin, metrics.height()-2*margin);
		int	hh = rich.height(), page(1);
		while (1)
		{
			rich.draw(&painter, margin, margin, r, colorGroup());
			TQString	s = caption() + ": " + TQString::number(page);
			TQRect	br = painter.fontMetrics().boundingRect(s);
			painter.drawText(r.right()-br.width()-5, r.top()-br.height()-4, br.width()+5, br.height()+4, Qt::AlignRight|Qt::AlignTop, s);
			r.moveBy(0, r.height()-10);
			painter.translate(0, -(r.height()-10));
			if (r.top() < hh)
			{
				printer.newPage();
				page++;
			}
			else
				break;
		}
	}
}
Exemplo n.º 3
0
bool NextClient::drawbound(const TQRect& geom, bool /* clear */)
{
    TQPainter p(workspaceWidget());
    p.setPen(TQPen(TQt::white, 3));
    p.setRasterOp(TQt::XorROP);
    p.drawRect(geom);
    int leftMargin = geom.left() + 2;
    p.fillRect(leftMargin, geom.top() + titleHeight - 1,
	    geom.width() - 4, 3, TQt::white);
    if (mustDrawHandle()) {
	p.fillRect(leftMargin, geom.bottom() - handleSize - 1,
		geom.width() - 4, 3, TQt::white);
    }	    
    return true;
}
Exemplo n.º 4
0
void EvaLVToolTip::maybeTip(const TQPoint &p)
{
	EvaListViewItem *item = dynamic_cast<EvaListViewItem *>(m_lv->itemAt(p));
	if(!item) return;

	int section = m_lv->header()->sectionAt(p.x());
	TQRect itemRect = m_lv->itemRect(item);
	TQRect headerRect = m_lv->header()->sectionRect(section);
	TQRect destRect(headerRect.left(), itemRect.top(), headerRect.width(), itemRect.height());
	
        tip(destRect, item->tip());
	
}
Exemplo n.º 5
0
TQWidget *KWMapEditor::beginEdit(int row, int col, bool replace) {
	//kdDebug(2300) << "EDIT COLUMN " << col << endl;
	if (col != 2) {
		return TQTable::beginEdit(row, col, replace);
	}

	TQRect geo = cellGeometry(row, col);
	TQTextEdit *e = new InlineEditor(this, row, col);
	e->setText(text(row, col));
	e->move(mapToGlobal(geo.topLeft()));
	e->resize(geo.width() * 2, geo.height() * 3);
	e->show();
	return e;
}
Exemplo n.º 6
0
bool Manager::animateMinimize(bool iconify)
{
   int style = Static::instance()->animationStyle();

   switch (style)
   {
      case 1:
      {
         // Double twisting double back, with pike ;)

         if (!iconify) // No animation for restore.
            return true;

         // Go away quick.
         helperShowHide(false);
         tqApp->syncX();

         TQRect r = iconGeometry();

         if (!r.isValid())
            return true;

         // Algorithm taken from Window Maker (http://www.windowmaker.org)

         int sx = geometry().x();
         int sy = geometry().y();
         int sw = width();
         int sh = height();
         int dx = r.x();
         int dy = r.y();
         int dw = r.width();
         int dh = r.height();

         double steps = 12;

         double xstep = double((dx-sx)/steps);
         double ystep = double((dy-sy)/steps);
         double wstep = double((dw-sw)/steps);
         double hstep = double((dh-sh)/steps);

         double cx = sx;
         double cy = sy;
         double cw = sw;
         double ch = sh;

         double finalAngle = 3.14159265358979323846;

         double delta  = finalAngle / steps;

         TQPainter p(workspaceWidget());
         p.setRasterOp(TQt::NotROP);

         for (double angle = 0; ; angle += delta)
         {
            if (angle > finalAngle)
               angle = finalAngle;

            double dx = (cw / 10) - ((cw / 5) * sin(angle));
            double dch = (ch / 2) * cos(angle);
            double midy = cy + (ch / 2);

            TQPoint p1(int(cx + dx), int(midy - dch));
            TQPoint p2(int(cx + cw - dx), p1.y());
            TQPoint p3(int(cx + dw + dx), int(midy + dch));
            TQPoint p4(int(cx - dx), p3.y());

            grabXServer();

            p.drawLine(p1, p2);
            p.drawLine(p2, p3);
            p.drawLine(p3, p4);
            p.drawLine(p4, p1);

            p.flush();

            usleep(500);

            p.drawLine(p1, p2);
            p.drawLine(p2, p3);
            p.drawLine(p3, p4);
            p.drawLine(p4, p1);

            ungrabXServer();

            cx += xstep;
            cy += ystep;
            cw += wstep;
            ch += hstep;

            if (angle >= finalAngle)
               break;
         }
      }
      break;

      case 2:
      {
         // KVirc style ? Maybe. For qwertz.

         if (!iconify) // No animation for restore.
            return true;

         // Go away quick.
         helperShowHide(false);
         tqApp->syncX();

         int stepCount = 12;

         TQRect r(geometry());

         int dx = r.width() / (stepCount * 2);
         int dy = r.height() / (stepCount * 2);

         TQPainter p(workspaceWidget());
         p.setRasterOp(TQt::NotROP);

         for (int step = 0; step < stepCount; step++)
         {
            r.moveBy(dx, dy);
            r.setWidth(r.width() - 2 * dx);
            r.setHeight(r.height() - 2 * dy);

            grabXServer();

            p.drawRect(r);
            p.flush();
            usleep(200);
            p.drawRect(r);

            ungrabXServer();
         }
      }
      break;


      default:
      {
         TQRect icongeom = iconGeometry();

         if (!icongeom.isValid())
            return true;

         TQRect wingeom = geometry();

         TQPainter p(workspaceWidget());

         p.setRasterOp(TQt::NotROP);
#if 0
         if (iconify)
            p.setClipRegion(TQRegion(workspaceWidget()->rect()) - wingeom);
#endif
         grabXServer();

         p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
         p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
         p.drawLine(wingeom.topLeft(), icongeom.topLeft());
         p.drawLine(wingeom.topRight(), icongeom.topRight());

         p.flush();

         tqApp->syncX();

         usleep(30000);

         p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
         p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
         p.drawLine(wingeom.topLeft(), icongeom.topLeft());
         p.drawLine(wingeom.topRight(), icongeom.topRight());

         ungrabXServer();
      }
      break;
   }
   return true;
}
Exemplo n.º 7
0
void NextClient::paintEvent( TQPaintEvent* )
{
    TQPainter p(widget());

    // Draw black frame
    TQRect fr = widget()->rect();
    p.setPen(TQt::black);
    p.drawRect(fr);

    // Draw title bar
    TQRect t = titlebar->tqgeometry();
    t.setTop(1);
    p.drawTiledPixmap(t.x()+1, t.y()+1, t.width()-2, t.height()-2,
                      isActive() ? *aTitlePix : *iTitlePix);
    qDrawShadePanel(&p, t.x(), t.y(), t.width(), t.height()-1,
                   options()->tqcolorGroup(KDecoration::ColorTitleBar, isActive()));
    p.drawLine(t.x(), t.bottom(), t.right(), t.bottom());

#if 0
    // Why setting up a clipping region if it is not used? (setClipping(false))
    TQRegion r = fr;
    r = r.subtract( t );
    p.setClipRegion( r );
    p.setClipping(false);
#endif

    t.setTop( 1 );
    t.setHeight(t.height()-2);
    t.setLeft( t.left() + 4 );
    t.setRight( t.right() - 2 );

    p.setPen(options()->color(KDecoration::ColorFont, isActive()));
    p.setFont(options()->font(isActive()));
    p.drawText( t, AlignCenter | AlignVCenter, caption() );

    // Draw resize handle
    if (mustDrawHandle()) {
        int corner = 16 + 3*handleSize/2;
	qDrawShadePanel(&p,
		fr.x() + 1, fr.bottom() - handleSize, corner-1, handleSize,
		options()->tqcolorGroup(KDecoration::ColorHandle, isActive()),
		false);
	p.drawTiledPixmap(fr.x() + 2, fr.bottom() - handleSize + 1,
		corner - 3, handleSize - 2, isActive() ? *aHandlePix : *iHandlePix);

	qDrawShadePanel(&p,
		fr.x() + corner, fr.bottom() - handleSize,
		fr.width() - 2*corner, handleSize,
		options()->tqcolorGroup(KDecoration::ColorFrame, isActive()),
		false);
	p.drawTiledPixmap(fr.x() + corner + 1, fr.bottom() - handleSize + 1,
		fr.width() - 2*corner - 2, handleSize - 2,
		isActive() ? *aFramePix : *iFramePix);

	qDrawShadePanel(&p,
		fr.right() - corner + 1, fr.bottom() - handleSize, corner - 1, handleSize,
		options()->tqcolorGroup(KDecoration::ColorHandle, isActive()),
		false);
	p.drawTiledPixmap(fr.right() - corner + 2, fr.bottom() - handleSize + 1,
		corner - 3, handleSize - 2, isActive() ? *aHandlePix : *iHandlePix);
    }
}
Exemplo n.º 8
0
void KJanusWidget::addPageWidget( TQFrame *page, const TQStringList &items,
				  const TQString &header,const TQPixmap &pixmap )
{
  connect(page, TQT_SIGNAL(destroyed(TQObject*)), TQT_SLOT(pageGone(TQObject*)));

  if( mFace == Tabbed )
  {
    mTabControl->addTab (page, items.last());
    d->mIntToPage[d->mNextPageIndex] = static_cast<TQWidget*>(page);
    d->mPageToInt[static_cast<TQWidget*>(page)] = d->mNextPageIndex;
    d->mNextPageIndex++;
  }
  else if( mFace == TreeList || mFace == IconList )
  {
    d->mIntToPage[d->mNextPageIndex] = static_cast<TQWidget*>(page);
    d->mPageToInt[static_cast<TQWidget*>(page)] = d->mNextPageIndex;
    mPageStack->addWidget( page, 0 );

    if (items.isEmpty()) {
      kdDebug() << "Invalid TQStringList, with zero items" << endl;
      return;
    }

    if( mFace == TreeList )
    {
      InsertTreeListItem(items, pixmap, page);
    }
    else // mFace == IconList
    {
      TQString itemName = items.last();
      IconListItem *item = new IconListItem( mIconList, pixmap, itemName );
      mIconListToPageStack.insert(item, page);
      mIconList->invalidateHeight();
      mIconList->invalidateWidth();

      if (mIconList->isVisible())
        mIconList->updateWidth();
    }

    //
    // Make sure the title label is sufficiently wide
    //
    TQString lastName = items.last();
    const TQString &title = (!header.isNull() ? header : lastName);
    TQRect r = mTitleLabel->fontMetrics().boundingRect( title );
    if( mTitleLabel->minimumWidth() < r.width() )
    {
      mTitleLabel->setMinimumWidth( r.width() );
    }
    d->mIntToTitle[d->mNextPageIndex] = title;
    if( d->mIntToTitle.count() == 1 )
    {
      showPage(0);
    }
    d->mNextPageIndex++;
  }
  else
  {
    kdDebug() << "KJanusWidget::addPageWidget: can only add a page in Tabbed, TreeList or IconList modes" << endl;
  }

}
Exemplo n.º 9
0
void KFileIVIDesktop::drawShadowedText( TQPainter *p, const TQColorGroup &cg )
{
  bool drawRoundedRect = TDEGlobalSettings::iconUseRoundedRect();

  int textX;
  if (drawRoundedRect == true)
    textX = textRect( FALSE ).x() + 4;
  else
    textX = textRect( FALSE ).x() + 2;
  int textY = textRect( FALSE ).y();
  int align = ((TDEIconView *) iconView())->itemTextPos() == TQIconView::Bottom
    ? AlignHCenter : AlignAuto;
  // FIXME
  // Work around incorrect shadow position detailed in Bug 1807
  bool rebuild = true; // shouldUpdateShadow(isSelected());

  KDesktopShadowSettings *settings = (KDesktopShadowSettings *) (m_shadow->shadowSettings());

  unsigned long uid = settings->UID();

  p->setFont(iconView()->font());
  paintFontUpdate(p);
  TQColor shadow;
  TQColor text;
  int spread = shadowThickness();

  if ( isSelected() && settings->selectionType() != KShadowSettings::InverseVideoOnSelection ) {
    text = cg.highlightedText();
    TQRect rect = textRect( false );
    rect.setRight( rect.right() - spread );
    rect.setBottom( rect.bottom() - spread + 1 );
    if (drawRoundedRect == true) {
      p->setBrush( TQBrush( cg.highlight() ) );
      p->setPen( TQPen( cg.highlight() ) );
      p->drawRoundRect( rect,
		      1000 / rect.width(),
		      1000 / rect.height() );
    }
    else {
      p->fillRect( textRect( false ), cg.highlight() );
    }
  }
  else {
    // use shadow
    if ( isSelected() ) {
      // inverse text and shadow colors
      shadow = settings->textColor();
      text = settings->bgColor();
      if ( rebuild ) {
        setSelectedImage( buildShadow( p, align, shadow ) );
        _selectedUID = uid;
      }
    }
    else {
      text = settings->textColor();
      shadow = ( settings->bgColor().isValid() ) ? settings->bgColor() :
               ( tqGray( text.rgb() ) > 127 ) ? black : white;
      if (rebuild) {
        setNormalImage(buildShadow(p, align, shadow));
        _normalUID = uid;
      }
    }

    // draw the shadow
    int shadowX = textX - spread + settings->offsetX();
    int shadowY = textY - spread + settings->offsetY();

    p->drawImage(shadowX, shadowY,
      (isSelected()) ? *selectedImage() : *normalImage(),
      0, 0, -1, -1, DITHER_FLAGS);
  }

  // draw the text
  p->setPen(text);
  wordWrap()->drawText( p, textX, textY, align | KWordWrap::Truncate );
}