Beispiel #1
0
/*!\reimp
  */
void QCDEStyle::drawExclusiveIndicator( QPainter* p,
				   int x, int y, int w, int h, const QColorGroup &g,
				   bool on, bool down, bool /* enabled */ )
{
    static const QCOORD pts1[] = {		// up left  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[] = {		// bottom right  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), pts1 );
    a.translate( x, y );
    p->setPen( (down||on) ? g.dark() : g.light() );
    p->drawPolyline( a );
    a.setPoints( QCOORDARRLEN(pts4), pts4 );
    a.translate( x, y );
    p->setPen(  (down||on) ? g.light() : g.dark() );
    p->drawPolyline( a );
    a.setPoints( QCOORDARRLEN(pts5), pts5 );
    a.translate( x, y );
    QColor fillColor = on ? g.dark() : g.background();
    p->setPen( fillColor );
    p->setBrush( on ?  g.brush( QColorGroup::Dark )        :
		       g.brush( QColorGroup::Background ) );
    p->drawPolygon( a );
}
Beispiel #2
0
/*!\reimp
 */
void QWindowsStyle::drawComboButton( QPainter *p, int x, int y, int w, int h,
				     const QColorGroup &g, bool sunken ,
				     bool /* editable */,
				     bool enabled,
				     const QBrush *fill )
{
    qDrawWinPanel(p, x, y, w, h, g, TRUE,
		   fill?fill:(enabled?&g.brush( QColorGroup::Base ):
				      &g.brush( QColorGroup::Background )));
    // the special reversed left shadow panel ( slightly different from drawPanel() )
    //qDrawWinPanel(p, w-2-16,2,16,h-4, g, sunken);
    // #### DO SUNKEN!
    if ( sunken )
	drawWinShades( p, x+w-2-16, y+2, 16, h-4,
		       g.dark(), g.dark(), g.button(), g.button(), 
		       fill ? fill : &g.brush( QColorGroup::Button ) );
    else
	drawWinShades( p, x+w-2-16, y+2, 16, h-4,
		       g.midlight(), g.shadow(), g.light(), g.dark(), 
		       fill ? fill : &g.brush( QColorGroup::Button ) );


    drawArrow( p, QStyle::DownArrow, sunken,
	       x+w-2-16+ 2, y+2+ 2, 16- 4, h-4- 4, g, enabled,
	       fill ? fill : &g.brush( QColorGroup::Button ) );

}
// 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;
}
Beispiel #4
0
void qDrawWinPanel( QPainter *p, int x, int y, int w, int h,
		    const QColorGroup &g, bool	sunken,
		    const QBrush *fill )
{
    if ( sunken )
	qDrawWinShades( p, x, y, w, h,
			g.dark(), g.light(), g.shadow(), g.midlight(), fill );
    else
	qDrawWinShades( p, x, y, w, h,
			g.light(), g.shadow(), g.midlight(), g.dark(), fill );
}
Beispiel #5
0
/*!
  Draws a press-sensitive shape.
*/
void QWindowsStyle::drawButton( QPainter *p, int x, int y, int w, int h,
				const QColorGroup &g, bool sunken, const QBrush* fill)
{
    if (sunken)
	drawWinShades( p, x, y, w, h,
		       g.shadow(), g.light(), g.dark(), g.button(),
		       fill?fill: &g.brush( QColorGroup::Button ) );
    else
	drawWinShades( p, x, y, w, h,
		       g.light(), g.shadow(), g.button(), g.dark(),
		       fill?fill:&g.brush( QColorGroup::Button ) );

}
void HierarchyItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
{
    QColorGroup g( cg );
    g.setColor( QColorGroup::Base, backgroundColor() );
    g.setColor( QColorGroup::Foreground, Qt::black );
    g.setColor( QColorGroup::Text, Qt::black );
    QString txt = text( 0 );
    if ( rtti() == Slot &&
   ( txt == "init()" || txt == "destroy()" ) ) {
  listView()->setUpdatesEnabled( false );
  if ( txt == "init()" )
      setText( 0, txt + " " + i18n( "(Constructor)" ) );
  else
      setText( 0, txt + " " + i18n( "(Destructor)" ) );
  QListViewItem::paintCell( p, g, column, width, align );
  setText( 0, txt );
  listView()->setUpdatesEnabled( true );
    } else {
  QListViewItem::paintCell( p, g, column, width, align );
    }
    p->save();
    p->setPen( QPen( cg.dark(), 1 ) );
    if ( column == 0 )
  p->drawLine( 0, 0, 0, height() - 1 );
    if ( listView()->firstChild() != this ) {
  if ( nextSibling() != itemBelow() && itemBelow()->depth() < depth() ) {
      int d = depth() - itemBelow()->depth();
      p->drawLine( -listView()->treeStepSize() * d, height() - 1, 0, height() - 1 );
  }
    }
    p->drawLine( 0, height() - 1, width, height() - 1 );
    p->drawLine( width - 1, 0, width - 1, height() );
    p->restore();
}
Beispiel #7
0
void KWTextImage::drawCustomItem( QPainter* p, int x, int y, int wpix, int hpix, int /*ascentpix*/, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected, int /*offset*/,  bool drawingShadow)
{
    if ( drawingShadow )
        return;

    // (x,y) is the position of the inline item (in pixels)
    // (wpix,hpix) is the size of the inline item (in pixels)
    // (cx,cy,cw,ch) is the rectangle to be painted, in pixels too
    if ( m_image.isNull() ) {
        kdDebug() << "KWTextImage::draw null image!" << endl;
        p->fillRect( x, y, 50, 50, cg.dark() );
        return;
    }

    QSize imgSize( wpix, hpix );

    QRect rect( QPoint(x, y), imgSize );
    if ( !rect.intersects( QRect( cx, cy, cw, ch ) ) )
        return;

    QPixmap pixmap=m_image.generatePixmap( imgSize, true );
    //if ( placement() == PlaceInline )
        p->drawPixmap( x, y, pixmap );
    //else
    //    p->drawPixmap( cx, cy, pixmap, cx - x, cy - y, cw, ch );

    if ( selected && placement() == PlaceInline && p->device()->devType() != QInternal::Printer ) {
        p->fillRect( rect , QBrush( cg.highlight(), QBrush::Dense4Pattern) );
    }
}
Beispiel #8
0
/*!\reimp
  */
