20 #include "kdockwidget.h"
21 #include "kdockwidget_private.h"
22 #include "kdockwidget_p.h"
24 #include <tqapplication.h>
26 #include <tqpainter.h>
27 #include <tqobjectlist.h>
28 #include <tqstrlist.h>
30 #include <tqwidgetlist.h>
31 #include <tqtabwidget.h>
32 #include <tqtooltip.h>
36 #include <tdeconfig.h>
37 #include <tdeglobal.h>
39 #include <tdetoolbar.h>
40 #include <tdepopupmenu.h>
43 #include <tdeglobalsettings.h>
52 #include <tqtoolbar.h>
53 #include <tqpopupmenu.h>
58 #undef BORDERLESS_WINDOWS
60 #define DOCK_CONFIG_VERSION "0.0.5"
62 static const char*
const dockback_xpm[]={
73 static const char*
const todesktop_xpm[]={
83 static const char*
const not_close_xpm[]={
105 TQString new_name = TQString(name) + TQString(
"_DockManager");
124 if ( view->isA(
"KDockWidget") ){
125 if ( view->parent() !=
this ) ((
KDockWidget*)view)->applyToWidget(
this );
129 TDEMainWindow::setCentralWidget(view);
131 TQMainWindow::setCentralWidget(view);
181 TQObject* pSender = (TQObject*) sender();
182 if (!pSender->inherits(
"KDockWidget"))
return;
189 :TQFrame( parent, name )
206 style().drawPrimitive (TQStyle::PE_DockWindowHandle, &paint, TQRect(0,0,width(), height()), colorGroup());
212 :TQFrame( parent, name )
219 #ifdef BORDERLESS_WINDOWS
220 setCursor(TQCursor(ArrowCursor));
222 d =
new KDockWidgetHeaderPrivate(
this );
224 layout =
new TQHBoxLayout(
this );
225 layout->setResizeMode( TQLayout::Minimum );
231 closeButton->setPixmap( style().stylePixmap (TQStyle::SP_TitleBarCloseButton ,
this));
233 connect(
closeButton, TQ_SIGNAL(clicked()), parent, TQ_SIGNAL(headerCloseButtonClicked()));
234 connect(
closeButton, TQ_SIGNAL(clicked()), parent, TQ_SLOT(undock()));
237 TQToolTip::add(
stayButton, i18n(
"Freeze the window geometry",
"Freeze") );
239 stayButton->setPixmap(
const_cast< const char**
>(not_close_xpm) );
244 TQToolTip::add(
dockbackButton, i18n(
"Dock this window",
"Dock") );
245 dockbackButton->setPixmap(
const_cast< const char**
>(dockback_xpm));
247 connect(
dockbackButton, TQ_SIGNAL(clicked()), parent, TQ_SIGNAL(headerDockbackButtonClicked()));
248 connect(
dockbackButton, TQ_SIGNAL(clicked()), parent, TQ_SLOT(dockBack()));
251 TQToolTip::add( d->toDesktopButton, i18n(
"Detach") );
252 d->toDesktopButton->setPixmap(
const_cast< const char**
>(todesktop_xpm));
254 connect( d->toDesktopButton, TQ_SIGNAL(clicked()), parent, TQ_SLOT(toDesktop()));
257 d->dummy =
new TQWidget(
this );
258 d->dummy->setFixedSize( 1,
closeButton->pixmap()->height() );
263 layout->addWidget( d->toDesktopButton );
264 layout->addWidget( d->dummy);
269 drag->setFixedHeight(
layout->minimumSize().height() );
274 d->topLevel = isTopLevel;
284 d->toDesktopButton->hide();
285 drag->setEnabled(
true );
289 if (!d->forceCloseButtonHidden)
closeButton->show();
290 if( d->showToDesktopButton )
291 d->toDesktopButton->show();
296 d->toDesktopButton->isVisibleTo(
this) ||
stayButton->isVisibleTo(
this) ||
298 for (TQPtrListIterator<KDockButton_Private> it( d->btns );it.current();++it) {
299 dontShowDummy=dontShowDummy || (it.current()->isVisibleTo(
this));
301 if (dontShowDummy) d->dummy->hide();
else d->dummy->show();
307 d->forceCloseButtonHidden=hidden;
321 layout =
new TQHBoxLayout(
this );
322 layout->setResizeMode( TQLayout::Minimum );
326 if (
drag->parentWidget()!=
this) {
327 drag->reparent(
this,TQPoint(0,0));
333 layout->addWidget( d->dummy );
334 layout->addWidget( d->toDesktopButton );
337 d->toDesktopButton->isVisibleTo(
this) ||
stayButton->isVisibleTo(
this) ||
339 for (TQPtrListIterator<KDockButton_Private> it( d->btns );it.current();++it) {
340 layout->addWidget(it.current());
341 dontShowDummy=dontShowDummy || (it.current()->isVisibleTo(
this));
343 if (dontShowDummy) d->dummy->hide();
else d->dummy->show();
346 kdDebug(282)<<
"KdockWidgetHeader::setDragPanel:minimum height="<<
layout->minimumSize().height()<<
endl;
354 if (btn->parentWidget()!=
this) {
355 btn->reparent(
this,TQPoint(0,0));
358 if (!d->btns.containsRef(btn)) d->btns.append(btn);
363 layout =
new TQHBoxLayout(
this );
364 layout->setResizeMode( TQLayout::Minimum );
368 layout->addWidget( d->toDesktopButton );
369 layout->addWidget( d->dummy);
372 d->toDesktopButton->isVisibleTo(
this) ||
stayButton->isVisibleTo(
this) ||
374 for (TQPtrListIterator<KDockButton_Private> it( d->btns );it.current();++it) {
375 layout->addWidget(it.current());
376 dontShowDummy=dontShowDummy || (it.current()->isVisibleTo(
this));
378 if (dontShowDummy) d->dummy->hide();
else d->dummy->show();
381 drag->setFixedHeight(
layout->minimumSize().height() );
385 if (btn->parentWidget()==
this) {
386 if (d->btns.containsRef(btn)) d->btns.removeRef(btn);
397 bool KDockWidgetHeader::dragEnabled()
const
399 return drag->isEnabled();
404 kdDebug(282)<<
"KDockWidgetHeader::showUndockButton("<<show<<
")"<<
endl;
405 if( d->showToDesktopButton == show )
408 d->showToDesktopButton = show;
409 if( !show || d->topLevel )
410 d->toDesktopButton->hide( );
412 d->toDesktopButton->show( );
415 void KDockWidgetHeader::setDragEnabled(
bool b)
430 setDragEnabled( !c->
readBoolEntry( TQString(
"%1%2").arg(parent()->name()).arg(
":stayButton"),
false ) );
436 class KDockManager::KDockManagerPrivate
466 TQGuardedPtr<KDockWidget> mainDockWidget;
468 TQObjectList containerDocks;
470 TQGuardedPtr<KDockWidget> leftContainer;
471 TQGuardedPtr<KDockWidget> topContainer;
472 TQGuardedPtr<KDockWidget> rightContainer;
473 TQGuardedPtr<KDockWidget> bottomContainer;
474 int m_readDockConfigMode;
480 #ifdef BORDERLESS_WINDOWS
481 : TQWidget( parent, name, f )
483 : TQWidget( parent, name, f )
485 ,formerBrotherDockWidget(0L)
486 ,currentDockPos(DockNone)
487 ,formerDockPos(DockNone)
489 ,pix(
new TQPixmap(pixmap))
490 ,prevSideDockPosBeforeDrag(DockNone)
497 layout =
new TQVBoxLayout(
this );
498 layout->setResizeMode( TQLayout::Minimum );
500 manager = dockManager;
501 manager->childDock->append(
this );
502 installEventFilter( manager );
504 eDocking = DockFullDocking;
505 sDocking = DockFullSite;
510 if( strCaption.isNull() )
513 setCaption( strCaption);
515 if( strTabPageLabel ==
" ")
516 setTabPageLabel( caption());
518 setTabPageLabel( strTabPageLabel);
521 d->isContainer =
false;
525 TQObject::connect(
this, TQ_SIGNAL(hasUndocked()), manager->main, TQ_SLOT(slotDockWidgetUndocked()) );
526 applyToWidget( parent, TQPoint(0,0) );
535 dtg->changeTab(
this,
pixmap,dtg->tabLabel(
this));
538 KDockContainer *x =
dynamic_cast<KDockContainer*
>(contWid);
540 x->setPixmap(
this,
pixmap);
551 d->pendingDtor =
true;
552 if ( !manager->undockProcess ){
553 d->blockHasUndockedSignal =
true;
555 d->blockHasUndockedSignal =
false;
561 x->removeWidget(
this);
565 if (manager->d) manager->d->containerDocks.remove(
this);
566 manager->childDock->remove(
this);
572 void KDockWidget::paintEvent(TQPaintEvent* pe)
574 TQWidget::paintEvent(pe);
577 style().drawPrimitive (TQStyle::PE_Panel, &paint, TQRect(0,0,width(), height()), colorGroup());
581 void KDockWidget::leaveEvent(TQEvent *e)
583 TQWidget::leaveEvent(e);
584 #ifdef BORDERLESS_WINDOWS
585 if (parent())
return;
590 void KDockWidget::mousePressEvent(TQMouseEvent* mme)
592 #ifdef BORDERLESS_WINDOWS
595 kdDebug(282)<<
"KDockWidget::mousePressEvent"<<
endl;
604 styleheight=2*style().pixelMetric(TQStyle::PM_DefaultFrameWidth,
this);
605 bbottom=mp.y()>=height()-styleheight;
606 btop=mp.y()<=styleheight;
607 bleft=mp.x()<=styleheight;
608 bright=mp.x()>=width()-styleheight;
615 d->resizeMode=KDockWidgetPrivate::ResizeTopRight;
616 d->resizePos=TQPoint(width(),0)-mme->pos();
621 d->resizePos=TQPoint(width(),height())-mme->pos();
622 if (bbottom) d->resizeMode=KDockWidgetPrivate::ResizeBottomRight;
623 else d->resizeMode=KDockWidgetPrivate::ResizeRight;
628 if (btop) setCursor(TQCursor(SizeFDiagCursor));
630 if (bbottom) setCursor(TQCursor(SizeBDiagCursor));
631 else setCursor(TQCursor(SizeHorCursor));
636 d->resizeMode=KDockWidgetPrivate::ResizeBottom;
637 d->resizePos=TQPoint(0,height())-mme->pos();
640 if (btop) setCursor(TQCursor(SizeVerCursor));
641 else d->resizing=
false;
643 if (d->resizing) grabMouse(cursor());
647 TQWidget::mousePressEvent(mme);
650 void KDockWidget::mouseReleaseEvent(TQMouseEvent* ev)
652 #ifdef BORDERLESS_WINDOWS
656 TQWidget::mouseReleaseEvent(ev);
659 void KDockWidget::mouseMoveEvent(TQMouseEvent* mme)
661 TQWidget::mouseMoveEvent(mme);
662 #ifdef BORDERLESS_WINDOWS
663 if (parent())
return;
667 switch (d->resizeMode)
669 case KDockWidgetPrivate::ResizeRight:
670 resize(mme->pos().x()+d->resizePos.x(),height());
672 case KDockWidgetPrivate::ResizeBottomRight:
673 resize(mme->pos().x()+d->resizePos.x(),mme->pos().y()+d->resizePos.y());
675 case KDockWidgetPrivate::ResizeBottom:
676 resize(width(),mme->pos().y()+d->resizePos.y());
692 styleheight=2*style().pixelMetric(TQStyle::PM_DefaultFrameWidth,
this);
693 bbottom=mp.y()>=height()-styleheight;
694 btop=mp.y()<=styleheight;
695 bleft=mp.x()<=styleheight;
696 bright=mp.x()>=width()-styleheight;
700 if (btop) setCursor(TQCursor(SizeBDiagCursor));
702 if (bbottom) setCursor(TQCursor(SizeFDiagCursor));
703 else setCursor(TQCursor(SizeHorCursor));
707 if (btop) setCursor(TQCursor(SizeFDiagCursor));
709 if (bbottom) setCursor(TQCursor(SizeBDiagCursor));
710 else setCursor(TQCursor(SizeHorCursor));
713 if (bbottom || btop) setCursor(TQCursor(SizeVerCursor));
714 else setCursor(TQCursor(ArrowCursor));
722 if (
dynamic_cast<KDockContainer*
>(container))
723 d->container=container;
731 if (!(d->container))
return 0;
732 if (
dynamic_cast<KDockContainer*
>(d->container.operator->()))
return d->container;
750 layout =
new TQVBoxLayout(
this );
751 layout->setResizeMode( TQLayout::Minimum );
752 layout->addWidget( header );
756 layout->addWidget( header );
758 kdDebug(282)<<caption()<<
": KDockWidget::setHeader"<<
endl;
766 if (header->inherits(
"KDockWidgetHeader" ) )
775 #ifdef BORDERLESS_WINDOWS
776 layout->setMargin(0);
777 setMouseTracking(
false);
778 setCursor(TQCursor(ArrowCursor));
781 if ( (parent() == manager->main) || isGroup || (eDocking == KDockWidget::DockNone) ){
785 if (widget &&
dynamic_cast<KDockContainer*
>(widget))
793 #ifdef BORDERLESS_WINDOWS
794 layout->setMargin(2*style().pixelMetric(TQStyle::PM_DefaultFrameWidth,
this));
795 setMouseTracking(
true);
800 void KDockWidget::applyToWidget( TQWidget* s,
const TQPoint& p )
805 reparent(s, 0, TQPoint(0,0),
false);
808 if ( s && s->inherits(
"KDockMainWindow") ){
812 if ( manager && s == manager->main ){
813 setGeometry( TQRect(TQPoint(0,0), manager->main->geometry().size()) );
822 if (d->transient && d->_parent)
823 XSetTransientForHint( tqt_xdisplay(), winId(), d->_parent->winId() );
825 #ifdef BORDERLESS_WINDOWS
842 if ( parent() || manager->main->isVisible() )
860 d->windowType = windowType;
861 applyToWidget( parentWidget(), TQPoint(0,0) );
866 void KDockWidget::setDockWindowTransient (TQWidget *parent,
bool transientEnabled)
869 d->transient = transientEnabled;
870 applyToWidget( parentWidget(), TQPoint(0,0) );
874 if (d->transient && d->_parent)
return d->_parent;
else return 0;
879 switch (
event->type() )
882 case TQEvent::FocusIn:
883 if (widget && !d->pendingFocusInEvent) {
884 d->pendingFocusInEvent =
true;
887 d->pendingFocusInEvent =
false;
889 case TQEvent::ChildRemoved:
890 if ( widget == ((TQChildEvent*)
event)->child() ) widget = 0L;
893 if ( widget ) widget->show();
897 if ( widget ) widget->hide();
900 case TQEvent::CaptionChange:
901 if ( parentWidget() ){
902 if ( parent()->inherits(
"KDockSplitter") ){
917 return TQWidget::event(
event );
922 if (!parent())
return 0;
923 if (!parent()->inherits(
"KDockSplitter"))
return 0;
924 Orientation orientation=((pos==DockLeft) || (pos==DockRight)) ? TQt::Vertical:TQt::Horizontal;
925 if (((
KDockSplitter*)(parent()))->orientation()==orientation)
928 ((pos==DockLeft)||(pos==DockTop))?
957 if ( !(eDocking & (
int)dockPos) ){
965 spliPos = spliPos / 100;
966 kdDebug(282) <<
"KDockWidget::manualDock(): fix splitter position: " << spliPos <<
endl;
989 if ( tmpTarget && target &&
this != tmpTarget && target ==
dockManager()->d->mainDockWidget )
990 return manualDock(tmpTarget,DockCenter,spliPos,pos,check,tabIndex);
993 if ( target && !(target->sDocking & (
int)dockPos) ){
1014 if ( target && !check ){
1017 case KDockWidget::DockLeft : another__dockPos = KDockWidget::DockRight ;
break;
1018 case KDockWidget::DockRight : another__dockPos = KDockWidget::DockLeft ;
break;
1019 case KDockWidget::DockTop : another__dockPos = KDockWidget::DockBottom;
break;
1020 case KDockWidget::DockBottom: another__dockPos = KDockWidget::DockTop ;
break;
1023 dock_result = target->
manualDock(
this, another__dockPos, spliPos, pos,
true, tabIndex );
1029 d->blockHasUndockedSignal =
true;
1031 d->blockHasUndockedSignal =
false;
1045 applyToWidget( parentTab );
1046 parentTab->insertTab(
this, icon() ? *icon() : TQPixmap(),
1049 TQWidget *wantTransient=parentTab->transientTo();
1050 target->setDockWindowTransient(wantTransient,wantTransient);
1052 setDockTabName( parentTab );
1064 if (!contWid) contWid=target->widget;
1067 KDockContainer *cont=
dynamic_cast<KDockContainer*
>(contWid);
1073 dc->removeWidget(
this);
1077 applyToWidget( contWid );
1078 cont->insertWidget(
this, icon() ? *icon() : TQPixmap(),
1094 TQWidget* parentDock = target->parentWidget();
1098 if ( dockPos == KDockWidget::DockCenter ){
1099 newDock->isTabGroup =
true;
1101 newDock->isGroup =
true;
1103 newDock->eDocking = (target->eDocking & eDocking) & (~(
int)KDockWidget::DockCenter);
1105 newDock->applyToWidget( parentDock );
1109 newDock->move( target->frameGeometry().topLeft() );
1110 newDock->resize( target->geometry().size() );
1111 if ( target->isVisibleToTLW() ) newDock->
show();
1124 if ( dockPos == KDockWidget::DockCenter )
1127 TQObject::connect(tab, TQ_SIGNAL(currentChanged(TQWidget*)), d, TQ_SLOT(slotFocusEmbeddedWidget(TQWidget*)));
1130 target->applyToWidget( tab );
1131 applyToWidget( tab );
1134 tab->insertTab( target, target->icon() ? *(target->icon()) : TQPixmap(),
1142 tab->insertTab(
this, icon() ? *icon() : TQPixmap(),
1145 TQRect geom=newDock->geometry();
1146 TQWidget *wantTransient=tab->transientTo();
1147 newDock->setDockWindowTransient(wantTransient,wantTransient);
1148 newDock->setGeometry(geom);
1153 setDockTabName( tab );
1164 if ( dockPos == KDockWidget::DockTop || dockPos == KDockWidget::DockBottom ) panner =
new KDockSplitter( newDock,
"_dock_split_", TQt::Horizontal, spliPos );
1165 if ( dockPos == KDockWidget::DockLeft || dockPos == KDockWidget::DockRight ) panner =
new KDockSplitter( newDock,
"_dock_split_", TQt::Vertical , spliPos );
1170 panner->setFocusPolicy( TQWidget::NoFocus );
1171 target->applyToWidget( panner );
1172 applyToWidget( panner );
1174 if ( dockPos == KDockWidget::DockRight) {
1179 else if( dockPos == KDockWidget::DockBottom) {
1184 else if( dockPos == KDockWidget::DockTop) {
1189 else if( dockPos == KDockWidget::DockLeft) {
1200 if ( parentDock->inherits(
"KDockSplitter") ){
1211 emit target->
docking(
this, dockPos );
1220 if ( !parent() )
return 0L;
1221 TQWidget* candidate = parentWidget()->parentWidget();
1222 if ( candidate && candidate->inherits(
"KDockTabGroup") )
return (
KDockTabGroup*)candidate;
1228 if (!parent())
return 0L;
1229 TQWidget* candidate = parentWidget()->parentWidget();
1230 if (candidate &&
dynamic_cast<KDockContainer*
>(candidate))
return candidate;
1239 if (!parent())
return;
1240 if (parent()->inherits(
"KDockSplitter"))
1241 ::tqt_cast<KDockSplitter*>(parent())->setForcedFixedWidth(
this,w);
1248 if (!parent())
return;
1249 if (parent()->inherits(
"KDockSplitter"))
1250 ::tqt_cast<KDockSplitter*>(parent())->setForcedFixedHeight(
this,h);
1255 return d->forcedWidth;
1260 return d->forcedHeight;
1268 setMaximumWidth(32000);
1269 setMinimumHeight(0);
1270 setMaximumHeight(32000);
1271 if (!parent())
return;
1272 if (parent()->inherits(
"KDockSplitter"))
1273 ::tqt_cast<KDockSplitter*>(parent())->restoreFromForcedFixedSize(
this);
1278 TQPoint p = mapToGlobal( TQPoint( -30, -30 ) );
1295 manager->d->dragRect = TQRect ();
1296 manager->drawDragRectangle ();
1298 TQWidget* parentW = parentWidget();
1301 if (!d->blockHasUndockedSignal)
1309 manager->blockSignals(
true);
1310 manager->undockProcess =
true;
1312 bool isV = parentW->isVisibleToTLW();
1317 d->index = parentTab->indexOf(
this);
1318 parentTab->removePage(
this );
1324 applyToWidget( 0L );
1325 if ( parentTab->count() == 1 ){
1329 parentTab->removePage( lastTab );
1333 lastTab->applyToWidget( 0L );
1334 lastTab->move( parentTab->mapToGlobal(parentTab->frameGeometry().topLeft()) );
1340 TQWidget* parentOfDockWidget = parentOfTab->parentWidget();
1341 if ( !parentOfDockWidget ){
1342 if ( isV ) lastTab->
show();
1344 if ( parentOfDockWidget->inherits(
"KDockSplitter") ){
1346 lastTab->applyToWidget( split );
1348 if ( split->
getFirst() == parentOfTab ){
1350 if ( ((
KDockWidget*)split->parent())->splitterOrientation == TQt::Vertical )
1356 if ( ((
KDockWidget*)split->parent())->splitterOrientation == TQt::Vertical )
1357 emit ((
KDockWidget*)split->
getAnother(parentOfTab))->docking( parentOfTab, KDockWidget::DockRight );
1359 emit ((
KDockWidget*)split->
getAnother(parentOfTab))->docking( parentOfTab, KDockWidget::DockBottom );
1363 lastTab->applyToWidget( parentOfDockWidget );
1367 manager->blockSignals(
false);
1368 emit manager->
replaceDock( parentOfTab, lastTab );
1371 manager->blockSignals(
true);
1375 setDockTabName( parentTab );
1380 bool undockedFromContainer=
false;
1384 undockedFromContainer=
true;
1385 KDockContainer* dc =
dynamic_cast<KDockContainer*
>(d->container.operator->());
1387 dc->undockWidget(
this);
1390 applyToWidget( 0L );
1392 if (!undockedFromContainer) {
1394 if ( parentW->inherits(
"KDockSplitter") ){
1401 applyToWidget( 0L );
1404 if ( !group->parentWidget() ){
1405 secondWidget->applyToWidget( 0L, group->frameGeometry().topLeft() );
1406 secondWidget->resize( group->width(), group->height() );
1408 TQWidget* obj = group->parentWidget();
1409 secondWidget->applyToWidget( obj );
1410 if ( obj->inherits(
"KDockSplitter") ){
1414 if ( parentOfGroup->
getFirst() == group )
1415 parentOfGroup->
activate( secondWidget );
1417 parentOfGroup->
activate( 0L, secondWidget );
1422 delete parentSplitterOfDockWidget;
1423 manager->blockSignals(
false);
1426 manager->blockSignals(
true);
1429 if ( isV ) secondWidget->
show();
1431 if (!d->pendingDtor) {
1433 applyToWidget( 0L );
1439 manager->blockSignals(
false);
1440 if (!d->blockHasUndockedSignal)
1442 manager->undockProcess =
false;
1444 if (!d->blockHasUndockedSignal)
1452 if ( mw->parent() !=
this ){
1453 mw->reparent(
this, 0, TQPoint(0,0),
false);
1456 #ifdef BORDERLESS_WINDOWS
1457 if (!mw->ownCursor()) mw->setCursor(TQCursor(ArrowCursor));
1462 layout =
new TQVBoxLayout(
this );
1463 layout->setResizeMode( TQLayout::Minimum );
1465 KDockContainer* dc =
dynamic_cast<KDockContainer*
>(widget);
1468 d->isContainer=
true;
1469 manager->d->containerDocks.append(
this);
1473 d->isContainer=
false;
1478 layout->addWidget( header );
1479 layout->addWidget( widget,1 );
1487 TQString listOfName;
1488 TQString listOfCaption;
1489 for (
int i = 0; i < tab->count(); ++i ) {
1490 TQWidget *w = tab->page( i );
1491 listOfCaption.append( w->caption() ).append(
",");
1492 listOfName.append( w->name() ).append(
",");
1494 listOfCaption.remove( listOfCaption.length()-1, 1 );
1495 listOfName.remove( listOfName.length()-1, 1 );
1497 tab->parentWidget()->setName( listOfName.utf8() );
1498 tab->parentWidget()->setCaption( listOfCaption );
1500 tab->parentWidget()->repaint(
false );
1501 if ( tab->parentWidget()->parent() )
1502 if ( tab->parentWidget()->parent()->inherits(
"KDockSplitter") )
1503 ((
KDockSplitter*)(tab->parentWidget()->parent()))->updateName();
1508 bool f = (parent() != manager->main);
1509 return ( !isGroup && !isTabGroup && f && isVisible() && ( eDocking != (int)KDockWidget::DockNone ) );
1514 bool f = (parent() != manager->main);
1515 return ( !isGroup && !isTabGroup && f && !isVisible() );
1526 if ( manager->main->inherits(
"KDockMainWindow") ){
1541 KDockContainer *x =
dynamic_cast<KDockContainer*
>(contWid);
1543 x->showWidget(
this);
1546 if ( isVisible() )
return;
1548 TQWidget* p = parentWidget();
1550 if ( !p->isVisible() )
1552 p = p->parentWidget();
1581 TQObjectList* cl = queryList(
"KDockWidget");
1582 TQObjectListIt it( *cl );
1584 while ( !found && (obj=it.current()) != 0 ) {
1586 TQWidget* widg = (TQWidget*)obj;
1620 :TQObject( mainWindow, name )
1622 ,currentDragWidget(0L)
1623 ,currentMoveWidget(0L)
1624 ,childDockWidgetList(0L)
1629 ,undockProcess(false)
1632 d =
new KDockManagerPrivate;
1634 d->readyToDrag =
false;
1635 d->mainDockWidget=0;
1640 d->splitterOpaqueResize =
false;
1643 d->splitterKeepSize =
false;
1644 d->splitterHighResolution =
false;
1645 d->m_readDockConfigMode = WrapExistingWidgetsOnly;
1647 main->installEventFilter(
this );
1649 undockProcess =
false;
1651 menuData =
new TQPtrList<MenuDockData>;
1652 menuData->setAutoDelete(
true );
1653 menuData->setAutoDelete(
true );
1658 menu =
new TQPopupMenu();
1661 connect( menu, TQ_SIGNAL(aboutToShow()), TQ_SLOT(slotMenuPopup()) );
1662 connect( menu, TQ_SIGNAL(activated(
int)), TQ_SLOT(slotMenuActivated(
int)) );
1664 childDock =
new TQObjectList();
1665 childDock->setAutoDelete(
false );
1671 d->mainDockWidget=w;
1679 TQObjectListIt it( *childDock );
1692 TQObjectListIt it( *childDock );
1697 if ( obj->widget ) obj->widget->show();
1702 if ( !main->inherits(
"TQDialog") ) main->show();
1708 if ( obj->inherits(
"KDockWidgetAbstractHeaderDrag") ){
1711 switch ( event->type() ){
1712 case TQEvent::MouseButtonDblClick:
1721 case TQEvent::MouseButtonPress:
1722 if ( ((TQMouseEvent*)event)->button() == TQt::LeftButton ){
1723 if ( curdw->eDocking != (
int)KDockWidget::DockNone ){
1726 tqApp->processOneEvent();
1728 currentDragWidget = curdw;
1729 currentMoveWidget = 0L;
1730 childDockWidgetList =
new TQWidgetList();
1731 childDockWidgetList->append( curdw );
1732 findChildDockWidget( curdw, childDockWidgetList );
1735 d->dragRect = TQRect(curdw->geometry());
1736 TQPoint p = curdw->mapToGlobal(TQPoint(0,0));
1737 d->dragRect.moveTopLeft(p);
1738 drawDragRectangle();
1739 d->readyToDrag =
true;
1741 d->dragOffset = TQCursor::pos()-currentDragWidget->mapToGlobal(TQPoint(0,0));
1746 case TQEvent::MouseButtonRelease:
1747 if ( ((TQMouseEvent*)event)->button() == TQt::LeftButton ){
1754 if (d->readyToDrag) {
1755 d->readyToDrag =
false;
1757 d->dragRect = TQRect(curdw->geometry());
1758 TQPoint p = curdw->mapToGlobal(TQPoint(0,0));
1759 d->dragRect.moveTopLeft(p);
1760 drawDragRectangle();
1761 currentDragWidget = 0L;
1762 delete childDockWidgetList;
1763 childDockWidgetList = 0L;
1769 case TQEvent::MouseMove:
1772 #ifdef BORDERLESS_WINDOWS
1775 if (!curdw->parent())
1777 curdw->move(TQCursor::pos()-d->dragOffset);
1778 pDockWdgAtCursor = findDockWidgetAt( TQCursor::pos()-TQPoint(0,d->dragOffset.y()+3) );
1779 oldMoveWidget = currentMoveWidget;
1783 pDockWdgAtCursor = findDockWidgetAt( TQCursor::pos() );
1784 oldMoveWidget = currentMoveWidget;
1788 pDockWdgAtCursor = findDockWidgetAt( TQCursor::pos() );
1792 if ( currentMoveWidget && pDockWdgAtCursor == currentMoveWidget ) {
1793 dragMove( currentMoveWidget, currentMoveWidget->mapFromGlobal( TQCursor::pos() ) );
1796 if (dropCancel && curdw) {
1797 d->dragRect = TQRect(curdw->geometry());
1798 TQPoint p = curdw->mapToGlobal(TQPoint(0,0));
1799 d->dragRect.moveTopLeft(p);
1801 d->dragRect = TQRect();
1803 drawDragRectangle();
1806 if ( !pDockWdgAtCursor && !(curdw->eDocking & (
int)KDockWidget::DockDesktop) ){
1808 currentMoveWidget = pDockWdgAtCursor;
1809 curPos = KDockWidget::DockDesktop;
1811 if ( oldMoveWidget && pDockWdgAtCursor != currentMoveWidget ) {
1812 currentMoveWidget = pDockWdgAtCursor;
1813 curPos = KDockWidget::DockDesktop;
1817 if ( oldMoveWidget != pDockWdgAtCursor && pDockWdgAtCursor ) {
1818 currentMoveWidget = pDockWdgAtCursor;
1819 curPos = KDockWidget::DockDesktop;
1822 if (d->readyToDrag) {
1823 d->readyToDrag =
false;
1825 if ( (((TQMouseEvent*)event)->state() == TQt::LeftButton) &&
1826 (curdw->eDocking != (
int)KDockWidget::DockNone) ) {
1835 return TQObject::eventFilter( obj, event );
1838 KDockWidget* KDockManager::findDockWidgetAt(
const TQPoint& pos )
1842 if (!currentDragWidget)
1845 if (currentDragWidget->eDocking == (
int)KDockWidget::DockNone )
return 0L;
1847 TQWidget* p = TQApplication::widgetAt( pos );
1852 #if defined(_OS_WIN32_) || defined(Q_OS_WIN32)
1853 p = p->topLevelWidget();
1856 findChildDockWidget( w, p, p->mapFromGlobal(pos) );
1858 if ( !p->inherits(
"KDockWidget") ) {
1863 if ( tqt_find_obj_child( w,
"KDockSplitter",
"_dock_split_" ) )
return 0L;
1864 if ( tqt_find_obj_child( w,
"KDockTabGroup",
"_dock_tab" ) )
return 0L;
1865 if (
dynamic_cast<KDockContainer*
>(w))
return 0L;
1867 if (!childDockWidgetList)
return 0L;
1868 if ( childDockWidgetList->find(w) != -1 )
return 0L;
1869 if ( currentDragWidget->isGroup && ((
KDockWidget*)w)->parentDockTabGroup() )
return 0L;
1872 if ( www->sDocking == (
int)KDockWidget::DockNone )
return 0L;
1877 TQPoint cpos = www->mapFromGlobal( pos );
1879 int ww = www->widget->width() / 3;
1880 int hh = www->widget->height() / 3;
1882 if ( cpos.y() <= hh ){
1883 curPos = KDockWidget::DockTop;
1885 if ( cpos.y() >= 2*hh ){
1886 curPos = KDockWidget::DockBottom;
1888 if ( cpos.x() <= ww ){
1889 curPos = KDockWidget::DockLeft;
1891 if ( cpos.x() >= 2*ww ){
1892 curPos = KDockWidget::DockRight;
1894 curPos = KDockWidget::DockCenter;
1896 if ( !(www->sDocking & (
int)curPos) )
return 0L;
1897 if ( !(currentDragWidget->eDocking & (
int)curPos) )
return 0L;
1898 if ( www->manager !=
this )
return 0L;
1904 void KDockManager::findChildDockWidget( TQWidget*& ww,
const TQWidget* p,
const TQPoint& pos )
1906 if ( !p->childrenListObject().isEmpty() ) {
1908 TQObjectListIt it( p->childrenListObject() );
1910 while ( it.current() ) {
1911 if ( it.current()->isWidgetType() ) {
1912 w = (TQWidget*)it.current();
1913 if ( w->isVisible() && w->geometry().contains(pos) ) {
1914 if ( w->inherits(
"KDockWidget") ) ww = w;
1915 findChildDockWidget( ww, w, w->mapFromParent(pos) );
1925 void KDockManager::findChildDockWidget(
const TQWidget* p, TQWidgetList*& list )
1927 if ( !p->childrenListObject().isEmpty() ) {
1929 TQObjectListIt it( p->childrenListObject() );
1931 while ( it.current() ) {
1932 if ( it.current()->isWidgetType() ) {
1933 w = (TQWidget*)it.current();
1934 if ( w->isVisible() ) {
1935 if ( w->inherits(
"KDockWidget") ) list->append( w );
1936 findChildDockWidget( w, list );
1951 if ( w->parentWidget()->inherits(
"KDockSplitter") ){
1957 curPos = KDockWidget::DockDesktop;
1960 TQApplication::setOverrideCursor(TQCursor(TQt::sizeAllCursor));
1963 void KDockManager::dragMove(
KDockWidget* dw, TQPoint pos )
1965 TQPoint p = dw->mapToGlobal( dw->widget->pos() );
1968 TQSize r = dw->widget->size();
1970 curPos = KDockWidget::DockCenter;
1971 if ( oldPos != curPos ) {
1972 d->dragRect.setRect( p.x()+2, p.y()+2, r.width()-4, r.height()-4 );
1977 int w = r.width() / 3;
1978 int h = r.height() / 3;
1980 if ( pos.y() <= h ){
1981 curPos = KDockWidget::DockTop;
1984 if ( pos.y() >= 2*h ){
1985 curPos = KDockWidget::DockBottom;
1986 p.setY( p.y() + 2*h );
1989 if ( pos.x() <= w ){
1990 curPos = KDockWidget::DockLeft;
1993 if ( pos.x() >= 2*w ){
1994 curPos = KDockWidget::DockRight;
1995 p.setX( p.x() + 2*w );
1999 curPos = KDockWidget::DockCenter;
2000 p.setX( p.x() + w );
2001 p.setY( p.y() + h );
2004 if ( oldPos != curPos ) {
2005 d->dragRect.setRect( p.x(), p.y(), w, h );
2006 drawDragRectangle();
2011 void KDockManager::cancelDrop()
2013 TQApplication::restoreOverrideCursor();
2015 delete childDockWidgetList;
2016 childDockWidgetList = 0L;
2018 d->dragRect = TQRect();
2019 drawDragRectangle();
2023 void KDockManager::drop()
2025 d->dragRect = TQRect();
2026 drawDragRectangle();
2028 TQApplication::restoreOverrideCursor();
2030 delete childDockWidgetList;
2031 childDockWidgetList = 0L;
2033 if ( dropCancel )
return;
2034 if ( !currentMoveWidget && (!(currentDragWidget->eDocking & (
int)KDockWidget::DockDesktop)) ) {
2035 d->dragRect = TQRect();
2036 drawDragRectangle();
2039 if ( !currentMoveWidget && !currentDragWidget->parent() ) {
2040 currentDragWidget->move( TQCursor::pos() - d->dragOffset );
2047 int splitPos = currentDragWidget->d->splitPosInPercent;
2059 if( (curPos != previousPosition)
2060 && (curPos != KDockWidget::DockCenter) && (curPos != KDockWidget::DockDesktop)) {
2062 if (previousPosition == KDockWidget::DockNone)
2065 switch( previousPosition ) {
2066 case KDockWidget::DockLeft:
2067 if(curPos != KDockWidget::DockTop && curPos != KDockWidget::DockLeft)
2068 splitPos = 100 - splitPos;
2071 case KDockWidget::DockRight:
2072 if(curPos != KDockWidget::DockBottom && curPos != KDockWidget::DockRight)
2073 splitPos = 100 - splitPos;
2076 case KDockWidget::DockTop:
2077 if(curPos != KDockWidget::DockLeft && curPos != KDockWidget::DockTop )
2078 splitPos = 100 - splitPos;
2081 case KDockWidget::DockBottom:
2082 if(curPos != KDockWidget::DockRight && curPos != KDockWidget::DockBottom )
2083 splitPos = 100 - splitPos;
2090 currentDragWidget->prevSideDockPosBeforeDrag = curPos;
2091 currentDragWidget->
manualDock( currentMoveWidget, curPos , splitPos, TQCursor::pos() - d->dragOffset );
2097 static TQDomElement createStringEntry(TQDomDocument &doc,
const TQString &tagName,
const TQString &str)
2099 TQDomElement el = doc.createElement(tagName);
2101 el.appendChild(doc.createTextNode(str));
2106 static TQDomElement createBoolEntry(TQDomDocument &doc,
const TQString &tagName,
bool b)
2108 return createStringEntry(doc, tagName, TQString::fromLatin1(b?
"true" :
"false"));
2112 static TQDomElement createNumberEntry(TQDomDocument &doc,
const TQString &tagName,
int n)
2114 return createStringEntry(doc, tagName, TQString::number(n));
2118 static TQDomElement createRectEntry(TQDomDocument &doc,
const TQString &tagName,
const TQRect &rect)
2120 TQDomElement el = doc.createElement(tagName);
2122 TQDomElement xel = doc.createElement(
"x");
2123 xel.appendChild(doc.createTextNode(TQString::number(rect.x())));
2124 el.appendChild(xel);
2125 TQDomElement yel = doc.createElement(
"y");
2126 yel.appendChild(doc.createTextNode(TQString::number(rect.y())));
2127 el.appendChild(yel);
2128 TQDomElement wel = doc.createElement(
"width");
2129 wel.appendChild(doc.createTextNode(TQString::number(rect.width())));
2130 el.appendChild(wel);
2131 TQDomElement hel = doc.createElement(
"height");
2132 hel.appendChild(doc.createTextNode(TQString::number(rect.height())));
2133 el.appendChild(hel);
2139 static TQDomElement createListEntry(TQDomDocument &doc,
const TQString &tagName,
2140 const TQString &subTagName,
const TQStrList &list)
2142 TQDomElement el = doc.createElement(tagName);
2144 TQStrListIterator it(list);
2145 for (; it.current(); ++it) {
2146 TQDomElement subel = doc.createElement(subTagName);
2147 subel.appendChild(doc.createTextNode(TQString::fromLatin1(it.current())));
2148 el.appendChild(subel);
2155 static TQString stringEntry(TQDomElement &base,
const TQString &tagName)
2157 return base.namedItem(tagName).firstChild().toText().data();
2161 static bool boolEntry(TQDomElement &base,
const TQString &tagName)
2163 return base.namedItem(tagName).firstChild().toText().data() ==
"true";
2167 static int numberEntry(TQDomElement &base,
const TQString &tagName)
2169 return stringEntry(base, tagName).toInt();
2173 static TQRect rectEntry(TQDomElement &base,
const TQString &tagName)
2175 TQDomElement el = base.namedItem(tagName).toElement();
2177 int x = numberEntry(el,
"x");
2178 int y = numberEntry(el,
"y");
2179 int width = numberEntry(el,
"width");
2180 int height = numberEntry(el,
"height");
2182 return TQRect(x, y, width, height);
2186 static TQStrList listEntry(TQDomElement &base,
const TQString &tagName,
const TQString &subTagName)
2190 for( TQDomNode n = base.namedItem(tagName).firstChild(); !n.isNull(); n = n.nextSibling() )
2192 TQDomElement subel = n.toElement();
2193 if (subel.tagName() == subTagName)
2194 list.append(subel.firstChild().toText().data().latin1());
2204 while (!base.firstChild().isNull())
2205 base.removeChild(base.firstChild());
2206 TQDomDocument doc = base.ownerDocument();
2209 TQString mainWidgetStr;
2213 TQObjectListIt it(*childDock);
2216 if ( obj1->parent() == main )
2217 mainWidgetStr = TQString::fromLatin1(obj1->name());
2218 nList.append(obj1->name());
2222 for (TQObjectListIt it(d->containerDocks);it.current();++it)
2224 KDockContainer* dc =
dynamic_cast<KDockContainer*
>(((
KDockWidget*)it.current())->widget);
2226 dc->prepareSave(nList);
2230 TQStringList::Iterator nListIt=nList.begin();
2231 while ( nListIt!=nList.end() ) {
2233 if ((obj->isGroup && (!obj->d->isContainer)) && (nameList.find( obj->firstName.latin1() ) == -1
2234 || nameList.find(obj->lastName.latin1()) == -1)) {
2242 TQDomElement groupEl;
2243 if (obj->d->isContainer) {
2244 KDockContainer* x =
dynamic_cast<KDockContainer*
>(obj->widget);
2246 groupEl=doc.createElement(
"dockContainer");
2252 groupEl = doc.createElement(
"splitGroup");
2254 groupEl.appendChild(createStringEntry(doc,
"firstName", obj->firstName));
2255 groupEl.appendChild(createStringEntry(doc,
"secondName", obj->lastName));
2256 groupEl.appendChild(createNumberEntry(doc,
"orientation", (
int)obj->splitterOrientation));
2257 groupEl.appendChild(createNumberEntry(doc,
"separatorPos", ((
KDockSplitter*)obj->widget)->separatorPosInPercent()));
2258 }
else if (obj->isTabGroup) {
2260 groupEl = doc.createElement(
"tabGroup");
2263 for (
int i = 0; i < ((
KDockTabGroup*)obj->widget)->count(); ++i )
2264 list.append( ((
KDockTabGroup*)obj->widget)->page( i )->name() );
2265 groupEl.appendChild(createListEntry(doc,
"tabs",
"tab", list));
2266 groupEl.appendChild(createNumberEntry(doc,
"currentTab", ((
KDockTabGroup*)obj->widget)->currentPageIndex()));
2267 if (!obj->parent()) {
2269 groupEl.appendChild(createNumberEntry(doc,
"dockBackToPos", obj->
formerDockPos));
2273 groupEl = doc.createElement(
"dock");
2274 groupEl.appendChild(createStringEntry(doc,
"tabCaption", obj->
tabPageLabel()));
2275 groupEl.appendChild(createStringEntry(doc,
"tabToolTip", obj->
toolTipString()));
2276 if (!obj->parent()) {
2278 groupEl.appendChild(createNumberEntry(doc,
"dockBackToPos", obj->
formerDockPos));
2282 groupEl.appendChild(createStringEntry(doc,
"name", TQString::fromLatin1(obj->name())));
2283 groupEl.appendChild(createBoolEntry(doc,
"hasParent", obj->parent()));
2284 if ( !obj->parent() ) {
2285 groupEl.appendChild(createRectEntry(doc,
"geometry", TQRect(main->frameGeometry().topLeft(), main->size())));
2286 groupEl.appendChild(createBoolEntry(doc,
"visible", obj->isVisible()));
2288 if (obj->header && obj->header->inherits(
"KDockWidgetHeader")) {
2290 groupEl.appendChild(createBoolEntry(doc,
"dragEnabled", h->dragEnabled()));
2293 base.appendChild(groupEl);
2294 nameList.append(obj->name());
2295 nList.remove(nListIt);
2296 nListIt=nList.begin();
2299 if (main->inherits(
"KDockMainWindow")) {
2301 TQString centralWidgetStr = TQString(dmain->centralWidget()? dmain->centralWidget()->name() :
"");
2302 base.appendChild(createStringEntry(doc,
"centralWidget", centralWidgetStr));
2304 base.appendChild(createStringEntry(doc,
"mainDockWidget", mainDockWidgetStr));
2306 base.appendChild(createStringEntry(doc,
"mainWidget", mainWidgetStr));
2309 base.appendChild(createRectEntry(doc,
"geometry", TQRect(main->frameGeometry().topLeft(), main->size())));
2315 if (base.namedItem(
"group").isNull()
2316 && base.namedItem(
"tabgroup").isNull()
2317 && base.namedItem(
"dock").isNull()
2318 && base.namedItem(
"dockContainer").isNull()) {
2323 autoCreateDock =
new TQObjectList();
2324 autoCreateDock->setAutoDelete(
true );
2326 bool isMainVisible = main->isVisible();
2329 TQObjectListIt it(*childDock);
2332 if ( !obj1->isGroup && !obj1->isTabGroup ) {
2333 if ( obj1->parent() )
2342 for( TQDomNode n = base.firstChild(); !n.isNull(); n = n.nextSibling() )
2344 TQDomElement childEl = n.toElement();
2345 if (childEl.tagName() !=
"dock")
continue;
2352 if (!boolEntry(childEl,
"hasParent")) {
2353 TQRect r = rectEntry(childEl,
"geometry");
2355 obj->applyToWidget(0);
2356 obj->setGeometry(r);
2357 if (boolEntry(childEl,
"visible"))
2358 obj->TQWidget::show();
2361 if (obj && obj->header && obj->header->inherits(
"KDockWidgetHeader")) {
2363 h->setDragEnabled(boolEntry(childEl,
"dragEnabled"));
2368 for( TQDomNode n = base.firstChild(); !n.isNull(); n = n.nextSibling() )
2370 TQDomElement childEl = n.toElement();
2371 if (childEl.isNull())
continue;
2375 if (childEl.tagName() ==
"dockContainer") {
2378 kdDebug(282)<<
"dockContainer: "<<stringEntry(childEl,
"name")<<
endl;
2379 if (!(cont->d->isContainer)) {
2380 kdDebug(282)<<
"restoration of dockContainer is only supported for already existing dock containers"<<
endl;
2382 KDockContainer *dc=
dynamic_cast<KDockContainer*
>(cont->
getWidget());
2383 if (!dc)
kdDebug(282)<<
"Error while trying to handle dockcontainer configuration restoration"<<
endl;
2386 removeFromAutoCreateList(cont);
2392 if (childEl.tagName() ==
"splitGroup") {
2394 TQString name = stringEntry(childEl,
"name");
2395 TQString firstName = stringEntry(childEl,
"firstName");
2396 TQString secondName = stringEntry(childEl,
"secondName");
2397 int orientation = numberEntry(childEl,
"orientation");
2398 int separatorPos = numberEntry(childEl,
"separatorPos");
2402 if (first && second) {
2404 (orientation == (
int)TQt::Vertical)? KDockWidget::DockLeft : KDockWidget::DockTop,
2407 obj->setName(name.latin1());
2409 }
else if (childEl.tagName() ==
"tabGroup") {
2411 TQString name = stringEntry(childEl,
"name");
2412 TQStrList list = listEntry(childEl,
"tabs",
"tab");
2422 while (list.current() && obj) {
2424 obj = tabDock->
manualDock(d1, KDockWidget::DockCenter);
2428 obj->setName(name.latin1());
2429 tab->showPage(tab->page(numberEntry(childEl,
"currentTab")));
2436 if (!boolEntry(childEl,
"hasParent")) {
2437 TQRect r = rectEntry(childEl,
"geometry");
2439 obj->applyToWidget(0);
2440 obj->setGeometry(r);
2441 if (boolEntry(childEl,
"visible"))
2442 obj->TQWidget::show();
2445 if (obj && obj->header && obj->header->inherits(
"KDockWidgetHeader")) {
2447 h->setDragEnabled(boolEntry(childEl,
"dragEnabled"));
2453 for( TQDomNode n = base.firstChild(); !n.isNull(); n = n.nextSibling() )
2455 TQDomElement childEl = n.toElement();
2457 if (childEl.tagName() !=
"dock" && childEl.tagName() !=
"tabGroup")
2462 if (!boolEntry(childEl,
"hasParent")) {
2465 TQString name = stringEntry(childEl,
"dockBackTo");
2466 if (!name.isEmpty()) {
2474 if (main->inherits(
"KDockMainWindow")) {
2477 TQString mv = stringEntry(base,
"centralWidget");
2480 mvd->applyToWidget(dmain);
2482 dmain->setCentralWidget(mvd);
2484 TQString md = stringEntry(base,
"mainDockWidget");
2490 TQString mv = stringEntry(base,
"mainWidget");
2493 mvd->applyToWidget(main);
2498 TQRect mr = rectEntry(base,
"geometry");
2499 main->move(mr.topLeft());
2500 main->resize(mr.size());
2506 if (d->m_readDockConfigMode == WrapExistingWidgetsOnly) {
2507 finishReadDockConfig();
2511 void KDockManager::removeFromAutoCreateList(
KDockWidget* pDockWidget)
2513 if (!autoCreateDock)
return;
2514 autoCreateDock->setAutoDelete(
false);
2515 autoCreateDock->removeRef(pDockWidget);
2516 autoCreateDock->setAutoDelete(
true);
2519 void KDockManager::finishReadDockConfig()
2521 delete autoCreateDock;
2525 void KDockManager::setReadDockConfigMode(
int mode)
2527 d->m_readDockConfigMode = mode;
2535 if ( group.isEmpty() ) group =
"dock_setting_default";
2538 c->
writeEntry(
"Version", DOCK_CONFIG_VERSION );
2540 TQStringList nameList;
2541 TQStringList findList;
2542 TQObjectListIt it( *childDock );
2550 nList.append( obj->name() );
2551 if ( obj->parent() == main )
2556 for (TQObjectListIt it(d->containerDocks);it.current();++it)
2558 KDockContainer* dc =
dynamic_cast<KDockContainer*
>(((
KDockWidget*)it.current())->widget);
2560 dc->prepareSave(nList);
2565 TQStringList::Iterator nListIt=nList.begin();
2566 while ( nListIt!=nList.end() ){
2569 TQString cname = obj->name();
2573 if (obj->d->isContainer) {
2574 KDockContainer* x =
dynamic_cast<KDockContainer*
>(obj->widget);
2580 if ( obj->isGroup ){
2581 if ( (findList.find( obj->firstName ) != findList.end()) && (findList.find( obj->lastName ) != findList.end() )){
2584 if ( !obj->parent() ){
2585 c->
writeEntry( cname+
":parent",
"___null___");
2586 c->
writeEntry( cname+
":geometry", TQRect(obj->frameGeometry().topLeft(), obj->size()) );
2587 c->
writeEntry( cname+
":visible", obj->isVisible());
2591 c->
writeEntry( cname+
":first_name", obj->firstName );
2592 c->
writeEntry( cname+
":last_name", obj->lastName );
2593 c->
writeEntry( cname+
":orientation", (
int)obj->splitterOrientation );
2596 nameList.append( obj->name() );
2597 findList.append( obj->name() );
2599 nList.remove(nListIt);
2600 nListIt=nList.begin();
2610 if (nListIt==nList.end()) nListIt=nList.begin();
2614 if ( obj->isTabGroup){
2616 if ( !obj->parent() ){
2617 c->
writeEntry( cname+
":parent",
"___null___");
2618 c->
writeEntry( cname+
":geometry", TQRect(obj->frameGeometry().topLeft(), obj->size()) );
2619 c->
writeEntry( cname+
":visible", obj->isVisible());
2626 for (
int i = 0; i < ((
KDockTabGroup*)obj->widget)->count(); ++i )
2627 list.append( ((
KDockTabGroup*)obj->widget)->page( i )->name() );
2631 nameList.append( obj->name() );
2632 findList.append( obj->name() );
2634 nList.remove(nListIt);
2635 nListIt=nList.begin();
2640 if ( !obj->parent() ){
2642 c->
writeEntry( cname+
":geometry", TQRect(obj->frameGeometry().topLeft(), obj->size()) );
2643 c->
writeEntry( cname+
":visible", obj->isVisible());
2649 nameList.append( cname.latin1() );
2651 findList.append( obj->name() );
2652 nList.remove(nListIt);
2653 nListIt=nList.begin();
2659 c->
writeEntry(
"Main:Geometry", TQRect(main->frameGeometry().topLeft(), main->size()) );
2660 c->
writeEntry(
"Main:visible", main->isVisible());
2662 if ( main->inherits(
"KDockMainWindow") ){
2665 c->
writeEntry(
"Main:view", dmain->centralWidget() ? dmain->centralWidget()->name():
"" );
2672 #include <tqmessagebox.h>
2676 if ( group.isEmpty() ) group =
"dock_setting_default";
2681 TQString ver = c->
readEntry(
"Version",
"0.0.1" );
2683 if ( !nameList.current() || ver != DOCK_CONFIG_VERSION ){
2688 autoCreateDock =
new TQObjectList();
2689 autoCreateDock->setAutoDelete(
true );
2691 bool isMainVisible = main->isVisible();
2696 TQObjectListIt it( *childDock );
2701 if ( !obj->isGroup && !obj->isTabGroup )
2703 if ( obj->parent() ) obj->
undock();
else obj->hide();
2710 while ( nameList.current() ){
2711 TQString oname = nameList.current();
2713 TQString type = c->
readEntry( oname +
":type" );
2716 if ( type ==
"NULL_DOCK" || c->
readEntry( oname +
":parent") ==
"___null___" ){
2719 obj->applyToWidget( 0L );
2720 obj->setGeometry(r);
2726 obj->TQWidget::show();
2730 if ( type ==
"DOCK" ){
2736 if (obj && obj->d->isContainer) {
2737 dynamic_cast<KDockContainer*
>(obj->widget)->load(c,group);
2738 removeFromAutoCreateList(obj);
2740 if ( obj && obj->header){
2748 while ( nameList.current() ){
2749 TQString oname = nameList.current();
2751 TQString type = c->
readEntry( oname +
":type" );
2754 if ( type ==
"GROUP" ){
2759 Orientation p = (Orientation)c->
readNumEntry( oname +
":orientation" );
2760 if ( first && last ){
2761 obj = first->
manualDock( last, ( p == TQt::Vertical ) ? KDockWidget::DockLeft : KDockWidget::DockTop, sepPos );
2763 obj->setName( oname.latin1() );
2768 if ( type ==
"TAB_GROUP" ){
2775 tabDockGroup = d2->
manualDock( d1, KDockWidget::DockCenter );
2776 if ( tabDockGroup ){
2779 while ( list.current() && tabDockGroup ){
2781 tabDockGroup = tabDock->
manualDock( d1, KDockWidget::DockCenter );
2784 if ( tabDockGroup ){
2785 tabDockGroup->setName( oname.latin1() );
2788 tab->showPage( tab->page( c->
readNumEntry( oname+
":curTab" ) ) );
2794 if (obj && obj->d->isContainer)
dynamic_cast<KDockContainer*
>(obj->widget)->load(c,group);
2795 if ( obj && obj->header){
2804 while ( nameList.current() ){
2805 TQString oname = nameList.current();
2807 TQString type = c->
readEntry( oname +
":type" );
2810 if ( type ==
"NULL_DOCK" || c->
readEntry( oname +
":parent") ==
"___null___" ){
2813 TQString name = c->
readEntry( oname +
":dockBackTo" );
2814 if (!name.isEmpty()) {
2823 if ( main->inherits(
"KDockMainWindow") ){
2827 TQString mv = c->
readEntry(
"Main:view" );
2830 mvd->applyToWidget( dmain );
2835 TQString md = c->
readEntry(
"Main:dock" );
2842 TQString mv = c->
readEntry(
"Main:view" );
2845 mvd->applyToWidget( main );
2852 if (d->m_readDockConfigMode == WrapExistingWidgetsOnly) {
2853 finishReadDockConfig();
2860 if (!main->inherits(
"KDockMainWindow"))
2861 main->move(mr.topLeft());
2863 main->resize(mr.size());
2865 if ( isMainVisible ) main->show();
2870 void KDockManager::dumpDockWidgets() {
2871 TQObjectListIt it( *childDock );
2875 kdDebug(282)<<
"KDockManager::dumpDockWidgets:"<<obj->name()<<
endl;
2882 TQObjectListIt it( *childDock );
2886 if ( TQString(obj->name()) == dockName )
return obj;
2890 if ( autoCreateDock ){
2891 kdDebug(282)<<
"Autocreating dock: "<<dockName<<
endl;
2892 autoCreate =
new KDockWidget(
this, dockName.latin1(), TQPixmap(TQString(
"")) );
2893 autoCreateDock->append( autoCreate );
2899 d->splitterOpaqueResize = b;
2904 return d->splitterOpaqueResize;
2909 d->splitterKeepSize = b;
2914 return d->splitterKeepSize;
2919 d->splitterHighResolution = b;
2924 return d->splitterHighResolution;
2927 void KDockManager::slotMenuPopup()
2932 TQObjectListIt it( *childDock );
2939 menu->insertItem( obj->icon() ? *(obj->icon()) : TQPixmap(), TQString(i18n(
"Hide %1").arg(obj->caption())), numerator++ );
2940 menuData->append(
new MenuDockData( obj,
true ) );
2945 menu->insertItem( obj->icon() ? *(obj->icon()) : TQPixmap(), TQString(i18n(
"Show %1").arg(obj->caption())), numerator++ );
2946 menuData->append(
new MenuDockData( obj,
false ) );
2951 void KDockManager::slotMenuActivated(
int id )
2953 MenuDockData* data = menuData->at(
id );
2954 data->dock->changeHideShowState();
2959 TQObjectListIt it( *childDock );
2965 if ( dock->widget == w ){ found = dock;
break; }
2970 void KDockManager::drawDragRectangle()
2972 #ifdef BORDERLESS_WINDOWS
2975 if (d->oldDragRect == d->dragRect)
2979 TQRect oldAndNewDragRect[2];
2980 oldAndNewDragRect[0] = d->oldDragRect;
2981 oldAndNewDragRect[1] = d->dragRect;
2984 for (i = 0; i <= 1; i++) {
2985 if (oldAndNewDragRect[i].isEmpty())
2988 KDockWidget* pDockWdgAtRect = (
KDockWidget*) TQApplication::widgetAt( oldAndNewDragRect[i].topLeft(), true );
2989 if (!pDockWdgAtRect)
2992 bool isOverMainWdg =
false;
2997 if (pDockWdgAtRect->topLevelWidget() == main) {
2998 isOverMainWdg =
true;
3000 unclipped = pMain->testWFlags( WPaintUnclipped );
3001 pMain->setWFlags( WPaintUnclipped );
3004 topWdg = pTLDockWdg = (
KDockWidget*) pDockWdgAtRect->topLevelWidget();
3005 unclipped = pTLDockWdg->testWFlags( WPaintUnclipped );
3006 pTLDockWdg->setWFlags( WPaintUnclipped );
3014 pMain->clearWFlags(WPaintUnclipped);
3016 pTLDockWdg->clearWFlags(WPaintUnclipped);
3019 p.setRasterOp(TQt::NotXorROP);
3020 TQRect r = oldAndNewDragRect[i];
3021 r.moveTopLeft( r.topLeft() - topWdg->mapToGlobal(TQPoint(0,0)) );
3022 p.drawRect(r.x(), r.y(), r.width(), r.height());
3027 d->oldDragRect = d->dragRect;
3031 d->leftContainer=container;
3034 void KDockManager::setSpecialTopDockContainer(
KDockWidget* container) {
3035 d->topContainer=container;
3038 void KDockManager::setSpecialRightDockContainer(
KDockWidget* container) {
3039 d->rightContainer=container;
3043 void KDockManager::setSpecialBottomDockContainer(
KDockWidget* container) {
3044 d->bottomContainer=container;
3048 KDockArea::KDockArea( TQWidget* parent,
const char *name)
3049 :TQWidget( parent,
name)
3051 TQString new_name = TQString(name) + TQString(
"_DockManager");
3052 dockManager =
new KDockManager(
this, new_name.latin1() );
3053 mainDockWidget = 0L;
3056 KDockArea::~KDockArea()
3061 KDockWidget* KDockArea::createDockWidget(
const TQString& name,
const TQPixmap &pixmap, TQWidget* parent,
const TQString& strCaption,
const TQString& strTabPageLabel)
3063 return new KDockWidget( dockManager,
name.latin1(), pixmap, parent, strCaption, strTabPageLabel );
3066 void KDockArea::makeDockVisible(
KDockWidget* dock )
3072 void KDockArea::makeDockInvisible(
KDockWidget* dock )
3078 void KDockArea::makeWidgetDockVisible( TQWidget* widget )
3083 void KDockArea::writeDockConfig(TQDomElement &base)
3088 void KDockArea::readDockConfig(TQDomElement &base)
3093 void KDockArea::slotDockWidgetUndocked()
3095 TQObject* pSender = (TQObject*) sender();
3096 if (!pSender->inherits(
"KDockWidget"))
return;
3098 emit dockWidgetHasUndocked( pDW);
3101 void KDockArea::resizeEvent(TQResizeEvent *rsize)
3103 TQWidget::resizeEvent(rsize);
3104 if (!childrenListObject().isEmpty()){
3108 TQObjectList *list=queryList(
"TQWidget",0,
false);
3110 TQObjectListIt it( *list );
3113 while ( (obj = it.current()) != 0 ) {
3115 ((TQWidget*)obj)->setGeometry(TQRect(TQPoint(0,0),size()));
3125 TQObject *obj=children()->
getFirst();
3128 split->setGeometry( TQRect(TQPoint(0,0), size() ));
3137 void KDockArea::writeDockConfig(
TDEConfig* c, TQString group )
3142 void KDockArea::readDockConfig(
TDEConfig* c, TQString group )
3147 void KDockArea::setMainDockWidget(
KDockWidget* mdw )
3149 if ( mainDockWidget == mdw )
return;
3150 mainDockWidget = mdw;
3151 mdw->applyToWidget(
this);
3158 KDockContainer::KDockContainer(){m_overlapMode=
false; m_childrenListBegin=0; m_childrenListEnd=0;}
3159 KDockContainer::~KDockContainer(){
3161 if (m_childrenListBegin)
3163 struct ListItem *tmp=m_childrenListBegin;
3166 struct ListItem *tmp2=tmp->next;
3171 m_childrenListBegin=0;
3172 m_childrenListEnd=0;
3177 void KDockContainer::activateOverlapMode(
int nonOverlapSize) {
3178 m_nonOverlapSize=nonOverlapSize;
3180 if (parentDockWidget() && parentDockWidget()->parent()) {
3181 kdDebug(282)<<
"KDockContainer::activateOverlapMode: recalculating sizes"<<
endl;
3182 KDockSplitter *sp= ::tqt_cast<KDockSplitter*>(parentDockWidget()->
3189 void KDockContainer::deactivateOverlapMode() {
3190 if (!m_overlapMode)
return;
3191 m_overlapMode=
false;
3192 if (parentDockWidget() && parentDockWidget()->parent()) {
3193 kdDebug(282)<<
"KDockContainer::deactivateOverlapMode: recalculating sizes"<<
endl;
3194 KDockSplitter *sp= ::tqt_cast<KDockSplitter*>(parentDockWidget()->
3201 bool KDockContainer::isOverlapMode() {
3202 return m_overlapMode;
3206 bool KDockContainer::dockDragEnter(
KDockWidget*, TQMouseEvent *) {
return false;}
3207 bool KDockContainer::dockDragMove(
KDockWidget*, TQMouseEvent *) {
return false;}
3208 bool KDockContainer::dockDragLeave(
KDockWidget*, TQMouseEvent *) {
return false;}
3211 KDockWidget *KDockContainer::parentDockWidget(){
return 0;}
3213 TQStringList KDockContainer::containedWidgets()
const {
3215 for (
struct ListItem *it=m_childrenListBegin;it;it=it->next) {
3216 tmp<<TQString(it->data);
3225 void KDockContainer::insertWidget (
KDockWidget *dw, TQPixmap,
const TQString &,
int &)
3227 struct ListItem *it=
new struct ListItem;
3228 it->data=strdup(dw->name());
3231 if (m_childrenListEnd)
3233 m_childrenListEnd->next=it;
3234 it->prev=m_childrenListEnd;
3235 m_childrenListEnd=it;
3240 m_childrenListEnd=it;
3241 m_childrenListBegin=it;
3244 void KDockContainer::removeWidget (
KDockWidget *dw){
3245 for (
struct ListItem *tmp=m_childrenListBegin;tmp;tmp=tmp->next)
3247 if (!strcmp(tmp->data,dw->name()))
3250 if (tmp->next) tmp->next->prev=tmp->prev;
3251 if (tmp->prev) tmp->prev->next=tmp->next;
3252 if (tmp==m_childrenListBegin) m_childrenListBegin=tmp->next;
3253 if (tmp==m_childrenListEnd) m_childrenListEnd=tmp->prev;
3261 void KDockContainer::undockWidget (
KDockWidget *){;}
3262 void KDockContainer::setToolTip(
KDockWidget *, TQString &){;}
3263 void KDockContainer::setPixmap(
KDockWidget*,
const TQPixmap&){;}
3264 void KDockContainer::load (
TDEConfig*,
const TQString&){;}
3265 void KDockContainer::save (
TDEConfig*,
const TQString&){;}
3266 void KDockContainer::load (TQDomElement&){;}
3267 void KDockContainer::save (TQDomElement&){;}
3268 void KDockContainer::prepareSave(TQStringList &names)
3271 for (
struct ListItem *tmp=m_childrenListBegin;tmp; tmp=tmp->next)
3272 names.remove(tmp->data);
3280 TQWidget *KDockTabGroup::transientTo() {
3282 for (
int i=0;i<count();i++) {
3283 KDockWidget *dw=::tqt_cast<KDockWidget*>(page(i));
3289 kdDebug(282)<<
"KDockTabGroup::transientTo: widget mismatch"<<
endl;
3296 kdDebug(282)<<
"KDockTabGroup::transientTo: "<<(tT?
"YES":
"NO")<<
endl;
3301 void KDockWidgetAbstractHeader::virtual_hook(
int,
void* )
3304 void KDockWidgetAbstractHeaderDrag::virtual_hook(
int,
void* )
3307 void KDockWidgetHeaderDrag::virtual_hook(
int id,
void* data )
3308 { KDockWidgetAbstractHeaderDrag::virtual_hook(
id, data ); }
3310 void KDockWidgetHeader::virtual_hook(
int id,
void* data )
3311 { KDockWidgetAbstractHeader::virtual_hook(
id, data ); }
3313 void KDockTabGroup::virtual_hook(
int,
void* )
3316 void KDockWidget::virtual_hook(
int,
void* )
3319 void KDockManager::virtual_hook(
int,
void* )
3322 void KDockMainWindow::virtual_hook(
int id,
void* data )
3323 { TDEMainWindow::virtual_hook(
id, data ); }
3325 void KDockArea::virtual_hook(
int,
void* )
3329 #ifndef NO_INCLUDE_MOCFILES
3330 #include "kdockwidget.moc"
A special kind of TDEMainWindow that is able to have dockwidget child widgets (and member of the dock...
KDockWidget * getMainDockWidget() const
Returns the main dockwidget.
void readDockConfig(TQDomElement &base)
Reads the current dock window layout from a DOM tree below the given element.
void writeDockConfig(TQDomElement &base)
Saves the current dock window layout into a DOM tree below the given element.
KDockWidget * createDockWidget(const TQString &name, const TQPixmap &pixmap, TQWidget *parent=0L, const TQString &strCaption=TQString::null, const TQString &strTabPageLabel=TQString::fromLatin1(" "))
This is one of the most important methods! The KDockMainWindow creates a new dockwidget object here t...
void makeWidgetDockVisible(TQWidget *widget)
This is an overloaded member function, provided for convenience.
void makeDockInvisible(KDockWidget *dock)
This method hides the given dockwidget.
KDockMainWindow(TQWidget *parent=0L, const char *name=0L, WFlags f=(WFlags)(WType_TopLevel|WDestructiveClose))
Constructs a dockmainwindow.
void setMainDockWidget(KDockWidget *dockwidget)
Sets a new main dockwidget.
virtual ~KDockMainWindow()
Destructs a dockmainwindow.
KDockManager * dockManager
A pointer to the manager for the dock process.
void slotDockWidgetUndocked()
Called whenever one of the dockwidgets of this has been undocked.
KDockWidget * mainDockWidget
A pointer to the main dockwidget (where one can manualDock() to.
void dockWidgetHasUndocked(KDockWidget *)
Signals a certain dockwidget is undocked now.
void makeDockVisible(KDockWidget *dock)
This method shows the given dockwidget.
void setView(TQWidget *widget)
This method calls the base class method.
The manager that knows all dockwidgets and handles the dock process (and member of the dockwidget cla...
KDockWidget * getDockWidgetFromName(const TQString &dockName)
void setSplitterKeepSize(bool b=true)
Try to preserve the widget's size.
bool splitterKeepSize() const
Returns true if the KeepSize is enabled, false otherwise.
KDockWidget * findWidgetParentDock(TQWidget *w) const
This method finds out what a widgets' dockwidget is.
void setSplitterHighResolution(bool b=true)
Operate the splitter with a higher resolution.
virtual ~KDockManager()
Destructs a dockmanager.
void writeConfig(TDEConfig *c=0L, TQString group=TQString::null)
Saves the current state of the dockmanager and of all controlled widgets.
bool splitterHighResolution() const
Returns true if the splitter uses the high resolution, false otherwise.
virtual bool eventFilter(TQObject *object, TQEvent *event)
It's more or less a method that catches several events which are interesting for the dockmanager.
void replaceDock(KDockWidget *oldDock, KDockWidget *newDock)
Signals a dockwidget is replaced with another one.
void setDockDefaultPos(KDockWidget *)
Signals a dockwidget without parent (toplevel) is shown.
KDockManager(TQWidget *mainWindow, const char *name=0L)
Constructs a dockmanager.
void change()
Signals changes of the docking state of a dockwidget.
void activate()
Shows all encapsulated widgets of all controlled dockwidgets and shows all dockwidgets which are pare...
void readConfig(TDEConfig *c=0L, TQString group=TQString::null)
Like writeConfig but reads the whole stuff in.
void setSplitterOpaqueResize(bool b=true)
Enables opaque resizing.
void setMainDockWidget2(KDockWidget *)
bool splitterOpaqueResize() const
Returns true if opaque resizing is enabled, false otherwise.
void setSpecialLeftDockContainer(KDockWidget *container)
Like TQSplitter but specially designed for dockwidgets stuff.
void deactivate()
Disables the splitter.
TQWidget * getAnother(TQWidget *w) const
If w is child0, return child1, otherwise child0.
TQWidget * getFirst() const
void setOpaqueResize(bool b=true)
Set opaque flag.
void activate(TQWidget *c0, TQWidget *c1=0L)
Initialize the splitter.
int separatorPosInPercent()
Return the separator position in percent (%), so the range is [0..100].
void setKeepSize(bool b=true)
If b is true, the splitter will keep its size on resize events.
virtual void resizeEvent(TQResizeEvent *ev)
The resize event resizes child0, child1 and the divider.
It just hides the special implementation of a dockwidget tab groups (and is member of the dockwidget ...
static void setType(WId win, NET::WindowType windowType)
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
int readNumEntry(const TQString &pKey, int nDefault=0) const
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
TQRect readRectEntry(const TQString &pKey, const TQRect *pDefault=0L) const
int readListEntry(const TQString &pKey, TQStrList &list, char sep=',') const
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
void setGroup(const TQString &group)
static bool opaqueResize()
static TDEConfig * config()
KDE top level main window
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)
TQString name(StdAccel id)