1 | /*************************************************************************** |
2 | kmagselrect.h - description |
3 | ------------------- |
4 | begin : Mon Feb 12 23:45:41 EST 2001 |
5 | copyright : (C) 2001-2003 by Sarang Lakare |
6 | email : sarang#users.sf.net |
7 | copyright : (C) 2003-2004 by Olaf Schmidt |
8 | email : ojschmidt@kde.org |
9 | ***************************************************************************/ |
10 | |
11 | /*************************************************************************** |
12 | * * |
13 | * This program is free software; you can redistribute it and/or modify * |
14 | * it under the terms of the GNU General Public License as published by * |
15 | * the Free Software Foundation; either version 2 of the License, or * |
16 | * (at your option) any later version. * |
17 | * * |
18 | ***************************************************************************/ |
19 | |
20 | #ifndef KMAGSELRECT_H |
21 | #define KMAGSELRECT_H |
22 | |
23 | #include <stdlib.h> |
24 | |
25 | // Qt includes |
26 | #include <QtCore/QRect> |
27 | #include <QtGui/QWidget> |
28 | #include <QtGui/QLabel> |
29 | #include <QtGui/QMouseEvent> |
30 | |
31 | class KMagSelWinCorner : public QLabel |
32 | { |
33 | Q_OBJECT |
34 | |
35 | public: |
36 | |
37 | explicit KMagSelWinCorner ( QWidget * parent = 0, Qt::WFlags f = 0 ); |
38 | |
39 | virtual ~KMagSelWinCorner(); |
40 | |
41 | signals: |
42 | |
43 | void startResizing (); |
44 | void resized ( QPoint offset ); |
45 | |
46 | protected: |
47 | |
48 | QPoint oldPos; |
49 | |
50 | virtual void mousePressEvent ( QMouseEvent * e ); |
51 | virtual void mouseReleaseEvent ( QMouseEvent * e ); |
52 | virtual void mouseMoveEvent ( QMouseEvent * e ); |
53 | }; |
54 | |
55 | class KMagSelWin : public QWidget |
56 | { |
57 | Q_OBJECT |
58 | |
59 | public: |
60 | |
61 | explicit KMagSelWin ( QWidget * parent = 0, Qt::WFlags f = 0 ); |
62 | |
63 | virtual ~KMagSelWin(); |
64 | |
65 | void setSelRect ( const QRect & selRect ); |
66 | QRect getSelRect (); |
67 | |
68 | public slots: |
69 | |
70 | void startResizing (); |
71 | void titleMoved ( const QPoint & offset ); |
72 | void topLeftResized ( const QPoint & offset ); |
73 | void topRightResized ( const QPoint & offset ); |
74 | void bottomLeftResized ( const QPoint & offset ); |
75 | void bottomRightResized ( const QPoint & offset ); |
76 | |
77 | signals: |
78 | |
79 | void resized(); |
80 | |
81 | protected: |
82 | |
83 | QRect oldSelRect; |
84 | |
85 | KMagSelWinCorner *titleBar; |
86 | KMagSelWinCorner *topLeftCorner; |
87 | KMagSelWinCorner *topRightCorner; |
88 | KMagSelWinCorner *bottomLeftCorner; |
89 | KMagSelWinCorner *bottomRightCorner; |
90 | }; |
91 | |
92 | /** |
93 | * This class stores the selected rectangular area for grabbing. It also displays the |
94 | * rectangular area on demand. |
95 | * |
96 | * @author Original : Michael Forster |
97 | * @author Current : Sarang Lakare |
98 | */ |
99 | class KMagSelRect : public QObject, public QRect |
100 | { |
101 | Q_OBJECT |
102 | |
103 | public: |
104 | explicit KMagSelRect(QWidget *parent=0); |
105 | KMagSelRect(const QPoint &topLeft, const QPoint &bottomRight, |
106 | QWidget *parent=0); |
107 | KMagSelRect(const QPoint &topLeft, const QSize &size, |
108 | QWidget *parent=0); |
109 | KMagSelRect(int left, int top, int width, int height, |
110 | QWidget *selWindowParent=0); |
111 | |
112 | virtual ~KMagSelRect(); |
113 | |
114 | bool visible(); |
115 | |
116 | /// Makes the rectangle always visible |
117 | void alwaysVisible(bool visible=true); |
118 | |
119 | /// Returns true if always visible is set |
120 | bool getAlwaysVisible() const { |
121 | return (m_alwaysVisible); |
122 | } |
123 | |
124 | public slots: |
125 | |
126 | void show(); |
127 | void hide(); |
128 | void update(); |
129 | |
130 | void selWinResized(); |
131 | |
132 | protected: |
133 | |
134 | void init(QWidget *); |
135 | |
136 | QWidget *selWindowParent; |
137 | KMagSelWin *selectionwindow; |
138 | bool m_alwaysVisible; |
139 | |
140 | }; |
141 | |
142 | void setTitleColors (const QColor & title, const QColor & text, const QColor & titleBtn); |
143 | void setFrameSize (int size); |
144 | |
145 | #endif // KMAGSELRECT_H |
146 | |