/*! \reimp */ void QProgressBar::drawContents( QPainter *p ) { const QRect bar = contentsRect(); QSharedDoubleBuffer buffer( p, bar.x(), bar.y(), bar.width(), bar.height() ); QPoint pn = backgroundOffset(); buffer.painter()->setBrushOrigin( -pn.x(), -pn.y() ); const QPixmap *bpm = paletteBackgroundPixmap(); if ( bpm ) buffer.painter()->fillRect( bar, QBrush( paletteBackgroundColor(), *bpm ) ); else buffer.painter()->fillRect( bar, paletteBackgroundColor() ); buffer.painter()->setFont( p->font() ); QStyle::SFlags flags = QStyle::Style_Default; if (isEnabled()) flags |= QStyle::Style_Enabled; if (hasFocus()) flags |= QStyle::Style_HasFocus; style().drawControl(QStyle::CE_ProgressBarGroove, buffer.painter(), this, QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarGroove, this), this ), colorGroup(), flags); style().drawControl(QStyle::CE_ProgressBarContents, buffer.painter(), this, QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarContents, this), this ), colorGroup(), flags); if (percentageVisible()) style().drawControl(QStyle::CE_ProgressBarLabel, buffer.painter(), this, QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarLabel, this), this ), colorGroup(), flags); }
/* void KColorGrid::show() { //updateScrollBars(); QWidget::show(); } */ void KColorGrid::paintEvent(QPaintEvent *e) { //kdDebug(4640) << "KColorGrid::paintEvent" << endl; //updateScrollBars(); //QWidget::paintEvent(e); const QRect urect = e->rect(); //kdDebug(4640) << "Update rect = ( " << //urect.left() << ", " << urect.top() << ", " << urect.width() << ", " << urect.height() << " )" << endl; int firstcol = getX(urect.x())-1; int firstrow = getY(urect.y())-1; int lastcol = getX(urect.right())+1; int lastrow = getY(urect.bottom())+1; QWMatrix matrix; QPixmap pm(urect.width(),urect.height()); pm.fill(paletteBackgroundColor()); QPainter p; p.begin( &pm ); firstrow = (firstrow < 0) ? 0 : firstrow; firstcol = (firstcol < 0) ? 0 : firstcol; lastrow = (lastrow >= rows) ? rows : lastrow; lastcol = (lastcol >= cols) ? cols : lastcol; //kdDebug(4640) << urect.x() << " x " << urect.y() << " - row: " << urect.width() << " x " << urect.height() << endl; //kdDebug(4640) << "col: " << firstcol << " -> " << lastcol << " - row: " << firstrow << " -> " << lastrow << endl; /* if(this->isA("KDrawGrid")) kdDebug(4640) << "KDrawGrid\n firstcol: " << firstcol << "\n lastcol: " << lastcol << "\n firstrow: " << firstrow << "\n lastrow: " << lastrow << endl; */ for(int i = firstrow; i < lastrow; i++) { //if(this->isA("KDrawGrid")) // kdDebug(4640) << "Updating row " << i << endl; for(int j = firstcol; j < lastcol; j++) { matrix.translate( (j*cellsize)-urect.x(), (i*cellsize)-urect.y() ); p.setWorldMatrix( matrix ); //p.setClipRect(j*cellsize, i*cellsize, cellsize, cellsize); paintCell(&p, i, j); //p.setClipping(FALSE); matrix.reset(); p.setWorldMatrix( matrix ); } //kapp->processEvents(); } matrix.translate(-urect.x(),-urect.y()); p.setWorldMatrix( matrix ); paintForeground(&p,e); p.end(); bitBlt(this,urect.topLeft(),&pm,QRect(0,0,pm.width(),pm.height())); }
void ScopeViewBase::paintEvent( QPaintEvent * event ) { QRect r = event->rect(); if (b_needRedraw) { //CALLGRIND_TOGGLE_COLLECT(); updateOutputHeight(); QPainter p; m_pixmap->fill( paletteBackgroundColor() ); p.begin(m_pixmap); p.setClipRegion(event->region()); //let the subclass draw the background (grids, etc.) drawBackground(p); // drawProbeMap(p, Oscilloscope::self()->m_logicProbeDataMap); // drawProbeMap(p, Oscilloscope::self()->m_floatingProbeDataMap); p.setPen(Qt::black); p.drawRect( frameRect() ); b_needRedraw = false; //CALLGRIND_TOGGLE_COLLECT(); } bitBlt( this, r.x(), r.y(), m_pixmap, r.x(), r.y(), r.width(), r.height() ); }
QColor KexiDBAutoField::backgroundLabelColor() const { if (d->widgetType == Boolean) return paletteBackgroundColor(); return d->label->palette().color(d->label->backgroundRole()); }
void KexiDBComboBox::paintEvent(QPaintEvent *) { QPainter p(this); p.setPen(palette().color(QPalette::Text)); // QColorGroup cg(palette().active()); // if ( hasFocus() ) // cg.setColor(QColorGroup::Base, cg.highlight()); // else QPalette pal(palette()); pal.setColor(QColorGroup::Base, paletteBackgroundColor()); //update base color using (reimplemented) bg color if (width() < 5 || height() < 5) { qDrawShadePanel(&p, rect(), pal, false /* !sunken */, 2 /*line width*/, &pal.brush(QPalette::Button)/*fill*/); return; } #ifdef __GNUC__ #warning TODO KexiDBComboBox::paintEvent() #else #pragma WARNING( TODO KexiDBComboBox::paintEvent() ) #endif QStyleOptionComboBox option; option.palette = pal; option.initFrom(d->paintedCombo); if (isEnabled()) option.state |= QStyle::State_Enabled; if (hasFocus()) option.state |= QStyle::State_HasFocus; if (d->mouseOver) option.state |= QStyle::State_MouseOver; style()->drawComplexControl(QStyle::CC_ComboBox, &option, &p, d->paintedCombo); #if 0 //TODO //! @todo support reverse layout //bool reverse = QApplication::reverseLayout(); style()->drawComplexControl(QStyle::CC_ComboBox, &option, &p, d->paintedCombo /*this*/ flags, (uint)QStyle::SC_All, (d->buttonPressed ? QStyle::SC_ComboBoxArrow : QStyle::SC_None) ); if (d->isEditable) { //if editable, editor paints itself, nothing to do } else { //not editable: we need to paint the current item QRect editorGeometry(this->editorGeometry()); if (hasFocus()) { if (0 == qstrcmp(style()->name(), "windows")) //a hack p.fillRect(editorGeometry, cg.brush(QColorGroup::Highlight)); QRect r(QStyle::visualRect(style()->subRect(QStyle::SR_ComboBoxFocusRect, d->paintedCombo), this)); r = QRect(r.left() - 1, r.top() - 1, r.width() + 2, r.height() + 2); //enlare by 1 pixel each side to avoid covering by the subwidget style()->drawPrimitive(QStyle::PE_FocusRect, &p, r, cg, flags | QStyle::Style_FocusAtBorder, QStyleOption(cg.highlight())); } //todo } #endif }
TimeWidgetIMPL::TimeWidgetIMPL( QWidget *parent, const char* name ) : TimeWidget( parent, name ) { text->setAlignment( text->alignment() | Qt::WordBreak ); text->setTextFormat( Qt::RichText ); text->setReadOnly( true ); text->setPaletteBackgroundColor( paletteBackgroundColor() ); text->setFrameStyle( QFrame::NoFrame ); }
void ClsSubDiagram::paintEvent ( QPaintEvent * event ){ QPainter painter(this); QColor qcolorFrame; if(bFocus){ qcolorFrame = Qt::red; } else { qcolorFrame = paletteBackgroundColor (); } qDrawPlainRect( &painter, frameRect(), qcolorFrame, lineWidth()); }
void Plot::printFrame(QPainter *painter, const QRect &rect) const { painter->save(); int lw = lineWidth(); if (lw) { QColor color = palette().color(QPalette::Active, QColorGroup::Foreground); painter->setPen (QPen(color, lw, Qt::SolidLine)); } else painter->setPen(QPen(Qt::NoPen)); if (paletteBackgroundColor() != Qt::white) painter->setBrush(paletteBackgroundColor()); QwtPainter::drawRect(painter, rect.x(), rect.y(), rect.width(), rect.height()); painter->restore(); }
ColorDisplay::ColorDisplay( QWidget *parent ) : QFrame( parent ) { Q_CHECK_PTR( parent ); setFrameStyle( QFrame::Panel | QFrame::Sunken ); parent_widget = parent; current_color = QColor( 0, 0, 0 ); dark_block_color = QColor( 135, 135, 135 ); light_block_color = paletteBackgroundColor(); alpha = 1.0; }
PaintWidget::PaintWidget( QWidget *parent, const char *name ) : QWidget( parent, name, WRepaintNoErase | WResizeNoErase ), buffer( size() ) { updateTimer = new QTimer( this ); connect( updateTimer, SIGNAL( timeout() ), this, SLOT( flush() ) ); painter = new QPainter; painter->begin( &buffer ); setBackgroundColor( "white" ); buffer.fill( paletteBackgroundColor() ); updateRegion = QRegion(); }
void Plot::printFrame(QPainter *painter, const QRect &rect) const { painter->save(); int lw = lineWidth(); if (lw){ QColor color = palette().color(QPalette::Active, QPalette::Foreground); painter->setPen (QPen(color, lw, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin)); } else painter->setPen(QPen(Qt::NoPen)); painter->setBrush(paletteBackgroundColor()); QwtPainter::drawRect(painter, rect); painter->restore(); }
void PaintWidget::resizeEvent( QResizeEvent *e ) { // ### save painter state and restore on begin painter->end(); buffer.resize( size() ); painter->begin( &buffer ); if ( width() > e->oldSize().width() ) { if ( ePixmap.isNull() ) painter->fillRect( e->oldSize().width(), 0, width() - e->oldSize().width() + 1, height(), paletteBackgroundColor() ); else painter->drawTiledPixmap( 0, 0, width(), height(), ePixmap, 0, 0 ); } if ( height() > e->oldSize().height() ) { if ( ePixmap.isNull() ) painter->fillRect( 0, e->oldSize().height(), width(), height() - e->oldSize().height() + 1, paletteBackgroundColor() ); else painter->drawTiledPixmap( 0, 0, width(), height(), ePixmap, 0, 0 ); } updateRegion = QRegion(); emit updateContents(); }
void dmsBox::setEmptyText() { QPalette p = palette(); QColor txc = p.color( QPalette::Active, QColorGroup::Text ); QColor bgc = paletteBackgroundColor(); int r( ( txc.red() + bgc.red() )/2 ); int g( ( txc.green() + bgc.green() )/2 ); int b( ( txc.blue() + bgc.blue() )/2 ); p.setColor( QPalette::Active, QColorGroup::Text, QColor( r, g, b ) ); p.setColor( QPalette::Inactive, QColorGroup::Text, QColor( r, g, b ) ); setPalette( p ); if ( degType() ) setText( "dd mm ss.s" ); else setText( "hh mm ss.s" ); EmptyFlag = true; }
void VCWidget::resetForegroundColor() { QColor bg; m_hasCustomForegroundColor = false; /* Store background color */ if (m_hasCustomBackgroundColor == true) bg = paletteBackgroundColor(); /* Reset the whole palette */ unsetPalette(); /* Restore foreground color */ if (bg.isValid() == true) setPaletteBackgroundColor(bg); else if (m_backgroundImage.isEmpty() == false) setPaletteBackgroundPixmap(QPixmap(m_backgroundImage)); _app->doc()->setModified(); }
// // Save settings to file // void VCDockSlider::saveToFile(QFile &file, t_vc_id parentID) { QString s; QString t; // Comment s = QString("# Virtual Console Slider Entry\n"); file.writeBlock((const char*) s, s.length()); // Entry type s = QString("Entry = Slider") + QString("\n"); file.writeBlock((const char*) s, s.length()); // Name s = QString("Name = ") + caption() + QString("\n"); file.writeBlock((const char*) s, s.length()); // Parent ID t.setNum(parentID); s = QString("Parent = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // X t.setNum(x()); s = QString("X = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Y t.setNum(y()); s = QString("Y = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // W t.setNum(width()); s = QString("Width = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // H t.setNum(height()); s = QString("Height = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Text color if (ownPalette()) { t.setNum(qRgb(paletteForegroundColor().red(), paletteForegroundColor().green(), paletteForegroundColor().blue())); s = QString("Textcolor = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); t.setNum(qRgb(paletteBackgroundColor().red(), paletteBackgroundColor().green(), paletteBackgroundColor().blue())); s = QString("Backgroundcolor = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); } // Background pixmap if (paletteBackgroundPixmap()) { s = QString("Pixmap = " + iconText() + QString("\n")); file.writeBlock((const char*) s, s.length()); } // Frame if (frameStyle() & KFrameStyle) { s = QString("Frame = ") + Settings::trueValue() + QString("\n"); } else { s = QString("Frame = ") + Settings::falseValue() + QString("\n"); } file.writeBlock((const char*) s, s.length()); // Font s = QString("Font = ") + font().toString() + QString("\n"); file.writeBlock((const char*) s, s.length()); // Bus t.setNum(m_busID); s = QString("Bus = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Bus Lo t.setNum(m_busLowLimit); s = QString("BusLowLimit = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Bus Hi t.setNum(m_busHighLimit); s = QString("BusHighLimit = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Channels if (m_channels.count()) { s = QString("Channels = "); QValueList<t_channel>::Iterator it; for (it = m_channels.begin(); it != m_channels.end(); ++it) { t.sprintf("%.3d", *it); s += t + QString(" "); } s += QString("\n"); file.writeBlock((const char*) s, s.length()); } // Level Lo t.setNum(m_levelLowLimit); s = QString("LevelLowLimit = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Level Hi t.setNum(m_levelHighLimit); s = QString("LevelHighLimit = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Mode (must be written after bus & channel settings) s = QString("Mode = ") + modeString(m_mode) + QString("\n"); file.writeBlock((const char*) s, s.length()); // Value t.setNum(m_slider->value()); s = QString("Value = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); }
void PaintWidget::setPaletteBackgroundColor( const QColor &color ) { painter->setBackgroundColor( color ); QWidget::setPaletteBackgroundColor( color ); painter->fillRect( 0, 0, width(), height(), paletteBackgroundColor() ); }
void VCButton::saveToFile(QFile& file, unsigned int parentID) { QString s; QString t; // Comment s = QString("# Virtual Console Button Entry\n"); file.writeBlock((const char*) s, s.length()); // Entry type s = QString("Entry = Button") + QString("\n"); file.writeBlock((const char*) s, s.length()); // Name s = QString("Name = ") + caption() + QString("\n"); file.writeBlock((const char*) s, s.length()); // Parent ID t.setNum(parentID); s = QString("Parent = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // X t.setNum(x()); s = QString("X = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Y t.setNum(y()); s = QString("Y = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // W t.setNum(width()); s = QString("Width = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // H t.setNum(height()); s = QString("Height = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Text color if (ownPalette()) { t.setNum(qRgb(paletteForegroundColor().red(), paletteForegroundColor().green(), paletteForegroundColor().blue())); s = QString("Textcolor = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Background color t.setNum(qRgb(paletteBackgroundColor().red(), paletteBackgroundColor().green(), paletteBackgroundColor().blue())); s = QString("Backgroundcolor = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); } // Background pixmap if (paletteBackgroundPixmap()) { s = QString("Pixmap = " + iconText() + QString("\n")); file.writeBlock((const char*) s, s.length()); } // Font s = QString("Font = ") + font().toString() + QString("\n"); file.writeBlock((const char*) s, s.length()); // Function s.sprintf("Function = %d\n", m_functionID); file.writeBlock((const char*) s, s.length()); // Key binding assert(m_keyBind); s.sprintf("BindKey = %d\n", m_keyBind->key()); file.writeBlock((const char*) s, s.length()); s.sprintf("BindMod = %d\n", m_keyBind->mod()); file.writeBlock((const char*) s, s.length()); s.sprintf("BindPress = %d\n", m_keyBind->pressAction()); file.writeBlock((const char*) s, s.length()); s.sprintf("BindRelease = %d\n", m_keyBind->releaseAction()); file.writeBlock((const char*) s, s.length()); }
bool VCWidget::saveXMLAppearance(QDomDocument* doc, QDomElement* frame_root) { QDomElement root; QDomElement tag; QDomText text; QString str; Q_ASSERT(doc != NULL); Q_ASSERT(frame_root != NULL); /* VC Label entry */ root = doc->createElement(KXMLQLCVCWidgetAppearance); frame_root->appendChild(root); /* Frame style */ tag = doc->createElement(KXMLQLCVCWidgetFrameStyle); root.appendChild(tag); text = doc->createTextNode(frameStyleToString(frameStyle())); tag.appendChild(text); /* Foreground color */ tag = doc->createElement(KXMLQLCVCWidgetForegroundColor); root.appendChild(tag); if (hasCustomForegroundColor() == true) str.setNum(paletteForegroundColor().rgb()); else str = KXMLQLCVCWidgetColorDefault; text = doc->createTextNode(str); tag.appendChild(text); /* Background color */ tag = doc->createElement(KXMLQLCVCWidgetBackgroundColor); root.appendChild(tag); if (hasCustomBackgroundColor() == true) str.setNum(paletteBackgroundColor().rgb()); else str = KXMLQLCVCWidgetColorDefault; text = doc->createTextNode(str); tag.appendChild(text); /* Background image */ tag = doc->createElement(KXMLQLCVCWidgetBackgroundImage); root.appendChild(tag); if (backgroundImage() != QString::null) str = m_backgroundImage; else str = KXMLQLCVCWidgetBackgroundImageNone; text = doc->createTextNode(str); tag.appendChild(text); /* Font */ tag = doc->createElement(KXMLQLCVCWidgetFont); root.appendChild(tag); if (hasCustomFont() == true) str = font().toString(); else str = KXMLQLCVCWidgetFontDefault; text = doc->createTextNode(str); tag.appendChild(text); return true; }
QString PaintWidget::backgroundColorEx() const { return paletteBackgroundColor().name(); }
void VCFrame::saveFramesToFile(QFile& file, t_vc_id parentID) { QString s; QString t; // Comment s = QString("# Virtual Console Frame Entry\n"); file.writeBlock((const char*) s, s.length()); // Entry type s = QString("Entry = Frame") + QString("\n"); file.writeBlock((const char*) s, s.length()); // Name s = QString("Name = ") + caption() + QString("\n"); file.writeBlock((const char*) s, s.length()); // Parent ID if (parentID != 0) { t.setNum(parentID); s = QString("Parent = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); } // Geometry if (m_bottomFrame == false) { // X t.setNum(x()); s = QString("X = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Y t.setNum(y()); s = QString("Y = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // W t.setNum(width()); s = QString("Width = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // H t.setNum(height()); s = QString("Height = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); } // Palette if (ownPalette()) { // Text color t.setNum(qRgb(paletteForegroundColor().red(), paletteForegroundColor().green(), paletteForegroundColor().blue())); s = QString("Textcolor = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Background color t.setNum(qRgb(paletteBackgroundColor().red(), paletteBackgroundColor().green(), paletteBackgroundColor().blue())); s = QString("Backgroundcolor = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); } // Background pixmap if (paletteBackgroundPixmap()) { s = QString("Pixmap = " + iconText() + QString("\n")); file.writeBlock((const char*) s, s.length()); } // Font s = QString("Font = ") + font().toString() + QString("\n"); file.writeBlock((const char*) s, s.length()); // Frame if (frameStyle() & KFrameStyle) { s = QString("Frame = ") + Settings::trueValue() + QString("\n"); } else { s = QString("Frame = ") + Settings::falseValue() + QString("\n"); } file.writeBlock((const char*) s, s.length()); // Button Behaviour t.setNum(m_buttonBehaviour); s = QString("ButtonBehaviour = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // ID t.setNum(id()); s = QString("ID = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); if (children() != NULL) { QObjectList* ol = (QObjectList*) children(); QObjectListIt it(*ol); // Child frames for (; it.current() != NULL; ++it) { if (QString(it.current()->className()) == QString("VCFrame")) { VCFrame* w = (VCFrame*) it.current(); w->saveFramesToFile(file, id()); } } } }
void HoverButton::paintEvent( QPaintEvent * e ) { if ( hasMouse() ) { QPushButton::paintEvent( e ); } else { QPainter p( this ); p.fillRect(e->rect(), parentWidget() ? parentWidget()->palette().brush(QPalette::Active, QColorGroup::Background) : paletteBackgroundColor()); drawButtonLabel( &p ); } }
void VCLabel::saveToFile(QFile& file, unsigned int parentID) { QString s; QString t; // Comment s = QString("# Virtual Console Label Entry\n"); file.writeBlock((const char*) s, s.length()); // Entry type s = QString("Entry = Label") + QString("\n"); file.writeBlock((const char*) s, s.length()); // Name s = QString("Name = ") + caption() + QString("\n"); file.writeBlock((const char*) s, s.length()); // Parent ID t.setNum(parentID); s = QString("Parent = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // X t.setNum(x()); s = QString("X = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Y t.setNum(y()); s = QString("Y = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // W t.setNum(width()); s = QString("Width = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // H t.setNum(height()); s = QString("Height = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Text color if (ownPalette()) { t.setNum(qRgb(paletteForegroundColor().red(), paletteForegroundColor().green(), paletteForegroundColor().blue())); s = QString("Textcolor = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); // Background color t.setNum(qRgb(paletteBackgroundColor().red(), paletteBackgroundColor().green(), paletteBackgroundColor().blue())); s = QString("Backgroundcolor = ") + t + QString("\n"); file.writeBlock((const char*) s, s.length()); } // Background pixmap if (paletteBackgroundPixmap()) { s = QString("Pixmap = " + iconText() + QString("\n")); file.writeBlock((const char*) s, s.length()); } // Font s = QString("Font = ") + font().toString() + QString("\n"); file.writeBlock((const char*) s, s.length()); // Frame if (frameStyle() & KFrameStyle) { s = QString("Frame = ") + Settings::trueValue() + QString("\n"); } else { s = QString("Frame = ") + Settings::falseValue() + QString("\n"); } file.writeBlock((const char*) s, s.length()); }
void DetailedGraphicalOverview::paintEvent( QPaintEvent* ) { int h = height(); int w = width(); QPixmap pm( w, h ); QPainter p; p.begin( &pm ); p.setBrush(Qt::SolidPattern); if ( !m_element ) { pm.fill( paletteBackgroundColor() ); p.drawText( 0, 0, w, h, Qt::AlignCenter | Qt::WordBreak, i18n( "No element selected" ) ); } else { h_t = 20; //height of the texts x1 = 0; y1 = 0; x2 = w; y2 = h; p.setBrush( m_element->elementColor() ); p.drawRect( x1 , y1 , x2 , y2 ); p.setBrush( Qt::black ); p.setBrush(Qt::NoBrush); QFont fA = KGlobalSettings::generalFont(); QFont fB = KGlobalSettings::generalFont(); QFont fC = KGlobalSettings::generalFont(); QString strLocalizedMass = KalziumUtils::localizedValue( m_element->mass(), 6 ); fA.setPointSize( fA.pointSize() + 20 ); //Huge font fA.setBold( true ); fB.setPointSize( fB.pointSize() + 6 ); //Big font fC.setPointSize( fC.pointSize() + 4 ); //Big font fC.setBold( true ); QFontMetrics fmA = QFontMetrics( fA ); QFontMetrics fmB = QFontMetrics( fB ); //coordinates for element symbol: near the center int xA = 4 * w / 10; int yA = h / 2; //coordinates for the atomic number: offset from element symbol to the upper left int xB = xA - fmB.width( QString::number( m_element->number() ) ); int yB = yA - fmA.height() + fmB.height(); //Element Symbol p.setFont( fA ); p.drawText( xA, yA , m_element->symbol() ); //Atomic number p.setFont( fB ); p.drawText( xB, yB, QString::number( m_element->number() )); QRect rect( 0, 20, w/2, h ); p.setFont( fC ); int size = KalziumUtils::maxSize(m_element->elname(), rect , fC, &p); int size2 = KalziumUtils::maxSize(m_element->oxstage(), rect, fC, &p); int size3 = KalziumUtils::maxSize( strLocalizedMass , rect , fC, &p); //Name and other data fC.setPointSize( size ); p.setFont( fC ); //Name p.drawText( 1, 0, w/2, h, Qt::AlignLeft, m_element->elname() ); //Oxidationstates fC.setPointSize( size2 ); p.setFont( fC ); int offsetOx = KalziumUtils::StringHeight( strLocalizedMass , fC, &p ); p.drawText( 1, h-offsetOx, w/2, offsetOx, Qt::AlignLeft, m_element->oxstage() ); //Mass fC.setPointSize( size3 ); p.setFont( fC ); int offset = KalziumUtils::StringHeight( strLocalizedMass, fC, &p ); p.drawText( w/2, h-offset, w/2, offset, Qt::AlignRight, strLocalizedMass ); drawBiologicalSymbol( &p ); } p.end(); bitBlt( this, 0, 0, &pm ); }