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

tdemdi

  • tdemdi
tdemdichildfrm.cpp
1//----------------------------------------------------------------------------
2// filename : tdemdichildfrm.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// : 01/2003 by Jens Zurheide to allow switching
12// between views based on timestamps
13// 2000-2003 maintained by the KDevelop project
14//
15// copyright : (C) 1999-2003 by Szymon Stefanek (stefanek@tin.it)
16// and
17// Falk Brettschneider
18// email : falkbr@kdevelop.org (Falk Brettschneider)
19//----------------------------------------------------------------------------
20//
21//----------------------------------------------------------------------------
22//
23// This program is free software; you can redistribute it and/or modify
24// it under the terms of the GNU Library General Public License as
25// published by the Free Software Foundation; either version 2 of the
26// License, or (at your option) any later version.
27//
28//----------------------------------------------------------------------------
29
30#include "tdemdichildfrm.h"
31#include "tdemdichildfrm.moc"
32
33#include "tdemdidefines.h"
34#include "tdemdichildfrmcaption.h"
35#include "tdemdichildarea.h"
36#include "tdemdimainfrm.h"
37
38#include <tqpainter.h>
39#include <tqapplication.h>
40#include <tqcursor.h>
41#include <tqobjectlist.h>
42#include <tqframe.h>
43#include <tqpopupmenu.h>
44#include <tqtoolbutton.h>
45#include <tqnamespace.h>
46#include <tqimage.h>
47
48#include <tdelocale.h>
49#include <kiconloader.h>
50
52// KMdiChildFrm
54
55#define KMDI_NORESIZE 0
56#define KMDI_RESIZE_TOP 1
57#define KMDI_RESIZE_LEFT 2
58#define KMDI_RESIZE_RIGHT 4
59#define KMDI_RESIZE_BOTTOM 8
60#define KMDI_RESIZE_TOPLEFT (1|2)
61#define KMDI_RESIZE_TOPRIGHT (1|4)
62#define KMDI_RESIZE_BOTTOMLEFT (8|2)
63#define KMDI_RESIZE_BOTTOMRIGHT (8|4)
64
65#include "filenew.xpm"
66#include "win_closebutton.xpm"
67#include "win_minbutton.xpm"
68#include "win_maxbutton.xpm"
69#include "win_restorebutton.xpm"
70#include "win_undockbutton.xpm"
71#include "kde_closebutton.xpm"
72#include "kde_minbutton.xpm"
73#include "kde_maxbutton.xpm"
74#include "kde_restorebutton.xpm"
75#include "kde_undockbutton.xpm"
76#include "kde2_closebutton.xpm"
77#include "kde2_minbutton.xpm"
78#include "kde2_maxbutton.xpm"
79#include "kde2_restorebutton.xpm"
80#include "kde2_undockbutton.xpm"
81#include "kde2laptop_closebutton.xpm"
82#include "kde2laptop_minbutton.xpm"
83#include "kde2laptop_maxbutton.xpm"
84#include "kde2laptop_restorebutton.xpm"
85#include "kde2laptop_undockbutton.xpm"
86
87
88KMdiWin32IconButton::KMdiWin32IconButton( TQWidget* parent, const char* name )
89 : TQLabel( parent, name )
90{}
91
92//============ mousePressEvent ============//
93
94void KMdiWin32IconButton::mousePressEvent( TQMouseEvent* )
95{
96 //emit pressed();
97}
98
99//============ KMdiChildFrm ============//
100
101KMdiChildFrm::KMdiChildFrm( KMdiChildArea *parent )
102 : TQFrame( parent, "tdemdi_childfrm" )
103 , m_pClient( 0L )
104 , m_pManager( 0L )
105 , m_pCaption( 0L )
106 , m_pWinIcon( 0L )
107 , m_pUnixIcon( 0L )
108 , m_pMinimize( 0L )
109 , m_pMaximize( 0L )
110 , m_pClose( 0L )
111 , m_pUndock( 0L )
112 , m_state( Normal )
113 , m_restoredRect()
114 , m_iResizeCorner( KMDI_NORESIZE )
115 , m_iLastCursorCorner( KMDI_NORESIZE )
116 , m_bResizing( false )
117 , m_bDragging( false )
118 , m_pIconButtonPixmap( 0L )
119 , m_pMinButtonPixmap( 0L )
120 , m_pMaxButtonPixmap( 0L )
121 , m_pRestoreButtonPixmap( 0L )
122 , m_pCloseButtonPixmap( 0L )
123 , m_pUndockButtonPixmap( 0L )
124 , m_windowMenuID( 0 )
125 , m_pSystemMenu( 0L )
126 , m_oldClientMinSize()
127 , m_oldClientMaxSize()
128 , m_oldLayoutResizeMode( TQLayout::Minimum )
129{
130 m_pCaption = new KMdiChildFrmCaption( this );
131
132 m_pManager = parent;
133
134 m_pWinIcon = new KMdiWin32IconButton( m_pCaption, "tdemdi_iconbutton_icon" );
135 m_pUnixIcon = new TQToolButton( m_pCaption, "tdemdi_toolbutton_icon" );
136 m_pMinimize = new TQToolButton( m_pCaption, "tdemdi_toolbutton_min" );
137 m_pMaximize = new TQToolButton( m_pCaption, "tdemdi_toolbutton_max" );
138 m_pClose = new TQToolButton( m_pCaption, "tdemdi_toolbutton_close" );
139 m_pUndock = new TQToolButton( m_pCaption, "tdemdi_toolbutton_undock" );
140
141 TQObject::connect( m_pMinimize, TQ_SIGNAL( clicked() ), this, TQ_SLOT( minimizePressed() ) );
142 TQObject::connect( m_pMaximize, TQ_SIGNAL( clicked() ), this, TQ_SLOT( maximizePressed() ) );
143 TQObject::connect( m_pClose, TQ_SIGNAL( clicked() ), this, TQ_SLOT( closePressed() ) );
144 TQObject::connect( m_pUndock, TQ_SIGNAL( clicked() ), this, TQ_SLOT( undockPressed() ) );
145
146 m_pIconButtonPixmap = new TQPixmap( SmallIcon( "document-new" ) );
147 if ( m_pIconButtonPixmap->isNull() )
148 * m_pIconButtonPixmap = TQPixmap( filenew );
149
150 redecorateButtons();
151
152 m_pWinIcon->setFocusPolicy( TQWidget::NoFocus );
153 m_pUnixIcon->setFocusPolicy( TQWidget::NoFocus );
154 m_pClose->setFocusPolicy( TQWidget::NoFocus );
155 m_pMinimize->setFocusPolicy( TQWidget::NoFocus );
156 m_pMaximize->setFocusPolicy( TQWidget::NoFocus );
157 m_pUndock->setFocusPolicy( TQWidget::NoFocus );
158
159 setFrameStyle( TQFrame::WinPanel | TQFrame::Raised );
160 setFocusPolicy( TQWidget::NoFocus );
161
162 setMouseTracking( true );
163
164 setMinimumSize( KMDI_CHILDFRM_MIN_WIDTH, m_pCaption->heightHint() );
165
166 m_pSystemMenu = new TQPopupMenu();
167}
168
169//============ ~KMdiChildFrm ============//
170
171KMdiChildFrm::~KMdiChildFrm()
172{
173 delete m_pMinButtonPixmap;
174 delete m_pMaxButtonPixmap;
175 delete m_pRestoreButtonPixmap;
176 delete m_pCloseButtonPixmap;
177 delete m_pUndockButtonPixmap;
178 delete m_pSystemMenu;
179 delete m_pIconButtonPixmap;
180}
181
182//============ mousePressEvent =============//
183void KMdiChildFrm::mousePressEvent( TQMouseEvent *e )
184{
185 if ( m_bResizing )
186 {
187 if ( TQApplication::overrideCursor() )
188 TQApplication::restoreOverrideCursor();
189
190 m_bResizing = false;
191 releaseMouse();
192 }
193
194 m_pCaption->setActive( true );
195 m_pManager->setTopChild( this, false );
196
197 m_iResizeCorner = getResizeCorner( e->pos().x(), e->pos().y() );
198 if ( m_iResizeCorner != KMDI_NORESIZE )
199 {
200 m_bResizing = true;
201 //notify child view
202 KMdiChildFrmResizeBeginEvent ue( e );
203 if ( m_pClient != 0L )
204 TQApplication::sendEvent( m_pClient, &ue );
205 }
206}
207
208//============ mouseReleaseEvent ==============//
209
210void KMdiChildFrm::mouseReleaseEvent( TQMouseEvent *e )
211{
212 if ( m_bResizing )
213 {
214 if ( TQApplication::overrideCursor() )
215 TQApplication::restoreOverrideCursor();
216
217 m_bResizing = false;
218 //notify child view
219 KMdiChildFrmResizeEndEvent ue( e );
220 if ( m_pClient != 0L )
221 TQApplication::sendEvent( m_pClient, &ue );
222 }
223}
224
225//============= setResizeCursor ===============//
226
227void KMdiChildFrm::setResizeCursor( int resizeCorner )
228{
229 if ( resizeCorner == m_iLastCursorCorner )
230 return ; //Don't do it twice
231
232 m_iLastCursorCorner = resizeCorner;
233 switch ( resizeCorner )
234 {
235 case KMDI_NORESIZE:
236 if ( TQApplication::overrideCursor() )
237 TQApplication::restoreOverrideCursor();
238 break;
239 case KMDI_RESIZE_LEFT:
240 case KMDI_RESIZE_RIGHT:
241 TQApplication::setOverrideCursor( TQt::sizeHorCursor, true );
242 break;
243 case KMDI_RESIZE_TOP:
244 case KMDI_RESIZE_BOTTOM:
245 TQApplication::setOverrideCursor( TQt::sizeVerCursor, true );
246 break;
247 case KMDI_RESIZE_TOPLEFT:
248 case KMDI_RESIZE_BOTTOMRIGHT:
249 TQApplication::setOverrideCursor( TQt::sizeFDiagCursor, true );
250 break;
251 case KMDI_RESIZE_BOTTOMLEFT:
252 case KMDI_RESIZE_TOPRIGHT:
253 TQApplication::setOverrideCursor( TQt::sizeBDiagCursor, true );
254 break;
255 }
256}
257
258//============= unsetResizeCursor ===============//
259
260void KMdiChildFrm::unsetResizeCursor()
261{
262 if ( !m_bResizing && m_iResizeCorner != KMDI_NORESIZE )
263 {
264 m_iResizeCorner = KMDI_NORESIZE;
265 m_iLastCursorCorner = KMDI_NORESIZE;
266 if ( TQApplication::overrideCursor() )
267 TQApplication::restoreOverrideCursor();
268 }
269}
270
271//============= mouseMoveEvent ===============//
272
273void KMdiChildFrm::mouseMoveEvent( TQMouseEvent *e )
274{
275 if ( m_state != Normal )
276 return;
277
278 if ( !m_pClient )
279 return;
280
281 if ( m_pClient->minimumSize() == m_pClient->maximumSize() )
282 return;
283
284 if ( m_bResizing )
285 {
286 if ( !( e->state() & TQt::RightButton ) && !( e->state() & TQt::MidButton ) )
287 {
288 // same as: if no button or left button pressed
289 TQPoint p = parentWidget()->mapFromGlobal( e->globalPos() );
290 resizeWindow( m_iResizeCorner, p.x(), p.y() );
291 }
292 else
293 m_bResizing = false;
294 }
295 else
296 {
297 m_iResizeCorner = getResizeCorner( e->pos().x(), e->pos().y() );
298 setResizeCursor( m_iResizeCorner );
299 }
300}
301
302//============= moveEvent ===============//
303
304void KMdiChildFrm::moveEvent( TQMoveEvent* me )
305{
306 // give its child view the chance to notify a childframe move
307 KMdiChildFrmMoveEvent cfme( me );
308 if ( m_pClient != 0L )
309 TQApplication::sendEvent( m_pClient, &cfme );
310}
311
312//=============== leaveEvent ===============//
313
314void KMdiChildFrm::leaveEvent( TQEvent * )
315{
316 unsetResizeCursor();
317}
318
319void KMdiChildFrm::resizeWindow( int resizeCorner, int xPos, int yPos )
320{
321 TQRect resizeRect( x(), y(), width(), height() );
322
323 // Calculate the minimum width & height
324 int minWidth = 0;
325 int minHeight = 0;
326 int maxWidth = TQWIDGETSIZE_MAX;
327 int maxHeight = TQWIDGETSIZE_MAX;
328
329 // it could be the client forces the childframe to enlarge its minimum size
330 if ( m_pClient )
331 {
332 minWidth = m_pClient->minimumSize().width() + KMDI_CHILDFRM_DOUBLE_BORDER;
333 minHeight = m_pClient->minimumSize().height() + KMDI_CHILDFRM_DOUBLE_BORDER +
334 m_pCaption->heightHint() + KMDI_CHILDFRM_SEPARATOR;
335 maxWidth = m_pClient->maximumSize().width() + KMDI_CHILDFRM_DOUBLE_BORDER;
336 maxHeight = m_pClient->maximumSize().height() + KMDI_CHILDFRM_DOUBLE_BORDER +
337 m_pCaption->heightHint() + KMDI_CHILDFRM_SEPARATOR;
338 }
339
340 if ( minWidth < minimumWidth() )
341 minWidth = minimumWidth();
342
343 if ( minHeight < minimumHeight() )
344 minHeight = minimumHeight();
345
346 if ( maxWidth > maximumWidth() )
347 maxWidth = maximumWidth();
348
349 if ( maxHeight > maximumHeight() )
350 maxHeight = maximumHeight();
351
352 TQPoint mousePos( xPos, yPos );
353
354 // manipulate width
355 switch ( resizeCorner )
356 {
357 //left sides
358 case KMDI_RESIZE_TOPLEFT:
359 case KMDI_RESIZE_LEFT:
360 case KMDI_RESIZE_BOTTOMLEFT:
361 resizeRect.setLeft( mousePos.x() );
362 if ( resizeRect.width() < minWidth )
363 resizeRect.setLeft( resizeRect.right() - minWidth + 1 );
364 if ( resizeRect.width() > maxWidth )
365 resizeRect.setLeft( resizeRect.right() - maxWidth + 1 );
366 break;
367 //right sides
368 case KMDI_RESIZE_TOPRIGHT:
369 case KMDI_RESIZE_RIGHT:
370 case KMDI_RESIZE_BOTTOMRIGHT:
371 resizeRect.setRight( mousePos.x() );
372 if ( resizeRect.width() < minWidth )
373 resizeRect.setRight( resizeRect.left() + minWidth - 1 );
374 if ( resizeRect.width() > maxWidth )
375 resizeRect.setRight( resizeRect.left() + maxWidth - 1 );
376 break;
377 default:
378 break;
379 }
380
381 // manipulate height
382 switch ( resizeCorner )
383 {
384 case KMDI_RESIZE_TOPLEFT:
385 case KMDI_RESIZE_TOP:
386 case KMDI_RESIZE_TOPRIGHT:
387 resizeRect.setTop( mousePos.y() );
388 if ( resizeRect.height() < minHeight )
389 resizeRect.setTop( resizeRect.bottom() - minHeight + 1 );
390 if ( resizeRect.height() > maxHeight )
391 resizeRect.setTop( resizeRect.bottom() - maxHeight + 1 );
392 break;
393 case KMDI_RESIZE_BOTTOMLEFT:
394 case KMDI_RESIZE_BOTTOM:
395 case KMDI_RESIZE_BOTTOMRIGHT:
396 resizeRect.setBottom( mousePos.y() );
397 if ( resizeRect.height() < minHeight )
398 resizeRect.setBottom( resizeRect.top() + minHeight - 1 );
399 if ( resizeRect.height() > maxHeight )
400 resizeRect.setBottom( resizeRect.top() + maxHeight - 1 );
401 break;
402 default:
403 // nothing to do
404 break;
405 }
406 // actually resize
407 setGeometry( resizeRect );
408
409 if ( m_state == Maximized )
410 {
411 m_state = Normal;
412 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
413 }
414}
415
416//================= getResizeCorner =============//
417
418int KMdiChildFrm::getResizeCorner( int ax, int ay )
419{
420 int ret = KMDI_NORESIZE;
421 if ( m_pClient->minimumWidth() != m_pClient->maximumWidth() )
422 {
423 if ( ( ax > 0 ) && ( ax < ( KMDI_CHILDFRM_BORDER + 2 ) ) )
424 ret |= KMDI_RESIZE_LEFT;
425
426 if ( ( ax < width() ) && ( ax > ( width() - ( KMDI_CHILDFRM_BORDER + 2 ) ) ) )
427 ret |= KMDI_RESIZE_RIGHT;
428 }
429 if ( m_pClient->minimumHeight() != m_pClient->maximumHeight() )
430 {
431 if ( ( ay > 0 ) && ( ay < ( KMDI_CHILDFRM_BORDER + 2 ) ) )
432 ret |= KMDI_RESIZE_TOP;
433
434 if ( ( ay < ( height() ) ) && ( ay > ( height() - ( KMDI_CHILDFRM_BORDER + 2 ) ) ) )
435 ret |= KMDI_RESIZE_BOTTOM;
436 }
437 return ret;
438}
439
440//============= maximizePressed ============//
441
442void KMdiChildFrm::maximizePressed()
443{
444 switch ( m_state )
445 {
446 case Maximized:
447 emit m_pManager->nowMaximized( false );
448 setState( Normal );
449 break;
450 case Normal:
451 case Minimized:
452 setState( Maximized );
453 emit m_pManager->nowMaximized( true );
454 break;
455 }
456}
457
458void KMdiChildFrm::restorePressed()
459{
460 if ( m_state == Normal )
461 return ;
462
463 if ( m_state == Maximized )
464 emit m_pManager->nowMaximized( false );
465
466 setState( Normal );
467}
468
469//============= minimizePressed ============//
470
471void KMdiChildFrm::minimizePressed()
472{
473 switch ( m_state )
474 {
475 case Minimized:
476 setState( Normal );
477 break;
478 case Normal:
479 setState( Minimized );
480 break;
481 case Maximized:
482 emit m_pManager->nowMaximized( false );
483 setState( Normal );
484 setState( Minimized );
485 break;
486 }
487}
488
489//============= closePressed ============//
490
491void KMdiChildFrm::closePressed()
492{
493 if ( m_pClient )
494 m_pClient->close();
495}
496
497//============= undockPressed ============//
498
499void KMdiChildFrm::undockPressed()
500{
501 if ( m_pClient )
502 {
503 if ( m_state == Minimized )
504 setState( Normal );
505 m_pClient->detach();
506 }
507}
508
509//============ setState =================//
510
511void KMdiChildFrm::setState( MdiWindowState state, bool /*bAnimate*/ )
512{
513 if ( m_state == Normal ) //save the current rect
514 m_restoredRect = TQRect( x(), y(), width(), height() );
515
516 switch ( state )
517 {
518 case Normal:
519 switch ( m_state )
520 {
521 case Maximized:
522 m_pClient->m_stateChanged = true;
523 m_state = state;
524 // client min / max size / layout behavior don't change
525 // set frame max size indirectly by setting the clients max size to
526 // it's current value (calls setMaxSize() of frame)
527 m_pClient->setMaximumSize( m_pClient->maximumSize().width(), m_pClient->maximumSize().height() );
528 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
529 setGeometry( m_restoredRect );
530 break;
531 case Minimized:
532 m_pClient->m_stateChanged = true;
533 m_state = state;
534 // restore client min / max size / layout behavior
535 m_pClient->setMinimumSize( m_oldClientMinSize.width(), m_oldClientMinSize.height() );
536 m_pClient->setMaximumSize( m_oldClientMaxSize.width(), m_oldClientMaxSize.height() );
537 if ( m_pClient->layout() != 0L )
538 {
539 m_pClient->layout() ->setResizeMode( m_oldLayoutResizeMode );
540 }
541 m_pMinimize->setPixmap( *m_pMinButtonPixmap );
542 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
543 TQObject::disconnect( m_pMinimize, TQ_SIGNAL( clicked() ), this, TQ_SLOT( restorePressed() ) );
544 TQObject::connect( m_pMinimize, TQ_SIGNAL( clicked() ), this, TQ_SLOT( minimizePressed() ) );
545 setGeometry( m_restoredRect );
546 break;
547 case Normal:
548 break;
549 }
550 break;
551 case Maximized:
552 switch ( m_state )
553 {
554 case Minimized:
555 {
556 m_pClient->m_stateChanged = true;
557 m_state = state;
558 // restore client min / max size / layout behavior
559 m_pClient->setMinimumSize( m_oldClientMinSize.width(), m_oldClientMinSize.height() );
560 m_pClient->setMaximumSize( m_oldClientMaxSize.width(), m_oldClientMaxSize.height() );
561 if ( m_pClient->layout() != 0L )
562 {
563 m_pClient->layout() ->setResizeMode( m_oldLayoutResizeMode );
564 }
565 setMaximumSize( TQWIDGETSIZE_MAX, TQWIDGETSIZE_MAX );
566 // reset to maximize-captionbar
567 m_pMaximize->setPixmap( *m_pRestoreButtonPixmap );
568 m_pMinimize->setPixmap( *m_pMinButtonPixmap );
569 TQObject::disconnect( m_pMinimize, TQ_SIGNAL( clicked() ), this, TQ_SLOT( restorePressed() ) );
570 TQObject::connect( m_pMinimize, TQ_SIGNAL( clicked() ), this, TQ_SLOT( minimizePressed() ) );
571 int nFrameWidth = KMDI_CHILDFRM_DOUBLE_BORDER;
572 int nFrameHeight = KMDI_CHILDFRM_DOUBLE_BORDER + KMDI_CHILDFRM_SEPARATOR +
573 m_pCaption->heightHint();
574 setGeometry( -m_pClient->x(), -m_pClient->y(),
575 m_pManager->width() + nFrameWidth,
576 m_pManager->height() + nFrameHeight );
577 raise();
578 }
579 break;
580 case Normal:
581 {
582 m_pClient->m_stateChanged = true;
583 m_state = state;
584 // client min / max size / layout behavior don't change
585 setMaximumSize( TQWIDGETSIZE_MAX, TQWIDGETSIZE_MAX );
586 m_pMaximize->setPixmap( *m_pRestoreButtonPixmap );
587 int nFrameWidth = KMDI_CHILDFRM_DOUBLE_BORDER;
588 int nFrameHeight = KMDI_CHILDFRM_DOUBLE_BORDER + KMDI_CHILDFRM_SEPARATOR +
589 m_pCaption->heightHint();
590 TQRect maximizedFrmRect( -m_pClient->x(), -m_pClient->y(),
591 m_pManager->width() + nFrameWidth,
592 m_pManager->height() + nFrameHeight );
593 if ( geometry() != maximizedFrmRect )
594 {
595 setGeometry( maximizedFrmRect );
596 }
597 raise();
598 }
599 break;
600 case Maximized:
601 break;
602 }
603 break;
604 case Minimized:
605 switch ( m_state )
606 {
607 case Maximized:
608 m_pClient->m_stateChanged = true;
609 m_state = state;
610 // save client min / max size / layout behavior
611 m_oldClientMinSize = m_pClient->minimumSize();
612 m_oldClientMaxSize = m_pClient->maximumSize();
613 if ( m_pClient->layout() != 0L )
614 {
615 m_oldLayoutResizeMode = m_pClient->layout() ->resizeMode();
616 }
617 m_pClient->setMinimumSize( 0, 0 );
618 m_pClient->setMaximumSize( 0, 0 );
619 if ( m_pClient->layout() != 0L )
620 {
621 m_pClient->layout() ->setResizeMode( TQLayout::FreeResize );
622 }
623 switchToMinimizeLayout();
624 m_pManager->childMinimized( this, true );
625 break;
626 case Normal:
627 m_pClient->m_stateChanged = true;
628 m_state = state;
629 // save client min / max size / layout behavior
630 m_oldClientMinSize = m_pClient->minimumSize();
631 m_oldClientMaxSize = m_pClient->maximumSize();
632 if ( m_pClient->layout() != 0L )
633 {
634 m_oldLayoutResizeMode = m_pClient->layout() ->resizeMode();
635 }
636 m_restoredRect = geometry();
637 m_pClient->setMinimumSize( 0, 0 );
638 m_pClient->setMaximumSize( 0, 0 );
639 if ( m_pClient->layout() != 0L )
640 {
641 m_pClient->layout() ->setResizeMode( TQLayout::FreeResize );
642 }
643 switchToMinimizeLayout();
644 m_pManager->childMinimized( this, false );
645 break;
646 case Minimized:
647 break;
648 }
649 break;
650 }
651
652 KMdiChildFrm* pTopFrame = m_pManager->topChild();
653 KMdiChildView* pTopChild = 0L;
654 if ( pTopFrame != 0L )
655 {
656 pTopChild = pTopFrame->m_pClient;
657 }
658 if ( ( pTopChild != 0L ) && pTopChild->isMaximized() )
659 {
660 m_pManager->setMinimumSize( pTopChild->minimumWidth(), pTopChild->minimumHeight() );
663 }
664 else
665 {
666 m_pManager->setMinimumSize( 0, 0 );
667 m_pManager->setMaximumSize( TQWIDGETSIZE_MAX, TQWIDGETSIZE_MAX );
668 }
669}
670
671//============== restoreGeometry ================//
672
673TQRect KMdiChildFrm::restoreGeometry() const
674{
675 return m_restoredRect;
676}
677
678//============== setRestoreGeometry ================//
679
680void KMdiChildFrm::setRestoreGeometry( const TQRect& newRestGeo )
681{
682 m_restoredRect = newRestGeo;
683}
684
685//============ setCaption ===============//
686
687void KMdiChildFrm::setCaption( const TQString& text )
688{
689 m_pCaption->setCaption( text );
690}
691
692//============ enableClose ==============//
693
694void KMdiChildFrm::enableClose( bool bEnable )
695{
696 m_pClose->setEnabled( bEnable );
697 m_pClose->repaint( false );
698}
699
700//============ setIcon ==================//
701
702void KMdiChildFrm::setIcon( const TQPixmap& pxm )
703{
704 TQPixmap p = pxm;
705 if ( p.width() != 18 || p.height() != 18 )
706 {
707 TQImage img = p.convertToImage();
708 p = img.smoothScale( 18, 18, TQImage::ScaleMin );
709 }
710 const bool do_resize = m_pIconButtonPixmap->size() != p.size();
711 *m_pIconButtonPixmap = p;
712 m_pWinIcon->setPixmap( p );
713 m_pUnixIcon->setPixmap( p );
714 if ( do_resize )
715 doResize( true );
716}
717
718//============ icon =================//
719
720TQPixmap* KMdiChildFrm::icon() const
721{
722 return m_pIconButtonPixmap;
723}
724
725//============ setClient ============//
726void KMdiChildFrm::setClient( KMdiChildView *w, bool bAutomaticResize )
727{
728 m_pClient = w;
729
730 if ( w->icon() )
731 setIcon( *( w->icon() ) );
732
733 //resize to match the client
734 int clientYPos = m_pCaption->heightHint() + KMDI_CHILDFRM_SEPARATOR + KMDI_CHILDFRM_BORDER;
735 if ( bAutomaticResize || w->size().isEmpty() || ( w->size() == TQSize( 1, 1 ) ) )
736 {
737 if ( m_pManager->topChild() )
738 {
739 resize( m_pManager->topChild() ->size() );
740 }
741 else
742 {
743 resize( m_pManager->m_defaultChildFrmSize.width() + KMDI_CHILDFRM_DOUBLE_BORDER,
744 m_pManager->m_defaultChildFrmSize.height() + KMDI_CHILDFRM_BORDER + clientYPos );
745 }
746 }
747 else
748 {
749 resize( w->width() + KMDI_CHILDFRM_DOUBLE_BORDER, w->height() + KMDI_CHILDFRM_BORDER + clientYPos );
750 }
751
752 // memorize the focuses in a dictionary because they will get lost during reparenting
753 TQDict<TQWidget::FocusPolicy>* pFocPolDict = new TQDict<TQWidget::FocusPolicy>;
754 pFocPolDict->setAutoDelete( true );
755 TQObjectList *list = m_pClient->queryList( "TQWidget" );
756 TQObjectListIt it( *list ); // iterate over the buttons
757 TQObject * obj;
758 int i = 1;
759 while ( ( obj = it.current() ) != 0 )
760 { // for each found object...
761 ++it;
762 TQWidget* widg = ( TQWidget* ) obj;
763 if ( widg->name( 0 ) == 0 )
764 {
765 TQString tmpStr;
766 tmpStr.setNum( i );
767 tmpStr = "unnamed" + tmpStr;
768 widg->setName( tmpStr.latin1() );
769 i++;
770 }
771 TQWidget::FocusPolicy* pFocPol = new TQWidget::FocusPolicy;
772 *pFocPol = widg->focusPolicy();
773 pFocPolDict->insert( widg->name(), pFocPol );
774 }
775 delete list; // delete the list, not the objects
776
777 //Reparent if needed
778 if ( w->parent() != this )
779 {
780 //reparent to this widget , no flags , point , show it
781 TQPoint pnt2( KMDI_CHILDFRM_BORDER, clientYPos );
782 TQSize mincs = w->minimumSize();
783 TQSize maxcs = w->maximumSize();
784 w->setMinimumSize( 0, 0 );
785 w->setMaximumSize( TQWIDGETSIZE_MAX, TQWIDGETSIZE_MAX );
786
787 // min/max sizes, flags, DND get lost. :-(
788 w->reparent( this, 0, pnt2, w->isVisible() );
789
790 w->setMinimumSize( mincs.width(), mincs.height() );
791 w->setMaximumSize( maxcs.width(), maxcs.height() );
792 }
793 else
794 w->move( KMDI_CHILDFRM_BORDER, clientYPos );
795
796 linkChildren( pFocPolDict );
797
798 TQObject::connect( m_pClient, TQ_SIGNAL( mdiParentNowMaximized( bool ) ), m_pManager, TQ_SIGNAL( nowMaximized( bool ) ) );
799
800 if ( m_pClient->minimumWidth() > m_pManager->m_defaultChildFrmSize.width() )
801 setMinimumWidth( m_pClient->minimumSize().width() + KMDI_CHILDFRM_DOUBLE_BORDER );
802
803 if ( m_pClient->minimumHeight() > m_pManager->m_defaultChildFrmSize.height() )
804 {
805 setMinimumHeight( m_pClient->minimumSize().height() + KMDI_CHILDFRM_DOUBLE_BORDER +
806 m_pCaption->heightHint() + KMDI_CHILDFRM_SEPARATOR );
807 }
808}
809
810//============ unsetClient ============//
811
812void KMdiChildFrm::unsetClient( TQPoint positionOffset )
813{
814 if ( !m_pClient )
815 return ;
816
817 TQObject::disconnect( m_pClient, TQ_SIGNAL( mdiParentNowMaximized( bool ) ), m_pManager, TQ_SIGNAL( nowMaximized( bool ) ) );
818
819 //reparent to desktop widget , no flags , point , show it
820 TQDict<TQWidget::FocusPolicy>* pFocPolDict;
821 pFocPolDict = unlinkChildren();
822
823 // get name of focused child widget
824 TQWidget* focusedChildWidget = m_pClient->focusedChildWidget();
825 const char* nameOfFocusedWidget = "";
826 if ( focusedChildWidget != 0 )
827 nameOfFocusedWidget = focusedChildWidget->name();
828
829 TQSize mins = m_pClient->minimumSize();
830 TQSize maxs = m_pClient->maximumSize();
831 m_pClient->reparent( 0, 0, mapToGlobal( pos() ) - pos() + positionOffset, isVisible() );
832 m_pClient->setMinimumSize( mins.width(), mins.height() );
833 m_pClient->setMaximumSize( maxs.width(), maxs.height() );
834
835 // remember the focus policies using the dictionary and reset them
836 TQObjectList *list = m_pClient->queryList( "TQWidget" );
837 TQObjectListIt it( *list ); // iterate over all child widgets of child frame
838 TQObject * obj;
839 TQWidget* firstFocusableChildWidget = 0;
840 TQWidget* lastFocusableChildWidget = 0;
841 while ( ( obj = it.current() ) != 0 )
842 { // for each found object...
843 TQWidget * widg = ( TQWidget* ) obj;
844 ++it;
845 TQWidget::FocusPolicy* pFocPol = pFocPolDict->find( widg->name() ); // remember the focus policy from before the reparent
846 if ( pFocPol )
847 widg->setFocusPolicy( *pFocPol );
848
849 // reset focus to old position (doesn't work :-( for its own unexplicable reasons)
850 if ( widg->name() == nameOfFocusedWidget )
851 widg->setFocus();
852
853 // get first and last focusable widget
854 if ( ( widg->focusPolicy() == TQWidget::StrongFocus ) || ( widg->focusPolicy() == TQWidget::TabFocus ) )
855 {
856 if ( firstFocusableChildWidget == 0 )
857 firstFocusableChildWidget = widg; // first widget
858 lastFocusableChildWidget = widg; // last widget
859
860 }
861 else
862 {
863 if ( widg->focusPolicy() == TQWidget::WheelFocus )
864 {
865 if ( firstFocusableChildWidget == 0 )
866 firstFocusableChildWidget = widg; // first widget
867 lastFocusableChildWidget = widg; // last widget
868 //tqDebug("*** %s (%s)",widg->name(),widg->className());
869 }
870 }
871 }
872 delete list; // delete the list, not the objects
873 delete pFocPolDict;
874
875 // reset first and last focusable widget
876 m_pClient->setFirstFocusableChildWidget( firstFocusableChildWidget );
877 m_pClient->setLastFocusableChildWidget( lastFocusableChildWidget );
878
879 // reset the focus policy of the view
880 m_pClient->setFocusPolicy( TQWidget::ClickFocus );
881
882 // lose information about the view (because it's undocked now)
883 m_pClient = 0;
884}
885
886//============== linkChildren =============//
887void KMdiChildFrm::linkChildren( TQDict<TQWidget::FocusPolicy>* pFocPolDict )
888{
889 // reset the focus policies for all widgets in the view (take them from the dictionary)
890 TQObjectList* list = m_pClient->queryList( "TQWidget" );
891 TQObjectListIt it( *list ); // iterate over all child widgets of child frame
892 TQObject* obj;
893 while ( ( obj = it.current() ) != 0 )
894 { // for each found object...
895 TQWidget* widg = ( TQWidget* ) obj;
896 ++it;
897 TQWidget::FocusPolicy* pFocPol = pFocPolDict->find( widg->name() ); // remember the focus policy from before the reparent
898
899 if ( pFocPol != 0 )
900 widg->setFocusPolicy( *pFocPol );
901
902 if ( !( widg->inherits( "TQPopupMenu" ) ) )
903 widg->installEventFilter( this );
904
905 }
906 delete list; // delete the list, not the objects
907 delete pFocPolDict;
908
909 // reset the focus policies for the rest
910 m_pWinIcon->setFocusPolicy( TQWidget::NoFocus );
911 m_pUnixIcon->setFocusPolicy( TQWidget::NoFocus );
912 m_pClient->setFocusPolicy( TQWidget::ClickFocus );
913 m_pCaption->setFocusPolicy( TQWidget::NoFocus );
914 m_pUndock->setFocusPolicy( TQWidget::NoFocus );
915 m_pMinimize->setFocusPolicy( TQWidget::NoFocus );
916 m_pMaximize->setFocusPolicy( TQWidget::NoFocus );
917 m_pClose->setFocusPolicy( TQWidget::NoFocus );
918
919 // install the event filter (catch mouse clicks) for the rest
920 m_pWinIcon->installEventFilter( this );
921 m_pUnixIcon->installEventFilter( this );
922 m_pCaption->installEventFilter( this );
923 m_pUndock->installEventFilter( this );
924 m_pMinimize->installEventFilter( this );
925 m_pMaximize->installEventFilter( this );
926 m_pClose->installEventFilter( this );
927 m_pClient->installEventFilter( this );
928 // m_pClient->installEventFilterForAllChildren();
929}
930
931//============== unlinkChildren =============//
932
933TQDict<TQWidget::FocusPolicy>* KMdiChildFrm::unlinkChildren()
934{
935 // memorize the focuses in a dictionary because they will get lost during reparenting
936 TQDict<TQWidget::FocusPolicy>* pFocPolDict = new TQDict<TQWidget::FocusPolicy>;
937 pFocPolDict->setAutoDelete( true );
938
939 TQObjectList *list = m_pClient->queryList( "TQWidget" );
940 TQObjectListIt it( *list ); // iterate over all child widgets of child frame
941 TQObject * obj;
942 int i = 1;
943 while ( ( obj = it.current() ) != 0 )
944 { // for each found object...
945 ++it;
946 TQWidget* w = ( TQWidget* ) obj;
947 // get current widget object name
948 if ( w->name( 0 ) == 0 )
949 {
950 TQString tmpStr;
951 tmpStr.setNum( i );
952 tmpStr = "unnamed" + tmpStr;
953 w->setName( tmpStr.latin1() );
954 i++;
955 }
956 TQWidget::FocusPolicy* pFocPol = new TQWidget::FocusPolicy;
957 *pFocPol = w->focusPolicy();
958 // memorize focus policy
959 pFocPolDict->insert( w->name(), pFocPol );
960 // remove event filter
961 ( ( TQWidget* ) obj ) ->removeEventFilter( this );
962 }
963 delete list; // delete the list, not the objects
964
965 // remove the event filter (catch mouse clicks) for the rest
966 m_pWinIcon->removeEventFilter( this );
967 m_pUnixIcon->removeEventFilter( this );
968 m_pCaption->removeEventFilter( this );
969 m_pUndock->removeEventFilter( this );
970 m_pMinimize->removeEventFilter( this );
971 m_pMaximize->removeEventFilter( this );
972 m_pClose->removeEventFilter( this );
973 m_pClient->removeEventFilter( this );
974
975 //SCHEDULED_FOR_REMOVE m_pClient->removeEventFilterForAllChildren();
976
977 return pFocPolDict;
978}
979
980//============== resizeEvent ===============//
981
982void KMdiChildFrm::resizeEvent( TQResizeEvent * )
983{
984 doResize(); // an extra method because it can also called directly
985}
986
987void KMdiChildFrm::doResize()
988{
989 doResize( false );
990}
991
992void KMdiChildFrm::doResize( bool captionOnly )
993{
994 //Resize the caption
995 int captionHeight = m_pCaption->heightHint();
996 int captionWidth = width() - KMDI_CHILDFRM_DOUBLE_BORDER;
997 int buttonHeight = m_pClose->pixmap() ->height();
998 int buttonWidth = m_pClose->pixmap() ->width();
999 int heightOffset = captionHeight / 2 - buttonHeight / 2;
1000 int rightOffset1 = 1;
1001 int rightOffset2 = 1;
1002 int frmIconHeight = m_pWinIcon->pixmap() ->height();
1003 int frmIconWidth = m_pWinIcon->pixmap() ->width();
1004 int frmIconOffset = 1;
1005 TQWidget* pIconWidget = m_pWinIcon;
1006 m_pCaption->setGeometry( KMDI_CHILDFRM_BORDER, KMDI_CHILDFRM_BORDER, captionWidth, captionHeight );
1007
1008 //The buttons are caption children
1009 if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::Win95Look )
1010 {
1011 rightOffset2 += 2;
1012 m_pUnixIcon->hide();
1013 }
1014 else if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::KDE1Look )
1015 {
1016 buttonWidth += 4;
1017 buttonHeight += 4;
1018 heightOffset -= 2;
1019 rightOffset1 = 0;
1020 rightOffset2 = 0;
1021 m_pWinIcon->hide();
1022 frmIconHeight = buttonHeight;
1023 frmIconWidth = buttonWidth;
1024 frmIconOffset = 0;
1025 pIconWidget = m_pUnixIcon;
1026 }
1027 else if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::KDELook )
1028 {
1029 buttonWidth += 3;
1030 buttonHeight += 3;
1031 heightOffset -= 1;
1032 m_pUnixIcon->hide();
1033 }
1034 if ( KMdiMainFrm::frameDecorOfAttachedViews() != KMdi::KDELaptopLook )
1035 {
1036 pIconWidget->setGeometry( frmIconOffset, captionHeight / 2 - frmIconHeight / 2, frmIconWidth, frmIconHeight );
1037 m_pClose->setGeometry( ( captionWidth - buttonWidth ) - rightOffset1, heightOffset, buttonWidth, buttonHeight );
1038 m_pMaximize->setGeometry( ( captionWidth - ( buttonWidth * 2 ) ) - rightOffset2, heightOffset, buttonWidth, buttonHeight );
1039 m_pMinimize->setGeometry( ( captionWidth - ( buttonWidth * 3 ) ) - rightOffset2, heightOffset, buttonWidth, buttonHeight );
1040 m_pUndock->setGeometry( ( captionWidth - ( buttonWidth * 4 ) ) - rightOffset2, heightOffset, buttonWidth, buttonHeight );
1041 }
1042 else
1043 { // KDELaptopLook
1044 m_pWinIcon->hide();
1045 m_pUnixIcon->hide();
1046 buttonHeight += 5;
1047 heightOffset -= 2;
1048 m_pClose->setGeometry ( 0, heightOffset, 27, buttonHeight );
1049 m_pMaximize->setGeometry( captionWidth - 27, heightOffset, 27, buttonHeight );
1050 m_pMinimize->setGeometry( captionWidth - 27 * 2, heightOffset, 27, buttonHeight );
1051 m_pUndock->setGeometry ( captionWidth - 27 * 3, heightOffset, 27, buttonHeight );
1052 }
1053
1054 //Resize the client
1055 if ( !captionOnly && m_pClient )
1056 {
1057 TQSize newClientSize( captionWidth,
1058 height() - ( KMDI_CHILDFRM_DOUBLE_BORDER + captionHeight + KMDI_CHILDFRM_SEPARATOR ) );
1059 if ( newClientSize != m_pClient->size() )
1060 {
1061 m_pClient->setGeometry( KMDI_CHILDFRM_BORDER,
1062 m_pCaption->heightHint() + KMDI_CHILDFRM_SEPARATOR + KMDI_CHILDFRM_BORDER,
1063 newClientSize.width(), newClientSize.height() );
1064 }
1065 }
1066}
1067
1068static bool hasParent( TQObject* par, TQObject* o )
1069{
1070 while ( o && o != par )
1071 o = o->parent();
1072 return o == par;
1073}
1074
1075//============= eventFilter ===============//
1076
1077bool KMdiChildFrm::eventFilter( TQObject *obj, TQEvent *e )
1078{
1079 switch ( e->type() )
1080 {
1081 case TQEvent::Enter:
1082 {
1083 // check if the receiver is really a child of this frame
1084 bool bIsChild = false;
1085 TQObject* pObj = obj;
1086 while ( ( pObj != 0L ) && !bIsChild )
1087 {
1088 bIsChild = ( pObj == this );
1089 pObj = pObj->parent();
1090 }
1091 // unset the resize cursor if the cursor moved from the frame into a inner widget
1092 if ( bIsChild )
1093 unsetResizeCursor();
1094 }
1095 break;
1096 case TQEvent::MouseButtonPress:
1097 {
1098 if ( !hasParent( m_pClient, obj ) )
1099 {
1100 bool bIsSecondClick = false;
1101 if ( m_timeMeasure.elapsed() <= TQApplication::doubleClickInterval() )
1102 bIsSecondClick = true; // of a possible double click
1103
1104 if ( !( ( ( obj == m_pWinIcon ) || ( obj == m_pUnixIcon ) ) && bIsSecondClick ) )
1105 {
1106 // in case we didn't click on the icon button
1107 TQFocusEvent focusEvent( TQFocusEvent::FocusIn );
1108 TQApplication::sendEvent( tqApp->mainWidget(), &focusEvent );
1109 if ( m_pClient )
1110 {
1111 m_pClient->updateTimeStamp();
1112 m_pClient->activate();
1113 }
1114
1115 if ( ( obj->parent() != m_pCaption ) && ( obj != m_pCaption ) )
1116 {
1117 TQWidget* w = ( TQWidget* ) obj;
1118 if ( ( w->focusPolicy() == TQWidget::ClickFocus ) || ( w->focusPolicy() == TQWidget::StrongFocus ) )
1119 {
1120 w->setFocus();
1121 }
1122 }
1123 }
1124 if ( ( obj == m_pWinIcon ) || ( obj == m_pUnixIcon ) )
1125 {
1126 // in case we clicked on the icon button
1127 if ( m_timeMeasure.elapsed() > TQApplication::doubleClickInterval() )
1128 {
1129 showSystemMenu();
1130 m_timeMeasure.start();
1131 }
1132 else
1133 closePressed(); // double click on icon button closes the view
1134
1135 return true;
1136 }
1137 }
1138 }
1139 break;
1140 case TQEvent::Resize:
1141 {
1142 if ( ( ( TQWidget* ) obj == m_pClient ) && ( m_state == Normal ) )
1143 {
1144 TQResizeEvent* re = ( TQResizeEvent* ) e;
1145 int captionHeight = m_pCaption->heightHint();
1146 TQSize newChildFrmSize( re->size().width() + KMDI_CHILDFRM_DOUBLE_BORDER,
1147 re->size().height() + captionHeight + KMDI_CHILDFRM_SEPARATOR + KMDI_CHILDFRM_DOUBLE_BORDER );
1148 if ( newChildFrmSize != size() )
1149 resize( newChildFrmSize );
1150 }
1151 }
1152 break;
1153 case TQEvent::ChildRemoved:
1154 {
1155 // if we lost a child we uninstall ourself as event filter for the lost
1156 // child and its children
1157 TQObject* pLostChild = ( ( TQChildEvent* ) e )->child();
1158 if ( ( pLostChild != 0L ) /*&& (pLostChild->inherits("TQWidget"))*/ )
1159 {
1160 TQObjectList* list = pLostChild->queryList();
1161 list->insert( 0, pLostChild ); // add the lost child to the list too, just to save code
1162 TQObjectListIt it( *list ); // iterate over all lost child widgets
1163 TQObject* obj;
1164 while ( ( obj = it.current() ) != 0 )
1165 { // for each found object...
1166 TQWidget* widg = ( TQWidget* ) obj;
1167 ++it;
1168 widg->removeEventFilter( this );
1169 }
1170 delete list; // delete the list, not the objects
1171 }
1172 }
1173 break;
1174 case TQEvent::ChildInserted:
1175 {
1176 // if we got a new child we install ourself as event filter for the new
1177 // child and its children (as we did when we got our client).
1178 // XXX see linkChildren() and focus policy stuff
1179 TQObject* pNewChild = ( ( TQChildEvent* ) e ) ->child();
1180 if ( ( pNewChild != 0L ) && ::tqt_cast<TQWidget*>( pNewChild ) )
1181 {
1182 TQWidget * pNewWidget = static_cast<TQWidget*>( pNewChild );
1183 TQObjectList *list = pNewWidget->queryList( "TQWidget" );
1184 list->insert( 0, pNewChild ); // add the new child to the list too, just to save code
1185 TQObjectListIt it( *list ); // iterate over all new child widgets
1186 TQObject * obj;
1187 while ( ( obj = it.current() ) != 0 )
1188 { // for each found object...
1189 TQWidget * widg = ( TQWidget* ) obj;
1190 ++it;
1191 if ( !::tqt_cast<TQPopupMenu*>( widg ) )
1192 {
1193 widg->installEventFilter( this );
1194 }
1195 }
1196 delete list; // delete the list, not the objects
1197 }
1198 }
1199 break;
1200 default:
1201 break;
1202 }
1203
1204 return false; // standard event processing (see Qt documentation)
1205}
1206
1207//============= raiseAndActivate ===============//
1208
1209void KMdiChildFrm::raiseAndActivate()
1210{
1211 m_pCaption->setActive( true );
1212 m_pManager->setTopChild( this, false ); //Do not focus by now...
1213}
1214
1215//============= setMinimumSize ===============//
1216
1217void KMdiChildFrm::setMinimumSize ( int minw, int minh )
1218{
1219 TQWidget::setMinimumSize( minw, minh );
1220 if ( m_state == Maximized )
1221 {
1222 m_pManager->setMinimumSize( minw, minh );
1223 }
1224}
1225
1226//============= systemMenu ===============//
1227
1228TQPopupMenu* KMdiChildFrm::systemMenu() const
1229{
1230 if ( m_pSystemMenu == 0 )
1231 return 0;
1232
1233 m_pSystemMenu->clear();
1234
1235 if ( KMdiMainFrm::frameDecorOfAttachedViews() != KMdi::Win95Look )
1236 {
1237 m_pSystemMenu->insertItem( i18n( "&Restore" ), this, TQ_SLOT( restorePressed() ) );
1238 m_pSystemMenu->insertItem( i18n( "&Move" ), m_pCaption, TQ_SLOT( slot_moveViaSystemMenu() ) );
1239 m_pSystemMenu->insertItem( i18n( "R&esize" ), this, TQ_SLOT( slot_resizeViaSystemMenu() ) );
1240 m_pSystemMenu->insertItem( i18n( "M&inimize" ), this, TQ_SLOT( minimizePressed() ) );
1241 m_pSystemMenu->insertItem( i18n( "M&aximize" ), this, TQ_SLOT( maximizePressed() ) );
1242 if ( state() == Normal )
1243 m_pSystemMenu->setItemEnabled( m_pSystemMenu->idAt( 0 ), false );
1244 else if ( state() == Maximized )
1245 {
1246 m_pSystemMenu->setItemEnabled( m_pSystemMenu->idAt( 1 ), false );
1247 m_pSystemMenu->setItemEnabled( m_pSystemMenu->idAt( 2 ), false );
1248 m_pSystemMenu->setItemEnabled( m_pSystemMenu->idAt( 4 ), false );
1249 }
1250 else if ( state() == Minimized )
1251 {
1252 m_pSystemMenu->setItemEnabled( m_pSystemMenu->idAt( 2 ), false );
1253 m_pSystemMenu->setItemEnabled( m_pSystemMenu->idAt( 3 ), false );
1254 }
1255 }
1256 else
1257 {
1258 if ( state() != Normal )
1259 m_pSystemMenu->insertItem( i18n( "&Restore" ), this, TQ_SLOT( restorePressed() ) );
1260 if ( state() != Maximized )
1261 m_pSystemMenu->insertItem( i18n( "&Maximize" ), this, TQ_SLOT( maximizePressed() ) );
1262 if ( state() != Minimized )
1263 m_pSystemMenu->insertItem( i18n( "&Minimize" ), this, TQ_SLOT( minimizePressed() ) );
1264 if ( state() != Maximized )
1265 m_pSystemMenu->insertItem( i18n( "M&ove" ), m_pCaption, TQ_SLOT( slot_moveViaSystemMenu() ) );
1266 if ( state() == Normal )
1267 m_pSystemMenu->insertItem( i18n( "&Resize" ), this, TQ_SLOT( slot_resizeViaSystemMenu() ) );
1268 }
1269
1270 m_pSystemMenu->insertItem( i18n( "&Undock" ), this, TQ_SLOT( undockPressed() ) );
1271 m_pSystemMenu->insertSeparator();
1272 m_pSystemMenu->insertItem( i18n( "&Close" ), this, TQ_SLOT( closePressed() ) );
1273
1274 return m_pSystemMenu;
1275}
1276
1278void KMdiChildFrm::showSystemMenu()
1279{
1280 if ( KMdiMainFrm::frameDecorOfAttachedViews() != KMdi::Win95Look )
1281 m_pUnixIcon->setDown( false );
1282
1283 TQPoint popupmenuPosition;
1284
1285 TQRect iconGeom;
1286 if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::Win95Look )
1287 iconGeom = m_pWinIcon->geometry();
1288 else
1289 iconGeom = m_pUnixIcon->geometry();
1290
1291 popupmenuPosition = TQPoint( iconGeom.x(), iconGeom.y() + captionHeight() + KMDI_CHILDFRM_BORDER );
1292 systemMenu() ->popup( mapToGlobal( popupmenuPosition ) );
1293}
1294
1295void KMdiChildFrm::switchToMinimizeLayout()
1296{
1297 setMinimumWidth( KMDI_CHILDFRM_MIN_WIDTH );
1298 setFixedHeight( m_pCaption->height() + KMDI_CHILDFRM_DOUBLE_BORDER );
1299
1300 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
1301
1302 // temporary use of minimize button for restore function
1303 m_pMinimize->setPixmap( *m_pRestoreButtonPixmap );
1304 TQObject::disconnect( m_pMinimize, TQ_SIGNAL( clicked() ), this, TQ_SLOT( minimizePressed() ) );
1305 TQObject::connect( m_pMinimize, TQ_SIGNAL( clicked() ), this, TQ_SLOT( restorePressed() ) );
1306
1307 // resizing
1308 resize( 300, minimumHeight() );
1309
1310 // positioning
1311 m_pManager->layoutMinimizedChildren();
1312}
1313
1314void KMdiChildFrm::slot_resizeViaSystemMenu()
1315{
1316 grabMouse();
1317 m_bResizing = true;
1318 m_iResizeCorner = KMDI_RESIZE_BOTTOMLEFT;
1319 setResizeCursor( m_iResizeCorner );
1320}
1321
1322void KMdiChildFrm::redecorateButtons()
1323{
1324 delete m_pMinButtonPixmap;
1325 delete m_pMaxButtonPixmap;
1326 delete m_pRestoreButtonPixmap;
1327 delete m_pCloseButtonPixmap;
1328 delete m_pUndockButtonPixmap;
1329
1330 if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::Win95Look )
1331 {
1332 m_pMinButtonPixmap = new TQPixmap( win_minbutton );
1333 m_pMaxButtonPixmap = new TQPixmap( win_maxbutton );
1334 m_pRestoreButtonPixmap = new TQPixmap( win_restorebutton );
1335 m_pCloseButtonPixmap = new TQPixmap( win_closebutton );
1336 m_pUndockButtonPixmap = new TQPixmap( win_undockbutton );
1337 }
1338 else if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::KDE1Look )
1339 {
1340 m_pMinButtonPixmap = new TQPixmap( kde_minbutton );
1341 m_pMaxButtonPixmap = new TQPixmap( kde_maxbutton );
1342 m_pRestoreButtonPixmap = new TQPixmap( kde_restorebutton );
1343 m_pCloseButtonPixmap = new TQPixmap( kde_closebutton );
1344 m_pUndockButtonPixmap = new TQPixmap( kde_undockbutton );
1345 }
1346 else if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::KDELook )
1347 {
1348 m_pMinButtonPixmap = new TQPixmap( kde2_minbutton );
1349 m_pMaxButtonPixmap = new TQPixmap( kde2_maxbutton );
1350 m_pRestoreButtonPixmap = new TQPixmap( kde2_restorebutton );
1351 m_pCloseButtonPixmap = new TQPixmap( kde2_closebutton );
1352 m_pUndockButtonPixmap = new TQPixmap( kde2_undockbutton );
1353 }
1354 else
1355 { // kde2laptop look
1356 m_pMinButtonPixmap = new TQPixmap( kde2laptop_minbutton );
1357 m_pMaxButtonPixmap = new TQPixmap( kde2laptop_maxbutton );
1358 m_pRestoreButtonPixmap = new TQPixmap( kde2laptop_restorebutton );
1359 m_pCloseButtonPixmap = new TQPixmap( kde2laptop_closebutton );
1360 m_pUndockButtonPixmap = new TQPixmap( kde2laptop_undockbutton );
1361 }
1362
1363 m_pUnixIcon->setAutoRaise( true );
1364 if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::KDE1Look )
1365 {
1366 m_pMinimize->setAutoRaise( true );
1367 m_pMaximize->setAutoRaise( true );
1368 m_pClose->setAutoRaise( true );
1369 m_pUndock->setAutoRaise( true );
1370 }
1371 else
1372 {
1373 m_pMinimize->setAutoRaise( false );
1374 m_pMaximize->setAutoRaise( false );
1375 m_pClose->setAutoRaise( false );
1376 m_pUndock->setAutoRaise( false );
1377 }
1378
1379 if ( m_pClient && m_pClient->icon() )
1380 {
1381 m_pWinIcon->setPixmap( *( m_pClient )->icon() );
1382 m_pUnixIcon->setPixmap( *( m_pClient )->icon() );
1383 }
1384 else
1385 {
1386 m_pWinIcon->setPixmap( *m_pIconButtonPixmap );
1387 m_pUnixIcon->setPixmap( *m_pIconButtonPixmap );
1388 }
1389 m_pClose->setPixmap( *m_pCloseButtonPixmap );
1390 m_pMinimize->setPixmap( *m_pMinButtonPixmap );
1391 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
1392 m_pUndock->setPixmap( *m_pUndockButtonPixmap );
1393}
1394
1395TQRect KMdiChildFrm::mdiAreaContentsRect() const
1396{
1397 TQFrame * p = ( TQFrame* ) parentWidget();
1398 if ( p )
1399 {
1400 return p->contentsRect();
1401 }
1402 else
1403 {
1404 TQRect empty;
1405 return empty;
1406 }
1407}
KMdiChildArea
Internal class.
Definition: tdemdichildarea.h:53
KMdiChildArea::topChild
KMdiChildFrm * topChild() const
Returns the topmost child (the active one) or 0 if there are no children.
Definition: tdemdichildarea.h:141
KMdiChildArea::nowMaximized
void nowMaximized(bool)
Signals that the child frames are maximized now.
KMdiChildArea::childMinimized
void childMinimized(KMdiChildFrm *lpC, bool bWasMaximized)
Internally used.
Definition: tdemdichildarea.cpp:319
KMdiChildArea::layoutMinimizedChildren
void layoutMinimizedChildren()
Position and layout the minimized child frames.
Definition: tdemdichildarea.cpp:723
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_defaultChildFrmSize
TQSize m_defaultChildFrmSize
the default size of an newly created childframe
Definition: tdemdichildarea.h:69
KMdiChildFrmCaption
Internal class.
Definition: tdemdichildfrmcaption.h:45
KMdiChildFrmCaption::heightHint
int heightHint()
Returns the caption bar height depending on the used font.
Definition: tdemdichildfrmcaption.cpp:198
KMdiChildFrmCaption::setCaption
void setCaption(const TQString &text)
Repaint with a new caption bar title.
Definition: tdemdichildfrmcaption.cpp:190
KMdiChildFrmCaption::setActive
void setActive(bool bActive)
Repaint the caption bar in active background colors.
Definition: tdemdichildfrmcaption.cpp:171
KMdiChildFrmMoveEvent
a TQCustomEvent for move This special event will be useful, to inform view about child frame event.
Definition: tdemdichildfrm.h:72
KMdiChildFrmResizeBeginEvent
a TQCustomEvent for begin of resizing This special event will be useful, to inform view about child f...
Definition: tdemdichildfrm.h:106
KMdiChildFrmResizeEndEvent
a TQCustomEvent for end of resizing This special event will be useful, to inform view about child fra...
Definition: tdemdichildfrm.h:117
KMdiChildFrm
Internal class.
Definition: tdemdichildfrm.h:131
KMdiChildFrm::linkChildren
void linkChildren(TQDict< TQWidget::FocusPolicy > *pFocPolDict)
Restore the focus policies for all widgets in the view using the list given as parameter.
Definition: tdemdichildfrm.cpp:887
KMdiChildFrm::unlinkChildren
TQDict< TQWidget::FocusPolicy > * unlinkChildren()
Backups all focus policies of all child widgets in the MDI childview since they get lost during a rep...
Definition: tdemdichildfrm.cpp:933
KMdiChildFrm::maximizePressed
void maximizePressed()
Handles a click on the Maximize button.
Definition: tdemdichildfrm.cpp:442
KMdiChildFrm::state
MdiWindowState state() const
Returns the current state of the window.
Definition: tdemdichildfrm.h:240
KMdiChildFrm::mousePressEvent
virtual void mousePressEvent(TQMouseEvent *e)
Reimplemented from the base class.
Definition: tdemdichildfrm.cpp:183
KMdiChildFrm::switchToMinimizeLayout
virtual void switchToMinimizeLayout()
That means to show a mini window showing the childframe's caption bar, only.
Definition: tdemdichildfrm.cpp:1295
KMdiChildFrm::mdiAreaContentsRect
TQRect mdiAreaContentsRect() const
Returns the inner client area of the parent of this (which is KMdiChildArea).
Definition: tdemdichildfrm.cpp:1395
KMdiChildFrm::getResizeCorner
int getResizeCorner(int ax, int ay)
Calculates the corner id for the resize cursor.
Definition: tdemdichildfrm.cpp:418
KMdiChildFrm::setClient
void setClient(KMdiChildView *w, bool bAutomaticResize=false)
Reparents the widget w to this KMdiChildFrm (if this is not already done) Installs an event filter to...
Definition: tdemdichildfrm.cpp:726
KMdiChildFrm::resizeEvent
virtual void resizeEvent(TQResizeEvent *)
Reimplemented from the base class.
Definition: tdemdichildfrm.cpp:982
KMdiChildFrm::raiseAndActivate
void raiseAndActivate()
Internally called from the signal focusInEventOccurs.
Definition: tdemdichildfrm.cpp:1209
KMdiChildFrm::mouseMoveEvent
virtual void mouseMoveEvent(TQMouseEvent *e)
Reimplemented from the base class.
Definition: tdemdichildfrm.cpp:273
KMdiChildFrm::setState
void setState(MdiWindowState state, bool bAnimate=true)
Minimizes, Maximizes, or restores the window.
Definition: tdemdichildfrm.cpp:511
KMdiChildFrm::setRestoreGeometry
void setRestoreGeometry(const TQRect &newRestGeo)
Sets the geometry that will be restored by calling restore().
Definition: tdemdichildfrm.cpp:680
KMdiChildFrm::setResizeCursor
void setResizeCursor(int resizeCorner)
Override the cursor appearance depending on the widget corner given as parameter.
Definition: tdemdichildfrm.cpp:227
KMdiChildFrm::icon
TQPixmap * icon() const
Returns the child frame icon.
Definition: tdemdichildfrm.cpp:720
KMdiChildFrm::eventFilter
virtual bool eventFilter(TQObject *, TQEvent *)
Reimplemented from the base class.
Definition: tdemdichildfrm.cpp:1077
KMdiChildFrm::systemMenu
TQPopupMenu * systemMenu() const
Returns the system menu.
Definition: tdemdichildfrm.cpp:1228
KMdiChildFrm::restorePressed
void restorePressed()
Handles a click on the Restore (Normalize) button.
Definition: tdemdichildfrm.cpp:458
KMdiChildFrm::enableClose
void enableClose(bool bEnable)
Enables or disables the close button.
Definition: tdemdichildfrm.cpp:694
KMdiChildFrm::setMinimumSize
virtual void setMinimumSize(int minw, int minh)
Sets the minimum size of the widget to w by h pixels.
Definition: tdemdichildfrm.cpp:1217
KMdiChildFrm::restoreGeometry
TQRect restoreGeometry() const
Returns the geometry that will be restored by calling restore().
Definition: tdemdichildfrm.cpp:673
KMdiChildFrm::doResize
void doResize()
Does the actual resize.
Definition: tdemdichildfrm.cpp:987
KMdiChildFrm::unsetResizeCursor
void unsetResizeCursor()
Changes from the resize cursor to the normal (previous) cursor.
Definition: tdemdichildfrm.cpp:260
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
KMdiChildFrm::setIcon
void setIcon(const TQPixmap &pxm)
Sets the window icon pointer.
Definition: tdemdichildfrm.cpp:702
KMdiChildFrm::undockPressed
void undockPressed()
Handles a click on the Undock (Detach) button.
Definition: tdemdichildfrm.cpp:499
KMdiChildFrm::minimizePressed
void minimizePressed()
Handles a click on the Minimize button.
Definition: tdemdichildfrm.cpp:471
KMdiChildFrm::resizeWindow
void resizeWindow(int resizeCorner, int x, int y)
Calculates the new geometry from the new mouse position given as parameters and calls KMdiChildFrm::s...
Definition: tdemdichildfrm.cpp:319
KMdiChildFrm::moveEvent
virtual void moveEvent(TQMoveEvent *me)
Reimplemented from the base class.
Definition: tdemdichildfrm.cpp:304
KMdiChildFrm::leaveEvent
virtual void leaveEvent(TQEvent *)
Reimplemented from the base class.
Definition: tdemdichildfrm.cpp:314
KMdiChildFrm::redecorateButtons
void redecorateButtons()
sets new raise behavior and pixmaps of the buttons depending on the current decoration style
Definition: tdemdichildfrm.cpp:1322
KMdiChildFrm::showSystemMenu
void showSystemMenu()
Shows a system menu for child frame windows.
Definition: tdemdichildfrm.cpp:1278
KMdiChildFrm::~KMdiChildFrm
~KMdiChildFrm()
Destroys this KMdiChildFrm If a child is still here managed (no recreation was made) it is destroyed ...
Definition: tdemdichildfrm.cpp:171
KMdiChildFrm::KMdiChildFrm
KMdiChildFrm(KMdiChildArea *parent)
Creates a new KMdiChildFrm class.
Definition: tdemdichildfrm.cpp:101
KMdiChildFrm::closePressed
void closePressed()
Handles a click on the Close button.
Definition: tdemdichildfrm.cpp:491
KMdiChildFrm::m_pSystemMenu
TQPopupMenu * m_pSystemMenu
Imitates a system menu for child frame windows.
Definition: tdemdichildfrm.h:173
KMdiChildFrm::captionHeight
int captionHeight() const
Returns the caption bar height.
Definition: tdemdichildfrm.h:271
KMdiChildFrm::mouseReleaseEvent
virtual void mouseReleaseEvent(TQMouseEvent *)
Reimplemented from the base class.
Definition: tdemdichildfrm.cpp:210
KMdiChildFrm::setCaption
void setCaption(const TQString &text)
Sets the caption of this window.
Definition: tdemdichildfrm.cpp:687
KMdiChildView
Base class for all your special view windows.
Definition: tdemdichildview.h:109
KMdiChildView::detach
virtual void detach()
Detaches this window from the Mdi manager.
Definition: tdemdichildview.cpp:301
KMdiChildView::isMaximized
bool isMaximized() const
Tells if the window is minimized when attached to the Mdi manager, otherwise returns false.
Definition: tdemdichildview.cpp:318
KMdiChildView::activate
void activate()
This method does the same as focusInEvent().
Definition: tdemdichildview.cpp:420
KMdiChildView::setFirstFocusableChildWidget
void setFirstFocusableChildWidget(TQWidget *)
Memorizes the first focusable child widget of this widget.
Definition: tdemdichildview.cpp:667
KMdiChildView::m_stateChanged
bool m_stateChanged
Holds a temporary information about if the MDI view state has changed but is not processed yet (pendi...
Definition: tdemdichildview.h:150
KMdiChildView::focusedChildWidget
TQWidget * focusedChildWidget()
Returns the current focused child widget of this widget.
Definition: tdemdichildview.cpp:662
KMdiChildView::setLastFocusableChildWidget
void setLastFocusableChildWidget(TQWidget *)
Memorizes the last focusable child widget of this widget.
Definition: tdemdichildview.cpp:672
KMdiChildView::setMinimumSize
virtual void setMinimumSize(int minw, int minh)
Sets the minimum size of the widget to w by h pixels.
Definition: tdemdichildview.cpp:715
KMdiChildView::updateTimeStamp
void updateTimeStamp()
Remember the current time.
Definition: tdemdichildview.h:359
KMdiChildView::setMaximumSize
virtual void setMaximumSize(int maxw, int maxh)
Sets the maximum size of the widget to w by h pixels.
Definition: tdemdichildview.cpp:727
KMdiMainFrm::frameDecorOfAttachedViews
static int frameDecorOfAttachedViews()
Definition: tdemdimainfrm.h:465
KMdiWin32IconButton
Internal class, only used on Win32.
Definition: tdemdichildfrm.h:53

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
  • 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 by doxygen 1.9.4
This website is maintained by Timothy Pearson.