1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // Author: Sergey TELKOV
35 class QAbstractButton;
38 #pragma warning( disable:4251 )
41 class QTX_EXPORT QtxDialog : public QDialog
49 //! Buttons alignment type
50 typedef enum { Position, //!< buttons are placed according their position
51 Expand, //!< buttons occupy all available space
52 Uniform //!< buttons are uniformly placed in the area
55 typedef enum { TopArea, //!< horizontal area at the top side of the dialog box
56 BottomArea, //!< horizontal area at the bottom side of the dialog box
57 LeftArea, //!< vertical area at the left side of the dialog box
58 RightArea //!< vertical area at the right side of the dialog box
61 typedef enum { Left, //!< set button left-most
62 Right, //!< set button right-most
63 Center, //!< place button in the center
64 Top = Left, //!< set button top-most
65 Bottom = Right //!< set button bottom-most
68 typedef enum { None = 0x00000000, //!< no button used
69 OK = 0x00000001, //!< OK button
70 Apply = 0x00000002, //!< Apply button
71 Cancel = 0x00000004, //!< Cancel button
72 Yes = 0x00000008, //!< Yes button
73 No = 0x00000010, //!< No button
74 Close = 0x00000020, //!< Close button
75 Help = 0x00000040, //!< Help button
76 OKCancel = OK | Cancel, //!< OK & Cancel button
77 YesNo = Yes | No, //!< Yes & No buttons
78 Standard = OK | Cancel | Help, //!< OK, Cancel & Help buttons
79 All = Standard | YesNo | Apply | Close //!< all buttons
82 typedef enum { Accept = 0x000001, //!< allow dialog box accepting control
83 Reject = 0x000002, //!< allow dialog box rejecting control
84 AlignOnce = 0x000004, //!< align dialog box only when it is first time shown
85 SetFocus = 0x000008 //!< allow to set focus on dialog box when it is shown (user can use setFocusProxy() and specify own initial focus widget)
89 QtxDialog( QWidget* = 0, bool = false, bool = false, const int = Standard, Qt::WindowFlags = 0 );
92 void setDialogFlags( const int );
93 void clearDialogFlags( const int );
94 bool testDialogFlags( const int ) const;
96 void setButtonFlags( const int );
97 void clearButtonFlags( const int );
98 bool testButtonFlags( const int ) const;
100 int buttonPosition( const int ) const;
101 void setButtonPosition( const int, const int = -1 );
102 void setPlacePosition( const int, const int );
104 int placePolicy( const int ) const;
105 void setPlacePolicy( const int, const int );
106 void setButtonPlace( const int, const int );
108 QString buttonText( const int );
109 void setButtonText( const int, const QString& text );
111 void setButtonFocus( const int );
112 bool hasButtonFocus( const int ) const;
114 bool isButtonEnabled( const int ) const;
115 void setButtonEnabled( const bool, const int );
117 bool isBorderEnabled( const int ) const;
118 void setBorderEnabled( const bool, const int );
120 void removeButton( const int );
121 int insertButton( const QString&, const int = BottomArea );
123 QIntList userButtonIds() const;
124 QAbstractButton* userButton( const int ) const;
126 uint setAlignment( uint align );
127 static void setUnits( QLabel*, const QString& );
130 void dlgButton( int );
131 void dlgParamChanged();
144 virtual void setVisible( bool );
147 virtual void accept();
148 virtual void reject();
154 void onSizeGripDestroyed();
155 void onDestroyed( QObject* );
158 typedef QMap<int, QAbstractButton*> ButtonMap; //!< button map
161 QFrame* mainFrame() const;
163 virtual bool acceptData() const;
164 virtual bool rejectData() const;
166 virtual QAbstractButton* createButton( QWidget* );
168 QAbstractButton* button( const int ) const;
169 ButtonMap buttons( const int = All ) const;
170 int buttonId( const QAbstractButton* ) const;
171 int buttonPosition( QAbstractButton* ) const;
173 virtual void showEvent( QShowEvent* );
174 virtual void hideEvent( QHideEvent* );
175 virtual void closeEvent( QCloseEvent* );
176 virtual void childEvent( QChildEvent* );
177 virtual void keyPressEvent( QKeyEvent* );
180 void adjustButtons();
184 typedef QMap<int, Area*> AreaMap; //!< button area map
185 typedef QMap<int, int> PositionMap; //!< button position map
190 AreaMap myArea; //!< buttons areas map
191 ButtonMap myButton; //!< buttons map
192 PositionMap myPosition; //!< buttons position map
194 bool myInited; //!< dialog's "initialized" flag
195 const QObject* mySender; //!< signal sender
196 uint myAlignment; //!< dialog box alignment type
197 QFrame* myMainFrame; //!< main frame
198 int myButtonFlags; //!< button flags
199 int myDialogFlags; //!< dialog flags
203 #pragma warning( default:4251 )