File indexing completed on 2024-05-12 16:36:45
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2009 Jean-Nicolas Artaud <jeannicolasartaud@gmail.com> 0003 * Copyright (C) 2009 Alexia Allanic <alexia_allanic@yahoo.fr> 0004 * Copyright (C) 2009 Jérémy Lugagne <jejewindsurf@hotmail.com> 0005 * Copyright (C) 2009 Johann Hingue <yoan1703@hotmail.fr> 0006 * Copyright (C) 2009 Thorsten Zachmann <zachmann@kde.org> 0007 * 0008 * This library is free software; you can redistribute it and/or 0009 * modify it under the terms of the GNU Library General Public 0010 * License as published by the Free Software Foundation; either 0011 * version 2 of the License, or (at your option) any later version. 0012 * 0013 * This library is distributed in the hope that it will be useful, 0014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 * Library General Public License for more details. 0017 * 0018 * You should have received a copy of the GNU Library General Public License 0019 * along with this library; see the file COPYING.LIB. If not, write to 0020 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0021 * Boston, MA 02110-1301, USA. 0022 */ 0023 #ifndef KPRPRESENTATIONDRAWWIDGET_H 0024 #define KPRPRESENTATIONDRAWWIDGET_H 0025 0026 #include "KPrPresentationToolEventForwarder.h" 0027 0028 #include <QLabel> 0029 #include <QVarLengthArray> 0030 0031 class QAction; 0032 0033 struct KPrPresentationDrawPath 0034 { 0035 QVector<QPointF> points; 0036 QColor color; 0037 int size; 0038 }; 0039 0040 Q_DECLARE_TYPEINFO(KPrPresentationDrawPath, Q_MOVABLE_TYPE); 0041 0042 0043 class KPrPresentationDrawWidget : public KPrPresentationToolEventForwarder 0044 { 0045 Q_OBJECT 0046 0047 public : 0048 explicit KPrPresentationDrawWidget(KoPACanvasBase *canvas); 0049 ~KPrPresentationDrawWidget() override; 0050 0051 /** Draw on the Presentation */ 0052 void paintEvent( QPaintEvent * event ) override; 0053 0054 /** Get all the mouse event needed to paint */ 0055 void mouseMoveEvent( QMouseEvent * e ) override; 0056 void mousePressEvent( QMouseEvent * e ) override; 0057 void mouseReleaseEvent( QMouseEvent * e ) override; 0058 0059 /** Popup menu for colors and sizes */ 0060 void contextMenuEvent( QContextMenuEvent * event ) override; 0061 0062 public Q_SLOTS: 0063 void updateColor( QAction * ); 0064 void updateColor( const QString &color ); 0065 void updateSize( QAction * ); 0066 void updateSize( int size ); 0067 0068 private : 0069 QIcon buildIconColor( const QColor& ); 0070 QIcon buildIconSize( int ); 0071 QAction* buildActionColor( const QColor&, const QString& ); 0072 QAction* buildActionSize( int ); 0073 0074 bool m_draw; 0075 int m_penSize; 0076 QColor m_penColor; 0077 QVector<KPrPresentationDrawPath> m_pointVectors; 0078 }; 0079 0080 #endif /* KPRPRESENTATIONDRAWWIDGET_H */