class QextMdiMainFrm

Base class for all your special main frames. More...

Definition#include <include/qextmdimainfrm.h>
InheritsDockMainWindow (unknown) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Slots

Signals

Public Static Methods

Protected Methods

Protected Slots

Protected Members

Private Members


Detailed Description

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;
   qApp->setMainWidget(&mainframe);
   mainframe->addWindow(view1); // put it under MDI control
   mainframe->addWindow(view2);

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);
   setSysButtonsAtMenuPosition();
 }

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);
 #endif

    // 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);
          mainframe->switchToToplevelMode();
       }
       break;
    case QextMdi::ChildframeMode:
       break;
    case QextMdi::TabPageMode:
       {
          int childFrmModeHt = m_pCfgFileManager->readIntEntry( "mainmodule session", "Childframe mode height", desktop()->height() - 50);
          mainframe->resize( m_pMdiMainFrm->width(), childFrmModeHt);
          mainframe->switchToTabPageMode();
       }
       break;
    default:
       break;
    }

    // restore a possible maximized Childframe mode
    bool maxChildFrmMode = config->readBoolEntry( "mainmodule session", "maximized childframes", true);
    mainframe->setEnableMaximizedChildFrmMode(maxChildFrmMode);

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));
       return;
    }
 }
 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.

friend class QextMdiChildView

QextMdiChildView

[private]

friend class QextMdiTaskBar

QextMdiTaskBar

[private]

QextMdiChildArea * m_pMdi

m_pMdi

[protected]

QextMdiTaskBar * m_pTaskBar

m_pTaskBar

[protected]

QList<QextMdiChildView> * m_pWinList

m_pWinList

[protected]

QextMdiChildView * m_pCurrentWindow

m_pCurrentWindow

[protected]

QPopupMenu * m_pWindowPopup

m_pWindowPopup

[protected]

QPopupMenu * m_pTaskBarPopup

m_pTaskBarPopup

[protected]

QPopupMenu * m_pWindowMenu

m_pWindowMenu

[protected]

QPopupMenu * m_pDockMenu

m_pDockMenu

[protected]

QPopupMenu * m_pMdiModeMenu

m_pMdiModeMenu

[protected]

QPopupMenu * m_pPlacingMenu

m_pPlacingMenu

[protected]

QMenuBar * m_pMainMenuBar

m_pMainMenuBar

[protected]

KMenuBar * m_pMainMenuBar

m_pMainMenuBar

[protected]

QPixmap * m_pUndockButtonPixmap

m_pUndockButtonPixmap

[protected]

QPixmap * m_pMinButtonPixmap

m_pMinButtonPixmap

[protected]

QPixmap * m_pRestoreButtonPixmap

m_pRestoreButtonPixmap

[protected]

QPixmap * m_pCloseButtonPixmap

m_pCloseButtonPixmap

[protected]

QToolButton * m_pUndock

m_pUndock

[protected]

QToolButton * m_pMinimize

m_pMinimize

[protected]

QToolButton * m_pRestore

m_pRestore

[protected]

QToolButton * m_pClose

m_pClose

[protected]

QPoint m_undockPositioningOffset

m_undockPositioningOffset

[protected]

static QextMdi::MdiMode m_mdiMode

m_mdiMode

[protected]

bool m_bMaximizedChildFrmMode

m_bMaximizedChildFrmMode

[protected]

int m_oldMainFrmHeight

m_oldMainFrmHeight

[protected]

int m_oldMainFrmMinHeight

m_oldMainFrmMinHeight

[protected]

int m_oldMainFrmMaxHeight

m_oldMainFrmMaxHeight

[protected]

static QextMdi::FrameDecor m_frameDecoration

m_frameDecoration

[protected]

bool m_bSDIApplication

m_bSDIApplication

[protected]

KDockWidget* m_pDockbaseAreaOfDocumentViews

m_pDockbaseAreaOfDocumentViews

[protected]

KDockWidget* m_pDockbaseOfTabPage

m_pDockbaseOfTabPage

[protected]

QDomDocument* m_pTempDockSession

m_pTempDockSession

[protected]

bool m_bClearingOfWindowMenuBlocked

m_bClearingOfWindowMenuBlocked

[protected]

QTimer* m_pDragEndTimer

m_pDragEndTimer

[protected]

 QextMdiMainFrm ( QWidget* parentWidget, const char* name = "", WFlags flags = WType_TopLevel | WDestructiveClose)

QextMdiMainFrm

Constructor.

 ~QextMdiMainFrm ()

~QextMdiMainFrm

[virtual]

Destructor.

bool  isInMaximizedChildFrmMode ()

isInMaximizedChildFrmMode

Returns whether the application's MDI views are in maximized state or not.

QextMdi::MdiMode  mdiMode ()

mdiMode

[static]

Returns the MDI mode. This can be one of the enumerations QextMdi::MdiMode.

QextMdiChildView *  activeWindow ()

activeWindow

Returns the focused attached MDI view.

QPopupMenu *  taskBarPopup (QextMdiChildView *pWnd,bool bIncludeWindowPopup = FALSE)

