Compound list   File list   Compound Members   Related Pages  

QHSSelector Class Reference

Hue-Saturation chart selector class. More...

List of all members.

Public Members

Public Slots

Signals

Protected Members


Detailed Description

Hue-Saturation chart selector class.

This class describes the Hue-Saturation chart as often found in the color selection dialogs. In combination with QValueSelector it can be used to select a color from the HSV space.

It behaves as any QRangeControl but with two degrees of freedom. Therefore it contains the following signal/slot pairs:

As usual, the signals are emited only if the appropriate value really changed (either because of user action or after calling 'set' function). The ranges of Hue and Saturation components are predefined as:

NOTE: Despite behaviour similarities, this class derives only from QLabel, not from QRangeControl.

See also:
QValueSelector


Member Function Documentation

QHSSelector::QHSSelector(QWidget* parent = 0, char * name = 0)

Constructor.

This method constructs the HS selection widget with given parent and name. The widget is always 180 pixels wide and 128 pixels high and it contains the image with colors changing in Hue from 0 to 359 and in Saturation from 0 to 255. In addition, the Value of the colors changes from 128 to 255 so that even low saturated colors don't blend into indidtinguishable darkness.

Parameters:
parent - a widget's parent as passed to QLabel constructor
name - a widget's name as passed to QLabel constructor

QHSSelector::~QHSSelector()

Destructor.

This destructor does nothing. The Qt framework takes care of all cleanup.

int QHSSelector::hue() const

Returns the hue value.

int QHSSelector::saturation() const

Returns the saturation value.

void QHSSelector::setHue(int h) [slot]

Set the hue value of selector.

This function validates the value of the parameter h, sets iHue to it and if the iHue has changed emits signal hueChanged(). It also calls update of the widget on the previous position of the cursor, so that the background is redrawn and a new cursor is painted appropriately.

Parameters:
h - hue value to be set

void QHSSelector::setSaturation(int s) [slot]

Set the saturation value of selector.

This function validates the value of the parameter s, sets iSaturation to it. If the iSaturation has changed emits signal saturationChanged(). It also calls update of the widget on the previous position of the cursor, so that the background is redrawn and a new cursor is painted appropriately.

Parameters:
s - saturation value to be set

void QHSSelector::hueChanged(int) [signal]

Emited when hue changed.

void QHSSelector::saturationChanged(int) [signal]

Emited when saturation changed.

virtual void QHSSelector::paintEvent(QPaintEvent * e) [protected, virtual]

Repaints the HS chart and draws the selection cross.

On repaint event, the default paintEvent() is called. In this way the color chart image is redrawn. Later the diagonal cross is painted in the position given by current iHue, iSaturation values.

Parameters:
e - QPaintEvent describing what should be repainted.

virtual void QHSSelector::mouseMoveEvent(QMouseEvent* e) [protected, virtual]

Used for user interaction.

This function simply calls setHue() and setSaturation() with appropriate values concerning the mouse position as described in mouse event.

Parameters:
e - QMouseEvent to be processed.

virtual void QHSSelector::mousePressEvent(QMouseEvent* e) [protected, virtual]

Used for user interaction.

As the result of pressing mouse button within HSSelector should be the same as dragging the mouse there, this function simply passes the event to mouseMoveEvent().

Parameters:
e - QMouseEvent to be processed.


Member Data Documentation

int QHSSelector::iHue [protected]

Current hue value.

int QHSSelector::iSaturation [protected]

Current saturation value.


The documentation for this class was generated from the following files:
Generated at Mon Jun 7 15:00:45 1999 for Qt Color Selection Dialog by doxygen  written by Dimitri van Heesch, © 1997-1998