1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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
24 // Author: Sergey TELKOV
36 class QAbstractButton;
39 #pragma warning( disable:4251 )
42 class QTX_EXPORT QtxDialog : public QDialog
50 //! Buttons alignment type
51 typedef enum { Position, //!< buttons are placed according their position
52 Expand, //!< buttons occupy all available space
53 Uniform //!< buttons are uniformly placed in the area
56 typedef enum { TopArea, //!< horizontal area at the top side of the dialog box
57 BottomArea, //!< horizontal area at the bottom side of the dialog box
58 LeftArea, //!< vertical area at the left side of the dialog box
59 RightArea //!< vertical area at the right side of the dialog box
62 typedef enum { Left, //!< set button left-most
63 Right, //!< set button right-most
64 Center, //!< place button in the center
65 Top = Left, //!< set button top-most
66 Bottom = Right //!< set button bottom-most
69 typedef enum { None = 0x00000000, //!< no button used
70 OK = 0x00000001, //!< OK button
71 Apply = 0x00000002, //!< Apply button
72 Cancel = 0x00000004, //!< Cancel button
73 Yes = 0x00000008, //!< Yes button
74 No = 0x00000010, //!< No button
75 Close = 0x00000020, //!< Close button
76 Help = 0x00000040, //!< Help button
77 OKCancel = OK | Cancel, //!< OK & Cancel button
78 YesNo = Yes | No, //!< Yes & No buttons
79 Standard = OK | Cancel | Help, //!< OK, Cancel & Help buttons
80 All = Standard | YesNo | Apply | Close //!< all buttons
83 typedef enum { Accept = 0x000001, //!< allow dialog box accepting control
84 Reject = 0x000002, //!< allow dialog box rejecting control
85 AlignOnce = 0x000004, //!< align dialog box only when it is first time shown
86 SetFocus = 0x000008 //!< allow to set focus on dialog box when it is shown (user can use setFocusProxy() and specify own initial focus widget)
90 QtxDialog( QWidget* = 0, bool = false, bool = false, const int = Standard, Qt::WindowFlags = 0 );
93 void setDialogFlags( const int );
94 void clearDialogFlags( const int );
95 bool testDialogFlags( const int ) const;
97 void setButtonFlags( const int );
98 void clearButtonFlags( const int );
99 bool testButtonFlags( const int ) const;
101 int buttonPosition( const int ) const;
102 void setButtonPosition( const int, const int = -1 );
103 void setPlacePosition( const int, const int );
105 int placePolicy( const int ) const;
106 void setPlacePolicy( const int, const int );
107 void setButtonPlace( const int, const int );
109 QString buttonText( const int );
110 void setButtonText( const int, const QString& text );
112 void setButtonFocus( const int );
113 bool hasButtonFocus( const int ) const;
115 bool isButtonEnabled( const int ) const;
116 void setButtonEnabled( const bool, const int );
118 bool isBorderEnabled( const int ) const;
119 void setBorderEnabled( const bool, const int );
121 void removeButton( const int );
122 int insertButton( const QString&, const int = BottomArea );
124 QIntList userButtonIds() const;
125 QAbstractButton* userButton( const int ) const;
127 uint setAlignment( uint align );
128 static void setUnits( QLabel*, const QString& );
131 void dlgButton( int );
132 void dlgParamChanged();
145 virtual void setVisible( bool );
148 virtual void accept();
149 virtual void reject();
155 void onSizeGripDestroyed();
156 void onDestroyed( QObject* );
159 typedef QMap<int, QAbstractButton*> ButtonMap; //!< button map
162 QFrame* mainFrame() const;
164 virtual bool acceptData() const;
165 virtual bool rejectData() const;
167 virtual QAbstractButton* createButton( QWidget* );
169 QAbstractButton* button( const int ) const;
170 ButtonMap buttons( const int = All ) const;
171 int buttonId( const QAbstractButton* ) const;
172 int buttonPosition( QAbstractButton* ) const;
174 virtual void showEvent( QShowEvent* );
175 virtual void hideEvent( QHideEvent* );
176 virtual void closeEvent( QCloseEvent* );
177 virtual void childEvent( QChildEvent* );
178 virtual void keyPressEvent( QKeyEvent* );
181 void adjustButtons();
185 typedef QMap<int, Area*> AreaMap; //!< button area map
186 typedef QMap<int, int> PositionMap; //!< button position map
191 AreaMap myArea; //!< buttons areas map
192 ButtonMap myButton; //!< buttons map
193 PositionMap myPosition; //!< buttons position map
195 bool myInited; //!< dialog's "initialized" flag
196 const QObject* mySender; //!< signal sender
197 uint myAlignment; //!< dialog box alignment type
198 QFrame* myMainFrame; //!< main frame
199 int myButtonFlags; //!< button flags
200 int myDialogFlags; //!< dialog flags
204 #pragma warning( default:4251 )