summaryrefslogtreecommitdiffstats
path: root/kmag/kmagselrect.h
blob: 675954c5778a6bd6434c94d3738ef16d57491d1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/***************************************************************************
                          kmagselrect.h  -  description
                             -------------------
    begin                : Mon Feb 12 23:45:41 EST 2001
    copyright            : (C) 2001-2003 by Sarang Lakare
    email                : sarang#users.sf.net
    copyright            : (C) 2003-2004 by Olaf Schmidt
    email                : ojschmidt@kde.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KMAGSELRECT_H
#define KMAGSELRECT_H

#include <stdlib.h>

// Qt includes
#include <qrect.h>
#include <qwidget.h>
#include <qlabel.h>

class KMagSelWinCorner : public QLabel
{
    Q_OBJECT

public:

    KMagSelWinCorner ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 );

    virtual ~KMagSelWinCorner();

signals:

    void startResizing ();
    void resized ( QPoint offset );

protected:

    QPoint oldPos;

    virtual void mousePressEvent ( QMouseEvent * e );
    virtual void mouseReleaseEvent ( QMouseEvent * e );
    virtual void mouseMoveEvent ( QMouseEvent * e );
};

class KMagSelWin : public QWidget
{
    Q_OBJECT

public:

    KMagSelWin ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 );

    virtual ~KMagSelWin();

    void setSelRect ( QRect selRect );
    QRect getSelRect ();

public slots:

    void startResizing ();
    void titleMoved ( QPoint offset );
    void topLeftResized ( QPoint offset );
    void topRightResized ( QPoint offset );
    void bottomLeftResized ( QPoint offset );
    void bottomRightResized ( QPoint offset );

signals:

    void resized();

protected:

    QRect oldSelRect;

    KMagSelWinCorner *titleBar;
    KMagSelWinCorner *topLeftCorner;
    KMagSelWinCorner *topRightCorner;
    KMagSelWinCorner *bottomLeftCorner;
    KMagSelWinCorner *bottomRightCorner;
};

/**
 * This class stores the selected rectangular area for grabbing. It also displays the
 * rectangular area on demand.
 *
 * @author Original : Michael Forster
 * @author Current : Sarang Lakare
 */
class KMagSelRect : public QObject, public QRect
{
    Q_OBJECT

public:
    KMagSelRect(QWidget *parent=0);
    KMagSelRect(const QPoint &topLeft, const QPoint &bottomRight,
      QWidget *parent=0);
    KMagSelRect(const QPoint &topLeft, const QSize &size,
      QWidget *parent=0);
    KMagSelRect(int left, int top, int width, int height,
      QWidget *selWindowParent=0);

    virtual ~KMagSelRect();

    WId winId();

    bool visible();

    /// Makes the rectangle always visible
    void alwaysVisible(bool visible=true);

    /// Returns true if always visible is set
    bool getAlwaysVisible() const {
      return (m_alwaysVisible);
    };

public slots:

    void show();
    void hide();
    void update();

    void selWinResized();

protected:

    void init(QWidget *);

    QWidget *selWindowParent;
    KMagSelWin *selectionwindow;
    bool m_alwaysVisible;

};

void setTitleColors (QColor title, QColor text, QColor titleBtn);
void setFrameSize (int size);

#endif // KMAGSELRECT_H