Google

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:

  • an opened view is always maximized
  • buttons for maximized childframe mode aren't inserted in the main menubar
  • taskbar and windowmenu are not created/updated

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:

  • the view should be attached or detached.
  • shown or hidden
  • maximized, minimized or restored (normalized)
  • added as tool view (stay-on-top and toplevel) or added as document-type view.

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

    addWindow

    [virtual slot]

    See the method above for more details. Additionally, it moves to point pos.

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

    addWindow

    [virtual slot]

    See the method above for more details. Additionally, it sets the geometry.

    void  removeWindowFromMdi (QextMdiChildView *pWnd)

    removeWindowFromMdi

    [virtual slot]

    Removes a QextMdiChildView from the MDI system and from the main frame`s control. Note: The view will not be deleted, but it's getting toplevel (reparent to 0)!

    void  closeWindow (QextMdiChildView *pWnd, bool layoutTaskBar = TRUE)

    closeWindow

    [virtual slot]

    Removes a QextMdiChildView from the MDI system and from the main frame`s control. Note: The view will be deleted!

    void  slot_toggleTaskBar ()

    slot_toggleTaskBar

    [virtual slot]

    Switches the QextMdiTaskBar on and off.

    void  attachWindow (QextMdiChildView *pWnd,bool bShow=TRUE)

    attachWindow

    [virtual slot]

    Makes a main frame controlled undocked QextMdiChildView docked. Doesn't work on QextMdiChildView which aren't added to the MDI system. Use addWindow() for that.

    void  detachWindow (QextMdiChildView *pWnd,bool bShow=TRUE)

    detachWindow

    [virtual slot]

    Makes a docked QextMdiChildView undocked. The view window still remains under the main frame's MDI control.

    void  childWindowCloseRequest (QextMdiChildView *pWnd)

    childWindowCloseRequest

    [virtual slot]

    Someone wants that the MDI view to be closed. This method sends a QextMdiViewCloseEvent to itself to break the function call stack. See also event() .

    void  closeAllViews ()

    closeAllViews

    [virtual slot]

    Close all views

    void  iconifyAllViews ()

    iconifyAllViews

    [virtual slot]

    Iconfiy all views

    void  closeActiveView ()

    closeActiveView

    [virtual slot]

    Closes the view of the active (topchild) window

    void  switchToToplevelMode ()

    switchToToplevelMode

    [virtual slot]

    Undocks all view windows (unix-like)

    void  finishToplevelMode ()

    finishToplevelMode

    [virtual slot]

    void  switchToChildframeMode ()

    switchToChildframeMode

    [virtual slot]

    Docks all view windows (Windows-like)

    void  finishChildframeMode ()

    finishChildframeMode

    [virtual slot]

    void  switchToTabPageMode ()

    switchToTabPageMode

    [virtual slot]

    Docks all view windows (Windows-like)

    void  finishTabPageMode ()

    finishTabPageMode

    [virtual slot]

    void  showViewTaskBar ()

    showViewTaskBar

    [virtual slot]

    Shows the view taskbar. This should be connected with your "View" menu.

    void  hideViewTaskBar ()

    hideViewTaskBar

    [virtual slot]

    Hides the view taskbar. This should be connected with your "View" menu.

    void  fillWindowMenu ()

    fillWindowMenu

    [virtual slot]

    Update of the window menu contents.

    void  cascadeWindows ()

    cascadeWindows

    [virtual slot]

    Cascades the windows without resizing them.

    void  cascadeMaximized ()

    cascadeMaximized

    [virtual slot]

    Cascades the windows resizing them to the maximum available size.

    void  expandVertical ()

    expandVertical

    [virtual slot]

    Maximizes only in vertical direction.

    void  expandHorizontal ()

    expandHorizontal

    [virtual slot]

    Maximizes only in horizontal direction.

    void  tilePragma ()

    tilePragma

    [virtual slot]

    Tile Pragma

    void  tileAnodine ()

    tileAnodine

    [virtual slot]

    Tile Anodine

    void  tileVertically ()

    tileVertically

    [virtual slot]

    Tile Vertically

    void  setFrameDecorOfAttachedViews ( int frameDecor)

    setFrameDecorOfAttachedViews

    [virtual slot]

    Sets the decoration of the window frame of docked (attached) MDI views

    void  setEnableMaximizedChildFrmMode (bool bEnable)

    setEnableMaximizedChildFrmMode

    [virtual slot]

    If in Childframe mode, we can switch between maximized or restored shown MDI views

    void  activateNextWin ()

    activateNextWin

    [virtual slot]

    Activates the next open view

    void  activatePrevWin ()

    activatePrevWin

    [virtual slot]

    Activates the previous open view

    void  activateView (int index)

    activateView

    [virtual slot]

    Activates the view with the tab page index (TabPage mode only)

    void  resizeEvent (QResizeEvent * )

    resizeEvent

    [protected virtual]

    void  createTaskBar ()

    createTaskBar

    [protected virtual]

    Creates a new MDI taskbar (showing the MDI views as taskbar entries) and shows it.

    void  createMdiManager ()

    createMdiManager

    [protected virtual]

    Creates the MDI view area and connects some signals and slots with the QextMdiMainFrm widget.

    void  addToolWindow ( QWidget* pWnd, KDockWidget::DockPosition pos = KDockWidget::DockNone, QWidget* pTargetWnd = 0L, int percent = 50, const QString& tabToolTip = 0, const QString& tabCaption = 0)

    addToolWindow

    [protected virtual]

    Usually called from addWindow() when adding a tool view window. It reparents the given widget as toplevel and stay-on-top on the application's main widget.

    void  blockClearingOfWindowMenu ( bool bBlocked)

    blockClearingOfWindowMenu

    [protected]

    prevents fillWindowMenu() from m_pWindowMenu->clear(). You have to care for it by yourself. This is useful if you want to add some actions in your overridden fillWindowMenu() method.

    void  activateView (QextMdiChildView *pWnd)

    activateView

    [protected slots virtual slot]

    Sets the focus to this MDI view, raises it, activates its taskbar button and updates the system buttons in the main menubar when in maximized (Maximize mode).

    void  taskbarButtonRightClicked (QextMdiChildView *pWnd)

    taskbarButtonRightClicked

    [protected slots virtual slot]

    Activates the MDI view (see activateView() ) and popups the taskBar popup menu (see taskBarPopup() ).

    void  switchOffMaximizeModeForMenu (QextMdiChildFrm* oldChild)

    switchOffMaximizeModeForMenu

    [protected slots slot]

    Turns the system buttons for maximize mode (SDI mode) off, and disconnects them

    void  updateSysButtonConnections ( QextMdiChildFrm* oldChild, QextMdiChildFrm* newChild)

    updateSysButtonConnections

    [protected slots slot]

    Reconnects the system buttons form maximize mode (SDI mode) with the new child frame

    void  windowMenuItemActivated (int id)

    windowMenuItemActivated

    [protected slots slot]

    Usually called when the user clicks an MDI view item in the "Window" menu.

    void  dockMenuItemActivated (int id)

    dockMenuItemActivated

    [protected slots slot]

    Usually called when the user clicks an MDI view item in the sub-popup menu "Docking" of the "Window" menu.

    void  popupWindowMenu (QPoint p)

    popupWindowMenu

    [protected slots slot]

    Popups the "Window" menu. See also windowPopup() .

    void  dragEndTimeOut ()

    dragEndTimeOut

    [protected slots slot]

    The timer for main widget moving has elapsed -> send drag end to all concerned views.

    void  lastChildFrmClosed ()

    lastChildFrmClosed

    [signal]

    Signals the last attached QextMdiChildView has been closed

    void  lastChildViewClosed ()

    lastChildViewClosed

    [signal]

    Signals the last QextMdiChildView (that is under MDI control) has been closed

    void  leftTopLevelMode ()

    leftTopLevelMode

    [signal]

    Signals that the Toplevel mode has been left

    void  childViewIsDetachedNow (QWidget*)

    childViewIsDetachedNow

    [signal]

    Signals that a child view has been detached (undocked to desktop)


    Generated by: falk on pc9 on Fri Nov 30 14:44:26 2001, using kdoc 2.0a53.