Back to index

salome-gui  6.5.0
QtxDialog.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
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 GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:      QtxDialog.h
00024 // Author:    Sergey TELKOV
00025 //
00026 #ifndef QTXDIALOG_H
00027 #define QTXDIALOG_H
00028 
00029 #include "Qtx.h"
00030 
00031 #include <QDialog>
00032 #include <QMap>
00033 
00034 class QFrame;
00035 class QLabel;
00036 class QAbstractButton;
00037 
00038 #ifdef WIN32
00039 #pragma warning( disable:4251 )
00040 #endif
00041 
00042 class QTX_EXPORT QtxDialog : public QDialog
00043 {
00044   Q_OBJECT
00045 
00046   class Area;
00047   class Border;
00048 
00049 public:
00051   typedef enum { Position,          
00052                  Expand,            
00053                  Uniform            
00054   } PlacePolicy;
00056   typedef enum { TopArea,           
00057                  BottomArea,        
00058                  LeftArea,          
00059                  RightArea          
00060   } ButtonArea;
00062   typedef enum { Left,              
00063                  Right,             
00064                  Center,            
00065                  Top = Left,        
00066                  Bottom = Right     
00067   } ButtonPosition;
00069   typedef enum { None      = 0x00000000,                      
00070                  OK        = 0x00000001,                      
00071                  Apply     = 0x00000002,                      
00072                  Cancel    = 0x00000004,                      
00073                  Yes       = 0x00000008,                      
00074                  No        = 0x00000010,                      
00075                  Close     = 0x00000020,                      
00076                  Help      = 0x00000040,                      
00077                  OKCancel  = OK  | Cancel,                    
00078                  YesNo     = Yes | No,                        
00079                  Standard  = OK  | Cancel | Help,             
00080                  All       = Standard | YesNo | Apply | Close 
00081   } ButtonFlags;
00083   typedef enum { Accept    = 0x000001, 
00084                  Reject    = 0x000002, 
00085                  AlignOnce = 0x000004, 
00086                  SetFocus  = 0x000008  
00087   } DialogFlags;
00088   
00089 public:
00090   QtxDialog( QWidget* = 0, bool = false, bool = false, const int = Standard, Qt::WindowFlags = 0 );
00091   virtual ~QtxDialog();
00092   
00093   void             setDialogFlags( const int );
00094   void             clearDialogFlags( const int );
00095   bool             testDialogFlags( const int ) const;
00096   
00097   void             setButtonFlags( const int );
00098   void             clearButtonFlags( const int );
00099   bool             testButtonFlags( const int ) const;
00100   
00101   int              buttonPosition( const int ) const;
00102   void             setButtonPosition( const int, const int = -1 );
00103   void             setPlacePosition( const int, const int );
00104   
00105   int              placePolicy( const int ) const;
00106   void             setPlacePolicy( const int, const int );
00107   void             setButtonPlace( const int, const int );
00108   
00109   QString          buttonText( const int );
00110   void             setButtonText( const int, const QString& text );
00111   
00112   void             setButtonFocus( const int );
00113   bool             hasButtonFocus( const int ) const;
00114   
00115   bool             isButtonEnabled( const int ) const;
00116   void             setButtonEnabled( const bool, const int );
00117   
00118   bool             isBorderEnabled( const int ) const;
00119   void             setBorderEnabled( const bool, const int );
00120   
00121   void             removeButton( const int );
00122   int              insertButton( const QString&, const int = BottomArea );
00123   
00124   QIntList         userButtonIds() const;
00125   QAbstractButton* userButton( const int ) const;
00126   
00127   uint             setAlignment( uint align );
00128   static  void     setUnits( QLabel*, const QString& );
00129   
00130 signals:
00131   void             dlgButton( int );
00132   void             dlgParamChanged();
00133   
00134   void             dlgHelp();
00135   void             dlgApply();
00136   
00137   void             dlgOk();
00138   void             dlgNo();
00139   void             dlgYes();
00140   void             dlgClose();
00141   void             dlgCancel();
00142   
00143 public slots:
00144   void             update();
00145   virtual void     setVisible( bool );
00146 
00147 protected slots:
00148   virtual void     accept();
00149   virtual void     reject();
00150 
00151 private slots:
00152   void             onAccept();
00153   void             onReject();
00154   void             onButton();
00155   void             onSizeGripDestroyed();
00156   void             onDestroyed( QObject* );
00157 
00158 protected:
00159   typedef QMap<int, QAbstractButton*> ButtonMap;   
00160 
00161 protected:
00162   QFrame*          mainFrame() const;
00163   
00164   virtual bool     acceptData() const;
00165   virtual bool     rejectData() const;
00166   
00167   virtual QAbstractButton* createButton( QWidget* );
00168   
00169   QAbstractButton* button( const int ) const;
00170   ButtonMap        buttons( const int = All ) const;
00171   int              buttonId( const QAbstractButton* ) const;
00172   int              buttonPosition( QAbstractButton* ) const;
00173   
00174   virtual void     showEvent( QShowEvent* );
00175   virtual void     hideEvent( QHideEvent* );
00176   virtual void     closeEvent( QCloseEvent* );
00177   virtual void     childEvent( QChildEvent* );
00178   virtual void     keyPressEvent( QKeyEvent* );
00179   
00180 private:
00181   void             adjustButtons();
00182   void             emitSignal();
00183   
00184 private:
00185   typedef QMap<int, Area*> AreaMap;        
00186   typedef QMap<int, int>   PositionMap;    
00187   
00188   friend class Area;
00189 
00190 private:
00191   AreaMap          myArea;                 
00192   ButtonMap        myButton;               
00193   PositionMap      myPosition;             
00194   
00195   bool             myInited;               
00196   const QObject*   mySender;               
00197   uint             myAlignment;            
00198   QFrame*          myMainFrame;            
00199   int              myButtonFlags;          
00200   int              myDialogFlags;          
00201 };
00202 
00203 #ifdef WIN32
00204 #pragma warning( default:4251 )
00205 #endif
00206 
00207 #endif