libyui-qt  2.43.5
/usr/src/RPM/BUILD/libyui-qt-2.43.5/src/YQMainWinDock.h
00001 /*
00002   Copyright (C) 2000-2012 Novell, Inc
00003   This library is free software; you can redistribute it and/or modify
00004   it under the terms of the GNU Lesser General Public License as
00005   published by the Free Software Foundation; either version 2.1 of the
00006   License, or (at your option) version 3.0 of the License. This library
00007   is distributed in the hope that it will be useful, but WITHOUT ANY
00008   WARRANTY; without even the implied warranty of MERCHANTABILITY or
00009   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00010   License for more details. You should have received a copy of the GNU
00011   Lesser General Public License along with this library; if not, write
00012   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
00013   Floor, Boston, MA 02110-1301 USA
00014 */
00015 
00016 
00017 /*-/
00018 
00019   File:       YQMainWinDock.h
00020 
00021   Author:     Stefan Hundhammer <sh@suse.de>
00022 
00023 /-*/
00024 
00025 
00026 #ifndef YQMainWinDock_h
00027 #define YQMainWinDock_h
00028 
00029 #include <deque>
00030 #include <qwidget.h>
00031 
00032 class QWidgetStack;
00033 
00034 
00035 /**
00036  * Container window for YQDialogs of type YMainWindowDialog:
00037  *
00038  * This widget "swallows" any main dialogs it gets so only the topmost of them
00039  * is visible at any given time. It acts as a window stack for main dialogs,
00040  * making the next lower dialog on the stack visible as when the (previously)
00041  * topmost main dialog is closed.
00042  *
00043  * This widget also handles its own visibility accordingly: It is visible if
00044  * and only if it has a main dialog to display. It makes itself invisible when
00045  * there is no more main dialog to display, and it makes itself visible again
00046  * when a new main dialog appears.
00047  *
00048  * This widget can swallow an arbitrary number of main dialogs as they are
00049  * opened as long as there is no popup dialog in between.
00050  **/
00051 class YQMainWinDock : public QWidget
00052 {
00053     friend class YQWizard;
00054 
00055     Q_OBJECT
00056 
00057 public:
00058     /**
00059      * Static method to access the singleton for this class.
00060      *
00061      * This creates the (one and only) instance of this class in the first
00062      * call. Subsequent calls simply return this instance.
00063      **/
00064     static YQMainWinDock * mainWinDock();
00065 
00066     /**
00067      * Add a dialog (the widgetRep() of a YQDialog) to the MainWinDock (on top
00068      * of its widget stack. The widget stack does not assume ownership of the
00069      * widget.
00070      *
00071      * If the MainWinDock is not visible yet, this operation makes it visible.
00072      **/
00073     void add( YQDialog * dialog );
00074 
00075     /**
00076      * Remove a dialog from the MainWinDock (if it belongs to the
00077      * MainWinDock). If dialog is 0, this removes the topmost dialog from the
00078      * MainWinDock.
00079      *
00080      * This can safely be called in the destructor of all dialogs, even those
00081      * that were never added to the MainWinDock.
00082      *
00083      * If that was the last main dialog in the MainWinDock, the MainWinDock
00084      * will be hidden (until another main dialog is added).
00085      **/
00086     void remove( YQDialog * dialog = 0 );
00087 
00088     /**
00089      * Return the current topmost dialog (the widgetRep() of a YQDialog)
00090      * or 0 if there is none.
00091      **/
00092     YQDialog * topmostDialog() const;
00093 
00094     /**
00095      * Return 'true' if the next main dialog could be docked,
00096      * i.e., if there is either no open dialog at all or only main dialogs.
00097      **/
00098     bool couldDock();
00099 
00100     /**
00101      * Show the widget (make it visible).
00102      *
00103      * Reimplemented from QWidget.
00104      **/
00105     virtual void show();
00106 
00107     /**
00108      * Window manager close event (Alt-F4):
00109      * Send a YCancelEvent and let the application handle that event.
00110      *
00111      * Reimplemented from QWidget.
00112      **/
00113     virtual void closeEvent( QCloseEvent * event );
00114 
00115 
00116 protected:
00117     /**
00118      * Constructor.
00119      *
00120      * Use the static mainWinDock() method to access the singleton for this
00121      * class.
00122      **/
00123     YQMainWinDock();
00124 
00125     /**
00126      * Destructor.
00127      **/
00128     virtual ~YQMainWinDock();
00129 
00130     /**
00131      * Paint event.
00132      *
00133      * Reimplemented from QWidget.
00134      **/
00135     virtual void paintEvent( QPaintEvent * event );
00136 
00137     /**
00138      * Resize event.
00139      *
00140      * Reimplemented from QWidget.
00141      **/
00142     virtual void resizeEvent( QResizeEvent * event );
00143 
00144     /**
00145      * Resize the visible child to the current size of the dock.
00146      **/
00147     void resizeVisibleChild();
00148 
00149     /**
00150      * For secondary wizards
00151      **/
00152     void setSideBarWidth( int width );
00153 
00154     /**
00155      * Activate or deactivate the next-lower dialog in the dock when a new
00156      * dialog is opened or when a dialog is closed.
00157      **/
00158     void activateCurrentDialog( bool active );
00159 
00160 
00161 protected slots:
00162 
00163     /**
00164      * Show the current dialog.
00165      **/
00166     void showCurrentDialog();
00167 
00168 
00169 private:
00170 
00171     typedef std::deque<YQDialog *> YQWidgetStack;
00172 
00173     /**
00174      * Return an iterator to the specified dialog in the internal
00175      * widgetstack or _widgetStack::end() if not found.
00176      **/
00177     YQWidgetStack::iterator findInStack( YQDialog * dialog );
00178 
00179 
00180     YQWidgetStack _widgetStack;
00181 
00182     int _sideBarWidth;
00183 };
00184 
00185 
00186 #endif // YQMainWinDock_h
 All Classes Functions Variables