26 #ifndef __TERRALIB_QT_WIDGETS_UTILS_INTERNAL_COLORPICKERTOOLBUTTON_H    27 #define __TERRALIB_QT_WIDGETS_UTILS_INTERNAL_COLORPICKERTOOLBUTTON_H    30 #include "../Config.h"    33 #include <QApplication>    35 #include <QColorDialog>    37 #include <QGridLayout>    39 #include <QMouseEvent>    42 #include <QToolButton>    89             setWindowFlags(Qt::Popup);
    90             setFrameShape(QFrame::StyledPanel);
    91             setFrameShadow(QFrame::Plain);
    92             setStyleSheet(
"QFrame{background-color: rgb(255, 255, 255);border-color: rgb(0, 0, 0);}");
    96             for(
int g = 0; g < 4; ++g)
    97               for(
int r = 0;  r < 4; ++r)
    98                 for(
int b = 0; b < 3; ++b)
    99                   m_stdrgb[i++] = qRgb(r * 255 / 3, g * 255 / 3, b * 255 / 2);
   102             int height = 48 / 
COLS;
   106             resize(width, height);
   108             setMouseTracking(
true);
   111           void paintButton(QPainter* painter, 
const QRectF& rc, 
const QString& text, 
bool hover)
   113             !hover ? painter->setBrush(Qt::lightGray) : painter->setBrush(Qt::gray);
   114             painter->drawRect(rc);
   115             painter->setPen(Qt::black);
   116             painter->drawText(rc, text, Qt::AlignHCenter | Qt::AlignVCenter);
   121             QPainter painter(
this);
   123             painter.drawRect(0, 0, width() - 1, height() - 1);
   124             painter.drawText(QRect(10, 1, this->width(), 19), tr(
"Basic Colors"), Qt::AlignLeft | Qt::AlignVCenter);
   128             painter.setPen(Qt::darkGray);
   129             for(
int i = 0; i < 48; ++i)
   133               col = (int)(i / 
ROWS);
   143               painter.setBrush(color);
   144               painter.drawRect(rc);
   148             QPointF mousePos = mapFromGlobal(QCursor::pos());
   161                 rc.setTop(rc.top() - 2);
   162                 rc.setLeft(rc.left() - 2);
   163                 rc.setBottom(rc.bottom() + 2);
   164                 rc.setRight(rc.right() + 2);
   167                 painter.drawRect(rc);
   181             if(!rect().contains(e->pos()))
   194 #if (QT_VERSION >= 0x050000)   201               QColor color = QColorDialog::getColor(
m_currentColor, 
this, 
"", QColorDialog::ShowAlphaChannel);
   246           void setColor(
const QColor& color);
   248           QColor getColor() 
const;
   252           void resizeEvent(QResizeEvent* e);
   254           void mousePressEvent(QMouseEvent* e);
   260           void onPopupSelected(
const QColor& color);
   264           void colorChanged(
const QColor&);
   277 #endif // __TERRALIB_QT_WIDGETS_UTILS_INTERNAL_COLORPICKERTOOLBUTTON_H