File indexing completed on 2024-05-12 16:37:10
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2005-2007 Thomas Zander <zander@kde.org> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Library General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Library General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Library General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA 0018 */ 0019 0020 #ifndef KWGUI_H 0021 #define KWGUI_H 0022 0023 0024 #include <QWidget> 0025 0026 class KWView; 0027 class KWCanvas; 0028 class KoCanvasController; 0029 class KoRuler; 0030 0031 class QMouseEvent; 0032 0033 /** 0034 * This class is a widget that is the sole widget under a KWView instance 0035 * separating concerns. 0036 */ 0037 class KWGui : public QWidget 0038 { 0039 Q_OBJECT 0040 0041 public: 0042 /** 0043 * Create new gui widget. 0044 * @param viewMode the KWViewMode::type() string to indicate the view mode the canvas 0045 * will use to show the content 0046 * @param parent the parent view 0047 */ 0048 KWGui(const QString &viewMode, KWView *parent); 0049 ~KWGui() override; 0050 0051 /** 0052 * Return the canvas child. 0053 * @return the canvas child. 0054 */ 0055 KWCanvas *canvas() const { 0056 return m_canvas; 0057 } 0058 /** 0059 * return the width of the canvas that is fully shown and not obscured behind scrollbars. 0060 * @return the amount of pixels visible 0061 */ 0062 int visibleWidth() const; 0063 /** 0064 * return the height of the canvas that is fully shown and not obscured behind scrollbars. 0065 * @return the amount of pixels visible 0066 */ 0067 int visibleHeight() const; 0068 0069 /** 0070 * return the height of the canvas that is fully shown and not obscured behind scrollbars. 0071 * @return the amount of pixels visible 0072 */ 0073 QSize viewportSize() const; 0074 0075 /// return if the there currently is a horizontal scrolBar visible 0076 bool horizontalScrollBarVisible(); 0077 0078 /** 0079 * Request a repaint of the rulers. 0080 */ 0081 void updateRulers() const; 0082 0083 /// return the canvasController that wraps this view 0084 KoCanvasController *canvasController() const { 0085 return m_canvasController; 0086 } 0087 0088 protected : 0089 void mouseMoveEvent(QMouseEvent *e) override; 0090 0091 private Q_SLOTS: 0092 void pageSetupChanged(); 0093 void updateMousePos(const QPoint &point); 0094 void shapeSelectionChanged(); 0095 void setupUnitActions(); 0096 0097 private: 0098 KWView *m_view; 0099 KWCanvas *m_canvas; 0100 KoRuler *m_horizontalRuler; 0101 KoRuler *m_verticalRuler; 0102 0103 KoCanvasController *m_canvasController; 0104 }; 0105 0106 #endif