File indexing completed on 2024-05-12 16:23:34
0001 0002 /*************************************************************************** 0003 * Copyright (C) 2005-2008 by Bjoern Erik Nilsen & Fredrik Berg Kjoelstad* 0004 * bjoern.nilsen@bjoernen.com & fredrikbk@hotmail.com * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, * 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0014 * GNU General Public License for more details. * 0015 * * 0016 * You should have received a copy of the GNU General Public License * 0017 * along with this program; if not, write to the * 0018 * Free Software Foundation, Inc., * 0019 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0020 ***************************************************************************/ 0021 #ifndef MENUFRAME_H 0022 #define MENUFRAME_H 0023 0024 #include <QFrame> 0025 #include <QSpinBox> 0026 #include <QLineEdit> 0027 #include <QMouseEvent> 0028 0029 /** 0030 * A customized GUI menu class for embedded menues which shouldn't be visible 0031 * at all times. The menues are hidden and pops up at various places in the 0032 * gui interface. 0033 * 0034 * This class allow you to create preferences/etc. menues without resorting to 0035 * the modal cover-the-gui menues. 0036 * 0037 * @author Bjoern Erik Nilsen & Fredrik Berg Kjoelstad 0038 */ 0039 class MenuFrame : public QFrame 0040 { 0041 Q_OBJECT 0042 public: 0043 /** 0044 * Creates and sets up the menu frame. 0045 * 0046 * @param parent the parent widget. 0047 * @param name the name of the menu. 0048 */ 0049 MenuFrame(QWidget * parent = 0, const char * name = 0); 0050 0051 /** 0052 * Sets the focus widget to the QSpinBox: focusSpinBox. 0053 * 0054 * NB: One should only use use one of the two setFocusWidget functions. If both 0055 * are used the spinbox will be used. (A bit hacky but saves me from creating 0056 * a custom(/messy!) class hierarchy and gives me time to go out and have 0057 * a few beers tonight). 0058 * 0059 * @param focusSpinBox the focuswidget of this menu. 0060 */ 0061 void setFocusWidget(QSpinBox * focusSpinBox = 0); 0062 0063 0064 /** 0065 * Sets the focus widget to the QLineEdit: focusSpinBox. 0066 * 0067 * NB: One should only use use one of the two setFocusWidget functions. If both 0068 * are used the spinbox will be used. (A bit hacky but saves me from creating 0069 * a custom(/messy!) class hierarchy and gives me time to go out and have 0070 * a few beers tonight). 0071 * 0072 * @param focusLineEdit the focuswidget of this menu. 0073 */ 0074 void setFocusWidget(QLineEdit * focusLineEdit = 0); 0075 0076 protected: 0077 /** 0078 * Overloaded function to intercept when the user press the mouse inside 0079 * the menu. (So that the mainwindow doesn't get the event). 0080 * @param e information about the event. 0081 */ 0082 void mousePressEvent( QMouseEvent * e); 0083 0084 private: 0085 QSpinBox *focusSpinBox; 0086 QLineEdit *focusLineEdit; 0087 0088 public slots: 0089 /** 0090 * Opens the menu. 0091 */ 0092 virtual void open(); 0093 0094 /** 0095 * Closes the menu and turns the focus to the newFocusWidget. 0096 * @param newFocusWidget the widget who will receive the focus after this menu 0097 * closes. 0098 */ 0099 virtual void close(QWidget * newFocusWidget); 0100 }; 0101 0102 #endif