added all files
[ffqwlibrary] / libffqw-n810-1.0 / sources / ffscrollarea.h
1 /*\r
2           GNU GENERAL PUBLIC LICENSE\r
3                        Version 3, 29 June 2007\r
4 \r
5  Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\r
6  Everyone is permitted to copy and distribute verbatim copies\r
7  of this license document, but changing it is not allowed.\r
8 \r
9                             Preamble\r
10 \r
11   The GNU General Public License is a free, copyleft license for\r
12 software and other kinds of works.\r
13 \r
14   The licenses for most software and other practical works are designed\r
15 to take away your freedom to share and change the works.  By contrast,\r
16 the GNU General Public License is intended to guarantee your freedom to\r
17 share and change all versions of a program--to make sure it remains free\r
18 software for all its users.  We, the Free Software Foundation, use the\r
19 GNU General Public License for most of our software; it applies also to\r
20 any other work released this way by its authors.  You can apply it to\r
21 your programs, too.\r
22 \r
23   When we speak of free software, we are referring to freedom, not\r
24 price.  Our General Public Licenses are designed to make sure that you\r
25 have the freedom to distribute copies of free software (and charge for\r
26 them if you wish), that you receive source code or can get it if you\r
27 want it, that you can change the software or use pieces of it in new\r
28 free programs, and that you know you can do these things.\r
29 \r
30   To protect your rights, we need to prevent others from denying you\r
31 these rights or asking you to surrender the rights.  Therefore, you have\r
32 certain responsibilities if you distribute copies of the software, or if\r
33 you modify it: responsibilities to respect the freedom of others.\r
34 \r
35   For example, if you distribute copies of such a program, whether\r
36 gratis or for a fee, you must pass on to the recipients the same\r
37 freedoms that you received.  You must make sure that they, too, receive\r
38 or can get the source code.  And you must show them these terms so they\r
39 know their rights.\r
40 \r
41   Developers that use the GNU GPL protect your rights with two steps:\r
42 (1) assert copyright on the software, and (2) offer you this License\r
43 giving you legal permission to copy, distribute and/or modify it.\r
44 \r
45   For the developers' and authors' protection, the GPL clearly explains\r
46 that there is no warranty for this free software.  For both users' and\r
47 authors' sake, the GPL requires that modified versions be marked as\r
48 changed, so that their problems will not be attributed erroneously to\r
49 authors of previous versions.\r
50 \r
51   Some devices are designed to deny users access to install or run\r
52 modified versions of the software inside them, although the manufacturer\r
53 can do so.  This is fundamentally incompatible with the aim of\r
54 protecting users' freedom to change the software.  The systematic\r
55 pattern of such abuse occurs in the area of products for individuals to\r
56 use, which is precisely where it is most unacceptable.  Therefore, we\r
57 have designed this version of the GPL to prohibit the practice for those\r
58 products.  If such problems arise substantially in other domains, we\r
59 stand ready to extend this provision to those domains in future versions\r
60 of the GPL, as needed to protect the freedom of users.\r
61 \r
62   Finally, every program is threatened constantly by software patents.\r
63 States should not allow patents to restrict development and use of\r
64 software on general-purpose computers, but in those that do, we wish to\r
65 avoid the special danger that patents applied to a free program could\r
66 make it effectively proprietary.  To prevent this, the GPL assures that\r
67 patents cannot be used to render the program non-free.\r
68 \r
69   The precise terms and conditions for copying, distribution and\r
70 modification follow.\r
71 \r
72 http://www.gnu.org/licenses/gpl-3.0.txt\r
73 */\r
74 /**\r
75  * @file ffscrollarea.h\r
76  * @brief Contains a necessary class declaration.\r
77  *\r
78  * @author ComArch S.A.\r
79  * @date 2009.09.20\r
80  * @version 1.0\r
81  */\r
82 \r
83 #ifndef QFFSCROLLAREA_H\r
84 #define QFFSCROLLAREA_H\r
85 \r
86 #include <QAbstractScrollArea>\r
87 #include <QScrollArea>\r
88 #include <QMouseEvent>\r
89 #include <QEvent>\r
90 #include <QDragMoveEvent>\r
91 #include <QPainter>\r
92 #include <QTimer>\r
93 \r
94 static const float DEFAULT_SLOWING_DOWN_RATE = 0.85;\r
95 static const int   DEFAULT_POSIOTION_SUMPLING_TIME = 80;\r
96 static const int   DEFAULT_KINETIC_ANIMATION_TIME  = 50;\r
97 static const int   DEFAULT_MIN_MOTION_LENGTH = 20;\r
98 \r
99 /**\r
100  * @author ComArch S.A.\r
101  * @date 2009.09.20\r
102  * @version 1.0\r
103  *\r
104  * @brief A class providing a scrolling view onto another widget.\r
105  */\r
106 class FFScrollArea : public QScrollArea\r
107 {\r
108         Q_OBJECT\r
109 \r
110 public:\r
111         FFScrollArea(QWidget* parent = 0);\r
112         ~FFScrollArea();\r
113         bool eventFilter(QObject * o, QEvent *event);\r
114         void setWidget(QWidget* widget);\r
115 \r
116         void  init();\r
117         float getSlowingDownRate() const;\r
118         void  setSlowingDownRate(float slowingDownRate_);\r
119         int   getKineticAnimationTime() const;\r
120         void  setKineticAnimationTime(int kineticAnimationTime_);\r
121         int   getPostionSumplingTime() const;\r
122         void  setPostionSumplingTime(int postionSumplingTime_);\r
123         int   getMinMotionLength() const;\r
124         void  setMinMotionLength(int minMotionLength_);\r
125 \r
126 private:\r
127         bool    moved; ///< is true when widget on scrolarea is moved\r
128         bool    animate; ///< is true when animation is active\r
129 \r
130         int     x; ///< variable to storing cursor global position (X axis)\r
131         int     y; ///< variable to storing cursor global position (Y axis)\r
132         int     postionSumplingTime_; ///< period of position sampling\r
133         int     kineticAnimationTime_; ///< period of one animation's frame\r
134         int     minMotionLength_; ///< is motion is shorter then this value moved is false\r
135         float   slowingDownRate_; ///< rate of animation slowing\r
136 \r
137         QPointF pos;      ///< cursor position when button was released\r
138         QPointF speed;    ///< contains motion speed value during kinetic animation\r
139         QPointF movement; ///< way's length traveled during mousemoveevent\r
140         QPointF prevPos;  ///< is used to moving when area is pressed\r
141         QPointF oldPos;   ///< is used to kinetic\r
142         QTimer  timerPos; ///< timer is used to sampling cursor position\r
143         QTimer  timerAnim; ///< timer is used to kinetic animation\r
144 \r
145         void installFilterRecursive(QWidget* widget);\r
146 \r
147 private slots:\r
148         void updatePos();\r
149         void animation();\r
150 };\r
151 \r
152 #endif // QFFSCROLLAREA_H\r