Logo Search packages:      
Sourcecode: kbear version File versions  Download package

QextMdiMainFrm Class Reference

#include <qextmdimainfrm.h>

Inheritance diagram for QextMdiMainFrm:


List of all members.

Detailed Description

Base class for all your special main frames.

It contains the child frame area (QMainWindow's central widget) and a child view taskbar for switching the MDI views. Most methods are virtual functions for later overriding.

Basically, this class provides functionality for docking/undocking view windows and manages the taskbar. Usually the programmer just need to know about this class and the child view class.

Your program mainwidget should inherit QextMdiMainFrm. Then usually you'll just need addWindow() and removeWindowFromMdi() to control the views.

   class MyMainWindow : public QextMdiMainFrm
   { .... };
   MyMainWindow mainframe;
   mainframe->addWindow(view1); // put it under MDI control

Most public and protected methods of this class are for program calls of the actions the user could click.

Dynamic switching the MDI mode can be done via switchToChildframeMode(), switchToToplevelMode(), switchToTabPageMode() or fakeSDIApplication() or asked via mdiMode(), isFakingSDIApplication().

This class provides already the "Window" menu needed in common MDI applications. Just insert it in your main menu:

 if (!isFakingSDIApplication()) {
    menuBar()->insertItem( tr("&Window"), windowMenu());

Synchronize the positions of the MDI control buttons inserted in your mainmenu:

 void B_MainModuleWidget::initMenuBar()
   setMenuForSDIModeSysButtons( menuBar());
 void B_MainModuleWidget::resizeEvent ( QResizeEvent *e)
   QextMdiMainFrm::resizeEvent( e);

You can dynamically change the shape of the attached MDI views using setFrameDecorOfAttachedViews().

Additionally, here's a hint how to restore the mainframe's settings from config file:

 ifdef NO_KDE2 // KDE2 comes with its own style
    int guiStyle = config->readIntEntry( "mainmodule session", "GUI style", 0);
    mainframe->setGUIStyle( guiStyle);

    // restore MDI mode (toplevel, childframe, tabpage)
    int mdiMode = config->readIntEntry( "mainmodule session", "MDI mode", QextMdi::ChildframeMode);
    switch (mdiMode) {
    case QextMdi::ToplevelMode:
          int childFrmModeHt = config->readIntEntry( "mainmodule session", "Childframe mode height", desktop()->height() - 50);
          mainframe->resize( m_pMdiMainFrm->width(), childFrmModeHt);
    case QextMdi::ChildframeMode:
    case QextMdi::TabPageMode:
          int childFrmModeHt = m_pCfgFileManager->readIntEntry( "mainmodule session", "Childframe mode height", desktop()->height() - 50);
          mainframe->resize( m_pMdiMainFrm->width(), childFrmModeHt);

    // restore a possible maximized Childframe mode
    bool maxChildFrmMode = config->readBoolEntry( "mainmodule session", "maximized childframes", true);
The maximized-Childframe mode means that currently all views are maximized in Childframe mode's application desktop.

This class provides placing algorithms in Childframe mode. Call tilePragma(), tileAnodine(), tileVertically(), cascadeWindows(), cascadeMaximized(), expandVertical(), expandHorizontal() for those actions.

activateView(QextMdiChildView*) and activateView(int index) set the appropriate MDI child view as the active one. It will be raised, gets an active MDI frame and gets the focus. Call activeView() to find out what the current MDI view is.

Use detachWindow() and attachWindow() for docking the MDI views to desktop and back.

Connect accels of your program with activatePrevWin(), activateNextWin() and activateView(int index).

Note: QextMdiChildViews can be added in 2 meanings: Either as a normal child view (usually containing user document views) or as a tool-view (usually containing status, info or control widgets). The tool-views can be added as floating dockwidgets or as stay-on-top desktop windows in tool style.

Here's an example how you can suggest things for the adding of views to the MDI control via flags:

 m_mapOfMdiWidgets.insert( pWnd, mh);
 unsigned int mdiFlags = QextMdi::StandardAdd;
 if( !bShow)
    mdiFlags |= QextMdi::Hide;
 if( !bAttach)
    mdiFlags |= QextMdi::Detach;
 if( bMinimize)
    mdiFlags |= QextMdi::Minimize;
 if( bToolWindow)
    mdiFlags |= QextMdi::ToolWindow;
 if (m_pMdiMainFrm->isFakingSDIApplication()) {
    if (bAttach) { // fake an SDI app
       mdiFlags |= QextMdi::Maximize;
    else {
       m_pMdiMainFrm->addWindow( pWnd, QPoint(20, 20), QextMdi::AddWindowFlags(mdiFlags));
 m_pMdiMainFrm->addWindow( pWnd, QextMdi::AddWindowFlags(mdiFlags));

Further note: Pay attention to the fact that when you click on the close button of MDI views that their close event should be redirected to closeWindow(). Otherwise the mainframe class will not get noticed about the deleted view and a dangling pointer will remain in the MDI control. The closeWindow() or the removeWindowFromMdi() method is for that issue. The difference is closeWindow() deletes the view object. So if your application wants to control that by itself, call removeWindowFromMdi() and call delete by yourself. See also QextMdiChildView::closeEvent() for tat issue.

Definition at line 206 of file qextmdimainfrm.h.

Public Slots

virtual void activateNextWin ()
virtual void activatePrevWin ()
virtual void activateView (int index)
virtual void addWindow (QextMdiChildView *pView, QRect rectNormal, int flags=QextMdi::StandardAdd)
virtual void addWindow (QextMdiChildView *pView, QPoint pos, int flags=QextMdi::StandardAdd)
virtual void addWindow (QextMdiChildView *pView, int flags=QextMdi::StandardAdd)
virtual void attachWindow (QextMdiChildView *pWnd, bool bShow=TRUE)
virtual void cascadeMaximized ()
virtual void cascadeWindows ()
virtual void childWindowCloseRequest (QextMdiChildView *pWnd)
virtual void closeActiveView ()
virtual void closeAllViews ()
virtual void closeWindow (QextMdiChildView *pWnd, bool layoutTaskBar=TRUE)
virtual void detachWindow (QextMdiChildView *pWnd, bool bShow=TRUE)
virtual void expandHorizontal ()
virtual void expandVertical ()
virtual void fillWindowMenu ()
virtual void finishChildframeMode ()
virtual void finishTabPageMode ()
virtual void finishToplevelMode ()
virtual void hideViewTaskBar ()
virtual void iconifyAllViews ()
bool isViewTaskBarOn ()
virtual void removeWindowFromMdi (QextMdiChildView *pWnd)
virtual void setEnableMaximizedChildFrmMode (bool bEnable)
virtual void setFrameDecorOfAttachedViews (int frameDecor)
virtual void showViewTaskBar ()
virtual void slot_toggleTaskBar ()
virtual void switchToChildframeMode ()
virtual void switchToTabPageMode ()
virtual void switchToToplevelMode ()
virtual void tileAnodine ()
virtual void tilePragma ()
virtual void tileVertically ()


void childViewIsDetachedNow (QWidget *)
void lastChildFrmClosed ()
void lastChildViewClosed ()
void leftTopLevelMode ()

Public Member Functions

QextMdiChildViewactiveWindow ()
virtual void applyOptions ()
int childFrameModeHeight ()
< QextMdiChildView * > * 
createIterator ()
QSize defaultChildFrmSize ()
void deleteIterator (QextMdiIterator< QextMdiChildView * > *pIt)
virtual bool event (QEvent *e)
virtual bool eventFilter (QObject *obj, QEvent *e)
void fakeSDIApplication ()
void findRootDockWidgets (QList< KDockWidget > *pRootDockWidgetList, QValueList< QRect > *pPositionList)
QextMdiChildViewfindWindow (const QString &caption)
bool isFakingSDIApplication ()
bool isInMaximizedChildFrmMode ()
 QextMdiMainFrm (QWidget *parentWidget, const char *name="", WFlags flags=WType_TopLevel|WDestructiveClose)
virtual void setBackgroundColor (const QColor &c)
virtual void setBackgroundPixmap (const QPixmap &pm)
void setDefaultChildFrmSize (const QSize &sz)
virtual void setMenuForSDIModeSysButtons (KMenuBar *=0)
virtual void setMinimumSize (int minw, int minh)
virtual void setSysButtonsAtMenuPosition ()
virtual void setUndockPositioningOffset (QPoint offset)
virtual int taskBarHeight ()
virtual QPopupMenu * taskBarPopup (QextMdiChildView *pWnd, bool bIncludeWindowPopup=FALSE)
bool windowExists (QextMdiChildView *pWnd)
QPopupMenu * windowMenu ()
virtual QPopupMenu * windowPopup (QextMdiChildView *pWnd, bool bIncludeTaskbarPopup=TRUE)
virtual ~QextMdiMainFrm ()

Static Public Member Functions

static int frameDecorOfAttachedViews ()
static QextMdi::MdiMode mdiMode ()

Protected Slots

virtual void activateView (QextMdiChildView *pWnd)
void dockMenuItemActivated (int id)
void dragEndTimeOut ()
void popupWindowMenu (QPoint p)
void switchOffMaximizeModeForMenu (QextMdiChildFrm *oldChild)
virtual void taskbarButtonRightClicked (QextMdiChildView *pWnd)
void updateSysButtonConnections (QextMdiChildFrm *oldChild, QextMdiChildFrm *newChild)
void windowMenuItemActivated (int id)

Protected Member Functions

virtual void addToolWindow (QWidget *pWnd, KDockWidget::DockPosition pos=KDockWidget::DockNone, QWidget *pTargetWnd=0L, int percent=50, const QString &tabToolTip=0, const QString &tabCaption=0)
void blockClearingOfWindowMenu (bool bBlocked)
virtual void createMdiManager ()
virtual void createTaskBar ()
virtual void resizeEvent (QResizeEvent *)

Protected Attributes

bool m_bClearingOfWindowMenuBlocked
bool m_bMaximizedChildFrmMode
bool m_bSDIApplication
int m_oldMainFrmHeight
int m_oldMainFrmMaxHeight
int m_oldMainFrmMinHeight
QToolButton * m_pClose
QPixmap * m_pCloseButtonPixmap
QGuardedPtr< KDockWidget > m_pDockbaseAreaOfDocumentViews
QGuardedPtr< KDockWidget > m_pDockbaseOfTabPage
QTimer * m_pDragEndTimer
KMenuBar * m_pMainMenuBar
QPixmap * m_pMinButtonPixmap
QToolButton * m_pMinimize
QPopupMenu * m_pPlacingMenu
QToolButton * m_pRestore
QPixmap * m_pRestoreButtonPixmap
QPopupMenu * m_pTaskBarPopup
QDomDocument * m_pTempDockSession
QToolButton * m_pUndock
QPixmap * m_pUndockButtonPixmap
QPopupMenu * m_pWindowMenu
QPopupMenu * m_pWindowPopup
QList< QextMdiChildView > * m_pWinList
QPoint m_undockPositioningOffset

Static Protected Attributes

static QextMdi::FrameDecor m_frameDecoration = QextMdi::KDE2Look
static QextMdi::MdiMode m_mdiMode = QextMdi::ChildframeMode


class QextMdiChildView
class QextMdiTaskBar

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index