41 #include <tqclipboard.h>
42 #include <tqobjectlist.h>
43 #include <tqpopupmenu.h>
44 #include <tqmenubar.h>
46 #include <tdemenubar.h>
47 #include <tdeapplication.h>
49 #include <tdeversion.h>
50 #include <tqtabwidget.h>
51 #include <tdelocale.h>
52 #include <tdestdaccel.h>
54 #include <kiconloader.h>
55 #include <tdemdidockcontainer.h>
58 #include <tqtoolbutton.h>
59 #include <tqdockarea.h>
62 #include <tqtextstream.h>
65 #include <tqvaluelist.h>
67 #include "tdemdimainfrm.h"
68 #include "tdemditaskbar.h"
69 #include "tdemdichildfrm.h"
70 #include "tdemdichildarea.h"
71 #include "tdemdichildview.h"
72 #include "tdemdidockcontainer.h"
73 #include "tdemditoolviewaccessor_p.h"
74 #include "tdemdifocuslist.h"
75 #include "tdemdidocumentviewtabwidget.h"
76 #include "tdemdiguiclient.h"
78 #include "win_undockbutton.xpm"
79 #include "win_minbutton.xpm"
80 #include "win_restorebutton.xpm"
81 #include "win_closebutton.xpm"
82 #include "kde_undockbutton.xpm"
83 #include "kde_minbutton.xpm"
84 #include "kde_restorebutton.xpm"
85 #include "kde_closebutton.xpm"
86 #include "kde2_undockbutton.xpm"
87 #include "kde2_minbutton.xpm"
88 #include "kde2_restorebutton.xpm"
89 #include "kde2_closebutton.xpm"
90 #include "kde2laptop_undockbutton.xpm"
91 #include "kde2laptop_minbutton.xpm"
92 #include "kde2laptop_restorebutton.xpm"
93 #include "kde2laptop_closebutton.xpm"
94 #include "kde2laptop_closebutton_menu.xpm"
113 using namespace KParts;
115 KMdi::FrameDecor KMdiMainFrm::m_frameDecoration = KMdi::KDELook;
117 class KMdiMainFrmPrivate
120 KMdiMainFrmPrivate() : focusList( 0 )
122 for (
int i = 0;i < 4;i++ )
124 activeDockPriority[ i ] = 0;
125 m_styleIDEAlMode = 0;
129 ~KMdiMainFrmPrivate()
131 KMdiDockContainer* activeDockPriority[ 4 ];
132 KMdiFocusList *focusList;
133 int m_styleIDEAlMode;
135 TDEAction *closeWindowAction;
139 KMdiMainFrm::KMdiMainFrm( TQWidget* parentWidget,
const char* name, KMdi::MdiMode mdiMode, WFlags flags )
140 : KParts::DockMainWindow( parentWidget, name, flags )
141 , m_mdiMode(
KMdi::UndefinedMode )
144 , m_pDocumentViews( 0L )
145 , m_pCurrentWindow( 0L )
146 , m_pWindowPopup( 0L )
147 , m_pTaskBarPopup( 0L )
148 , m_pWindowMenu( 0L )
150 , m_pMdiModeMenu( 0L )
151 , m_pPlacingMenu( 0L )
152 , m_pMainMenuBar( 0L )
153 , m_pUndockButtonPixmap( 0L )
154 , m_pMinButtonPixmap( 0L )
155 , m_pRestoreButtonPixmap( 0L )
156 , m_pCloseButtonPixmap( 0L )
161 , m_bMaximizedChildFrmMode( false )
162 , m_oldMainFrmHeight( 0 )
163 , m_oldMainFrmMinHeight( 0 )
164 , m_oldMainFrmMaxHeight( 0 )
165 , m_bSDIApplication( false )
166 , m_pDockbaseAreaOfDocumentViews( 0L )
167 , m_pTempDockSession( 0L )
168 , m_bClearingOfWindowMenuBlocked( false )
169 , m_pDragEndTimer( 0L )
170 , m_bSwitching( false )
171 , m_leftContainer( 0 )
172 , m_rightContainer( 0 )
173 , m_topContainer( 0 )
174 , m_bottomContainer( 0 )
175 , d( new KMdiMainFrmPrivate() )
176 , m_mdiGUIClient( 0 )
177 , m_managedDockPositionMode( false )
178 , m_documentTabWidget( 0 )
180 kdDebug(760) << k_funcinfo << endl;
182 m_pDocumentViews =
new TQPtrList<KMdiChildView>;
183 m_pDocumentViews->setAutoDelete(
false );
184 m_pToolViews =
new TQMap<TQWidget*, KMdiToolViewAccessor*>;
187 setFocusPolicy( TQWidget::ClickFocus );
193 m_pDockbaseAreaOfDocumentViews = createDockWidget(
"mdiAreaCover", TQPixmap(), 0L,
"mdi_area_cover" );
194 m_pDockbaseAreaOfDocumentViews->setDockWindowTransient(
this,
true );
195 m_pDockbaseAreaOfDocumentViews->setEnableDocking( KDockWidget::DockNone );
196 m_pDockbaseAreaOfDocumentViews->setDockSite( KDockWidget::DockCorner );
197 m_pDockbaseAreaOfDocumentViews->setWidget( m_pMdi );
199 setView( m_pDockbaseAreaOfDocumentViews );
200 setMainDockWidget( m_pDockbaseAreaOfDocumentViews );
205 m_pTaskBarPopup =
new TQPopupMenu(
this,
"taskbar_popup_menu" );
206 m_pWindowPopup =
new TQPopupMenu(
this,
"window_popup_menu" );
208 m_pWindowMenu =
new TQPopupMenu(
this,
"window_menu" );
209 m_pWindowMenu->setCheckable(
true );
210 TQObject::connect( m_pWindowMenu, TQ_SIGNAL( aboutToShow() ),
this, TQ_SLOT( fillWindowMenu() ) );
212 m_pDockMenu =
new TQPopupMenu(
this,
"dock_menu" );
213 m_pDockMenu->setCheckable(
true );
215 m_pMdiModeMenu =
new TQPopupMenu(
this,
"mdimode_menu" );
216 m_pMdiModeMenu->setCheckable(
true );
218 m_pPlacingMenu =
new TQPopupMenu(
this,
"placing_menu" );
220 d->closeWindowAction =
new TDEAction(i18n(
"&Close"), TDEStdAccel::close(),
221 this, TQ_SLOT(closeActiveView()), actionCollection(),
"window_close");
228 setMenuForSDIModeSysButtons( menuBar() );
232 case KMdi::IDEAlMode:
233 kdDebug(760) << k_funcinfo <<
"Switching to IDEAl mode" << endl;
236 case KMdi::TabPageMode:
237 kdDebug(760) << k_funcinfo <<
"Switching to tab page mode" << endl;
238 switchToTabPageMode();
240 case KMdi::ToplevelMode:
241 kdDebug(760) << k_funcinfo <<
"Switching to top level mode" << endl;
242 switchToToplevelMode();
245 m_mdiMode = KMdi::ChildframeMode;
246 kdDebug(760) << k_funcinfo <<
"Switching to child frame mode" << endl;
251 m_pDragEndTimer =
new TQTimer();
252 connect( m_pDragEndTimer, TQ_SIGNAL( timeout() ),
this, TQ_SLOT( dragEndTimeOut() ) );
253 connect( guiFactory(), TQ_SIGNAL( clientAdded( KXMLGUIClient* ) ),
254 this, TQ_SLOT( verifyToplevelHeight() ) );
255 connect( guiFactory(), TQ_SIGNAL( clientRemoved( KXMLGUIClient* ) ),
256 this, TQ_SLOT( verifyToplevelHeight() ) );
259 void KMdiMainFrm::verifyToplevelHeight()
261 if ( m_mdiMode != KMdi::ToplevelMode )
265 int topDockHeight = topDock() ? topDock()->height() : 0;
266 int menuBarHeight = hasMenuBar() ? menuBar()->height() : 0;
267 setFixedHeight( topDockHeight + menuBarHeight );
268 resize( width(), height() );
274 connect( m_mdiGUIClient, TQ_SIGNAL( toggleTop() ),
this, TQ_SIGNAL( toggleTop() ) );
275 connect( m_mdiGUIClient, TQ_SIGNAL( toggleLeft() ),
this, TQ_SIGNAL( toggleLeft() ) );
276 connect( m_mdiGUIClient, TQ_SIGNAL( toggleRight() ),
this, TQ_SIGNAL( toggleRight() ) );
277 connect( m_mdiGUIClient, TQ_SIGNAL( toggleBottom() ),
this, TQ_SIGNAL( toggleBottom() ) );
279 if ( m_mdiMode == KMdi::IDEAlMode )
281 if ( m_topContainer )
282 connect(
this, TQ_SIGNAL( toggleTop() ), m_topContainer->getWidget(), TQ_SLOT( toggle() ) );
283 if ( m_leftContainer )
284 connect(
this, TQ_SIGNAL( toggleLeft() ), m_leftContainer->getWidget(), TQ_SLOT( toggle() ) );
285 if ( m_rightContainer )
286 connect(
this, TQ_SIGNAL( toggleRight() ), m_rightContainer->getWidget(), TQ_SLOT( toggle() ) );
287 if ( m_bottomContainer )
288 connect(
this, TQ_SIGNAL( toggleBottom() ), m_bottomContainer->getWidget(), TQ_SLOT( toggle() ) );
295 KMdiMainFrm::~KMdiMainFrm()
298 TQValueList<KMdiChildView*> children;
299 for (
KMdiChildView * w = m_pDocumentViews->first();w;w = m_pDocumentViews->next() )
300 children.append( w );
303 TQValueListIterator<KMdiChildView*> childIt;
304 for ( childIt = children.begin(); childIt != children.end(); ++childIt )
310 delete m_pDocumentViews;
313 delete m_pDragEndTimer;
315 delete m_pUndockButtonPixmap;
316 delete m_pMinButtonPixmap;
317 delete m_pRestoreButtonPixmap;
318 delete m_pCloseButtonPixmap;
322 delete m_pMdiModeMenu;
323 delete m_pPlacingMenu;
324 delete m_pTaskBarPopup;
325 delete m_pWindowPopup;
326 delete m_pWindowMenu;
327 delete m_mdiGUIClient;
328 delete m_pTempDockSession;
338 TQPtrListIterator<KMdiChildView> it( *m_pDocumentViews );
339 for ( ; ( *it ); ++it )
341 TQWidget* childFrame = 0L;
342 if ( ( *it )->mdiParent() )
344 kdDebug(760) << k_funcinfo <<
"using child view's mdi parent for resize hack" << endl;
345 childFrame = ( *it )->mdiParent();
349 kdDebug(760) << k_funcinfo <<
"using child view for resize hack" << endl;
350 childFrame = ( *it );
353 int w = childFrame->width();
354 int h = childFrame->height();
355 childFrame->resize( w + 1, h + 1 );
356 childFrame->resize( w - 1, h - 1 );
363 kdDebug(760) << k_funcinfo <<
"creating MDI manager" << endl;
365 setCentralWidget( m_pMdi );
366 TQObject::connect( m_pMdi, TQ_SIGNAL( nowMaximized(
bool ) ),
368 TQObject::connect( m_pMdi, TQ_SIGNAL( noMaximizedChildFrmLeft(
KMdiChildFrm* ) ),
381 m_pTaskBar =
new KMdiTaskBar(
this, TQMainWindow::DockBottom );
382 m_pTaskBar->installEventFilter(
this );
392 void KMdiMainFrm::resizeEvent( TQResizeEvent *e )
394 if ( ( m_mdiMode == KMdi::ToplevelMode ) && !parentWidget() )
396 if ( e->oldSize().height() != e->size().height() )
399 KParts::DockMainWindow::resizeEvent( e );
400 if ( !m_mdiGUIClient )
409 if ( ( m_mdiMode == KMdi::ToplevelMode ) && !parentWidget() )
411 DockMainWindow::setMinimumSize( minw, minh );
422 TQBoxLayout* pLayout =
new TQHBoxLayout( pMDICover, 0, -1,
"layout" );
423 view->reparent( pMDICover, TQPoint( 0, 0 ) );
424 pLayout->addWidget( view );
429 const TQPixmap* wndIcon = view->icon();
431 pMDICover->setIcon( *wndIcon );
433 pMDICover->trackIconAndCaptionChanges( view );
449 if ( flags & KMdi::ToolWindow )
458 d->closeWindowAction->setEnabled(
true);
461 TQObject::connect( pWnd, TQ_SIGNAL( clickedInWindowMenu(
int ) ),
this, TQ_SLOT(
windowMenuItemActivated(
int ) ) );
466 TQObject::connect( pWnd, TQ_SIGNAL( clickedInDockMenu(
int ) ),
this, TQ_SLOT(
dockMenuItemActivated(
int ) ) );
471 m_pDocumentViews->append( pWnd );
473 m_pDocumentViews->insert( index, pWnd );
478 TQObject::connect( pWnd, TQ_SIGNAL( tabCaptionChanged(
const TQString& ) ), but, TQ_SLOT( setNewText(
const TQString& ) ) );
482 if ( m_mdiMode == KMdi::TabPageMode || m_mdiMode == KMdi::IDEAlMode )
486 pixmap = *( pWnd->icon() );
490 connect( pWnd, TQ_SIGNAL( iconUpdated( TQWidget*, TQPixmap ) ), m_documentTabWidget, TQ_SLOT( updateIconInView( TQWidget*, TQPixmap ) ) );
491 connect( pWnd, TQ_SIGNAL( captionUpdated( TQWidget*,
const TQString& ) ), m_documentTabWidget, TQ_SLOT( updateCaptionInView( TQWidget*,
const TQString& ) ) );
495 if ( ( flags & KMdi::Detach ) || ( m_mdiMode == KMdi::ToplevelMode ) )
501 attachWindow( pWnd, !( flags & KMdi::Hide ), flags & KMdi::UseKMdiSizeHint );
503 if ( ( m_bMaximizedChildFrmMode && ( !m_bSDIApplication && ( flags & KMdi::Detach ) )
504 && m_mdiMode != KMdi::ToplevelMode ) || ( flags & KMdi::Maximize ) )
510 if ( !m_bSDIApplication || ( flags & KMdi::Detach ) )
512 if ( flags & KMdi::Minimize )
515 if ( !( flags & KMdi::Hide ) )
530 if ( m_bMaximizedChildFrmMode && pWnd->
isAttached() )
533 pWnd->setGeometry( rectNormal );
540 if ( m_bMaximizedChildFrmMode && pWnd->
isAttached() )
550 return new KMdiToolViewAccessor(
this );
554 void KMdiMainFrm::deleteToolWindow( TQWidget* pWnd )
556 if ( m_pToolViews->contains( pWnd ) )
557 deleteToolWindow( ( *m_pToolViews ) [ pWnd ] );
560 void KMdiMainFrm::deleteToolWindow( KMdiToolViewAccessor *accessor )
567 int percent,
const TQString& tabToolTip,
const TQString& tabCaption )
569 TQWidget* tvta = pWnd;
570 KDockWidget* pDW = dockManager->getDockWidgetFromName( pWnd->name() );
574 pDW->setWidget( pWnd );
577 pDW->setPixmap( *pWnd->icon() );
579 pDW->setTabPageLabel( ( tabCaption == 0 ) ? pWnd->caption() : tabCaption );
580 pDW->setToolTipString( tabToolTip );
581 dockManager->removeFromAutoCreateList( pDW );
585 TQRect r = pWnd->geometry();
587 KMdiToolViewAccessor *mtva =
new KMdiToolViewAccessor(
this, pWnd, tabToolTip, ( tabCaption == 0 ) ? pWnd->caption() : tabCaption );
588 m_pToolViews->insert( tvta, mtva );
590 if ( pos == KDockWidget::DockNone )
592 mtva->d->widgetContainer->setEnableDocking( KDockWidget::DockNone );
593 mtva->d->widgetContainer->reparent(
this, (WFlags)(WType_TopLevel | WType_Dialog), r.topLeft(),
true );
596 mtva->place( pos, pTargetWnd, percent );
605 pWnd->installEventFilter(
this );
608 bool bCascade =
false;
609 TQApplication::sendPostedEvents();
610 TQRect frameGeo = pWnd->frameGeometry();
611 TQPoint topLeftScreen = pWnd->mapToGlobal( TQPoint( 0, 0 ) );
612 TQPoint topLeftMdiChildArea = m_pMdi->mapFromGlobal( topLeftScreen );
613 TQRect childAreaGeo = m_pMdi->geometry();
614 if ( topLeftMdiChildArea.x() < 0 || topLeftMdiChildArea.y() < 0 ||
615 ( topLeftMdiChildArea.x() + frameGeo.width() > childAreaGeo.width() ) ||
616 ( topLeftMdiChildArea.y() + frameGeo.height() > childAreaGeo.height() ) )
625 lpC->move( topLeftMdiChildArea );
627 lpC->
setClient( pWnd, bAutomaticResize );
630 if ( ( m_mdiMode == KMdi::ToplevelMode ) && !parentWidget() )
632 setMinimumHeight( m_oldMainFrmMinHeight );
633 setMaximumHeight( m_oldMainFrmMaxHeight );
634 resize( width(), m_oldMainFrmHeight );
635 m_oldMainFrmHeight = 0;
642 TQRect r = lpC->geometry();
643 lpC->setGeometry( -lpC->m_pClient->x(), -lpC->m_pClient->y(),
644 m_pMdi->width() + KMDI_CHILDFRM_DOUBLE_BORDER,
645 m_pMdi->height() + lpC->
captionHeight() + KMDI_CHILDFRM_SEPARATOR + KMDI_CHILDFRM_DOUBLE_BORDER );
655 TQFocusEvent fe( TQEvent::FocusIn );
656 TQApplication::sendEvent( pWnd, &fe );
658 m_pCurrentWindow = pWnd;
666 pWnd->removeEventFilter(
this );
669 if ( pWnd->parent() )
676 TQPixmap pixm( *( lpC->
icon() ) );
677 pWnd->setIcon( pixm );
679 TQString capt( lpC->
caption() );
690 if ( pWnd->size().isEmpty() || ( pWnd->size() == TQSize( 1, 1 ) ) )
692 if ( m_pCurrentWindow )
694 pWnd->setGeometry( TQRect( m_pMdi->
getCascadePoint( m_pDocumentViews->count() - 1 ), m_pCurrentWindow->size() ) );
702 if (
mdiMode() == KMdi::ToplevelMode )
704 XSetTransientForHint( tqt_xdisplay(), pWnd->winId(), topLevelWidget() ->winId() );
712 if (
mdiMode() == KMdi::ToplevelMode )
714 XSetTransientForHint( tqt_xdisplay(), pWnd->winId(), topLevelWidget() ->winId() );
734 if ( !( m_pWinList->removeRef( pWnd ) ) )
736 if ( m_pWinList->count() == 0 )
737 m_pCurrentWindow = 0L;
743 TQObject::disconnect( pWnd, TQ_SIGNAL( clickedInWindowMenu(
int ) ),
this, TQ_SLOT(
windowMenuItemActivated(
int ) ) );
744 TQObject::disconnect( pWnd, TQ_SIGNAL( clickedInDockMenu(
int ) ),
this, TQ_SLOT(
dockMenuItemActivated(
int ) ) );
751 TQObject::disconnect( pWnd, TQ_SIGNAL( tabCaptionChanged(
const TQString& ) ), but, TQ_SLOT( setNewText(
const TQString& ) ) );
756 if ( m_mdiMode == KMdi::TabPageMode )
758 if ( m_pWinList->count() == 0 )
760 if ( !m_pDockbaseAreaOfDocumentViews )
762 m_pDockbaseAreaOfDocumentViews = createDockWidget(
"mdiAreaCover", TQPixmap(), 0L,
"mdi_area_cover" );
763 m_pDockbaseAreaOfDocumentViews->setDockWindowTransient(
this,
true );
765 m_pDockbaseAreaOfDocumentViews->setWidget( m_pMdi );
766 setMainDockWidget( m_pDockbaseAreaOfDocumentViews );
768 m_pDockbaseOfTabPage->setDockSite( KDockWidget::DockFullSite );
769 m_pDockbaseAreaOfDocumentViews->setEnableDocking( KDockWidget::DockCenter );
770 m_pDockbaseAreaOfDocumentViews->manualDock( m_pDockbaseOfTabPage, KDockWidget::DockCenter );
771 m_pDockbaseAreaOfDocumentViews->setEnableDocking( KDockWidget::DockNone );
772 m_pDockbaseOfTabPage = m_pDockbaseAreaOfDocumentViews;
775 KDockWidget* pDockW = ( KDockWidget* ) pWnd->parentWidget();
776 pWnd->reparent( 0L, TQPoint( 0, 0 ) );
777 pDockW->setWidget( 0L );
778 if ( pDockW == m_pDockbaseOfTabPage )
780 TQTabWidget * pTab = ( TQTabWidget* ) pDockW->parentWidget() ->parentWidget();
781 int cnt = pTab->count();
782 m_pDockbaseOfTabPage = ( KDockWidget* ) pTab->page( cnt - 2 );
783 if ( pDockW == m_pDockbaseOfTabPage )
785 m_pDockbaseOfTabPage = ( KDockWidget* ) pTab->page( cnt - 1 );
789 if ( m_pWinList->count() == 1 )
805 m_pCurrentWindow = 0L;
812 else if ( m_pWinList->count() > 0 )
820 pWnd->m_bToolView =
false;
822 if ( !m_pCurrentWindow )
833 m_pDocumentViews->removeRef( pWnd );
834 if ( m_pDocumentViews->count() == 0 )
835 m_pCurrentWindow = 0L;
842 if ( ( m_mdiMode == KMdi::TabPageMode ) || ( m_mdiMode == KMdi::IDEAlMode ) )
844 if ( !m_documentTabWidget )
846 if ( m_pDocumentViews->count() == 0 )
848 pWnd->reparent( 0L, TQPoint( 0, 0 ) );
849 kdDebug(760) <<
"-------- 1" << endl;
850 if ( m_pDocumentViews->count() == 1 )
852 m_pDocumentViews->last() ->activate();
855 if ( ( m_mdiMode == KMdi::TabPageMode ) || ( m_mdiMode == KMdi::IDEAlMode ) )
857 if ( m_pDocumentViews->count() == 0 )
859 if ( !m_pDockbaseAreaOfDocumentViews )
861 m_pDockbaseAreaOfDocumentViews = createDockWidget(
"mdiAreaCover", TQPixmap(), 0L,
"mdi_area_cover" );
862 m_pDockbaseAreaOfDocumentViews->setDockWindowTransient(
this,
true );
863 m_pDockbaseAreaOfDocumentViews->setWidget( m_pMdi );
864 setMainDockWidget( m_pDockbaseAreaOfDocumentViews );
867 m_pDockbaseOfTabPage->setDockSite( KDockWidget::DockFullSite );
868 m_pDockbaseAreaOfDocumentViews->setEnableDocking( KDockWidget::DockCenter );
869 m_pDockbaseAreaOfDocumentViews->manualDock( m_pDockbaseOfTabPage, KDockWidget::DockCenter );
870 m_pDockbaseAreaOfDocumentViews->setEnableDocking( KDockWidget::DockNone );
871 m_pDockbaseOfTabPage = m_pDockbaseAreaOfDocumentViews;
877 KDockWidget* pDockW = ( KDockWidget* ) pWnd->parentWidget();
878 pWnd->reparent( 0L, TQPoint( 0, 0 ) );
879 pDockW->setWidget( 0L );
880 if ( pDockW == m_pDockbaseOfTabPage )
882 TQTabWidget * pTab = ( TQTabWidget* ) pDockW->parentWidget() ->parentWidget();
883 int cnt = pTab->count();
884 m_pDockbaseOfTabPage = ( KDockWidget* ) pTab->page( cnt - 2 );
885 if ( pDockW == m_pDockbaseOfTabPage )
887 m_pDockbaseOfTabPage = ( KDockWidget* ) pTab->page( cnt - 1 );
894 if ( m_pDocumentViews->count() == 1 )
896 m_pDocumentViews->last() ->activate();
910 m_pCurrentWindow = 0L;
917 else if ( m_pDocumentViews->count() > 0 )
919 if ( m_pDocumentViews->current() )
921 m_pDocumentViews->current() ->activate();
922 m_pDocumentViews->current() ->setFocus();
926 m_pDocumentViews->last() ->activate();
927 m_pDocumentViews->last() ->setFocus();
932 if ( !m_pCurrentWindow )
934 d->closeWindowAction->setEnabled(
false);
942 TQPtrListIterator<KMdiChildView> it( *m_pDocumentViews );
943 for ( ; ( *it ); ++it )
945 if ( ( *it )->caption() == caption )
954 return m_pCurrentWindow;
960 if ( ( as == ToolView ) || ( as == AnyView ) )
962 if ( m_pToolViews->contains( pWnd ) )
964 if ( as == ToolView )
968 if ( m_pDocumentViews->findRef( pWnd ) != -1 )
976 m_pWindowPopup->clear();
977 if ( bIncludeTaskbarPopup )
979 m_pWindowPopup->insertItem( i18n(
"Window" ),
taskBarPopup( pWnd,
false ) );
980 m_pWindowPopup->insertSeparator();
982 return m_pWindowPopup;
989 m_pTaskBarPopup->clear();
992 m_pTaskBarPopup->insertItem( i18n(
"Undock" ), pWnd, TQ_SLOT( detach() ) );
993 m_pTaskBarPopup->insertSeparator();
995 m_pTaskBarPopup->insertItem( i18n(
"Restore" ), pWnd, TQ_SLOT( restore() ) );
997 m_pTaskBarPopup->insertItem( i18n(
"Maximize" ), pWnd, TQ_SLOT( maximize() ) );
999 m_pTaskBarPopup->insertItem( i18n(
"Minimize" ), pWnd, TQ_SLOT( minimize() ) );
1002 m_pTaskBarPopup->insertItem( i18n(
"Dock" ), pWnd, TQ_SLOT( attach() ) );
1003 m_pTaskBarPopup->insertSeparator();
1004 m_pTaskBarPopup->insertItem( i18n(
"Close" ), pWnd, TQ_SLOT( close() ) );
1006 m_pTaskBarPopup->insertSeparator();
1007 m_pTaskBarPopup->insertItem( i18n(
"Operations" ),
windowPopup( pWnd,
false ) );
1008 return m_pTaskBarPopup;
1011 void KMdiMainFrm::slotDocCurrentChanged( TQWidget* pWidget )
1014 pWnd->m_bMainframesActivateViewIsPending =
true;
1016 bool bActivateNecessary =
true;
1017 if ( m_pCurrentWindow != pWnd )
1018 m_pCurrentWindow = pWnd;
1023 if ( m_documentTabWidget && ( m_mdiMode == KMdi::TabPageMode || m_mdiMode == KMdi::IDEAlMode ) )
1025 m_documentTabWidget->showPage( pWnd );
1039 if ( bActivateNecessary )
1043 if ( !pWnd->isActiveWindow() )
1044 pWnd->setActiveWindow();
1052 pWnd->m_bMainframesActivateViewIsPending =
false;
1058 pWnd->m_bMainframesActivateViewIsPending =
true;
1060 bool bActivateNecessary =
true;
1061 if ( m_pCurrentWindow != pWnd )
1062 m_pCurrentWindow = pWnd;
1065 bActivateNecessary =
false;
1068 pWnd->m_bInterruptActivation =
true;
1074 if ( m_documentTabWidget && m_mdiMode == KMdi::TabPageMode || m_mdiMode == KMdi::IDEAlMode )
1076 m_documentTabWidget->showPage( pWnd );
1090 if ( bActivateNecessary )
1094 if ( !pWnd->isActiveWindow() )
1095 pWnd->setActiveWindow();
1103 pWnd->m_bMainframesActivateViewIsPending =
false;
1116 TQApplication::postEvent(
this, ce );
1121 if ( e->type() == TQEvent::User )
1142 else if ( isVisible() && e->type() == TQEvent::Move )
1144 if ( m_pDragEndTimer->isActive() )
1147 m_pDragEndTimer->stop();
1152 TQPtrListIterator<KMdiChildView> it( *m_pDocumentViews );
1153 for ( ; ( *it ); ++it )
1156 TQApplication::sendEvent( ( *it ), &dragBeginEvent );
1159 m_pDragEndTimer->start( 200,
true );
1162 return DockMainWindow::event( e );
1167 if ( e->type() == TQEvent::Resize && m_mdiMode == KMdi::ToplevelMode )
1169 verifyToplevelHeight();
1173 if ( e->type() == TQEvent::FocusIn )
1175 TQFocusEvent * pFE = ( TQFocusEvent* ) e;
1176 if ( pFE->reason() == TQFocusEvent::ActiveWindow )
1178 if ( m_pCurrentWindow && !m_pCurrentWindow->isHidden() &&
1186 static bool focusTCIsPending =
false;
1187 if ( !focusTCIsPending && m_mdiMode == KMdi::ChildframeMode )
1189 focusTCIsPending =
true;
1191 focusTCIsPending =
false;
1195 else if ( e->type() == TQEvent::KeyRelease )
1199 TDEAction * a = actionCollection() ->action(
"view_last_window" ) ;
1202 const TDEShortcut cut( a->shortcut() );
1203 const KKeySequence& seq = cut.seq( 0 );
1204 const KKey& key = seq.key( 0 );
1205 int modFlags = key.modFlags();
1206 int state = ( ( TQKeyEvent * ) e ) ->state();
1207 KKey key2( ( TQKeyEvent * ) e );
1213 if ( state != ( ( TQKeyEvent * ) e ) ->stateAfter() &&
1214 ( ( modFlags & KKey::CTRL ) > 0 ) == ( ( state & TQt::ControlButton ) > 0 ) &&
1215 ( ( modFlags & KKey::ALT ) > 0 ) == ( ( state & TQt::AltButton ) > 0 ) &&
1216 ( ( modFlags & KKey::WIN ) > 0 ) == ( ( state & TQt::MetaButton ) > 0 ) )
1225 kdDebug(760) <<
"TDEAction( \"view_last_window\") not found." << endl;
1238 TQValueList<KMdiChildView*> children;
1239 for (
KMdiChildView * w = m_pDocumentViews->first();w;w = m_pDocumentViews->next() )
1241 children.append( w );
1243 TQValueListIterator<KMdiChildView *> childIt;
1244 for ( childIt = children.begin(); childIt != children.end(); ++childIt )
1246 ( *childIt )->close();
1256 kdDebug(760) << k_funcinfo <<
"minimizing all the views" << endl;
1257 TQPtrListIterator<KMdiChildView> it( *m_pDocumentViews );
1258 for ( ; ( *it ); ++it )
1259 ( *it )->minimize();
1267 kdDebug(760) << k_funcinfo <<
"closing the active view" << endl;
1268 if ( m_pCurrentWindow )
1269 m_pCurrentWindow->close();
1276 if ( !rootDockWidgetList && !positionList )
1280 const int frameBorderWidth = 7;
1281 const int windowTitleHeight = 10;
1283 TQObjectList* pObjList = queryList(
"KDockWidget" );
1284 if ( pObjList->isEmpty() )
1285 pObjList = queryList(
"KDockWidget_Compat::KDockWidget" );
1287 TQObjectListIt it( *pObjList );
1291 KDockWidget* dockWindow = 0L;
1292 KDockWidget* rootDockWindow = 0L;
1293 KDockWidget* undockCandidate = 0L;
1294 TQWidget* pW =
static_cast<TQWidget*
>( ( *it ) );
1297 while ( !pW->isTopLevel() )
1299 if ( ::tqt_cast<KDockWidget*>( pW ) || pW->inherits(
"KDockWidget_Compat::KDockWidget" ) )
1301 undockCandidate =
static_cast<KDockWidget*
>( pW );
1302 if ( undockCandidate->enableDocking() != KDockWidget::DockNone )
1303 rootDockWindow = undockCandidate;
1305 pW = pW->parentWidget();
1308 if ( rootDockWindow )
1312 if ( !rootDockWidgetList->isEmpty() )
1314 TQPtrListIterator<KDockWidget> it2( *rootDockWidgetList );
1315 for ( ; it2.current() && !found; ++it2 )
1317 dockWindow = it2.current();
1318 if ( dockWindow == rootDockWindow )
1323 if ( !found || rootDockWidgetList->isEmpty() )
1325 rootDockWidgetList->append( dockWindow );
1326 kdDebug(760) << k_funcinfo <<
"Appending " << rootDockWindow <<
" to our list of " <<
1327 "root dock windows" << endl;
1328 TQPoint p = rootDockWindow->mapToGlobal( rootDockWindow->pos() ) - rootDockWindow->pos();
1329 TQRect r( p.x(), p.y() + m_undockPositioningOffset.y(),
1330 rootDockWindow->width() - windowTitleHeight - frameBorderWidth * 2,
1331 rootDockWindow->height() - windowTitleHeight - frameBorderWidth * 2 );
1332 positionList->append( r );
1345 if ( m_mdiMode == KMdi::ToplevelMode )
1351 KMdi::MdiMode oldMdiMode = m_mdiMode;
1353 const int frameBorderWidth = 7;
1357 TQPtrList<KDockWidget> rootDockWidgetList;
1358 TQValueList<TQRect> positionList;
1361 switch( oldMdiMode )
1363 case KMdi::ChildframeMode:
1364 finishChildframeMode();
1366 case KMdi::TabPageMode:
1367 finishTabPageMode();
1369 case KMdi::IDEAlMode:
1378 TQPtrListIterator<KDockWidget> kdwit( rootDockWidgetList );
1379 for ( ; ( *kdwit ); ++kdwit )
1380 ( *kdwit )->undock();
1383 if ( oldMdiMode == KMdi::TabPageMode || oldMdiMode == KMdi::IDEAlMode )
1385 if ( !m_pDockbaseAreaOfDocumentViews )
1387 m_pDockbaseAreaOfDocumentViews = createDockWidget(
"mdiAreaCover", TQPixmap(), 0L,
"mdi_area_cover" );
1388 m_pDockbaseAreaOfDocumentViews->setDockWindowTransient(
this,
true );
1389 m_pDockbaseAreaOfDocumentViews->setEnableDocking( KDockWidget::DockNone );
1390 m_pDockbaseAreaOfDocumentViews->setDockSite( KDockWidget::DockCorner );
1391 m_pDockbaseAreaOfDocumentViews->setWidget( m_pMdi );
1394 setView( m_pDockbaseAreaOfDocumentViews );
1395 setMainDockWidget( m_pDockbaseAreaOfDocumentViews );
1398 if ( !parentWidget() )
1403 int topDockHeight = topDock() ? topDock()->height() : 0;
1404 int bottomDockHeight = bottomDock() ? bottomDock()->height() : 0;
1405 int menuBarHeight = hasMenuBar() ? menuBar()->height() : 0;
1406 if ( m_pDocumentViews->count() != 0 )
1407 setFixedHeight( height() - m_pDockbaseAreaOfDocumentViews->height() );
1410 kdDebug(760) << k_funcinfo <<
"height is: " << height() << endl;
1411 kdDebug(760) << k_funcinfo <<
"top dock height: " << topDockHeight << endl;
1412 kdDebug(760) << k_funcinfo <<
"bottom dock height: " << bottomDockHeight << endl;
1413 kdDebug(760) << k_funcinfo <<
"menu bar height: " << menuBarHeight << endl;
1414 kdDebug(760) << k_funcinfo <<
"dock base area height: " << m_pDockbaseAreaOfDocumentViews->height() << endl;
1415 setFixedHeight( topDockHeight + menuBarHeight );
1421 TQPtrListIterator<KMdiChildView> tdemdicvit( *m_pDocumentViews );
1422 for ( tdemdicvit.toFirst(); ( *tdemdicvit ); ++tdemdicvit )
1425 XSetTransientForHint( tqt_xdisplay(), ( *tdemdicvit )->winId(), winId() );
1427 ( *tdemdicvit )->show();
1431 TQValueList<TQRect>::Iterator qvlqrit;
1432 TQValueList<TQRect>::Iterator qvlEnd = positionList.end();
1433 for ( tdemdicvit.toFirst(), qvlqrit = positionList.begin() ; ( *tdemdicvit ) && qvlqrit != qvlEnd; ++tdemdicvit, ++qvlqrit )
1435 ( *tdemdicvit )->setGeometry( ( *qvlqrit ) );
1436 ( *tdemdicvit )->show();
1439 m_pDockbaseAreaOfDocumentViews->setDockSite( KDockWidget::DockNone );
1440 m_mdiMode = KMdi::ToplevelMode;
1442 kdDebug(760) << k_funcinfo <<
"Switch to toplevel mode completed" << endl;
1447 void KMdiMainFrm::finishToplevelMode()
1449 m_pDockbaseAreaOfDocumentViews->setDockSite( KDockWidget::DockCorner );
1457 if ( m_mdiMode == KMdi::ChildframeMode )
1463 TQPtrList<KDockWidget> rootDockWidgetList;
1464 TQValueList<TQRect> positionList;
1466 if ( m_mdiMode == KMdi::TabPageMode )
1468 kdDebug(760) << k_funcinfo <<
"finishing tab page mode" << endl;
1471 kdDebug(760) << k_funcinfo <<
"Found " << rootDockWidgetList.count() <<
" widgets to undock" << endl;
1474 TQPtrListIterator<KDockWidget> it( rootDockWidgetList );
1475 for ( ; ( *it ) ; ++it )
1478 finishTabPageMode();
1480 else if ( m_mdiMode == KMdi::ToplevelMode )
1482 finishToplevelMode();
1484 else if ( m_mdiMode == KMdi::IDEAlMode )
1486 kdDebug(760) << k_funcinfo <<
"finishing ideal mode" << endl;
1487 finishIDEAlMode(
false );
1491 kdDebug(760) << k_funcinfo <<
"Found " << rootDockWidgetList.count() <<
" widgets to undock" << endl;
1494 TQPtrListIterator<KDockWidget> it( rootDockWidgetList );
1495 for ( ; ( *it ) ; ++it )
1498 m_mdiMode = KMdi::TabPageMode;
1499 finishTabPageMode();
1500 m_mdiMode = KMdi::IDEAlMode;
1503 if ( !m_pDockbaseAreaOfDocumentViews )
1506 m_pDockbaseAreaOfDocumentViews = createDockWidget(
"mdiAreaCover", TQPixmap(), 0L,
"mdi_area_cover" );
1507 m_pDockbaseAreaOfDocumentViews->setDockWindowTransient(
this,
true );
1508 m_pDockbaseAreaOfDocumentViews->setEnableDocking( KDockWidget::DockNone );
1509 m_pDockbaseAreaOfDocumentViews->setDockSite( KDockWidget::DockCorner );
1510 m_pDockbaseAreaOfDocumentViews->setWidget( m_pMdi );
1511 kdDebug(760) << k_funcinfo <<
"childarea is now covered by a dockwidget" << endl;
1514 if ( m_pDockbaseAreaOfDocumentViews->isTopLevel() )
1517 setView( m_pDockbaseAreaOfDocumentViews );
1518 setMainDockWidget( m_pDockbaseAreaOfDocumentViews );
1519 m_pDockbaseAreaOfDocumentViews->setEnableDocking( KDockWidget::DockNone );
1520 m_pDockbaseAreaOfDocumentViews->setDockSite( KDockWidget::DockCorner );
1521 kdDebug(760) << k_funcinfo <<
"Dock base area has been set to the main view" << endl;
1523 m_pDockbaseAreaOfDocumentViews->setWidget( m_pMdi );
1524 m_pDockbaseAreaOfDocumentViews->show();
1526 if ( ( m_mdiMode == KMdi::TabPageMode ) || ( m_mdiMode == KMdi::IDEAlMode ) )
1528 kdDebug(760) << k_funcinfo <<
"trying to dock back the undock toolviews" << endl;
1529 TQPtrListIterator<KDockWidget> it( rootDockWidgetList );
1530 for ( ; ( *it ); ++it )
1531 ( *it )->dockBack();
1534 if ( m_mdiMode == KMdi::ToplevelMode && m_pTempDockSession )
1537 kdDebug(760) << k_funcinfo <<
"Restoring old dock scenario memorized from toplevel mode" << endl;
1538 TQDomElement oldDockState = m_pTempDockSession->namedItem(
"cur_dock_state" ).toElement();
1539 readDockConfig( oldDockState );
1542 KMdi::MdiMode oldMdiMode = m_mdiMode;
1543 m_mdiMode = KMdi::ChildframeMode;
1546 TQPtrListIterator<KMdiChildView> it( *m_pDocumentViews );
1547 for ( ; ( *it ); ++it )
1553 for ( it.toFirst(); ( *it ); ++it )
1559 if ( ( oldMdiMode == KMdi::ToplevelMode ) && !parentWidget() )
1561 setMinimumHeight( m_oldMainFrmMinHeight );
1562 setMaximumHeight( m_oldMainFrmMaxHeight );
1563 resize( width(), m_oldMainFrmHeight );
1564 m_oldMainFrmHeight = 0;
1565 kdDebug(760) << k_funcinfo <<
"left top level mode completely" << endl;
1571 void KMdiMainFrm::finishChildframeMode()
1574 kdDebug(760) << k_funcinfo <<
"saving the current dock scenario" << endl;
1575 delete m_pTempDockSession;
1576 m_pTempDockSession =
new TQDomDocument(
"docksession" );
1577 TQDomElement curDockState = m_pTempDockSession->createElement(
"cur_dock_state" );
1578 m_pTempDockSession->appendChild( curDockState );
1579 writeDockConfig( curDockState );
1582 kdDebug(760) << k_funcinfo <<
"detaching all document views and moving them to toplevel" << endl;
1583 TQPtrListIterator<KMdiChildView> it( *m_pDocumentViews );
1584 for ( ; ( *it ); ++it )
1592 pView->
mdiParent()->setGeometry( 0, 0, m_pMdi->width(), m_pMdi->height() );
1603 if ( m_mdiMode == KMdi::TabPageMode )
1611 case KMdi::ChildframeMode:
1612 finishChildframeMode();
1614 case KMdi::ToplevelMode:
1615 finishToplevelMode();
1617 case KMdi::IDEAlMode:
1618 finishIDEAlMode(
false );
1620 m_mdiMode = KMdi::TabPageMode;
1627 setupTabbedDocumentViewSpace();
1628 m_mdiMode = KMdi::TabPageMode;
1629 if ( m_pCurrentWindow )
1630 m_pCurrentWindow->setFocus();
1637 if ( m_pDocumentViews->count() > 0 )
1641 kdDebug(760) <<
"close button nonexistant. strange things might happen" << endl;
1643 kdDebug(760) <<
"Switch to tab page mode complete" << endl;
1647 void KMdiMainFrm::finishTabPageMode()
1650 if ( m_mdiMode == KMdi::TabPageMode )
1655 TQPtrListIterator<KMdiChildView> it( *m_pDocumentViews );
1656 for ( ; it.current(); ++it )
1661 kdDebug(760) <<
"KMdiMainFrm::finishTabPageMode: in loop" << endl;
1662 TQSize mins = pView->minimumSize();
1663 TQSize maxs = pView->maximumSize();
1664 TQSize sz = pView->size();
1665 TQWidget* pParent = pView->parentWidget();
1666 TQPoint p( pParent->mapToGlobal( pParent->pos() ) - pParent->pos() + m_undockPositioningOffset );
1668 pView->reparent( 0, 0, p );
1670 pView->resize( sz );
1680 delete m_documentTabWidget;
1681 m_documentTabWidget = 0;
1688 void KMdiMainFrm::setupTabbedDocumentViewSpace()
1691 if ( ( m_mdiMode == KMdi::ToplevelMode ) && !parentWidget() )
1693 setMinimumHeight( m_oldMainFrmMinHeight );
1694 setMaximumHeight( m_oldMainFrmMaxHeight );
1695 resize( width(), m_oldMainFrmHeight );
1696 m_oldMainFrmHeight = 0;
1699 TQApplication::sendPostedEvents();
1702 if ( m_pTempDockSession )
1704 TQDomElement oldDockState = m_pTempDockSession->namedItem(
"cur_dock_state" ).toElement();
1705 readDockConfig( oldDockState );
1710 if ( m_pDockbaseOfTabPage != m_pDockbaseAreaOfDocumentViews )
1712 delete m_pDockbaseOfTabPage;
1713 m_pDockbaseOfTabPage = m_pDockbaseAreaOfDocumentViews;
1716 delete m_documentTabWidget;
1718 connect( m_documentTabWidget, TQ_SIGNAL( currentChanged( TQWidget* ) ),
this, TQ_SLOT( slotDocCurrentChanged( TQWidget* ) ) );
1719 m_pDockbaseAreaOfDocumentViews->setWidget( m_documentTabWidget );
1720 m_documentTabWidget->show();
1721 TQPtrListIterator<KMdiChildView> it4( *m_pDocumentViews );
1722 for ( ; it4.current(); ++it4 )
1725 m_documentTabWidget->
addTab( pView, pView->icon() ? *( pView->icon() ) : TQPixmap(), pView->
tabCaption() );
1730 connect( pView, TQ_SIGNAL( iconUpdated( TQWidget*, TQPixmap ) ), m_documentTabWidget, TQ_SLOT( updateIconInView( TQWidget*, TQPixmap ) ) );
1731 connect( pView, TQ_SIGNAL( captionUpdated( TQWidget*,
const TQString& ) ), m_documentTabWidget, TQ_SLOT( updateCaptionInView( TQWidget*,
const TQString& ) ) );
1739 d->m_styleIDEAlMode = flags;
1740 if ( m_leftContainer )
1742 KMdiDockContainer * tmpL = ::tqt_cast<KMdiDockContainer*>( m_leftContainer->getWidget() );
1744 tmpL->setStyle( flags );
1747 if ( m_rightContainer )
1749 KMdiDockContainer * tmpR = ::tqt_cast<KMdiDockContainer*>( m_rightContainer->getWidget() );
1751 tmpR->setStyle( flags );
1754 if ( m_topContainer )
1756 KMdiDockContainer * tmpT = ::tqt_cast<KMdiDockContainer*>( m_topContainer->getWidget() );
1758 tmpT->setStyle( flags );
1761 if ( m_bottomContainer )
1763 KMdiDockContainer * tmpB = ::tqt_cast<KMdiDockContainer*>( m_bottomContainer->getWidget() );
1765 tmpB->setStyle( flags );
1771 if ( m_mdiMode == KMdi::IDEAlMode )
1775 d->m_toolviewStyle = flag;
1776 bool toolviewExists =
false;
1777 TQMap<TQWidget*, KMdiToolViewAccessor*>::Iterator it;
1778 for ( it = m_pToolViews->begin(); it != m_pToolViews->end(); ++it )
1780 KDockWidget *dockWidget =
dynamic_cast<KDockWidget*
>( it.data()->wrapperWidget() );
1786 dockWidget->setTabPageLabel( TQString::null );
1787 dockWidget->setPixmap( *( it.data()->wrappedWidget()->icon() ) );
1790 dockWidget->setPixmap();
1791 dockWidget->setTabPageLabel( it.data()->wrappedWidget()->caption() );
1794 dockWidget->setPixmap( *( it.data()->wrappedWidget()->icon() ) );
1795 dockWidget->setTabPageLabel( it.data()->wrappedWidget()->caption() );
1799 toolviewExists =
true;
1803 if ( toolviewExists )
1824 kdDebug(760) << k_funcinfo <<
"switching to IDEAl mode" << endl;
1826 if ( m_mdiMode == KMdi::IDEAlMode )
1834 case KMdi::ChildframeMode:
1835 finishChildframeMode();
1837 case KMdi::ToplevelMode:
1838 finishToplevelMode();
1840 case KMdi::TabPageMode:
1841 m_mdiMode = KMdi::IDEAlMode;
1842 setupToolViewsForIDEALMode();
1850 setupTabbedDocumentViewSpace();
1851 m_mdiMode = KMdi::IDEAlMode;
1852 setupToolViewsForIDEALMode();
1854 if ( m_pCurrentWindow )
1855 m_pCurrentWindow->setFocus();
1862 if ( m_pDocumentViews->count() > 0 )
1866 kdWarning(760) << k_funcinfo <<
"close button pointer does not exist!" << endl;
1868 kdDebug(760) << k_funcinfo <<
"switch to IDEAl mode complete" << endl;
1874 void KMdiMainFrm::dockToolViewsIntoContainers( TQPtrList<KDockWidget>& widgetsToReparent, KDockWidget *container )
1876 TQPtrListIterator<KDockWidget> it( widgetsToReparent );
1877 for ( ; ( *it ); ++it )
1879 ( *it )->manualDock( container, KDockWidget::DockCenter, 20 );
1880 ( *it )->loseFormerBrotherDockWidget();
1884 void KMdiMainFrm::findToolViewsDockedToMain( TQPtrList<KDockWidget>* list, KDockWidget::DockPosition dprtmw )
1886 KDockWidget* mainDock = getMainDockWidget();
1887 if ( mainDock->parentDockTabGroup() )
1889 mainDock =
dynamic_cast<KDockWidget*
>( mainDock->parentDockTabGroup()->parent() );
1895 kdDebug(760) << k_funcinfo <<
"mainDock invalid. No main dock widget found." << endl;
1899 KDockWidget* widget = mainDock->findNearestDockWidget( dprtmw );
1900 if ( widget && widget->parentDockTabGroup() )
1902 widget =
static_cast<KDockWidget*
>( widget->parentDockTabGroup() ->parent() );
1906 KDockTabGroup* tg =
dynamic_cast<KDockTabGroup*
>( widget->getWidget() );
1909 kdDebug(760) << k_funcinfo <<
"KDockTabGroup found" << endl;
1910 for (
int i = 0;i < tg->count();i++ )
1911 list->append(
static_cast<KDockWidget*
>( tg->page( i ) ) );
1914 list->append( widget );
1917 kdDebug(760) << k_funcinfo <<
"no widget found" << endl;
1920 kdDebug(760) <<
"No main dock widget found" << endl;
1924 void KMdiMainFrm::setupToolViewsForIDEALMode()
1926 m_leftContainer = createDockWidget(
"KMdiDock::leftDock", SmallIcon(
"misc" ), 0L,
"Left Dock" );
1927 m_rightContainer = createDockWidget(
"KMdiDock::rightDock", SmallIcon(
"misc" ), 0L,
"Right Dock" );
1928 m_topContainer = createDockWidget(
"KMdiDock::topDock", SmallIcon(
"misc" ), 0L,
"Top Dock" );
1929 m_bottomContainer = createDockWidget(
"KMdiDock::bottomDock", SmallIcon(
"misc" ), 0L,
"Bottom Dock" );
1931 KDockWidget *mainDock = getMainDockWidget();
1932 KDockWidget *w = mainDock;
1933 if ( mainDock->parentDockTabGroup() )
1934 w =
static_cast<KDockWidget*
>( mainDock->parentDockTabGroup()->parent() );
1936 TQPtrList<KDockWidget> leftReparentWidgets;
1937 TQPtrList<KDockWidget> rightReparentWidgets;
1938 TQPtrList<KDockWidget> bottomReparentWidgets;
1939 TQPtrList<KDockWidget> topReparentWidgets;
1941 if ( mainDock->parentDockTabGroup() )
1942 mainDock =
static_cast<KDockWidget*
>( mainDock->parentDockTabGroup() ->parent() );
1944 findToolViewsDockedToMain( &leftReparentWidgets, KDockWidget::DockLeft );
1945 findToolViewsDockedToMain( &rightReparentWidgets, KDockWidget::DockRight );
1946 findToolViewsDockedToMain( &bottomReparentWidgets, KDockWidget::DockBottom );
1947 findToolViewsDockedToMain( &topReparentWidgets, KDockWidget::DockTop );
1949 mainDock->setEnableDocking( KDockWidget::DockNone );
1950 mainDock->setDockSite( KDockWidget::DockCorner );
1953 KMdiDockContainer *tmpDC;
1954 m_leftContainer->setWidget( tmpDC =
new KMdiDockContainer( m_leftContainer,
this, KDockWidget::DockLeft, d->m_styleIDEAlMode ) );
1955 m_leftContainer->setEnableDocking( KDockWidget::DockLeft );
1956 m_leftContainer->manualDock( mainDock, KDockWidget::DockLeft, 20 );
1958 if ( m_mdiGUIClient )
1959 connect (
this, TQ_SIGNAL( toggleLeft() ), tmpDC, TQ_SLOT( toggle() ) );
1961 connect( tmpDC, TQ_SIGNAL( activated( KMdiDockContainer* ) ),
this, TQ_SLOT( setActiveToolDock( KMdiDockContainer* ) ) );
1962 connect( tmpDC, TQ_SIGNAL( deactivated( KMdiDockContainer* ) ),
this, TQ_SLOT( removeFromActiveDockList( KMdiDockContainer* ) ) );
1964 m_rightContainer->setWidget( tmpDC =
new KMdiDockContainer( m_rightContainer,
this, KDockWidget::DockRight, d->m_styleIDEAlMode ) );
1965 m_rightContainer->setEnableDocking( KDockWidget::DockRight );
1966 m_rightContainer->manualDock( mainDock, KDockWidget::DockRight, 80 );
1968 if ( m_mdiGUIClient )
1969 connect (
this, TQ_SIGNAL( toggleRight() ), tmpDC, TQ_SLOT( toggle() ) );
1971 connect( tmpDC, TQ_SIGNAL( activated( KMdiDockContainer* ) ),
this, TQ_SLOT( setActiveToolDock( KMdiDockContainer* ) ) );
1972 connect( tmpDC, TQ_SIGNAL( deactivated( KMdiDockContainer* ) ),
this, TQ_SLOT( removeFromActiveDockList( KMdiDockContainer* ) ) );
1974 m_topContainer->setWidget( tmpDC =
new KMdiDockContainer( m_topContainer,
this, KDockWidget::DockTop, d->m_styleIDEAlMode ) );
1975 m_topContainer->setEnableDocking( KDockWidget::DockTop );
1976 m_topContainer->manualDock( mainDock, KDockWidget::DockTop, 20 );
1978 if ( m_mdiGUIClient )
1979 connect (
this, TQ_SIGNAL( toggleTop() ), tmpDC, TQ_SLOT( toggle() ) );
1981 connect( tmpDC, TQ_SIGNAL( activated( KMdiDockContainer* ) ),
this, TQ_SLOT( setActiveToolDock( KMdiDockContainer* ) ) );
1982 connect( tmpDC, TQ_SIGNAL( deactivated( KMdiDockContainer* ) ),
this, TQ_SLOT( removeFromActiveDockList( KMdiDockContainer* ) ) );
1984 m_bottomContainer->setWidget( tmpDC =
new KMdiDockContainer( m_bottomContainer,
this, KDockWidget::DockBottom, d->m_styleIDEAlMode ) );
1985 m_bottomContainer->setEnableDocking( KDockWidget::DockBottom );
1986 m_bottomContainer->manualDock( mainDock, KDockWidget::DockBottom, 80 );
1988 if ( m_mdiGUIClient )
1989 connect (
this, TQ_SIGNAL( toggleBottom() ), tmpDC, TQ_SLOT( toggle() ) );
1991 connect( tmpDC, TQ_SIGNAL( activated( KMdiDockContainer* ) ),
this, TQ_SLOT( setActiveToolDock( KMdiDockContainer* ) ) );
1992 connect( tmpDC, TQ_SIGNAL( deactivated( KMdiDockContainer* ) ),
this, TQ_SLOT( removeFromActiveDockList( KMdiDockContainer* ) ) );
1994 m_leftContainer->setDockSite( KDockWidget::DockCenter );
1995 m_rightContainer->setDockSite( KDockWidget::DockCenter );
1996 m_topContainer->setDockSite( KDockWidget::DockCenter );
1997 m_bottomContainer->setDockSite( KDockWidget::DockCenter );
1999 dockToolViewsIntoContainers( leftReparentWidgets, m_leftContainer );
2000 dockToolViewsIntoContainers( rightReparentWidgets, m_rightContainer );
2001 dockToolViewsIntoContainers( bottomReparentWidgets, m_bottomContainer );
2002 dockToolViewsIntoContainers( topReparentWidgets, m_topContainer );
2005 dockManager->setSpecialLeftDockContainer( m_leftContainer );
2006 dockManager->setSpecialRightDockContainer( m_rightContainer );
2007 dockManager->setSpecialTopDockContainer( m_topContainer );
2008 dockManager->setSpecialBottomDockContainer( m_bottomContainer );
2011 ( ( KMdiDockContainer* ) ( m_leftContainer->getWidget() ) ) ->hideIfNeeded();
2012 ( ( KMdiDockContainer* ) ( m_rightContainer->getWidget() ) ) ->hideIfNeeded();
2013 ( ( KMdiDockContainer* ) ( m_topContainer->getWidget() ) ) ->hideIfNeeded();
2014 ( ( KMdiDockContainer* ) ( m_bottomContainer->getWidget() ) ) ->hideIfNeeded();
2020 void KMdiMainFrm::finishIDEAlMode(
bool full )
2023 if ( m_mdiMode == KMdi::IDEAlMode )
2030 TQStringList leftNames;
2031 leftNames = prepareIdealToTabs( m_leftContainer );
2032 int leftWidth = m_leftContainer->width();
2034 TQStringList rightNames;
2035 rightNames = prepareIdealToTabs( m_rightContainer );
2036 int rightWidth = m_rightContainer->width();
2038 TQStringList topNames;
2039 topNames = prepareIdealToTabs( m_topContainer );
2040 int topHeight = m_topContainer->height();
2042 TQStringList bottomNames;
2043 bottomNames = prepareIdealToTabs( m_bottomContainer );
2044 int bottomHeight = m_bottomContainer->height();
2047 kdDebug(760) <<
"leftNames" << leftNames << endl;
2048 kdDebug(760) <<
"rightNames" << rightNames << endl;
2049 kdDebug(760) <<
"topNames" << topNames << endl;
2050 kdDebug(760) <<
"bottomNames" << bottomNames << endl;
2052 delete m_leftContainer;
2053 m_leftContainer = 0;
2054 delete m_rightContainer;
2055 m_rightContainer = 0;
2056 delete m_bottomContainer;
2057 m_bottomContainer = 0;
2058 delete m_topContainer;
2062 idealToolViewsToStandardTabs( bottomNames, KDockWidget::DockBottom, bottomHeight );
2063 idealToolViewsToStandardTabs( leftNames, KDockWidget::DockLeft, leftWidth );
2064 idealToolViewsToStandardTabs( rightNames, KDockWidget::DockRight, rightWidth );
2065 idealToolViewsToStandardTabs( topNames, KDockWidget::DockTop, topHeight );
2067 TQApplication::sendPostedEvents();
2072 TQPtrListIterator<KMdiChildView> it( *m_pDocumentViews );
2073 for ( ; it.current(); ++it )
2078 TQSize mins = pView->minimumSize();
2079 TQSize maxs = pView->maximumSize();
2080 TQSize sz = pView->size();
2081 TQWidget* pParent = pView->parentWidget();
2082 TQPoint p( pParent->mapToGlobal( pParent->pos() ) - pParent->pos() + m_undockPositioningOffset );
2083 pView->reparent( 0, 0, p );
2084 pView->reparent( 0, 0, p );
2085 pView->resize( sz );
2088 KDockWidget* pDockW = 0L;
2092 if ( pParent->inherits(
"KDockWidget" ) || pParent->inherits(
"KDockWidget_Compat::KDockWidget" ) )
2094 pDockW = ( KDockWidget* ) pParent;
2096 if ( pParent != m_pDockbaseAreaOfDocumentViews )
2104 pParent = pParent->parentWidget();
2107 while ( pParent && !pDockW );
2108 if ( centralWidget() == pParent )
2110 setCentralWidget( 0L );
2119 TQStringList KMdiMainFrm::prepareIdealToTabs( KDockWidget* container )
2121 KDockContainer * pDW =
dynamic_cast<KDockContainer*
>( container->getWidget() );
2122 TQStringList widgetNames = ( ( KMdiDockContainer* ) pDW ) ->containedWidgets();
2123 for ( TQStringList::iterator it = widgetNames.begin();it != widgetNames.end();++it )
2125 KDockWidget* dw = ( KDockWidget* ) manager() ->getDockWidgetFromName( *it );
2127 dw->setLatestKDockContainer( 0 );
2128 dw->loseFormerBrotherDockWidget();
2133 void KMdiMainFrm::idealToolViewsToStandardTabs( TQStringList widgetNames, KDockWidget::DockPosition pos,
int size )
2137 KDockWidget * mainDock = getMainDockWidget();
2138 if ( mainDock->parentDockTabGroup() )
2140 mainDock =
static_cast<KDockWidget*
>( mainDock->parentDockTabGroup() ->parent() );
2143 if ( widgetNames.count() > 0 )
2145 TQStringList::iterator it = widgetNames.begin();
2146 KDockWidget *dwpd = manager() ->getDockWidgetFromName( *it );
2149 kdDebug(760) <<
"Fatal error in finishIDEAlMode" << endl;
2152 dwpd->manualDock( mainDock, pos, 20 );
2154 for ( ;it != widgetNames.end();++it )
2156 KDockWidget *tmpdw = manager() ->getDockWidgetFromName( *it );
2159 kdDebug(760) <<
"Fatal error in finishIDEAlMode" << endl;
2162 tmpdw->manualDock( dwpd, KDockWidget::DockCenter, 20 );
2166 TQWidget *wid = dwpd->parentDockTabGroup();
2169 wid->setGeometry( 0, 0, 20, 20 );
2190 if ( m_bSDIApplication )
2193 m_pMainMenuBar = pMenuBar;
2194 if ( m_pMainMenuBar == 0L )
2198 m_pUndock =
new TQToolButton( pMenuBar );
2200 m_pRestore =
new TQToolButton( pMenuBar );
2202 m_pMinimize =
new TQToolButton( pMenuBar );
2204 m_pClose =
new TQToolButton( pMenuBar );
2205 m_pUndock->setAutoRaise(
false );
2206 m_pMinimize->setAutoRaise(
false );
2207 m_pRestore->setAutoRaise(
false );
2208 m_pClose->setAutoRaise(
false );
2212 delete m_pUndockButtonPixmap;
2213 delete m_pMinButtonPixmap;
2214 delete m_pRestoreButtonPixmap;
2215 delete m_pCloseButtonPixmap;
2219 m_pUndockButtonPixmap =
new TQPixmap( win_undockbutton );
2220 m_pMinButtonPixmap =
new TQPixmap( win_minbutton );
2221 m_pRestoreButtonPixmap =
new TQPixmap( win_restorebutton );
2222 m_pCloseButtonPixmap =
new TQPixmap( win_closebutton );
2226 m_pUndockButtonPixmap =
new TQPixmap( kde_undockbutton );
2227 m_pMinButtonPixmap =
new TQPixmap( kde_minbutton );
2228 m_pRestoreButtonPixmap =
new TQPixmap( kde_restorebutton );
2229 m_pCloseButtonPixmap =
new TQPixmap( kde_closebutton );
2230 m_pUndock->setAutoRaise(
true );
2231 m_pMinimize->setAutoRaise(
true );
2232 m_pRestore->setAutoRaise(
true );
2233 m_pClose->setAutoRaise(
true );
2237 m_pUndockButtonPixmap =
new TQPixmap( kde2_undockbutton );
2238 m_pMinButtonPixmap =
new TQPixmap( kde2_minbutton );
2239 m_pRestoreButtonPixmap =
new TQPixmap( kde2_restorebutton );
2240 m_pCloseButtonPixmap =
new TQPixmap( kde2_closebutton );
2244 m_pUndockButtonPixmap =
new TQPixmap( kde2laptop_undockbutton );
2245 m_pMinButtonPixmap =
new TQPixmap( kde2laptop_minbutton );
2246 m_pRestoreButtonPixmap =
new TQPixmap( kde2laptop_restorebutton );
2247 m_pCloseButtonPixmap =
new TQPixmap( kde2laptop_closebutton );
2251 m_pMinimize->hide();
2255 m_pUndock->setPixmap( *m_pUndockButtonPixmap );
2256 m_pMinimize->setPixmap( *m_pMinButtonPixmap );
2257 m_pRestore->setPixmap( *m_pRestoreButtonPixmap );
2258 m_pClose->setPixmap( *m_pCloseButtonPixmap );
2263 if ( m_pMainMenuBar == 0L )
2265 if ( m_pMainMenuBar->parentWidget() == 0L )
2268 int menuW = m_pMainMenuBar->parentWidget() ->width();
2279 y = m_pMainMenuBar->height() / 2 - h / 2;
2284 m_pUndock->setGeometry( ( menuW - ( w * 3 ) - 5 ), y, w, h );
2285 m_pMinimize->setGeometry( ( menuW - ( w * 2 ) - 5 ), y, w, h );
2286 m_pRestore->setGeometry( ( menuW - w - 5 ), y, w, h );
2290 m_pUndock->setGeometry( ( menuW - ( h * 4 ) - 5 ), y, h, h );
2291 m_pMinimize->setGeometry( ( menuW - ( h * 3 ) - 5 ), y, h, h );
2292 m_pRestore->setGeometry( ( menuW - ( h * 2 ) - 5 ), y, h, h );
2293 m_pClose->setGeometry( ( menuW - h - 5 ), y, h, h );
2302 for ( it->first(); !it->isDone(); it->next() )
2304 if ( it->currentItem() == aWin )
2307 if ( !it->currentItem() )
2311 if ( it->currentItem() )
2326 for ( it->first(); !it->isDone(); it->next() )
2328 if ( it->currentItem() == aWin )
2331 if ( !it->currentItem() )
2335 if ( it->currentItem() )
2350 TQMap<TQDateTime, KMdiChildView*> m;
2351 for ( it->first(); !it->isDone(); it->next() )
2353 m.insert( it->currentItem() ->getTimeStamp(), it->currentItem() );
2360 TQMap<TQDateTime, KMdiChildView*>::iterator pos( m.find( current ) );
2361 TQMap<TQDateTime, KMdiChildView*>::iterator newPos = pos;
2362 if ( pos != m.end() )
2366 if ( newPos != m.end() )
2383 TQMap<TQDateTime, KMdiChildView*> m;
2384 for ( it->first(); !it->isDone(); it->next() )
2386 m.insert( it->currentItem() ->getTimeStamp(), it->currentItem() );
2393 TQMap<TQDateTime, KMdiChildView*>::iterator pos( m.find( current ) );
2394 if ( pos != m.begin() )
2411 for (
int i = 0; pView && ( i < index ); i++ )
2413 pView = m_pDocumentViews->next();
2424 if ( enableMaxChildFrameMode )
2426 kdDebug(760) << k_funcinfo <<
"Turning on maximized child frame mode" << endl;
2427 m_bMaximizedChildFrmMode =
true;
2432 if ( !pCurrentChild || !m_pMainMenuBar )
2435 TQObject::connect( m_pUndock, TQ_SIGNAL( clicked() ), pCurrentChild, TQ_SLOT( undockPressed() ) );
2436 TQObject::connect( m_pMinimize, TQ_SIGNAL( clicked() ), pCurrentChild, TQ_SLOT( minimizePressed() ) );
2437 TQObject::connect( m_pRestore, TQ_SIGNAL( clicked() ), pCurrentChild, TQ_SLOT( maximizePressed() ) );
2438 m_pMinimize->show();
2444 m_pMainMenuBar->insertItem( TQPixmap( kde2laptop_closebutton_menu ), m_pMdi->
topChild(), TQ_SLOT( closePressed() ), 0, -1, 0 );
2448 m_pMainMenuBar->insertItem( *pCurrentChild->
icon(), pCurrentChild->
systemMenu(), -1, 0 );
2451 TQObject::connect( m_pClose, TQ_SIGNAL( clicked() ), pCurrentChild, TQ_SLOT( closePressed() ) );
2455 kdDebug(760) << k_funcinfo <<
"no close button. things won't behave correctly" << endl;
2460 if ( !m_bMaximizedChildFrmMode )
2463 kdDebug(760) << k_funcinfo <<
"Turning off maximized child frame mode" << endl;
2464 m_bMaximizedChildFrmMode =
false;
2467 if ( pFrmChild && pFrmChild->m_pClient && pFrmChild->
state() == KMdiChildFrm::Maximized )
2469 pFrmChild->m_pClient->
restore();
2479 if ( !m_pMainMenuBar )
2482 m_pMainMenuBar->removeItem( m_pMainMenuBar->idAt( 0 ) );
2486 Q_ASSERT( m_pClose );
2487 TQObject::disconnect( m_pUndock, TQ_SIGNAL( clicked() ), oldChild, TQ_SLOT( undockPressed() ) );
2488 TQObject::disconnect( m_pMinimize, TQ_SIGNAL( clicked() ), oldChild, TQ_SLOT( minimizePressed() ) );
2489 TQObject::disconnect( m_pRestore, TQ_SIGNAL( clicked() ), oldChild, TQ_SLOT( maximizePressed() ) );
2490 TQObject::disconnect( m_pClose, TQ_SIGNAL( clicked() ), oldChild, TQ_SLOT( closePressed() ) );
2493 m_pMinimize->hide();
2503 if ( !m_pMainMenuBar )
2509 m_pMainMenuBar->insertItem( TQPixmap( kde2laptop_closebutton_menu ), newChild, TQ_SLOT( closePressed() ), 0, -1, 0 );
2511 m_pMainMenuBar->insertItem( *newChild->
icon(), newChild->
systemMenu(), -1, 0 );
2516 m_pMainMenuBar->removeItem( m_pMainMenuBar->idAt( 1 ) );
2517 Q_ASSERT( m_pClose );
2518 TQObject::disconnect( m_pUndock, TQ_SIGNAL( clicked() ), oldChild, TQ_SLOT( undockPressed() ) );
2519 TQObject::disconnect( m_pMinimize, TQ_SIGNAL( clicked() ), oldChild, TQ_SLOT( minimizePressed() ) );
2520 TQObject::disconnect( m_pRestore, TQ_SIGNAL( clicked() ), oldChild, TQ_SLOT( maximizePressed() ) );
2521 TQObject::disconnect( m_pClose, TQ_SIGNAL( clicked() ), oldChild, TQ_SLOT( closePressed() ) );
2525 Q_ASSERT( m_pClose );
2526 TQObject::connect( m_pUndock, TQ_SIGNAL( clicked() ), newChild, TQ_SLOT( undockPressed() ) );
2527 TQObject::connect( m_pMinimize, TQ_SIGNAL( clicked() ), newChild, TQ_SLOT( minimizePressed() ) );
2528 TQObject::connect( m_pRestore, TQ_SIGNAL( clicked() ), newChild, TQ_SLOT( maximizePressed() ) );
2529 TQObject::connect( m_pClose, TQ_SIGNAL( clicked() ), newChild, TQ_SLOT( closePressed() ) );
2559 bool tabPageMode =
false;
2560 if ( m_mdiMode == KMdi::TabPageMode )
2563 bool IDEAlMode =
false;
2564 if ( m_mdiMode == KMdi::IDEAlMode )
2567 bool noViewOpened =
false;
2568 if ( m_pDocumentViews->isEmpty() )
2569 noViewOpened =
true;
2572 if ( !m_bClearingOfWindowMenuBlocked )
2573 m_pWindowMenu->clear();
2575 d->closeWindowAction->plug(m_pWindowMenu);
2577 int closeAllId = m_pWindowMenu->insertItem( i18n(
"Close &All" ),
this, TQ_SLOT(
closeAllViews() ) );
2580 d->closeWindowAction->setEnabled(
false);
2581 m_pWindowMenu->setItemEnabled( closeAllId,
false );
2584 if ( !tabPageMode && !IDEAlMode )
2586 int iconifyId = m_pWindowMenu->insertItem( i18n(
"&Minimize All" ),
this, TQ_SLOT(
iconifyAllViews() ) );
2588 m_pWindowMenu->setItemEnabled( iconifyId,
false );
2591 m_pWindowMenu->insertSeparator();
2592 m_pWindowMenu->insertItem( i18n(
"&MDI Mode" ), m_pMdiModeMenu );
2593 m_pMdiModeMenu->clear();
2594 m_pMdiModeMenu->insertItem( i18n(
"&Toplevel Mode" ),
this, TQ_SLOT(
switchToToplevelMode() ) );
2596 m_pMdiModeMenu->insertItem( i18n(
"Ta&b Page Mode" ),
this, TQ_SLOT(
switchToTabPageMode() ) );
2597 m_pMdiModeMenu->insertItem( i18n(
"I&DEAl Mode" ),
this, TQ_SLOT(
switchToIDEAlMode() ) );
2598 switch ( m_mdiMode )
2600 case KMdi::ToplevelMode:
2601 m_pMdiModeMenu->setItemChecked( m_pMdiModeMenu->idAt( 0 ),
true );
2603 case KMdi::ChildframeMode:
2604 m_pMdiModeMenu->setItemChecked( m_pMdiModeMenu->idAt( 1 ),
true );
2606 case KMdi::TabPageMode:
2607 m_pMdiModeMenu->setItemChecked( m_pMdiModeMenu->idAt( 2 ),
true );
2609 case KMdi::IDEAlMode:
2610 m_pMdiModeMenu->setItemChecked( m_pMdiModeMenu->idAt( 3 ),
true );
2616 m_pWindowMenu->insertSeparator();
2617 if ( !tabPageMode && !IDEAlMode )
2619 int placMenuId = m_pWindowMenu->insertItem( i18n(
"&Tile" ), m_pPlacingMenu );
2620 m_pPlacingMenu->clear();
2621 m_pPlacingMenu->insertItem( i18n(
"Ca&scade Windows" ), m_pMdi, TQ_SLOT(
cascadeWindows() ) );
2622 m_pPlacingMenu->insertItem( i18n(
"Cascade &Maximized" ), m_pMdi, TQ_SLOT(
cascadeMaximized() ) );
2623 m_pPlacingMenu->insertItem( i18n(
"Expand &Vertically" ), m_pMdi, TQ_SLOT(
expandVertical() ) );
2624 m_pPlacingMenu->insertItem( i18n(
"Expand &Horizontally" ), m_pMdi, TQ_SLOT(
expandHorizontal() ) );
2625 m_pPlacingMenu->insertItem( i18n(
"Tile &Non-Overlapped" ), m_pMdi, TQ_SLOT(
tileAnodine() ) );
2626 m_pPlacingMenu->insertItem( i18n(
"Tile Overla&pped" ), m_pMdi, TQ_SLOT(
tilePragma() ) );
2627 m_pPlacingMenu->insertItem( i18n(
"Tile V&ertically" ), m_pMdi, TQ_SLOT(
tileVertically() ) );
2628 if ( m_mdiMode == KMdi::ToplevelMode )
2630 m_pWindowMenu->setItemEnabled( placMenuId,
false );
2632 m_pWindowMenu->insertSeparator();
2633 int dockUndockId = m_pWindowMenu->insertItem( i18n(
"&Dock/Undock" ), m_pDockMenu );
2634 m_pDockMenu->clear();
2635 m_pWindowMenu->insertSeparator();
2638 m_pWindowMenu->setItemEnabled( placMenuId,
false );
2639 m_pWindowMenu->setItemEnabled( dockUndockId,
false );
2642 int entryCount = m_pWindowMenu->count();
2647 TQPtrListIterator<KMdiChildView> it( *m_pDocumentViews );
2648 TQValueList<TQDateTime> timeStamps;
2649 for ( ; it.current(); ++it )
2651 pView = it.current();
2675 unsigned int windowItemCount = m_pWindowMenu->count() - entryCount;
2676 bool inserted =
false;
2678 TQValueList<TQDateTime>::iterator timeStampIterator = timeStamps.begin();
2679 for ( indx = 0; indx <= windowItemCount; indx++, ++timeStampIterator )
2681 bool putHere =
false;
2682 if ( ( *timeStampIterator ) < timeStamp )
2685 timeStamps.insert( timeStampIterator, timeStamp );
2689 m_pWindowMenu->insertItem( item, pView, TQ_SLOT( slot_clickedInWindowMenu() ), 0, -1, indx + entryCount );
2690 if ( pView == m_pCurrentWindow )
2692 m_pWindowMenu->setItemChecked( m_pWindowMenu->idAt( indx + entryCount ),
true );
2697 m_pDockMenu->insertItem( item, pView, TQ_SLOT( slot_clickedInDockMenu() ), 0, -1, indx );
2700 m_pDockMenu->setItemChecked( m_pDockMenu->idAt( indx ),
true );
2705 indx = windowItemCount + 1;
2710 m_pWindowMenu->insertItem( item, pView, TQ_SLOT( slot_clickedInWindowMenu() ), 0, -1, windowItemCount + entryCount );
2711 if ( pView == m_pCurrentWindow )
2713 m_pWindowMenu->setItemChecked( m_pWindowMenu->idAt( windowItemCount + entryCount ),
true );
2718 m_pDockMenu->insertItem( item, pView, TQ_SLOT( slot_clickedInDockMenu() ), 0, -1, windowItemCount );
2721 m_pDockMenu->setItemChecked( m_pDockMenu->idAt( windowItemCount ),
true );
2741 if ( m_mdiMode != KMdi::TabPageMode )
2746 if ( ( pView == pTopChild->m_pClient ) && pView->
isAttached() )
2783 m_pWindowMenu->popup( p );
2792 for ( m_pDocumentViews->first(); ( pView = m_pDocumentViews->current() ) != 0L; m_pDocumentViews->next() )
2795 TQApplication::sendEvent( pView, &dragEndEvent );
2803 switch ( frameDecor )
2806 m_frameDecoration = KMdi::Win95Look;
2809 m_frameDecoration = KMdi::KDE1Look;
2812 m_frameDecoration = KMdi::KDELook;
2815 m_frameDecoration = KMdi::KDELaptopLook;
2818 tqDebug(
"unknown MDI decoration" );
2822 TQPtrListIterator<KMdiChildView> it( *m_pDocumentViews );
2823 for ( ; it.current(); ++it )
2835 m_bSDIApplication =
true;
2837 m_pTaskBar->close();
2850 void KMdiMainFrm::setManagedDockPositionModeEnabled(
bool enabled )
2852 m_managedDockPositionMode = enabled;
2855 void KMdiMainFrm::setActiveToolDock( KMdiDockContainer* td )
2857 if ( td == d->activeDockPriority[ 0 ] )
2859 if ( d->activeDockPriority[ 0 ] == 0 )
2861 d->activeDockPriority[ 0 ] = td;
2867 for (
int dst = 3, src = 2;src >= 0;dst--, src-- )
2869 if ( d->activeDockPriority[ src ] == td )
2873 d->activeDockPriority[ dst ] = d->activeDockPriority[ src ];
2875 d->activeDockPriority[ 0 ] = td;
2878 void KMdiMainFrm::removeFromActiveDockList( KMdiDockContainer* td )
2880 for (
int i = 0;i < 4;i++ )
2882 if ( d->activeDockPriority[ i ] == td )
2885 d->activeDockPriority[ i ] = d->activeDockPriority[ i + 1 ];
2886 d->activeDockPriority[ 3 ] = 0;
2899 void KMdiMainFrm::prevToolViewInDock()
2901 KMdiDockContainer * td = d->activeDockPriority[ 0 ];
2907 void KMdiMainFrm::nextToolViewInDock()
2909 KMdiDockContainer * td = d->activeDockPriority[ 0 ];
2917 if ( m_documentTabWidget )
2920 return KMdi::NeverShowTabs;
2925 if ( m_documentTabWidget )
2931 return m_documentTabWidget;
2934 #include "tdemdimainfrm.moc"
A class derived from KXMLGUIClient that handles the various KMDI modes.
void destroyChild(KMdiChildFrm *child, bool focusTopChild=true)
Destroys a managed KMdiChildFrm Also deletes the client attached to this child.
KMdiChildFrm * topChild() const
Returns the topmost child (the active one) or 0 if there are no children.
void manageChild(KMdiChildFrm *lpC, bool bShow=true, bool bCascade=true)
Appends a new KMdiChildFrm to this manager.
void focusTopChild()
Gives focus to the topmost child if it doesn't get focus automatically or you want to wait to give it...
void destroyChildButNotItsView(KMdiChildFrm *lpC, bool bFocusTopChild=true)
Destroys a managed KMdiChildFrm Clients attached to the KMdiChildFrm are not deleted.
int getVisibleChildCount() const
Returns the number of visible children.
void setTopChild(KMdiChildFrm *child, bool setFocus=false)
Brings the child to the top of the stack The child is focused if setFocus is true.
TQPoint getCascadePoint(int indexOfWindow=-1)
Calculates the cascade point for the given index.
a TQCustomEvent for begin of dragging This special event will be useful, to inform view about child f...
a TQCustomEvent for end of dragging This special event will be useful, to inform view about child fra...
MdiWindowState state() const
Returns the current state of the window.
void setClient(KMdiChildView *w, bool bAutomaticResize=false)
Reparents the widget w to this KMdiChildFrm (if this is not already done) Installs an event filter to...
void raiseAndActivate()
Internally called from the signal focusInEventOccurs.
void setRestoreGeometry(const TQRect &newRestGeo)
Sets the geometry that will be restored by calling restore().
TQPixmap * icon() const
Returns the child frame icon.
TQPopupMenu * systemMenu() const
Returns the system menu.
const TQString & caption()
Gets the caption of this mdi child.
void unsetClient(TQPoint positionOffset=TQPoint(0, 0))
Reparents the client widget to 0 (desktop), moves with an offset from the original position Removes t...
void redecorateButtons()
sets new raise behavior and pixmaps of the buttons depending on the current decoration style
int captionHeight() const
Returns the caption bar height.
Base class for all your special view windows.
bool isMinimized() const
Tells if the window is minimized when attached to the Mdi manager, or if it is VISIBLE when 'floating...
virtual void youAreAttached(KMdiChildFrm *lpC)
Internally called, if KMdiMainFrm::attach is called.
const TQDateTime & getTimeStamp() const
Recall a previously remembered time, i.e.
virtual void youAreDetached()
Internally called, if KMdiMainFrm::detach is called.
KMdiChildFrm * mdiParent() const
Returns the KMdiChildFrm parent widget (or 0 if the window is not attached)
virtual void maximize(bool bAnimate)
Maximizes this window when it is attached to the Mdi manager.
bool isMaximized() const
Tells if the window is minimized when attached to the Mdi manager, otherwise returns false.
virtual void restore()
Restores this window to its normal size.
virtual void minimize(bool bAnimate)
Minimizes this window when it is attached to the Mdi manager.
void activate()
This method does the same as focusInEvent().
virtual void setCaption(const TQString &szCaption)
Sets the window caption string...
virtual void raise()
Calls TQWidget::raise() or it's parent widget raise() if attached.
const TQString & caption() const
Returns the caption of the child window (different from the caption on the button in the taskbar)
const TQString & tabCaption() const
Returns the caption of the button on the taskbar.
void setRestoreGeometry(const TQRect &newRestGeo)
Sets the geometry that will be restored by calling restore().
bool isAttached() const
Returns true if the MDI view is a child window within the MDI mainframe widget or false if the MDI vi...
void setWindowMenuID(int id)
Internally used for setting an ID for the 'Window' menu entry.
virtual void show()
Calls TQWidget::show but also for it's parent widget if attached.
virtual void setTabCaption(const TQString &caption)
Sets the caption of the button referring to this window.
bool isToolView() const
Returns if this is added as MDI tool-view.
TQRect restoreGeometry()
Returns the geometry that will be restored by calling restore().
virtual void setMinimumSize(int minw, int minh)
Sets the minimum size of the widget to w by h pixels.
void updateTimeStamp()
Remember the current time.
virtual void hide()
Calls TQWidget::hide() or it's parent widget hide() if attached.
virtual void setMaximumSize(int maxw, int maxh)
Sets the maximum size of the widget to w by h pixels.
void setStandardMDIMenuEnabled(bool showModeMenu=true)
Control whether or not the standard MDI menu is displayed when a context menu is displayed.
void fakeSDIApplication()
An SDI application user interface is faked:
virtual void tilePragma()
Tile Pragma.
void setTabWidgetVisibility(KMdi::TabWidgetVisibility)
Set tabwidget visibility.
virtual void hideViewTaskBar()
Hides the view taskbar.
void popupWindowMenu(TQPoint p)
Popups the "Window" menu.
void setToolviewStyle(int flags)
Sets the appearance of the toolview tabs.
bool isFakingSDIApplication() const
void windowMenuItemActivated(int id)
Usually called when the user clicks an MDI view item in the "Window" menu.
void lastChildFrmClosed()
Signals the last attached KMdiChildView has been closed.
virtual void showViewTaskBar()
Shows the view taskbar.
virtual void attachWindow(KMdiChildView *pWnd, bool bShow=true, bool bAutomaticResize=false)
Makes a main frame controlled undocked KMdiChildView docked.
bool windowExists(KMdiChildView *pWnd, ExistsAs as)
Returns whether this MDI child view is under MDI control (using addWindow() ) or not.
virtual void iconifyAllViews()
Iconfiy all views.
virtual void switchToIDEAlMode()
Docks all view windows.
void leftTopLevelMode()
Signals that the Toplevel mode has been left.
virtual TQPopupMenu * taskBarPopup(KMdiChildView *pWnd, bool bIncludeWindowPopup=false)
Returns a popup menu filled according to the MDI view state.
void mdiModeHasBeenChangedTo(KMdi::MdiMode)
Signals the MDI mode has been changed.
virtual void setEnableMaximizedChildFrmMode(bool bEnable)
If in Childframe mode, we can switch between maximized or restored shown MDI views.
void childViewIsDetachedNow(TQWidget *)
Signals that a child view has been detached (undocked to desktop)
bool isViewTaskBarOn()
Shows the view taskbar.
KMdiChildView * activeWindow()
Returns the focused attached MDI view.
virtual void taskbarButtonRightClicked(KMdiChildView *pWnd)
Activates the MDI view (see activateView() ) and popups the taskBar popup menu (see taskBarPopup() ).
virtual void expandVertical()
Maximizes only in vertical direction.
virtual void closeWindow(KMdiChildView *pWnd, bool layoutTaskBar=true)
Removes a KMdiChildView from the MDI system and from the main frame`s control.
KMdiChildView * createWrapper(TQWidget *view, const TQString &name, const TQString &shortName)
addWindow demands a KMdiChildView.
virtual void activateLastWin()
Activates the view last viewed concerning to the access time.
virtual void activatePrevWin()
Activates the previous open view.
virtual void activateFirstWin()
Activates the view first viewed concerning to the access time.
KMdiChildView * findWindow(const TQString &caption)
Returns the KMdiChildView belonging to the given caption string.
virtual void closeActiveView()
Closes the view of the active (topchild) window.
virtual void childWindowCloseRequest(KMdiChildView *pWnd)
Someone wants that the MDI view to be closed.
virtual void activateView(int index)
Activates the view with the tab page index (TabPage mode only)
KMdiToolViewAccessor * createToolWindow()
Using this method you have to use the setWidget method of the access object, and it is very recommend...
virtual void setUndockPositioningOffset(TQPoint offset)
Sets an offset value that is used on detachWindow() .
virtual void expandHorizontal()
Maximizes only in horizontal direction.
KMdi::MdiMode mdiMode()
Returns the MDI mode.
virtual void cascadeMaximized()
Cascades the windows resizing them to the maximum available size.
void collapseOverlapContainers()
Signals we need to collapse the overlapped containers.
virtual void switchToToplevelMode()
Undocks all view windows (unix-like)
virtual void tileVertically()
Tile Vertically.
virtual void removeWindowFromMdi(KMdiChildView *pWnd)
Removes a KMdiChildView from the MDI system and from the main frame`s control.
virtual void applyOptions()
Called in the constructor (forces a resize of all MDI views)
virtual void setMenuForSDIModeSysButtons(KMenuBar *menuBar=0)
Tells the MDI system a QMenu where it can insert buttons for the system menu, undock,...
virtual TQPopupMenu * windowPopup(KMdiChildView *pWnd, bool bIncludeTaskbarPopup=true)
Returns a popup menu with only a title "Window".
virtual void slot_toggleTaskBar()
Switches the KMdiTaskBar on and off.
virtual void tileAnodine()
Tile Anodine.
void dragEndTimeOut()
The timer for main widget moving has elapsed -> send drag end to all concerned views.
virtual void cascadeWindows()
Cascades the windows without resizing them.
virtual KMdiToolViewAccessor * addToolWindow(TQWidget *pWnd, KDockWidget::DockPosition pos=KDockWidget::DockNone, TQWidget *pTargetWnd=0L, int percent=50, const TQString &tabToolTip=0, const TQString &tabCaption=0)
Usually called from addWindow() when adding a tool view window.
static int frameDecorOfAttachedViews()
virtual void addWindow(KMdiChildView *pWnd, int flags=KMdi::StandardAdd)
Adds a KMdiChildView to the MDI system.
virtual bool event(TQEvent *e)
Catches certain Qt events and processes it here.
void dockMenuItemActivated(int id)
Usually called when the user clicks an MDI view item in the sub-popup menu "Docking" of the "Window" ...
void updateSysButtonConnections(KMdiChildFrm *oldChild, KMdiChildFrm *newChild)
Reconnects the system buttons form maximize mode (SDI mode) with the new child frame.
virtual void switchToChildframeMode()
Docks all view windows (Windows-like)
virtual void detachWindow(KMdiChildView *pWnd, bool bShow=true)
Makes a docked KMdiChildView undocked.
virtual void closeAllViews()
Close all views.
TQSize defaultChildFrmSize()
Returns the default size for a newly added KMdiChildView.
virtual void switchToTabPageMode()
Docks all view windows (Windows-like)
void setSwitching(const bool switching)
We're switching something.
virtual void createTaskBar()
Creates a new MDI taskbar (showing the MDI views as taskbar entries) and shows it.
virtual void createMdiManager()
Creates the MDI view area and connects some signals and slots with the KMdiMainFrm widget.
virtual bool eventFilter(TQObject *obj, TQEvent *e)
void switchOffMaximizeModeForMenu(KMdiChildFrm *oldChild)
Turns the system buttons for maximize mode (SDI mode) off, and disconnects them.
KMdi::TabWidgetVisibility tabWidgetVisibility()
Get tabwidget visibility.
virtual void setFrameDecorOfAttachedViews(int frameDecor)
Sets the decoration of the window frame of docked (attached) MDI views.
void lastChildViewClosed()
Signals the last KMdiChildView (that is under MDI control) has been closed.
KMdiIterator< KMdiChildView * > * createIterator()
If you don't want to know about the inner structure of the KMdi system, you can use this iterator to ...
void findRootDockWidgets(TQPtrList< KDockWidget > *pRootDockWidgetList, TQValueList< TQRect > *pPositionList)
find the root dockwidgets and store their geometry
void setIDEAlModeStyle(int flags) TDE_DEPRECATED
Sets the appearance of the IDEAl mode.
virtual void activateNextWin()
Activates the next open view.
virtual void fillWindowMenu()
Update of the window menu contents.
virtual void setSysButtonsAtMenuPosition()
If there's a main menubar given, it will create the 4 maximize mode buttons there (undock,...
virtual void setMinimumSize(int minw, int minh)
Do nothing when in Toplevel mode.
class KTabWidget * tabWidget() const
Returns the tabwidget used in IDEAl and Tabbed modes.
void closeViewButtonPressed()
internally used to handle click on view close button (TabPage mode, only)
KMdiTaskBarButton * getButton(KMdiChildView *win_ptr)
Get the button belonging to the MDI view given as parameter.
KMdiTaskBarButton * addWinButton(KMdiChildView *win_ptr)
Add a new KMdiTaskBarButton .
void setActiveButton(KMdiChildView *win_ptr)
Pushes the desired taskbar button down (switch on), the old one is released (switched off).
bool isSwitchedOn() const
void switchOn(bool bOn)
Switch it on or off.
void removeWinButton(KMdiChildView *win_ptr, bool haveToLayoutTaskBar=true)
Removes a KMdiTaskBarButton and deletes it.
A namespace for the KMDI library.
@ TextAndIcon
Show both the icon and description on the toolview tabs.
@ IconOnly
Show only icons on the toolview tabs.
@ TextOnly
Show only the text description on the toolview tabs.