lib Library API Documentation

kotooldockmanager.cpp

00001 /*
00002  * This file is part of the KDE project
00003  * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #include "kdebug.h"
00021 
00022 #include "kotooldockmanager.h"
00023 #include "kotooldockbase.h"
00024 
00025 #include <qapplication.h>
00026 #include <qcursor.h>
00027 
00028 KoToolDockManager::KoToolDockManager( QWidget* parent, const char* name )
00029     : QObject(parent,name)
00030 {
00031     m_pView = parent;
00032     m_pView -> installEventFilter(this);
00033     connect(&timer,SIGNAL(timeout()),SLOT(slotTimeOut()));
00034     timer.start(1000);
00035 }
00036 
00037 KoToolDockManager::~KoToolDockManager()
00038 {
00039 }
00040 
00041 void KoToolDockManager::slotTimeOut()
00042 {
00043     QPoint p = m_pView -> mapFromGlobal(QCursor::pos());
00044     for (KoToolDockBase* b = tools.first(); b; b = tools.next() ) {
00045         b -> mouseStatus(b -> geometry().contains(p));
00046     }
00047 }
00048 
00049 void KoToolDockManager::addToolWindow( KoToolDockBase* t )
00050 {
00051     tools.append(t);
00052     connect(t,SIGNAL(destroyed()),SLOT(removeToolWindow()));
00053 }
00054 
00055 void KoToolDockManager::removeToolWindow( KoToolDockBase* t )
00056 {
00057     tools.removeRef(t);
00058 }
00059 
00060 void KoToolDockManager::removeToolWindow()
00061 {
00062     removeToolWindow((KoToolDockBase*)sender());
00063 }
00064 
00065 bool KoToolDockManager::eventFilter( QObject* obj, QEvent* ev )
00066 {
00067     if (obj == m_pView && ev -> type() == QEvent::Resize ) {
00068         for (KoToolDockBase* b = tools.first(); b; b = tools.next() ) {
00069             QRect g = b -> geometry();
00070             if (b -> snaps.get(KoToolDockRight) == m_pView) {
00071                 if (b -> snaps.get(KoToolDockLeft) == m_pView) {
00072                     g.setWidth(m_pView -> width());
00073                 } else {
00074                     g.moveTopLeft(QPoint(m_pView -> width()-b -> width(), g.y()));
00075                 }
00076             }
00077             if (b -> snaps.get(KoToolDockBottom) == m_pView) {
00078                 if (b -> snaps.get(KoToolDockTop) == m_pView) {
00079                     g.setHeight(m_pView -> height());
00080                 } else {
00081                     g.moveTopLeft(QPoint(g.x(), m_pView -> height() - b -> height()));
00082                 }
00083             }
00084             if (b -> geometry()!=g)
00085                 b -> setGeometry(g);
00086         }
00087         return false;
00088     }
00089 
00090     return false;
00091 }
00092 
00093 KoToolDockBase* KoToolDockManager::createSimpleToolDock( QWidget* view, const char* name )
00094 {
00095     KoToolDockBase* b = new KoToolDockBase(m_pView, name);
00096     b -> setView(view);
00097     addToolWindow(b);
00098     return b;
00099 }
00100 
00101 KoTabbedToolDock* KoToolDockManager::createTabbedToolDock( const char* name )
00102 {
00103     KoTabbedToolDock* b = new KoTabbedToolDock(m_pView, name);
00104     addToolWindow(b);
00105     return b;
00106 }
00107 
00108 
00109 
00110 #include "kotooldockmanager.moc"
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:40:13 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003