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 #include <QLocale>
00037 
00038 class QEvent;
00039 class QCloseEvent;
00040 class QString;
00041 class Folder;
00042 
00054 class MyWidget: public QWidget
00055 {
00056     Q_OBJECT
00057 
00058 public:
00059 
00061 
00068     MyWidget(const QString& label = QString(), QWidget * parent = 0, const QString& name = QString(), Qt::WFlags f = 0);
00069 
00071     enum CaptionPolicy{
00072         Name = 0, 
00073         Label = 1, 
00074         Both = 2 
00075     };
00076     enum Status{Hidden = -1, Normal = 0, Minimized = 1, Maximized = 2};
00077 
00079     QString windowLabel(){return QString(w_label);};
00081     void setWindowLabel(const QString& s) { w_label = s; updateCaption();};
00082 
00084     QString name(){return objectName();};
00086     void setName(const QString& s){setObjectName(s); updateCaption();};
00087 
00089     CaptionPolicy captionPolicy(){return caption_policy;};
00091     void setCaptionPolicy(CaptionPolicy policy) { caption_policy = policy; updateCaption(); }
00092 
00094     QString birthDate(){return birthdate;};
00096     void setBirthDate(const QString& s){birthdate = s;};
00097 
00099     QString aspect();
00101     Status status(){return w_status;};
00103     void setStatus(Status s);
00104 
00105     virtual QString saveAsTemplate(const QString& ){return QString();};
00106     // TODO:
00108     virtual void restore(const QStringList& ){};
00109 
00110     virtual void print(){};
00111     virtual void exportPDF(const QString&){};
00112 
00113     virtual QString saveToString(const QString &, bool = false){return QString();};
00114 
00115     // TODO: make this return something useful
00117     virtual QString sizeToString();
00118 
00120     virtual void setHidden();
00121 
00122     //event handlers
00124 
00128     void closeEvent( QCloseEvent *);
00129     void resizeEvent( QResizeEvent* );
00130 
00132     void askOnCloseEvent(bool ask){askOnClose = ask;};
00134     bool eventFilter(QObject *object, QEvent *e);
00135 
00137     Folder* folder(){return parentFolder;};
00138 
00140     void setFolder(Folder* f){parentFolder = f;};
00141 
00143     void notifyChanges(){emit modifiedWindow(this);};
00144 
00145     void setNormal();
00146     void setMinimized();
00147     void setMaximized();
00148 
00149     QLocale locale(){return d_locale;};
00150     void setLocale(const QLocale & l){d_locale = l;};
00151 
00152 signals:
00154     void closedWindow(MyWidget *);
00156     void hiddenWindow(MyWidget *);
00157     void modifiedWindow(QWidget *);
00158     void resizedWindow(QWidget *);
00160     void statusChanged(MyWidget *);
00162     void showTitleBarMenu();
00163     void moved();
00164 
00165 protected:
00167     virtual void changeEvent(QEvent *event);
00169     QWidget *titleBar;
00170 
00171 private:
00173     void updateCaption();
00174 
00176     Folder *parentFolder;
00178 
00181     QString w_label;
00183     QString birthdate;
00185     Status w_status;
00187 
00190     CaptionPolicy caption_policy;
00192     bool askOnClose;
00193 
00194     QLocale d_locale;
00195 };
00196 
00197 #endif

Generated on Thu Feb 7 13:59:27 2008 for QtiPlot by  doxygen 1.5.4