there is no moc file generated for this class
[kdegraphics.git] / kolourpaint / widgets / kpDualColorButton.h
blob4fd82507ba74c2802ac77b9670c95f4b8425d998
2 /*
3 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
4 All rights reserved.
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef kpDualColorButton_H
30 #define kpDualColorButton_H
33 #include <qframe.h>
35 #include <kpColor.h>
39 // Widget similar to KDualColorButton.
40 // Main differences:
41 // - more consistent feel with other KolourPaint widgets
42 // (esp. kpColorPalette)
43 // - displays the transparent colour using the special pixmap
44 // used by kpTransparentColorCell
45 // - no obscure "current" colour
47 class kpDualColorButton : public QFrame
49 Q_OBJECT
51 public:
52 kpDualColorButton (QWidget *parent);
53 virtual ~kpDualColorButton ();
55 kpColor color (int which) const;
56 kpColor foregroundColor () const;
57 kpColor backgroundColor () const;
59 public slots:
60 void setColor (int which, const kpColor &color);
61 void setForegroundColor (const kpColor &color);
62 void setBackgroundColor (const kpColor &color);
64 signals:
65 // If you connect to this signal, ignore the following
66 // foregroundColorChanged() and backgroundColorChanged() signals
67 void colorsSwapped (const kpColor &newForegroundColor,
68 const kpColor &newBackgroundColor);
70 void foregroundColorChanged (const kpColor &color);
71 void backgroundColorChanged (const kpColor &color);
73 public:
74 // (only valid in slots connected to foregroundColorChanged())
75 kpColor oldForegroundColor () const;
76 // (only valid in slots connected to backgroundColorChanged())
77 kpColor oldBackgroundColor () const;
79 public:
80 virtual QSize sizeHint () const;
82 protected:
83 QRect swapPixmapRect () const;
84 QRect foregroundBackgroundRect () const;
85 QRect foregroundRect () const;
86 QRect backgroundRect () const;
88 virtual void dragEnterEvent (QDragEnterEvent *e);
89 virtual void dragMoveEvent (QDragMoveEvent *e);
90 virtual void dropEvent (QDropEvent *e);
92 virtual void mousePressEvent (QMouseEvent *e);
93 virtual void mouseMoveEvent (QMouseEvent *e);
94 virtual void mouseReleaseEvent (QMouseEvent *e);
96 virtual void mouseDoubleClickEvent (QMouseEvent *e);
98 virtual void paintEvent (QPaintEvent *e);
100 QPoint m_dragStartPoint;
101 kpColor m_color [2];
102 kpColor m_oldColor [2];
106 #endif // kpDualColorButton_H