QGIS/python/gui/qgscolorbutton.sip

424 lines
13 KiB
Plaintext
Raw Normal View History

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgscolorbutton.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2016-08-04 13:49:59 +02:00
class QgsColorButton : QToolButton
{
%Docstring
A cross platform button subclass for selecting colors. Will open a color chooser dialog when clicked.
Offers live updates to button from color chooser dialog. An attached drop-down menu allows for copying
and pasting colors, picking colors from the screen, and selecting colors from color swatch grids.
.. versionadded:: 2.5
%End
%TypeHeaderCode
#include "qgscolorbutton.h"
%End
%ConvertToSubClassCode
if ( qobject_cast<QgsColorButton *>( sipCpp ) )
sipType = sipType_QgsColorButton;
else
sipType = NULL;
%End
public:
2016-08-04 13:49:59 +02:00
enum Behavior
2016-08-04 13:49:59 +02:00
{
ShowDialog,
SignalOnly
2016-08-04 13:49:59 +02:00
};
QgsColorButton( QWidget *parent /TransferThis/ = 0, const QString &cdt = "", QgsColorSchemeRegistry *registry = 0 );
%Docstring
Construct a new color ramp button.
Use ``parent`` to attach a parent QWidget to the dialog.
Use ``cdt`` string to define the title to show in the color ramp dialog
Use a color scheme ``registry`` for color swatch grids to show in the drop-down menu. If not specified,
the button will use the global color scheme registry instead
%End
2016-08-04 13:49:59 +02:00
virtual QSize minimumSizeHint() const;
2016-08-04 13:49:59 +02:00
QColor color() const;
%Docstring
Return the currently selected color.
:return: currently selected color
2017-04-30 16:51:18 +02:00
.. seealso:: setColor
:rtype: QColor
%End
2017-05-30 13:33:09 +10:00
void setAllowOpacity( const bool allowOpacity );
%Docstring
2017-05-30 13:33:09 +10:00
Sets whether opacity modification (transparency) is permitted
for the color. Defaults to false.
2017-05-30 13:33:09 +10:00
\param allowOpacity set to true to allow opacity modification
.. seealso:: allowOpacity()
.. versionadded:: 3.0
%End
2017-05-30 13:33:09 +10:00
bool allowOpacity() const;
%Docstring
2017-05-30 13:33:09 +10:00
Returns whether opacity modification (transparency) is permitted
for the color.
2017-05-30 13:33:09 +10:00
:return: true if opacity modification is allowed
.. seealso:: setAllowOpacity()
.. versionadded:: 3.0
:rtype: bool
%End
void setColorDialogTitle( const QString &title );
%Docstring
Set the title for the color chooser dialog window.
\param title Title for the color chooser dialog
2017-04-30 16:51:18 +02:00
.. seealso:: colorDialogTitle
%End
2016-08-04 13:49:59 +02:00
QString colorDialogTitle() const;
%Docstring
Returns the title for the color chooser dialog window.
:return: title for the color chooser dialog
2017-04-30 16:51:18 +02:00
.. seealso:: setColorDialogTitle
:rtype: str
%End
2016-08-04 13:49:59 +02:00
bool acceptLiveUpdates() const;
%Docstring
Returns whether the button accepts live updates from QColorDialog.
:return: true if the button will be accepted immediately when the dialog's color changes
2017-04-30 16:51:18 +02:00
.. seealso:: setAcceptLiveUpdates
:rtype: bool
%End
2016-08-04 13:49:59 +02:00
void setAcceptLiveUpdates( const bool accept );
%Docstring
Sets whether the button accepts live updates from QColorDialog. Live updates may cause changes
that are not undoable on QColorDialog cancel.
\param accept set to true to enable live updates
2017-04-30 16:51:18 +02:00
.. seealso:: acceptLiveUpdates
%End
2016-08-04 13:49:59 +02:00
void setShowMenu( const bool showMenu );
%Docstring
Sets whether the drop-down menu should be shown for the button. The default behavior is to
show the menu.
\param showMenu set to false to hide the drop-down menu
2017-04-30 16:51:18 +02:00
.. seealso:: showMenu
%End
2016-08-04 13:49:59 +02:00
bool showMenu() const;
%Docstring
Returns whether the drop-down menu is shown for the button.
:return: true if drop-down menu is shown
2017-04-30 16:51:18 +02:00
.. seealso:: setShowMenu
:rtype: bool
%End
2016-08-04 13:49:59 +02:00
void setBehavior( const Behavior behavior );
%Docstring
Sets the behavior for when the button is clicked. The default behavior is to show
a color picker dialog.
\param behavior behavior when button is clicked
2017-04-30 16:51:18 +02:00
.. seealso:: behavior
%End
2016-08-04 13:49:59 +02:00
Behavior behavior() const;
%Docstring
Returns the behavior for when the button is clicked.
:return: behavior when button is clicked
2017-04-30 16:51:18 +02:00
.. seealso:: setBehavior
:rtype: Behavior
%End
void setDefaultColor( const QColor &color );
%Docstring
Sets the default color for the button, which is shown in the button's drop-down menu for the
"default color" option.
\param color default color for the button. Set to an invalid QColor to disable the default color
option.
2017-04-30 16:51:18 +02:00
.. seealso:: defaultColor
%End
2016-08-04 13:49:59 +02:00
QColor defaultColor() const;
%Docstring
Returns the default color for the button, which is shown in the button's drop-down menu for the
"default color" option.
:return: default color for the button. Returns an invalid QColor if the default color
option is disabled.
2017-04-30 16:51:18 +02:00
.. seealso:: setDefaultColor
:rtype: QColor
%End
2016-08-04 13:49:59 +02:00
void setShowNoColor( const bool showNoColorOption );
%Docstring
Sets whether the "no color" option should be shown in the button's drop-down menu. If selected,
the "no color" option sets the color button's color to a totally transparent color.
\param showNoColorOption set to true to show the no color option. This is disabled by default.
2017-04-30 16:51:18 +02:00
.. seealso:: showNoColor
.. seealso:: setNoColorString
.. note::
The "no color" option is only shown if the color button is set to show an alpha channel in the color
dialog (see setColorDialogOptions)
%End
2016-08-04 13:49:59 +02:00
bool showNoColor() const;
%Docstring
Returns whether the "no color" option is shown in the button's drop-down menu. If selected,
the "no color" option sets the color button's color to a totally transparent color.
:return: true if the no color option is shown.
2017-04-30 16:51:18 +02:00
.. seealso:: setShowNoColor
.. seealso:: noColorString
.. note::
The "no color" option is only shown if the color button is set to show an alpha channel in the color
dialog (see setColorDialogOptions)
:rtype: bool
%End
void setNoColorString( const QString &noColorString );
%Docstring
Sets the string to use for the "no color" option in the button's drop-down menu.
\param noColorString string to use for the "no color" menu option
2017-04-30 16:51:18 +02:00
.. seealso:: noColorString
.. seealso:: setShowNoColor
.. note::
The "no color" option is only shown if the color button is set to show an alpha channel in the color
dialog (see setColorDialogOptions)
%End
2016-08-04 13:49:59 +02:00
void setShowNull( bool showNull );
%Docstring
Sets whether a set to null (clear) option is shown in the button's drop-down menu.
\param showNull set to true to show a null option
.. versionadded:: 2.16
2017-04-30 16:51:18 +02:00
.. seealso:: showNull()
.. seealso:: isNull()
%End
2016-08-04 13:49:59 +02:00
bool showNull() const;
%Docstring
Returns whether the set to null (clear) option is shown in the button's drop-down menu.
.. versionadded:: 2.16
2017-04-30 16:51:18 +02:00
.. seealso:: setShowNull()
.. seealso:: isNull()
:rtype: bool
%End
2016-08-04 13:49:59 +02:00
bool isNull() const;
%Docstring
Returns true if the current color is null.
.. versionadded:: 2.16
2017-04-30 16:51:18 +02:00
.. seealso:: setShowNull()
.. seealso:: showNull()
:rtype: bool
%End
2016-08-04 13:49:59 +02:00
QString noColorString() const;
%Docstring
Returns the string used for the "no color" option in the button's drop-down menu.
:return: string used for the "no color" menu option
2017-04-30 16:51:18 +02:00
.. seealso:: setNoColorString
.. seealso:: showNoColor
.. note::
The "no color" option is only shown if the color button is set to show an alpha channel in the color
dialog (see setColorDialogOptions)
:rtype: str
%End
void setContext( const QString &context );
%Docstring
Sets the context string for the color button. The context string is passed to all color swatch
grids shown in the button's drop-down menu, to allow them to customise their display colors
based on the context.
\param context context string for the color button's color swatch grids
2017-04-30 16:51:18 +02:00
.. seealso:: context
%End
2016-08-04 13:49:59 +02:00
QString context() const;
%Docstring
Returns the context string for the color button. The context string is passed to all color swatch
grids shown in the button's drop-down menu, to allow them to customise their display colors
based on the context.
:return: context string for the color button's color swatch grids
2017-04-30 16:51:18 +02:00
.. seealso:: setContext
:rtype: str
%End
2016-08-04 13:49:59 +02:00
void setColorSchemeRegistry( QgsColorSchemeRegistry *registry );
%Docstring
Sets the color scheme registry for the button, which controls the color swatch grids
that are shown in the button's drop-down menu.
\param registry color scheme registry for the button. Set to 0 to hide all color
swatch grids from the button's drop-down menu.
2017-04-30 16:51:18 +02:00
.. seealso:: colorSchemeRegistry
%End
QgsColorSchemeRegistry *colorSchemeRegistry();
%Docstring
Returns the color scheme registry for the button, which controls the color swatch grids
that are shown in the button's drop-down menu.
:return: color scheme registry for the button. If returned value is 0 then all color
swatch grids are hidden from the button's drop-down menu.
2017-04-30 16:51:18 +02:00
.. seealso:: setColorSchemeRegistry
:rtype: QgsColorSchemeRegistry
%End
public slots:
2016-08-04 13:49:59 +02:00
void setColor( const QColor &color );
%Docstring
Sets the current color for the button. Will emit a colorChanged signal if the color is different
to the previous color.
\param color new color for the button
2017-04-30 16:51:18 +02:00
.. seealso:: color
%End
2016-08-04 13:49:59 +02:00
void setButtonBackground( const QColor &color = QColor() );
%Docstring
Sets the background pixmap for the button based upon color and transparency.
Call directly to update background after adding/removing QColorDialog.ShowAlphaChannel option
but the color has not changed, i.e. setColor() wouldn't update button and
you want the button to retain the set color's alpha component regardless
\param color Color for button background. If no color is specified, the button's current
color will be used
%End
2016-08-04 13:49:59 +02:00
void copyColor();
%Docstring
Copies the current color to the clipboard
2017-04-30 16:51:18 +02:00
.. seealso:: pasteColor
%End
2016-08-04 13:49:59 +02:00
void pasteColor();
%Docstring
Pastes a color from the clipboard to the color button. If clipboard does not contain a valid
color or string representation of a color, then no change is applied.
2017-04-30 16:51:18 +02:00
.. seealso:: copyColor
%End
2016-08-04 13:49:59 +02:00
void activatePicker();
%Docstring
Activates the color picker tool, which allows for sampling a color from anywhere on the screen
%End
2016-08-04 13:49:59 +02:00
void setToNoColor();
%Docstring
Sets color to a totally transparent color.
.. note::
2017-05-30 13:33:09 +10:00
If the color button is not set to show an opacity channel in the color
dialog (see setColorDialogOptions) then the color will not be changed.
2017-04-30 16:51:18 +02:00
.. seealso:: setToNull()
%End
2016-08-04 13:49:59 +02:00
void setToDefaultColor();
%Docstring
Sets color to the button's default color, if set.
2017-04-30 16:51:18 +02:00
.. seealso:: setDefaultColor
.. seealso:: defaultColor
.. seealso:: setToNull()
%End
2016-08-04 13:49:59 +02:00
void setToNull();
%Docstring
Sets color to null.
2017-04-30 16:51:18 +02:00
.. seealso:: setToDefaultColor()
.. seealso:: setToNoColor()
.. versionadded:: 2.16
%End
signals:
2016-08-04 13:49:59 +02:00
void colorChanged( const QColor &color );
%Docstring
Is emitted whenever a new color is set for the button. The color is always valid.
In case the new color is the same no signal is emitted, to avoid infinite loops.
\param color New color
%End
2016-08-04 13:49:59 +02:00
void colorClicked( const QColor &color );
%Docstring
Emitted when the button is clicked, if the button's behavior is set to SignalOnly
\param color button color
2017-04-30 16:51:18 +02:00
.. seealso:: setBehavior
.. seealso:: behavior
%End
2016-08-04 13:49:59 +02:00
protected:
2016-08-04 13:49:59 +02:00
virtual bool event( QEvent *e );
2017-04-20 13:48:50 +02:00
virtual void changeEvent( QEvent *e );
2017-04-20 13:48:50 +02:00
virtual void showEvent( QShowEvent *e );
2017-04-20 13:48:50 +02:00
virtual void resizeEvent( QResizeEvent *event );
2016-08-04 13:49:59 +02:00
2017-04-20 13:48:50 +02:00
static const QPixmap &transparentBackground();
%Docstring
Returns a checkboard pattern pixmap for use as a background to transparent colors
:rtype: QPixmap
%End
2014-05-27 23:22:50 +02:00
virtual void mousePressEvent( QMouseEvent *e );
2017-04-20 13:48:50 +02:00
%Docstring
Reimplemented to detect right mouse button clicks on the color button and allow dragging colors
%End
2014-05-27 23:22:50 +02:00
virtual void mouseMoveEvent( QMouseEvent *e );
2017-04-20 13:48:50 +02:00
%Docstring
Reimplemented to allow dragging colors from button
%End
virtual void mouseReleaseEvent( QMouseEvent *e );
2017-04-20 13:48:50 +02:00
%Docstring
Reimplemented to allow color picking
%End
virtual void keyPressEvent( QKeyEvent *e );
2017-04-20 13:48:50 +02:00
%Docstring
Reimplemented to allow canceling color pick via keypress, and sample via space bar press
%End
virtual void dragEnterEvent( QDragEnterEvent *e );
2017-04-20 13:48:50 +02:00
%Docstring
Reimplemented to accept dragged colors
%End
virtual void dragLeaveEvent( QDragLeaveEvent *e );
2017-04-20 13:48:50 +02:00
%Docstring
Reimplemented to reset button appearance after drag leave
%End
2016-08-04 13:49:59 +02:00
virtual void dropEvent( QDropEvent *e );
2017-04-20 13:48:50 +02:00
%Docstring
Reimplemented to accept dropped colors
%End
2016-08-04 13:49:59 +02:00
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgscolorbutton.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/