• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdemdi/tdemdi
 

tdemdi/tdemdi

  • tdemdi
  • tdemdi
toolviewaccessor.cpp
1/* This file is part of the KDE libraries
2 Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include <kdebug.h>
21
22#include "toolviewaccessor_p.h"
23#include "guiclient.h"
24#include "mainwindow.h"
25
26#include "toolviewaccessor.h"
27#include "toolviewaccessor.moc"
28
29#include "toolviewaccessor_p.h"
30
31namespace KMDI
32{
33
34ToolViewAccessor::ToolViewAccessor( KMDI::MainWindow *parent, TQWidget *widgetToWrap, const TQString& tabToolTip, const TQString& tabCaption)
35: TQObject(parent)
36{
37 mdiMainFrm=parent;
38 d=new KMDIPrivate::ToolViewAccessorPrivate();
39 if (widgetToWrap->inherits("KDockWidget")) {
40 d->widgetContainer=dynamic_cast<KDockWidget*>(widgetToWrap);
41 d->widget=d->widgetContainer->getWidget();
42 } else {
43 d->widget=widgetToWrap;
44 TQString finalTabCaption;
45 if (tabCaption == 0) {
46 finalTabCaption = widgetToWrap->caption();
47 if (finalTabCaption.isEmpty() && !widgetToWrap->icon()) {
48 finalTabCaption = widgetToWrap->name();
49 }
50 }
51 else {
52 finalTabCaption = tabCaption;
53 }
54 d->widgetContainer= parent->createDockWidget( widgetToWrap->name(),
55 (widgetToWrap->icon()?(*(widgetToWrap->icon())):TQPixmap()),
56 0L, // parent
57 widgetToWrap->caption(),
58 finalTabCaption);
59 d->widgetContainer->setWidget(widgetToWrap);
60 if (tabToolTip!=0) {
61 d->widgetContainer->setToolTipString(tabToolTip);
62 }
63 }
64
65 //mdiMainFrm->m_toolViews.insert(d->widget,this);
66 mdiMainFrm->m_guiClient->addToolView(this);
67 d->widget->installEventFilter(this);
68}
69
70ToolViewAccessor::ToolViewAccessor( KMDI::MainWindow *parent) : TQObject(parent) {
71 mdiMainFrm=parent;
72 d=new KMDIPrivate::ToolViewAccessorPrivate();
73}
74
75ToolViewAccessor::~ToolViewAccessor() {
76 if (mdiMainFrm->m_toolViews)
77 mdiMainFrm->m_toolViews->remove(d->widget);
78 delete d;
79
80}
81
82TQWidget *ToolViewAccessor::wrapperWidget() {
83 if (!d->widgetContainer) {
84 d->widgetContainer=mdiMainFrm->createDockWidget( "ToolViewAccessor::null",TQPixmap());
85 connect(d->widgetContainer,TQ_SIGNAL(widgetSet(TQWidget*)),this,TQ_SLOT(setWidgetToWrap(TQWidget*)));
86 }
87 return d->widgetContainer;
88}
89
90TQWidget *ToolViewAccessor::wrappedWidget() {
91 return d->widget;
92}
93
94
95void ToolViewAccessor::setWidgetToWrap(TQWidget *widgetToWrap, const TQString& tabToolTip, const TQString& tabCaption)
96{
97 Q_ASSERT(!(d->widget));
98 Q_ASSERT(!widgetToWrap->inherits("KDockWidget"));
99 disconnect(d->widgetContainer,TQ_SIGNAL(widgetSet(TQWidget*)),this,TQ_SLOT(setWidgetToWrap(TQWidget*)));
100 delete d->widget;
101 d->widget=widgetToWrap;
102 KDockWidget *tmp=d->widgetContainer;
103
104 TQString finalTabCaption;
105 if (tabCaption == 0) {
106 finalTabCaption = widgetToWrap->caption();
107 if (finalTabCaption.isEmpty() && !widgetToWrap->icon()) {
108 finalTabCaption = widgetToWrap->name();
109 }
110 }
111 else {
112 finalTabCaption = tabCaption;
113 }
114
115 if (!tmp) {
116 tmp = mdiMainFrm->createDockWidget( widgetToWrap->name(),
117 widgetToWrap->icon()?(*(widgetToWrap->icon())):TQPixmap(),
118 0L, // parent
119 widgetToWrap->caption(),
120 finalTabCaption );
121 d->widgetContainer= tmp;
122 if (tabToolTip!=0) {
123 d->widgetContainer->setToolTipString(tabToolTip);
124 }
125 }
126 else {
127 tmp->setCaption(widgetToWrap->caption());
128 tmp->setTabPageLabel(finalTabCaption);
129 tmp->setPixmap(widgetToWrap->icon()?(*(widgetToWrap->icon())):TQPixmap());
130 tmp->setName(widgetToWrap->name());
131 if (tabToolTip!=0) {
132 d->widgetContainer->setToolTipString(tabToolTip);
133 }
134 }
135 tmp->setWidget(widgetToWrap);
136 mdiMainFrm->m_toolViews->insert(widgetToWrap,this);
137 mdiMainFrm->m_guiClient->addToolView(this);
138
139 d->widget->installEventFilter(this);
140}
141
142
143bool ToolViewAccessor::eventFilter(TQObject *o, TQEvent *e) {
144 if (e->type()==TQEvent::IconChange) {
145 d->widgetContainer->setPixmap(d->widget->icon()?(*d->widget->icon()):TQPixmap());
146 }
147 return false;
148}
149
150void ToolViewAccessor::placeAndShow(KDockWidget::DockPosition pos, TQWidget* pTargetWnd ,int percent)
151{
152 place(pos,pTargetWnd,percent);
153 show();
154}
155void ToolViewAccessor::place(KDockWidget::DockPosition pos, TQWidget* pTargetWnd ,int percent)
156{
157 Q_ASSERT(d->widgetContainer);
158 if (!d->widgetContainer) return;
159 if (pos == KDockWidget::DockNone) {
160 d->widgetContainer->setEnableDocking(KDockWidget::DockNone);
161 d->widgetContainer->reparent(mdiMainFrm, (WFlags)(WType_TopLevel | WType_Dialog), TQPoint(0,0), mdiMainFrm->isVisible());
162 }
163 else { // add (and dock) the toolview as DockWidget view
164
165 KDockWidget* pCover = d->widgetContainer;
166
167 KDockWidget* pTargetDock = 0L;
168 if (pTargetWnd->inherits("KDockWidget") || pTargetWnd->inherits("KDockWidget_Compat::KDockWidget")) {
169 pTargetDock = (KDockWidget*) pTargetWnd;
170 }
171
172 // Should we dock to ourself?
173 bool DockToOurself = false;
174 if (mdiMainFrm->getMainDockWidget()) {
175 if (pTargetWnd == mdiMainFrm->getMainDockWidget()->getWidget()) {
176 DockToOurself = true;
177 pTargetDock = mdiMainFrm->getMainDockWidget();
178 }
179 else if (pTargetWnd == mdiMainFrm->getMainDockWidget()) {
180 DockToOurself = true;
181 pTargetDock = mdiMainFrm->getMainDockWidget();
182 }
183 }
184 // this is not inheriting TQWidget*, its plain impossible that this condition is true
185 //if (pTargetWnd == this) DockToOurself = true;
186 if (!DockToOurself) if(pTargetWnd != 0L) {
187 pTargetDock = mdiMainFrm->dockManager->findWidgetParentDock( pTargetWnd);
188 if (!pTargetDock) {
189 if (pTargetWnd->parentWidget()) {
190 pTargetDock = mdiMainFrm->dockManager->findWidgetParentDock( pTargetWnd->parentWidget());
191 }
192 }
193 }
194 /* if (!pTargetDock || pTargetWnd == mdiMainFrm->getMainDockWidget()) {
195 if (mdiMainFrm->m_managedDockPositionMode && (mdiMainFrm->m_pMdi || mdiMainFrm->m_documentTabWidget)) {
196 KDockWidget *dw1=pTargetDock->findNearestDockWidget(pos);
197 if (dw1)
198 pCover->manualDock(dw1,KDockWidget::DockCenter,percent);
199 else
200 pCover->manualDock ( pTargetDock, pos, 20 );
201 return;
202 }
203 }*/ //TODO
204 pCover->manualDock( pTargetDock, pos, percent);
205//check pCover->show();
206 }
207}
208
209void ToolViewAccessor::hide() {
210 Q_ASSERT(d->widgetContainer);
211 if (!d->widgetContainer) return;
212 d->widgetContainer->undock();
213}
214
215void ToolViewAccessor::show() {
216 Q_ASSERT(d->widgetContainer);
217 if (!d->widgetContainer) return;
218 d->widgetContainer->makeDockVisible();
219}
220
221}
KMDI
A namespace for the KMDI library.
Definition dockcontainer.cpp:52

tdemdi/tdemdi

Skip menu "tdemdi/tdemdi"
  • Main Page
  • Namespace List
  • File List
  • Namespace Members

tdemdi/tdemdi

Skip menu "tdemdi/tdemdi"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdemdi/tdemdi by doxygen 1.9.8
This website is maintained by Timothy Pearson.