taskBarPopup

[virtual]

Returns a popup menu filled according to the MDI view state. You can override this method to insert additional entries there. The popup menu is usually popuped when the user clicks with the right mouse button on a taskbar entry. The default entries are: Undock/Dock, Restore/Maximize/Minimize, Close and an empty sub-popup ( windowPopup() ) menu called Operations.

QPopupMenu *  windowPopup (QextMdiChildView *pWnd,bool bIncludeTaskbarPopup = TRUE)

windowPopup

[virtual]

Returns a popup menu with only a title "Window". You can fill it with own operations entries on the MDI view. This popup menu is inserted as last menu item in taskBarPopup() .

void  applyOptions ()

applyOptions

[virtual]

Called in the constructor (forces a resize of all MDI views)

QextMdiChildView *  findWindow (const QString& caption)

findWindow

Returns the QextMdiChildView belonging to the given caption string.

bool  windowExists (QextMdiChildView *pWnd)

windowExists

Returns whether this MDI child view is under MDI control (using addWindow() ) or not.

bool  event (QEvent* e)

event

[virtual]

Catches certain Qt events and processes it here. Currently, here this catches only the QextMdiViewCloseEvent (a QextMDI user event) which is sent from itself in childWindowCloseRequest() right after a QextMdiChildView::closeEvent() . The reason for this event to itself is simple: It just wants to break the function call stack. It continues the processing with calling closeWindow() . You see, a close() is translated to a closeWindow() . It is necessary that the main frame has to start an MDI view close action because it must remove the MDI view from MDI control, additionally.

This method calls QMainWindow::event , additionally.

void  setSysButtonsAtMenuPosition ()

setSysButtonsAtMenuPosition

[virtual]

If there's a main menubar given, it will create the 4 maximize mode buttons there (undock, minimize, restore, close).

int  taskBarHeight ()

taskBarHeight

[virtual]

Returns the height of the taskbar.

void  setUndockPositioningOffset ( QPoint offset)

setUndockPositioningOffset

[virtual]

Sets an offset value that is used on detachWindow() . The undocked window is visually moved on the desktop by this offset.

QextMdiIterator<QextMdiChildView*>*  createIterator ()

createIterator

If you don't want to know about the inner structure of the QextMDI system, you can use this iterator to handle with the MDI view list in a more abstract way. The iterator hides what special data structure is used in QextMDI.

void  deleteIterator (QextMdiIterator<QextMdiChildView*>* pIt)

deleteIterator

Deletes an QextMdiIterator created in the QextMDI library (needed for the windows dll problem).

QPopupMenu*  windowMenu ()

windowMenu

Returns a popup menu that contains the MDI controlled view list. Additionally, this menu provides some placing actions for these views. Usually, you insert this popup menu in your main menubar as "Window" menu.

void  setBackgroundColor ( const QColor &c)

setBackgroundColor

[virtual]

Sets a background colour for the MDI view area widget.

void  setBackgroundPixmap ( const QPixmap &pm)

setBackgroundPixmap

[virtual]

Sets a background pixmap for the MDI view area widget.

void  setDefaultChildFrmSize ( const QSize& sz)

setDefaultChildFrmSize

Sets a size that is used as the default size for a newly to the MDI system added QextMdiChildView . By default this size is 600x400. So all non-resized added MDI views appear in that size.

QSize  defaultChildFrmSize ()

defaultChildFrmSize

Returns the default size for a newly added QextMdiChildView. See setDefaultChildFrmSize() .

void  setMinimumSize ( int minw, int minh)

setMinimumSize

[virtual]

Do nothing when in Toplevel mode

int  childFrameModeHeight ()

childFrameModeHeight

Returns the Childframe mode height of this. Makes only sense when in Toplevel mode.

void  setMenuForSDIModeSysButtons ( KMenuBar* = 0)

setMenuForSDIModeSysButtons

[virtual]

Tells the MDI system a QMenu where it can insert buttons for the system menu, undock, minimize, restore actions. If no such menu is given, QextMDI simply overlays the buttons at the upper right-hand side of the main widget.

void  setMenuForSDIModeSysButtons ( QMenuBar* = 0)

setMenuForSDIModeSysButtons

[virtual]

int  frameDecorOfAttachedViews ()

frameDecorOfAttachedViews

[static]

Returns: the decoration of the window frame of docked (attached) MDI views

void  fakeSDIApplication ()

fakeSDIApplication

An SDI application user interface is faked:

bool  isFakingSDIApplication ()

isFakingSDIApplication

Returns: if we are fake an SDI application (fakeSDIApplication())

bool  eventFilter (QObject *obj, QEvent *e )

eventFilter

[virtual]

void  findRootDockWidgets (QList<KDockWidget>* pRootDockWidgetList, QValueList* pPositionList)

findRootDockWidgets

void  addWindow ( QextMdiChildView* pView, int flags = QextMdi::StandardAdd)

addWindow

[virtual slot]

One of the most important methods at all! Adds a QextMdiChildView to the MDI system. The main frame takes it under control. You can specify here whether: