KJFileInfo::KJFileInfo(const QStringList &l, KJLoader *p)
	: KJWidget(p), mBack(0)
{
	mInfoType = l[0]; // type of info-display

	int x  = l[1].toInt();
	int y  = l[2].toInt();
	int xs = l[3].toInt() - x;
	int ys = l[4].toInt() - y;

	// fix for all those weird skins where the timewindow
	// has more space than needed for the font
	int maxNeededHeight = timeFont().fontHeight();
	if ( ys > maxNeededHeight )
		ys = maxNeededHeight;

	// five digits + spacing between them
	int maxNeededWidth = ( 3 *timeFont().fontWidth() ) + ( 2 * timeFont().fontSpacing() );
	if ( xs > maxNeededWidth )
		xs = maxNeededWidth;

	// background under info-display
	QPixmap tmp  = p->pixmap(p->item("backgroundimage")[1]);
	mBack = new KPixmap ( QSize(xs,ys) );
	bitBlt( mBack, 0, 0, &tmp, x, y, xs, ys, Qt::CopyROP );

	setRect(x,y,xs,ys);

	prepareString("");
}
void KJTime::readConfig()
{
//	kdDebug(66666) << "KJTime::readConfig()" << endl;
	countDown = napp->displayRemaining();
	timeFont().recalcSysFont();
	mLastTime=""; // invalidate time so it gets repainted on next timeUpdate()
}
void KJTime::prepareString(const QCString &str)
{
//	kdDebug(66666) << "START KJTime::prepareString(const QCString &str)" << endl;
	if ( str == mLastTime )
		return;

	mLastTime = str;
	mTime = timeFont().draw(str, rect().width());

	repaint();
//	kdDebug(66666) << "END KJTime::prepareString(const QCString &str)" << endl;
}
示例#4
0
void WallClock::paintEvent(QPaintEvent *)
{
    static const int hourHand[8] = { -2, 18, 2, 18, 2, -60, -2, -60 };
    static const int minuteHand[8] = { -2, 28, 2, 28, 2, -80, -2, -80 };
    static const int secondHand[12] = {-1, 0, -1, -90, 1,-90, 1, 0, 4, 35, -4, 35};

    // odmalowywuje t³o
    drawBackground();
      // inicjalizacja paintera

    QPainter painter(this);
    initCoordinateSystem(painter);

    // Wyliczanie czasu i daty
    QTime time = m_dateTime.time(); 
    QDate date = m_dateTime.date(); 
    QString Str;
    QSize Size;

    if (timeOffset()!=0.0)
    {
      // Rysowanie tekstów - godziny
      painter.setFont(timeFont());
      painter.setPen(timeColor());
      Str = time.toString("hh:mm");
      Size = painter.fontMetrics().size(Qt::TextSingleLine, Str );
      painter.drawText( QPointF (Size.width() / -2.0, Size.height()+ timeOffset()) ,Str);
    }

    if (dateOffset()!=0.0)
    {
      // Rysowanie daty
      painter.setFont(dateFont());
      painter.setPen(dateColor());
      Str = date.toString("dd.MM.yyyy");
      Size = painter.fontMetrics().size(Qt::TextSingleLine, Str);
      painter.drawText( QPointF(Size.width() / -2.0,static_cast<int>(0 - dateOffset())), Str);
    }
    if (dayOffset()!=0.0)
    {
      // Dzieñ tygodnia
      painter.setFont(dayFont());
      painter.setPen(dayColor());
      Str =  date.toString("dddd");
      Size = painter.fontMetrics().size(Qt::TextSingleLine, Str);
      painter.drawText( QPointF (Size.width() / -2.0,static_cast<int>( 0 - dayOffset())) , Str);
    }

    // rysowanie wskazówki godzin
    painter.setPen(Qt::NoPen);
    painter.setBrush(Qt::black);
    painter.save();
    painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0)));
    painter.drawConvexPolygon(QPolygon(4, hourHand));
    painter.restore();

    // rysowanie minutnika
    painter.setBrush(Qt::black);
    painter.save();
    painter.rotate(6.0 * (time.minute() + time.second() / 60.0));
    painter.drawConvexPolygon(QPolygon(4, minuteHand));
    painter.restore();

    // Malowanie wskazówki sekundnika
    painter.setPen(Qt::NoPen);
    painter.setBrush(Qt::red);
    painter.save();
    painter.rotate(6.0 * ( time.second())); //  + time.msec() / 1000.0) );
    painter.drawConvexPolygon(QPolygon(6, secondHand));
    painter.restore();
    // Kó³ko sekundnika
    painter.drawEllipse(-5,-5,10,10);
}// paintEvent