[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
Public Slots | Signals | Public Member Functions | Protected Member Functions | List of all members
QtColorTriangle Class Reference

The QtColorTriangle class provides a triangular color selection widget. More...

#include <qtcolortriangle.h>

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

Public Slots

void setColor (const QColor &col)
 

Signals

void colorChanged (const QColor &col)
 

Public Member Functions

 QtColorTriangle (QWidget *parent=0)
 
 ~QtColorTriangle ()
 
QSize sizeHint () const
 
int heightForWidth (int w) const
 
void polish ()
 
QColor color () const
 
- Public Member Functions inherited from QWidget
 ContextMenuPolicy
 
 FocusPolicy
 
 LayoutDirection
 
 WindowFlags
 
 WindowModality
 
 QWidget (QWidget *parent=0, Qt::WindowFlags f=0)
 
 actionEvent (QActionEvent *event)
 
 actions ()
 
 activateWindow ()
 
 addAction (QAction *action)
 
 addActions (QList< QAction * > actions)
 
 adjustSize ()
 
 ColorRole QWidget::backgroundRole()
 
 changeEvent (QEvent *event)
 
 childAt (int x, int y)
 
 childAt (const QPoint &p)
 
 clearFocus ()
 
 clearMask ()
 
 close ()
 
 closeEvent (QCloseEvent *event)
 
 contentsRect ()
 
 contextMenuEvent (QContextMenuEvent *event)
 
 create (WId window=0, bool initializeWindow=true, bool destroyOldWindow=true)
 
 customContextMenuRequested (const QPoint &pos)
 
 destroy (bool destroyWindow=true, bool destroySubWindows=true)
 
 dragEnterEvent (QDragEnterEvent *event)
 
 dragLeaveEvent (QDragLeaveEvent *event)
 
 dragMoveEvent (QDragMoveEvent *event)
 
 dropEvent (QDropEvent *event)
 
 ensurePolished ()
 
 enterEvent (QEvent *event)
 
 event (QEvent *event)
 
 find (WId id)
 
 focusInEvent (QFocusEvent *event)
 
 focusNextChild ()
 
 focusNextPrevChild (bool next)
 
 focusOutEvent (QFocusEvent *event)
 
 focusPreviousChild ()
 
 focusProxy ()
 
 focusWidget ()
 
 fontInfo ()
 
 fontMetrics ()
 
 ColorRole QWidget::foregroundRole()
 
 getContentsMargins (int *left, int *top, int *right, int *bottom)
 
 getDC ()
 
 grabKeyboard ()
 
 grabMouse ()
 
 grabMouse (const QCursor &cursor)
 
 grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 
 hasEditFocus ()
 
 heightForWidth (int w)
 
 hide ()
 
 hideEvent (QHideEvent *event)
 
 inputContext ()
 
 inputMethodEvent (QInputMethodEvent *event)
 
 inputMethodQuery (Qt::InputMethodQuery query)
 
 insertAction (QAction *before, QAction *action)
 
 insertActions (QAction *before, QList< QAction * > actions)
 
 isAncestorOf (const QWidget *child)
 
 isEnabledTo (QWidget *ancestor)
 
 isHidden ()
 
 isVisibleTo (QWidget *ancestor)
 
 isWindow ()
 
 keyPressEvent (QKeyEvent *event)
 
 keyReleaseEvent (QKeyEvent *event)
 
 keyboardGrabber ()
 
 layout ()
 
 leaveEvent (QEvent *event)
 
 lower ()
 
 HANDLE QWidget::macCGHandle()
 
 macEvent (EventHandlerCallRef caller, EventRef event)
 
 HANDLE QWidget::macQDHandle()
 
 mapFrom (QWidget *parent, const QPoint &pos)
 
 mapFromGlobal (const QPoint &pos)
 
 mapFromParent (const QPoint &pos)
 
 mapTo (QWidget *parent, const QPoint &pos)
 
 mapToGlobal (const QPoint &pos)
 
 mapToParent (const QPoint &pos)
 
 mask ()
 
 metric (PaintDeviceMetric m)
 
 mouseDoubleClickEvent (QMouseEvent *event)
 
 mouseGrabber ()
 
 mouseMoveEvent (QMouseEvent *event)
 
 mousePressEvent (QMouseEvent *event)
 
 mouseReleaseEvent (QMouseEvent *event)
 
 moveEvent (QMoveEvent *event)
 
 nextInFocusChain ()
 
 overrideWindowFlags (Qt::WindowFlags flags)
 
 paintEngine ()
 
 paintEvent (QPaintEvent *event)
 
 parentWidget ()
 
 qwsEvent (QWSEvent *event)
 
 raise ()
 
 releaseDC (HDC hdc)
 
 releaseKeyboard ()
 
 releaseMouse ()
 
 releaseShortcut (int id)
 
 removeAction (QAction *action)
 
 render (QPaintDevice *target, const QPoint &targetOffset=QPoint()
 
 repaint ()
 
 repaint (int x, int y, int w, int h)
 
 repaint (const QRect &r)
 
 repaint (const QRegion &rgn)
 
 resetInputContext ()
 
 resizeEvent (QResizeEvent *event)
 
 restoreGeometry (const QByteArray &geometry)
 
 saveGeometry ()
 
 scroll (int dx, int dy)
 
 scroll (int dx, int dy, const QRect &r)
 
 setAttribute (Qt::WidgetAttribute attribute, bool on=true)
 
 setBackgroundRole (QPalette::ColorRole role)
 
 setContentsMargins (int left, int top, int right, int bottom)
 
 setDisabled (bool disable)
 
 setEditFocus (bool enable)
 
 setFixedHeight (int h)
 
 setFixedSize (const QSize &s)
 
 setFixedSize (int w, int h)
 
 setFixedWidth (int w)
 
 setFocus (Qt::FocusReason reason)
 
 setFocus ()
 
 setFocusProxy (QWidget *w)
 
 setForegroundRole (QPalette::ColorRole role)
 
 setHidden (bool hidden)
 
 setInputContext (QInputContext *context)
 
 setLayout (QLayout *layout)
 
 setMask (const QBitmap &bitmap)
 
 setMask (const QRegion &region)
 
 setParent (QWidget *parent)
 
 setParent (QWidget *parent, Qt::WindowFlags f)
 
 setShortcutAutoRepeat (int id, bool enable=true)
 
 setShortcutEnabled (int id, bool enable=true)
 
 setStyle (QStyle *style)
 
 setTabOrder (QWidget *first, QWidget *second)
 
 setWindowRole (const QString &role)
 
 setWindowState (Qt::WindowStates windowState)
 
 setWindowSurface (QWindowSurface *surface)
 
 show ()
 
 showEvent (QShowEvent *event)
 
 showFullScreen ()
 
 showMaximized ()
 
 showMinimized ()
 
 showNormal ()
 
 stackUnder (QWidget *w)
 
 style ()
 
 tabletEvent (QTabletEvent *event)
 
 testAttribute (Qt::WidgetAttribute attribute)
 
 underMouse ()
 
 update ()
 
 update (int x, int y, int w, int h)
 
 update (const QRect &r)
 
 update (const QRegion &rgn)
 
 updateGeometry ()
 
 updateMicroFocus ()
 
 visibleRegion ()
 
 wheelEvent (QWheelEvent *event)
 
 winEvent (MSG *message, long *result)
 
 winId ()
 
 window ()
 
 windowRole ()
 
 WindowStates QWidget::windowState()
 
 windowSurface ()
 
 WindowType QWidget::windowType()
 
 x11Event (XEvent *event)
 
 x11Info ()
 
 HANDLE QWidget::x11PictureHandle()
 
 QWidget (QWidget *parent, const char *name, Qt::WindowFlags f=0)
 
 BackgroundMode QWidget::backgroundMode()
 
 backgroundOffset ()
 
 backgroundOrigin ()
 
 caption ()
 
 childAt (int x, int y, bool includeThis)
 
 childAt (const QPoint &p, bool includeThis)
 
 close (bool alsoDelete)
 
 colorGroup ()
 
 constPolish ()
 
 drawText (const QPoint &p, const QString &s)
 
 drawText (int x, int y, const QString &s)
 
 erase ()
 
 erase (int x, int y, int w, int h)
 
 erase (const QRect &rect)
 
 erase (const QRegion &rgn)
 
 hasMouse ()
 
 icon ()
 
 iconText ()
 
 iconify ()
 
 isDesktop ()
 
 isDialog ()
 
 isInputMethodEnabled ()
 
 isPopup ()
 
 isShown ()
 
 isUpdatesEnabled ()
 
 isVisibleToTLW ()
 
 ownCursor ()
 
 ownFont ()
 
 ownPalette ()
 
 parentWidget (bool sameWindow)
 
 polish ()
 
 recreate (QWidget *parent, Qt::WindowFlags f, const QPoint &p, bool showIt=false)
 
 repaint (bool b)
 
 repaint (int x, int y, int w, int h, bool b)
 
 repaint (const QRect &r, bool b)
 
 repaint (const QRegion &rgn, bool b)
 
 reparent (QWidget *parent, Qt::WindowFlags f, const QPoint &p, bool showIt=false)
 
 reparent (QWidget *parent, const QPoint &p, bool showIt=false)
 
 setActiveWindow ()
 
 setBackgroundColor (const QColor &color)
 
 setBackgroundMode (Qt::BackgroundMode widgetBackground, Qt::BackgroundMode paletteBackground=Qt::PaletteBackground)
 
 setBackgroundOrigin (BackgroundOrigin background)
 
 setBackgroundPixmap (const QPixmap &pixmap)
 
 setCaption (const QString &c)
 
 setEraseColor (const QColor &color)
 
 setErasePixmap (const QPixmap &pixmap)
 
 setFont (const QFont &f, bool b)
 
 setIcon (const QPixmap &i)
 
 setIconText (const QString &it)
 
 setInputMethodEnabled (bool enabled)
 
 setKeyCompression (bool b)
 
 setPalette (const QPalette &p, bool b)
 
 setPaletteBackgroundColor (const QColor &color)
 
 setPaletteBackgroundPixmap (const QPixmap &pixmap)
 
 setPaletteForegroundColor (const QColor &color)
 
 setShown (bool shown)
 
 setSizePolicy (QSizePolicy::Policy hor, QSizePolicy::Policy ver, bool hfw)
 
 setStyle (const QString &style)
 
 unsetFont ()
 
 unsetPalette ()
 
 visibleRect ()
 
 wmapper ()
 

Protected Member Functions

void paintEvent (QPaintEvent *)
 
void mouseMoveEvent (QMouseEvent *)
 
void mousePressEvent (QMouseEvent *)
 
void mouseReleaseEvent (QMouseEvent *)
 
void keyPressEvent (QKeyEvent *e)
 
void resizeEvent (QResizeEvent *)
 
void drawTrigon (QImage *p, const QPointF &a, const QPointF &b, const QPointF &c, const QColor &color)
 
void internalSetNewColor (const QColor &color)
 

Detailed Description

The QtColorTriangle class provides a triangular color selection widget.

This widget uses the HSV color model, and is therefore useful for selecting colors by eye.

The triangle in the center of the widget is used for selecting saturation and value, and the surrounding circle is used for selecting hue.

Use setColor() and color() to set and get the current color.

Definition at line 79 of file qtcolortriangle.h.

Constructor & Destructor Documentation

QtColorTriangle::QtColorTriangle ( QWidget parent = 0)

Constructs a color triangle widget with the given parent.

Definition at line 140 of file qtcolortriangle.cpp.

References setColor(), QColor::setHsv(), and QWidget::setSizePolicy().

QtColorTriangle::~QtColorTriangle ( )

Destructs the color triangle.

Definition at line 156 of file qtcolortriangle.cpp.

Member Function Documentation

QColor QtColorTriangle::color ( ) const
QtColorTriangle::colorChanged ( const QColor color)
signal

Whenever the color triangles color changes this signal is emitted with the new color.

Referenced by internalSetNewColor().

void QtColorTriangle::drawTrigon ( QImage buf,
const QPointF pa,
const QPointF pb,
const QPointF pc,
const QColor color 
)
protected

Draws a trigon (polygon with three corners pa, pb and pc and three edges), using painter.

Fills the trigon with a gradient, where the pa point has the color color, pb is black and bc is white. Bilinear gradient.

Definition at line 620 of file qtcolortriangle.cpp.

References DoubleColor::b, Vertex::color, DoubleColor::g, Vertex::point, DoubleColor::r, QVarLengthArray::resize(), QImage::scanLine(), swap(), QPointF::x(), and QPointF::y().

Referenced by paintEvent().

int QtColorTriangle::heightForWidth ( int  w) const

Forces the triangle widget to always be square. Returns the value w.

Definition at line 203 of file qtcolortriangle.cpp.

void QtColorTriangle::internalSetNewColor ( const QColor color)
protected

Definition at line 604 of file qtcolortriangle.cpp.

References colorChanged().

Referenced by mouseMoveEvent(), mousePressEvent(), and setColor().

void QtColorTriangle::keyPressEvent ( QKeyEvent e)
protected

Definition at line 443 of file qtcolortriangle.cpp.

References QColor::getHsv(), QKeyEvent::key(), setColor(), and QColor::setHsv().

void QtColorTriangle::mouseMoveEvent ( QMouseEvent e)
protected

Selects new hue or saturation/value values, depending on where the mouse button was pressed initially.

Definition at line 271 of file qtcolortriangle.cpp.

References QColor::alpha(), QWidget::contentsRect(), QColor::getHsv(), internalSetNewColor(), PI, Vertex::point, QMouseEvent::pos(), QColor::setHsv(), swap(), TWOPI, QWidget::update(), and QPointF::y().

void QtColorTriangle::mousePressEvent ( QMouseEvent e)
protected

When the left mouse button is pressed, this function determines what part of the color triangle the cursor is, and from that it initiates either selecting the hue (outside the triangle's area) or the saturation/value (inside the triangle's area).

Definition at line 352 of file qtcolortriangle.cpp.

References QColor::alpha(), QWidget::contentsRect(), QColor::getHsv(), internalSetNewColor(), PI, Vertex::point, QMouseEvent::pos(), QColor::setAlpha(), QColor::setHsv(), swap(), TWOPI, QWidget::update(), and QPointF::y().

void QtColorTriangle::mouseReleaseEvent ( QMouseEvent e)
protected

Stops selecting of colors with the mouse.

Definition at line 434 of file qtcolortriangle.cpp.

void QtColorTriangle::paintEvent ( QPaintEvent e)
protected

(reimplemented)

First copies a background image of the hue donut and its background color onto the frame, then draws the color triangle, and finally the selectors.

Definition at line 538 of file qtcolortriangle.cpp.

References QWidget::contentsRect(), QImage::copy(), QPainter::drawEllipse(), QPainter::drawLine(), QPainter::drawPixmap(), drawTrigon(), QPixmap::fromImage(), QColor::getHsv(), QColor::getRgb(), QPaintEvent::rect(), QPaintEvent::region(), QPainter::setClipRegion(), QColor::setHsv(), QPainter::setPen(), QPainter::setRenderHint(), QPointF::x(), and QPointF::y().

void QtColorTriangle::polish ( )

Generates the first background image.

Definition at line 165 of file qtcolortriangle.cpp.

References QWidget::contentsRect(), and QWidget::update().

void QtColorTriangle::resizeEvent ( QResizeEvent )
protected

Regenerates the background image and sends an update.

Definition at line 504 of file qtcolortriangle.cpp.

References QWidget::contentsRect(), and QWidget::update().

void QtColorTriangle::setColor ( const QColor col)
slot

Sets the color of the triangle to col.

Definition at line 820 of file qtcolortriangle.cpp.

References QWidget::contentsRect(), QColor::getHsv(), internalSetNewColor(), PI, TWOPI, and QWidget::update().

Referenced by keyPressEvent(), and QtColorTriangle().

QSize QtColorTriangle::sizeHint ( ) const

(reimplemented)

Definition at line 194 of file qtcolortriangle.cpp.


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

Generated by doxygen 1.8.8