summaryrefslogtreecommitdiffstats
path: root/kmag/kmagselrect.h
blob: 5da665febdce1ad1ec45d0347c2a3036a6997565 (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
147
148
149
/***************************************************************************
                          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>

// TQt includes
#include <tqrect.h>
#include <tqwidget.h>
#include <tqlabel.h>

class KMagSelWinCorner : public TQLabel
{
    TQ_OBJECT
  

public:

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

    virtual ~KMagSelWinCorner();

signals:

    void startResizing ();
    void resized ( TQPoint offset );

protected:

    TQPoint oldPos;

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

class KMagSelWin : public TQWidget
{
    TQ_OBJECT
  

public:

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

    virtual ~KMagSelWin();

    void setSelRect ( TQRect selRect );
    TQRect getSelRect ();

public slots:

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

signals:

    void resized();

protected:

    TQRect 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 TQObject, public TQRect
{
    TQ_OBJECT
  

public:
    KMagSelRect(TQWidget *parent=0);
    KMagSelRect(const TQPoint &topLeft, const TQPoint &bottomRight,
      TQWidget *parent=0);
    KMagSelRect(const TQPoint &topLeft, const TQSize &size,
      TQWidget *parent=0);
    KMagSelRect(int left, int top, int width, int height,
      TQWidget *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(TQWidget *);

    TQWidget *selWindowParent;
    KMagSelWin *selectionwindow;
    bool m_alwaysVisible;

};

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

#endif // KMAGSELRECT_H