summaryrefslogtreecommitdiffstats
path: root/tdemdi/tdemdi
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:21 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:21 -0600
commitdfe289850f068f19ba4a83ab4e7e22a7e09c13c9 (patch)
treec297348a55df66c571de4525646e0b9762427353 /tdemdi/tdemdi
parentb7658a0d5eca24a9d37c6e04f88298ef02389db0 (diff)
downloadtdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.tar.gz
tdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdemdi/tdemdi')
-rw-r--r--tdemdi/tdemdi/CMakeLists.txt52
-rw-r--r--tdemdi/tdemdi/Makefile.am14
-rw-r--r--tdemdi/tdemdi/dockcontainer.cpp656
-rw-r--r--tdemdi/tdemdi/dockcontainer.h144
-rw-r--r--tdemdi/tdemdi/global.h69
-rw-r--r--tdemdi/tdemdi/guiclient.cpp230
-rw-r--r--tdemdi/tdemdi/guiclient.h103
-rw-r--r--tdemdi/tdemdi/mainwindow.cpp451
-rw-r--r--tdemdi/tdemdi/mainwindow.h199
-rw-r--r--tdemdi/tdemdi/tabwidget.cpp284
-rw-r--r--tdemdi/tdemdi/tabwidget.h115
-rw-r--r--tdemdi/tdemdi/toolviewaccessor.cpp223
-rw-r--r--tdemdi/tdemdi/toolviewaccessor.h88
-rw-r--r--tdemdi/tdemdi/toolviewaccessor_p.h60
14 files changed, 2688 insertions, 0 deletions
diff --git a/tdemdi/tdemdi/CMakeLists.txt b/tdemdi/tdemdi/CMakeLists.txt
new file mode 100644
index 000000000..7f2b3c7ad
--- /dev/null
+++ b/tdemdi/tdemdi/CMakeLists.txt
@@ -0,0 +1,52 @@
+#################################################
+#
+# (C) 2010 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${TQT_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_BINARY_DIR}/tdecore
+ ${CMAKE_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}/tdemdi
+ ${CMAKE_SOURCE_DIR}/tdecore
+ ${CMAKE_SOURCE_DIR}/tdefx
+ ${CMAKE_SOURCE_DIR}/tdeui
+ ${CMAKE_SOURCE_DIR}/tdeutils
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### headers ###################################
+
+install( FILES
+ global.h mainwindow.h toolviewaccessor.h tabwidget.h
+ DESTINATION ${INCLUDE_INSTALL_DIR}/tdemdi )
+
+
+#### tdemdi2 ######################################
+
+set( target tdemdi2 )
+
+set( ${target}_SRCS
+ mainwindow.cpp dockcontainer.cpp toolviewaccessor.cpp
+ guiclient.cpp tabwidget.cpp
+)
+
+tde_add_library( ${target} SHARED AUTOMOC
+ SOURCES ${${target}_SRCS}
+ VERSION 1.0.0
+ LINK tdeutils-shared
+ DESTINATION ${LIB_INSTALL_DIR}
+)
diff --git a/tdemdi/tdemdi/Makefile.am b/tdemdi/tdemdi/Makefile.am
new file mode 100644
index 000000000..82abae6e6
--- /dev/null
+++ b/tdemdi/tdemdi/Makefile.am
@@ -0,0 +1,14 @@
+INCLUDES = -I$(top_srcdir)/tdeutils -I$(top_srcdir) -I$(top_srcdir)/tdemdi $(all_includes)
+
+lib_LTLIBRARIES = libtdemdi2.la
+libtdemdi2_la_LDFLAGS = $(all_libraries) -version-info 1:0
+libtdemdi2_la_LIBADD = $(LIB_KPARTS) $(top_builddir)/tdeutils/libtdeutils.la $(LIB_TDEUI) $(LIB_QT) $(LIB_TDECORE)
+
+libtdemdi2_la_SOURCES = mainwindow.cpp dockcontainer.cpp toolviewaccessor.cpp guiclient.cpp tabwidget.cpp
+
+tdemdiincludedir = $(includedir)/tdemdi
+tdemdiinclude_HEADERS = global.h mainwindow.h toolviewaccessor.h tabwidget.h
+
+METASOURCES = AUTO
+
+include ../../admin/Doxyfile.am
diff --git a/tdemdi/tdemdi/dockcontainer.cpp b/tdemdi/tdemdi/dockcontainer.cpp
new file mode 100644
index 000000000..5dfe82d64
--- /dev/null
+++ b/tdemdi/tdemdi/dockcontainer.cpp
@@ -0,0 +1,656 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002, 2003 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2002, 2004 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "mainwindow.h"
+#include "dockcontainer.h"
+
+#include "dockcontainer.moc"
+
+#include "kdockwidget_private.h"
+
+#include <tqwidgetstack.h>
+#include <tqlayout.h>
+#include <tqtimer.h>
+#include <tqtooltip.h>
+#include <tdemultitabbar.h>
+#include <kglobalsettings.h>
+
+#include <kdebug.h>
+#include <kiconloader.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include <klocale.h>
+
+//TODO: Well, this is already defined in tdeui/kdockwidget.cpp
+static const char* const tdemdi_not_close_xpm[]={
+"5 5 2 1",
+"# c black",
+". c None",
+"#####",
+"#...#",
+"#...#",
+"#...#",
+"#####"};
+
+namespace KMDI
+{
+
+
+DockContainer::DockContainer(TQWidget *parent, TQWidget *win, int position, int flags)
+: TQWidget(parent),KDockContainer()
+{
+ m_tabSwitching = false;
+ m_block=false;
+ m_inserted=-1;
+ m_mainWin = win;
+ oldtab=-1;
+ mTabCnt=0;
+ m_position = position;
+ m_previousTab=-1;
+ m_separatorPos = 18000;
+ m_movingState=NotMoving;
+ m_startEvent=0;
+ kdDebug(760)<<"DockContainer created"<<endl;
+
+ TQBoxLayout *l;
+ m_vertical=!((position==KDockWidget::DockTop) || (position==KDockWidget::DockBottom));
+
+ if (!m_vertical)
+ l=new TQVBoxLayout(this);
+ else
+ l=new TQHBoxLayout(this);
+
+ l->setAutoAdd(false);
+
+ m_tb=new KMultiTabBar(((position==KDockWidget::DockTop) || (position==KDockWidget::DockBottom))?
+ KMultiTabBar::Horizontal:KMultiTabBar::Vertical,this);
+
+ m_tb->setStyle(KMultiTabBar::KMultiTabBarStyle(flags));
+ m_tb->showActiveTabTexts(true);
+
+ m_tb->setPosition((position==KDockWidget::DockLeft)?KMultiTabBar::Left:
+ (position==KDockWidget::DockBottom)?KMultiTabBar::Bottom:
+ (position==KDockWidget::DockTop)?KMultiTabBar::Top:KMultiTabBar::Right);
+
+ m_ws=new TQWidgetStack(this);
+
+ m_ws->setSizePolicy(TQSizePolicy(TQSizePolicy::Expanding,TQSizePolicy::Expanding));
+
+ if ( (position==KDockWidget::DockLeft) || (position==KDockWidget::DockTop))
+ {
+ l->add(m_tb);
+ l->add(m_ws);
+ }
+ else
+ {
+ l->add(m_ws);
+ l->add(m_tb);
+ }
+
+ l->activate();
+ m_ws->hide();
+ m_tb->installEventFilter(this);
+}
+
+void DockContainer::setStyle(int style) {
+ if (m_tb) m_tb->setStyle(KMultiTabBar::KMultiTabBarStyle(style));
+}
+
+DockContainer::~DockContainer()
+{
+ TQMap<KDockWidget*,int>::iterator it;
+ while (m_map.count()) {
+ it = m_map.begin();
+ KDockWidget *w=it.key();
+ if (m_overlapButtons.contains(w)) {
+ (::tqqt_cast<KDockWidgetHeader*>(w->getHeader()))->removeButton(m_overlapButtons[w]);
+ m_overlapButtons.remove(w);
+ }
+ m_map.remove(w);
+ w->undock();
+ }
+ deactivated(this);
+}
+
+
+void DockContainer::init()
+{
+ bool overlap = isOverlapMode();
+ if (m_vertical)
+ {
+ parentDockWidget()->setForcedFixedWidth(m_tb->width());
+ activateOverlapMode(m_tb->width());
+ }
+ else
+ {
+ parentDockWidget()->setForcedFixedHeight(m_tb->height());
+ activateOverlapMode(m_tb->height());
+ }
+
+ if (!overlap) deactivateOverlapMode();
+
+ // try to restore splitter size
+ if ( parentDockWidget() && parentDockWidget()->parent() )
+ {
+ KDockSplitter *sp= ::tqqt_cast<KDockSplitter*>(parentDockWidget()->
+ parent());
+ if ( sp )
+ sp->setSeparatorPosX( m_separatorPos );
+ }
+}
+
+KDockWidget *DockContainer::parentDockWidget()
+{
+ return ((KDockWidget*)parent());
+}
+
+void DockContainer::insertWidget (KDockWidget *dwdg, TQPixmap pixmap, const TQString &text, int &)
+{
+ KDockWidget* w = (KDockWidget*) dwdg;
+ int tab;
+ bool alreadyThere=m_map.contains(w);
+
+ if (alreadyThere)
+ {
+ tab=m_map[w];
+ if (m_ws->addWidget(w,tab)!=tab) kdDebug(760)<<"ERROR COULDN'T READD WIDGET************"<<endl;
+ kdDebug(760)<<"READDED WIDGET***********************************"<<endl;
+/*JOWENN m_tb->setTab(tab,true);
+ tabClicked(tab);*/
+ }
+ else
+ {
+ tab=m_ws->addWidget(w);
+ m_map.insert(w,tab);
+ m_revMap.insert(tab,w);
+
+
+ if (((KDockWidget*)parentWidget())->mayBeShow())
+ ((KDockWidget*)parentWidget())->dockBack();
+
+ if (::tqqt_cast<KDockWidgetHeader*>(w->getHeader()))
+ {
+ kdDebug(760)<<"*** KDockWidgetHeader has been found"<<endl;
+
+ KDockWidgetHeader *hdr=::tqqt_cast<KDockWidgetHeader*>(w->getHeader());
+
+ KDockButton_Private *btn = new KDockButton_Private( hdr, "OverlapButton" );
+
+ TQToolTip::add( btn, i18n("Switch between overlap and side by side mode", "Overlap") );
+
+ btn->setToggleButton( true );
+ btn->setPixmap( const_cast< const char** >(tdemdi_not_close_xpm) );
+ hdr->addButton(btn);
+ m_overlapButtons.insert(w,btn);
+ btn->setOn(!isOverlapMode());
+
+ connect(btn,TQT_SIGNAL(clicked()),this,TQT_SLOT(changeOverlapMode()));
+ }
+
+ m_tb->appendTab(pixmap.isNull()?SmallIcon("misc"):pixmap,tab,w->tabPageLabel());
+ m_tb->tab(tab)->installEventFilter( this );
+ kdDebug(760)<<"NAMENAMENAMENAME:===========================:"<<w->tabPageLabel()<<endl;
+
+//FB m_tb->setTab(tab,true);
+
+ connect(m_tb->tab(tab),TQT_SIGNAL(clicked(int)),this,TQT_SLOT(tabClicked(int)));
+
+ kdDebug(760)<<"DockContainer::insertWidget()"<<endl;
+
+//FB m_tb->setTab(oldtab,false);
+
+ mTabCnt++;
+ m_inserted=tab;
+ int dummy=0;
+//FB tabClicked(tab);
+ KDockContainer::insertWidget(w,pixmap,text,dummy);
+ itemNames.append(w->name());
+ tabCaptions.insert(w->name(),w->tabPageLabel());
+ tabTooltips.insert(w->name(),w->toolTipString());
+
+
+ }
+
+//FB m_ws->raiseWidget(tab);
+}
+
+
+bool DockContainer::eventFilter( TQObject *obj, TQEvent *event )
+{
+ if (TQT_BASE_OBJECT(obj)==TQT_BASE_OBJECT(m_tb)) {
+ if ( (event->type()==TQEvent::Resize) && (m_ws->isHidden()) ) {
+ TQSize size=((TQResizeEvent*)event)->size();
+ if (m_vertical)
+ parentDockWidget()->setForcedFixedWidth(size.width());
+ else
+ parentDockWidget()->setForcedFixedHeight(size.height());
+ }
+ }
+ else
+ switch ( event->type() ){
+ case TQEvent::MouseButtonPress:
+ {
+ KDockWidget * w=m_revMap[tqt_dynamic_cast<KMultiTabBarTab*>(obj)->id()];
+ if (!w) {
+ kdDebug()<<"NoWidget"<<endl;
+ break;
+ }
+ if (!w->getHeader()) {
+ kdDebug()<<"NO HEADER"<<endl;
+ break;
+ }
+ KDockWidgetHeader *hdr=::tqqt_cast<KDockWidgetHeader*>(w->getHeader());
+ if (!hdr) {
+ kdDebug()<<"Wrong header type in DockContainer::eventFilter"<<endl;
+ break;
+ }
+ m_dockManager=w->dockManager();
+ m_dragPanel=TQT_TQOBJECT(hdr->dragPanel());
+ if (m_dragPanel) m_movingState=WaitingForMoveStart;
+ delete m_startEvent;
+ m_startEvent=new TQMouseEvent(* ((TQMouseEvent*)event));
+ }
+ break;
+ case TQEvent::MouseButtonRelease:
+ if (m_movingState==Moving) {
+ m_movingState=NotMoving;
+ TQApplication::postEvent(m_dragPanel,new TQMouseEvent(* ( (TQMouseEvent*)event)));
+ delete m_startEvent;
+ m_startEvent=0;
+ }
+ break;
+ case TQEvent::MouseMove:
+ if (m_movingState==WaitingForMoveStart) {
+ TQPoint p( ((TQMouseEvent*)event)->pos() - m_startEvent->pos() );
+ if( p.manhattanLength() > TDEGlobalSettings::dndEventDelay()) {
+ m_dockManager->eventFilter(m_dragPanel,TQT_TQEVENT(m_startEvent));
+ m_dockManager->eventFilter(m_dragPanel,event);
+ m_movingState=Moving;
+ }
+ } else if (m_movingState==Moving) {
+ m_dockManager->eventFilter(m_dragPanel,event);
+ }
+ break;
+ default:
+ break;
+
+ }
+ return false;
+
+}
+
+void DockContainer::showWidget(KDockWidget *w) {
+ if (!m_map.contains(w)) return;
+
+ kdDebug()<<"KMDI::DockContainer::<showWidget"<<endl;
+ int id=m_map[w];
+ m_tb->setTab(id,true);
+ tabClicked(id);
+
+}
+
+void DockContainer::changeOverlapMode()
+{
+ const KDockButton_Private *btn=tqt_dynamic_cast<const KDockButton_Private*>(sender());
+
+ kdDebug(760)<<"DockContainer::changeOverlapMode: button=="<<btn<<endl;
+
+ if (!btn) return;
+
+ if (!btn->isOn()) {
+ kdDebug(760)<<"DockContainer::changeOverlapMode: activateOverlapMode"<<endl;
+ if (m_vertical) {
+ activateOverlapMode(m_tb->width());
+ }
+ else
+ {
+ activateOverlapMode(m_tb->height());
+ }
+ } else {
+ kdDebug(760)<<"DockContainer::changeOverlapMode: deactivateOverlapMode"<<endl;
+ deactivateOverlapMode();
+ }
+
+ for (TQMap<KDockWidget*,KDockButton_Private*>::iterator it=m_overlapButtons.begin();
+ it!=m_overlapButtons.end();++it)
+ it.data()->setOn(!isOverlapMode());
+}
+
+void DockContainer::hideIfNeeded() {
+ kdDebug(760)<<"************************* hideIfNeeded *************************"<<endl;
+ if (!itemNames.count())
+ ((KDockWidget*)parentWidget())->undock();
+}
+
+void DockContainer::removeWidget(KDockWidget* dwdg)
+{
+ KDockWidget* w = (KDockWidget*) dwdg;
+ if (!m_map.contains(w)) return;
+ int id=m_map[w];
+ if (m_tb->isTabRaised(id)) {
+ //why do we hide the tab if we're just going
+ //to remove it? - mattr 2004-10-26
+ m_tb->setTab(id,false);
+ m_tabSwitching = false;
+ tabClicked(id);
+ }
+ m_tb->removeTab(id);
+ m_ws->removeWidget(w);
+ m_map.remove(w);
+ m_revMap.remove(id);
+ if (m_overlapButtons.contains(w)) {
+ (::tqqt_cast<KDockWidgetHeader*>(w->getHeader()))->removeButton(m_overlapButtons[w]);
+ m_overlapButtons.remove(w);
+ }
+ KDockContainer::removeWidget(w);
+ itemNames.remove(w->name());
+ tabCaptions.remove(w->name());
+ tabTooltips.remove(w->name());
+ if (!itemNames.count())
+ ((KDockWidget*)parentWidget())->undock();
+}
+
+void DockContainer::undockWidget(KDockWidget *dwdg)
+{
+ KDockWidget* w = (KDockWidget*) dwdg;
+
+ if (!m_map.contains(w))
+ return;
+
+ int id=m_map[w];
+ if (m_tb->isTabRaised(id)) {
+ kdDebug(760)<<"Wiget has been undocked, setting tab down"<<endl;
+ m_tb->setTab(id,false);
+ tabClicked(id);
+ }
+}
+
+void DockContainer::tabClicked(int t)
+{
+ kdDebug(760)<<"DockContainer::tabClicked()"<<endl;
+ bool call_makeVisible=!m_tabSwitching;
+ m_tabSwitching=true;
+ if ((t!=-1) && m_tb->isTabRaised(t))
+ {
+ if (m_ws->isHidden())
+ {
+ m_ws->show ();
+ parentDockWidget()->restoreFromForcedFixedSize();
+ }
+ if (!m_ws->widget(t))
+ {
+ m_revMap[t]->manualDock(parentDockWidget(),KDockWidget::DockCenter,20);
+ if (call_makeVisible) m_revMap[t]->makeDockVisible();//manualDock(parentDockWidget(),KDockWidget::DockCenter,20);
+ m_tabSwitching=false;
+ emit activated(this);
+ return;
+ }
+ m_ws->raiseWidget(t);
+ if (m_ws->widget(t)) {
+ KDockWidget *tmpDw=::tqqt_cast<KDockWidget*>(m_ws->widget(t));
+ if (tmpDw) {
+ if (tmpDw->getWidget()) tmpDw->getWidget()->setFocus();
+ } else kdDebug(760)<<"Something really weird is going on"<<endl;
+ } else
+ kdDebug(760)<<"DockContainer::tabClicked(int): m_ws->widget(t)==0 "<<endl;
+
+ if (oldtab!=t) m_tb->setTab(oldtab,false);
+ m_tabSwitching=true;
+ oldtab=t;
+ emit activated(this);
+ }
+ else
+ {
+ // try save splitter position
+ if ( parentDockWidget() && parentDockWidget()->parent() )
+ {
+ KDockSplitter *sp= ::tqqt_cast<KDockSplitter*>(parentDockWidget()->
+ parent());
+ if ( sp )
+ m_separatorPos = sp->separatorPos();
+ }
+ m_previousTab=t;
+// oldtab=-1;
+ if (m_block) return;
+ emit deactivated(this);
+ m_block=true;
+ if (m_ws->widget(t))
+ {
+// ((KDockWidget*)m_ws->widget(t))->undock();
+ }
+ m_block=false;
+ m_ws->hide ();
+
+
+ kdDebug(760)<<"Fixed Width:"<<m_tb->width()<<endl;
+ if (m_vertical)
+ parentDockWidget()->setForcedFixedWidth(m_tb->width()); // strange why it worked before at all
+ else
+ parentDockWidget()->setForcedFixedHeight(m_tb->height()); // strange why it worked before at all
+ }
+ m_tabSwitching=false;
+}
+
+void DockContainer::setToolTip (KDockWidget *, TQString &s)
+{
+ kdDebug(760)<<"***********************************Setting tooltip for a widget: "<<s<<endl;
+}
+
+void DockContainer::setPixmap(KDockWidget* widget ,const TQPixmap& pixmap)
+{
+ int id=m_ws->id(widget);
+ if (id==-1) return;
+ KMultiTabBarTab *tab=m_tb->tab(id);
+ tab->setIcon(pixmap.isNull()?SmallIcon("misc"):pixmap);
+}
+
+void DockContainer::save(TDEConfig* cfg,const TQString& group_or_prefix)
+{
+ // group name
+ TQString grp=cfg->group();
+ cfg->deleteGroup(group_or_prefix+TQString("::%1").arg(parent()->name()));
+ cfg->setGroup(group_or_prefix+TQString("::%1").arg(parent()->name()));
+
+ // save overlap mode
+ cfg->writeEntry("overlapMode",isOverlapMode());
+
+ // try to save the splitter position
+ if ( parentDockWidget() && parentDockWidget()->parent() )
+ {
+ KDockSplitter *sp= ::tqqt_cast<KDockSplitter*>(parentDockWidget()->
+ parent());
+ if ( sp )
+ cfg->writeEntry( "separatorPosition", m_separatorPos );
+ }
+
+ TQPtrList<KMultiTabBarTab>* tl=m_tb->tabs();
+ TQPtrListIterator<KMultiTabBarTab> it(*tl);
+ TQStringList::Iterator it2=itemNames.begin();
+ int i=0;
+ for (;it.current()!=0;++it,++it2)
+ {
+// cfg->writeEntry(TQString("widget%1").arg(i),m_ws->widget(it.current()->id())->name());
+ cfg->writeEntry(TQString("widget%1").arg(i),(*it2));
+ TQString s=tabCaptions[*it2];
+ if (!s.isEmpty()) {
+ cfg->writeEntry(TQString("widget%1-tabCaption").arg(i),s);
+ }
+ s=tabTooltips[*it2];
+ if (!s.isEmpty()) {
+ cfg->writeEntry(TQString("widget%1-tabTooltip").arg(i),s);
+ }
+// kdDebug(760)<<"****************************************Saving: "<<m_ws->widget(it.current()->id())->name()<<endl;
+ if (m_tb->isTabRaised(it.current()->id()))
+ cfg->writeEntry(m_ws->widget(it.current()->id())->name(),true);
+ ++i;
+ }
+
+ cfg->setGroup(grp);
+}
+
+void DockContainer::load(TDEConfig* cfg,const TQString& group_or_prefix)
+{
+ TQString grp=cfg->group();
+ cfg->setGroup(group_or_prefix+TQString("::%1").arg(parent()->name()));
+
+ if (cfg->readBoolEntry("overlapMode"))
+ activateOverlapMode( m_vertical?m_tb->width():m_tb->height() );
+ else
+ deactivateOverlapMode();
+
+ m_separatorPos = cfg->readNumEntry( "separatorPosition", 18000 ); // = 18%
+
+ int i=0;
+ TQString raise;
+ while (true)
+ {
+ TQString dwn=cfg->readEntry(TQString("widget%1").arg(i));
+ if (dwn.isEmpty()) break;
+ kdDebug(760)<<"*************************************************************Configuring dockwidget :"<<dwn<<endl;
+ KDockWidget *dw=((KDockWidget*)parent())->dockManager()->getDockWidgetFromName(dwn);
+ if (dw)
+ {
+ TQString s=cfg->readEntry(TQString("widget%1-tabCaption").arg(i));
+ if (!s.isEmpty()) {
+ dw->setTabPageLabel(s);
+ }
+ s=cfg->readEntry(TQString("widget%1-tabTooltip").arg(i));
+ if (!s.isEmpty()) {
+ dw->setToolTipString(s);
+ }
+ dw->manualDock((KDockWidget*)parent(),KDockWidget::DockCenter);
+ }
+ if (cfg->readBoolEntry(dwn,false)) raise=dwn;
+ i++;
+
+ }
+
+ TQPtrList<KMultiTabBarTab>* tl=m_tb->tabs();
+ TQPtrListIterator<KMultiTabBarTab> it1(*tl);
+ m_ws->hide();
+ if (m_vertical)
+ parentDockWidget()->setForcedFixedWidth(m_tb->width());
+ else
+ parentDockWidget()->setForcedFixedHeight(m_tb->height());
+ for (;it1.current()!=0;++it1)
+ {
+ m_tb->setTab(it1.current()->id(),false);
+ }
+ kapp->syncX();
+ m_delayedRaise=-1;
+
+ for (TQMap<KDockWidget*,KDockButton_Private*>::iterator it=m_overlapButtons.begin();
+ it!=m_overlapButtons.end();++it)
+ it.data()->setOn(!isOverlapMode());
+
+ if (!raise.isEmpty())
+ {
+ for (TQMap<KDockWidget*,int>::iterator it=m_map.begin();it!=m_map.end();++it)
+ {
+ if (it.key()->name()==raise)
+ {
+/* tabClicked(it.data());
+ m_tb->setTab(it.data(),true);
+ tabClicked(it.data());
+ m_ws->raiseWidget(it.key());
+ kapp->sendPostedEvents();
+ kapp->syncX();*/
+
+ m_delayedRaise=it.data();
+ TQTimer::singleShot(0,this,TQT_SLOT(delayedRaise()));
+ kdDebug(760)<<"************** raising *******: "<<it.key()->name()<<endl;
+ break;
+ }
+ }
+
+ }
+ if (m_delayedRaise==-1) TQTimer::singleShot(0,this,TQT_SLOT(init()));
+ cfg->setGroup(grp);
+
+}
+
+void DockContainer::delayedRaise()
+{
+ m_tb->setTab(m_delayedRaise,true);
+ tabClicked(m_delayedRaise);
+}
+
+void DockContainer::collapseOverlapped()
+{
+ if (m_tabSwitching) return;
+ if (isOverlapMode()){
+ TQPtrList<KMultiTabBarTab>* tl=m_tb->tabs();
+ TQPtrListIterator<KMultiTabBarTab> it(*tl);
+ for(;it.current();++it) {
+ if (it.current()->isOn()) {
+ kdDebug(760)<<"Lowering TAB"<<endl;
+ it.current()->setState(false);
+ tabClicked(it.current()->id());
+ }
+ }
+ }
+}
+
+void DockContainer::toggle() {
+ kdDebug(760)<<"DockContainer:activate"<<endl;
+ if (m_tb->isTabRaised(oldtab)) {
+ m_tb->setTab(oldtab,false);
+ tabClicked(oldtab);
+ // KMDI::MainWindow *mainFrm = tqt_dynamic_cast<KMDI::MainWindow*>(m_mainWin);
+ // if (mainFrm && mainFrm->activeWindow() ) // TODO
+ // mainFrm->activeWindow()->setFocus();
+
+ } else {
+ kdDebug(760)<<"DockContainer::toggle(): raising tab"<<endl;
+ if (m_tb->tab(m_previousTab)==0) {
+ if (m_tb->tabs()->count()==0) return;
+ m_previousTab=m_tb->tabs()->getFirst()->id();
+ }
+ m_tb->setTab(m_previousTab,true);
+ tabClicked(m_previousTab);
+ }
+}
+
+void DockContainer::prevToolView() {
+ TQPtrList<KMultiTabBarTab>* tabs=m_tb->tabs();
+ int pos=tabs->findRef(m_tb->tab(oldtab));
+ if (pos==-1) return;
+ pos--;
+ if (pos<0) pos=tabs->count()-1;
+ KMultiTabBarTab *tab=tabs->at(pos);
+ if (!tab) return; //can never happen here, but who knows
+ m_tb->setTab(tab->id(),true);
+ tabClicked(tab->id());
+}
+
+void DockContainer::nextToolView() {
+ TQPtrList<KMultiTabBarTab>* tabs=m_tb->tabs();
+ int pos=tabs->findRef(m_tb->tab(oldtab));
+ if (pos==-1) return;
+ pos++;
+ if (pos>=(int)tabs->count()) pos=0;
+ KMultiTabBarTab *tab=tabs->at(pos);
+ if (!tab) return; //can never happen here, but who knows
+ m_tb->setTab(tab->id(),true);
+ tabClicked(tab->id());
+}
+
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/tdemdi/tdemdi/dockcontainer.h b/tdemdi/tdemdi/dockcontainer.h
new file mode 100644
index 000000000..9b7478378
--- /dev/null
+++ b/tdemdi/tdemdi/dockcontainer.h
@@ -0,0 +1,144 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002, 2003 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2002, 2004 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KMDI_DOCK_CONTAINER_
+#define _KMDI_DOCK_CONTAINER_
+
+#include <tqwidget.h>
+#include <tqstringlist.h>
+#include <kdockwidget.h>
+#include <tqmap.h>
+
+# include <kdockwidget_p.h>
+
+#include <tqpushbutton.h>
+
+class TQWidgetStack;
+class KMultiTabBar;
+class KDockButton_Private;
+
+namespace KMDI
+{
+
+class DockContainer: public TQWidget, public KDockContainer
+{
+ Q_OBJECT
+
+ public:
+ DockContainer(TQWidget *parent, TQWidget *win, int position, int flags);
+ virtual ~DockContainer();
+
+ /** Get the KDockWidget that is our parent */
+ KDockWidget *parentDockWidget();
+
+ /**
+ * Add a widget to this container.
+ * \param w the KDockWidget object to add
+ * \todo Remove the extra parameters that we don't use?
+ */
+ virtual void insertWidget (KDockWidget *w, TQPixmap, const TQString &, int &);
+
+ /**
+ * Show a KDockWidget in our DockContainer
+ * \param w the KDockWidget to show
+ */
+ virtual void showWidget (KDockWidget *w);
+
+ /**
+ * Set a tooltip for a widget
+ *
+ * \todo Actually implement it? Right now, it looks just it
+ * does exactly nothing
+ */
+ virtual void setToolTip (KDockWidget *, TQString &);
+
+ /**
+ * Set a pixmap for one of our dock widgets
+ * \param widget the KDockWidget to set the pixmap for
+ * \param pixmap the pixmap you want to give the widget
+ */
+ virtual void setPixmap(KDockWidget* widget, const TQPixmap& pixmap);
+
+ /**
+ * Undock a widget from the container. This function is called
+ * when you've dragged a tab off the dock it's attached to.
+ * \param dwdg the KDockWidget to undock
+ */
+ virtual void undockWidget(KDockWidget* dwdg);
+
+ /**
+ * Remove a widget from the container. The caller
+ * of this function is responsible for deleting the widget after calling
+ * this function.
+ */
+ virtual void removeWidget(KDockWidget*);
+
+ void hideIfNeeded();
+
+ virtual void save(TDEConfig *,const TQString& group_or_prefix);
+ virtual void load(TDEConfig *,const TQString& group_or_prefix);
+
+ void setStyle(int);
+ protected:
+ bool eventFilter(TQObject*,TQEvent*);
+
+ public slots:
+ void init();
+ void collapseOverlapped();
+ void toggle();
+ void nextToolView();
+ void prevToolView();
+ protected slots:
+ void tabClicked(int);
+ void delayedRaise();
+ void changeOverlapMode();
+ private:
+ TQWidget *m_mainWin;
+ TQWidgetStack *m_ws;
+ KMultiTabBar *m_tb;
+ int mTabCnt;
+ int oldtab;
+ int m_previousTab;
+ int m_position;
+ int m_separatorPos;
+ TQMap<KDockWidget*,int> m_map;
+ TQMap<int,KDockWidget*> m_revMap;
+ TQMap<KDockWidget*,KDockButton_Private*> m_overlapButtons;
+ TQStringList itemNames;
+ TQMap<TQString,TQString> tabCaptions;
+ TQMap<TQString,TQString> tabTooltips;
+ int m_inserted;
+ int m_delayedRaise;
+ bool m_vertical;
+ bool m_block;
+ bool m_tabSwitching;
+ TQObject *m_dragPanel;
+ KDockManager *m_dockManager;
+ TQMouseEvent *m_startEvent;
+ enum MovingState {NotMoving=0,WaitingForMoveStart,MovingInternal,Moving} m_movingState;
+ signals:
+ void activated(DockContainer*);
+ void deactivated(DockContainer*);
+};
+
+}
+
+#endif
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/tdemdi/tdemdi/global.h b/tdemdi/tdemdi/global.h
new file mode 100644
index 000000000..6ea09a93e
--- /dev/null
+++ b/tdemdi/tdemdi/global.h
@@ -0,0 +1,69 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2004 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002,2003 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ Based on:
+
+ //----------------------------------------------------------------------------
+ // Project : KDE MDI extension
+ //
+ // begin : 07/1999 by Szymon Stefanek as part of kvirc
+ // (an IRC application)
+ // changes : 09/1999 by Falk Brettschneider to create an
+ // - 06/2000 stand-alone Qt extension set of
+ // classes and a Qt-based library
+ // : 02/2000 by Massimo Morin (mmorin@schedsys.com)
+ // 2000-2003 maintained by the KDevelop project
+ // patches : -/2000 by Lars Beikirch (Lars.Beikirch@gmx.net)
+ // : 01/2003 by Jens Zurheide (jens.zurheide@gmx.de)
+ //
+ // copyright : (C) 1999-2003 by Falk Brettschneider
+ // and
+ // Szymon Stefanek (stefanek@tin.it)
+ // email : falkbr@tdevelop.org (Falk Brettschneider)
+ //----------------------------------------------------------------------------
+*/
+
+#ifndef _KMDI_GLOBAL_H_
+#define _KMDI_GLOBAL_H_
+
+/**
+ * @short A namespace for the KMDI library
+ */
+namespace KMDI
+{
+ enum TabWidgetVisibility {
+ AlwaysShowTabs = 0,
+ ShowWhenMoreThanOneTab = 1,
+ NeverShowTabs = 2
+ };
+
+ /**
+ * The style of the toolview tabs
+ */
+ enum ToolviewStyle {
+ /** Show only icons on the toolview tabs. The visible toolviews contain both the icon and text. */
+ IconOnly = 0,
+ /** Show only the text description on the toolview tabs. */
+ TextOnly = 1,
+ /** Show both the icon and description on the toolview tabs. */
+ TextAndIcon = 3
+ };
+}
+
+#endif
diff --git a/tdemdi/tdemdi/guiclient.cpp b/tdemdi/tdemdi/guiclient.cpp
new file mode 100644
index 000000000..490eb2b43
--- /dev/null
+++ b/tdemdi/tdemdi/guiclient.cpp
@@ -0,0 +1,230 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2004 Christoph Cullmann <cullmann@kde.org>
+ based on ktoolbarhandler.cpp: Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "guiclient.h"
+#include "guiclient.moc"
+
+#include <tqpopupmenu.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include <ktoolbar.h>
+#include <klocale.h>
+#include <kaction.h>
+#include <tqstring.h>
+#include <kdebug.h>
+#include <kdockwidget.h>
+
+#include "mainwindow.h"
+#include "toolviewaccessor.h"
+#include "toolviewaccessor_p.h"
+
+static const char *actionListName = "show_tdemdi_document_tool_view_actions";
+
+static const char *guiDescription = ""
+ "<!DOCTYPE kpartgui><kpartgui name=\"KMDIViewActions\">"
+ "<MenuBar>"
+ " <Menu name=\"window\">"
+ " <ActionList name=\"%1\" />"
+ " </Menu>"
+ "</MenuBar>"
+ "</kpartgui>";
+
+static const char *resourceFileName = "tdemdiviewactions.rc";
+
+namespace KMDIPrivate
+{
+
+GUIClient::GUIClient (KMDI::MainWindow* mdiMainFrm,const char* name)
+ : TQObject ( mdiMainFrm,name )
+ , KXMLGUIClient ( mdiMainFrm )
+{
+ m_mdiMainFrm=mdiMainFrm;
+
+ connect( mdiMainFrm->guiFactory(), TQT_SIGNAL( clientAdded( KXMLGUIClient * ) ),
+ this, TQT_SLOT( clientAdded( KXMLGUIClient * ) ) );
+
+ /* re-use an existing resource file if it exists. can happen if the user launches the
+ * toolbar editor */
+ /*
+ setXMLFile( resourceFileName );
+ */
+
+ if ( domDocument().documentElement().isNull() )
+ {
+ TQString completeDescription = TQString::fromLatin1( guiDescription ).arg( actionListName );
+
+ setXML( completeDescription, false /*merge*/ );
+ }
+
+ if (actionCollection()->kaccel()==0)
+ actionCollection()->setWidget(mdiMainFrm);
+
+ m_toolMenu=new KActionMenu(i18n("Tool &Views"),actionCollection(),"tdemdi_toolview_menu");
+
+ m_gotoToolDockMenu=new KActionMenu(i18n("Tool &Docks"),actionCollection(),"tdemdi_tooldock_menu");
+ m_gotoToolDockMenu->insert(new KAction(i18n("Switch Top Dock"),ALT+CTRL+SHIFT+Key_T,this,TQT_SIGNAL(toggleTop()),
+ actionCollection(),"tdemdi_activate_top"));
+ m_gotoToolDockMenu->insert(new KAction(i18n("Switch Left Dock"),ALT+CTRL+SHIFT+Key_L,this,TQT_SIGNAL(toggleLeft()),
+ actionCollection(),"tdemdi_activate_left"));
+ m_gotoToolDockMenu->insert(new KAction(i18n("Switch Right Dock"),ALT+CTRL+SHIFT+Key_R,this,TQT_SIGNAL(toggleRight()),
+ actionCollection(),"tdemdi_activate_right"));
+ m_gotoToolDockMenu->insert(new KAction(i18n("Switch Bottom Dock"),ALT+CTRL+SHIFT+Key_B,this,TQT_SIGNAL(toggleBottom()),
+ actionCollection(),"tdemdi_activate_bottom"));
+ m_gotoToolDockMenu->insert(new KActionSeparator(actionCollection(),"tdemdi_goto_menu_separator"));
+ m_gotoToolDockMenu->insert(new KAction(i18n("Previous Tool View"),ALT+CTRL+Key_Left,TQT_TQOBJECT(m_mdiMainFrm),TQT_SLOT(prevToolViewInDock()),
+ actionCollection(),"tdemdi_prev_toolview"));
+ m_gotoToolDockMenu->insert(new KAction(i18n("Next Tool View"),ALT+CTRL+Key_Right,TQT_TQOBJECT(m_mdiMainFrm),TQT_SLOT(nextToolViewInDock()),
+ actionCollection(),"tdemdi_next_toolview"));
+
+ actionCollection()->readShortcutSettings( "Shortcuts", kapp->config() );
+}
+
+GUIClient::~GUIClient()
+{
+// actionCollection()->writeShortcutSettings( "KMDI Shortcuts", kapp->config() );
+ for (uint i=0;i<m_toolViewActions.count();i++)
+ disconnect(m_toolViewActions.at(i),0,this,0);
+
+ m_toolViewActions.setAutoDelete( false );
+ m_toolViewActions.clear();
+ m_documentViewActions.setAutoDelete( false );
+ m_documentViewActions.clear();
+}
+
+void GUIClient::setupActions()
+{
+ if ( !factory() || !m_mdiMainFrm )
+ return;
+
+ unplugActionList( actionListName );
+
+ TQPtrList<KAction> addList;
+ if (m_toolViewActions.count()<3)
+ {
+ for (uint i=0;i<m_toolViewActions.count();i++)
+ addList.append(m_toolViewActions.at(i));
+ }
+ else
+ addList.append(m_toolMenu);
+
+ addList.append(m_gotoToolDockMenu);
+
+ kdDebug(760)<<"GUIClient::setupActions: plugActionList"<<endl;
+
+ plugActionList( actionListName, addList );
+}
+
+void GUIClient::addToolView(KMDI::ToolViewAccessor* mtva)
+{
+ kdDebug(760)<<"*****void GUIClient::addToolView(KMDI::ToolViewAccessor* mtva)*****"<<endl;
+
+ TQString aname = TQString("tdemdi_toolview_") + mtva->wrappedWidget()->name();
+
+ // try to read the action shortcut
+ KShortcut sc;
+ TDEConfig *cfg = kapp->config();
+ TQString _grp = cfg->group();
+ cfg->setGroup("Shortcuts");
+ sc = KShortcut( cfg->readEntry( aname, "" ) );
+ cfg->setGroup( _grp );
+
+ KAction *a=new ToggleToolViewAction(i18n("Show %1").arg(mtva->wrappedWidget()->caption()),
+ /*TQString::null*/sc,tqt_dynamic_cast<KDockWidget*>(mtva->wrapperWidget()),
+ m_mdiMainFrm,actionCollection(), aname.latin1() );
+
+ ((ToggleToolViewAction*)a)->setCheckedState(TQString(i18n("Hide %1").arg(mtva->wrappedWidget()->caption())));
+
+ connect(a,TQT_SIGNAL(destroyed(TQObject*)),this,TQT_SLOT(actionDeleted(TQObject*)));
+
+ m_toolViewActions.append(a);
+ m_toolMenu->insert(a);
+ mtva->d->action=a;
+
+ setupActions();
+}
+
+void GUIClient::actionDeleted(TQObject* a)
+{
+ m_toolViewActions.remove(static_cast<KAction*>(a));
+ setupActions();
+}
+
+
+void GUIClient::clientAdded( KXMLGUIClient *client )
+{
+ if ( client == this )
+ setupActions();
+}
+
+ToggleToolViewAction::ToggleToolViewAction ( const TQString& text, const KShortcut& cut,KDockWidget *dw, KMDI::MainWindow *mdiMainFrm,
+ TQObject* parent, const char* name )
+ : KToggleAction(text,cut,parent,name)
+ , m_dw(dw)
+ , m_mdiMainFrm(mdiMainFrm)
+{
+ if (m_dw)
+ {
+ connect(this,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(slotToggled(bool)));
+ connect(m_dw->dockManager(),TQT_SIGNAL(change()),this,TQT_SLOT(anDWChanged()));
+ connect(m_dw,TQT_SIGNAL(destroyed()),this,TQT_SLOT(slotWidgetDestroyed()));
+
+ setChecked(m_dw->mayBeHide());
+ }
+}
+
+ToggleToolViewAction::~ToggleToolViewAction()
+{
+ unplugAll();
+}
+
+void ToggleToolViewAction::anDWChanged()
+{
+ if (isChecked() && m_dw->mayBeShow())
+ setChecked(false);
+ else if ((!isChecked()) && m_dw->mayBeHide())
+ setChecked(true);
+ else if (isChecked() && (m_dw->parentDockTabGroup() &&
+ ((::tqqt_cast<KDockWidget*>(m_dw->parentDockTabGroup()->
+ parent()))->mayBeShow())))
+ setChecked(false);
+}
+
+
+void ToggleToolViewAction::slotToggled(bool t)
+{
+ if ((!t) && m_dw->mayBeHide() )
+ m_dw->undock();
+ else
+ if ( t && m_dw->mayBeShow() )
+ m_mdiMainFrm->makeDockVisible(m_dw);
+}
+
+void ToggleToolViewAction::slotWidgetDestroyed()
+{
+ disconnect(m_dw->dockManager(),TQT_SIGNAL(change()),this,TQT_SLOT(anDWChanged()));
+ disconnect(this,TQT_SIGNAL(toggled(bool)),0,0);
+
+ unplugAll();
+ deleteLater();
+}
+
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/tdemdi/tdemdi/guiclient.h b/tdemdi/tdemdi/guiclient.h
new file mode 100644
index 000000000..4d1609ce6
--- /dev/null
+++ b/tdemdi/tdemdi/guiclient.h
@@ -0,0 +1,103 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2004 Christoph Cullmann <cullmann@kde.org>
+ based on ktoolbarhandler.cpp: Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KMDI_GUICLIENT_H_
+#define _KMDI_GUICLIENT_H_
+
+#include <tqobject.h>
+#include <tqguardedptr.h>
+#include <kxmlguiclient.h>
+#include <kaction.h>
+
+#include <tdemdi/global.h>
+
+class KMainWindow;
+class KToolBar;
+
+namespace KMDI {
+ class MainWindow;
+ class ToolViewAccessor;
+}
+
+class KDockWidget;
+
+namespace KMDIPrivate {
+
+class GUIClientPrivate;
+
+class GUIClient : public TQObject, public KXMLGUIClient
+{
+ Q_OBJECT
+
+ public:
+ GUIClient( KMDI::MainWindow *mdiMainFrm, const char *name = 0 );
+ virtual ~GUIClient();
+
+ void addToolView(KMDI::ToolViewAccessor*);
+
+ private slots:
+ void clientAdded( KXMLGUIClient *client );
+ void setupActions();
+ void actionDeleted(TQObject*);
+
+ signals:
+ void toggleTop();
+ void toggleLeft();
+ void toggleRight();
+ void toggleBottom();
+
+ private:
+ GUIClientPrivate *d;
+
+ TQGuardedPtr<KMDI::MainWindow> m_mdiMainFrm;
+ TQPtrList<KAction> m_toolViewActions;
+ TQPtrList<KAction> m_documentViewActions;
+
+ KActionMenu *m_docMenu;
+ KActionMenu *m_toolMenu;
+
+ KActionMenu *m_gotoToolDockMenu;
+};
+
+class ToggleToolViewAction:public KToggleAction
+{
+ Q_OBJECT
+
+ public:
+ ToggleToolViewAction ( const TQString& text, const KShortcut& cut = KShortcut(),
+ KDockWidget *dw=0,KMDI::MainWindow *mdiMainFrm=0, TQObject* parent = 0, const char* name = 0 );
+
+ virtual ~ToggleToolViewAction();
+
+ protected slots:
+ void slotToggled(bool);
+ void anDWChanged();
+ void slotWidgetDestroyed();
+
+ private:
+ KDockWidget *m_dw;
+ KMDI::MainWindow *m_mdiMainFrm;
+};
+
+}
+
+#endif
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/tdemdi/tdemdi/mainwindow.cpp b/tdemdi/tdemdi/mainwindow.cpp
new file mode 100644
index 000000000..358791ab0
--- /dev/null
+++ b/tdemdi/tdemdi/mainwindow.cpp
@@ -0,0 +1,451 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2004 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002,2003 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ Based on:
+
+ //----------------------------------------------------------------------------
+ // Project : KDE MDI extension
+ //
+ // begin : 07/1999 by Szymon Stefanek as part of kvirc
+ // (an IRC application)
+ // changes : 09/1999 by Falk Brettschneider to create an
+ // - 06/2000 stand-alone Qt extension set of
+ // classes and a Qt-based library
+ // : 02/2000 by Massimo Morin (mmorin@schedsys.com)
+ // 2000-2003 maintained by the KDevelop project
+ // patches : -/2000 by Lars Beikirch (Lars.Beikirch@gmx.net)
+ // : 01/2003 by Jens Zurheide (jens.zurheide@gmx.de)
+ //
+ // copyright : (C) 1999-2003 by Falk Brettschneider
+ // and
+ // Szymon Stefanek (stefanek@tin.it)
+ // email : falkbr@tdevelop.org (Falk Brettschneider)
+ //----------------------------------------------------------------------------
+*/
+
+#include "config.h"
+
+#include "tabwidget.h"
+
+#include <assert.h>
+
+#include <tqcursor.h>
+#include <tqclipboard.h>
+#include <tqobjectlist.h>
+#include <tqpopupmenu.h>
+#include <tqmenubar.h>
+
+#include <kmenubar.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <tdeversion.h>
+#include <tqtabwidget.h>
+#include <klocale.h>
+
+#include <kiconloader.h>
+#include "dockcontainer.h"
+#include "mainwindow.moc"
+
+
+#include <tqtoolbutton.h>
+#include <tqlayout.h>
+#include <tqstring.h>
+#include <tqmap.h>
+#include <tqvaluelist.h>
+
+#include "mainwindow.h"
+#include "dockcontainer.h"
+#include "toolviewaccessor_p.h"
+
+#include "guiclient.h"
+
+namespace KMDIPrivate
+{
+ class MainWindowPrivate {
+ public:
+ MainWindowPrivate() {
+ for (int i=0;i<4;i++) {
+ activeDockPriority[i]=0;
+ m_styleIDEAlMode = 0;
+ m_toolviewStyle = 0;
+ }
+ }
+ ~MainWindowPrivate() {}
+ KMDI::DockContainer* activeDockPriority[4];
+ int m_styleIDEAlMode;
+ int m_toolviewStyle;
+ };
+}
+
+namespace KMDI
+{
+
+//============ constructor ============//
+MainWindow::MainWindow(TQWidget* parentWidget, const char* name)
+ : KParts::DockMainWindow( parentWidget, name)
+ , m_toolViews (new TQMap<TQWidget*,KMDI::ToolViewAccessor*>)
+ , d(new KMDIPrivate::MainWindowPrivate())
+{
+ // setup main dock stuff
+ setupMainDock ();
+
+ // setup the sidebar framework
+ setupToolViews ();
+
+ // setup all menu entries
+ setupGUIClient ();
+}
+
+//============ ~MainWindow ============//
+MainWindow::~MainWindow()
+{
+ delete m_toolViews;
+ m_toolViews=0;
+
+ delete d;
+ d=0;
+}
+
+void MainWindow::setupMainDock ()
+{
+ // cover KMdi's childarea by a dockwidget
+ KDockWidget *dw = createDockWidget( "mdiAreaCover", TQPixmap(), 0L, "mdi_area_cover");
+ dw->setDockWindowTransient(this,true);
+ dw->setEnableDocking(KDockWidget::DockNone);
+ dw->setDockSite(KDockWidget::DockCorner);
+
+ // setup tab widget
+ m_tabWidget = new KMDI::TabWidget (dw);
+ dw->setWidget(m_tabWidget);
+
+ // set this dock to main view
+ setView(dw);
+ setMainDockWidget(dw);
+
+ // connect signals to collapse sidebars
+ connect(m_tabWidget,TQT_SIGNAL(focusInEvent()),this,TQT_SIGNAL(collapseOverlapContainers()));
+}
+
+void MainWindow::setupToolViews ()
+{
+ m_leftContainer = createDockWidget("KMdiDock::leftDock",SmallIcon("misc"),0L,"Left Dock");
+ m_rightContainer = createDockWidget("KMdiDock::rightDock",SmallIcon("misc"),0L,"Right Dock");
+ m_topContainer = createDockWidget("KMdiDock::topDock",SmallIcon("misc"),0L,"Top Dock");
+ m_bottomContainer = createDockWidget("KMdiDock::bottomDock",SmallIcon("misc"),0L,"Bottom Dock");
+
+ KDockWidget *mainDock=getMainDockWidget();
+ KDockWidget *w=mainDock;
+
+ if (mainDock->parentDockTabGroup()) {
+ w=static_cast<KDockWidget*>(TQT_TQWIDGET(mainDock->parentDockTabGroup()->parent()));
+ }
+
+ TQPtrList<KDockWidget> leftReparentWidgets;
+ TQPtrList<KDockWidget> rightReparentWidgets;
+ TQPtrList<KDockWidget> bottomReparentWidgets;
+ TQPtrList<KDockWidget> topReparentWidgets;
+
+ if (mainDock->parentDockTabGroup()) {
+ mainDock=static_cast<KDockWidget*>(TQT_TQWIDGET(mainDock->parentDockTabGroup()->parent()));
+ }
+
+ findToolViewsDockedToMain(&leftReparentWidgets,KDockWidget::DockLeft);
+ findToolViewsDockedToMain(&rightReparentWidgets,KDockWidget::DockRight);
+ findToolViewsDockedToMain(&bottomReparentWidgets,KDockWidget::DockBottom);
+ findToolViewsDockedToMain(&topReparentWidgets,KDockWidget::DockTop);
+
+ mainDock->setEnableDocking(KDockWidget::DockNone); //::DockCorner);
+ mainDock->setDockSite(KDockWidget::DockCorner);
+
+
+ DockContainer *tmpDC;
+ m_leftContainer->setWidget(tmpDC=new DockContainer(m_leftContainer, this, KDockWidget::DockLeft, d->m_styleIDEAlMode));
+ m_leftContainer->setEnableDocking(KDockWidget::DockLeft);
+ m_leftContainer->manualDock(mainDock, KDockWidget::DockLeft,20);
+ tmpDC->init();
+
+ connect (this,TQT_SIGNAL(toggleLeft()),tmpDC,TQT_SLOT(toggle()));
+ connect(this,TQT_SIGNAL(collapseOverlapContainers()),tmpDC,TQT_SLOT(collapseOverlapped()));
+ connect(tmpDC,TQT_SIGNAL(activated(DockContainer*)),this,TQT_SLOT(setActiveToolDock(DockContainer*)));
+ connect(tmpDC,TQT_SIGNAL(deactivated(DockContainer*)),this,TQT_SLOT(removeFromActiveDockList(DockContainer*)));
+
+ m_rightContainer->setWidget(tmpDC=new DockContainer(m_rightContainer, this, KDockWidget::DockRight, d->m_styleIDEAlMode));
+ m_rightContainer->setEnableDocking(KDockWidget::DockRight);
+ m_rightContainer->manualDock(mainDock, KDockWidget::DockRight,80);
+ tmpDC->init();
+
+ connect (this,TQT_SIGNAL(toggleRight()),tmpDC,TQT_SLOT(toggle()));
+ connect(this,TQT_SIGNAL(collapseOverlapContainers()),tmpDC,TQT_SLOT(collapseOverlapped()));
+ connect(tmpDC,TQT_SIGNAL(activated(DockContainer*)),this,TQT_SLOT(setActiveToolDock(DockContainer*)));
+ connect(tmpDC,TQT_SIGNAL(deactivated(DockContainer*)),this,TQT_SLOT(removeFromActiveDockList(DockContainer*)));
+
+ m_topContainer->setWidget(tmpDC=new DockContainer(m_topContainer, this, KDockWidget::DockTop, d->m_styleIDEAlMode));
+ m_topContainer->setEnableDocking(KDockWidget::DockTop);
+ m_topContainer->manualDock(mainDock, KDockWidget::DockTop,20);
+ tmpDC->init();
+
+ connect (this,TQT_SIGNAL(toggleTop()),tmpDC,TQT_SLOT(toggle()));
+ connect(this,TQT_SIGNAL(collapseOverlapContainers()),tmpDC,TQT_SLOT(collapseOverlapped()));
+ connect(tmpDC,TQT_SIGNAL(activated(DockContainer*)),this,TQT_SLOT(setActiveToolDock(DockContainer*)));
+ connect(tmpDC,TQT_SIGNAL(deactivated(DockContainer*)),this,TQT_SLOT(removeFromActiveDockList(DockContainer*)));
+
+ m_bottomContainer->setWidget(tmpDC=new DockContainer(m_bottomContainer, this, KDockWidget::DockBottom, d->m_styleIDEAlMode));
+ m_bottomContainer->setEnableDocking(KDockWidget::DockBottom);
+ m_bottomContainer->manualDock(mainDock, KDockWidget::DockBottom,80);
+ tmpDC->init();
+
+ connect (this,TQT_SIGNAL(toggleBottom()),tmpDC,TQT_SLOT(toggle()));
+ connect(this,TQT_SIGNAL(collapseOverlapContainers()),tmpDC,TQT_SLOT(collapseOverlapped()));
+ connect(tmpDC,TQT_SIGNAL(activated(DockContainer*)),this,TQT_SLOT(setActiveToolDock(DockContainer*)));
+ connect(tmpDC,TQT_SIGNAL(deactivated(DockContainer*)),this,TQT_SLOT(removeFromActiveDockList(DockContainer*)));
+
+ m_leftContainer->setDockSite( KDockWidget::DockCenter );
+ m_rightContainer->setDockSite( KDockWidget::DockCenter );
+ m_topContainer->setDockSite( KDockWidget::DockCenter );
+ m_bottomContainer->setDockSite( KDockWidget::DockCenter );
+
+ dockToolViewsIntoContainers(leftReparentWidgets,m_leftContainer);
+ dockToolViewsIntoContainers(rightReparentWidgets,m_rightContainer);
+ dockToolViewsIntoContainers(bottomReparentWidgets,m_bottomContainer);
+ dockToolViewsIntoContainers(topReparentWidgets,m_topContainer);
+
+ dockManager->setSpecialLeftDockContainer(m_leftContainer);
+ dockManager->setSpecialRightDockContainer(m_rightContainer);
+ dockManager->setSpecialTopDockContainer(m_topContainer);
+ dockManager->setSpecialBottomDockContainer(m_bottomContainer);
+
+ ((DockContainer*) (m_leftContainer->getWidget()))->hideIfNeeded();
+ ((DockContainer*) (m_rightContainer->getWidget()))->hideIfNeeded();
+ ((DockContainer*) (m_topContainer->getWidget()))->hideIfNeeded();
+ ((DockContainer*) (m_bottomContainer->getWidget()))->hideIfNeeded();
+}
+
+void MainWindow::setupGUIClient ()
+{
+ m_guiClient = new KMDIPrivate::GUIClient (this);
+
+ connect(m_guiClient,TQT_SIGNAL(toggleTop()),this,TQT_SIGNAL(toggleTop()));
+ connect(m_guiClient,TQT_SIGNAL(toggleLeft()),this,TQT_SIGNAL(toggleLeft()));
+ connect(m_guiClient,TQT_SIGNAL(toggleRight()),this,TQT_SIGNAL(toggleRight()));
+ connect(m_guiClient,TQT_SIGNAL(toggleBottom()),this,TQT_SIGNAL(toggleBottom()));
+}
+
+TabWidget *MainWindow::tabWidget ()
+{
+ return m_tabWidget;
+}
+
+ToolViewAccessor *MainWindow::createToolWindow()
+{
+ return new KMDI::ToolViewAccessor(this);
+}
+
+KMDI::ToolViewAccessor *MainWindow::addToolWindow( TQWidget* pWnd, KDockWidget::DockPosition pos, TQWidget* pTargetWnd, int percent, const TQString& tabToolTip, const TQString& tabCaption)
+{
+ TQWidget *tvta=pWnd;
+ KDockWidget* pDW = dockManager->getDockWidgetFromName(pWnd->name());
+ if (pDW) {
+ // probably readDockConfig already created the widgetContainer, use that
+ pDW->setWidget(pWnd);
+
+ if (pWnd->icon()) {
+ pDW->setPixmap(*pWnd->icon());
+ }
+ pDW->setTabPageLabel((tabCaption==0)?pWnd->caption():tabCaption);
+ pDW->setToolTipString(tabToolTip);
+ dockManager->removeFromAutoCreateList(pDW);
+ pWnd=pDW;
+ }
+
+ TQRect r=pWnd->geometry();
+
+ KMDI::ToolViewAccessor *mtva=new KMDI::ToolViewAccessor(this,pWnd,tabToolTip,(tabCaption==0)?pWnd->caption():tabCaption);
+ m_toolViews->insert(tvta,mtva);
+
+ if (pos == KDockWidget::DockNone) {
+ mtva->d->widgetContainer->setEnableDocking(KDockWidget::DockNone);
+ mtva->d->widgetContainer->reparent(this, (WFlags)(WType_TopLevel | WType_Dialog), r.topLeft(), isVisible());
+ } else { // add (and dock) the toolview as DockWidget view
+ //const TQPixmap& wndIcon = pWnd->icon() ? *(pWnd->icon()) : TQPixmap();
+
+ //KDockWidget *pCover=mtva->d->widgetContainer;
+
+ mtva->place(pos, pTargetWnd,percent);
+ }
+
+ return mtva;
+}
+
+void MainWindow::deleteToolWindow( KMDI::ToolViewAccessor *accessor)
+{
+ delete accessor;
+}
+
+void MainWindow::deleteToolWindow( TQWidget* pWnd)
+{
+ if (!pWnd)
+ return;
+
+ if (m_toolViews->contains(pWnd)) {
+ deleteToolWindow((*m_toolViews)[pWnd]);
+ }
+}
+
+void MainWindow::setToolViewStyle(int flag)
+{
+ d->m_styleIDEAlMode = flag; // see KMultiTabBar for the first 3 bits
+
+ DockContainer *tmpL=::tqqt_cast<KMDI::DockContainer*>(m_leftContainer->getWidget());
+ if (tmpL) tmpL->setStyle(flag);
+
+ DockContainer *tmpR=::tqqt_cast<KMDI::DockContainer*>(m_rightContainer->getWidget());
+ if (tmpR) tmpR->setStyle(flag);
+
+ DockContainer *tmpT=::tqqt_cast<KMDI::DockContainer*>(m_topContainer->getWidget());
+ if (tmpT) tmpT->setStyle(flag);
+
+ DockContainer *tmpB=::tqqt_cast<KMDI::DockContainer*>(m_bottomContainer->getWidget());
+ if (tmpB) tmpB->setStyle(flag);
+
+ d->m_toolviewStyle = flag;
+ bool toolviewExists = false;
+ TQMap<TQWidget*,KMDI::ToolViewAccessor*>::Iterator it;
+ for (it = m_toolViews->begin(); it != m_toolViews->end(); ++it) {
+ KDockWidget *dockWidget = tqt_dynamic_cast<KDockWidget*>(it.data()->wrapperWidget());
+ if (dockWidget) {
+ if (flag == KMDI::IconOnly)
+ {
+ dockWidget->setTabPageLabel(" ");
+ dockWidget->setPixmap(*(it.data()->wrappedWidget()->icon()));
+ } else
+ if (flag == KMDI::TextOnly)
+ {
+ dockWidget->setPixmap(); //FIXME: Does not hide the icon in the IDEAl mode.
+ dockWidget->setTabPageLabel(it.data()->wrappedWidget()->caption());
+ } else
+ if (flag == KMDI::TextAndIcon)
+ {
+ dockWidget->setPixmap(*(it.data()->wrappedWidget()->icon()));
+ dockWidget->setTabPageLabel(it.data()->wrappedWidget()->caption());
+ }
+ toolviewExists = true;
+ }
+ }
+ if (toolviewExists)
+ {
+ //workaround for the above FIXME to make switching to TextOnly mode work in IDEAl as well. Be sure that this version of switch* is called.
+ if (flag == KMDI::TextOnly)
+ {
+ /* MainWindow::switchToTabPageMode();
+ MainWindow::switchToIDEAlMode();*/ //TODO
+ } else
+ {
+ writeDockConfig();
+ readDockConfig();
+ }
+ }
+}
+
+void MainWindow::dockToolViewsIntoContainers(TQPtrList<KDockWidget>& widgetsToReparent,KDockWidget *container) {
+ for ( KDockWidget *dw = widgetsToReparent.first(); dw;
+ dw=widgetsToReparent.next()){
+ dw->manualDock(container,KDockWidget::DockCenter,20);
+ dw->loseFormerBrotherDockWidget();
+ }
+}
+
+void MainWindow::findToolViewsDockedToMain(TQPtrList<KDockWidget>* list,KDockWidget::DockPosition dprtmw) {
+ KDockWidget *mainDock=getMainDockWidget();
+ if (mainDock->parentDockTabGroup()) {
+ mainDock=tqt_dynamic_cast<KDockWidget*>(mainDock->parentDockTabGroup()->parent());
+ // FIXME: will likely crash below due to unchecked cast
+ }
+
+ KDockWidget* widget=mainDock->findNearestDockWidget(dprtmw);
+ if (widget) {
+ if (widget->parentDockTabGroup()) {
+ widget=static_cast<KDockWidget*>(TQT_TQWIDGET(widget->parentDockTabGroup()->parent()));
+ }
+
+ if (widget) {
+ KDockTabGroup *tg=tqt_dynamic_cast<KDockTabGroup*>(widget->
+ getWidget());
+ if (tg) {
+ kdDebug(760)<<"KDockTabGroup found"<<endl;
+ for (int i=0;i<tg->count();i++)
+ list->append((KDockWidget*)static_cast<KDockWidget*>(
+ tg->page(i)));
+ } else
+ list->append((KDockWidget*)widget);
+ } else
+ kdDebug(760)<<"setupToolViewsForIDEALMode: no widget found"<<endl;
+ } else
+ kdDebug(760)<<"No main dock widget found"<<endl;
+}
+
+void MainWindow::setActiveToolDock(DockContainer* td) {
+ if (td==d->activeDockPriority[0]) return;
+ if (d->activeDockPriority[0]==0) {
+ d->activeDockPriority[0]=td;
+ // d->focusList=new KMdiFocusList(this);
+ // if (m_pMdi) d->focusList->addWidgetTree(m_pMdi);
+ // if (m_documentTabWidget) d->focusList->addWidgetTree(m_documentTabWidget);
+ return;
+ }
+ for (int dst=3,src=2;src>=0;dst--,src--) {
+ if (d->activeDockPriority[src]==td) src--;
+ if (src<0) break;
+ d->activeDockPriority[dst]=d->activeDockPriority[src];
+ }
+ d->activeDockPriority[0]=td;
+}
+
+void MainWindow::removeFromActiveDockList(DockContainer* td) {
+ for (int i=0;i<4;i++) {
+ if (d->activeDockPriority[i]==td) {
+ for (;i<3;i++)
+ d->activeDockPriority[i]=d->activeDockPriority[i+1];
+ d->activeDockPriority[3]=0;
+ break;
+ }
+ }
+ /*
+ if (d->activeDockPriority[0]==0) {
+ if (d->focusList) d->focusList->restore();
+ delete d->focusList;
+ d->focusList=0;
+ }
+ */
+}
+
+void MainWindow::prevToolViewInDock() {
+ DockContainer* td=d->activeDockPriority[0];
+ if (!td) return;
+ td->prevToolView();
+}
+
+void MainWindow::nextToolViewInDock() {
+ DockContainer* td=d->activeDockPriority[0];
+ if (!td) return;
+ td->nextToolView();
+}
+
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/tdemdi/tdemdi/mainwindow.h b/tdemdi/tdemdi/mainwindow.h
new file mode 100644
index 000000000..0916cb908
--- /dev/null
+++ b/tdemdi/tdemdi/mainwindow.h
@@ -0,0 +1,199 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2004 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002,2003 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ Based on:
+
+ //----------------------------------------------------------------------------
+ // Project : KDE MDI extension
+ //
+ // begin : 07/1999 by Szymon Stefanek as part of kvirc
+ // (an IRC application)
+ // changes : 09/1999 by Falk Brettschneider to create an
+ // - 06/2000 stand-alone Qt extension set of
+ // classes and a Qt-based library
+ // : 02/2000 by Massimo Morin (mmorin@schedsys.com)
+ // 2000-2003 maintained by the KDevelop project
+ // patches : -/2000 by Lars Beikirch (Lars.Beikirch@gmx.net)
+ // : 01/2003 by Jens Zurheide (jens.zurheide@gmx.de)
+ //
+ // copyright : (C) 1999-2003 by Falk Brettschneider
+ // and
+ // Szymon Stefanek (stefanek@tin.it)
+ // email : falkbr@tdevelop.org (Falk Brettschneider)
+ //----------------------------------------------------------------------------
+*/
+
+#ifndef _KMDI_MAINWINDOW_H_
+#define _KMDI_MAINWINDOW_H_
+
+#include <tdeparts/dockmainwindow.h>
+#include <kmenubar.h>
+#include <kpopupmenu.h>
+
+#include <tqptrlist.h>
+#include <tqrect.h>
+#include <tqapplication.h>
+#include <tqguardedptr.h>
+
+#include <tdemdi/global.h>
+
+class TQPopupMenu;
+class TQMenuBar;
+
+#include <tdemdi/toolviewaccessor.h>
+
+namespace KMDIPrivate {
+ class MainWindowPrivate;
+ class GUIClient;
+}
+
+namespace KMDI
+{
+
+class DockContainer;
+class TabWidget;
+
+class KMDI_EXPORT MainWindow : public KParts::DockMainWindow
+{
+ Q_OBJECT
+
+ friend class KMDI::ToolViewAccessor;
+
+ public:
+ /**
+ * Constructor.
+ */
+ MainWindow ( TQWidget* parentWidget, const char* name = "");
+
+ /**
+ * Destructor.
+ */
+ virtual ~MainWindow ();
+
+ public:
+ /**
+ * get the central tabwidget
+ * add all your content as child to this widget
+ * or as multiple tabs
+ * @return tabwidget in central of window
+ */
+ TabWidget *tabWidget ();
+
+ /**
+ * Using this method you have to use the setWidget method of the access object, and it is very recommendet, that you use
+ * the widgetContainer() method for the parent of your newly created widget
+ * @return created toolview
+ */
+ KMDI::ToolViewAccessor *createToolWindow();
+
+ /**
+ * Usually called from addWindow() when adding a tool view window. It reparents the given widget
+ * as toplevel and stay-on-top on the application's main widget.
+ * @param pWnd widget for the toolview
+ * @param pos docking position
+ * @param pTargetWnd
+ * @param percent
+ * @param tabToolTip
+ * @param tabCaption
+ * @return created toolview
+ */
+ KMDI::ToolViewAccessor *addToolWindow( TQWidget* pWnd, KDockWidget::DockPosition pos = KDockWidget::DockNone, TQWidget* pTargetWnd = 0L, int percent = 50, const TQString& tabToolTip = 0, const TQString& tabCaption = 0);
+
+ /**
+ * delete the toolview belonging to the given accessor
+ * @param accessor toolview to delete
+ */
+ void deleteToolWindow( KMDI::ToolViewAccessor *accessor);
+
+ /**
+ * delete the toolview belonging to the given pWnd
+ * @param pWnd toolview to be deleted
+ */
+ void deleteToolWindow( TQWidget* pWnd);
+
+ /**
+ * Sets the appearance of the toolview tabs.
+ * @param flags See KMDI::ToolviewStyle.
+ */
+ void setToolViewStyle(int flags);
+
+ public slots:
+ void prevToolViewInDock();
+ void nextToolViewInDock();
+
+ signals:
+ void collapseOverlapContainers();
+
+ protected:
+ void findToolViewsDockedToMain(TQPtrList<KDockWidget>* list,KDockWidget::DockPosition dprtmw);
+ void dockToolViewsIntoContainers(TQPtrList<KDockWidget>& widgetsToReparent,KDockWidget *container);
+
+ private:
+ /**
+ * setup main dock + tab widget
+ */
+ void setupMainDock ();
+
+ /**
+ * setup the sidebars for the toolviews
+ * and other internals to get them working
+ */
+ void setupToolViews ();
+
+ /**
+ * setup the menuentries
+ * must be done AFTER setupToolViews ()
+ */
+ void setupGUIClient ();
+
+ private slots:
+ void setActiveToolDock(DockContainer*);
+ void removeFromActiveDockList(DockContainer*);
+
+ #define protected public
+ signals:
+ #undef protected
+ void toggleTop();
+ void toggleLeft();
+ void toggleRight();
+ void toggleBottom();
+
+ protected:
+ KMDIPrivate::GUIClient *m_guiClient;
+ TQMap <TQWidget*, KMDI::ToolViewAccessor*> *m_toolViews;
+
+ KDockWidget *m_leftContainer;
+ KDockWidget *m_rightContainer;
+ KDockWidget *m_topContainer;
+ KDockWidget *m_bottomContainer;
+
+ KMDI::TabWidget *m_tabWidget;
+
+ private:
+ /**
+ * private d-pointer for BC
+ */
+ KMDIPrivate::MainWindowPrivate *d;
+};
+
+}
+
+#endif //_MainWindow_H_
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/tdemdi/tdemdi/tabwidget.cpp b/tdemdi/tdemdi/tabwidget.cpp
new file mode 100644
index 000000000..2d9603bf5
--- /dev/null
+++ b/tdemdi/tdemdi/tabwidget.cpp
@@ -0,0 +1,284 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2004 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002,2003 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ Based on:
+
+ //----------------------------------------------------------------------------
+ // Project : KDE MDI extension
+ //
+ // begin : 07/1999 by Szymon Stefanek as part of kvirc
+ // (an IRC application)
+ // changes : 09/1999 by Falk Brettschneider to create an
+ // - 06/2000 stand-alone Qt extension set of
+ // classes and a Qt-based library
+ // : 02/2000 by Massimo Morin (mmorin@schedsys.com)
+ // 2000-2003 maintained by the KDevelop project
+ // patches : -/2000 by Lars Beikirch (Lars.Beikirch@gmx.net)
+ // : 01/2003 by Jens Zurheide (jens.zurheide@gmx.de)
+ //
+ // copyright : (C) 1999-2003 by Falk Brettschneider
+ // and
+ // Szymon Stefanek (stefanek@tin.it)
+ // email : falkbr@tdevelop.org (Falk Brettschneider)
+ //----------------------------------------------------------------------------
+*/
+
+#include <ktabbar.h>
+#include <kpopupmenu.h>
+#include <kdebug.h>
+
+#include <tqobjectlist.h>
+
+#include "tabwidget.h"
+#include "tabwidget.moc"
+
+namespace KMDIPrivate
+{
+ class TabWidgetPrivate
+ {
+
+ };
+}
+
+namespace KMDI
+{
+
+TabWidget::TabWidget(TQWidget* parent, const char* name)
+ : KTabWidget(parent,name)
+ , m_visibility (KMDI::ShowWhenMoreThanOneTab)
+ , d (new KMDIPrivate::TabWidgetPrivate())
+{
+ installEventFilter (this);
+
+ tabBar()->hide();
+
+ setHoverCloseButton(true);
+
+ connect(this, TQT_SIGNAL(closeRequest(TQWidget*)), this, TQT_SLOT(closeTab(TQWidget*)));
+}
+
+TabWidget::~TabWidget()
+{
+ delete d;
+ d = 0;
+}
+
+bool TabWidget::eventFilter(TQObject *obj, TQEvent *e )
+{
+ if(e->type() == TQEvent::FocusIn)
+ {
+ emit focusInEvent ();
+ }
+ else if (e->type() == TQEvent::ChildRemoved)
+ {
+ // if we lost a child we uninstall ourself as event filter for the lost
+ // child and its children
+ TQObject* pLostChild = TQT_TQOBJECT(((TQChildEvent*)e)->child());
+ if ((pLostChild != 0L) && (pLostChild->isWidgetType())) {
+ TQObjectList *list = pLostChild->queryList( TQWIDGET_OBJECT_NAME_STRING );
+ list->insert(0, pLostChild); // add the lost child to the list too, just to save code
+ TQObjectListIt it( *list ); // iterate over all lost child widgets
+ TQObject * o;
+ while ( (o=it.current()) != 0 ) { // for each found object...
+ TQWidget* widg = (TQWidget*)o;
+ ++it;
+ widg->removeEventFilter(this);
+ }
+ delete list; // delete the list, not the objects
+ }
+ }
+ else if (e->type() == TQEvent::ChildInserted)
+ {
+ // if we got a new child and we are attached to the MDI system we
+ // install ourself as event filter for the new child and its children
+ // (as we did when we were added to the MDI system).
+ TQObject* pNewChild = TQT_TQOBJECT(((TQChildEvent*)e)->child());
+ if ((pNewChild != 0L) && (pNewChild->isWidgetType()))
+ {
+ TQWidget* pNewWidget = (TQWidget*)pNewChild;
+ if (pNewWidget->testWFlags((WFlags)(WType_Dialog | WShowModal)))
+ return false;
+ TQObjectList *list = pNewWidget->queryList( TQWIDGET_OBJECT_NAME_STRING );
+ list->insert(0, pNewChild); // add the new child to the list too, just to save code
+ TQObjectListIt it( *list ); // iterate over all new child widgets
+ TQObject * o;
+ while ( (o=it.current()) != 0 ) { // for each found object...
+ TQWidget* widg = (TQWidget*)o;
+ ++it;
+ widg->installEventFilter(this);
+ connect(widg, TQT_SIGNAL(destroyed()), this, TQT_SLOT(childDestroyed()));
+ }
+ delete list; // delete the list, not the objects
+ }
+ }
+
+ return KTabWidget::eventFilter (obj, e);
+}
+
+void TabWidget::childDestroyed()
+{
+ // if we lost a child we uninstall ourself as event filter for the lost
+ // child and its children
+ const TQObject* pLostChild = TQT_TQOBJECT_CONST(sender());
+ if ((pLostChild != 0L) && (pLostChild->isWidgetType()))
+ {
+ TQObjectList *list = ((TQObject*)(pLostChild))->queryList(TQWIDGET_OBJECT_NAME_STRING);
+ list->insert(0, pLostChild); // add the lost child to the list too, just to save code
+ TQObjectListIt it( *list ); // iterate over all lost child widgets
+ TQObject * obj;
+ while ( (obj=it.current()) != 0 ) { // for each found object...
+ TQWidget* widg = (TQWidget*)obj;
+ ++it;
+ widg->removeEventFilter(this);
+ }
+ delete list; // delete the list, not the objects
+ }
+}
+
+void TabWidget::closeTab(TQWidget* w)
+{
+ w->close();
+}
+
+void TabWidget::addTab ( TQWidget * child, const TQString & label )
+{
+ KTabWidget::addTab(child,label);
+ showPage(child);
+ maybeShow();
+}
+
+void TabWidget::addTab ( TQWidget * child, const TQIconSet & iconset, const TQString & label )
+{
+ KTabWidget::addTab(child,iconset,label);
+ showPage(child);
+ maybeShow();
+}
+
+void TabWidget::addTab ( TQWidget * child, TQTab * tab )
+{
+ KTabWidget::addTab(child,tab);
+ showPage(child);
+ maybeShow();
+}
+
+void TabWidget::insertTab ( TQWidget * child, const TQString & label, int index)
+{
+ KTabWidget::insertTab(child,label,index);
+ showPage(child);
+ maybeShow();
+ tabBar()->repaint();
+}
+
+void TabWidget::insertTab ( TQWidget * child, const TQIconSet & iconset, const TQString & label, int index )
+{
+ KTabWidget::insertTab(child,iconset,label,index);
+ showPage(child);
+ maybeShow();
+ tabBar()->repaint();
+}
+
+void TabWidget::insertTab ( TQWidget * child, TQTab * tab, int index)
+{
+ KTabWidget::insertTab(child,tab,index);
+ showPage(child);
+ maybeShow();
+ tabBar()->repaint();
+}
+
+void TabWidget::removePage ( TQWidget * w )
+{
+ KTabWidget::removePage(w);
+ maybeShow();
+}
+
+void TabWidget::updateIconInView( TQWidget *w, TQPixmap icon )
+{
+ changeTab(w,icon,tabLabel(w));
+}
+
+void TabWidget::updateCaptionInView( TQWidget *w, const TQString &caption )
+{
+ changeTab(w, caption);
+}
+
+void TabWidget::maybeShow()
+{
+ switch (m_visibility)
+ {
+ case KMDI::AlwaysShowTabs:
+ tabBar()->show();
+
+ // show/hide corner widgets
+ if (count() == 0)
+ setCornerWidgetVisibility(false);
+ else
+ setCornerWidgetVisibility(true);
+
+ break;
+
+ case KMDI::ShowWhenMoreThanOneTab:
+ if (count()<2) tabBar()->hide();
+ else tabBar()->show();
+
+ // show/hide corner widgets
+ if (count() < 2)
+ setCornerWidgetVisibility(false);
+ else
+ setCornerWidgetVisibility(true);
+
+ break;
+
+ case KMDI::NeverShowTabs:
+ tabBar()->hide();
+ break;
+ }
+}
+
+void TabWidget::setCornerWidgetVisibility(bool visible) {
+ // there are two corner widgets: on TopLeft and on TopTight!
+
+ if (cornerWidget(TQt::TopLeft) ) {
+ if (visible)
+ cornerWidget(TQt::TopLeft)->show();
+ else
+ cornerWidget(TQt::TopLeft)->hide();
+ }
+
+ if (cornerWidget(TQt::TopRight) ) {
+ if (visible)
+ cornerWidget(TQt::TopRight)->show();
+ else
+ cornerWidget(TQt::TopRight)->hide();
+ }
+}
+
+void TabWidget::setTabWidgetVisibility( KMDI::TabWidgetVisibility visibility )
+{
+ m_visibility = visibility;
+ maybeShow();
+}
+
+KMDI::TabWidgetVisibility TabWidget::tabWidgetVisibility( ) const
+{
+ return m_visibility;
+}
+
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/tdemdi/tdemdi/tabwidget.h b/tdemdi/tdemdi/tabwidget.h
new file mode 100644
index 000000000..992aa657d
--- /dev/null
+++ b/tdemdi/tdemdi/tabwidget.h
@@ -0,0 +1,115 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2004 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002,2003 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ Based on:
+
+ //----------------------------------------------------------------------------
+ // Project : KDE MDI extension
+ //
+ // begin : 07/1999 by Szymon Stefanek as part of kvirc
+ // (an IRC application)
+ // changes : 09/1999 by Falk Brettschneider to create an
+ // - 06/2000 stand-alone Qt extension set of
+ // classes and a Qt-based library
+ // : 02/2000 by Massimo Morin (mmorin@schedsys.com)
+ // 2000-2003 maintained by the KDevelop project
+ // patches : -/2000 by Lars Beikirch (Lars.Beikirch@gmx.net)
+ // : 01/2003 by Jens Zurheide (jens.zurheide@gmx.de)
+ //
+ // copyright : (C) 1999-2003 by Falk Brettschneider
+ // and
+ // Szymon Stefanek (stefanek@tin.it)
+ // email : falkbr@tdevelop.org (Falk Brettschneider)
+ //----------------------------------------------------------------------------
+*/
+
+#ifndef _KMDI_TABWIDGET_H_
+#define _KMDI_TABWIDGET_H_
+
+#include <ktabwidget.h>
+#include <tdemdi/global.h>
+
+namespace KMDIPrivate
+{
+ class TabWidgetPrivate;
+}
+
+namespace KMDI
+{
+
+class KMDI_EXPORT TabWidget : public KTabWidget
+{
+ Q_OBJECT
+
+ public:
+ TabWidget(TQWidget* parent, const char* name=0);
+ virtual ~TabWidget();
+
+ virtual void addTab ( TQWidget * child, const TQString & label );
+
+ virtual void addTab ( TQWidget * child, const TQIconSet & iconset, const TQString & label );
+
+ virtual void addTab ( TQWidget * child, TQTab * tab );
+
+ virtual void insertTab ( TQWidget * child, const TQString & label, int index = -1 );
+
+ virtual void insertTab ( TQWidget * child, const TQIconSet & iconset, const TQString & label, int index = -1 );
+
+ virtual void insertTab ( TQWidget * child, TQTab * tab, int index = -1 );
+
+ virtual void removePage ( TQWidget * w );
+
+ KMDI::TabWidgetVisibility tabWidgetVisibility() const;
+
+ void setTabWidgetVisibility( KMDI::TabWidgetVisibility );
+
+ bool eventFilter(TQObject *obj, TQEvent *e );
+
+ private slots:
+ void closeTab(TQWidget* w);
+
+ public slots:
+ void updateIconInView(TQWidget*,TQPixmap);
+ void updateCaptionInView(TQWidget*,const TQString&);
+
+ signals:
+ void focusInEvent ();
+
+ protected slots:
+ void childDestroyed ();
+
+ private:
+ void maybeShow();
+ void setCornerWidgetVisibility(bool visible);
+
+ private:
+ KMDI::TabWidgetVisibility m_visibility;
+
+ private:
+ /**
+ * private d-pointer for BC
+ */
+ KMDIPrivate::TabWidgetPrivate *d;
+};
+
+}
+
+#endif
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/tdemdi/tdemdi/toolviewaccessor.cpp b/tdemdi/tdemdi/toolviewaccessor.cpp
new file mode 100644
index 000000000..c0d191ff4
--- /dev/null
+++ b/tdemdi/tdemdi/toolviewaccessor.cpp
@@ -0,0 +1,223 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <kdebug.h>
+
+#include "toolviewaccessor_p.h"
+#include "guiclient.h"
+#include "mainwindow.h"
+
+#include "toolviewaccessor.h"
+#include "toolviewaccessor.moc"
+
+#include "toolviewaccessor_p.h"
+
+namespace KMDI
+{
+
+ToolViewAccessor::ToolViewAccessor( KMDI::MainWindow *parent, TQWidget *widgetToWrap, const TQString& tabToolTip, const TQString& tabCaption)
+: TQObject(parent)
+{
+ mdiMainFrm=parent;
+ d=new KMDIPrivate::ToolViewAccessorPrivate();
+ if (widgetToWrap->inherits("KDockWidget")) {
+ d->widgetContainer=tqt_dynamic_cast<KDockWidget*>(widgetToWrap);
+ d->widget=d->widgetContainer->getWidget();
+ } else {
+ d->widget=widgetToWrap;
+ TQString finalTabCaption;
+ if (tabCaption == 0) {
+ finalTabCaption = widgetToWrap->caption();
+ if (finalTabCaption.isEmpty() && !widgetToWrap->icon()) {
+ finalTabCaption = widgetToWrap->name();
+ }
+ }
+ else {
+ finalTabCaption = tabCaption;
+ }
+ d->widgetContainer= parent->createDockWidget( widgetToWrap->name(),
+ (widgetToWrap->icon()?(*(widgetToWrap->icon())):TQPixmap()),
+ 0L, // parent
+ widgetToWrap->caption(),
+ finalTabCaption);
+ d->widgetContainer->setWidget(widgetToWrap);
+ if (tabToolTip!=0) {
+ d->widgetContainer->setToolTipString(tabToolTip);
+ }
+ }
+
+ //mdiMainFrm->m_toolViews.insert(d->widget,this);
+ mdiMainFrm->m_guiClient->addToolView(this);
+ d->widget->installEventFilter(this);
+}
+
+ToolViewAccessor::ToolViewAccessor( KMDI::MainWindow *parent) : TQObject(parent) {
+ mdiMainFrm=parent;
+ d=new KMDIPrivate::ToolViewAccessorPrivate();
+}
+
+ToolViewAccessor::~ToolViewAccessor() {
+ if (mdiMainFrm->m_toolViews)
+ mdiMainFrm->m_toolViews->remove(d->widget);
+ delete d;
+
+}
+
+TQWidget *ToolViewAccessor::wrapperWidget() {
+ if (!d->widgetContainer) {
+ d->widgetContainer=mdiMainFrm->createDockWidget( "ToolViewAccessor::null",TQPixmap());
+ connect(d->widgetContainer,TQT_SIGNAL(widgetSet(TQWidget*)),this,TQT_SLOT(setWidgetToWrap(TQWidget*)));
+ }
+ return d->widgetContainer;
+}
+
+TQWidget *ToolViewAccessor::wrappedWidget() {
+ return d->widget;
+}
+
+
+void ToolViewAccessor::setWidgetToWrap(TQWidget *widgetToWrap, const TQString& tabToolTip, const TQString& tabCaption)
+{
+ Q_ASSERT(!(d->widget));
+ Q_ASSERT(!widgetToWrap->inherits("KDockWidget"));
+ disconnect(d->widgetContainer,TQT_SIGNAL(widgetSet(TQWidget*)),this,TQT_SLOT(setWidgetToWrap(TQWidget*)));
+ delete d->widget;
+ d->widget=widgetToWrap;
+ KDockWidget *tmp=d->widgetContainer;
+
+ TQString finalTabCaption;
+ if (tabCaption == 0) {
+ finalTabCaption = widgetToWrap->caption();
+ if (finalTabCaption.isEmpty() && !widgetToWrap->icon()) {
+ finalTabCaption = widgetToWrap->name();
+ }
+ }
+ else {
+ finalTabCaption = tabCaption;
+ }
+
+ if (!tmp) {
+ tmp = mdiMainFrm->createDockWidget( widgetToWrap->name(),
+ widgetToWrap->icon()?(*(widgetToWrap->icon())):TQPixmap(),
+ 0L, // parent
+ widgetToWrap->caption(),
+ finalTabCaption );
+ d->widgetContainer= tmp;
+ if (tabToolTip!=0) {
+ d->widgetContainer->setToolTipString(tabToolTip);
+ }
+ }
+ else {
+ tmp->setCaption(widgetToWrap->caption());
+ tmp->setTabPageLabel(finalTabCaption);
+ tmp->setPixmap(widgetToWrap->icon()?(*(widgetToWrap->icon())):TQPixmap());
+ tmp->setName(widgetToWrap->name());
+ if (tabToolTip!=0) {
+ d->widgetContainer->setToolTipString(tabToolTip);
+ }
+ }
+ tmp->setWidget(widgetToWrap);
+ mdiMainFrm->m_toolViews->insert(widgetToWrap,this);
+ mdiMainFrm->m_guiClient->addToolView(this);
+
+ d->widget->installEventFilter(this);
+}
+
+
+bool ToolViewAccessor::eventFilter(TQObject *o, TQEvent *e) {
+ if (e->type()==TQEvent::IconChange) {
+ d->widgetContainer->setPixmap(d->widget->icon()?(*d->widget->icon()):TQPixmap());
+ }
+ return false;
+}
+
+void ToolViewAccessor::placeAndShow(KDockWidget::DockPosition pos, TQWidget* pTargetWnd ,int percent)
+{
+ place(pos,pTargetWnd,percent);
+ show();
+}
+void ToolViewAccessor::place(KDockWidget::DockPosition pos, TQWidget* pTargetWnd ,int percent)
+{
+ Q_ASSERT(d->widgetContainer);
+ if (!d->widgetContainer) return;
+ if (pos == KDockWidget::DockNone) {
+ d->widgetContainer->setEnableDocking(KDockWidget::DockNone);
+ d->widgetContainer->reparent(mdiMainFrm, (WFlags)(WType_TopLevel | WType_Dialog), TQPoint(0,0), mdiMainFrm->isVisible());
+ }
+ else { // add (and dock) the toolview as DockWidget view
+
+ KDockWidget* pCover = d->widgetContainer;
+
+ KDockWidget* pTargetDock = 0L;
+ if (pTargetWnd->inherits("KDockWidget") || pTargetWnd->inherits("KDockWidget_Compat::KDockWidget")) {
+ pTargetDock = (KDockWidget*) pTargetWnd;
+ }
+
+ // Should we dock to ourself?
+ bool DockToOurself = false;
+ if (mdiMainFrm->getMainDockWidget()) {
+ if (pTargetWnd == mdiMainFrm->getMainDockWidget()->getWidget()) {
+ DockToOurself = true;
+ pTargetDock = mdiMainFrm->getMainDockWidget();
+ }
+ else if (pTargetWnd == mdiMainFrm->getMainDockWidget()) {
+ DockToOurself = true;
+ pTargetDock = mdiMainFrm->getMainDockWidget();
+ }
+ }
+ // this is not inheriting TQWidget*, its plain impossible that this condition is true
+ //if (pTargetWnd == this) DockToOurself = true;
+ if (!DockToOurself) if(pTargetWnd != 0L) {
+ pTargetDock = mdiMainFrm->dockManager->findWidgetParentDock( pTargetWnd);
+ if (!pTargetDock) {
+ if (pTargetWnd->parentWidget()) {
+ pTargetDock = mdiMainFrm->dockManager->findWidgetParentDock( pTargetWnd->parentWidget());
+ }
+ }
+ }
+ /* if (!pTargetDock || pTargetWnd == mdiMainFrm->getMainDockWidget()) {
+ if (mdiMainFrm->m_managedDockPositionMode && (mdiMainFrm->m_pMdi || mdiMainFrm->m_documentTabWidget)) {
+ KDockWidget *dw1=pTargetDock->findNearestDockWidget(pos);
+ if (dw1)
+ pCover->manualDock(dw1,KDockWidget::DockCenter,percent);
+ else
+ pCover->manualDock ( pTargetDock, pos, 20 );
+ return;
+ }
+ }*/ //TODO
+ pCover->manualDock( pTargetDock, pos, percent);
+//check pCover->show();
+ }
+}
+
+void ToolViewAccessor::hide() {
+ Q_ASSERT(d->widgetContainer);
+ if (!d->widgetContainer) return;
+ d->widgetContainer->undock();
+}
+
+void ToolViewAccessor::show() {
+ Q_ASSERT(d->widgetContainer);
+ if (!d->widgetContainer) return;
+ d->widgetContainer->makeDockVisible();
+}
+
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/tdemdi/tdemdi/toolviewaccessor.h b/tdemdi/tdemdi/toolviewaccessor.h
new file mode 100644
index 000000000..75d9a863e
--- /dev/null
+++ b/tdemdi/tdemdi/toolviewaccessor.h
@@ -0,0 +1,88 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KMDI_TOOLVIEWACCESSOR_H_
+#define _KMDI_TOOLVIEWACCESSOR_H_
+
+#include <tqwidget.h>
+#include <tqpixmap.h>
+#include <tqrect.h>
+#include <tqapplication.h>
+#include <tqdatetime.h>
+
+#include <kdockwidget.h>
+
+namespace KMDIPrivate {
+ class GUIClient;
+ class ToolViewAccessorPrivate;
+}
+
+namespace KMDI {
+
+class MainWindow;
+
+class ToolViewAccessor : public TQObject
+{
+ Q_OBJECT
+
+ friend class KMDI::MainWindow;
+ friend class KMDIPrivate::GUIClient;
+
+private:
+ /**
+ * Internally used by KMDI::MainWindow to store a temporary information that the method
+ * activate() is unnecessary and that it can by escaped.
+ * This saves from unnecessary calls when activate is called directly.
+ */
+ bool m_bInterruptActivation;
+ /**
+ * Internally used to prevent cycles between KMDI::MainWindow::activateView() and KMdiChildView::activate().
+ */
+ bool m_bMainframesActivateViewIsPending;
+ /**
+ *
+ */
+ bool m_bFocusInEventIsPending;
+
+private:
+ ToolViewAccessor( KMDI::MainWindow *parent , TQWidget *widgetToWrap, const TQString& tabToolTip = 0, const TQString& tabCaption = 0);
+ ToolViewAccessor( KMDI::MainWindow *parent);
+public:
+ ~ToolViewAccessor();
+ TQWidget *wrapperWidget();
+ TQWidget *wrappedWidget();
+ void place(KDockWidget::DockPosition pos = KDockWidget::DockNone, TQWidget* pTargetWnd = 0L,int percent = 50);
+ void placeAndShow(KDockWidget::DockPosition pos = KDockWidget::DockNone, TQWidget* pTargetWnd = 0L,int percent = 50);
+ void show();
+public slots:
+ void setWidgetToWrap(TQWidget* widgetToWrap, const TQString& tabToolTip = 0, const TQString& tabCaption = 0);
+ void hide();
+private:
+ KMDIPrivate::ToolViewAccessorPrivate *d;
+ KMDI::MainWindow *mdiMainFrm;
+
+protected:
+ bool eventFilter(TQObject *o, TQEvent *e);
+};
+
+}
+
+#endif //_KMDITOOLVIEWACCESSOR_H_
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/tdemdi/tdemdi/toolviewaccessor_p.h b/tdemdi/tdemdi/toolviewaccessor_p.h
new file mode 100644
index 000000000..71ffb286a
--- /dev/null
+++ b/tdemdi/tdemdi/toolviewaccessor_p.h
@@ -0,0 +1,60 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KMDI_TOOLVIEW_ACCESSOR_PRIVATE_H_
+#define KMDI_TOOLVIEW_ACCESSOR_PRIVATE_H_
+
+#include <kdockwidget.h>
+#include <tqguardedptr.h>
+#include <kaction.h>
+
+namespace KMDIPrivate
+{
+
+class ToolViewAccessorPrivate
+{
+ public:
+ ToolViewAccessorPrivate()
+ : widgetContainer (0)
+ , widget (0)
+ {
+ }
+
+ ~ToolViewAccessorPrivate()
+ {
+ delete action;
+
+ if (!widgetContainer.isNull())
+ widgetContainer->undock();
+
+ delete (KDockWidget*)widgetContainer;
+ }
+
+ TQGuardedPtr<KDockWidget> widgetContainer;
+ TQWidget *widget;
+ TQGuardedPtr<KAction> action;
+};
+
+}
+
+#endif
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
+
+