1 /* 2 * Stellarium 3 * Copyright (C) 2008 Guillaume Chereau 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. 18 */ 19 20 21 #ifndef DIALOG_HPP 22 #define DIALOG_HPP 23 24 #include <QWidget> 25 #include <QFrame> 26 #include <QMouseEvent> 27 28 //! \class BarFrame 29 //! A title bar control used in windows derived from StelDialog. 30 //! 31 //! As window classes derived from StelDialog are basic QWidgets, they have no 32 //! title bar. A BarFrame control needs to be used in each window's design 33 //! to allow the user to move them. 34 //! 35 //! Typically, the frame should contain a centered label displaying the window's 36 //! title and a button for closing the window (connected to the 37 //! StelDialog::close() slot). 38 //! 39 //! To use the default Stellarium style for title bars, the BarFrame object of a 40 //! given window should be named "TitleBar". See the normalStyle.css file for 41 //! the style sheet description. 42 class BarFrame : public QFrame 43 { 44 Q_OBJECT 45 public: 46 QPoint mousePos; 47 BarFrame(QWidget * parent)48 BarFrame(QWidget* parent) : QFrame(parent), moving(false) {} 49 50 virtual void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; 51 virtual void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; 52 virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; 53 signals: 54 // should be connected to the StelDialog in createDialogContents() 55 void movedTo(QPoint newPosition); 56 protected: 57 bool moving; 58 }; 59 60 class ResizeFrame : public QFrame 61 { 62 Q_OBJECT 63 public: 64 QPoint mousePos; 65 ResizeFrame(QWidget * parent)66 ResizeFrame(QWidget* parent) : QFrame(parent) {} 67 mousePressEvent(QMouseEvent * event)68 virtual void mousePressEvent(QMouseEvent *event) { 69 mousePos = event->pos(); 70 } 71 virtual void mouseMoveEvent(QMouseEvent *event); 72 }; 73 74 75 #endif // DIALOG_HPP 76