Source Code (Use browser search to find items of interest.)

Class Index

kiconedit'KDrawColors (./kdegraphics/kiconedit/kiconcolors.h:31)

class KDrawColors : public KColorGrid
{
  Q_OBJECT
public:
  KDrawColors(QWidget *parent);

  //bool hasColor(uint);

signals:
  void newcolor(uint);

protected:
  virtual void paintCell( QPainter*, int, int );
  virtual void mouseReleaseEvent(QMouseEvent*);

  int selected;
};


kiconedit'KDrawColors::KDrawColors() (./kdegraphics/kiconedit/kiconcolors.cpp:23)

KDrawColors::KDrawColors(QWidget *parent) : KColorGrid(parent, 0, 3)
{
  debug("KDrawColors - constructor");
  setCellSize(17);
  setGrid(true);
  setGridState(KColorGrid::Shaded);
  selected = 0;
  debug("KDrawColors - constructor - done");
}


kiconedit'KDrawColors::paintCell() (./kdegraphics/kiconedit/kiconcolors.cpp:33)

void KDrawColors::paintCell( QPainter *painter, int row, int col )
{
  //KColorGrid::paintCell(painter, row, col);
  uint c = colorAt( row * numCols() + col );
  QBrush brush(c);
  int d = spacing();

  qDrawShadePanel( painter, d, d, cellSize()-d, cellSize()-d,
                colorGroup(), true, 1, &brush);
  if ( row * numCols() + col == selected)
     painter->drawWinFocusRect( d+1, d+1, cellSize()-(2*d)+1, cellSize()-(2*d)+1 );
}


kiconedit'KDrawColors::mouseReleaseEvent() (./kdegraphics/kiconedit/kiconcolors.cpp:46)

void KDrawColors::mouseReleaseEvent( QMouseEvent *e )
{
  int row = findRow( e->pos().y() );
  int col = findCol( e->pos().x() );
  int cell = row * numCols() + col;

  if ( selected != cell )
  {
    int prevSel = selected;
    selected = cell;
    updateCell( prevSel/numCols(), prevSel%numCols(), FALSE );
    updateCell( row, col, FALSE );
  }

  emit newcolor(colorAt(cell)|OPAQUE_MASK);
}