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

tdemdi

  • tdemdi
tdemdichildarea.cpp
1 //----------------------------------------------------------------------------
2 // filename : tdemdichildarea.cpp
3 //----------------------------------------------------------------------------
4 // Project : KDE MDI extension
5 //
6 // begin : 07/1999 by Szymon Stefanek as part of kvirc
7 // (an IRC application)
8 // changes : 09/1999 by Falk Brettschneider to create an
9 // - 06/2000 stand-alone Qt extension set of
10 // classes and a Qt-based library
11 // 2000-2003 maintained by the KDevelop project
12 //
13 // copyright : (C) 1999-2003 by Szymon Stefanek (stefanek@tin.it)
14 // and
15 // Falk Brettschneider
16 // email : falkbr@kdevelop.org (Falk Brettschneider)
17 //----------------------------------------------------------------------------
18 //
19 //----------------------------------------------------------------------------
20 //
21 // This program is free software; you can redistribute it and/or modify
22 // it under the terms of the GNU Library General Public License as
23 // published by the Free Software Foundation; either version 2 of the
24 // License, or (at your option) any later version.
25 //
26 //----------------------------------------------------------------------------
27 
28 #include "tdemdichildarea.h"
29 #include "tdemdichildarea.moc"
30 
31 #include "tdemdidefines.h"
32 
33 #include <tdeconfig.h>
34 #include <kdebug.h>
35 #include <tdeglobal.h>
36 #include <tdeglobalsettings.h>
37 
38 #include <math.h>
39 #include <tqpopupmenu.h>
40 
41 
43 // KMdiChildArea
45 
46 //============ KMdiChildArea ============//
47 
48 KMdiChildArea::KMdiChildArea( TQWidget *parent )
49  : TQFrame( parent, "tdemdi_childarea" )
50 {
51  setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
52  m_captionFont = TQFont();
53  TQFontMetrics fm( m_captionFont );
54  m_captionFontLineSpacing = fm.lineSpacing();
55  m_captionActiveBackColor = TDEGlobalSettings::activeTitleColor();
56  m_captionActiveForeColor = TDEGlobalSettings::activeTextColor();
57  m_captionInactiveBackColor = TDEGlobalSettings::inactiveTitleColor();
58  m_captionInactiveForeColor = TDEGlobalSettings::inactiveTextColor();
59  m_pZ = new TQPtrList<KMdiChildFrm>;
60  m_pZ->setAutoDelete( true );
61  setFocusPolicy( TQ_ClickFocus );
62  m_defaultChildFrmSize = TQSize( 400, 300 );
63 }
64 
65 
66 KMdiChildArea::~KMdiChildArea()
67 {
68  delete m_pZ; //This will destroy all the widgets inside.
69 }
70 
71 
72 void KMdiChildArea::manageChild( KMdiChildFrm* child, bool show, bool cascade )
73 {
74  kdDebug( 760 ) << k_funcinfo << "Adding child " << child << " to be managed" << endl;
75  KMdiChildFrm* top = topChild();
76 
77  //remove old references. There can be more than one so we remove them all
78  if ( m_pZ->findRef( child ) != -1 )
79  {
80  //TQPtrList::find* moves current() to the found item
81  m_pZ->take();
82  while ( m_pZ->findNextRef( child ) != -1 )
83  m_pZ->take();
84  }
85 
86  if ( show )
87  m_pZ->append( child ); //visible -> first in the Z order
88  else
89  m_pZ->insert( 0, child ); //hidden -> last in the Z order
90 
91  if ( cascade )
92  child->move( getCascadePoint( m_pZ->count() - 1 ) );
93 
94  if ( show )
95  {
96  if ( top && top->state() == KMdiChildFrm::Maximized )
97  {
98  kdDebug( 760 ) << k_funcinfo << "Maximizing the new child" << endl;
99  emit sysButtonConnectionsMustChange( top, child );
100  top->setState( KMdiChildFrm::Normal, false /*animate*/ );
101  child->setState( KMdiChildFrm::Maximized, false /*animate*/ );
102  }
103  child->show();
104  focusTopChild();
105  }
106 }
107 
108 
109 void KMdiChildArea::destroyChild( KMdiChildFrm *child, bool focusTop )
110 {
111  kdDebug( 760 ) << k_funcinfo << "Removing child " << child->caption() << endl;
112  bool wasMaximized = ( child->state() == KMdiChildFrm::Maximized );
113 
114  // destroy the old one
115  disconnect( child );
116  child->blockSignals( true );
117  m_pZ->setAutoDelete( false );
118  m_pZ->removeRef( child );
119 
120  // focus the next new childframe
121  KMdiChildFrm* newTopChild = topChild();
122  if ( wasMaximized )
123  {
124  if ( newTopChild )
125  {
126  newTopChild->setState( KMdiChildFrm::Maximized, false );
127  emit sysButtonConnectionsMustChange( child, newTopChild );
128  }
129  else
130  emit noMaximizedChildFrmLeft( child ); // last childframe removed
131  }
132 
133  delete child;
134  m_pZ->setAutoDelete( true );
135 
136  if ( focusTop )
137  focusTopChild();
138 }
139 
140 
141 void KMdiChildArea::destroyChildButNotItsView( KMdiChildFrm* child, bool focusTop )
142 {
143  kdDebug( 760 ) << k_funcinfo << "Removing child " << child->caption() << endl;
144  bool wasMaximized = ( child->state() == KMdiChildFrm::Maximized );
145 
146  // destroy the old one
147  disconnect( child );
148  child->unsetClient();
149  m_pZ->setAutoDelete( false );
150  m_pZ->removeRef( child );
151 
152  // focus the next new childframe
153  KMdiChildFrm* newTopChild = topChild();
154  if ( wasMaximized )
155  {
156  if ( newTopChild )
157  {
158  newTopChild->setState( KMdiChildFrm::Maximized, false );
159  emit sysButtonConnectionsMustChange( child, newTopChild );
160  }
161  else
162  emit noMaximizedChildFrmLeft( child ); // last childframe removed
163  }
164  delete child;
165  m_pZ->setAutoDelete( true );
166 
167  if ( focusTop )
168  focusTopChild();
169 }
170 
171 void KMdiChildArea::setTopChild( KMdiChildFrm* child, bool /* bSetFocus */ )
172 {
173  if ( !child )
174  return;
175 
176  if ( topChild() != child )
177  {
178  kdDebug( 760 ) << k_funcinfo << "Setting " << child->caption() << " as the new top child" << endl;
179  m_pZ->setAutoDelete( false );
180  if ( child )
181  m_pZ->removeRef( child );
182  m_pZ->setAutoDelete( true );
183 
184  //disable the labels of all the other children
185  TQPtrListIterator<KMdiChildFrm> it( *m_pZ );
186  for ( ; ( *it ); ++it )
187  ( *it )->m_pCaption->setActive( false );
188 
189  KMdiChildFrm* maximizedChild = topChild();
190  bool topChildMaximized = false;
191  if ( maximizedChild && maximizedChild->state() == KMdiChildFrm::Maximized )
192  topChildMaximized = true;
193 
194  m_pZ->append( child );
195 
196  int nChildAreaMinW = 0, nChildAreaMinH = 0;
197  int nChildAreaMaxW = TQWIDGETSIZE_MAX, nChildAreaMaxH = TQWIDGETSIZE_MAX;
198  if ( topChildMaximized && child->m_pClient )
199  {
200  //the former top child is maximized, so maximize the new one
201  nChildAreaMinW = child->m_pClient->minimumWidth();
202  nChildAreaMinH = child->m_pClient->minimumHeight();
204  // nChildAreaMaxW = child->m_pClient->maximumWidth();
205  // nChildAreaMaxH = child->m_pClient->maximumHeight();
206  }
207 
208  //set the min and max sizes of this child area to the new top child
209  setMinimumSize( nChildAreaMinW, nChildAreaMinH );
210  setMaximumSize( nChildAreaMaxW, nChildAreaMaxH );
211 
212  if ( topChildMaximized )
213  { //maximize the new view and restore the old
214  child->setState( KMdiChildFrm::Maximized, false /*animate*/);
215  maximizedChild->setState( KMdiChildFrm::Normal, false /*animate*/ );
216  emit sysButtonConnectionsMustChange( maximizedChild, child );
217  }
218  else
219  child->raise();
220 
221 #ifdef USE_QT4
222  child->m_pClient->setFocus();
223 #else // USE_QT4
224  TQFocusEvent::setReason( TQFocusEvent::Other );
225  child->m_pClient->setFocus();
226 #endif // USE_QT4
227  }
228 }
229 
230 
231 void KMdiChildArea::resizeEvent( TQResizeEvent* e )
232 {
233  //If we have a maximized children at the top , adjust its size
234  KMdiChildFrm* child = topChild();
235  if ( child && child->state() == KMdiChildFrm::Maximized )
236  {
237  int clientw = 0, clienth = 0;
238  if ( child->m_pClient != 0L )
239  {
240  clientw = child->m_pClient->width();
241  clienth = child->m_pClient->height();
242  }
243  child->resize( width() + KMDI_CHILDFRM_DOUBLE_BORDER,
244  height() + child->m_pCaption->heightHint() + KMDI_CHILDFRM_SEPARATOR + KMDI_CHILDFRM_DOUBLE_BORDER );
245 
246  }
247  layoutMinimizedChildren();
248  TQWidget::resizeEvent( e );
249 }
250 
251 //=============== mousePressEvent =============//
252 
253 void KMdiChildArea::mousePressEvent( TQMouseEvent *e )
254 {
255  //Popup the window menu
256  if ( e->button() & Qt::RightButton )
257  emit popupWindowMenu( mapToGlobal( e->pos() ) );
258 }
259 
260 //=============== getCascadePoint ============//
261 
262 TQPoint KMdiChildArea::getCascadePoint( int indexOfWindow )
263 {
264  if ( indexOfWindow < 0 )
265  {
266  indexOfWindow = m_pZ->count(); //use the window count
267  kdDebug( 760 ) << k_funcinfo << "indexOfWindow was less than zero, using "
268  << indexOfWindow << " as new index" << endl;
269  }
270 
271  TQPoint pnt( 0, 0 );
272  if ( indexOfWindow == 0 )
273  {
274  kdDebug( 760 ) << k_funcinfo << "No windows. Returning TQPoint( 0, 0 ) as the cascade point" << endl;
275  return pnt;
276  }
277 
278  bool topLevelMode = false;
279  if ( height() == 1 ) // hacky?!
280  topLevelMode = true;
281 
282  kdDebug( 760 ) << k_funcinfo << "Getting the cascade point for window index " << indexOfWindow << endl;
283  kdDebug( 760 ) << k_funcinfo << "Do we think we're in top level mode? " << topLevelMode << endl;
284 
285  KMdiChildFrm* child = m_pZ->first();
286 
287  //default values
288  int step = 20;
289  int h = ( topLevelMode ? TQApplication::desktop()->height() : height() );
290  int w = ( topLevelMode ? TQApplication::desktop()->width() : width() );
291 
292  int availableHeight = h - m_defaultChildFrmSize.height();
293  int availableWidth = w - m_defaultChildFrmSize.width();
294  int ax = 0;
295  int ay = 0;
296 
297  if ( child )
298  {
299  kdDebug( 760 ) << k_funcinfo << "child frame exists. resetting height and width values" << endl;
300  step = child->m_pCaption->heightHint() + KMDI_CHILDFRM_BORDER;
301  availableHeight = h - child->minimumHeight();
302  availableWidth = w - child->minimumWidth();
303  }
304 
305  for ( int i = 0; i < indexOfWindow; i++ )
306  {
307  ax += step;
308  ay += step;
309 
310  //do some bounds checking, because to not do it would be bad.
311  if ( ax > availableWidth )
312  ax = 0;
313 
314  if ( ay > availableHeight )
315  ay = 0;
316  }
317  pnt.setX( ax );
318  pnt.setY( ay );
319  return pnt;
320 }
321 
322 
323 void KMdiChildArea::childMinimized( KMdiChildFrm *minimizedChild, bool wasMaximized )
324 {
325  //can't find the child in our list, so we don't care.
326  if ( m_pZ->findRef( minimizedChild ) == -1 )
327  {
328  kdDebug( 760 ) << k_funcinfo << "child was minimized but wasn't in our list!" << endl;
329  return;
330  }
331 
332  kdDebug( 760 ) << k_funcinfo << endl;
333  if ( m_pZ->count() > 1 )
334  {
335  //move the minimized child to the bottom
336  m_pZ->setAutoDelete( false );
337  m_pZ->removeRef( minimizedChild );
338  m_pZ->setAutoDelete( true );
339  m_pZ->insert( 0, minimizedChild );
340 
341  if ( wasMaximized )
342  { // Need to maximize the new top child
343  kdDebug( 760 ) << k_funcinfo << "child just minimized from maximized state. maximize new top child" << endl;
344  minimizedChild = topChild();
345  if ( !minimizedChild )
346  return; //??
347 
348  if ( minimizedChild->state() == KMdiChildFrm::Maximized )
349  return; //it's already maximized
350 
351  minimizedChild->setState( KMdiChildFrm::Maximized, false ); //do not animate the change
352  }
353  focusTopChild();
354  }
355  else
356  setFocus(); //Remove focus from the child. We only have one window
357 }
358 
359 void KMdiChildArea::focusTopChild()
360 {
361  KMdiChildFrm* lastChild = topChild();
362  if ( !lastChild )
363  {
364  kdDebug( 760 ) << k_funcinfo << "No more child windows left" << endl;
365  emit lastChildFrmClosed();
366  return;
367  }
368 
369  if ( !lastChild->m_pClient->hasFocus() )
370  {
371  //disable the labels of all the other children
372  TQPtrListIterator<KMdiChildFrm> it ( *m_pZ );
373  for ( ; ( *it ); ++it )
374  {
375  if ( ( *it ) != lastChild )
376  ( *it )->m_pCaption->setActive( false );
377  }
378 
379  kdDebug( 760 ) << k_funcinfo << "Giving focus to " << lastChild->caption() << endl;
380  lastChild->raise();
381  lastChild->m_pClient->activate();
382  }
383 
384 }
385 
386 void KMdiChildArea::cascadeWindows()
387 {
388  kdDebug( 760 ) << k_funcinfo << "cascading windows but not changing their size" << endl;
389  int idx = 0;
390  TQPtrList<KMdiChildFrm> list( *m_pZ );
391  list.setAutoDelete( false );
392  while ( !list.isEmpty() )
393  {
394  KMdiChildFrm* childFrm = list.first();
395  if ( childFrm->state() != KMdiChildFrm::Minimized )
396  {
397  if ( childFrm->state() == KMdiChildFrm::Maximized )
398  childFrm->restorePressed();
399 
400  childFrm->move( getCascadePoint( idx ) );
401  idx++;
402  }
403  list.removeFirst();
404  }
405  focusTopChild();
406 }
407 
408 void KMdiChildArea::cascadeMaximized()
409 {
410  kdDebug( 760 ) << k_funcinfo << "cascading windows. will make sure they are minimum sized" << endl;
411  int idx = 0;
412  TQPtrList<KMdiChildFrm> list( *m_pZ );
413 
414  list.setAutoDelete( false );
415  while ( !list.isEmpty() )
416  {
417  KMdiChildFrm* childFrm = list.first();
418  if (childFrm->state() != KMdiChildFrm::Minimized )
419  {
420  if (childFrm->state() == KMdiChildFrm::Maximized )
421  childFrm->restorePressed();
422 
423  TQPoint pnt( getCascadePoint( idx ) );
424  childFrm->move( pnt );
425  TQSize curSize( width() - pnt.x(), height() - pnt.y() );
426 
427  if ( ( childFrm->minimumSize().width() > curSize.width() ) ||
428  ( childFrm->minimumSize().height() > curSize.height() ) )
429  {
430  childFrm->resize( childFrm->minimumSize() );
431  }
432  else
433  childFrm->resize( curSize );
434 
435  idx++;
436  }
437  list.removeFirst();
438  }
439  focusTopChild();
440 }
441 
442 void KMdiChildArea::expandVertical()
443 {
444  kdDebug( 760 ) << k_funcinfo << "expanding all child frames vertically" << endl;
445  int idx = 0;
446  TQPtrList<KMdiChildFrm> list( *m_pZ );
447  list.setAutoDelete( false );
448  while ( !list.isEmpty() )
449  {
450  KMdiChildFrm* childFrm = list.first();
451  if ( childFrm->state() != KMdiChildFrm::Minimized )
452  {
453  if ( childFrm->state() == KMdiChildFrm::Maximized )
454  childFrm->restorePressed();
455 
456  childFrm->setGeometry( childFrm->x(), 0, childFrm->width(), height() );
457  idx++;
458  }
459  list.removeFirst();
460  }
461  focusTopChild();
462 }
463 
464 void KMdiChildArea::expandHorizontal()
465 {
466  kdDebug( 760 ) << k_funcinfo << "expanding all child frames horizontally" << endl;
467  int idx = 0;
468  TQPtrList<KMdiChildFrm> list( *m_pZ );
469  list.setAutoDelete( false );
470  while ( !list.isEmpty() )
471  {
472  KMdiChildFrm* childFrm = list.first();
473  if ( childFrm->state() != KMdiChildFrm::Minimized )
474  {
475  if ( childFrm->state() == KMdiChildFrm::Maximized )
476  childFrm->restorePressed();
477 
478  childFrm->setGeometry( 0, childFrm->y(), width(), childFrm->height() );
479  idx++;
480  }
481  list.removeFirst();
482  }
483  focusTopChild();
484 }
485 
486 int KMdiChildArea::getVisibleChildCount() const
487 {
488  int visibleChildCount = 0;
489  TQPtrListIterator<KMdiChildFrm> it( *m_pZ );
490  for ( ; ( *it ); ++it )
491  {
492  if ( ( *it )->state() != KMdiChildFrm::Minimized && ( *it )->isVisible() )
493  visibleChildCount++;
494  }
495  return visibleChildCount;
496 }
497 
498 void KMdiChildArea::tilePragma()
499 {
500  kdDebug( 760 ) << k_funcinfo << endl;
501  tileAllInternal( 9 );
502 }
503 
504 void KMdiChildArea::tileAllInternal( int maxWnds )
505 {
506  kdDebug( 760 ) << k_funcinfo << endl;
507  //NUM WINDOWS = 1,2,3,4,5,6,7,8,9
508  static int colstable[ 9 ] = { 1, 1, 1, 2, 2, 2, 3, 3, 3 }; //num columns
509  static int rowstable[ 9 ] = { 1, 2, 3, 2, 3, 3, 3, 3, 3 }; //num rows
510  static int lastwindw[ 9 ] = { 1, 1, 1, 1, 2, 1, 3, 2, 1 }; //last window multiplier
511  static int colrecall[ 9 ] = { 0, 0, 0, 3, 3, 3, 6, 6, 6 }; //adjust self
512  static int rowrecall[ 9 ] = { 0, 0, 0, 0, 4, 4, 4, 4, 4 }; //adjust self
513 
514  int numVisible = getVisibleChildCount();
515  if ( numVisible < 1 )
516  {
517  kdDebug( 760 ) << k_funcinfo << "No visible child windows to tile" << endl;
518  return;
519  }
520 
521  KMdiChildFrm *tcw = topChild();
522  int numToHandle = ( ( numVisible > maxWnds ) ? maxWnds : numVisible );
523 
524  int xQuantum = width() / colstable[ numToHandle - 1 ];
525  int widthToCompare;
526 
527  if ( tcw->minimumWidth() > m_defaultChildFrmSize.width() )
528  widthToCompare = tcw->minimumWidth();
529  else
530  widthToCompare = m_defaultChildFrmSize.width();
531 
532  if ( xQuantum < widthToCompare )
533  {
534  if ( colrecall[ numToHandle - 1 ] != 0 )
535  {
536  tileAllInternal( colrecall[ numToHandle - 1 ] );
537  return ;
538  }
539  }
540 
541  int yQuantum = height() / rowstable[ numToHandle - 1 ];
542  int heightToCompare;
543  if ( tcw->minimumHeight() > m_defaultChildFrmSize.height() )
544  heightToCompare = tcw->minimumHeight();
545  else
546  heightToCompare = m_defaultChildFrmSize.height();
547 
548  if ( yQuantum < heightToCompare )
549  {
550  if ( rowrecall[ numToHandle - 1 ] != 0 )
551  {
552  tileAllInternal( rowrecall[ numToHandle - 1 ] );
553  return ;
554  }
555  }
556  int curX = 0;
557  int curY = 0;
558  int curRow = 1;
559  int curCol = 1;
560  int curWin = 1;
561 
562  TQPtrListIterator<KMdiChildFrm> it( *m_pZ );
563  for ( ; ( *it ); ++it )
564  {
565  KMdiChildFrm* child = ( *it );
566  if ( child->state() != KMdiChildFrm::Minimized )
567  {
568  //restore the window
569  if ( child->state() == KMdiChildFrm::Maximized )
570  child->restorePressed();
571 
572  if ( ( curWin % numToHandle ) == 0 )
573  child->setGeometry( curX, curY, xQuantum * lastwindw[ numToHandle - 1 ], yQuantum );
574  else
575  child->setGeometry( curX, curY, xQuantum, yQuantum );
576 
577  //example : 12 windows : 3 cols 3 rows
578  if ( curCol < colstable[ numToHandle - 1 ] )
579  { //curCol<3
580  curX += xQuantum; //add a column in the same row
581  curCol++; //increase current column
582  }
583  else
584  {
585  curX = 0; //new row
586  curCol = 1; //column 1
587  if ( curRow < rowstable[ numToHandle - 1 ] )
588  { //curRow<3
589  curY += yQuantum; //add a row
590  curRow++; //increase current row
591  }
592  else
593  {
594  curY = 0; //restart from beginning
595  curRow = 1; //reset current row
596  }
597  }
598  curWin++;
599  }
600  }
601 
602  if ( tcw )
603  tcw->m_pClient->activate();
604 }
605 
606 void KMdiChildArea::tileAnodine()
607 {
608  KMdiChildFrm * topChildWindow = topChild();
609  int numVisible = getVisibleChildCount(); // count visible windows
610  if ( numVisible < 1 )
611  return ;
612 
613  int numCols = int( sqrt( ( double ) numVisible ) ); // set columns to square root of visible count
614  // create an array to form grid layout
615  int *numRows = new int[ numCols ];
616  int numCurCol = 0;
617 
618  while ( numCurCol < numCols )
619  {
620  numRows[numCurCol] = numCols; // create primary grid values
621  numCurCol++;
622  }
623 
624  int numDiff = numVisible - ( numCols * numCols ); // count extra rows
625  int numCurDiffCol = numCols; // set column limiting for grid updates
626 
627  while ( numDiff > 0 )
628  {
629  numCurDiffCol--;
630  numRows[numCurDiffCol]++; // add extra rows to column grid
631 
632  if ( numCurDiffCol < 1 )
633  numCurDiffCol = numCols; // rotate through the grid
634 
635  numDiff--;
636  }
637 
638  numCurCol = 0;
639  int numCurRow = 0;
640  int curX = 0;
641  int curY = 0;
642 
643  // the following code will size everything based on my grid above
644  // there is no limit to the number of windows it will handle
645  // it's great when a kick-ass theory works!!! // Pragma :)
646  int xQuantum = width() / numCols;
647  int yQuantum = height() / numRows[numCurCol];
648  TQPtrListIterator<KMdiChildFrm> it( *m_pZ );
649  for ( ; ( *it ); ++it )
650  {
651  KMdiChildFrm* child = ( *it );
652  if ( child->state() != KMdiChildFrm::Minimized )
653  {
654  if ( child->state() == KMdiChildFrm::Maximized )
655  child->restorePressed();
656 
657  child->setGeometry( curX, curY, xQuantum, yQuantum );
658  numCurRow++;
659  curY += yQuantum;
660 
661  if ( numCurRow == numRows[numCurCol] )
662  {
663  numCurRow = 0;
664  numCurCol++;
665  curY = 0;
666  curX += xQuantum;
667  if ( numCurCol != numCols )
668  yQuantum = height() / numRows[ numCurCol ];
669  }
670  }
671  }
672 
673  delete[] numRows;
674 
675  if ( topChildWindow )
676  topChildWindow->m_pClient->activate();
677 }
678 
679 
680 void KMdiChildArea::tileVertically()
681 {
682  KMdiChildFrm * topChildWindow = topChild();
683  int numVisible = getVisibleChildCount(); // count visible windows
684  if ( numVisible < 1 )
685  return ;
686 
687  int w = width() / numVisible;
688  int lastWidth = 0;
689 
690  if ( numVisible > 1 )
691  lastWidth = width() - ( w * ( numVisible - 1 ) );
692  else
693  lastWidth = w;
694 
695  int h = height();
696  int posX = 0;
697  int countVisible = 0;
698 
699  TQPtrListIterator<KMdiChildFrm> it( *m_pZ );
700  for ( ; ( *it ); ++it )
701  {
702  KMdiChildFrm* child = ( *it );
703  if ( child->state() != KMdiChildFrm::Minimized )
704  {
705  if ( child->state() == KMdiChildFrm::Maximized )
706  child->restorePressed();
707 
708  countVisible++;
709 
710  if ( countVisible < numVisible )
711  {
712  child->setGeometry( posX, 0, w, h );
713  posX += w;
714  }
715  else
716  { // last visible childframe
717  child->setGeometry( posX, 0, lastWidth, h );
718  }
719  }
720  }
721 
722  if ( topChildWindow )
723  topChildWindow->m_pClient->activate();
724 }
725 
726 
727 void KMdiChildArea::layoutMinimizedChildren()
728 {
729  int posX = 0;
730  int posY = height();
731  TQPtrListIterator<KMdiChildFrm> it( *m_pZ );
732  for ( ; ( *it ); ++it )
733  {
734  KMdiChildFrm* child = *( it );
735  if ( child->state() == KMdiChildFrm::Minimized )
736  {
737 
738  if ( ( posX > 0 ) && ( posX + child->width() > width() ) )
739  {
740  posX = 0;
741  posY -= child->height();
742  }
743 
744  child->move( posX, posY - child->height() );
745  posX = child->geometry().right();
746  }
747  }
748 }
749 
750 
751 void KMdiChildArea::setMdiCaptionFont( const TQFont& fnt )
752 {
753  m_captionFont = fnt;
754  TQFontMetrics fm( m_captionFont );
755  m_captionFontLineSpacing = fm.lineSpacing();
756 
757  TQPtrListIterator<KMdiChildFrm> it( *m_pZ );
758  for ( ; ( *it ); ++it )
759  ( *it )->doResize();
760 
761 }
762 
763 void KMdiChildArea::setMdiCaptionActiveForeColor( const TQColor& clr )
764 {
765  m_captionActiveForeColor = clr;
766 }
767 
768 void KMdiChildArea::setMdiCaptionActiveBackColor( const TQColor& clr )
769 {
770  m_captionActiveBackColor = clr;
771 }
772 
773 void KMdiChildArea::setMdiCaptionInactiveForeColor( const TQColor& clr )
774 {
775  m_captionInactiveForeColor = clr;
776 }
777 
778 void KMdiChildArea::setMdiCaptionInactiveBackColor( const TQColor& clr )
779 {
780  m_captionInactiveBackColor = clr;
781 }
782 
783 //KDE4: remove
784 void KMdiChildArea::getCaptionColors( const TQPalette& /*pal*/, TQColor& activeBG,
785  TQColor& activeFG, TQColor& inactiveBG, TQColor& inactiveFG )
786 {
787  activeBG = TDEGlobalSettings::activeTitleColor();
788  activeFG = TDEGlobalSettings::activeTextColor();
789  inactiveBG = TDEGlobalSettings::inactiveTitleColor();
790  inactiveFG = TDEGlobalSettings::inactiveTextColor();
791 }
KMdiChildArea::getCaptionColors
static void getCaptionColors(const TQPalette &pal, TQColor &activeBG, TQColor &activeFG, TQColor &inactiveBG, TQColor &inactiveFG) KDE_DEPRECATED
Gets all caption colors, consistent with current WM settings (or other Desktop settings e...
Definition: tdemdichildarea.cpp:784
KMdiChildArea::tileAnodine
void tileAnodine()
Tile Anodine.
Definition: tdemdichildarea.cpp:606
KMdiChildArea::destroyChildButNotItsView
void destroyChildButNotItsView(KMdiChildFrm *lpC, bool bFocusTopChild=true)
Destroys a managed KMdiChildFrm Clients attached to the KMdiChildFrm are not deleted.
Definition: tdemdichildarea.cpp:141
KMdiChildArea::~KMdiChildArea
~KMdiChildArea()
Destructor : THERE should be no child windows anymore...
Definition: tdemdichildarea.cpp:66
KMdiChildArea::setMdiCaptionActiveBackColor
void setMdiCaptionActiveBackColor(const TQColor &clr)
Sets the background color of the active MDI childframe window captions A relayout does not occur when...
Definition: tdemdichildarea.cpp:768
KMdiChildArea::m_captionActiveForeColor
TQColor m_captionActiveForeColor
The background color of the active MDI childframe window captions.
Definition: tdemdichildarea.h:84
KMdiChildArea::mousePressEvent
void mousePressEvent(TQMouseEvent *e)
Shows the 'Window' popup menu on right mouse button click.
Definition: tdemdichildarea.cpp:253
KMdiChildArea::topChild
KMdiChildFrm * topChild() const
Returns the topmost child (the active one) or 0 if there are no children.
Definition: tdemdichildarea.h:141
KMdiChildArea::expandHorizontal
void expandHorizontal()
Maximize all windows but only in horizontal direction.
Definition: tdemdichildarea.cpp:464
KMdiChildArea::getCascadePoint
TQPoint getCascadePoint(int indexOfWindow=-1)
Calculates the cascade point for the given index.
Definition: tdemdichildarea.cpp:262
KMdiChildArea::cascadeWindows
void cascadeWindows()
Cascades all windows resizing them to the minimum size.
Definition: tdemdichildarea.cpp:386
KMdiChildArea::destroyChild
void destroyChild(KMdiChildFrm *child, bool focusTopChild=true)
Destroys a managed KMdiChildFrm Also deletes the client attached to this child.
Definition: tdemdichildarea.cpp:109
KMdiChildArea::noMaximizedChildFrmLeft
void noMaximizedChildFrmLeft(KMdiChildFrm *)
Signals that there aren't maximized child frames any more.
KMdiChildArea::expandVertical
void expandVertical()
Maximize all windows but only in vertical direction.
Definition: tdemdichildarea.cpp:442
KMdiChildArea::setMdiCaptionInactiveBackColor
void setMdiCaptionInactiveBackColor(const TQColor &clr)
Sets the background color of inactive MDI childframe window captions A relayout does not occur when u...
Definition: tdemdichildarea.cpp:778
KMdiChildArea::childMinimized
void childMinimized(KMdiChildFrm *lpC, bool bWasMaximized)
Internally used.
Definition: tdemdichildarea.cpp:323
KMdiChildFrm::restorePressed
void restorePressed()
Handles a click on the Restore (Normalize) button.
Definition: tdemdichildfrm.cpp:458
KMdiChildArea::tileAllInternal
void tileAllInternal(int maxWnds)
Internally used for the tile algorithm.
Definition: tdemdichildarea.cpp:504
KMdiChildArea::resizeEvent
virtual void resizeEvent(TQResizeEvent *)
Automatically resizes a maximized MDI view and layouts the positions of minimized MDI views...
Definition: tdemdichildarea.cpp:231
KMdiChildArea::lastChildFrmClosed
void lastChildFrmClosed()
Signals that the last attached (docked) MDI view has been closed.
KMdiChildArea::tilePragma
void tilePragma()
Tile Pragma.
Definition: tdemdichildarea.cpp:498
KMdiChildArea::setTopChild
void setTopChild(KMdiChildFrm *child, bool setFocus=false)
Brings the child to the top of the stack The child is focused if setFocus is true.
Definition: tdemdichildarea.cpp:171
KMdiChildArea::m_captionActiveBackColor
TQColor m_captionActiveBackColor
The foreground color of the active MDI childframe window caption.
Definition: tdemdichildarea.h:79
KMdiChildView::activate
void activate()
This method does the same as focusInEvent().
Definition: tdemdichildview.cpp:420
KMdiChildFrm
Internal class.
Definition: tdemdichildfrm.h:130
KMdiChildArea::tileVertically
void tileVertically()
Tile all the windows in the child area vertically.
Definition: tdemdichildarea.cpp:680
KMdiChildArea::layoutMinimizedChildren
void layoutMinimizedChildren()
Position and layout the minimized child frames.
Definition: tdemdichildarea.cpp:727
KMdiChildArea::m_captionInactiveForeColor
TQColor m_captionInactiveForeColor
The background color of inactive MDI childframe window captions.
Definition: tdemdichildarea.h:94
KMdiChildFrm::caption
const TQString & caption()
Gets the caption of this mdi child.
Definition: tdemdichildfrm.h:230
KMdiChildArea::sysButtonConnectionsMustChange
void sysButtonConnectionsMustChange(KMdiChildFrm *, KMdiChildFrm *)
Signals a KMdiMainFrm that the signal/slot connections of the system buttons in the menubar (only in ...
KMdiChildFrmCaption::heightHint
int heightHint()
Returns the caption bar height depending on the used font.
Definition: tdemdichildfrmcaption.cpp:198
KMdiChildArea::popupWindowMenu
void popupWindowMenu(TQPoint)
Signals a KMdiMainFrm that the 'Window' popup menu must be shown.
KMdiChildFrm::state
MdiWindowState state() const
Returns the current state of the window.
Definition: tdemdichildfrm.h:240
KMdiChildArea::m_captionFont
TQFont m_captionFont
The MDI childframe window caption font.
Definition: tdemdichildarea.h:74
KMdiChildFrm::setState
void setState(MdiWindowState state, bool bAnimate=true)
Minimizes, Maximizes, or restores the window.
Definition: tdemdichildfrm.cpp:511
KMdiChildArea::setMdiCaptionFont
void setMdiCaptionFont(const TQFont &fnt)
Sets the MDI childframe window caption font A relayout does not occur when using this function...
Definition: tdemdichildarea.cpp:751
KMdiChildFrm::unsetClient
void unsetClient(TQPoint positionOffset=TQPoint(0, 0))
Reparents the client widget to 0 (desktop), moves with an offset from the original position Removes t...
Definition: tdemdichildfrm.cpp:812
KMdiChildArea::getVisibleChildCount
int getVisibleChildCount() const
Returns the number of visible children.
Definition: tdemdichildarea.cpp:486
KMdiChildArea::KMdiChildArea
KMdiChildArea(TQWidget *parent)
Consruction.
Definition: tdemdichildarea.cpp:48
KMdiChildArea::setMdiCaptionInactiveForeColor
void setMdiCaptionInactiveForeColor(const TQColor &clr)
Sets the foreground color of inactive MDI childframe window captions A relayout does not occur when u...
Definition: tdemdichildarea.cpp:773
KMdiChildArea::focusTopChild
void focusTopChild()
Gives focus to the topmost child if it doesn't get focus automatically or you want to wait to give it...
Definition: tdemdichildarea.cpp:359
KMdiChildArea::cascadeMaximized
void cascadeMaximized()
Cascades all windows resizing them to the maximum available size.
Definition: tdemdichildarea.cpp:408
KMdiChildArea::manageChild
void manageChild(KMdiChildFrm *lpC, bool bShow=true, bool bCascade=true)
Appends a new KMdiChildFrm to this manager.
Definition: tdemdichildarea.cpp:72
KMdiChildArea::setMdiCaptionActiveForeColor
void setMdiCaptionActiveForeColor(const TQColor &clr)
Sets the foreground color of the active MDI childframe window caption A relayout does not occur when ...
Definition: tdemdichildarea.cpp:763
KMdiChildArea::m_captionInactiveBackColor
TQColor m_captionInactiveBackColor
The foreground color of inactive MDI childframe window captions.
Definition: tdemdichildarea.h:89
KMdiChildArea::m_pZ
TQPtrList< KMdiChildFrm > * m_pZ
Z Order stack of KMdiChildFrm childframe windows (top=last)
Definition: tdemdichildarea.h:64
KMdiChildArea::m_defaultChildFrmSize
TQSize m_defaultChildFrmSize
the default size of an newly created childframe
Definition: tdemdichildarea.h:69

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.