void PanelKMenu::paintEvent(QPaintEvent * e) { if (sidePixmap.isNull()) { PanelServiceMenu::paintEvent(e); return; } QPainter p(this); p.setClipRegion(e->region()); style().drawPrimitive( QStyle::PE_PanelPopup, &p, QRect( 0, 0, width(), height() ), colorGroup(), QStyle::Style_Default, QStyleOption( frameWidth(), 0 ) ); QRect r = sideImageRect(); r.setBottom( r.bottom() - sidePixmap.height() ); if ( r.intersects( e->rect() ) ) { p.drawTiledPixmap( r, sideTilePixmap ); } r = sideImageRect(); r.setTop( r.bottom() - sidePixmap.height() ); if ( r.intersects( e->rect() ) ) { QRect drawRect = r.intersect( e->rect() ); QRect pixRect = drawRect; pixRect.moveBy( -r.left(), -r.top() ); p.drawPixmap( drawRect.topLeft(), sidePixmap, pixRect ); } drawContents( &p ); }
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 }
void PrettyPopupMenu::paintEvent( QPaintEvent* e ) { generateSidePixmap(); QPainter p( this ); QRect r = sideImageRect(); r.setTop( r.bottom() - s_sidePixmap.height() ); if ( r.intersects( e->rect() ) ) { QRect drawRect = r.intersect( e->rect() ).intersect( sideImageRect() ); QRect pixRect = drawRect; pixRect.moveBy( -r.left(), -r.top() ); p.drawImage( drawRect.topLeft(), s_sidePixmap, pixRect ); } p.setClipRegion( e->region() ); //NOTE The order is important here. drawContents() must be called before drawPrimitive(), // otherwise we get rendering glitches. drawContents( &p ); style().drawPrimitive( QStyle::PE_PanelPopup, &p, QRect( 0, 0, width(), height() ), colorGroup(), QStyle::Style_Default, QStyleOption( frameWidth(), 0 ) ); }
void RegionGrabber::drawRubber() { QPainter p; p.begin( this ); p.setRasterOp( NotROP ); p.setPen( QPen( color0, 1 ) ); p.setBrush( NoBrush ); style().drawPrimitive( QStyle::PE_FocusRect, &p, grabRect, colorGroup(), QStyle::Style_Default, QStyleOption( colorGroup().base() ) ); p.end(); }
static void TreeViewFieldElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned state) { if (!TileGtk_GtkInitialised()) NO_GTK_STYLE_ENGINE; NULL_PROXY_WIDGET(TileGtk_QWidget_Widget); Tcl_MutexLock(&tilegtkMutex); QPixmap pixmap(b.width, b.height); QPainter painter(&pixmap); TILEGTK_PAINT_BACKGROUND_BASE(b.width, b.height); TILEGTK_SET_FOCUS(state); #ifdef TILEGTK_GTK_VERSION_3 QStyle::SFlags sflags =TileGtk_StateTableLookup(treeview_field_statemap, state); sflags |= QStyle::Style_Horizontal; wc->TileGtk_Style->drawPrimitive(QStyle::PE_GroupBoxFrame, &painter, QRect(0, 0, b.width, b.height), qApp->palette().active(), sflags, QStyleOption(/*lineWidth*/1, /*midLineWidth*/0, /*frameShape*/QFrame::StyledPanel, /*frameShadow*/QFrame::Sunken)); wc->TileGtk_Style->drawPrimitive(QStyle::PE_PanelLineEdit, &painter, QRect(0, 0, b.width, b.height), qApp->palette().active(), sflags, QStyleOption(1,1)); #endif /* TILEGTK_GTK_VERSION_3 */ #ifdef TILEGTK_GTK_VERSION_4 QStyleOptionFrame option; option.rect = QRect(0, 0, b.width, b.height); option.lineWidth = 1; option.state |= (QStyle::StateFlag) TileGtk_StateTableLookup(treeview_field_statemap, state); wc->TileGtk_Style->drawPrimitive(QStyle::PE_FrameGroupBox, &option, &painter); #endif /* TILEGTK_GTK_VERSION_4 */ TILEGTK_CLEAR_FOCUS(state); // printf("x=%d, y=%d, w=%d, h=%d\n", b.x, b.y, b.width, b.height); TileGtk_CopyGtkPixmapOnToDrawable(gdkDrawable, d, tkwin, 0, 0, b.width, b.height, b.x, b.y); Tcl_MutexUnlock(&tilegtkMutex); }
QRect KCompletionBox::calculateGeometry() const { QRect visualRect; if (count() == 0 || !(visualRect = visualItemRect(item(0))).isValid()) return QRect(); int x = 0, y = 0; int ih = visualRect.height(); int h = qMin( 15 * ih, (int) count() * ih ) + 2*frameWidth(); int w = (d->m_parent) ? d->m_parent->width() : KListWidget::minimumSizeHint().width(); w = qMax( KListWidget::minimumSizeHint().width(), w ); //### M.O.: Qt4 doesn't actually honor SC_ComboBoxListBoxPopup ??? #if 0 //If we're inside a combox, Qt by default makes the dropdown // as wide as the combo, and gives the style a chance // to adjust it. Do that here as well, for consistency const QObject* combo; if ( d->m_parent && (combo = d->m_parent->parent() ) && qobject_cast<QComboBox*>(combo) ) { const QComboBox* cb = static_cast<const QComboBox*>(combo); //Expand to the combo width w = qMax( w, cb->width() ); QPoint parentCorner = d->m_parent->mapToGlobal(QPoint(0, 0)); QPoint comboCorner = cb->mapToGlobal(QPoint(0, 0)); //We need to adjust our horizontal position to also be WRT to the combo x += comboCorner.x() - parentCorner.x(); //The same with vertical one y += cb->height() - d->m_parent->height() + comboCorner.y() - parentCorner.y(); //Ask the style to refine this a bit QRect styleAdj = style().querySubControlMetrics(QStyle::CC_ComboBox, cb, QStyle::SC_ComboBoxListBoxPopup, QStyleOption(x, y, w, h)); //QCommonStyle returns QRect() by default, so this is what we get if the //style doesn't implement this if (!styleAdj.isNull()) return styleAdj; } #endif return QRect(x, y, w, h); }
void KTabBar::paintLabel( QPainter *p, const QRect& br, QTab *t, bool has_focus ) const { QRect r = br; bool selected = currentTab() == t->identifier(); if ( t->iconSet() ) { // the tab has an iconset, draw it in the right mode QIconSet::Mode mode = ( t->isEnabled() && isEnabled() ) ? QIconSet::Normal : QIconSet::Disabled; if ( mode == QIconSet::Normal && has_focus ) mode = QIconSet::Active; QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); int pixw = pixmap.width(); int pixh = pixmap.height(); r.setLeft( r.left() + pixw + 4 ); r.setRight( r.right() + 2 ); #if QT_VERSION >= 0x030200 int inactiveXShift = style().pixelMetric( QStyle::PM_TabBarTabShiftHorizontal, this ); int inactiveYShift = style().pixelMetric( QStyle::PM_TabBarTabShiftVertical, this ); #else int inactiveXShift = 0; int inactiveYShift = 0; #endif int right = t->text().isEmpty() ? br.right() - pixw : br.left() + 2; p->drawPixmap( right + ((selected == true) ? 0 : inactiveXShift), br.center().y() - pixh / 2 + ((selected == true) ? 0 : inactiveYShift), pixmap ); } QStyle::SFlags flags = QStyle::Style_Default; if ( isEnabled() && t->isEnabled() ) flags |= QStyle::Style_Enabled; if ( has_focus ) flags |= QStyle::Style_HasFocus; QColorGroup cg( colorGroup() ); if ( mTabColors.contains( t->identifier() ) ) cg.setColor( QColorGroup::Foreground, mTabColors[t->identifier()] ); style().drawControl( QStyle::CE_TabBarLabel, p, this, r, t->isEnabled() ? cg : palette().disabled(), flags, QStyleOption(t) ); }
static void BorderElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned state) { if (qApp == NULL) NULL_Q_APP; NULL_PROXY_WIDGET(TileQt_QWidget_WidgetParent); Tcl_MutexLock(&tileqtMutex); BorderElement *border = (BorderElement*) elementRecord; int relief = TK_RELIEF_FLAT; int borderWidth = 0; Tcl_GetIntFromObj(NULL, border->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, border->reliefObj, &relief); QStyle::State sflags; switch (relief) { case TK_RELIEF_GROOVE : case TK_RELIEF_RIDGE : case TK_RELIEF_RAISED : sflags |= QStyle::State_Raised; break; case TK_RELIEF_SUNKEN : sflags |= QStyle::State_Sunken; break; case TK_RELIEF_FLAT : break; case TK_RELIEF_SOLID : break; } QPixmap pixmap(b.width, b.height); QPainter painter(&pixmap); if (!(wc->TileQt_QPixmap_BackgroundTile.isNull())) { painter.fillRect(0, 0, b.width, b.height, QBrush(QColor(255,255,255), (wc->TileQt_QPixmap_BackgroundTile))); } else { painter.fillRect(0, 0, b.width, b.height, #ifdef TILEQT_QT_VERSION_3 qApp->palette().active().background()); #endif /*TILEQT_QT_VERSION_3*/ #ifdef TILEQT_QT_VERSION_4 QColor(0, 0, 0, 0)); //qApp->palette().window()); //palette().paletteBackgroundColor()); #endif /*TILEQT_QT_VERSION_4*/ } if (borderWidth) { #ifdef TILEQT_QT_VERSION_3 wc->TileQt_Style->drawPrimitive(QStyle::PE_GroupBoxFrame, &painter, QRect(0, 0, b.width, b.height), qApp->palette().active(), //sflags, QStyleOption(borderWidth, 0)); #endif /*TILEQT_QT_VERSION_3*/ //inQt3: QStyle::drawPrimitive(QStyle::PrimitiveElement, QPainter*, QRect, const QBrush&, QStyleOption #ifdef TILEQT_QT_VERSION_4 //in QT4: virtual void QStyle::drawPrimitive(QStyle::PrimitiveElement, const QStyleOption*, QPainter*, const QWidget*) const QStyleOption qso(borderWidth, 0); //QRect qr(0, 0, b.width, b.height); wc->TileQt_Style->drawPrimitive(QStyle::PE_FrameGroupBox, &qso, &painter, NULL//, //qApp->palette().toolTipBase(), //sflags ); #endif /*TILEQT_QT_VERSION_4*/ } TileQt_CopyQtPixmapOnToDrawable(pixmap, d, tkwin, 0, 0, b.width, b.height, b.x, b.y); Tcl_MutexUnlock(&tileqtMutex); }
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 ChannelListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) { QPixmap back( width, height() ); QPainter paint( &back ); //KListViewItem::paintCell( &paint, cg, column, width, align ); // PASTED FROM KLISTVIEWITEM: // set the alternate cell background colour if necessary QColorGroup _cg = cg; if (isAlternate()) if (listView()->viewport()->backgroundMode()==Qt::FixedColor) _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); else _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); // PASTED FROM QLISTVIEWITEM { QPainter *p = &paint; QListView *lv = listView(); if ( !lv ) return; QFontMetrics fm( p->fontMetrics() ); // any text we render is done by the Components, not by this class, so make sure we've nothing to write QString t; // removed text truncating code from Qt - we do that differently, further on int marg = lv->itemMargin(); int r = marg; // const QPixmap * icon = pixmap( column ); const BackgroundMode bgmode = lv->viewport()->backgroundMode(); const QColorGroup::ColorRole crole = QPalette::backgroundRoleFromMode( bgmode ); if ( _cg.brush( crole ) != lv->colorGroup().brush( crole ) ) p->fillRect( 0, 0, width, height(), _cg.brush( crole ) ); else { // all copied from QListView::paintEmptyArea //lv->paintEmptyArea( p, QRect( 0, 0, width, height() ) ); QStyleOption opt( lv->sortColumn(), 0 ); // ### hack; in 3.1, add a property in QListView and QHeader QStyle::SFlags how = QStyle::Style_Default; if ( lv->isEnabled() ) how |= QStyle::Style_Enabled; lv->style().drawComplexControl( QStyle::CC_ListView, p, lv, QRect( 0, 0, width, height() ), lv->colorGroup(), how, QStyle::SC_ListView, QStyle::SC_None, opt ); } if ( isSelected() && (column == 0 || lv->allColumnsShowFocus()) ) { p->fillRect( r - marg, 0, width - r + marg, height(), _cg.brush( QColorGroup::Highlight ) ); // removed text pen setting code from Qt } // removed icon drawing code from Qt // draw the tree gubbins if ( multiLinesEnabled() && column == 0 && isOpen() && childCount() ) { int textheight = fm.size( align, t ).height() + 2 * lv->itemMargin(); textheight = QMAX( textheight, QApplication::globalStrut().height() ); if ( textheight % 2 > 0 ) textheight++; if ( textheight < height() ) { int w = lv->treeStepSize() / 2; lv->style().drawComplexControl( QStyle::CC_ListView, p, lv, QRect( 0, textheight, w + 1, height() - textheight + 1 ), _cg, lv->isEnabled() ? QStyle::Style_Enabled : QStyle::Style_Default, QStyle::SC_ListViewExpand, (uint)QStyle::SC_All, QStyleOption( this ) ); } } } // END OF PASTE //do you see a better way to tell the TextComponent we are selected ? - Olivier 2004-09-02 if ( isSelected() ) _cg.setColor(QColorGroup::Text , _cg.highlightedText() ); QSimpleRichText myrichtext( text(column), paint.font() ); myrichtext.draw( &paint, 0, 0, paint.window(), _cg ); paint.end(); p->drawPixmap( 0, 0, back ); }
void KMenuBar::drawContents(QPainter *p) { // Closes the BR77113 // We need to overload this method to paint only the menu items // This way when the KMenuBar is embedded in the menu applet it // integrates correctly. // // Background mode and origin are set so late because of styles // using the polish() method to modify these settings. // // Of course this hack can safely be removed when real transparency // will be available if(!d->topLevel) { QMenuBar::drawContents(p); } else { bool up_enabled = isUpdatesEnabled(); BackgroundMode bg_mode = backgroundMode(); BackgroundOrigin bg_origin = backgroundOrigin(); setUpdatesEnabled(false); setBackgroundMode(X11ParentRelative); setBackgroundOrigin(WindowOrigin); p->eraseRect(rect()); erase(); QColorGroup g = colorGroup(); bool e; for(int i = 0; i < (int)count(); i++) { QMenuItem *mi = findItem(idAt(i)); if(!mi->text().isNull() || mi->pixmap()) { QRect r = itemRect(i); if(r.isEmpty() || !mi->isVisible()) continue; e = mi->isEnabledAndVisible(); if(e) g = isEnabled() ? (isActiveWindow() ? palette().active() : palette().inactive()) : palette().disabled(); else g = palette().disabled(); bool item_active = (actItem == i); p->setClipRect(r); if(item_active) { QStyle::SFlags flags = QStyle::Style_Default; if(isEnabled() && e) flags |= QStyle::Style_Enabled; if(item_active) flags |= QStyle::Style_Active; if(item_active && actItemDown) flags |= QStyle::Style_Down; flags |= QStyle::Style_HasFocus; style().drawControl(QStyle::CE_MenuBarItem, p, this, r, g, flags, QStyleOption(mi)); } else { style().drawItem(p, r, AlignCenter | AlignVCenter | ShowPrefix, g, e, mi->pixmap(), mi->text()); } } } setBackgroundOrigin(bg_origin); setBackgroundMode(bg_mode); setUpdatesEnabled(up_enabled); } }
/*!\reimp */ void QPlatinumStyle::drawComplexControl( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how, SCFlags sub, SCFlags subActive, const QStyleOption& opt ) const { switch ( control ) { case CC_ComboBox: { int x, y, w, h; r.rect( &x, &y, &w, &h ); p->fillRect( x + 2, y + 2, w - 4, h - 4, cg.brush(QColorGroup::Button) ); // the bright side p->setPen(cg.shadow()); p->drawLine( x, y, x + w - 1, y ); p->drawLine( x, y, x, y + h - 1 ); p->setPen( cg.light() ); p->drawLine( x + 1, y + 1, x + w - 2, y + 1 ); p->drawLine( x + 1, y + 1, x + 1, y + h - 2 ); // the dark side! p->setPen( cg.mid() ); p->drawLine( x + 2, y + h - 2, x + w - 2, y + h - 2 ); p->drawLine( x + w - 2, y + 2, x + w - 2, y + h - 2 ); p->setPen (cg.shadow() ); p->drawLine( x + 1, y + h - 1, x + w - 1, y + h - 1 ); p->drawLine( x + w - 1, y, x + w - 1, y + h - 1 ); // top left corner: p->setPen( cg.background() ); p->drawPoint( x, y ); p->drawPoint( x + 1, y ); p->drawPoint( x, y + 1 ); p->setPen( cg.shadow() ); p->drawPoint( x + 1, y + 1 ); p->setPen( white ); p->drawPoint( x + 3, y + 3 ); // bottom left corner: p->setPen( cg.background() ); p->drawPoint( x, y + h - 1 ); p->drawPoint( x + 1, y + h - 1 ); p->drawPoint( x, y + h - 2 ); p->setPen( cg.shadow() ); p->drawPoint( x + 1, y + h - 2 ); // top right corner: p->setPen( cg.background() ); p->drawPoint( x + w - 1, y ); p->drawPoint( x + w - 2, y ); p->drawPoint( x + w - 1, y + 1 ); p->setPen( cg.shadow() ); p->drawPoint( x + w - 2, y + 1 ); // bottom right corner: p->setPen( cg.background() ); p->drawPoint( x + w - 1, y + h - 1 ); p->drawPoint( x + w - 2, y + h - 1 ); p->drawPoint( x + w - 1, y + h - 2 ); p->setPen( cg.shadow() ); p->drawPoint( x + w - 2, y + h - 2 ); p->setPen( cg.dark() ); p->drawPoint( x + w - 3, y + h - 3 ); if ( sub & SC_ComboBoxArrow ) { QRect rTmp = querySubControlMetrics( CC_ComboBox, widget, SC_ComboBoxArrow, opt ); int xx = rTmp.x(), yy = rTmp.y(), ww = rTmp.width(), hh = rTmp.height(); // the bright side p->setPen( cg.mid() ); p->drawLine( xx, yy+2, xx, yy+hh-3 ); p->setPen( cg.button() ); p->drawLine( xx+1, yy+1, xx+ww-2, yy+1 ); p->drawLine( xx+1, yy+1, xx+1, yy+hh-2 ); p->setPen( cg.light() ); p->drawLine( xx+2, yy+2, xx+2, yy+hh-2 ); p->drawLine( xx+2, yy+2, xx+ww-2, yy+2 ); // the dark side! p->setPen( cg.mid() ); p->drawLine( xx+3, yy+hh-3 ,xx+ww-3, yy+hh-3 ); p->drawLine( xx+ww-3, yy+3, xx+ww-3, yy+hh-3 ); p->setPen( cg.dark() ); p->drawLine( xx+2, yy+hh-2 ,xx+ww-2, yy+hh-2 ); p->drawLine( xx+ww-2, yy+2, xx+ww-2, yy+hh-2 ); p->setPen( cg.shadow() ); p->drawLine( xx+1, yy+hh-1,xx+ww-1, yy+hh-1 ); p->drawLine( xx+ww-1, yy, xx+ww-1, yy+hh-1 ); // top right corner: p->setPen( cg.background() ); p->drawPoint( xx + ww - 1, yy ); p->drawPoint( xx + ww - 2, yy ); p->drawPoint( xx + ww - 1, yy + 1 ); p->setPen( cg.shadow() ); p->drawPoint( xx + ww - 2, yy + 1 ); // bottom right corner: p->setPen( cg.background() ); p->drawPoint( xx + ww - 1, yy + hh - 1 ); p->drawPoint( xx + ww - 2, yy + hh - 1 ); p->drawPoint( xx + ww - 1, yy + hh - 2 ); p->setPen( cg.shadow() ); p->drawPoint( xx + ww - 2, yy + hh - 2 ); p->setPen( cg.dark() ); p->drawPoint( xx + ww - 3, yy + hh - 3 ); p->setPen( cg.mid() ); p->drawPoint( xx + ww - 4, yy + hh - 4 ); // and the arrows p->setPen( cg.foreground() ); QPointArray a ; a.setPoints( 7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2 ); a.translate( xx + ww / 2, yy + hh / 2 - 3 ); p->drawLineSegments( a, 0, 3 ); // draw arrow p->drawPoint( a[6] ); a.setPoints( 7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2 ); a.translate( xx + ww / 2, yy + hh / 2 + 2 ); p->drawLineSegments( a, 0, 3 ); // draw arrow p->drawPoint( a[6] ); } #ifndef QT_NO_COMBOBOX if ( sub & SC_ComboBoxEditField ) { const QComboBox *cmb; cmb = (const QComboBox*)widget; // sadly this is pretty much the windows code, except // for the first fillRect call... QRect re = QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget, SC_ComboBoxEditField ), widget ); if ( cmb->hasFocus() && !cmb->editable() ) p->fillRect( re.x() + 1, re.y() + 1, re.width() - 2, re.height() - 2, cg.brush( QColorGroup::Highlight ) ); if ( cmb->hasFocus() ) { p->setPen( cg.highlightedText() ); p->setBackgroundColor( cg.highlight() ); } else { p->setPen( cg.text() ); p->setBackgroundColor( cg.background() ); } if ( cmb->hasFocus() && !cmb->editable() ) { QRect re = QStyle::visualRect( subRect( SR_ComboBoxFocusRect, cmb ), widget ); drawPrimitive( PE_FocusRect, p, re, cg, Style_FocusAtBorder, QStyleOption(cg.highlight())); } if ( cmb->editable() ) { // need this for the moment... // was the code in comboButton rect QRect ir( x + 3, y + 3, w - 6 - 16, h - 6 ); if ( QApplication::reverseLayout() ) ir.moveBy( 16, 0 ); // end comboButtonRect... ir.setRect( ir.left() - 1, ir.top() - 1, ir.width() + 2, ir.height() + 2 ); qDrawShadePanel( p, ir, cg, TRUE, 2, 0 ); } } #endif break; } case CC_Slider: { #ifndef QT_NO_SLIDER const QSlider *slider = (const QSlider *) widget; int thickness = pixelMetric( PM_SliderControlThickness, widget ); int len = pixelMetric( PM_SliderLength, widget ); int ticks = slider->tickmarks(); QRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove, opt), handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle, opt); if ((sub & SC_SliderGroove) && groove.isValid()) { p->fillRect( groove, cg.brush(QColorGroup::Background) ); int x, y, w, h; int mid = thickness / 2; if ( ticks & QSlider::Above ) mid += len / 8; if ( ticks & QSlider::Below ) mid -= len / 8; if ( slider->orientation() == Horizontal ) { x = 0; y = groove.y() + mid - 3; w = slider->width(); h = 7; } else { x = groove.x() + mid - 3; y = 0; w = 7; h = slider->height(); } p->fillRect( x, y, w, h, cg.brush( QColorGroup::Dark )); // the dark side p->setPen( cg.dark() ); p->drawLine( x, y, x + w - 1, y ); p->drawLine( x, y, x, y + h - 1); p->setPen( cg.shadow() ); p->drawLine( x + 1, y + 1, x + w - 2, y + 1 ); p->drawLine( x + 1, y + 1, x + 1, y + h - 2 ); // the bright side! p->setPen(cg.shadow()); p->drawLine( x + 1, y + h - 2, x + w - 2, y + h - 2 ); p->drawLine( x + w - 2, y + 1, x + w - 2, y + h - 2 ); p->setPen( cg.light() ); p->drawLine( x, y + h - 1, x + w - 1, y + h - 1 ); p->drawLine( x + w - 1, y, x + w - 1, y + h - 1 ); // top left corner: p->setPen(cg.background()); p->drawPoint( x, y ); p->drawPoint( x + 1, y ); p->drawPoint( x, y + 1 ); p->setPen(cg.shadow()); p->drawPoint( x + 1, y + 1 ); // bottom left corner: p->setPen( cg.background() ); p->drawPoint( x, y + h - 1 ); p->drawPoint( x + 1, y + h - 1 ); p->drawPoint( x, y + h - 2 ); p->setPen( cg.light() ); p->drawPoint( x + 1, y + h - 2 ); // top right corner: p->setPen( cg.background() ); p->drawPoint( x + w - 1, y ); p->drawPoint( x + w - 2, y ); p->drawPoint( x + w - 1, y + 1 ); p->setPen( cg.dark() ); p->drawPoint( x + w - 2, y + 1 ); // bottom right corner: p->setPen( cg.background() ); p->drawPoint( x + w - 1, y + h - 1 ); p->drawPoint( x + w - 2, y + h - 1 ); p->drawPoint( x + w - 1, y + h - 2 ); p->setPen( cg.light() ); p->drawPoint( x + w - 2, y + h - 2 ); p->setPen( cg.dark() ); p->drawPoint( x + w - 3, y + h - 3 ); // ### end slider groove if ( how & Style_HasFocus ) drawPrimitive( PE_FocusRect, p, groove, cg ); } if ((sub & SC_SliderHandle) && handle.isValid()) { const QColor c0 = cg.shadow(); const QColor c1 = cg.dark(); const QColor c3 = cg.light(); int x1 = handle.x(); int x2 = handle.x() + handle.width() - 1; int y1 = handle.y(); int y2 = handle.y() + handle.height() - 1; int mx = handle.width() / 2; int my = handle.height() / 2; if ( slider->orientation() == Vertical ) { // Background QBrush oldBrush = p->brush(); p->setBrush( cg.brush( QColorGroup::Button ) ); p->setPen( NoPen ); QPointArray a(6); a.setPoint( 0, x1 + 1, y1 + 1 ); a.setPoint( 1, x2 - my + 2, y1 + 1 ); a.setPoint( 2, x2 - 1, y1 + my - 1 ); a.setPoint( 3, x2 - 1, y2 - my + 1 ); a.setPoint( 4, x2 - my + 2, y2 - 1 ); a.setPoint( 5, x1 + 1, y2 - 1 ); p->drawPolygon( a ); p->setBrush( oldBrush ); // shadow border p->setPen( c0 ); p->drawLine( x1, y1 + 1, x1,y2 - 1 ); p->drawLine( x2 - my + 2, y1, x2, y1 + my - 2 ); p->drawLine( x2 - my + 2, y2, x2, y1 + my + 2 ); p->drawLine( x2, y1 + my - 2, x2, y1 + my + 2 ); p->drawLine( x1 + 1, y1, x2 - my + 2, y1 ); p->drawLine( x1 + 1, y2, x2 - my + 2, y2 ); // light shadow p->setPen( c3 ); p->drawLine( x1 + 1, y1 + 2, x1 + 1, y2 - 2 ); p->drawLine( x1 + 1, y1 + 1, x2 - my + 2, y1 + 1 ); p->drawLine( x2 - my + 2, y1 + 1, x2 - 1, y1 + my - 2 ); // dark shadow p->setPen(c1); p->drawLine( x2 - 1, y1 + my - 2, x2 - 1, y1 + my + 2 ); p->drawLine( x2 - my + 2, y2 - 1, x2 - 1, y1 + my + 2 ); p->drawLine( x1 + 1, y2 - 1, x2 -my + 2, y2 - 1 ); drawRiffles( p, handle.x(), handle.y() + 2, handle.width() - 3, handle.height() - 4, cg, TRUE ); } else { // Horizontal QBrush oldBrush = p->brush(); p->setBrush( cg.brush( QColorGroup::Button ) ); p->setPen( NoPen ); QPointArray a(6); a.setPoint( 0, x2 - 1, y1 + 1 ); a.setPoint( 1, x2 - 1, y2 - mx + 2 ); a.setPoint( 2, x2 - mx + 1, y2 - 1 ); a.setPoint( 3, x1 + mx - 1, y2 - 1 ); a.setPoint( 4, x1 + 1, y2 - mx + 2 ); a.setPoint( 5, x1 + 1, y1 + 1 ); p->drawPolygon( a ); p->setBrush( oldBrush ); // shadow border p->setPen( c0 ); p->drawLine( x1 + 1, y1, x2 - 1, y1 ); p->drawLine( x1, y2 - mx + 2, x1 + mx - 2, y2 ); p->drawLine( x2, y2 - mx + 2, x1 + mx + 2, y2 ); p->drawLine( x1 + mx - 2, y2, x1 + mx + 2, y2 ); p->drawLine( x1, y1 + 1, x1, y2 - mx + 2 ); p->drawLine( x2, y1 + 1, x2, y2 - mx + 2 ); // light shadow p->setPen(c3); p->drawLine( x1 + 1, y1 + 1, x2 - 1, y1 + 1 ); p->drawLine( x1 + 1, y1 + 1, x1 + 1, y2 - mx + 2 ); // dark shadow p->setPen(c1); p->drawLine( x2 - 1, y1 + 1, x2 - 1, y2 - mx + 2 ); p->drawLine( x1 + 1, y2 - mx + 2, x1 + mx - 2, y2 - 1 ); p->drawLine( x2 - 1, y2 - mx + 2, x1 + mx + 2, y2 - 1 ); p->drawLine( x1 + mx - 2, y2 - 1, x1 + mx + 2, y2 - 1 ); drawRiffles( p, handle.x() + 2, handle.y(), handle.width() - 4, handle.height() - 5, cg, FALSE ); } } if ( sub & SC_SliderTickmarks ) QCommonStyle::drawComplexControl( control, p, widget, r, cg, how, SC_SliderTickmarks, subActive, opt ); #endif break; } default: QWindowsStyle::drawComplexControl( control, p, widget, r, cg, how, sub, subActive, opt ); break; } }