void MarkListTable::clear() { QColorGroup cg = QApplication::palette()->normal(); if( backgroundColor() != cg.base() ) setBackgroundColor(cg.base()); items.clear(); sel = -1; update(); }
static void PaintBars(toTreeWidgetItem *item, QPainter *p, const QColorGroup & cg, int width, std::list<double> &val, std::list<double> &maxExt, std::list<double> &curExt) { #if 0 // disabled, wrong override if ( val.empty() ) { p->fillRect(0, 0, width, item->height(), QBrush(item->isSelected() ? cg.highlight() : cg.base())); } else { int num = 0; int lastHeight = 0; std::list<double>::iterator j = curExt.begin(); std::list<double>::iterator k = maxExt.begin(); for (std::list<double>::iterator i = val.begin(); i != val.end() && j != curExt.end() && k != maxExt.end(); i++, j++, k++) { num++; QBrush bg(item->isSelected() ? cg.highlight() : cg.base()); QBrush fg(num % 2 ? Qt::blue : Qt::red); double start = (*i); double end = (*j); if (BarsAlignLeft) { end -= start; start = 0; if (end < 0) end += (*k); } int height = item->height() * num / val.size(); int pos = int(start * width / (*k)); int posEnd = int(end * width / (*k)); if (start > end) { p->fillRect(0, lastHeight, posEnd, height, fg); p->fillRect(posEnd, lastHeight, pos, height, bg); p->fillRect(pos, lastHeight, width, height, fg); } else { p->fillRect(0, lastHeight, pos, height, bg); p->fillRect(pos, lastHeight, posEnd, height, fg); p->fillRect(posEnd, lastHeight, width, height, bg); } lastHeight = height; } } #endif }
void FreshStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w, int h, const QColorGroup &cg, bool on, bool down, bool enabled ) { static const QCOORD pts1[] = { // dark lines 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; static const QCOORD pts4[] = { // white lines 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, 11,4, 10,3, 10,2 }; static const QCOORD pts5[] = { // inner fill 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; p->eraseRect( x, y, w, h ); QPointArray a( QCOORDARRLEN(pts1), pts4 ); a.translate( x, y ); p->setPen( cg.dark() ); p->drawPolyline( a ); a.setPoints( QCOORDARRLEN(pts4), pts1 ); a.translate( x, y ); p->setPen( cg.light() ); p->drawPolyline( a ); a.setPoints( QCOORDARRLEN(pts5), pts5 ); a.translate( x, y ); QColor fillColor = ( down || !enabled ) ? cg.button() : cg.base(); p->setPen( fillColor ); p->setBrush( fillColor ) ; p->drawPolygon( a ); if ( on ) { p->setPen( NoPen ); p->setBrush( cg.text() ); p->drawRect( x+5, y+4, 2, 4 ); p->drawRect( x+4, y+5, 4, 2 ); } }
void TeQtBigTable::paintCell(QPainter *painter, int row, int col, const QRect &cr, bool selected, const QColorGroup &cg) { QRect rect(0, 0, cr.width(), cr.height()); if (selected) { painter->fillRect(rect, cg.highlight()); painter->setPen(cg.highlightedText()); } else { painter->fillRect(rect, cg.base()); painter->setPen(cg.text()); } QTable::paintCell(painter, row, col, cr, selected, cg); QVariant v(dataSource_->cell(row, col)); if (v.type() == QVariant::Pixmap) { QPixmap p = v.toPixmap(); painter->drawPixmap(0, 0, p); } else if (v.type() == QVariant::String || v.type() == QVariant::CString) { QString qs = v.toString(); bool ok; qs.toDouble(&ok); if (ok) painter->drawText(0, 0, cr.width()-10, cr.height(), Qt::AlignRight | Qt::SingleLine, v.toString()); else painter->drawText(0, 0, cr.width()-10, cr.height(), Qt::AlignLeft | Qt::SingleLine, v.toString()); } }
// Reimplemented void QmvItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ) { QListView *listview = listView(); QColorGroup g( cg ); g.setColor( QColorGroup::Base, backgroundColor() ); g.setColor( QColorGroup::Foreground, Qt::black ); g.setColor( QColorGroup::Text, Qt::black ); int indent = 0; if ( column == 0 ) { indent = 20 + (shuttletupleattribute ? 20 : 0 ); p->fillRect( 0, 0, width, height(), backgroundColor() ); p->save(); p->translate( indent, 0 ); } if ( isChanged() && column == 0 ) { p->save(); QFont f = p->font(); f.setBold( TRUE ); p->setFont( f ); } if ( !hasCustomContents() || column != 1 ) { QListViewItem::paintCell( p, g, column, width - indent, alignment ); } else { p->fillRect( 0, 0, width, height(), backgroundColor() ); drawCustomContents( p, QRect( 0, 0, width, height() ) ); } if ( isChanged() && column == 0 ) p->restore(); if ( column == 0 ) p->restore(); // Draw +/- open/close control icon on tuple items if ( !shuttletupleattribute && column == 0 ) { p->save(); p->setPen( cg.foreground() ); p->setBrush( cg.base() ); p->drawRect( 5, height() / 2 - 4, 9, 9 ); p->drawLine( 7, height() / 2, 11, height() / 2 ); if ( !isOpen() ) p->drawLine( 9, height() / 2 - 2, 9, height() / 2 + 2 ); p->restore(); } p->save(); p->setPen( QPen( cg.dark(), 1 ) ); p->drawLine( 0, height() - 1, width, height() - 1 ); p->drawLine( width - 1, 0, width - 1, height() ); p->restore(); if ( listview->currentItem() == this && column == 0 && !listview->hasFocus() && !listview->viewport()->hasFocus() ) paintFocus( p, cg, QRect( 0, 0, width, height() ) ); }
void ListListViewItem::paintCell(QPainter *p,const QColorGroup &cg,int column, int width,int align) { if(column!=list_track_column) { Q3ListViewItem::paintCell(p,cg,column,width,align); return; } QColor fg=cg.text(); QColor bg=cg.base(); if(isSelected()) { fg=cg.highlightedText(); bg=cg.highlight(); } QString str=QString().sprintf("%u / %u",list_tracks,list_total_tracks); QPixmap *icon=list_whiteball_map; if(list_total_tracks>0) { if(list_tracks==list_total_tracks) { icon=list_greenball_map; } else { icon=list_redball_map; } } QFontMetrics *m=new QFontMetrics(p->font()); p->setBackgroundColor(bg); p->eraseRect(0,0,width,height()); p->setPen(fg); p->drawPixmap(list_parent->itemMargin(),(height()-icon->size().height())/2, *icon); p->drawText(icon->size().width()+10,3*(height()-m->height())/2,str); delete m; }
void KviVariantTableItem::paint(QPainter *p,const QColorGroup &cg,const QRect &cr,bool) { p->fillRect(0,0,cr.width(),cr.height(),cg.base()); if(m_property.type() == QVariant::Color) { p->fillRect(3,3,cr.width() - 6,cr.height() - 6,m_property.asColor()); } else { QString sz; switch(m_property.type()) { case QVariant::String: sz = m_property.toString(); break; case QVariant::Bool: sz = m_property.toBool() ? "TRUE" : "FALSE"; break; case QVariant::Font: sz.setNum(m_property.toFont().pointSize()); sz.prepend(", "); sz.prepend(m_property.toFont().family()); break; case QVariant::Int: sz.setNum(m_property.toInt()); break; case QVariant::UInt: sz.setNum(m_property.toUInt()); break; default: break; } p->setPen(cg.text()); p->drawText(0,0,cr.width(),cr.height(),Qt::AlignLeft | Qt::AlignTop,sz); } }
void KstMatrixTable::paintCell( QPainter* painter, int row, int col, const QRect& cr, bool selected, const QColorGroup& cg ) { KstMatrixList matrices = KST::matrixList; KstMatrixPtr matrix = *matrices.findTag(_strMatrix); QString str; double value; painter->eraseRect( 0, 0, cr.width(), cr.height() ); if (selected) { painter->fillRect( 0, 0, cr.width(), cr.height(), cg.highlight() ); painter->setPen(cg.highlightedText()); } else { painter->fillRect( 0, 0, cr.width(), cr.height(), cg.base() ); painter->setPen(cg.text()); } if (matrix) { bool ok; value = matrix->valueRaw(col, row, &ok); if (ok) { str.setNum(value, 'g', 16); } } painter->drawText(0, 0, cr.width(), cr.height(), AlignLeft, str); }
virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) { #if 0 // disabled - not overriding correct method if (column == 2) { toProfilerUnits *units = dynamic_cast<toProfilerUnits *>(listView()); if (!units) { toTreeWidgetItem::paintCell(p, cg, column, width, alignment); return ; } double total = allText(column).toDouble(); QString timstr = FormatTime(total / 1E9); double val = total / units->total(); p->fillRect(0, 0, int(val*width), height(), QBrush(Qt::blue)); p->fillRect(int(val*width), 0, width, height(), QBrush(isSelected() ? cg.highlight() : cg.base())); QPen pen(isSelected() ? cg.highlightedText() : cg.foreground()); p->setPen(pen); p->drawText(0, 0, width, height(), Qt::AlignRight, timstr); } else { toTreeWidgetItem::paintCell(p, cg, column, width, alignment); } #endif }
// Overridden to highlight the changed items void VarItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align) { if (p == 0) { return; } if (column == VALUE_COLUMN) { // Show color values as colors, and make the text color the same // as the base color if (dataType_ == COLOR_TYPE) { QRegExp color_re("\\s(#.*)>"); if (color_re.search(text(column)) != -1) { QColorGroup color_cg( cg.foreground(), cg.background(), cg.light(), cg.dark(), cg.mid(), QColor(color_re.cap(1)), QColor(color_re.cap(1)) ); QListViewItem::paintCell(p, color_cg, column, width, align); return; } } // Highlight recently changed items in red if (highlight_) { QColorGroup hl_cg( cg.foreground(), cg.background(), cg.light(), cg.dark(), cg.mid(), red, cg.base() ); QListViewItem::paintCell(p, hl_cg, column, width, align); return; } } QListViewItem::paintCell(p, cg, column, width, align); return; }
void FancyItem::paintCell(QPainter *p, const QColorGroup &cg, int c, int w, int) { int h = height(); QFontMetrics fm(p->font()); if(isSelected()) p->fillRect(0, 0, w, h-1, cg.highlight()); else p->fillRect(0, 0, w, h, cg.base()); int x = 0; const QPixmap *pix = pixmap(c); if(pix) { p->drawPixmap(4, (h - pix->height()) / 2, *pix); x += pix->width(); } else x += 16; x += 8; int y = ((h - fm.height()) / 2) + fm.ascent(); p->setPen(isSelected() ? cg.highlightedText() : cg.text()); p->drawText(x, y, text(c)); p->setPen(QPen(QColor(0xE0, 0xE0, 0xE0), 0, Qt::DotLine)); p->drawLine(0, h-1, w-1, h-1); }
void UserViewItemBase::paintCell(QPainter *p, const QColorGroup &cg, int, int width, int) { UserListBase *view = static_cast<UserListBase*>(listView()); width = view->width() - 4; QScrollBar *vBar = view->verticalScrollBar(); if (vBar->isVisible()) width -= vBar->width(); if (width < 1) width = 1; QPixmap bg(width, height()); QPainter pp(&bg); int margin = 0; if (isSelected() && view->hasFocus() && CorePlugin::m_plugin->getUseDblClick()){ pp.fillRect(QRect(0, 0, width, height()), cg.highlight()); pp.setPen(cg.highlightedText()); }else{ pp.fillRect(QRect(0, 0, width, height()), cg.base()); PaintView pv; pv.p = &pp; pv.pos = view->viewport()->mapToParent(view->itemRect(this).topLeft()); pv.size = QSize(width, height()); pv.win = view; pv.isStatic = false; pv.height = height(); pv.margin = 0; if (CorePlugin::m_plugin->getUseSysColors()){ pp.setPen(cg.text()); }else{ pp.setPen(QColor(CorePlugin::m_plugin->getColorOnline())); } Event e(EventPaintView, &pv); e.process(); view->setStaticBackground(pv.isStatic); margin = pv.margin; } view->drawItem(this, &pp, cg, width, margin); pp.end(); if (view->m_pressedItem == this){ p->drawPixmap(QPoint(1, 1), bg); if (CorePlugin::m_plugin->getUseSysColors()){ p->setPen(cg.text()); }else{ p->setPen(QColor(CorePlugin::m_plugin->getColorOnline())); } p->moveTo(0, 0); p->lineTo(width - 1, 0); p->lineTo(width - 1, height() - 1); p->lineTo(0, height() - 1); p->lineTo(0, 0); p->setPen(cg.shadow()); p->moveTo(width - 2, 1); p->lineTo(1, 1); p->lineTo(1, height() - 2); }else{ p->drawPixmap(QPoint(0, 0), bg); } }
// A ctor. QsciStyle::QsciStyle(int style) { init(style); QColorGroup cg = QApplication::palette().active(); setColor(cg.text()); setPaper(cg.base()); setFont(QApplication::font()); setEolFill(false); }
bool InvestTransactionDownloaded::paintRegisterCellSetup(QPainter* painter, int& row, int& col, QRect& cellRect, QRect& textRect, QColorGroup& cg, QBrush& brush) { bool rc = Transaction::paintRegisterCellSetup(painter, row, col, cellRect, textRect, cg, brush); // if not selected paint in selected background color if(!isSelected()) { cg.setColor(QColorGroup::Base, KMyMoneyGlobalSettings::importedTransactionColor()); brush = QBrush(cg.base()); } return rc; }
void KateFileListItem::paintCell( QPainter *painter, const QColorGroup & cg, int column, int width, int align ) { KateFileList *fl = (KateFileList*)listView(); if ( ! fl ) return; if ( column == 0 ) { QColorGroup cgNew = cg; // replace the base color with a different shading if necessary... if ( fl->shadingEnabled() && m_viewhistpos > 1 ) { QColor b( cg.base() ); QColor shade = fl->viewShade(); QColor eshade = fl->editShade(); int hc = fl->histCount(); // If this file is in the edit history, blend in the eshade // color. The blend is weighted by the position in the editing history if ( fl->shadingEnabled() && m_edithistpos > 0 ) { int ec = fl->editHistCount(); int v = hc-m_viewhistpos; int e = ec-m_edithistpos+1; e = e*e; int n = QMAX(v + e, 1); shade.setRgb( ((shade.red()*v) + (eshade.red()*e))/n, ((shade.green()*v) + (eshade.green()*e))/n, ((shade.blue()*v) + (eshade.blue()*e))/n ); } // blend in the shade color. // max transperancy < .5, latest is most colored. float t = (0.5/hc)*(hc-m_viewhistpos+1); b.setRgb( (int)((b.red()*(1-t)) + (shade.red()*t)), (int)((b.green()*(1-t)) + (shade.green()*t)), (int)((b.blue()*(1-t)) + (shade.blue()*t)) ); cgNew.setColor(QColorGroup::Base, b); } QListViewItem::paintCell( painter, cgNew, column, width, align ); } else QListViewItem::paintCell( painter, cg, column, width, align ); }
void Kleo::SignatureKeyListViewItem::paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int alignment ) { const KeyListView::DisplayStrategy * ds = listView() ? listView()->displayStrategy() : 0 ; if ( !ds ) { QListViewItem::paintCell( p, cg, column, width, alignment ); return; } const QColor fg = ds->signatureForeground( signature(), cg.text() ); const QColor bg = ds->signatureBackground( signature(), cg.base() ); const QFont f = ds->signatureFont( signature(), p->font() ); QColorGroup _cg = cg; p->setFont( f ); _cg.setColor( QColorGroup::Text, fg ); _cg.setColor( QColorGroup::Base, bg ); QListViewItem::paintCell( p, _cg, column, width, alignment ); }
virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) { #if 0 // disabled - not overriding correct class if (column == 1 || column == 2 || column == 3 || column == 4) { toProfilerSource *source = dynamic_cast<toProfilerSource *>(listView()); if (!source) { toTreeWidgetItem::paintCell(p, cg, column, width, alignment); return ; } double total = allText(column).toDouble(); double val; switch (column) { case 1: val = total / source->TotalOccur; break; case 2: val = total / source->TotalTime; break; case 3: val = total / source->MaxTime; break; case 4: val = total / source->MinTime; break; default: val = 0; } p->fillRect(0, 0, int(val*width), height(), QBrush(Qt::blue)); p->fillRect(int(val*width), 0, width, height(), QBrush(isSelected() ? cg.highlight() : cg.base())); QPen pen(isSelected() ? cg.highlightedText() : cg.foreground()); p->setPen(pen); p->drawText(0, 0, width, height(), Qt::AlignRight, text(column)); } else { toTreeWidgetItem::paintCell(p, cg, column, width, alignment); } #endif }
void QWindowsStyle::drawIndicator( QPainter* p, int x, int y, int w, int h, const QColorGroup &g, int s, bool down, bool enabled ) { #ifndef QT_NO_BUTTON QBrush fill; if ( s == QButton::NoChange ) { QBrush b = p->brush(); QColor c = p->backgroundColor(); p->setBackgroundMode( TransparentMode ); p->setBackgroundColor( green ); fill = QBrush(g.base(), Dense4Pattern); p->setBackgroundColor( c ); p->setBrush( b ); } else if ( down ) fill = g.brush( QColorGroup::Button ); else fill = g.brush( enabled ? QColorGroup::Base : QColorGroup::Background ); qDrawWinPanel( p, x, y, w, h, g, TRUE, &fill ); if ( s != QButton::Off ) { QPointArray a( 7*2 ); int i, xx, yy; xx = x+3; yy = y+5; for ( i=0; i<3; i++ ) { a.setPoint( 2*i, xx, yy ); a.setPoint( 2*i+1, xx, yy+2 ); xx++; yy++; } yy -= 2; for ( i=3; i<7; i++ ) { a.setPoint( 2*i, xx, yy ); a.setPoint( 2*i+1, xx, yy+2 ); xx++; yy--; } if ( s == QButton::NoChange ) { p->setPen( g.dark() ); } else { p->setPen( g.text() ); } p->drawLineSegments( a ); } #endif }
void DriverItem::paintCell(QPainter *p, const QColorGroup &cg, int, int width, int) { // background p->fillRect(0, 0, width, height(), cg.base()); // highlight rectangle if(isSelected()) p->fillRect(0, 0, /*2+p->fontMetrics().width(text(0))+(pixmap(0) ? pixmap(0)->width()+2 : 0)*/ width, height(), (m_conflict ? red : cg.highlight())); // draw pixmap int w(0); if(pixmap(0) && !pixmap(0)->isNull()) { int h((height() - pixmap(0)->height()) / 2); p->drawPixmap(w, h, *pixmap(0)); w += (pixmap(0)->width() + 2); } // draw Text if(!m_item || !m_item->isOption() || isSelected()) { p->setPen((isSelected() ? cg.highlightedText() : (m_conflict ? red : cg.text()))); p->drawText(w, 0, width - w, height(), Qt::AlignLeft | Qt::AlignVCenter, text(0)); } else { int w1(0); QString s(m_item->get("text") + ": <"); w1 = p->fontMetrics().width(s); p->setPen(cg.text()); p->drawText(w, 0, w1, height(), Qt::AlignLeft | Qt::AlignVCenter, s); w += w1; p->setPen((m_conflict ? red : darkGreen)); s = m_item->prettyText(); w1 = p->fontMetrics().width(s); p->drawText(w, 0, w1, height(), Qt::AlignLeft | Qt::AlignVCenter, s); w += w1; p->setPen(cg.text()); s = QString::fromLatin1(">"); w1 = p->fontMetrics().width(s); p->drawText(w, 0, w1, height(), Qt::AlignLeft | Qt::AlignVCenter, s); } }
void KstVectorTable::paintCell( QPainter* painter, int row, int col, const QRect& cr, bool selected, const QColorGroup& cg ) { KstVectorPtr vector = *KST::vectorList.findTag(_strVector); QString str; painter->eraseRect( 0, 0, cr.width(), cr.height() ); if (selected) { painter->fillRect( 0, 0, cr.width(), cr.height(), cg.highlight() ); painter->setPen(cg.highlightedText()); } else { painter->fillRect( 0, 0, cr.width(), cr.height(), cg.base() ); painter->setPen(cg.text()); } if( col == 0 && vector) { str.setNum(vector->value(row), 'g', 16); } painter->drawText(0, 0, cr.width(), cr.height(), AlignLeft, str); }
void PlaylistItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align) { if(!m_playingItems.contains(this)) return KListViewItem::paintCell(p, cg, column, width, align); QColorGroup colorGroup = cg; QColor base = colorGroup.base(); QColor selection = colorGroup.highlight(); int r = (base.red() + selection.red()) / 2; int b = (base.blue() + selection.blue()) / 2; int g = (base.green() + selection.green()) / 2; QColor c(r, g, b); colorGroup.setColor(QColorGroup::Base, c); QListViewItem::paintCell(p, colorGroup, column, width, align); }
// Caption KMDITitleLabel::KMDITitleLabel(QWidget* p, const char* name) : QFrame(p, name) { // setAlignment(AlignVCenter|AlignLeft); // setMargin (BORDER); QPalette* pal=QApplication::palette(); QColorGroup active = pal->active(); QColorGroup disabled = pal->disabled(); QColorGroup normal(white, blue,active.light(), active.dark(), active.mid(), white, active.base()); QPalette npal(normal, disabled, active); setPalette(npal); options.titlebarPixmapActive = new("QPixmap") QPixmap; options.titlebarPixmapInactive = new("QPixmap") QPixmap; readConfiguration(); titlestring_offset=0; titlestring_offset_delta=TITLE_ANIMATION_STEP; }
void KstScalarTable::paintCell( QPainter* painter, int row, int col, const QRect& cr, bool selected, const QColorGroup& cg ) { KstScalarList::iterator it = KST::scalarList.begin(); QString str; if (selected) { painter->eraseRect( 0, 0, cr.width(), cr.height() ); painter->fillRect( 0, 0, cr.width(), cr.height(), cg.highlight() ); painter->setPen(cg.highlightedText()); } else { painter->eraseRect( 0, 0, cr.width(), cr.height() ); painter->fillRect( 0, 0, cr.width(), cr.height(), cg.base() ); painter->setPen(cg.text()); } it += row; if( col == 0 ) { str = (*it)->tagName(); } else if( col == 1 ) { str = (*it)->label(); } painter->drawText(0, 0, cr.width(), cr.height(), AlignLeft, str); }
void QLineEdit::paintEvent( QPaintEvent *e ) { if ( !d->pm || d->pmDirty ) { if ( !d->pm ) d->pm = new QPixmap( size() ); QPainter p( d->pm, this ); QColorGroup g = colorGroup(); QColor bg = isEnabled() ? g.base() : g.background(); QFontMetrics fm = fontMetrics(); int markBegin = minMark(); int markEnd = maxMark(); int margin = frame() ? 2 : 0; if ( frame() ) { QBrush fill( bg ); qDrawWinPanel( &p, 0, 0, width(), height(), g, TRUE, &fill ); } else { p.fillRect( 0, 0, width(), height(), bg ); } QString displayText; switch( echoMode() ) { case Normal: displayText = tbuf.mid( offset, tbuf.length() ); break; case NoEcho: displayText = ""; break; case Password: displayText.fill( '*', tbuf.length() - offset ); break; } int ypos = height() - margin - fm.descent() - 1 - (height() - 2*margin - fm.height())/2; if ( !displayText.isEmpty() ) { int charsVisible = lastCharVisible() - offset; if ( displayText[ charsVisible ] != '\0' ) charsVisible++; int mark1,mark2; if ( markBegin > offset ) { if ( markBegin < offset + charsVisible ) mark1 = markBegin - offset; else mark1 = charsVisible; } else { mark1 = 0; } if ( markEnd > offset ) { if ( markEnd < offset + charsVisible ) mark2 = markEnd - offset; else mark2 = charsVisible; } else { mark2 = 0; } // display code comes here - a bit yucky but it works if ( mark1 != mark2 ) { QString marked( displayText.mid( mark1, mark2 - mark1 ) ); int xpos1 = margin + 2 + fm.width( displayText, mark1 ); int xpos2 = xpos1 + fm.width( marked ) - 1; p.fillRect( xpos1, ypos - fm.ascent(), xpos2 - xpos1, fm.height(), style() == WindowsStyle ? QApplication::winStyleHighlightColor() : g.text() ); p.setPen( style() == WindowsStyle ? white : g.base() ); p.drawText( xpos1, ypos, marked ); } p.setPen( g.text() ); if ( mark1 != 0 ) p.drawText( margin + 2, ypos, displayText, mark1 ); if ( mark2 != charsVisible ) { QString rest( displayText.mid( mark2, charsVisible - mark2 ) ); p.drawText( margin + 2 + fm.width( displayText.left( mark2) ), ypos, rest ); } } p.setPen( g.foreground() ); int curXPos = margin + 2; if ( echoMode() != NoEcho ) curXPos += offset > cursorPos ? -1 : // ?: for scrolling case fm.width( displayText, cursorPos - offset ) - 1; int curYPos = ypos - fm.ascent(); d->cursorRepaintRect.setRect( curXPos-2, curYPos, 5, fm.height() ); d->pmDirty = FALSE; } bitBlt( this, e->rect().topLeft(), d->pm, e->rect() ); if ( hasFocus() ) { if ( cursorOn && d->cursorRepaintRect.intersects( e->rect() ) ) { QPainter p( this ); int curYTop = d->cursorRepaintRect.y(); int curYBot = d->cursorRepaintRect.bottom(); int curXPos = d->cursorRepaintRect.x() + 2; p.drawLine( curXPos, curYTop, curXPos, curYBot ); if ( style() != WindowsStyle ) { p.drawLine( curXPos - 2, curYTop, curXPos + 2, curYTop ); p.drawLine( curXPos - 2, curYBot, curXPos + 2, curYBot ); } } } else { delete d->pm; d->pm = 0; } }
void process(const QObject * obj){ if(obj != NULL){ QListViewItem * buf = __current; __current = new QListViewItem(__current,obj->className(),QString(obj->name())); __current->setPixmap(0,__pixgeom); QMetaObject* _m = obj->metaObject(); QListViewItem * att = NULL; if(_m != NULL){ QString _superclass(_m->superClassName()); if(!_superclass.isEmpty()){ att = new QListViewItem(__current,"Inherit",_superclass); att->setPixmap(0,__pixattptr); QMetaObject* _meta = _m->superClass(); QListViewItem * att4 = NULL; while((_meta = _meta->superClass())!= NULL){ att4 = new QListViewItem(att,att4,QString(_meta->className())); att4->setPixmap(0,__pixatt); } } att = new QListViewItem(__current,att,"Priority",(obj->highPriority()?"High":"Normal")); att->setPixmap(0,__pixatt); att = new QListViewItem(__current,att,"Widget",(obj->isWidgetType()?"True":"False")); att->setPixmap(0,__pixatt); QStrList _slots = _m->slotNames(true); if(!_slots.isEmpty()){ att = new QListViewItem(__current,att,"Slots"); att->setPixmap(0,__pixtransf); uint sl_size = _slots.count(); QListViewItem * att2 = NULL; for(uint j = 0; j < sl_size; j++ ){ att2 = new QListViewItem(att,att2,_slots.at(j)); att2->setPixmap(0,__pixatt); } } QStrList _signals = _m->signalNames(true); if(!_signals.isEmpty()){ att = new QListViewItem(__current,att,"Signals"); att->setPixmap(0,__pixtransf); uint si_size = _signals.count(); QListViewItem * att2 = NULL; for(uint j = 0; j < si_size; j++ ){ att2 = new QListViewItem(att,att2,_signals.at(j)); att2->setPixmap(0,__pixatt); } } int numCInfo = _m->numClassInfo(true); if(numCInfo !=0){ att = new QListViewItem(__current,att,"ClassInfo","List<Info>["+QString::number(numCInfo)+']'); att->setPixmap(0,__pixtransf); QListViewItem * att2 = NULL; for(int j = 0; j < numCInfo; j++ ){ const QClassInfo * _inf = _m->classInfo(j); if(_inf != NULL){ att2 = new QListViewItem(att,att2,QString(_inf->name),QString(_inf->value)); att2->setPixmap(0,__pixatt); } } } QStrList _props = _m->propertyNames(true); if(!_props.isEmpty()){ att = new QListViewItem(__current,att,"Properties"); att->setPixmap(0,__pixtransf); uint p_size = _props.count(); QListViewItem * att2 = NULL; for(uint j = 0; j < p_size; j++ ){ att2 = new QListViewItem(att,att2,_props.at(j)); att2->setPixmap(0,__pixatt); QVariant val; QString propname(_props.at(j)); #if QT_VERSION >= 300 const QMetaProperty* prop = _m->property (j,true); #else const QMetaProperty* prop = _m->property (propname,true); #endif QString proptype; if(prop){ proptype = prop->type(); att2->setText(2,proptype); /* QListViewItem * att3 = new QListViewItem(att2,"Writable",(prop->writable()?"True":"False")); att3->setPixmap(0,__pixatt); att3 = new QListViewItem(att2,att3,"Designable",(prop->designable()?"True":"False")); att3->setPixmap(0,__pixatt); */ } val = obj->property(propname); if(!val.isValid())att2->setText(1,"Invalid"); else if(prop->isEnumType()){ att2->setText(1,prop->valueToKey(val.toInt())); } else if(prop->isSetType()){ QStrList st = prop->valueToKeys(val.toInt()); QString t = st.at(0); for(uint i= 1; i < st.count(); i++)t+='/'+st.at(i); att2->setText(1,t); } else if(val.type() == QVariant::String)att2->setText(1,'"'+val.toString()+'"'); else if(val.type() == QVariant::CString)att2->setText(1,'"'+val.toCString()+'"'); else if(val.type() == QVariant::Bool){ if(val.toBool())att2->setText(1,"True"); else att2->setText(1,"False"); } else if(val.type() == QVariant::Int)att2->setText(1,QString::number(val.toInt())); else if(val.type() == QVariant::UInt)att2->setText(1,QString::number(val.toUInt())); else if(val.type() == QVariant::Double)att2->setText(1,QString::number(val.toDouble())); else if(val.type() == QVariant::Rect){ const QRect r = val.toRect(); att2->setText(1,'[' + QString::number(r.left()) + ',' + QString::number(r.top())+ ',' + QString::number(r.right()) + ',' + QString::number(r.bottom())+']'); } else if(val.type() == QVariant::Region){ const QRegion reg = val.toRegion(); QRect r = reg.boundingRect(); att2->setText(1,'[' + QString::number(r.left()) + ',' + QString::number(r.top())+ ',' + QString::number(r.right()) + ',' + QString::number(r.bottom())+"],"); } else if(val.type() == QVariant::Size){ const QSize s = val.toSize(); att2->setText(1,'[' + QString::number(s.width()) + ',' + QString::number(s.height())+']'); } else if(val.type() == QVariant::Point){ const QPoint p = val.toPoint(); att2->setText(1,'[' + QString::number(p.x()) + ',' + QString::number(p.y())+']'); } else if(val.type() == QVariant::Color){ const QColor c = val.toColor(); att2->setText(1,'[' + QString::number(c.red()) + ',' + QString::number(c.green()) + ',' + QString::number(c.blue()) + ']'); } else if(val.type() == QVariant::ColorGroup){ const QColorGroup cg = val.toColorGroup(); QColor c = cg.base(); att2->setText(1,'[' + QString::number(c.red()) + ',' + QString::number(c.green()) + ',' + QString::number(c.blue()) + "], ..."); } else if(val.type() == QVariant::Font){ const QFont f = val.toFont(); QString text = '\'' + f.family() + "', " + QString::number(f.pointSize()) + ", " + QString::number(f.weight()); if(f.italic())text+=", italic"; att2->setText(1,text); } else if(val.type() == QVariant::SizePolicy){ QSizePolicy sp = val.toSizePolicy(); QString text; if(sp.horData() == QSizePolicy::Fixed)text+="Fixed"; else if(sp.horData() == QSizePolicy::Minimum )text+="Minimum"; else if(sp.horData() == QSizePolicy::Maximum )text+="Maximum"; else if(sp.horData() == QSizePolicy::Preferred )text+="Preferred"; else if(sp.horData() == QSizePolicy::MinimumExpanding )text+="MinimumExpanding"; else if(sp.horData() == QSizePolicy::Expanding )text+="Expanding"; text +='/'; if(sp.verData() == QSizePolicy::Fixed)text+="Fixed"; else if(sp.verData() == QSizePolicy::Minimum )text+="Minimum"; else if(sp.verData() == QSizePolicy::Maximum )text+="Maximum"; else if(sp.verData() == QSizePolicy::Preferred )text+="Preferred"; else if(sp.verData() == QSizePolicy::MinimumExpanding )text+="MinimumExpanding"; else if(sp.verData() == QSizePolicy::Expanding )text+="Expanding"; att2->setText(1,text); } else if(val.type() == QVariant::Pixmap){ QPixmap pix = val.toPixmap(); if(!pix.isNull())att2->setPixmap(1,pix); } else if(val.type() == QVariant::Cursor){ const QCursor cur = val.toCursor(); const QBitmap * pix = cur.bitmap(); if(pix && !pix->isNull())att2->setPixmap(1,*pix); else att2->setText(1,QString::number(cur.shape())); } } } } const QObjectList * roots = obj->children(); if(roots != NULL){ __current = new QListViewItem(__current,att,"children","ptr="+QString::number((unsigned long)roots), "List<QObject>["+QString::number(roots->count())+"]"); __current->setPixmap(0,__pixappe); QObjectList r(*roots); uint size = r.count(); for(uint i = 0; i < size; i++ ){ QObject * _obj = r.at(i); process(_obj); } } __current = buf; } }
/****************************************************************************** * Paint one value in one of the columns in the list view. */ void AlarmListViewItem::paintCell(QPainter *painter, const QColorGroup &cg, int column, int width, int /*align*/) { const AlarmListView *listView = alarmListView(); int margin = listView->itemMargin(); QRect box(margin, margin, width - margin * 2, height() - margin * 2); // area within which to draw bool selected = isSelected(); QColor bgColour = selected ? cg.highlight() : cg.base(); QColor fgColour = selected ? cg.highlightedText() : !event().enabled() ? Preferences::disabledColour() : event().expired() ? Preferences::expiredColour() : cg.text(); painter->setPen(fgColour); painter->fillRect(0, 0, width, height(), bgColour); if(column == listView->column(AlarmListView::TIME_COLUMN)) { int i = -1; QString str = text(column); if(mTimeHourPos >= 0) { // Need to pad out spacing to align times without leading zeroes i = str.find(" ~"); if(i >= 0) { if(mDigitWidth < 0) mDigitWidth = painter->fontMetrics().width("0"); QString date = str.left(i + 1); int w = painter->fontMetrics().width(date) + mDigitWidth; painter->drawText(box, AlignVCenter, date); box.setLeft(box.left() + w); painter->drawText(box, AlignVCenter, str.mid(i + 2)); } } if(i < 0) painter->drawText(box, AlignVCenter, str); } else if(column == listView->column(AlarmListView::TIME_TO_COLUMN)) painter->drawText(box, AlignVCenter | AlignRight, text(column)); else if(column == listView->column(AlarmListView::REPEAT_COLUMN)) painter->drawText(box, AlignVCenter | AlignHCenter, text(column)); else if(column == listView->column(AlarmListView::COLOUR_COLUMN)) { // Paint the cell the colour of the alarm message if(event().action() == KAEvent::MESSAGE || event().action() == KAEvent::FILE) painter->fillRect(box, event().bgColour()); } else if(column == listView->column(AlarmListView::TYPE_COLUMN)) { // Display the alarm type icon, horizontally and vertically centred in the cell QPixmap *pixmap = eventIcon(); QRect pixmapRect = pixmap->rect(); int diff = box.height() - pixmap->height(); if(diff < 0) { pixmapRect.setTop(-diff / 2); pixmapRect.setHeight(box.height()); } QPoint iconTopLeft(box.left() + (box.width() - pixmapRect.width()) / 2, box.top() + (diff > 0 ? diff / 2 : 0)); painter->drawPixmap(iconTopLeft, *pixmap, pixmapRect); } else if(column == listView->column(AlarmListView::MESSAGE_COLUMN)) { if(!selected && listView->drawMessageInColour()) { painter->fillRect(box, event().bgColour()); painter->setBackgroundColor(event().bgColour()); // painter->setPen(event().fgColour()); } QString txt = text(column); painter->drawText(box, AlignVCenter, txt); mMessageColWidth = listView->fontMetrics().boundingRect(txt).width(); } }
void GCUserViewItem::paintBranches(QPainter *p, const QColorGroup &cg, int w, int, int h) { // paint a square of nothing p->fillRect(0, 0, w, h, cg.base()); }
void K3bDeviceBranchViewItem::paintCell( QPainter* p, const QColorGroup& cg, int /* col */, int width, int align ) { p->save(); int xpos = 1; int ypos = 1; QFontMetrics fm( p->fontMetrics() ); if( isSelected() ) { p->fillRect( 0, 0, width, height(), cg.brush( QColorGroup::Highlight ) ); p->setPen( cg.highlightedText() ); } else { p->fillRect( 0, 0, width, height(), cg.base() ); p->setPen( cg.text() ); } if( pixmap(0) ) { p->drawPixmap( xpos, ypos, *pixmap(0) ); xpos += pixmap(0)->width() + 5; } if( m_bCurrent ) { QFont f( listView()->font() ); f.setBold( true ); p->setFont( f ); } ypos += fm.ascent(); QString line1 = text(0).left( text(0).find('\n') ); p->drawText( xpos, ypos, line1 ); QFont f( listView()->font() ); f.setItalic( true ); f.setBold( false ); f.setPointSize( f.pointSize() - 2 ); p->setFont( f ); ypos += p->fontMetrics().height() + 1; QString line2 = text(0).mid( text(0).find('\n')+1 ); p->drawText( xpos - p->fontMetrics().leftBearing( line2[0] ), ypos, line2 ); // from QListViewItem if( isOpen() && childCount() ) { int textheight = fm.size( align, text(0) ).height() + 2 * listView()->itemMargin(); textheight = QMAX( textheight, QApplication::globalStrut().height() ); if ( textheight % 2 > 0 ) textheight++; if ( textheight < height() ) { int w = listView()->treeStepSize() / 2; listView()->style().drawComplexControl( QStyle::CC_ListView, p, listView(), QRect( 0, textheight, w + 1, height() - textheight + 1 ), cg, QStyle::Style_Enabled, QStyle::SC_ListViewExpand, (uint)QStyle::SC_All, QStyleOption( this ) ); } } p->restore(); }
void MarkListTable::paintCell( QPainter *p, int row, int col) { QColorGroup cg = QApplication::palette()->normal(); if ( col == 0 ) { if ( items.at( row )->select() ) { //p->setBrush( selectColor ); //p->setPen( selectColor ); p->setBrush(cg.base()); p->setPen(cg.base()); } else { p->setBrush(cg.base()); p->setPen(cg.base()); } p->drawRect(0,0,cellWidth(0),cellHeight()); if( items.at( row )->mark() ) { int xOffset=6; int yOffset=3; if ( items.at( row )->select() ) p->setPen( cg.text() ); //p->setPen( selectTextColor ); else p->setPen( cg.text() ); p->drawLine( xOffset+4, yOffset, xOffset+4, yOffset+9 ); p->setPen( red ); p->drawLine( xOffset+3, yOffset+1, xOffset, yOffset+4 ); p->drawLine( xOffset+3, yOffset+1, xOffset+3, yOffset+4 ); p->drawLine( xOffset, yOffset+4, xOffset+3, yOffset+4 ); } else { int xOffset=4; int yOffset=5; p->setPen( cg.dark() ); p->setBrush( cg.dark() ); p->drawEllipse( xOffset+4, yOffset, 4, 4 ); //p->setPen( cg.mid() ); //p->setBrush( cg.mid() ); //p->drawEllipse( xOffset+5, yOffset+1, 2, 2 ); p->setPen( white ); p->drawPoint( xOffset+5, yOffset+1); } } /*if ( col == 1 ) { if ( items.at( row )->select() ) { p->setBrush(selectColor); p->setPen(selectColor); p->drawRect(0,0,cellWidth(1),cellHeight()); //qDrawShadePanel( p, 3, 2, cellHeight( 1 ) - 6, cellHeight(1)-4, // cg, FALSE, 1, &QBrush(colorGroup().light())); p->setBrush(white); p->setPen(black); p->drawRect(3,2,cellHeight( 1 ) - 7, cellHeight(1)-5); } else { p->setBrush(cg.base()); p->setPen(cg.base()); p->drawRect(0,0,cellWidth(1),cellHeight()); //qDrawShadePanel( p, 3, 2, cellHeight( 1 ) - 6, cellHeight(1)-4, // cg, FALSE,1 ); p->setBrush(white); p->setPen(black); p->drawRect(3,2,cellHeight( 1 ) - 7, cellHeight(1)-5); } //QFontMetrics fm = p->fontMetrics(); //int yPos; // vertical text position //if ( 10 < fm.height() ) // yPos = fm.ascent() + fm.leading()/2; //else // yPos = 5 - fm.height()/2 + fm.ascent(); //p->drawText( 4, yPos, items.at( row )->text() ); }*/ if ( col == 1 ) { if ( items.at( row )->select() ) { p->setBrush(selectColor); p->setPen(selectColor); } else { p->setBrush(cg.base()); p->setPen(cg.base()); } p->drawRect(0,0,cellWidth(2),cellHeight()); /* if ( items.at( row )->select() ) { QColorGroup cg = QApplication::palette()->normal(); qDrawShadePanel( p, 0, 0, cellWidth( 1 ) - 1, cellHeight(), cg, FALSE, 1, &QBrush(colorGroup().light())); }*/ if ( items.at( row )->select() ) p->setPen(selectTextColor); else p->setPen(cg.text()); QFontMetrics fm = p->fontMetrics(); int yPos; // vertical text position /*if ( 10 < fm.height() ) yPos = fm.ascent() + fm.leading()/2; else*/ yPos = cellHeight()-fm.leading()/2; yPos = fm.ascent() + fm.leading()/2+1; p->drawText( 4, yPos, items.at( row )->text() ); } }
void EditorItem::paintBranches(QPainter *p, const QColorGroup &cg, int w, int y, int h) { p->eraseRect(0,0,w,h); KListViewItem *item = static_cast<KListViewItem*>(firstChild()); if(!item) return; QColor backgroundColor; p->save(); p->translate(0,y); QFont font = listView()->font(); while(item) { if(item->isSelected()) backgroundColor = cg.highlight(); else { if (dynamic_cast<EditorGroupItem*>(item)) backgroundColor = cg.base(); else backgroundColor = item->backgroundColor(); } // p->fillRect(-50,0,50, item->height(), QBrush(backgroundColor)); p->save(); p->setPen( KPROPEDITOR_ITEM_BORDER_COLOR ); int delta = 0; int fillWidth = w; int x = 0; if (dynamic_cast<EditorGroupItem*>(item->parent())) { delta = 0;//-19; fillWidth += 19; } else { if (dynamic_cast<EditorGroupItem*>(item) || /*for flat mode*/ dynamic_cast<EditorDummyItem*>(item->parent())) x = 19; else x = -19; fillWidth += 19; } if (dynamic_cast<EditorDummyItem*>(item->parent())) { x = 19; } else if (item->parent() && dynamic_cast<EditorDummyItem*>(item->parent()->parent())) { x = 0; } p->fillRect(x+1, 0, fillWidth-1, item->height()-1, QBrush(backgroundColor)); p->drawLine(x, item->height()-1, w, item->height()-1 ); if (!dynamic_cast<EditorGroupItem*>(item)) p->drawLine(x, 0, x, item->height()-1 ); p->restore(); // for (int i=0; i<10000000; i++) // ; // if(item->isSelected()) { // p->fillRect(parent() ? 0 : 50, 0, w, item->height()-1, QBrush(cg.highlight())); // p->fillRect(-50,0,50, item->height(), QBrush(cg.highlight())); // } //sorry, but we need to draw text here again font.setBold( dynamic_cast<EditorGroupItem*>(item) || (static_cast<EditorItem*>(item)->property() && static_cast<EditorItem*>(item)->property()->isModified()) ); p->setFont(font); p->setPen(item->isSelected() ? cg.highlightedText() : cg.text()); if (item->firstChild() && dynamic_cast<EditorGroupItem*>(item->parent())) { delta = 19-KPROPEDITOR_ITEM_MARGIN-1; } else if (dynamic_cast<EditorDummyItem*>(item->parent())) { delta = 19; } if (item->parent() && dynamic_cast<EditorDummyItem*>(item->parent()->parent())) { if (dynamic_cast<EditorGroupItem*>(item->parent())) delta += KPROPEDITOR_ITEM_MARGIN*2; else delta += KPROPEDITOR_ITEM_MARGIN*5; } if (!dynamic_cast<EditorDummyItem*>(item->parent())) p->drawText(QRect(delta+1,0, w+listView()->columnWidth(1), item->height()), Qt::AlignLeft | Qt::AlignVCenter /*| Qt::SingleLine*/, item->text(0)); if(item->firstChild()) { paintListViewExpander(p, listView(), item->height(), cg, item->isOpen()); } // draw icon (if there is one) EditorItem *editorItem = dynamic_cast<EditorItem*>(item); if (editorItem && editorItem->property() && !editorItem->property()->icon().isEmpty()) { //int margin = listView()->itemMargin(); QPixmap pix = SmallIcon(editorItem->property()->icon()); if (!pix.isNull()) p->drawPixmap(-19+(19-pix.width())/2, (item->height() - pix.height()) / 2, pix); } p->translate(0, item->totalHeight()); item = (KListViewItem*)item->nextSibling(); } p->restore(); }