void QCDEStyle::drawIndicator( QPainter* p,
			       int x, int y, int w, int h, const QColorGroup &g,
			       int s, bool down, bool /* enabled */ )
{
    bool showUp = !down && s == QButton::Off;
    QBrush fill =  down ? g.brush( QColorGroup::Mid )   :
			  g.brush( QColorGroup::Button );
    qDrawShadePanel( p, x, y, w, h, g, !showUp, defaultFrameWidth(), &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.foreground() );
	p->drawLineSegments( a );
    }
}
Beispiel #9
0
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 );
    }
}
Beispiel #10
0
// 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() ) );


}
Beispiel #11
0
/*!\reimp
 */
void
QWindowsStyle::drawPushButton( QPushButton* btn, QPainter *p)
{
#ifndef QT_NO_PUSHBUTTON
    QColorGroup g = btn->colorGroup();
    int x1, y1, x2, y2;

    btn->rect().coords( &x1, &y1, &x2, &y2 );	// get coordinates

    p->setPen( g.foreground() );
    p->setBrush( QBrush(g.button(),NoBrush) );

    int diw = buttonDefaultIndicatorWidth();
    if ( btn->isDefault() || btn->autoDefault() ) {
	if ( btn->isDefault() ) {
	    p->setPen( g.shadow() );
	    p->drawRect( x1, y1, x2-x1+1, y2-y1+1 );
	}
	x1 += diw;
	y1 += diw;
	x2 -= diw;
	y2 -= diw;
    }

    bool clearButton = TRUE;
    if ( btn->isDown() ) {
	if ( btn->isDefault() ) {
	    p->setPen( g.dark() );
	    p->drawRect( x1, y1, x2-x1+1, y2-y1+1 );
	} else {
	    drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE,
			&g.brush( QColorGroup::Button ) );
	}
    } else {
	if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() ) {
	    QBrush fill(g.light(), Dense4Pattern );
	    drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, &fill );
	    clearButton = FALSE;
	} else {
	    if ( !btn->isFlat() )
		drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, btn->isOn(),
			&g.brush( QColorGroup::Button ) );
	}
    }
    if ( clearButton ) {
	if (btn->isDown())
	    p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
	p->fillRect( x1+2, y1+2, x2-x1-3, y2-y1-3,
		     g.brush( QColorGroup::Button ) );
	if (btn->isDown())
	    p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
    }

    if ( p->brush().style() != NoBrush )
	p->setBrush( NoBrush );

#endif
}
Beispiel #12
0
void
QWindowsStyle::drawPanel( QPainter *p, int x, int y, int w, int h,
		const QColorGroup &g, bool sunken,
		   int lineWidth, const QBrush* fill)
{
    if ( lineWidth == 2 ) {
	if (sunken)
	    drawWinShades( p, x, y, w, h,
			   g.dark(), g.light(), g.shadow(), g.midlight(),
			   fill );
	else
	    drawWinShades( p, x, y, w, h,
			   g.light(), g.shadow(), g.midlight(), g.dark(),
			   fill );
    }
    else
	QStyle::drawPanel( p, x, y, w, h, g, sunken, lineWidth, fill );
}
/*!
    Draws the nifty Macintosh decoration used on sliders using painter
    \a p and colorgroup \a g. \a x, \a y, \a w, \a h and \a horizontal
    specify the geometry and orientation of the riffles.
*/
void QPlatinumStyle::drawRiffles( QPainter* p,  int x, int y, int w, int h,
				  const QColorGroup &g, bool horizontal ) const
{
    if (!horizontal) {
	if (h > 20) {
	    y += (h-20)/2 ;
	    h = 20;
	}
	if (h > 8) {
	    int n = h / 4;
	    int my = y+h/2-n;
	    int i ;
	    p->setPen(g.light());
	    for (i=0; i<n; i++) {
		p->drawLine(x+3, my+2*i, x+w-5, my+2*i);
	    }
	    p->setPen(g.dark());
	    my++;
	    for (i=0; i<n; i++) {
		p->drawLine(x+4, my+2*i, x+w-4, my+2*i);
	    }
	}
    }
    else {
	if (w > 20) {
	    x += (w-20)/2 ;
	    w = 20;
	}
	if (w > 8) {
	    int n = w / 4;
	    int mx = x+w/2-n;
	    int i ;
	    p->setPen(g.light());
	    for (i=0; i<n; i++) {
		p->drawLine(mx+2*i, y+3, mx + 2*i, y+h-5);
	    }
	    p->setPen(g.dark());
	    mx++;
	    for (i=0; i<n; i++) {
		p->drawLine(mx+2*i, y+4, mx + 2*i, y+h-4);
	    }
	}
    }
}
Beispiel #14
0
    HTMLColors()
    {
        map["black"] = "#000000";
        map["green"] = "#008000";
        map["silver"] = "#c0c0c0";
        map["lime"] = "#00ff00";
        map["gray"] = "#808080";
        map["olive"] = "#808000";
        map["white"] = "#ffffff";
        map["yellow"] = "#ffff00";
        map["maroon"] = "#800000";
        map["navy"] = "#000080";
        map["red"] = "#ff0000";
        map["blue"] = "#0000ff";
        map["purple"] = "#800080";
        map["teal"] = "#008080";
        map["fuchsia"] = "#ff00ff";
        map["aqua"] = "#00ffff";
	map["crimson"] = "#dc143c";
	map["indigo"] = "#4b0082";
#ifdef __BEOS__
	printf( "Warning: HTMLColors::HTMLColors() not initiating all colors\n" );
#else	
        // ### react to style changes
        // see http://www.richinstyle.com for details
        QColorGroup cg = kapp->palette().active();
        map["activeborder"] = cg.light(); // bordercolor of an active window
        map["activecaption"] = cg.text(); // caption color of an active window
        map["appworkspace"] = cg.background(); // background color of an MDI interface
        map["highlight"] = cg.highlight();
        map["highlighttext"] = cg.highlightedText();
        cg = kapp->palette().inactive();
        map["background"] = cg.background(); // desktop background color
        map["buttonface"] = cg.button(); // Button background color
        map["buttonhighlight"] =  cg.light();
        map["buttonshadow"] = cg.shadow();
        map["buttontext"] = cg.buttonText();
        map["captiontext"] = cg.text();
        map["infobackground"] = QToolTip::palette().inactive().background();
        map["menu"] = cg.background();
        map["menutext"] = cg.foreground();
        map["scrollbar"] = cg.background();
        map["threeddarkshadow"] = cg.dark();
        map["threedface"] = cg.button();
        map["threedhighlight"] = cg.light();
        map["threedlightshadow"] = cg.midlight();
        map["window"] = cg.background();
        map["windowframe"] = cg.background();
        map["text"] = cg.text();
        cg = kapp->palette().disabled();
        map["inactiveborder"] = cg.background();
        map["inactivecaption"] = cg.background();
        map["inactivecaptiontext"] = cg.text();
        map["graytext"] = cg.text();
#endif	
    };
