26 #ifndef __TERRALIB_QT_WIDGETS_UTILS_INTERNAL_COLORPICKERTOOLBUTTON_H 
   27 #define __TERRALIB_QT_WIDGETS_UTILS_INTERNAL_COLORPICKERTOOLBUTTON_H 
   30 #include "../Config.h" 
   33 #include <QtGui/QApplication> 
   34 #include <QtGui/QColor> 
   35 #include <QtGui/QColorDialog> 
   36 #include <QtGui/QFrame> 
   37 #include <QtGui/QGridLayout> 
   38 #include <QtCore/QHash> 
   39 #include <QtGui/QMouseEvent> 
   40 #include <QtGui/QPainter> 
   41 #include <QtCore/QRectF> 
   42 #include <QtGui/QToolButton> 
   88             setWindowFlags(Qt::Popup);
 
   89             setFrameShape(QFrame::StyledPanel);
 
   90             setFrameShadow(QFrame::Plain);
 
   91             setStyleSheet(
"QFrame{background-color: rgb(255, 255, 255);border-color: rgb(0, 0, 0);}");
 
   95             for(
int g = 0; g < 4; ++g)
 
   96               for(
int r = 0;  r < 4; ++r)
 
   97                 for(
int b = 0; b < 3; ++b)
 
   98                   m_stdrgb[i++] = qRgb(r * 255 / 3, g * 255 / 3, b * 255 / 2);
 
  101             int height = 48 / 
COLS;
 
  105             resize(width, height);
 
  107             setMouseTracking(
true);
 
  110           void paintButton(QPainter* painter, 
const QRectF& rc, 
const QString& text, 
bool hover)
 
  112             !hover ? painter->setBrush(Qt::lightGray) : painter->setBrush(Qt::gray);
 
  113             painter->drawRect(rc);
 
  114             painter->setPen(Qt::black);
 
  115             painter->drawText(rc, text, Qt::AlignHCenter | Qt::AlignVCenter);
 
  120             QPainter painter(
this);
 
  122             painter.drawRect(0, 0, width() - 1, height() - 1);
 
  123             painter.drawText(QRect(10, 1, this->width(), 19), tr(
"Basic Colors"), Qt::AlignLeft | Qt::AlignVCenter);
 
  127             painter.setPen(Qt::darkGray);
 
  128             for(
int i = 0; i < 48; ++i)
 
  132               row = (int)(i / 
COLS);
 
  141               painter.setBrush(color);
 
  142               painter.drawRect(rc);
 
  146             QPointF mousePos = mapFromGlobal(QCursor::pos());
 
  159                 rc.setTop(rc.top() - 2);
 
  160                 rc.setLeft(rc.left() - 2);
 
  161                 rc.setBottom(rc.bottom() + 2);
 
  162                 rc.setRight(rc.right() + 2);
 
  165                 painter.drawRect(rc);
 
  179             if(!rect().contains(e->pos()))
 
  195               QColor color = QColorDialog::getColor(Qt::white, 
this, 
"", QColorDialog::ShowAlphaChannel);
 
  234           void setColor(
const QColor& color);
 
  236           QColor getColor() 
const;
 
  240           void resizeEvent(QResizeEvent* e);
 
  242           void mousePressEvent(QMouseEvent* e);
 
  248           void onPopupSelected(
const QColor& color);
 
  252           void colorChanged(
const QColor&);
 
  264 #endif // __TERRALIB_QT_WIDGETS_UTILS_INTERNAL_COLORPICKERTOOLBUTTON_H 
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module. 
 
Create a frame with a default color palette. 
 
void selected(const QColor &color)
 
void mouseMoveEvent(QMouseEvent *)
 
void paintButton(QPainter *painter, const QRectF &rc, const QString &text, bool hover)
 
ColorKeyInfo(const QColor &color, const QRectF &rect)
 
void mousePressEvent(QMouseEvent *e)
 
Associate a rect to a color. 
 
ColorPickerPopup(QWidget *parent=0)
 
void paintEvent(QPaintEvent *)
 
Custom tool button used to pick a color. 
 
QList< ColorKeyInfo > m_colorInfos
 
ColorPickerPopup * m_popup