64 QColor lightLightBlue( 152, 180, 226 );
65 QColor darkLightBlue(193, 210, 238);
66 QColor darkBlue(35, 75, 139);
67 QColor background = darkLightBlue;
72 QSize newSize = r.size().expandedTo(
buffer.size() );
77 QPainter bufferPainter(&
buffer);
78 bufferPainter.translate( -r.x(), -r.y() );
81 bufferPainter.setClipping(
false);
84 bool paintRect =
false;
86 if(isSelected()) { paintColor = darkBlue; paintRect =
true; }
87 else if(
mousedOver) { paintColor = lightLightBlue; paintRect =
true; }
96 r2.setLeft( r.left() + 4);
97 r2.setRight( r.right() - 4);
99 r2.setBottom( r.bottom() );
100 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.40 ) );
102 r2.setLeft( r2.left() + 1);
103 r2.setRight( r2.right() - 1);
104 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.67 ) );
107 r2.setLeft( r2.left() - 3);
108 r2.setRight( r2.right() + 3);
109 r2.setTop( r2.top() + 1 );
110 r2.setBottom( r2.bottom() - 1);
111 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.40 ) );
113 r2.setLeft( r2.left() + 1);
114 r2.setRight( r2.right() - 1);
115 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.67 ) );
118 r2.setLeft( r2.left() - 2);
119 r2.setRight( r2.right() + 2);
120 r2.setTop( r2.top() + 1 );
121 r2.setBottom( r2.bottom() - 1);
122 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.40) );
124 r2.setTop( r2.top() + 1);
125 r2.setBottom( r2.bottom() - 1);
126 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.67) );
129 r2.setLeft( r2.left() - 1 );
130 r2.setRight( r2.right() + 1 );
131 r2.setTop( r2.top() + 1);
132 r2.setBottom( r2.bottom() - 1);
133 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.40) );
135 r2.setTop( r2.top() + 1);
136 r2.setBottom( r2.bottom() - 1);
137 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.67) );
141 r2.setLeft( r.left() + 1);
142 r2.setRight( r.right() - 1);
143 r2.setTop( r.top() + 4 );
144 r2.setBottom( r.bottom() - 4);
145 bufferPainter.fillRect( r2, paintColor );
147 r2.setLeft( r2.left() + 1);
148 r2.setRight( r2.right() - 1);
149 r2.setTop( r2.top() - 2 );
150 r2.setBottom( r2.bottom() + 2 );
151 bufferPainter.fillRect( r2, paintColor );
153 r2.setLeft( r2.left() + 2);
154 r2.setRight( r2.right() - 2);
155 r2.setTop( r2.top() - 1 );
156 r2.setBottom( r2.bottom() + 1 );
157 bufferPainter.fillRect( r2, paintColor );
161 bufferPainter.drawPixmap( x()+4 , y() + 4, *pixmap());
164 int align = Qt::AlignLeft | Qt::AlignTop | Qt::TextWrapAnywhere;
166 bufferPainter.setPen( Qt::white );
168 bufferPainter.setPen( Qt::black );
169 bufferPainter.drawText( x() + 4 + pixmapRect().
width(),
175 p->drawPixmap( x(), y(),
buffer );
265 QImage icon(imageName);
273 QFontMetrics fm( qApp->font() );
276 int idealImageHeight = fm.leading() + 2*fm.height();
279 int idealImageWidth = (4 * idealImageHeight ) / 3;
282 int actualImageWidth = 0;
283 int actualImageHeight = 0;
285 idealImageWidth, idealImageHeight,
286 actualImageWidth, actualImageHeight );
289 if(actualImageHeight == idealImageHeight - 1)
291 actualImageHeight = idealImageHeight;
294 QImage scaledIcon= icon.smoothScale( actualImageWidth, actualImageHeight );
295 QImage* paddedScaledIcon =
new QImage(idealImageWidth, idealImageHeight, scaledIcon.depth());
296 paddedScaledIcon->setAlphaBuffer(
true);
300 for(x=0; x< idealImageWidth; x++)
302 for(y=0; y<idealImageHeight; y++)
304 paddedScaledIcon->setPixel(x,y, qRgba(255, 255, 255,0) );
309 int xDiff = idealImageWidth - actualImageWidth;
310 int yDiff = idealImageHeight - actualImageHeight;
312 for(x= xDiff/2; x < (xDiff/2) + actualImageWidth; x++)
315 for(y= yDiff/2; y < (yDiff/2) + actualImageHeight; y++)
317 paddedScaledIcon->setPixel(x, y, scaledIcon.pixel(x2, y2));
326 paddedScaledIcon->setPixel(0, 0, qRgba(255, 0,0,0) );
327 paddedScaledIcon->setPixel(idealImageWidth-1, 0, qRgba(255, 0,0,0) );
328 paddedScaledIcon->setPixel(0, idealImageHeight-1, qRgba(255, 0,0,0) );
329 paddedScaledIcon->setPixel(idealImageWidth-1, idealImageHeight-1, qRgba(255, 0,0,0) );
332 QPixmap* padddedScaledPix =
new QPixmap( paddedScaledIcon->width(), paddedScaledIcon->height() );
333 padddedScaledPix->convertFromImage( *paddedScaledIcon );
334 delete paddedScaledIcon;
335 return padddedScaledPix;