MyWidget.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : MyWidget.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006 by Ion Vasilief,
00006                            Tilman Hoener zu Siederdissen,
00007                            Knut Franke
00008     Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net,
00009                            knut.franke*gmx.de
00010     Description          : MDI window widget
00011 
00012  ***************************************************************************/
00013 
00014 /***************************************************************************
00015  *                                                                         *
00016  *  This program is free software; you can redistribute it and/or modify   *
00017  *  it under the terms of the GNU General Public License as published by   *
00018  *  the Free Software Foundation; either version 2 of the License, or      *
00019  *  (at your option) any later version.                                    *
00020  *                                                                         *
00021  *  This program is distributed in the hope that it will be useful,        *
00022  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00023  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00024  *  GNU General Public License for more details.                           *
00025  *                                                                         *
00026  *   You should have received a copy of the GNU General Public License     *
00027  *   along with this program; if not, write to the Free Software           *
00028  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00029  *   Boston, MA  02110-1301  USA                                           *
00030  *                                                                         *
00031  ***************************************************************************/
00032 #ifndef WIDGET_H
00033 #define WIDGET_H
00034 
00035 #include <QWidget>
00036 class QEvent;
00037 class QCloseEvent;
00038 class QString;
00039 class Folder;
00040 
00052 class MyWidget: public QWidget
00053 {
00054     Q_OBJECT
00055 
00056 public:
00057 
00059 
00066     MyWidget(const QString& label = QString(), QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0);
00067 
00068     enum CaptionPolicy{Name = 0, Label = 1, Both = 2};
00069     enum Status{Hidden = -1, Normal = 0, Minimized = 1, Maximized = 2};
00070 
00072     QString windowLabel(){return QString(w_label);};
00074     void setWindowLabel(const QString& s) { w_label = s; updateCaption();};
00075 
00077     QString name(){return objectName();};
00079     void setName(const QString& s){setObjectName(s); updateCaption();};
00080 
00082     CaptionPolicy captionPolicy(){return caption_policy;};
00084 
00090     void setCaptionPolicy(CaptionPolicy policy) { caption_policy = policy; updateCaption(); }
00092     void setName(const char *newname) { QWidget::setName(newname); updateCaption(); }
00093 
00095     QString birthDate(){return birthdate;};
00097     void setBirthDate(const QString& s){birthdate = s;};
00098 
00100     QString aspect();
00102     Status status(){return w_status;};
00104     void setStatus(Status s);
00105 
00106     virtual QString saveAsTemplate(const QString& ){return QString();};
00107     // TODO:
00109     virtual void restore(const QStringList& ){};
00110 
00111     virtual void print(){};
00112     virtual void exportPDF(const QString&){};
00113 
00114     virtual QString saveToString(const QString &){return QString();};
00115 
00116     // TODO: make this return something useful
00118     virtual QString sizeToString();
00119 
00121     virtual void setHidden();
00122 
00123     //event handlers
00125 
00129     void closeEvent( QCloseEvent *);
00131     void askOnCloseEvent(bool ask){askOnClose = ask;};
00133     bool eventFilter(QObject *object, QEvent *e);
00134 
00136     Folder* folder(){return parentFolder;};
00137 
00139     void setFolder(Folder* f){parentFolder = f;};
00140 
00142     void notifyChanges(){emit modifiedWindow(this);};
00143 
00144     static double stringToDouble(const QString& s);
00145 
00146     void setNormal();
00147     void setMinimized();
00148     void setMaximized();
00149 
00150 signals:
00152     void closedWindow(MyWidget *);
00154     void hiddenWindow(MyWidget *);
00155     void modifiedWindow(QWidget *);
00156     void resizedWindow(QWidget *);
00158     void statusChanged(MyWidget *);
00160     void showTitleBarMenu();
00161 
00162 protected:
00164     virtual void changeEvent(QEvent *event);
00166     QWidget *titleBar;
00167 
00168 private:
00170     void updateCaption();
00171 
00173     Folder *parentFolder;
00175 
00178     QString w_label;
00180     QString birthdate;
00182     Status w_status;
00184 
00187     CaptionPolicy caption_policy;
00189     bool askOnClose;
00190 };
00191 
00192 #endif

Generated on Mon Oct 15 06:11:42 2007 for QtiPlot by  doxygen 1.5.3