Version: 9.15.0
QtxDialog.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2025 CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // File: QtxDialog.h
24 // Author: Sergey TELKOV
25 //
26 #ifndef QTXDIALOG_H
27 #define QTXDIALOG_H
28 
29 #include "Qtx.h"
30 
31 #include <QDialog>
32 #include <QMap>
33 
34 class QFrame;
35 class QLabel;
36 class QAbstractButton;
37 
38 #ifdef WIN32
39 #pragma warning( disable:4251 )
40 #endif
41 
43 {
44  Q_OBJECT
45 
46  class Area;
47  class Border;
48 
49 public:
51  typedef enum { Position,
53  Uniform
54  } PlacePolicy;
56  typedef enum { TopArea,
59  RightArea
60  } ButtonArea;
62  typedef enum { Left,
65  Top = Left,
66  Bottom = Right
67  } ButtonPosition;
69  typedef enum { None = 0x00000000,
70  OK = 0x00000001,
71  Apply = 0x00000002,
72  Cancel = 0x00000004,
73  Yes = 0x00000008,
74  No = 0x00000010,
75  Close = 0x00000020,
76  Help = 0x00000040,
77  OKCancel = OK | Cancel,
78  YesNo = Yes | No,
79  Standard = OK | Cancel | Help,
80  All = Standard | YesNo | Apply | Close
81  } ButtonFlags;
83  typedef enum { Accept = 0x000001,
84  Reject = 0x000002,
85  AlignOnce = 0x000004,
86  SetFocus = 0x000008
87  } DialogFlags;
88 
89 public:
90  QtxDialog( QWidget* = 0, bool = false, bool = false, const int = Standard, Qt::WindowFlags = 0 );
91  virtual ~QtxDialog();
92 
93  void setDialogFlags( const int );
94  void clearDialogFlags( const int );
95  bool testDialogFlags( const int ) const;
96 
97  void setButtonFlags( const int );
98  void clearButtonFlags( const int );
99  bool testButtonFlags( const int ) const;
100 
101  int buttonPosition( const int ) const;
102  void setButtonPosition( const int, const int = -1 );
103  void setPlacePosition( const int, const int );
104 
105  int placePolicy( const int ) const;
106  void setPlacePolicy( const int, const int );
107  void setButtonPlace( const int, const int );
108 
109  QString buttonText( const int );
110  void setButtonText( const int, const QString& text );
111 
112  void setButtonFocus( const int );
113  bool hasButtonFocus( const int ) const;
114 
115  bool isButtonEnabled( const int ) const;
116  void setButtonEnabled( const bool, const int );
117 
118  bool isBorderEnabled( const int ) const;
119  void setBorderEnabled( const bool, const int );
120 
121  void removeButton( const int );
122  int insertButton( const QString&, const int = BottomArea );
123 
124  QIntList userButtonIds() const;
125  QAbstractButton* userButton( const int ) const;
126 
127  uint setAlignment( uint align );
128  static void setUnits( QLabel*, const QString& );
129 
130 signals:
131  void dlgButton( int );
133 
134  void dlgHelp();
135  void dlgApply();
136 
137  void dlgOk();
138  void dlgNo();
139  void dlgYes();
140  void dlgClose();
141  void dlgCancel();
142 
143 public slots:
144  void update();
145  virtual void setVisible( bool );
146 
147 protected slots:
148  virtual void accept();
149  virtual void reject();
150 
151 private slots:
152  void onAccept();
153  void onReject();
154  void onButton();
155  void onSizeGripDestroyed();
156  void onDestroyed( QObject* );
157 
158 protected:
159  typedef QMap<int, QAbstractButton*> ButtonMap;
160 
161 protected:
162  QFrame* mainFrame() const;
163 
164  virtual bool acceptData() const;
165  virtual bool rejectData() const;
166 
167  virtual QAbstractButton* createButton( QWidget* );
168 
169  QAbstractButton* button( const int ) const;
170  ButtonMap buttons( const int = All ) const;
171  int buttonId( const QAbstractButton* ) const;
172  int buttonPosition( QAbstractButton* ) const;
173 
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* );
179 
180 private:
181  void adjustButtons();
182  void emitSignal();
183 
184 private:
185  typedef QMap<int, Area*> AreaMap;
186  typedef QMap<int, int> PositionMap;
187 
188  friend class Area;
189 
190 private:
194 
195  bool myInited;
196  const QObject* mySender;
197  uint myAlignment;
201 };
202 
203 #ifdef WIN32
204 #pragma warning( default:4251 )
205 #endif
206 
207 #endif
QList< int > QIntList
list of int values
Definition: Qtx.h:55
#define QTX_EXPORT
Definition: Qtx.h:36
@ Help
Definition: SalomePyQt.h:85
For more information see QT documentation.
Definition: SUIT_Application.h:42
Area containing dialog box buttons.
Definition: QtxDialog.cxx:43
Special label used as border widget (separator between main frame and button frame).
Definition: QtxDialog.cxx:355
Generic dialog box class.
Definition: QtxDialog.h:43
void dlgButton(int)
Emitted when the user button is clicked.
QMap< int, Area * > AreaMap
button area map
Definition: QtxDialog.h:185
QFrame * myMainFrame
main frame
Definition: QtxDialog.h:198
void dlgYes()
Emitted when the "Yes" button is clicked.
bool myInited
dialog's "initialized" flag
Definition: QtxDialog.h:195
@ Expand
buttons occupy all available space
Definition: QtxDialog.h:52
void dlgNo()
Emitted when the "No" button is clicked.
QMap< int, QAbstractButton * > ButtonMap
button map
Definition: QtxDialog.h:159
void dlgClose()
Emitted when the "Close" button is clicked.
void dlgApply()
Emitted when the "Apply" button is clicked.
QMap< int, int > PositionMap
button position map
Definition: QtxDialog.h:186
PositionMap myPosition
buttons position map
Definition: QtxDialog.h:193
uint myAlignment
dialog box alignment type
Definition: QtxDialog.h:197
ButtonMap myButton
buttons map
Definition: QtxDialog.h:192
const QObject * mySender
signal sender
Definition: QtxDialog.h:196
int myDialogFlags
dialog flags
Definition: QtxDialog.h:200
@ Center
place button in the center
Definition: QtxDialog.h:64
@ Right
set button right-most
Definition: QtxDialog.h:63
void dlgParamChanged()
This signal can be used in successor classes to signalize about some dialog parameter changing.
void dlgOk()
Emitted when the "OK" button is clicked.
void dlgCancel()
Emitted when the "Cancel" button is clicked.
@ LeftArea
vertical area at the left side of the dialog box
Definition: QtxDialog.h:58
@ BottomArea
horizontal area at the bottom side of the dialog box
Definition: QtxDialog.h:57
int myButtonFlags
button flags
Definition: QtxDialog.h:199
void dlgHelp()
Emitted when the "Help" button is clicked.
AreaMap myArea
buttons areas map
Definition: QtxDialog.h:191
@ None
Definition: Plot2d.h:74