home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / KoContainerHandler.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-30  |  3.7 KB  |  138 lines

  1. /* This file is part of the KDE project
  2.    Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License as published by the Free Software Foundation; either
  7.    version 2 of the License, or (at your option) any later version.
  8.  
  9.    This library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Library General Public License
  15.    along with this library; see the file COPYING.LIB.  If not, write to
  16.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.  * Boston, MA 02110-1301, USA.
  18. */
  19.  
  20. #ifndef HANDLER_H
  21. #define HANDLER_H
  22.  
  23. #include <qobject.h>
  24. #include <KoDocumentChild.h>
  25.  
  26. class QWMatrix;
  27.  
  28. class KoView;
  29. class KoPartResizeHandlerPrivate;
  30. class KoPartMoveHandlerPrivate;
  31.  
  32. /**
  33.  * @brief An abstract base class for event handlers.
  34.  *
  35.  * The idea of an event handler is that it is created for a
  36.  * certain purpose, for example moving or resizing of a part.
  37.  * Once that action is finished, the handler will destroy
  38.  * itself.
  39.  *
  40.  * This design pattern helps you to keep your event filters
  41.  * and your mousePressEvent, mouseMoveEvent etc. methods clean.
  42.  */
  43. class KOFFICECORE_EXPORT KoEventHandler : public QObject
  44. {
  45.     Q_OBJECT
  46. public:
  47.     KoEventHandler( QObject* target );
  48.     ~KoEventHandler();
  49.  
  50.     QObject* target();
  51.  
  52. private:
  53.     QObject* m_target;
  54. };
  55.  
  56. /**
  57.  * Used by @ref KoContainerHandler internally to handle resizing of
  58.  * embedded documents.
  59.  */
  60. class KoPartResizeHandler : public KoEventHandler
  61. {
  62.     Q_OBJECT
  63. public:
  64.     KoPartResizeHandler( QWidget* widget, const QWMatrix& matrix, KoView* view, KoChild* child,
  65.                        KoChild::Gadget gadget, const QPoint& point );
  66.     ~KoPartResizeHandler();
  67.  
  68. protected:
  69.     void repaint(QRegion &rgn);
  70.     bool eventFilter( QObject*, QEvent* );
  71.  
  72. private:
  73.     KoPartResizeHandlerPrivate *d;
  74. };
  75.  
  76. /**
  77.  * Used by @ref KoContainerHandler internally to handle moving of
  78.  * embedded documents.
  79.  */
  80. class KoPartMoveHandler : public KoEventHandler
  81. {
  82.     Q_OBJECT
  83. public:
  84.     KoPartMoveHandler( QWidget* widget, const QWMatrix& matrix, KoView* view, KoChild* child,
  85.                      const QPoint& point );
  86.     ~KoPartMoveHandler();
  87.  
  88. protected:
  89.     bool eventFilter( QObject*, QEvent* );
  90.  
  91. private:
  92.     KoPartMoveHandlerPrivate *d;
  93. };
  94.  
  95. /**
  96.  * This class can handle moving and resizing of embedded
  97.  * documents in your class derived from @ref KoView.
  98.  *
  99.  * Just create one instance per view of this class and parts
  100.  * will magically be moved around on your document.
  101.  *
  102.  * This class acts like an event filter on your view, so the
  103.  * mouse events which are used for parts moving and resizing
  104.  * will never show up in your view.
  105.  *
  106.  * @see KoPartMoveHandlerPrivate
  107.  * @see KoPartResizeHandlerPrivate
  108.  */
  109. class KOFFICECORE_EXPORT KoContainerHandler : public KoEventHandler
  110. {
  111.     Q_OBJECT
  112. public:
  113.     KoContainerHandler( KoView* view, QWidget* widget );
  114.     ~KoContainerHandler();
  115.  
  116. signals:
  117.     /**
  118.      * Emitted if the user wants to open the popup menu for some
  119.      * child object.
  120.      */
  121.     void popupMenu( KoChild*, const QPoint& global_pos );
  122.  
  123.     /**
  124.       * Emitted if the user pressed the delete key whilst a child was selected
  125.       */
  126.     void deleteChild( KoChild* );
  127.  
  128. protected:
  129.     bool eventFilter( QObject*, QEvent* );
  130.  
  131. private:
  132.     /// This is a little helper function to get rid of some duplicated code
  133.     KoChild *child(KoChild::Gadget &gadget, QPoint &pos, const QMouseEvent *ev);
  134.     KoView* m_view;
  135. };
  136.  
  137. #endif
  138.