added all files
[ffqwlibrary] / libffqw-n810-1.0 / sources / ffscrollarea.h
diff --git a/libffqw-n810-1.0/sources/ffscrollarea.h b/libffqw-n810-1.0/sources/ffscrollarea.h
new file mode 100644 (file)
index 0000000..1045c0e
--- /dev/null
@@ -0,0 +1,152 @@
+/*\r
+         GNU GENERAL PUBLIC LICENSE\r
+                       Version 3, 29 June 2007\r
+\r
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\r
+ Everyone is permitted to copy and distribute verbatim copies\r
+ of this license document, but changing it is not allowed.\r
+\r
+                            Preamble\r
+\r
+  The GNU General Public License is a free, copyleft license for\r
+software and other kinds of works.\r
+\r
+  The licenses for most software and other practical works are designed\r
+to take away your freedom to share and change the works.  By contrast,\r
+the GNU General Public License is intended to guarantee your freedom to\r
+share and change all versions of a program--to make sure it remains free\r
+software for all its users.  We, the Free Software Foundation, use the\r
+GNU General Public License for most of our software; it applies also to\r
+any other work released this way by its authors.  You can apply it to\r
+your programs, too.\r
+\r
+  When we speak of free software, we are referring to freedom, not\r
+price.  Our General Public Licenses are designed to make sure that you\r
+have the freedom to distribute copies of free software (and charge for\r
+them if you wish), that you receive source code or can get it if you\r
+want it, that you can change the software or use pieces of it in new\r
+free programs, and that you know you can do these things.\r
+\r
+  To protect your rights, we need to prevent others from denying you\r
+these rights or asking you to surrender the rights.  Therefore, you have\r
+certain responsibilities if you distribute copies of the software, or if\r
+you modify it: responsibilities to respect the freedom of others.\r
+\r
+  For example, if you distribute copies of such a program, whether\r
+gratis or for a fee, you must pass on to the recipients the same\r
+freedoms that you received.  You must make sure that they, too, receive\r
+or can get the source code.  And you must show them these terms so they\r
+know their rights.\r
+\r
+  Developers that use the GNU GPL protect your rights with two steps:\r
+(1) assert copyright on the software, and (2) offer you this License\r
+giving you legal permission to copy, distribute and/or modify it.\r
+\r
+  For the developers' and authors' protection, the GPL clearly explains\r
+that there is no warranty for this free software.  For both users' and\r
+authors' sake, the GPL requires that modified versions be marked as\r
+changed, so that their problems will not be attributed erroneously to\r
+authors of previous versions.\r
+\r
+  Some devices are designed to deny users access to install or run\r
+modified versions of the software inside them, although the manufacturer\r
+can do so.  This is fundamentally incompatible with the aim of\r
+protecting users' freedom to change the software.  The systematic\r
+pattern of such abuse occurs in the area of products for individuals to\r
+use, which is precisely where it is most unacceptable.  Therefore, we\r
+have designed this version of the GPL to prohibit the practice for those\r
+products.  If such problems arise substantially in other domains, we\r
+stand ready to extend this provision to those domains in future versions\r
+of the GPL, as needed to protect the freedom of users.\r
+\r
+  Finally, every program is threatened constantly by software patents.\r
+States should not allow patents to restrict development and use of\r
+software on general-purpose computers, but in those that do, we wish to\r
+avoid the special danger that patents applied to a free program could\r
+make it effectively proprietary.  To prevent this, the GPL assures that\r
+patents cannot be used to render the program non-free.\r
+\r
+  The precise terms and conditions for copying, distribution and\r
+modification follow.\r
+\r
+http://www.gnu.org/licenses/gpl-3.0.txt\r
+*/\r
+/**\r
+ * @file ffscrollarea.h\r
+ * @brief Contains a necessary class declaration.\r
+ *\r
+ * @author ComArch S.A.\r
+ * @date 2009.09.20\r
+ * @version 1.0\r
+ */\r
+\r
+#ifndef QFFSCROLLAREA_H\r
+#define QFFSCROLLAREA_H\r
+\r
+#include <QAbstractScrollArea>\r
+#include <QScrollArea>\r
+#include <QMouseEvent>\r
+#include <QEvent>\r
+#include <QDragMoveEvent>\r
+#include <QPainter>\r
+#include <QTimer>\r
+\r
+static const float DEFAULT_SLOWING_DOWN_RATE = 0.85;\r
+static const int   DEFAULT_POSIOTION_SUMPLING_TIME = 80;\r
+static const int   DEFAULT_KINETIC_ANIMATION_TIME  = 50;\r
+static const int   DEFAULT_MIN_MOTION_LENGTH = 20;\r
+\r
+/**\r
+ * @author ComArch S.A.\r
+ * @date 2009.09.20\r
+ * @version 1.0\r
+ *\r
+ * @brief A class providing a scrolling view onto another widget.\r
+ */\r
+class FFScrollArea : public QScrollArea\r
+{\r
+       Q_OBJECT\r
+\r
+public:\r
+       FFScrollArea(QWidget* parent = 0);\r
+       ~FFScrollArea();\r
+       bool eventFilter(QObject * o, QEvent *event);\r
+       void setWidget(QWidget* widget);\r
+\r
+       void  init();\r
+       float getSlowingDownRate() const;\r
+       void  setSlowingDownRate(float slowingDownRate_);\r
+       int   getKineticAnimationTime() const;\r
+       void  setKineticAnimationTime(int kineticAnimationTime_);\r
+       int   getPostionSumplingTime() const;\r
+       void  setPostionSumplingTime(int postionSumplingTime_);\r
+       int   getMinMotionLength() const;\r
+       void  setMinMotionLength(int minMotionLength_);\r
+\r
+private:\r
+       bool    moved; ///< is true when widget on scrolarea is moved\r
+       bool    animate; ///< is true when animation is active\r
+\r
+       int     x; ///< variable to storing cursor global position (X axis)\r
+       int     y; ///< variable to storing cursor global position (Y axis)\r
+       int     postionSumplingTime_; ///< period of position sampling\r
+       int     kineticAnimationTime_; ///< period of one animation's frame\r
+       int     minMotionLength_; ///< is motion is shorter then this value moved is false\r
+       float   slowingDownRate_; ///< rate of animation slowing\r
+\r
+       QPointF pos;      ///< cursor position when button was released\r
+       QPointF speed;    ///< contains motion speed value during kinetic animation\r
+       QPointF movement; ///< way's length traveled during mousemoveevent\r
+       QPointF prevPos;  ///< is used to moving when area is pressed\r
+       QPointF oldPos;   ///< is used to kinetic\r
+       QTimer  timerPos; ///< timer is used to sampling cursor position\r
+       QTimer  timerAnim; ///< timer is used to kinetic animation\r
+\r
+       void installFilterRecursive(QWidget* widget);\r
+\r
+private slots:\r
+       void updatePos();\r
+       void animation();\r
+};\r
+\r
+#endif // QFFSCROLLAREA_H\r