CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Public Types | Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Properties | List of all members
ctkColorPickerButton Class Reference

#include <Libs/Widgets/ctkColorPickerButton.h>

Inheritance diagram for ctkColorPickerButton:
Inheritance graph
[legend]
Collaboration diagram for ctkColorPickerButton:
Collaboration graph
[legend]

Public Types

enum  ColorDialogOption { ShowAlphaChannel = 0x00000001 , NoButtons = 0x00000002 , DontUseNativeDialog = 0x00000004 , UseCTKColorDialog = 0x0000000C }
 

Public Slots

void changeColor ()
 
void setColor (const QColor &color)
 Set a new current color without opening a dialog. More...
 
void setDisplayColorName (bool displayColorName)
 

Signals

void colorChanged (QColor)
 
void colorNameChanged (QString)
 This signaled is fired anytime a new color name is set. More...
 

Public Member Functions

QColor color () const
 Current selected color. More...
 
QString colorName () const
 
 ctkColorPickerButton (const QColor &color, const QString &text, QWidget *parent=0)
 
 ctkColorPickerButton (const QString &text, QWidget *parent=0)
 
 ctkColorPickerButton (QWidget *parent=0)
 By default, the color is black. More...
 
const ColorDialogOptions & dialogOptions () const
 
bool displayColorName () const
 Display the color name after color selection. More...
 
void setColorName (const QString &name)
 
void setDialogOptions (const ColorDialogOptions &options)
 
virtual QSize sizeHint () const
 
virtual ~ctkColorPickerButton ()
 

Protected Slots

void onToggled (bool change=true)
 

Protected Member Functions

virtual void paintEvent (QPaintEvent *event)
 

Protected Attributes

QScopedPointer< ctkColorPickerButtonPrivate > d_ptr
 

Properties

QColor color
 
QString colorName
 
ColorDialogOptions dialogOptions
 This property controls the properties of the dialog used in changeColor. More...
 
bool displayColorName
 

Detailed Description

ctkColorPickerButton is a QPushButton that refers to a color. The color and the name of the color (i.e. &#35;FFFFFF) are displayed on the button. When clicked, a color dialog pops up to select a new color for the QPushButton.

Definition at line 38 of file ctkColorPickerButton.h.

Member Enumeration Documentation

◆ ColorDialogOption

Enumerator
ShowAlphaChannel 
NoButtons 
DontUseNativeDialog 
UseCTKColorDialog 

Definition at line 60 of file ctkColorPickerButton.h.

Constructor & Destructor Documentation

◆ ctkColorPickerButton() [1/3]

ctkColorPickerButton::ctkColorPickerButton ( QWidget *  parent = 0)
explicit

By default, the color is black.

◆ ctkColorPickerButton() [2/3]

ctkColorPickerButton::ctkColorPickerButton ( const QString &  text,
QWidget *  parent = 0 
)
explicit

By default, the color is black. The text will be shown on the button if displayColorName is false, otherwise the color name is shown.

See also
QPushButton::setText

◆ ctkColorPickerButton() [3/3]

ctkColorPickerButton::ctkColorPickerButton ( const QColor &  color,
const QString &  text,
QWidget *  parent = 0 
)
explicit

The text will be shown on the button if displayColorName is false, otherwise the color name is shown.

See also
setColor, QPushButton::setText

◆ ~ctkColorPickerButton()

virtual ctkColorPickerButton::~ctkColorPickerButton ( )
virtual

Member Function Documentation

◆ changeColor

void ctkColorPickerButton::changeColor ( )
slot

Opens a color dialog to select a new current color. If the CTK color dialog (UseCTKColorDialog) is used, then the color name is also set if the user selects a named color.

See also
ctkColorDialog, color, colorName

◆ color()

QColor ctkColorPickerButton::color ( ) const

Current selected color.

◆ colorChanged

void ctkColorPickerButton::colorChanged ( QColor  )
signal

colorChanged is fired anytime a new color is set. Programatically or by the user when choosing a color from the color dialog

◆ colorName()

QString ctkColorPickerButton::colorName ( ) const

Current selected color name. Returns the name of the color in the format "#RRGGBB" or the string set by setColorName().

See also
color(), setColorName()

◆ colorNameChanged

void ctkColorPickerButton::colorNameChanged ( QString  )
signal

This signaled is fired anytime a new color name is set.

◆ dialogOptions()

const ColorDialogOptions& ctkColorPickerButton::dialogOptions ( ) const

◆ displayColorName()

bool ctkColorPickerButton::displayColorName ( ) const

Display the color name after color selection.

◆ onToggled

void ctkColorPickerButton::onToggled ( bool  change = true)
protectedslot

◆ paintEvent()

virtual void ctkColorPickerButton::paintEvent ( QPaintEvent *  event)
protectedvirtual

◆ setColor

void ctkColorPickerButton::setColor ( const QColor &  color)
slot

Set a new current color without opening a dialog.

◆ setColorName()

void ctkColorPickerButton::setColorName ( const QString &  name)

Set the current color name. This allows you to give name other than the default "#RRGGBB" Set an invalid QString to restore the default color names

◆ setDialogOptions()

void ctkColorPickerButton::setDialogOptions ( const ColorDialogOptions &  options)

Set the color dialog options to configure the color dialog.

See also
QColorDialog::setOptions QColorDialog::ColorDialogOption

◆ setDisplayColorName

void ctkColorPickerButton::setDisplayColorName ( bool  displayColorName)
slot

Toggle the display of the color name after color selection. By default, this is activated.

◆ sizeHint()

virtual QSize ctkColorPickerButton::sizeHint ( ) const
virtual

Reimplemented to return a toolbutton sizehint when no text is displayed in the button.

Member Data Documentation

◆ d_ptr

QScopedPointer<ctkColorPickerButtonPrivate> ctkColorPickerButton::d_ptr
protected

Definition at line 142 of file ctkColorPickerButton.h.

Property Documentation

◆ color

QColor ctkColorPickerButton::color
readwrite

This property controls the name of the color. Black (0,0,0) by default.

Definition at line 1 of file ctkColorPickerButton.h.

◆ colorName

QString ctkColorPickerButton::colorName
readwrite

This property controls the name of the color. If empty (default), the color in the format "#RRGGBB" is displayed in the button if displayColorName is true, otherwise, the color name is used.

Definition at line 1 of file ctkColorPickerButton.h.

◆ dialogOptions

ColorDialogOptions ctkColorPickerButton::dialogOptions
readwrite

This property controls the properties of the dialog used in changeColor.

Definition at line 1 of file ctkColorPickerButton.h.

◆ displayColorName

bool ctkColorPickerButton::displayColorName
readwrite

This properties controls whether the name of the color is shown on the button if true or the button text instead. True by default.

See also
colorName, QPushButton::text

Definition at line 1 of file ctkColorPickerButton.h.


The documentation for this class was generated from the following file: