~ubuntu-branches/ubuntu/oneiric/koffice/oneiric-updates

« back to all changes in this revision

Viewing changes to krita/plugins/extensions/dockers/colorselectorng/kis_color_patches.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (c) 2010 Adam Celarek <kdedev at xibo dot at>
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or modify
 
5
 *  it under the terms of the GNU Lesser General Public License as published by
 
6
 *  the Free Software Foundation; version 2 of the License.
 
7
 *
 
8
 *  This program is distributed in the hope that it will be useful,
 
9
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 *  GNU General Public License for more details.
 
12
 *
 
13
 *  You should have received a copy of the GNU Lesser General Public License
 
14
 *  along with this program; if not, write to the Free Software
 
15
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
16
 */
 
17
 
 
18
#ifndef KIS_COLOR_PATCHES_H
 
19
#define KIS_COLOR_PATCHES_H
 
20
 
 
21
#include "kis_color_selector_base.h"
 
22
 
 
23
#include "KoColor.h"
 
24
 
 
25
class KoColor;
 
26
class KisCanvas2;
 
27
 
 
28
 
 
29
class KisColorPatches : public KisColorSelectorBase
 
30
{
 
31
Q_OBJECT
 
32
public:
 
33
    explicit KisColorPatches(QString configPrefix, QWidget *parent = 0);
 
34
    enum Direction { Horizontal, Vertical };
 
35
 
 
36
    void setColors(QList<KoColor> colors);
 
37
    QList<KoColor> colors() const {return m_colors;}
 
38
    virtual void setCanvas(KisCanvas2 *canvas) {m_canvas=canvas;}
 
39
 
 
40
public slots:
 
41
    void updateSettings();
 
42
 
 
43
protected:
 
44
    void paintEvent(QPaintEvent *);
 
45
    void wheelEvent(QWheelEvent *);
 
46
    void resizeEvent(QResizeEvent *);
 
47
    void mouseReleaseEvent(QMouseEvent *);
 
48
    void mousePressEvent(QMouseEvent *);
 
49
    void mouseMoveEvent(QMouseEvent *);
 
50
    int patchCount() const;
 
51
    bool colorAt(const QPoint &, KoColor *result) const;
 
52
 
 
53
public:
 
54
    /// set buttons, that should be drawn additionally to the patches
 
55
    /// this class takes ownership of them and will delete them
 
56
    /// they will be resized to the patchsize
 
57
    void setAdditionalButtons(QList<QWidget*> buttonList);
 
58
 
 
59
private:
 
60
    int m_patchWidth;
 
61
    int m_patchHeight;
 
62
    int m_patchCount;
 
63
    QList<KoColor> m_colors;
 
64
    bool m_allowColorListChangeGuard;
 
65
    int m_scrollValue;
 
66
 
 
67
    Direction m_direction;
 
68
    bool m_allowScrolling;
 
69
    int m_numCols;
 
70
    int m_numRows;
 
71
    QList<QWidget*> m_buttonList;
 
72
 
 
73
    /// returns width of the patchfield, if there are only m_numRows allowed
 
74
    int widthOfAllPatches();
 
75
    /// returns height of the patchfield, if there are only m_numCols allowed
 
76
    int heightOfAllPatches();
 
77
 
 
78
    /// returns height, that is needed to display all patches with the given width
 
79
    int heightForWidth(int width) const;
 
80
    /// returns width, that is needed to display all patches with the given height
 
81
    int widthForHeight(int height) const;
 
82
    
 
83
    /// returns count of colors and buttons
 
84
    int fieldCount() const;
 
85
 
 
86
    QString m_configPrefix;
 
87
 
 
88
    QPoint m_dragStartPos;
 
89
};
 
90
 
 
91
#endif