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

tdemdi

  • tdemdi
tdemditoolviewaccessor.cpp
1 //----------------------------------------------------------------------------
2 // filename : tdemditoolviewaccessor.h
3 //----------------------------------------------------------------------------
4 // Project : KDE MDI extension
5 //
6 // begin : 08/2003 by Joseph Wenninger (jowenn@kde.org)
7 // changes : ---
8 // patches : ---
9 //
10 // copyright : (C) 2003 by Joseph Wenninger (jowenn@kde.org)
11 //----------------------------------------------------------------------------
12 //
13 //----------------------------------------------------------------------------
14 //
15 // This program is free software; you can redistribute it and/or modify
16 // it under the terms of the GNU Library General Public License as
17 // published by the Free Software Foundation; either version 2 of the
18 // License, or (at your option) any later version.
19 //
20 //----------------------------------------------------------------------------
21 
22 #ifndef NO_KDE
23 # include <kdebug.h>
24 #endif
25 #include "tdemditoolviewaccessor_p.h"
26 #include "tdemdiguiclient.h"
27 #include "tdemdimainfrm.h"
28 
29 #include "tdemditoolviewaccessor.h"
30 #include "tdemditoolviewaccessor_p.h"
31 
32 KMdiToolViewAccessor::KMdiToolViewAccessor( KMdiMainFrm *parent, TQWidget *widgetToWrap, const TQString& tabToolTip, const TQString& tabCaption )
33  : TQObject( parent )
34 {
35  mdiMainFrm = parent;
36  d = new KMdiToolViewAccessorPrivate();
37  if ( widgetToWrap->inherits( "KDockWidget" ) )
38  {
39  d->widgetContainer = tqt_dynamic_cast<KDockWidget*>( widgetToWrap );
40  d->widget = d->widgetContainer->getWidget();
41  }
42  else
43  {
44  d->widget = widgetToWrap;
45  TQString finalTabCaption;
46  if ( tabCaption == 0 )
47  {
48  finalTabCaption = widgetToWrap->caption();
49  if ( finalTabCaption.isEmpty() && !widgetToWrap->icon() )
50  {
51  finalTabCaption = widgetToWrap->name();
52  }
53  }
54  else
55  {
56  finalTabCaption = tabCaption;
57  }
58  d->widgetContainer = parent->createDockWidget( widgetToWrap->name(),
59  ( widgetToWrap->icon() ? ( *( widgetToWrap->icon() ) ) : TQPixmap() ),
60  0L, // parent
61  widgetToWrap->caption(),
62  finalTabCaption );
63  d->widgetContainer->setWidget( widgetToWrap );
64  if ( tabToolTip != 0 )
65  {
66  d->widgetContainer->setToolTipString( tabToolTip );
67  }
68  }
69  //mdiMainFrm->m_pToolViews->insert(d->widget,this);
70  if ( mdiMainFrm->m_mdiGUIClient )
71  mdiMainFrm->m_mdiGUIClient->addToolView( this );
72  else
73  kdDebug( 760 ) << "mdiMainFrm->m_mdiGUIClient == 0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl;
74 
75  d->widget->installEventFilter( this );
76 }
77 
78 KMdiToolViewAccessor::KMdiToolViewAccessor( KMdiMainFrm *parent )
79 {
80  mdiMainFrm = parent;
81  d = new KMdiToolViewAccessorPrivate();
82 }
83 
84 KMdiToolViewAccessor::~KMdiToolViewAccessor()
85 {
86  if ( mdiMainFrm->m_pToolViews )
87  mdiMainFrm->m_pToolViews->remove
88  ( d->widget );
89  delete d;
90 
91 }
92 
93 TQWidget *KMdiToolViewAccessor::wrapperWidget()
94 {
95  if ( !d->widgetContainer )
96  {
97  d->widgetContainer = mdiMainFrm->createDockWidget( "KMdiToolViewAccessor::null", TQPixmap() );
98  connect( d->widgetContainer, TQT_SIGNAL( widgetSet( TQWidget* ) ), this, TQT_SLOT( setWidgetToWrap( TQWidget* ) ) );
99  }
100  return d->widgetContainer;
101 }
102 
103 TQWidget *KMdiToolViewAccessor::wrappedWidget()
104 {
105  return d->widget;
106 }
107 
108 
109 void KMdiToolViewAccessor::setWidgetToWrap( TQWidget *widgetToWrap, const TQString& tabToolTip, const TQString& tabCaption )
110 {
111  Q_ASSERT( !( d->widget ) );
112  Q_ASSERT( !widgetToWrap->inherits( "KDockWidget" ) );
113  disconnect( d->widgetContainer, TQT_SIGNAL( widgetSet( TQWidget* ) ), this, TQT_SLOT( setWidgetToWrap( TQWidget* ) ) );
114  delete d->widget;
115  d->widget = widgetToWrap;
116  KDockWidget *tmp = d->widgetContainer;
117 
118  TQString finalTabCaption;
119  if ( tabCaption == 0 )
120  {
121  finalTabCaption = widgetToWrap->caption();
122  if ( finalTabCaption.isEmpty() && !widgetToWrap->icon() )
123  {
124  finalTabCaption = widgetToWrap->name();
125  }
126  }
127  else
128  {
129  finalTabCaption = tabCaption;
130  }
131 
132  if ( !tmp )
133  {
134  tmp = mdiMainFrm->createDockWidget( widgetToWrap->name(),
135  widgetToWrap->icon() ? ( *( widgetToWrap->icon() ) ) : TQPixmap(),
136  0L, // parent
137  widgetToWrap->caption(),
138  finalTabCaption );
139  d->widgetContainer = tmp;
140  if ( tabToolTip != 0 )
141  {
142  d->widgetContainer->setToolTipString( tabToolTip );
143  }
144  }
145  else
146  {
147  tmp->setCaption( widgetToWrap->caption() );
148  tmp->setTabPageLabel( finalTabCaption );
149  tmp->setPixmap( widgetToWrap->icon() ? ( *( widgetToWrap->icon() ) ) : TQPixmap() );
150  tmp->setName( widgetToWrap->name() );
151  if ( tabToolTip != 0 )
152  {
153  d->widgetContainer->setToolTipString( tabToolTip );
154  }
155  }
156  tmp->setWidget( widgetToWrap );
157  mdiMainFrm->m_pToolViews->insert( widgetToWrap, this );
158  if ( mdiMainFrm->m_mdiGUIClient )
159  mdiMainFrm->m_mdiGUIClient->addToolView( this );
160  else
161  kdDebug( 760 ) << "mdiMainFrm->m_mdiGUIClient == 0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl;
162 
163  d->widget->installEventFilter( this );
164 }
165 
166 
167 bool KMdiToolViewAccessor::eventFilter( TQObject *, TQEvent *e )
168 {
169  if ( e->type() == TQEvent::IconChange )
170  {
171  d->widgetContainer->setPixmap( d->widget->icon() ? ( *d->widget->icon() ) : TQPixmap() );
172  }
173  return false;
174 }
175 
176 void KMdiToolViewAccessor::placeAndShow( KDockWidget::DockPosition pos, TQWidget* pTargetWnd , int percent )
177 {
178  place( pos, pTargetWnd, percent );
179  show();
180 }
181 void KMdiToolViewAccessor::place( KDockWidget::DockPosition pos, TQWidget* pTargetWnd , int percent )
182 {
183  Q_ASSERT( d->widgetContainer );
184  if ( !d->widgetContainer )
185  return ;
186  if ( pos == KDockWidget::DockNone )
187  {
188  d->widgetContainer->setEnableDocking( KDockWidget::DockNone );
189  d->widgetContainer->reparent( mdiMainFrm, (WFlags)(WType_TopLevel | WType_Dialog), TQPoint( 0, 0 ), true ); //pToolView->isVisible());
190  }
191  else
192  { // add (and dock) the toolview as DockWidget view
193 
194  KDockWidget* pCover = d->widgetContainer;
195 
196  KDockWidget* pTargetDock = 0L;
197  if ( pTargetWnd->inherits( "KDockWidget" ) || pTargetWnd->inherits( "KDockWidget_Compat::KDockWidget" ) )
198  {
199  pTargetDock = ( KDockWidget* ) pTargetWnd;
200  }
201 
202  // Should we dock to ourself?
203  bool DockToOurself = false;
204  if ( mdiMainFrm->m_pDockbaseAreaOfDocumentViews )
205  {
206  if ( pTargetWnd == mdiMainFrm->m_pDockbaseAreaOfDocumentViews->getWidget() )
207  {
208  DockToOurself = true;
209  pTargetDock = mdiMainFrm->m_pDockbaseAreaOfDocumentViews;
210  }
211  else if ( pTargetWnd == mdiMainFrm->m_pDockbaseAreaOfDocumentViews )
212  {
213  DockToOurself = true;
214  pTargetDock = mdiMainFrm->m_pDockbaseAreaOfDocumentViews;
215  }
216  }
217  // this is not inheriting TQWidget*, its plain impossible that this condition is true
218  //if (pTargetWnd == this) DockToOurself = true;
219  if ( !DockToOurself )
220  if ( pTargetWnd != 0L )
221  {
222  pTargetDock = mdiMainFrm->dockManager->findWidgetParentDock( pTargetWnd );
223  if ( !pTargetDock )
224  {
225  if ( pTargetWnd->parentWidget() )
226  {
227  pTargetDock = mdiMainFrm->dockManager->findWidgetParentDock( pTargetWnd->parentWidget() );
228  }
229  }
230  }
231  if ( !pTargetDock || pTargetWnd == mdiMainFrm->getMainDockWidget() )
232  {
233  if ( mdiMainFrm->m_managedDockPositionMode && ( mdiMainFrm->m_pMdi || mdiMainFrm->m_documentTabWidget ) )
234  {
235  KDockWidget * dw1 = pTargetDock->findNearestDockWidget( pos );
236  if ( dw1 )
237  pCover->manualDock( dw1, KDockWidget::DockCenter, percent );
238  else
239  pCover->manualDock ( pTargetDock, pos, 20 );
240  return ;
241  }
242  }
243  pCover->manualDock( pTargetDock, pos, percent );
244  //check pCover->show();
245  }
246 }
247 
248 void KMdiToolViewAccessor::hide()
249 {
250  Q_ASSERT( d->widgetContainer );
251  if ( !d->widgetContainer )
252  return ;
253  d->widgetContainer->undock();
254 }
255 
256 void KMdiToolViewAccessor::show()
257 {
258  Q_ASSERT( d->widgetContainer );
259  if ( !d->widgetContainer )
260  return ;
261  d->widgetContainer->makeDockVisible();
262 }
263 
264 
265 #ifndef NO_INCLUDE_MOCFILES
266 #include "tdemditoolviewaccessor.moc"
267 #endif
KMdiMainFrm
Base class for all your special main frames.
Definition: tdemdimainfrm.h:239

tdemdi

Skip menu "tdemdi"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdemdi

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