The QtxColorButton class implements a widget for color preference items editing. More...
#include <QtxColorButton.h>

Signals | |
| void | clicked (QColor) |
| This signal is emitted when the widget button is clicked by the user. | |
| void | changed (QColor) |
| This signal is emitted when the current color is changed. | |
Public Member Functions | |
| QtxColorButton (QWidget *=0) | |
| Constructor. | |
| virtual | ~QtxColorButton () |
| Destructor. | |
| QColor | color () const |
| Get currently selected color. | |
| void | setColor (const QColor &) |
| Set color. | |
| bool | eventFilter (QObject *, QEvent *) |
| Filter events for the child widgets. | |
| bool | isAutoEnabled () const |
| Returns the status of "auto" color button in popup widget. | |
| void | setAutoEnabled (bool) |
| Enable/disable the "auto" color button in popup widget. | |
| QString | autoText () const |
| Returns text of the "auto" color button in popup widget. | |
| void | setAutoText (const QString &) |
| Sets text of the "auto" color button in popup widget. | |
Protected Member Functions | |
| virtual void | paintEvent (QPaintEvent *) |
| Customize paint event for the widget. | |
Private Types | |
| typedef QMap< const QToolButton *, QColor > | ColorMap |
Private Slots | |
| void | onClicked (bool) |
| Called when the button is clicked by the user. | |
| void | onToggled (bool) |
| Called when any color selection button from popup menu is clicked. | |
| void | onAboutToShow () |
| Called when the popup menu is about to show. | |
| void | onAutoClicked (bool) |
| Called the "Auto" child button from popup menu is clicked. | |
| void | onDialogClicked (bool) |
| Called the "Other colors" child button from popup menu is clicked. | |
Private Member Functions | |
| QList< QColor > | colorsList () const |
| Get predefined list of colors to be used in the popup menu. | |
| void | updateState () |
| Update widget state. | |
| void | updateButton (QToolButton *) |
| Update child button state. | |
| QPixmap | buttonIcon (const QColor &) const |
| Generate (if necessary) or get the icon for the button. | |
| void | drawColor (QPaintDevice *, const QColor &, const int=1) const |
| Draw pixmap. | |
Private Attributes | |
| ColorMap | myColors |
| QToolButton * | myAutoButton |
The color preference item is represented as the colored button with assocoiated popup menu whihc is called when the user presses the small arrow button near it. The popup menu allows selecting of the color from the predefined set. In addition it contains the button which invokes standard "Select color" dialog box.
Initial color value can be set with setColor() method. Chosen color can be retrieved with the color() method.
typedef QMap<const QToolButton*, QColor> QtxColorButton.ColorMap [private] |
| QtxColorButton::QtxColorButton | ( | QWidget * | parent = 0 | ) |
| parent | parent widget |
References test_table.c, clicked(), colorsList(), myAutoButton, myColors, onAboutToShow(), onAutoClicked(), onClicked(), onDialogClicked(), onToggled(), and updateButton().
| QtxColorButton::~QtxColorButton | ( | ) | [virtual] |
| QColor QtxColorButton::color | ( | ) | const |
Returns null QColor if no color is selected.
References myColors.
| void QtxColorButton::setColor | ( | const QColor & | c | ) |
| c | color to be set as current |
References myColors, updateButton(), and updateState().
| o | event receiver object |
| e | event |
true if the event should be filtered References updateButton().
| bool QtxColorButton::isAutoEnabled | ( | ) | const |
true if the "auto" button is enabled References myAutoButton.
| void QtxColorButton::setAutoEnabled | ( | bool | on | ) |
| on | enable/disable state |
References myAutoButton.
| QString QtxColorButton::autoText | ( | ) | const |
References myAutoButton.
| void QtxColorButton::setAutoText | ( | const QString & | txt | ) |
| txt | new button text |
References myAutoButton.
| void QtxColorButton::clicked | ( | QColor | color | ) | [signal] |
| color | current color |
| void QtxColorButton::changed | ( | QColor | color | ) | [signal] |
| color | new current color |
| void QtxColorButton::onClicked | ( | bool | ) | [private, slot] |
Emits the signal clicked( QColor ).
| on | button state (not used) |
| void QtxColorButton::onToggled | ( | bool | on | ) | [private, slot] |
Changes the currently selected color and emits the signal changed( QColor ).
| on | button state |
References changed(), color(), myColors, updateButton(), and updateState().
| void QtxColorButton::onAboutToShow | ( | ) | [private, slot] |
Updates the menu and child widgets state.
References updateState().
| void QtxColorButton::onAutoClicked | ( | bool | ) | [private, slot] |
| void QtxColorButton::onDialogClicked | ( | bool | ) | [private, slot] |
Invokes standard "Select color" dialog box allowing user to select custom color. If the current color is changed by the user, emits the signal changed( QColor ).
| on | (not used) |
References test_table.c, changed(), color(), and setColor().
| void QtxColorButton::paintEvent | ( | QPaintEvent * | e | ) | [protected, virtual] |
| e | paint event |
References color(), and drawColor().
| QList< QColor > QtxColorButton::colorsList | ( | ) | const [private] |
| void QtxColorButton::updateState | ( | ) | [private] |
References updateButton().
| void QtxColorButton::updateButton | ( | QToolButton * | btn | ) | [private] |
| btn | child button |
References buttonIcon(), test_table.c, color(), and myColors.
| QPixmap QtxColorButton::buttonIcon | ( | const QColor & | c | ) | const [private] |
| c | color to be used for the icon |
References drawColor().
| void QtxColorButton::drawColor | ( | QPaintDevice * | pd, |
| const QColor & | c, | ||
| const int | m = 1 |
||
| ) | const [private] |
| pd | paint device |
| c | color |
| m | margin |
ColorMap QtxColorButton.myColors [private] |
QToolButton* QtxColorButton.myAutoButton [private] |