F:/KPlato/koffice/libs/kofficeui/KoShapeSelector.h

Aller à la documentation de ce fichier.
00001 /*
00002  * Copyright (C) 2006 Thomas Zander <zander@kde.org>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this library; see the file COPYING.LIB.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #ifndef KOSHAPESELECTOR_H
00021 #define KOSHAPESELECTOR_H
00022 
00023 #include <KoCanvasBase.h>
00024 #include <KoViewConverter.h>
00025 #include <koffice_export.h>
00026 
00027 #include <QDockWidget>
00028 #include <QRectF>
00029 
00030 class KoTool;
00031 class KoShape;
00032 class KoViewConverter;
00033 class KCommand;
00034 class KoCanvasController;
00035 class KoShapeManager;
00036 class QKeyEvent;
00037 class QPainter;
00038 
00039 class KOFFICEUI_EXPORT KoShapeSelector : public QDockWidget {
00040     Q_OBJECT
00041 public:
00042     KoShapeSelector(QWidget *parent);
00043     ~KoShapeSelector();
00044 
00045 private slots:
00046     void itemSelected();
00047     void loadShapeTypes();
00048 
00049 private:
00050     void add(KoShape *item);
00051 
00052 private:
00054     class DummyViewConverter : public KoViewConverter {
00055         QPointF documentToView (const QPointF &documentPoint) const;
00056         QPointF viewToDocument (const QPointF &viewPoint) const;
00057         QRectF documentToView (const QRectF &documentRect) const;
00058         QRectF viewToDocument (const QRectF &viewRect) const;
00059         void zoom (double *zoomX, double *zoomY) const;
00060         double documentToViewX (double documentX) const;
00061         double documentToViewY (double documentY) const;
00062         double viewToDocumentX (double viewX) const;
00063         double viewToDocumentY (double viewY) const;
00064     };
00065 
00067     class Canvas : public QWidget, public KoCanvasBase {
00068         public:
00069             Canvas(KoShapeSelector *parent);
00070             void gridSize (double *horizontal, double *vertical) const;
00071             bool snapToGrid() const { return false; }
00072             void addCommand (KCommand *command, bool execute=true);
00073             KoShapeManager * shapeManager () const { return m_parent->m_shapeManager; }
00074             void updateCanvas (const QRectF &rc);
00075             KoToolProxy *toolProxy () { return m_toolProxy; }
00076             KoViewConverter * viewConverter() { return &m_converter; }
00077             QWidget *canvasWidget () { return m_parent; }
00078             KoUnit::Unit unit() { return KoUnit::U_MM; }
00079 
00080         protected: // event handlers
00081             void mouseMoveEvent(QMouseEvent *e);
00082             void mousePressEvent(QMouseEvent *e);
00083             void mouseReleaseEvent(QMouseEvent *e);
00084             void keyReleaseEvent (QKeyEvent *e);
00085             void keyPressEvent( QKeyEvent *e );
00086             void paintEvent(QPaintEvent * e);
00087             bool event(QEvent *e);
00088 
00089         private:
00090             DummyViewConverter m_converter;
00091             KoShapeSelector *m_parent;
00092             KoToolProxy * m_toolProxy;
00093             KoTool * m_tool;
00094     };
00095 
00096     friend class Canvas;
00097 
00098     KoShapeManager *m_shapeManager;
00099     Canvas *m_canvas;
00100 };
00101 
00102 #endif

Généré le Wed Nov 22 23:41:05 2006 pour KPlato par  doxygen 1.5.1-p1