Beispiel #15
0
KDEFX_EXPORT void kDrawRoundButton(QPainter *p, const QRect &r, const QColorGroup &g,
                      bool sunken)
{
    int x, y, x2, y2;
    r.coords(&x, &y, &x2, &y2);
    if(r.width() > 16 && r.height() > 16){
        QPen oldPen = p->pen();
        QPointArray hPntArray, lPntArray;
        hPntArray.putPoints(0, 12, x+4,y+1, x+5,y+1, // top left
                            x+3,y+2, x+2,y+3, x+1,y+4, x+1,y+5,
                            x+1,y2-5, x+1,y2-4, x+2,y2-3, // half corners
                            x2-5,y+1, x2-4,y+1, x2-3,y+2);

        lPntArray.putPoints(0, 17, x2-5,y2-1, x2-4,y2-1, // btm right
                            x2-3,y2-2, x2-2,y2-3, x2-1,y2-5, x2-1,y2-4,
 
                            x+3,y2-2, x+4,y2-1, x+5,y2-1, //half corners
                            x2-2,y+3, x2-1,y+4, x2-1,y+5,

                            x2-5,y2-2, x2-4,y2-2, // testing
                            x2-3,y2-3,
                            x2-2,y2-5, x2-2,y2-4);

        p->setPen(sunken ? g.dark() : g.light());
        p->drawLine(x+6, y, x2-6, y);
        p->drawLine(0, y+6, 0, y2-6);
        p->drawPoints(hPntArray);

        p->setPen(sunken ? g.light() : g.dark());
        p->drawLine(x+6, y2, x2-6, y2);
        p->drawLine(x+6, y2-1, x2-6, y2-1);
        p->drawLine(x2, y+6, x2, y2-6);
        p->drawLine(x2-1, y+6, x2-1, y2-6);
        p->drawPoints(lPntArray);
        p->setPen(oldPen);
    }
    else
        qDrawWinPanel(p, x, y, r.width(), r.height(), g, sunken);
}
Beispiel #16
0
void FreshStyle::drawButton( QPainter *p, int x, int y, int w, int h,
                                const QColorGroup &cg, bool sunken, const QBrush* fill )
{
    QPen oldPen = p->pen();
    int off = sunken ? 1 : 0;
    p->fillRect( x+1+off, y+1+off, w-3, h-3, fill?(*fill):cg.brush(QColorGroup::Button) );

    int x2 = x+w-1;
    int y2 = y+h-1;

    if ( sunken )
	p->setPen( cg.dark() );
    else
	p->setPen( cg.light() );
    p->drawLine( x, y, x, y2-1 );
    p->drawLine( x, y, x2, y );

    if ( sunken ) {
	p->setPen( white );
	p->drawLine( x+1, y+1, x+1, y2-2 );
	p->drawLine( x+1, y+1, x2-2, y+1 );
    }

    if ( sunken )
	p->setPen( cg.light() );
    else
	p->setPen( cg.dark() );
    p->drawLine( x2, y+1, x2, y2 );
    p->drawLine( x, y2, x2, y2 );

    if ( !sunken ) {
	p->setPen( white );
	p->drawLine( x2-1, y+1, x2-1, y2-1 );
	p->drawLine( x+1, y2-1, x2-1, y2-1 );
    }
    p->setPen( oldPen );
}
Beispiel #17
0
QPEInputMethod::QPEInputMethod(QWidget *parent,const char *name,WFlags f):QFrame(parent,name,f)
//QPEInputMethod::QPEInputMethod(QWidget *parent,const char *name,WFlags f):QWidget(parent,name,f)
{
 // qt3
 //setBackgroundMode(Qt::NoBackground);
 // qt2
// setBackgroundMode(NoBackground);
// _input[ENGLISH]=new DS::EnglishInput(this);
// _input[ET_PHONETIC]=new DS::EtPhoneticInput(this,std::string(getenv("QPEDIR"))+"/plugins/inputmethods/phonetic.tab" );
// _input[ET_CHANGJEI]=new DS::EtChangjeiInput(this,std::string(getenv("QPEDIR"))+"/plugins/inputmethods/changjei.tab");
//
// _change_input_method = new QPopupMenu(this);
 //_change_input_method->insertItem("english",ENGLISH);
 //_change_input_method->insertItem("et phonetic",ET_PHONETIC);
// _change_input_method->insertItem("english",this,SLOT(change_input_method(int)),0,ENGLISH);
// _change_input_method->insertItem("et phonetic",this,SLOT(change_input_method(int)),0,ET_PHONETIC);
// _change_input_method->insertItem("et changjei",this,SLOT(change_input_method(int)),0,ET_CHANGJEI);

 //connect(_change_input_method,SIGNAL(actiaved(int)),this,SLOT(change_input_method(int)));

 //QFont font("unifont",16,15,false);
// QFont font("mingliu",12,50,false);
// setFont(font);
// _input_status=ENGLISH;
 //_input_status=ET_PHONETIC;

 _cell_rows=5; //  QPEInputMethod widget 的 rows 有幾個 cell
 _cell_cols=15; // QPEInputMethod widget 的 col 有幾個 cell
 // QPEInputMethod key width 的基本單位
 _key_unit_width=(width() / _cell_cols) / 2 ; 
 //qDebug("_key_unit_width : %d",_key_unit_width);
 // QPEInputMethod key height 的基本單位
 _key_unit_height=fontMetrics().lineSpacing()+3; 


 _painter.begin(this);
 //_buffer_painter.begin(&_buffer);

 // 設定此 widget 的背景色
 const QColorGroup cg=colorGroup();
 QColor key_color= key_color=cg.dark();
 QColor key_bg=QColor(240,240,230);
 // qt3 使用
 //setEraseColor(key_bg);
 // qt2 使用
 setBackgroundColor(key_bg);
}
Beispiel #18
0
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
}
Beispiel #19
0
void IconViewItemExt::paintItem(QPainter* p,const QColorGroup& cg)
{
  if(isSelected())
  {
    p->setBrush(cg.highlight());
    p->drawRect(textRect(false));
    p->setPen(QPen(cg.highlightedText()));
    p->setBackgroundColor(cg.highlight());
    p->setBackgroundMode(Qt::OpaqueMode);
    p->drawText(textRect(false),Qt::AlignHCenter|Qt::WordBreak,text());
    p->setPen(QPen(cg.dark(),4));
    p->drawRect(pixmapRect(false));
    p->drawPixmap(pixmapRect(false).x(),pixmapRect(false).y(),*pixmap());
  }
  else
  {
    QIconViewItem::paintItem ( p,cg);
  }
}
Beispiel #20
0
KDEFX_EXPORT void kDrawBeButton(QPainter *p, int x, int y, int w, int h,
                   const QColorGroup &g, bool sunken, const QBrush *fill)
{
    QPen oldPen = p->pen();
    int x2 = x+w-1;
    int y2 = y+h-1;
    p->setPen(g.dark());
    p->drawLine(x+1, y, x2-1, y);
    p->drawLine(x, y+1, x, y2-1);
    p->drawLine(x+1, y2, x2-1, y2);
    p->drawLine(x2, y+1, x2, y2-1);


    if(!sunken){
        p->setPen(g.light());
        p->drawLine(x+2, y+2, x2-1, y+2);
        p->drawLine(x+2, y+3, x2-2, y+3);
        p->drawLine(x+2, y+4, x+2, y2-1);
        p->drawLine(x+3, y+4, x+3, y2-2);
    }
    else{
        p->setPen(g.mid());
        p->drawLine(x+2, y+2, x2-1, y+2);
        p->drawLine(x+2, y+3, x2-2, y+3);
        p->drawLine(x+2, y+4, x+2, y2-1);
        p->drawLine(x+3, y+4, x+3, y2-2);
    }


    p->setPen(sunken? g.light() : g.mid());
    p->drawLine(x2-1, y+2, x2-1, y2-1);
    p->drawLine(x+2, y2-1, x2-1, y2-1);

    p->setPen(g.mid());
    p->drawLine(x+1, y+1, x2-1, y+1);
    p->drawLine(x+1, y+2, x+1, y2-1);
    p->drawLine(x2-2, y+3, x2-2, y2-2);

    if(fill)
        p->fillRect(x+4, y+4, w-6, h-6, *fill);
    
    p->setPen(oldPen);
}
Beispiel #21
0
KDEFX_EXPORT void kColorBitmaps(QPainter *p, const QColorGroup &g, int x, int y,
                   QBitmap *lightColor, QBitmap *midColor,
                   QBitmap *midlightColor, QBitmap *darkColor,
                   QBitmap *blackColor, QBitmap *whiteColor)
{
    QBitmap *bitmaps[]={lightColor, midColor, midlightColor, darkColor,
        blackColor, whiteColor};

    QColor colors[]={g.light(), g.mid(), g.midlight(), g.dark(),
        Qt::black, Qt::white};

    int i;
    for(i=0; i < 6; ++i){
        if(bitmaps[i]){
            if(!bitmaps[i]->mask())
                bitmaps[i]->setMask(*bitmaps[i]);
            p->setPen(colors[i]);
            p->drawPixmap(x, y, *bitmaps[i]);
        }
    }
}
Beispiel #22
0
void QtCalculator::set_colors(){


  QPalette mypalette = (calc_display->palette()).copy();

  QColorGroup cgrp = mypalette.active();
  QColorGroup ncgrp(kcalcdefaults.forecolor,
                    cgrp.background(),
                    cgrp.light(),
                    cgrp.dark(),
                    cgrp.mid(),
                    kcalcdefaults.forecolor,
                    kcalcdefaults.backcolor);

  mypalette.setActive(ncgrp);
  mypalette.setDisabled(ncgrp);
  mypalette.setActive(ncgrp);

  calc_display->setPalette(mypalette);
  calc_display->setBackgroundColor(kcalcdefaults.backcolor);

}
Beispiel #23
0
// 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;
}
Beispiel #24
0
KDEFX_EXPORT void kColorBitmaps(QPainter *p, const QColorGroup &g, int x, int y, int w,
                   int h, bool isXBitmaps, const uchar *lightColor,
                   const uchar *midColor, const uchar *midlightColor,
                   const uchar *darkColor, const uchar *blackColor,
                   const uchar *whiteColor)
{
    const uchar *data[]={lightColor, midColor, midlightColor, darkColor,
        blackColor, whiteColor};

    QColor colors[]={g.light(), g.mid(), g.midlight(), g.dark(),
        Qt::black, Qt::white};

    int i;
    QBitmap b;
    for(i=0; i < 6; ++i){
        if(data[i]){
            b = QBitmap(w, h, data[i], isXBitmaps);
            b.setMask(b);
            p->setPen(colors[i]);
            p->drawPixmap(x, y, b);
        }
    }
}
Beispiel #25
0
void WorkspaceItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
{
    QColorGroup g( cg );
    g.setColor( QColorGroup::Base, backgroundColor() );
    g.setColor( QColorGroup::Foreground, Qt::black );

    if ( type() == FormSourceType &&
	 ( !formFile->hasFormCode() || ( formFile->codeFileState() == FormFile::Deleted && formFile->formWindow() ) ) &&
	 parent() && parent()->parent() && ( (WorkspaceItem*)parent()->parent() )->project &&
	 ( (WorkspaceItem*)parent()->parent() )->project->isCpp() ) {
	g.setColor( QColorGroup::Text, listView()->palette().disabled().color( QColorGroup::Text) );
	g.setColor( QColorGroup::HighlightedText, listView()->palette().disabled().color( QColorGroup::Text) );
    } else {
	g.setColor( QColorGroup::Text, Qt::black );
    }
    p->save();

    if ( isModified() ) {
	QFont f = p->font();
	f.setBold( TRUE );
	p->setFont( f );
    }

    QListViewItem::paintCell( p, g, column, width, align );
    p->setPen( QPen( cg.dark(), 1 ) );
    if ( column == 0 )
	p->drawLine( 0, 0, 0, height() - 1 );
    if ( listView()->firstChild() != this ) {
	if ( nextSibling() != itemBelow() && itemBelow()->depth() < depth() ) {
	    int d = depth() - itemBelow()->depth();
	    p->drawLine( -listView()->treeStepSize() * d, height() - 1, 0, height() - 1 );
	}
    }
    p->drawLine( 0, height() - 1, width, height() - 1 );
    p->drawLine( width - 1, 0, width - 1, height() );
    p->restore();
}
Beispiel #26
0
void qDrawShadePanel( QPainter *p, int x, int y, int w, int h,
		      const QColorGroup &g, bool sunken,
		      int lineWidth, const QBrush *fill )
{
    if ( w == 0 || h == 0 )
	return;
    if ( !( w > 0 && h > 0 && lineWidth >= 0 ) ) {
#if defined(QT_CHECK_RANGE)
    	qWarning( "qDrawShadePanel() Invalid parameters." );
#endif
    }
    QColor shade = g.dark();
    QColor light = g.light();
    if ( fill ) {
	if ( fill->color() == shade )
	    shade = g.shadow();
	if ( fill->color() == light )
	    light = g.midlight();
    }
    QPen oldPen = p->pen();			// save pen
    QPointArray a( 4*lineWidth );
    if ( sunken )
	p->setPen( shade );
    else
	p->setPen( light );
    int x1, y1, x2, y2;
    int i;
    int n = 0;
    x1 = x;
    y1 = y2 = y;
    x2 = x+w-2;
    for ( i=0; i<lineWidth; i++ ) {		// top shadow
	a.setPoint( n++, x1, y1++ );
	a.setPoint( n++, x2--, y2++ );
    }
    x2 = x1;
    y1 = y+h-2;
    for ( i=0; i<lineWidth; i++ ) {		// left shadow
	a.setPoint( n++, x1++, y1 );
	a.setPoint( n++, x2++, y2-- );
    }
    p->drawLineSegments( a );
    n = 0;
    if ( sunken )
	p->setPen( light );
    else
	p->setPen( shade );
    x1 = x;
    y1 = y2 = y+h-1;
    x2 = x+w-1;
    for ( i=0; i<lineWidth; i++ ) {		// bottom shadow
	a.setPoint( n++, x1++, y1-- );
	a.setPoint( n++, x2, y2-- );
    }
    x1 = x2;
    y1 = y;
    y2 = y+h-lineWidth-1;
    for ( i=0; i<lineWidth; i++ ) {		// right shadow
	a.setPoint( n++, x1--, y1++ );
	a.setPoint( n++, x2--, y2 );
    }
    p->drawLineSegments( a );
    if ( fill ) {				// fill with fill color
	QBrush oldBrush = p->brush();
	p->setPen( Qt::NoPen );
	p->setBrush( *fill );
	p->drawRect( x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2 );
	p->setBrush( oldBrush );
    }
    p->setPen( oldPen );			// restore pen
}
Beispiel #27
0
// Quartz Paint magic goes here.
void QuartzClient::paintEvent(QPaintEvent *)
{
    // Never paint if the pixmaps have not been created
    if(!quartz_initialized)
        return;

    const bool maxFull = (maximizeMode() == MaximizeFull) && !options()->moveResizeMaximizedWindows();

    QColorGroup g;
    QPainter p(widget());

    // Obtain widget bounds.
    QRect r(widget()->rect());
    int x = r.x();
    int y = r.y();
    int x2 = r.width() - 1;
    int y2 = r.height() - 1;
    int w = r.width();
    int h = r.height();

    // Draw part of the frame that is the title color

    if(coloredFrame)
        g = options()->colorGroup(ColorTitleBar, isActive());
    else
        g = options()->colorGroup(ColorFrame, isActive());

    // Draw outer highlights and lowlights
    p.setPen(g.light().light(120));
    p.drawLine(x, y, x2 - 1, y);
    p.drawLine(x, y + 1, x, y2 - 1);
    p.setPen(g.dark().light(120));
    p.drawLine(x2, y, x2, y2);
    p.drawLine(x, y2, x2, y2);

    // Fill out the border edges
    QColor frameColor;
    if(coloredFrame)
        frameColor = g.background().light(130);
    else
        frameColor = g.background();
    if(borderSize > 2)
    {
        p.fillRect(x + 1, y + 1, w - 2, borderSize - 2, frameColor); // top
        if(!maxFull)
        {
            p.fillRect(x + 1, y + h - (borderSize - 1), w - 2, borderSize - 2, frameColor);                             // bottom
            p.fillRect(x + 1, y + borderSize - 1, borderSize - 1, h - 2 * (borderSize - 1), frameColor);                // left
            p.fillRect(x + w - (borderSize), y + borderSize - 1, borderSize - 1, h - 2 * (borderSize - 1), frameColor); // right
        }
    }

    // Draw a frame around the wrapped widget.
    p.setPen(g.background());
    if(maxFull)
    {
        p.drawLine(x + 1, y + titleHeight + (borderSize - 1), w - 2, y + titleHeight + (borderSize - 1));
    }
    else
    {
        p.drawRect(x + (borderSize - 1), y + titleHeight + (borderSize - 1), w - 2 * (borderSize - 1), h - titleHeight - 2 * (borderSize - 1));
    }

    // Drawing this extra line removes non-drawn areas when shaded
    p.drawLine(x + borderSize, y2 - borderSize, x2 - borderSize, y2 - borderSize);

    // Highlight top corner
    p.setPen(g.light().light(160));
    p.drawPoint(x, y);
    p.setPen(g.light().light(140));
    p.drawPoint(x + 1, y);
    p.drawPoint(x, y + 1);

    // Draw the title bar.
    // ===================
    int r_x, r_y, r_x2, r_y2;
    widget()->rect().coords(&r_x, &r_y, &r_x2, &r_y2);
    const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
    const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop);
    const int titleEdgeRight = layoutMetric(LM_TitleEdgeRight);
    const int titleEdgeBottom = layoutMetric(LM_TitleEdgeBottom);
    const int ttlHeight = layoutMetric(LM_TitleHeight);
    const int titleEdgeBottomBottom = r_y + titleEdgeTop + ttlHeight + titleEdgeBottom - 1;
    r = QRect(r_x + titleEdgeLeft + buttonsLeftWidth(), r_y + titleEdgeTop,
              r_x2 - titleEdgeRight - buttonsRightWidth() - (r_x + titleEdgeLeft + buttonsLeftWidth()), titleEdgeBottomBottom - (r_y + titleEdgeTop));

    // Obtain titlebar blend colours
    QColor c1 = options()->color(ColorTitleBar, isActive()).light(130);
    QColor c2 = options()->color(ColorTitleBlend, isActive());

    // Create a disposable pixmap buffer for the titlebar
    KPixmap *titleBuffer = new KPixmap;
    titleBuffer->resize(maxFull ? w - 2 : (w - 2 * (borderSize - 1)), titleHeight);

    QPainter p2(titleBuffer, this);

    // subtract titleBlocks pixmap width and some
    int rightoffset = r.x() + r.width() - titleBlocks->width() - borderSize;

    p2.fillRect(0, 0, w, r.height(), c1);
    p2.fillRect(rightoffset, 0, maxFull ? w - rightoffset : w - rightoffset - 2 * (borderSize - 1), r.height(), c2);

    // 8 bit displays will be a bit dithered, but they still look ok.
    if(isActive())
        p2.drawPixmap(rightoffset, 0, *titleBlocks);
    else
        p2.drawPixmap(rightoffset, 0, *ititleBlocks);

    // Draw the title text on the pixmap, and with a smaller font
    // for toolwindows than the default.
    QFont fnt;
    if(largeButtons)
    {
        fnt = options()->font(true, false); // font not small
    }
    else
    {
        fnt = options()->font(true, true); // font small
        fnt.setWeight(QFont::Normal);      // and disable bold
    }
    p2.setFont(fnt);

    p2.setPen(options()->color(ColorFont, isActive()));
    p2.drawText(r.x() + 4 - borderSize, 0, r.width() - 3, r.height(), AlignLeft | AlignVCenter, caption());
    p2.end();

    p.drawPixmap(maxFull ? 1 : borderSize - 1, borderSize - 1, *titleBuffer);

    delete titleBuffer;
}
/*! \reimp */
void QCompactStyle::drawControl( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r,
		  const QColorGroup &g, SFlags flags, const QStyleOption& opt )
{
    switch ( element ) {
    case CE_PopupMenuItem:
	{
	    if (! widget || opt.isDefault())
		break;

	    const QPopupMenu *popupmenu = (const QPopupMenu *) widget;
	    QMenuItem *mi = opt.menuItem();
	    if ( !mi )
		break;

	    int tab = opt.tabWidth();
	    int maxpmw = opt.maxIconWidth();
	    bool dis = !(flags & Style_Enabled);
	    bool checkable = popupmenu->isCheckable();
	    bool act = flags & Style_Active;
	    int x, y, w, h;
	    r.rect( &x, &y, &w, &h );

	    QColorGroup itemg = g;

	    if ( checkable )
		maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks

	    int checkcol	  =     maxpmw;

	    if ( mi && mi->isSeparator() ) {			// draw separator
		p->setPen( g.dark() );
		p->drawLine( x, y, x+w, y );
		p->setPen( g.light() );
		p->drawLine( x, y+1, x+w, y+1 );
		return;
	    }

	    QBrush fill = act? g.brush( QColorGroup::Highlight ) :
				    g.brush( QColorGroup::Button );
	    p->fillRect( x, y, w, h, fill);

	    if ( !mi )
		return;

	    if ( mi->isChecked() ) {
		if ( act && !dis ) {
		    qDrawShadePanel( p, x, y, checkcol, h,
				     g, TRUE, 1, &g.brush( QColorGroup::Button ) );
		} else {
		    qDrawShadePanel( p, x, y, checkcol, h,
				     g, TRUE, 1, &g.brush( QColorGroup::Midlight ) );
		}
	    } else if ( !act ) {
		p->fillRect(x, y, checkcol , h,
			    g.brush( QColorGroup::Button ));
	    }

	    if ( mi->iconSet() ) {		// draw iconset
		QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
		if (act && !dis )
		    mode = QIconSet::Active;
		QPixmap pixmap;
		if ( checkable && mi->isChecked() )
		    pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode, QIconSet::On );
		else
		    pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
		int pixw = pixmap.width();
		int pixh = pixmap.height();
		if ( act && !dis ) {
		    if ( !mi->isChecked() )
			qDrawShadePanel( p, x, y, checkcol, h, g, FALSE,  1, &g.brush( QColorGroup::Button ) );
		}
		QRect cr( x, y, checkcol, h );
		QRect pmr( 0, 0, pixw, pixh );
		pmr.moveCenter( cr.center() );
		p->setPen( itemg.text() );
		p->drawPixmap( pmr.topLeft(), pixmap );

		QBrush fill = act? g.brush( QColorGroup::Highlight ) :
				      g.brush( QColorGroup::Button );
		p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill);
	    } else  if ( checkable ) {	// just "checking"...
		int mw = checkcol + motifItemFrame;
		int mh = h - 2*motifItemFrame;
		if ( mi->isChecked() ) {

		    SFlags cflags = Style_Default;
		    if (! dis)
			cflags |= Style_Enabled;
		    if (act)
			cflags |= Style_On;

		    drawPrimitive( PE_CheckMark, p, QRect(x + motifItemFrame + 2, y + motifItemFrame,
				    mw, mh), itemg, cflags, opt );
		}
	    }

	    p->setPen( act ? g.highlightedText() : g.buttonText() );

	    QColor discol;
	    if ( dis ) {
		discol = itemg.text();
		p->setPen( discol );
	    }

	    int xm = motifItemFrame + checkcol + motifItemHMargin;

	    if ( mi->custom() ) {
		int m = motifItemVMargin;
		p->save();
		if ( dis && !act ) {
		    p->setPen( g.light() );
		    mi->custom()->paint( p, itemg, act, !dis,
					 x+xm+1, y+m+1, w-xm-tab+1, h-2*m );
		    p->setPen( discol );
		}
		mi->custom()->paint( p, itemg, act, !dis,
				     x+xm, y+m, w-xm-tab+1, h-2*m );
		p->restore();
	    }
	    QString s = mi->text();
	    if ( !s.isNull() ) {			// draw text
		int t = s.find( '\t' );
		int m = motifItemVMargin;
		const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
		if ( t >= 0 ) {				// draw tab text
		    if ( dis && !act ) {
			p->setPen( g.light() );
			p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1,
				     y+m+1, tab, h-2*m, text_flags, s.mid( t+1 ));
			p->setPen( discol );
		    }
		    p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame,
				 y+m, tab, h-2*m, text_flags, s.mid( t+1 ) );
		    s = s.left( t );
		}
		if ( dis && !act ) {
		    p->setPen( g.light() );
		    p->drawText( x+xm+1, y+m+1, w-xm+1, h-2*m, text_flags, s, t );
		    p->setPen( discol );
		}
		p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t );
	    } else if ( mi->pixmap() ) {			// draw pixmap
		QPixmap *pixmap = mi->pixmap();
		if ( pixmap->depth() == 1 )
		    p->setBackgroundMode( OpaqueMode );
		p->drawPixmap( x+xm, y+motifItemFrame, *pixmap );
		if ( pixmap->depth() == 1 )
		    p->setBackgroundMode( TransparentMode );
	    }
	    if ( mi->popup() ) {			// draw sub menu arrow
		int dim = (h-2*motifItemFrame) / 2;
		if ( act ) {
		    if ( !dis )
			discol = white;
		    QColorGroup g2( discol, g.highlight(),
				    white, white,
				    dis ? discol : white,
				    discol, white );
		    drawPrimitive(PE_ArrowRight, p, QRect(x+w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, dim, dim),
				  g2, Style_Enabled);
		} else {
		    drawPrimitive(PE_ArrowRight, p, QRect(x+w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, dim, dim),
				  g, !dis ? Style_Enabled : Style_Default);
		}
	    }
	}
	break;

    default:
	QWindowsStyle::drawControl( element, p, widget, r, g, flags, opt );
	break;
    }
}
Beispiel #29
0
// motif arrows look the same whether they are used or not
// is this correct?
static void qDrawMotifArrow( QPainter *p, Qt::ArrowType type, bool down,
			     int x, int y, int w, int h,
			     const QColorGroup &g, bool )
{
    QPointArray bFill;				// fill polygon
    QPointArray bTop;				// top shadow.
    QPointArray bBot;				// bottom shadow.
    QPointArray bLeft;				// left shadow.
#ifndef QT_NO_TRANSFORMATIONS
    QWMatrix	matrix;				// xform matrix
#endif
    bool vertical = type == Qt::UpArrow || type == Qt::DownArrow;
    bool horizontal = !vertical;
    int	 dim = w < h ? w : h;
    int	 colspec = 0x0000;			// color specification array

    if ( dim < 2 )				// too small arrow
	return;

    if ( dim > 3 ) {
	if ( dim > 6 )
	    bFill.resize( dim & 1 ? 3 : 4 );
	bTop.resize( (dim/2)*2 );
	bBot.resize( dim & 1 ? dim + 1 : dim );
	bLeft.resize( dim > 4 ? 4 : 2 );
	bLeft.putPoints( 0, 2, 0,0, 0,dim-1 );
	if ( dim > 4 )
	    bLeft.putPoints( 2, 2, 1,2, 1,dim-3 );
	bTop.putPoints( 0, 4, 1,0, 1,1, 2,1, 3,1 );
	bBot.putPoints( 0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2 );

	for( int i=0; i<dim/2-2 ; i++ ) {
	    bTop.putPoints( i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i );
	    bBot.putPoints( i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i );
	}
	if ( dim & 1 )				// odd number size: extra line
	    bBot.putPoints( dim-1, 2, dim-3,dim/2, dim-1,dim/2 );
	if ( dim > 6 ) {			// dim>6: must fill interior
	    bFill.putPoints( 0, 2, 1,dim-3, 1,2 );
	    if ( dim & 1 )			// if size is an odd number
		bFill.setPoint( 2, dim - 3, dim / 2 );
	    else
		bFill.putPoints( 2, 2, dim-4,dim/2-1, dim-4,dim/2 );
	}
    }
    else {
	if ( dim == 3 ) {			// 3x3 arrow pattern
	    bLeft.setPoints( 4, 0,0, 0,2, 1,1, 1,1 );
	    bTop .setPoints( 2, 1,0, 1,0 );
	    bBot .setPoints( 2, 1,2, 2,1 );
	}
	else {					// 2x2 arrow pattern
	    bLeft.setPoints( 2, 0,0, 0,1 );
	    bTop .setPoints( 2, 1,0, 1,0 );
	    bBot .setPoints( 2, 1,1, 1,1 );
	}
    }

    if ( type == Qt::UpArrow || type == Qt::LeftArrow ) {
#ifndef QT_NO_TRANSFORMATIONS	// #### fix me!
	matrix.translate( x, y );
	if ( vertical ) {
	    matrix.translate( 0, h - 1 );
	    matrix.rotate( -90 );
	} else {
	    matrix.translate( w - 1, h - 1 );
	    matrix.rotate( 180 );
	}
#endif
	if ( down )
	    colspec = horizontal ? 0x2334 : 0x2343;
	else
	    colspec = horizontal ? 0x1443 : 0x1434;
    }
    else if ( type == Qt::DownArrow || type == Qt::RightArrow ) {
#ifndef QT_NO_TRANSFORMATIONS	// #### fix me!
	matrix.translate( x, y );
	if ( vertical ) {
	    matrix.translate( w-1, 0 );
	    matrix.rotate( 90 );
	}
#endif
	if ( down )
	    colspec = horizontal ? 0x2443 : 0x2434;
	else
	    colspec = horizontal ? 0x1334 : 0x1343;
    }

    QColor *cols[5];
    cols[0] = 0;
    cols[1] = (QColor *)&g.button();
    cols[2] = (QColor *)&g.mid();
    cols[3] = (QColor *)&g.light();
    cols[4] = (QColor *)&g.dark();
#define CMID	*cols[ (colspec>>12) & 0xf ]
#define CLEFT	*cols[ (colspec>>8) & 0xf ]
#define CTOP	*cols[ (colspec>>4) & 0xf ]
#define CBOT	*cols[ colspec & 0xf ]

    QPen     savePen   = p->pen();		// save current pen
    QBrush   saveBrush = p->brush();		// save current brush
#ifndef QT_NO_TRANSFORMATIONS
    QWMatrix wxm = p->worldMatrix();
#endif
    QPen     pen( Qt::NoPen );
    const QBrush &brush = g.brush( QColorGroup::Button );

    p->setPen( pen );
    p->setBrush( brush );
#ifndef QT_NO_TRANSFORMATIONS
    p->setWorldMatrix( matrix, TRUE );		// set transformation matrix
#endif
    p->drawPolygon( bFill );			// fill arrow
    p->setBrush( Qt::NoBrush );			// don't fill

    p->setPen( CLEFT );
    p->drawLineSegments( bLeft );
    p->setPen( CTOP );
    p->drawLineSegments( bTop );
    p->setPen( CBOT );
    p->drawLineSegments( bBot );

#ifndef QT_NO_TRANSFORMATIONS
    p->setWorldMatrix( wxm );
#endif
    p->setBrush( saveBrush );			// restore brush
    p->setPen( savePen );			// restore pen

#undef CMID
#undef CLEFT
#undef CTOP
#undef CBOT
}
Beispiel #30
0
void qDrawShadeLine( QPainter *p, int x1, int y1, int x2, int y2,
		     const QColorGroup &g, bool sunken,
		     int lineWidth, int midLineWidth )
{
    if (!( p && lineWidth >= 0 && midLineWidth >= 0 ) )	{
#if defined(QT_CHECK_RANGE)
	qWarning( "qDrawShadeLine invalid parameters." );
#endif
	return;
    }
    int tlw = lineWidth*2 + midLineWidth;	// total line width
    QPen oldPen = p->pen();			// save pen
    if ( sunken )
	p->setPen( g.dark() );
    else
	p->setPen( g.light() );
    QPointArray a;
    int i;
    if ( y1 == y2 ) {				// horizontal line
	int y = y1 - tlw/2;
	if ( x1 > x2 ) {			// swap x1 and x2
	    int t = x1;
	    x1 = x2;
	    x2 = t;
	}
	x2--;
	for ( i=0; i<lineWidth; i++ ) {		// draw top shadow
	    a.setPoints( 3, x1+i, y+tlw-1-i,
			 x1+i, y+i,
			 x2-i, y+i );
	    p->drawPolyline( a );
	}
	if ( midLineWidth > 0 ) {
	    p->setPen( g.mid() );
	    for ( i=0; i<midLineWidth; i++ )	// draw lines in the middle
		p->drawLine( x1+lineWidth, y+lineWidth+i,
			     x2-lineWidth, y+lineWidth+i );
	}
	if ( sunken )
	    p->setPen( g.light() );
	else
	    p->setPen( g.dark() );
	for ( i=0; i<lineWidth; i++ ) {		// draw bottom shadow
	    a.setPoints( 3, x1+i, y+tlw-i-1,
			 x2-i, y+tlw-i-1,
			 x2-i, y+i+1 );
	    p->drawPolyline( a );
	}
    }
    else if ( x1 == x2 ) {			// vertical line
	int x = x1 - tlw/2;
	if ( y1 > y2 ) {			// swap y1 and y2
	    int t = y1;
	    y1 = y2;
	    y2 = t;
	}
	y2--;
	for ( i=0; i<lineWidth; i++ ) {		// draw left shadow
	    a.setPoints( 3, x+i, y2,
			 x+i, y1+i,
			 x+tlw-1, y1+i );
	    p->drawPolyline( a );
	}
	if ( midLineWidth > 0 ) {
	    p->setPen( g.mid() );
	    for ( i=0; i<midLineWidth; i++ )	// draw lines in the middle
		p->drawLine( x+lineWidth+i, y1+lineWidth, x+lineWidth+i, y2 );
	}
	if ( sunken )
	    p->setPen( g.light() );
	else
	    p->setPen( g.dark() );
	for ( i=0; i<lineWidth; i++ ) {		// draw right shadow
	    a.setPoints( 3, x+lineWidth, y2-i,
			 x+tlw-i-1, y2-i,
			 x+tlw-i-1, y1+lineWidth );
	    p->drawPolyline( a );
	}
    }
    p->setPen( oldPen );
}