PrefWidgets.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef GUI_PREFWIDGETS_H
00025 #define GUI_PREFWIDGETS_H
00026 
00027 #include <QCheckBox>
00028 #include <QComboBox>
00029 #include <QRadioButton>
00030 #include <Base/Parameter.h>
00031 #include "Widgets.h"
00032 #include "Window.h"
00033 #include "SpinBox.h"
00034 #include "FileDialog.h"
00035 
00036 namespace Gui {
00037 class CommandManager;
00038 class WidgetFactoryInst;
00039 
00054 class GuiExport PrefWidget : public WindowParameter
00055 {
00056 public:
00057   virtual void setEntryName( const QByteArray& name );
00058   virtual QByteArray entryName() const;
00059 
00060   virtual void setParamGrpPath( const QByteArray& path );
00061   virtual QByteArray paramGrpPath() const;
00062 
00063   virtual void OnChange(Base::Subject<const char*> &rCaller, const char * sReason);
00064   void onSave();
00065   void onRestore();
00066 
00067 protected:
00071   virtual void restorePreferences() = 0;
00075   virtual void savePreferences()    = 0;
00076 
00077   PrefWidget();
00078   virtual ~PrefWidget();
00079 
00080 private:
00081   QByteArray m_sPrefName;
00082   QByteArray m_sPrefGrp;
00083 
00084   // friends
00085   friend class Gui::WidgetFactoryInst;
00086 };
00087 
00091 class GuiExport PrefSpinBox : public QSpinBox, public PrefWidget
00092 {
00093   Q_OBJECT
00094 
00095   Q_PROPERTY( QByteArray prefEntry READ entryName     WRITE setEntryName     )
00096   Q_PROPERTY( QByteArray prefPath  READ paramGrpPath  WRITE setParamGrpPath  )
00097 
00098 public:
00099   PrefSpinBox ( QWidget * parent = 0 );
00100   virtual ~PrefSpinBox();
00101 
00102   // PROPERTIES
00103   // getters
00104   QByteArray entryName    () const;
00105   QByteArray paramGrpPath () const;
00106   // setters
00107   void  setEntryName     ( const QByteArray& name );
00108   void  setParamGrpPath  ( const QByteArray& name );
00109 
00110 protected:
00111   // restore from/save to parameters
00112   void restorePreferences();
00113   void savePreferences();
00114 };
00115 
00119 class GuiExport PrefDoubleSpinBox : public QDoubleSpinBox, public PrefWidget
00120 {
00121   Q_OBJECT
00122 
00123   Q_PROPERTY( QByteArray prefEntry READ entryName     WRITE setEntryName     )
00124   Q_PROPERTY( QByteArray prefPath  READ paramGrpPath  WRITE setParamGrpPath  )
00125 
00126 public:
00127   PrefDoubleSpinBox ( QWidget * parent = 0 );
00128   virtual ~PrefDoubleSpinBox();
00129 
00130   // PROPERTIES
00131   // getters
00132   QByteArray entryName    () const;
00133   QByteArray paramGrpPath () const;
00134   // setters
00135   void  setEntryName     ( const QByteArray& name );
00136   void  setParamGrpPath  ( const QByteArray& name );
00137 
00138 protected:
00139   // restore from/save to parameters
00140   void restorePreferences();
00141   void savePreferences();
00142 };
00143 
00148 class GuiExport PrefLineEdit : public QLineEdit, public PrefWidget
00149 {
00150   Q_OBJECT
00151 
00152   Q_PROPERTY( QByteArray prefEntry READ entryName     WRITE setEntryName     )
00153   Q_PROPERTY( QByteArray prefPath  READ paramGrpPath  WRITE setParamGrpPath  )
00154 
00155 public:
00156   PrefLineEdit ( QWidget * parent = 0 );
00157   virtual ~PrefLineEdit();
00158 
00159   // PROPERTIES
00160   // getters
00161   QByteArray entryName    () const;
00162   QByteArray paramGrpPath () const;
00163   // setters
00164   void  setEntryName     ( const QByteArray& name );
00165   void  setParamGrpPath  ( const QByteArray& name );
00166 
00167 protected:
00168   // restore from/save to parameters
00169   void restorePreferences();
00170   void savePreferences();
00171 };
00172 
00177 class GuiExport PrefFileChooser : public FileChooser, public PrefWidget
00178 {
00179   Q_OBJECT
00180 
00181   Q_PROPERTY( QByteArray prefEntry READ entryName     WRITE setEntryName     )
00182   Q_PROPERTY( QByteArray prefPath  READ paramGrpPath  WRITE setParamGrpPath  )
00183 
00184 public:
00185   PrefFileChooser ( QWidget * parent = 0 );
00186   virtual ~PrefFileChooser();
00187 
00188   // PROPERTIES
00189   // getters
00190   QByteArray entryName    () const;
00191   QByteArray paramGrpPath () const;
00192   // setters
00193   void  setEntryName     ( const QByteArray& name );
00194   void  setParamGrpPath  ( const QByteArray& name );
00195 
00196 protected:
00197   // restore from/save to parameters
00198   void restorePreferences();
00199   void savePreferences();
00200 };
00201 
00206 class GuiExport PrefComboBox : public QComboBox, public PrefWidget
00207 {
00208   Q_OBJECT
00209 
00210   Q_PROPERTY( QByteArray prefEntry READ entryName     WRITE setEntryName     )
00211   Q_PROPERTY( QByteArray prefPath  READ paramGrpPath  WRITE setParamGrpPath  )
00212 
00213 public:
00214   PrefComboBox ( QWidget * parent = 0 );
00215   virtual ~PrefComboBox();
00216 
00217   // PROPERTIES
00218   // getters
00219   QByteArray entryName    () const;
00220   QByteArray paramGrpPath () const;
00221   // setters
00222   void  setEntryName     ( const QByteArray& name );
00223   void  setParamGrpPath  ( const QByteArray& name );
00224 
00225 protected:
00226   // restore from/save to parameters
00227   void restorePreferences();
00228   void savePreferences();
00229 };
00230 
00235 class GuiExport PrefCheckBox : public QCheckBox, public PrefWidget
00236 {
00237   Q_OBJECT
00238 
00239   Q_PROPERTY( QByteArray prefEntry READ entryName     WRITE setEntryName     )
00240   Q_PROPERTY( QByteArray prefPath  READ paramGrpPath  WRITE setParamGrpPath  )
00241 
00242 public:
00243   PrefCheckBox ( QWidget * parent = 0 );
00244   virtual ~PrefCheckBox();
00245 
00246   // PROPERTIES
00247   // getters
00248   QByteArray entryName    () const;
00249   QByteArray paramGrpPath () const;
00250   // setters
00251   void  setEntryName     ( const QByteArray& name );
00252   void  setParamGrpPath  ( const QByteArray& name );
00253 
00254 protected:
00255   // restore from/save to parameters
00256   void restorePreferences();
00257   void savePreferences();
00258 };
00259 
00264 class GuiExport PrefRadioButton : public QRadioButton, public PrefWidget
00265 {
00266   Q_OBJECT
00267 
00268   Q_PROPERTY( QByteArray prefEntry READ entryName     WRITE setEntryName     )
00269   Q_PROPERTY( QByteArray prefPath  READ paramGrpPath  WRITE setParamGrpPath  )
00270 
00271 public:
00272   PrefRadioButton ( QWidget * parent = 0 );
00273   virtual ~PrefRadioButton();
00274 
00275   // PROPERTIES
00276   // getters
00277   QByteArray entryName    () const;
00278   QByteArray paramGrpPath () const;
00279   // setters
00280   void  setEntryName     ( const QByteArray& name );
00281   void  setParamGrpPath  ( const QByteArray& name );
00282 
00283 protected:
00284   // restore from/save to parameters
00285   void restorePreferences();
00286   void savePreferences();
00287 };
00288 
00293 class GuiExport PrefSlider : public QSlider, public PrefWidget
00294 {
00295   Q_OBJECT
00296 
00297   Q_PROPERTY( QByteArray prefEntry READ entryName     WRITE setEntryName     )
00298   Q_PROPERTY( QByteArray prefPath  READ paramGrpPath  WRITE setParamGrpPath  )
00299 
00300 public:
00301   PrefSlider ( QWidget * parent = 0 );
00302   virtual ~PrefSlider();
00303 
00304   // PROPERTIES
00305   // getters
00306   QByteArray entryName    () const;
00307   QByteArray paramGrpPath () const;
00308   // setters
00309   void  setEntryName     ( const QByteArray& name );
00310   void  setParamGrpPath  ( const QByteArray& name );
00311 
00312 protected:
00313   // restore from/save to parameters
00314   void restorePreferences();
00315   void savePreferences();
00316 };
00317 
00322 class GuiExport PrefColorButton : public ColorButton, public PrefWidget
00323 {
00324   Q_OBJECT
00325 
00326   Q_PROPERTY( QByteArray prefEntry READ entryName     WRITE setEntryName     )
00327   Q_PROPERTY( QByteArray prefPath  READ paramGrpPath  WRITE setParamGrpPath  )
00328 
00329 public:
00330   PrefColorButton ( QWidget * parent = 0 );
00331   virtual ~PrefColorButton();
00332 
00333   // PROPERTIES
00334   // getters
00335   QByteArray entryName    () const;
00336   QByteArray paramGrpPath () const;
00337   // setters
00338   void  setEntryName     ( const QByteArray& name );
00339   void  setParamGrpPath  ( const QByteArray& name );
00340 
00341 protected:
00342   // restore from/save to parameters
00343   void restorePreferences();
00344   void savePreferences();
00345 };
00346 
00347 } // namespace Gui
00348 
00349 #endif // GUI_PREFWIDGETS_H

Generated on Wed Nov 23 19:00:29 2011 for FreeCAD by  doxygen 1.6.1