Logo Search packages:      
Sourcecode: kdewebdev version File versions

KMdiMainFrm Class Reference

#include <kmdimainfrm.h>

Inheritance diagram for KMdiMainFrm:


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 KMdiMainFrm. Then usually you'll just need addWindow() and removeWindowFromMdi() to control the views.

   class MyMainWindow : public KMdiMainFrm
   { .... };
   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)
   KMdiMainFrm::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:

    // restore MDI mode (toplevel, childframe, tabpage)
    int mdiMode = config->readIntEntry( "mainmodule session", "MDI mode", KMdi::ChildframeMode);
    switch (mdiMode) {
    case KMdi::ToplevelMode:
          int childFrmModeHt = config->readIntEntry( "mainmodule session", "Childframe mode height", desktop()->height() - 50);
          mainframe->resize( m_pMdiMainFrm->width(), childFrmModeHt);
    case KMdi::ChildframeMode:
    case KMdi::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(KMdiChildView*) 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: KMdiChildViews 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 = KMdi::StandardAdd;
 if( !bShow)
    mdiFlags |= KMdi::Hide;
 if( !bAttach)
    mdiFlags |= KMdi::Detach;
 if( bMinimize)
    mdiFlags |= KMdi::Minimize;
 if( bToolWindow)
    mdiFlags |= KMdi::ToolWindow;
 if (m_pMdiMainFrm->isFakingSDIApplication()) {
    if (bAttach) { // fake an SDI app
       mdiFlags |= KMdi::Maximize;
    else {
       m_pMdiMainFrm->addWindow( pWnd, QPoint(20, 20), KMdi::AddWindowFlags(mdiFlags));
 m_pMdiMainFrm->addWindow( pWnd, KMdi::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 KMdiChildView::closeEvent() for tat issue.

Definition at line 204 of file kmdimainfrm.h.

Public Types

enum  ExistsAs { DocumentView, ToolView, AnyView }

Public Slots

virtual void activateFirstWin ()
virtual void activateLastWin ()
virtual void activateNextWin ()
virtual void activatePrevWin ()
virtual void activateView (int index)
virtual KMdiToolViewAccessor * addToolWindow (QWidget *pWnd, KDockWidget::DockPosition pos=KDockWidget::DockNone, QWidget *pTargetWnd=0L, int percent=50, const QString &tabToolTip=0, const QString &tabCaption=0)
virtual void addWindow (KMdiChildView *pView, QRect rectNormal, int flags=KMdi::StandardAdd)
virtual void addWindow (KMdiChildView *pView, QPoint pos, int flags=KMdi::StandardAdd)
void addWindow (KMdiChildView *pView, int flags, int index)
virtual void addWindow (KMdiChildView *pView, int flags=KMdi::StandardAdd)
virtual void attachWindow (KMdiChildView *pWnd, bool bShow=true, bool bAutomaticResize=false)
virtual void cascadeMaximized ()
virtual void cascadeWindows ()
virtual void childWindowCloseRequest (KMdiChildView *pWnd)
virtual void closeActiveView ()
virtual void closeAllViews ()
virtual void closeWindow (KMdiChildView *pWnd, bool layoutTaskBar=true)
KMdiToolViewAccessor * createToolWindow ()
KMdiChildViewcreateWrapper (QWidget *view, const QString &name, const QString &shortName)
virtual void deleteToolWindow (KMdiToolViewAccessor *accessor)
virtual void deleteToolWindow (QWidget *pWnd)
virtual void detachWindow (KMdiChildView *pWnd, bool bShow=true)
virtual void expandHorizontal ()
virtual void expandVertical ()
virtual void fillWindowMenu ()
virtual void finishChildframeMode ()
virtual void finishIDEAlMode (bool full=true)
virtual void finishTabPageMode ()
virtual void finishToplevelMode ()
virtual void hideViewTaskBar ()
virtual void iconifyAllViews ()
bool isViewTaskBarOn ()
void nextToolViewInDock ()
void prevToolViewInDock ()
virtual void removeWindowFromMdi (KMdiChildView *pWnd)
virtual void setEnableMaximizedChildFrmMode (bool bEnable)
virtual void setFrameDecorOfAttachedViews (int frameDecor)
void setIDEAlModeStyle (int flags) KDE_DEPRECATED
void setToolviewStyle (int flags)
virtual void showViewTaskBar ()
virtual void slot_toggleTaskBar ()
virtual void switchToChildframeMode ()
virtual void switchToIDEAlMode ()
virtual void switchToTabPageMode ()
virtual void switchToToplevelMode ()
virtual void tileAnodine ()
virtual void tilePragma ()
virtual void tileVertically ()


void childViewIsDetachedNow (QWidget *)
void collapseOverlapContainers ()
void lastChildFrmClosed ()
void lastChildViewClosed ()
void leftTopLevelMode ()
void mdiModeHasBeenChangedTo (KMdi::MdiMode)
void toggleBottom ()
void toggleLeft ()
void toggleRight ()
void toggleTop ()
void viewActivated (KMdiChildView *)
void viewDeactivated (KMdiChildView *)

Public Member Functions

KMdiChildViewactiveWindow ()
virtual void applyOptions ()
int childFrameModeHeight ()
KMdiIterator< KMdiChildView * > * createIterator ()
QSize defaultChildFrmSize ()
void deleteIterator (KMdiIterator< KMdiChildView * > *pIt)
virtual bool event (QEvent *e)
virtual bool eventFilter (QObject *obj, QEvent *e)
void fakeSDIApplication ()
void findRootDockWidgets (QPtrList< KDockWidget > *pRootDockWidgetList, QValueList< QRect > *pPositionList)
KMdiChildViewfindWindow (const QString &caption)
bool isFakingSDIApplication () const
bool isInMaximizedChildFrmMode ()
 KMdiMainFrm (QWidget *parentWidget, const char *name="", KMdi::MdiMode mdiMode=KMdi::ChildframeMode, WFlags flags=WType_TopLevel|WDestructiveClose)
KMdi::MdiMode mdiMode ()
virtual void setBackgroundColor (const QColor &c)
virtual void setBackgroundPixmap (const QPixmap &pm)
void setDefaultChildFrmSize (const QSize &sz)
void setManagedDockPositionModeEnabled (bool enabled)
virtual void setMenuForSDIModeSysButtons (KMenuBar *=0)
virtual void setMinimumSize (int minw, int minh)
void setStandardMDIMenuEnabled (bool showModeMenu=true)
void setSwitching (const bool switching)
virtual void setSysButtonsAtMenuPosition ()
virtual void setUndockPositioningOffset (QPoint offset)
bool switching (void) const
virtual int taskBarHeight ()
virtual QPopupMenu * taskBarPopup (KMdiChildView *pWnd, bool bIncludeWindowPopup=false)
bool windowExists (KMdiChildView *pWnd, ExistsAs as)
QPopupMenu * windowMenu () const
virtual QPopupMenu * windowPopup (KMdiChildView *pWnd, bool bIncludeTaskbarPopup=true)
virtual ~KMdiMainFrm ()

Static Public Member Functions

static int frameDecorOfAttachedViews ()

Protected Slots

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

Protected Member Functions

void blockClearingOfWindowMenu (bool bBlocked)
virtual void createMdiManager ()
virtual void createTaskBar ()
void dockToolViewsIntoContainers (QPtrList< KDockWidget > &widgetsToReparent, KDockWidget *container)
void findToolViewsDockedToMain (QPtrList< KDockWidget > *list, KDockWidget::DockPosition dprtmw)
void idealToolViewsToStandardTabs (QStringList widgetNames, KDockWidget::DockPosition pos, int sizee)
QStringList prepareIdealToTabs (KDockWidget *container)
virtual void resizeEvent (QResizeEvent *)
void setTabWidgetVisibility (KMdi::TabWidgetVisibility)
class KTabWidgettabWidget () const
KMdi::TabWidgetVisibility tabWidgetVisibility ()

Protected Attributes

bool m_bClearingOfWindowMenuBlocked
bool m_bMaximizedChildFrmMode
bool m_bSDIApplication
bool m_bSwitching
KMdi::MdiMode m_mdiMode
int m_oldMainFrmHeight
int m_oldMainFrmMaxHeight
int m_oldMainFrmMinHeight
QToolButton * m_pClose
QPixmap * m_pCloseButtonPixmap
QPopupMenu * m_pDockMenu
QPtrList< KMdiChildView > * m_pDocumentViews
QTimer * m_pDragEndTimer
KMenuBar * m_pMainMenuBar
QPopupMenu * m_pMdiModeMenu
QPixmap * m_pMinButtonPixmap
QToolButton * m_pMinimize
QPopupMenu * m_pPlacingMenu
QToolButton * m_pRestore
QPixmap * m_pRestoreButtonPixmap
QPopupMenu * m_pTaskBarPopup
QDomDocument * m_pTempDockSession
QMap< QWidget
*, KMdiToolViewAccessor * > * 
QToolButton * m_pUndock
QPixmap * m_pUndockButtonPixmap
QPopupMenu * m_pWindowMenu
QPopupMenu * m_pWindowPopup
QPoint m_undockPositioningOffset

Static Protected Attributes

static KMdi::FrameDecor m_frameDecoration = KMdi::KDELook

Private Slots

void removeFromActiveDockList (KMdiDockContainer *)
void setActiveToolDock (KMdiDockContainer *)
void slotDocCurrentChanged (QWidget *)

Private Member Functions

void setupTabbedDocumentViewSpace ()
void setupToolViewsForIDEALMode ()

Private Attributes

KMdiMainFrmPrivate * d
class KMdiDocumentViewTabWidget * m_documentTabWidget
bool m_managedDockPositionMode
KMDIPrivate::KMDIGUIClient * m_mdiGUIClient


class KMdiChildView
class KMdiTaskBar
class KMdiToolViewAccessor

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

Generated by  Doxygen 1.6.0   Back to index