Source Code (Use browser search to find items of interest.)
Class Index
kdelibs'KValueSelector (./kdelibs/kdeui/kcolordlg.h:79)
class KValueSelector : public KSelector
{
Q_OBJECT
public:
KValueSelector( QWidget *parent );
void setHue( int h ) { hue = h; }
void setSaturation( int s ) { sat = s; }
void drawPalette();
protected:
virtual void resizeEvent( QResizeEvent * );
virtual void drawContents( QPainter *painter );
protected:
int hue;
int sat;
QPixmap pixmap;
private:
class KValueSelectorPrivate;
KValueSelectorPrivate *d;
};
kdelibs'KValueSelector::KValueSelector() (./kdelibs/kdeui/kcolordlg.cpp:195)
KValueSelector::KValueSelector( QWidget *parent )
: KSelector( KSelector::Vertical, parent ), hue(0), sat(0)
{
setRange( 0, 255 );
pixmap.setOptimization( QPixmap::BestOptim );
}
kdelibs'KValueSelector::resizeEvent() (./kdelibs/kdeui/kcolordlg.cpp:202)
void KValueSelector::resizeEvent( QResizeEvent * )
{
drawPalette();
}
kdelibs'KValueSelector::drawContents() (./kdelibs/kdeui/kcolordlg.cpp:207)
void KValueSelector::drawContents( QPainter *painter )
{
painter->drawPixmap( contentsRect().x(), contentsRect().y(), pixmap );
}
kdelibs'KValueSelector::drawPalette() (./kdelibs/kdeui/kcolordlg.cpp:212)
void KValueSelector::drawPalette()
{
int xSize = contentsRect().width(), ySize = contentsRect().height();
QImage image( xSize, ySize, 32 );
QColor col;
uint *p;
QRgb rgb;
for ( int v = 0; v < ySize; v++ )
{
p = (uint *) image.scanLine( ySize - v - 1 );
col.setHsv( hue, sat, 255*v/(ySize-1) );
rgb = col.rgb();
for ( int i = 0; i < xSize; i++ )
*p++ = rgb;
}
if ( QColor::numBitPlanes() <= 8 )
{
createStandardPalette();
KImageEffect::dither( image, standardPalette, STANDARD_PAL_SIZE );
}
pixmap.convertFromImage( image );
}
//-----------------------------------------------------------------------------