kscribbleview.h

KDE Anwendungs Tutorials: Der KDE Anwendungs-Tutorial Leitfaden für die Integrierte Entwicklungsumgebung KDevelop
Zurück | Anhang A. KScribble-1.0 Beispiel Quellcode | Vor

# A.7. kscribbleview.h

       1 /***************************************************************************
       2                           kscribbleview.h  -  description
       3                              -------------------
       4     begin                : Mon Jan 31 11:05:05 CET 2000
       5     copyright            : (C) 2000 by Ralf Nolden
       6     email                : Ralf.Nolden@post.rwth-aachen.de
       7  ***************************************************************************/
       8
       9 /***************************************************************************
      10  *                                                                         *
      11  *   This program is free software; you can redistribute it and/or modify  *
      12  *   it under the terms of the GNU General Public License as published by  *
      13  *   the Free Software Foundation; either version 2 of the License, or     *
      14  *   (at your option) any later version.                                   *
      15  *                                                                         *
      16  ***************************************************************************/
      17
      18 #ifndef KSCRIBBLEVIEW_H
      19 #define KSCRIBBLEVIEW_H
      20
      21 #ifdef HAVE_CONFIG_H
      22 #include <config.h>
      23 #endif
      24
      25 // include files for Qt
      26 #include <qscrollview.h>
      27 #include <kpixmap.h>
      28
      29 class KScribbleDoc;
      30
      31 /** The KScribbleView class provides the view widget for the document instance connected to it and is displayed
      32  * as a MDI child window in the main view area of the KScribbleApp class instance. The KScribbleApp
      33  * class also has an eventFilter()  method that gets installed on every KScribbleView instance to
      34  * control events of the type QEvent::Close.The document connected to the view instance keeps a list
      35  * of all view that represent the document contents as there can be more than one view. Views get created in
      36  * KScribbleApp::createClient() and automatically added to the list of views.
      37  * The KScribbleView class inherits QWidget as a base. Another possible inheritance besides specialized
      38  + widgets could be QMainWindow so that you can easily set up the main area of your view by setting another view
      39  * as main widget (QMainWindow::setMainWidget() ).
      40  * NOTE: The close event always has to be empty (DON`T CALL QWidget::closeEvent(e) in closeEvent())
      41  * because the installed event filter can only manage a forward implementation. If the QCloseEvent
      42  * is received by the KScribbleView, the overwritten event handler has to do nothing as the eventFilter
      43  * has set accept() or ignore() already. If QWidget::closeEvent() is called again, the default event
      44  * handler will accept the close event and the window gets destroyed even if the installed eventFilter
      45  * has set the event to be ignored.
      46  * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
      47  * @version KDevelop version 1.1 code generation
      48  */
      49 class KScribbleView : public QScrollView
      50 {
      51   Q_OBJECT
      52
      53   friend KScribbleDoc;
      54
      55   public:
      56     /** Constructor for the view
      57       * @param pDoc  your document instance that the view represents. Create a document
      58       * before calling the constructor or connect an already existing document to a new MDI child widget.*/
      59     KScribbleView(KScribbleDoc* pDoc, QWidget* parent, const char *name, int wflags);
      60     /** Destructor for the main view */
      61     ~KScribbleView();
      62     /** returns a pointer to the document connected to the view*/
      63     KScribbleDoc *getDocument() const;
      64     /** gets called to redraw the document contents if it has been modified */
      65     void update(KScribbleView* pSender);
      66     /** contains the implementation for printing functionality and gets called by KScribbleApp::slotFilePrint() */
      67     void print(QPrinter *pPrinter);
      68     /** cuts out a selection */
      69     void cutSelection();
      70     /** copies a selection to the clipboard */
      71     void copySelection();
      72     /** pastes the clipboard contents to a selection that can be inserted into the picture */
      73     void pasteSelection();
      74
      75   protected:
      76
      77     /** overwritten QWidget::closeEvent() to catch closing views. Does nothing, as the closeEvents for
      78     * KScribbleView's are processed by KScribbleApp::eventFilter(), so this overwitten closeEvent is necessary
      79     * and has to be empty. Don't overwrite this method !
      80     */
      81     virtual void closeEvent(QCloseEvent* );
      82     /** overwritten to interpret key events for scrollbars */
      83     virtual void keyPressEvent( QKeyEvent* );
      84     /** changed from mousePressEvent() overwriting QScrollView method */
      85     virtual void viewportMousePressEvent( QMouseEvent* );
      86     /** changed from mouseReleaseEvent() overwriting QScrollView method */
      87     virtual void viewportMouseReleaseEvent( QMouseEvent* );
      88     /** On paste actions inserts the pasted clipboard contents */
      89     virtual void viewportMouseDoubleClickEvent(QMouseEvent* e);
      90     /** changed from mouseMoveEvent() overwriting QScrollView method */
      91     virtual void viewportMouseMoveEvent( QMouseEvent* );
      92     /** changed from resizeEvent() overwriting QScrollView method */
      93 //    virtual void viewportResizeEvent( QResizeEvent* );
      94     /** changed from paintEvent() overwriting QScrollView method */
      95     virtual void viewportPaintEvent( QPaintEvent* );
      96
      97     virtual void viewportDragEnterEvent ( QDragEnterEvent * );
      98
      99     virtual void viewportDragMoveEvent ( QDragMoveEvent * );
     100
     101     virtual void viewportDragLeaveEvent ( QDragLeaveEvent * );
     102
     103     virtual void viewportDropEvent ( QDropEvent * );
     104
     105     /** the document instance */
     106     KScribbleDoc *doc;
     107
     108   private:
     109     KPixmap tmp;
     110     QRect select;
     111     QClipboard *cb;
     112     enum Action{IDLE=0, DRAW, SELECT, PASTE, DRAG} action;
     113 };
     114
     115 #endif // KSCRIBBLEVIEW_H

Zurück | Anfang | Vor
kscribbledoc.cpp | Hoch | kscribbleview.cpp