32 #include "kmdichildview.h"
33 #include "kmdichildview.moc"
35 #include <tqdatetime.h>
36 #include <tqobjectlist.h>
38 #include "kmdimainfrm.h"
39 #include "kmdichildfrm.h"
40 #include "kmdidefines.h"
43 #include <tqiconset.h>
48 : TQWidget( parentWidget, name, f )
49 , m_focusedChildWidget( 0L )
50 , m_firstFocusableChildWidget( 0L )
51 , m_lastFocusableChildWidget( 0L )
52 , m_stateChanged( true )
53 , m_bToolView( false )
54 , m_bInterruptActivation( false )
55 , m_bMainframesActivateViewIsPending( false )
56 , m_bFocusInEventIsPending( false )
59 setGeometry( 0, 0, 0, 0 );
66 setFocusPolicy( TQ_ClickFocus );
67 installEventFilter(
this );
77 : TQWidget( parentWidget, name, f )
78 , m_focusedChildWidget( 0L )
79 , m_firstFocusableChildWidget( 0L )
80 , m_lastFocusableChildWidget( 0L )
81 , m_stateChanged( true )
82 , m_bToolView( false )
83 , m_bInterruptActivation( false )
84 , m_bMainframesActivateViewIsPending( false )
85 , m_bFocusInEventIsPending( false )
88 setGeometry( 0, 0, 0, 0 );
91 setFocusPolicy( TQ_ClickFocus );
92 installEventFilter(
this );
102 kdDebug( 760 ) << k_funcinfo << endl;
105 void KMdiChildView::trackIconAndCaptionChanges( TQWidget *view )
107 m_trackChanges = view;
118 TQRect posInFrame = geometry();
121 TQPoint ptTopLeft =
mdiParent() ->mapToParent( posInFrame.topLeft() );
123 return TQRect( ptTopLeft, sz );
127 TQRect geo = geometry();
129 return TQRect( frameGeo.x(), frameGeo.y(), geo.width(), geo.height() );
143 int nFrameSizeTop = geo.y() - frameGeo.y();
144 int nFrameSizeLeft = geo.x() - frameGeo.x();
148 newGeoQt.setX( newGeometry.x() - nFrameSizeLeft );
149 newGeoQt.setY( newGeometry.y() - nFrameSizeTop );
151 newGeoQt.setWidth( newGeometry.width() + nFrameSizeLeft + KMDI_CHILDFRM_DOUBLE_BORDER / 2 );
152 newGeoQt.setHeight( newGeometry.height() + nFrameSizeTop + KMDI_CHILDFRM_DOUBLE_BORDER / 2 );
164 int nFrameSizeTop = geo.y() - frameGeo.y();
165 int nFrameSizeLeft = geo.x() - frameGeo.x();
170 newGeoQt.setX( newGeometry.x() - nFrameSizeLeft );
171 newGeoQt.setY( newGeometry.y() - nFrameSizeTop );
173 newGeoQt.setWidth( newGeometry.width() );
174 newGeoQt.setHeight( newGeometry.height() );
177 setGeometry( newGeoQt );
194 mdiParent() ->setGeometry( newGeometry );
201 int nTotalFrameWidth = frameGeo.width() - geo.width();
202 int nTotalFrameHeight = frameGeo.height() - geo.height();
203 int nFrameSizeTop = geo.y() - frameGeo.y();
204 int nFrameSizeLeft = geo.x() - frameGeo.x();
209 newGeoQt.setX( newGeometry.x() + nFrameSizeLeft );
210 newGeoQt.setY( newGeometry.y() + nFrameSizeTop );
211 newGeoQt.setWidth( newGeometry.width() - nTotalFrameWidth );
212 newGeoQt.setHeight( newGeometry.height() - nTotalFrameHeight );
215 setGeometry( newGeoQt );
311 return (
mdiParent()->state() == KMdiChildFrm::Minimized );
321 return (
mdiParent()->state() == KMdiChildFrm::Maximized );
366 setFocusPolicy( TQ_StrongFocus );
407 if ( e && ( ( e->reason() ) == TQFocusEvent::Popup ) )
411 m_bFocusInEventIsPending =
true;
413 m_bFocusInEventIsPending =
false;
423 static bool s_bActivateIsPending =
false;
424 if ( s_bActivateIsPending )
427 s_bActivateIsPending =
true;
430 if ( !m_bMainframesActivateViewIsPending )
434 if ( m_bInterruptActivation )
435 m_bInterruptActivation =
false;
438 if ( !m_bFocusInEventIsPending )
441 kdDebug( 760 ) << k_funcinfo << endl;
455 s_bActivateIsPending =
false;
490 void KMdiChildView::slot_childDestroyed()
496 const TQObject * pLostChild = TQT_TQOBJECT_CONST(sender());
497 if ( pLostChild && ( pLostChild->isWidgetType() ) )
499 TQObjectList* list = ( ( TQObject* ) ( pLostChild ) ) ->queryList( TQWIDGET_OBJECT_NAME_STRING );
500 list->insert( 0, pLostChild );
501 TQObjectListIt it( *list );
503 while ( ( obj = it.current() ) != 0 )
505 TQWidget * widg = ( TQWidget* ) obj;
507 widg->removeEventFilter(
this );
524 if ( e->type() == TQEvent::KeyPress &&
isAttached() )
526 TQKeyEvent* ke = ( TQKeyEvent* ) e;
527 if ( ke->key() == Qt::Key_Tab )
529 TQWidget* w = ( TQWidget* ) obj;
530 TQ_FocusPolicy wfp = w->focusPolicy();
531 if ( wfp == TQ_StrongFocus || wfp == TQ_TabFocus || w->focusPolicy() == TQ_WheelFocus )
544 else if ( e->type() == TQEvent::FocusIn )
546 if ( obj->isWidgetType() )
548 TQObjectList * list = queryList( TQWIDGET_OBJECT_NAME_STRING );
549 if ( list->find( obj ) != -1 )
556 static bool m_bActivationIsPending =
false;
557 if ( !m_bActivationIsPending )
559 m_bActivationIsPending =
true;
561 m_bActivationIsPending =
false;
565 else if ( e->type() == TQEvent::ChildRemoved )
569 TQObject * pLostChild = TQT_TQOBJECT(( ( TQChildEvent* ) e ) ->child());
570 if ( ( pLostChild != 0L ) && ( pLostChild->isWidgetType() ) )
572 TQObjectList * list = pLostChild->queryList( TQWIDGET_OBJECT_NAME_STRING );
573 list->insert( 0, pLostChild );
574 TQObjectListIt it( *list );
576 while ( ( o = it.current() ) != 0 )
578 TQWidget * widg = ( TQWidget* ) o;
580 widg->removeEventFilter(
this );
581 TQ_FocusPolicy wfp = widg->focusPolicy();
582 if ( wfp == TQ_StrongFocus || wfp == TQ_TabFocus || widg->focusPolicy() == TQ_WheelFocus )
594 else if ( e->type() == TQEvent::ChildInserted )
599 TQObject * pNewChild = TQT_TQOBJECT(( ( TQChildEvent* ) e ) ->child());
600 if ( ( pNewChild != 0L ) && ( pNewChild->isWidgetType() ) )
602 TQWidget * pNewWidget = ( TQWidget* ) pNewChild;
603 if ( pNewWidget->testWFlags( (WFlags)(WType_Dialog | WShowModal) ) )
605 TQObjectList *list = pNewWidget->queryList( TQWIDGET_OBJECT_NAME_STRING );
606 list->insert( 0, pNewChild );
607 TQObjectListIt it( *list );
609 while ( ( o = it.current() ) != 0 )
611 TQWidget * widg = ( TQWidget* ) o;
613 widg->installEventFilter(
this );
614 connect( widg, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slot_childDestroyed() ) );
615 TQ_FocusPolicy wfp = widg->focusPolicy();
616 if ( wfp == TQ_StrongFocus || wfp == TQ_TabFocus || widg->focusPolicy() == TQ_WheelFocus )
629 if ( e->type() == TQEvent::IconChange )
632 if ( TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(
this) )
633 iconUpdated(
this, icon() ? ( *icon() ) : TQPixmap() );
634 else if ( TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(m_trackChanges) )
635 setIcon( m_trackChanges->icon() ? ( *( m_trackChanges->icon() ) ) : TQPixmap() );
637 if ( e->type() == TQEvent::CaptionChange )
639 if ( TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(
this) )
640 captionUpdated(
this,
caption() );
650 TQObjectList* list = queryList( TQWIDGET_OBJECT_NAME_STRING );
651 TQObjectListIt it( *list );
653 while ( ( obj = it.current() ) != 0 )
655 TQWidget* widg = ( TQWidget* ) obj;
657 widg->removeEventFilter(
this );
721 minh + KMDI_CHILDFRM_DOUBLE_BORDER + KMDI_CHILDFRM_SEPARATOR +
mdiParent() ->captionHeight() );
731 int w = maxw + KMDI_CHILDFRM_DOUBLE_BORDER;
732 if ( w > QWIDGETSIZE_MAX )
736 if ( h > QWIDGETSIZE_MAX )