1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
23 #include <Qt3Support/q3frame.h>
29 class YQGenericButton;
34 class YQDialog : public QWidget, public YDialog
40 * Constructor: Constructor.
42 YQDialog( const YWidgetOpt & opt,
43 QWidget * qt_parent = 0,
44 bool default_size = false );
47 * Destructor: Cleans up.
52 * Makes this dialog active or inactive
54 void activate( bool active );
57 * Interited from QDialog: The window was closed via the window
58 * manager close button.
60 void closeEvent( QCloseEvent * ev );
63 * Set enabled/disabled state.
65 * Reimplemented from YWidget.
67 virtual void setEnabled( bool enabled );
70 * Preferred width of the widget.
72 * Reimplemented from YWidget.
74 virtual int preferredWidth();
77 * Preferred height of the widget.
79 * Reimplemented from YWidget.
81 virtual int preferredHeight();
84 * Set the new size of the widget.
86 * Reimplemented from YWidget.
88 virtual void setSize( int newWidth, int newHeight );
91 * Returns the size of (artificial) window manager decorations, depending
92 * on the value of YDialog::isDecorated().
94 int decorationWidth();
97 * Return this dialog's (first) default button or 0 if none
99 YQGenericButton * findDefaultButton();
102 * Returns whether or not the user has resized this dialog.
104 bool userResized() { return _userResized; }
107 * Returns the button that has the keyboard focus or 0 if no button has
108 * the keyboard focus.
110 YQGenericButton * focusButton() const { return _focusButton; }
113 * Returns the dialog's default button - the button that is activated with
114 * [Return] if no button has the keyboard focus.
116 YQGenericButton * defaultButton() const { return _defaultButton; }
119 * Notification that a button loses the keyboard focus.
121 * All pushbuttons are required to call this whenever they lose focus so
122 * the dialog can keep track of its focusButton.
124 void losingFocus( YQGenericButton * button );
127 * Notification that a button gets the keyboard focus.
129 * All pushbuttons are required to call this whenever they gain focus so
130 * the dialog can keep track of its focusButton.
132 void gettingFocus( YQGenericButton * button );
135 * Set the dialog's default button - the button that is activated with
136 * [Return] if no other button has the keyboard focus.
137 * 'newDefaultButton' may be 0 if the former default button is destroyed.
139 void setDefaultButton( YQGenericButton * newDefaultButton );
142 * Ensure presence of no more than one single default button.
144 void ensureOnlyOneDefaultButton();
147 * Activate ( i.e. click ) this dialog's default button, if there is any.
148 * Issue a warning to the log file if 'warn' is true.
150 bool activateDefaultButton( bool warn = true );
153 * Find the first wizard in that dialog, if there is any.
154 * Returns 0 if there is none.
156 YQWizard * findWizard() const;
159 * Find a wizard button that would make sense as a default button.
160 * Return 0 if none can be found.
162 YQGenericButton * wizardDefaultButton( YQWizard * wizard ) const;
165 * Center a dialog relative to 'parent'.
167 * If 'parent' is 0, the dialog is centered relative to the application's
168 * main widget. If 'dialog' is the main widget and 'parent' is 0, the
169 * dialog is centered relative to the desktop.
171 static void center( QWidget * dialog, QWidget * parent = 0 );
177 * Return the (first) default button between 'begin' and 'end'
178 * or 0 if there is none.
180 YQGenericButton * findDefaultButton( YWidgetListConstIterator begin,
181 YWidgetListConstIterator end ) const;
184 * Return the (first) wizard widget between 'begin' and 'end'
185 * or 0 if there is none.
187 YQWizard * findWizard( YWidgetListConstIterator begin,
188 YWidgetListConstIterator end ) const;
191 * Helper function for ensureOnlyOneDefaultButton():
192 * Recursively find all normal and wizard buttons between 'begin' and 'end'
193 * and make sure that no more than one button is marked as default.
194 * Return (the first) wizard widget found on the way.
196 YQWizard * ensureOnlyOneDefaultButton( YWidgetListConstIterator begin,
197 YWidgetListConstIterator end );
200 * Event handler for keyboard input.
201 * Only very special keys are processed here.
203 * Inherited from QWidget.
205 void keyPressEvent( QKeyEvent * e );
209 * Event handler for focusIn event.
211 * Inherited from QWidget.
213 void focusInEvent( QFocusEvent * event );
216 * Event handler for window resize.
218 * Inherited from QWidget.
220 void resizeEvent ( QResizeEvent * ev );
224 * Inherited from QWidget: Called when the dialog is shown.
238 YQGenericButton * _focusButton;
239 YQGenericButton * _defaultButton;