You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
774 lines
21 KiB
774 lines
21 KiB
15 years ago
|
//----------------------------------------------------------------------------
|
||
12 years ago
|
// filename : tdemdichildview.cpp
|
||
15 years ago
|
//----------------------------------------------------------------------------
|
||
|
// Project : KDE MDI extension
|
||
|
//
|
||
|
// begin : 07/1999 by Szymon Stefanek as part of kvirc
|
||
|
// (an IRC application)
|
||
|
// changes : 09/1999 by Falk Brettschneider to create a
|
||
14 years ago
|
// -06/2000 stand-alone TQt extension set of
|
||
|
// classes and a TQt-based library
|
||
15 years ago
|
// 2000-2003 maintained by the KDevelop project
|
||
|
// patches : 02/2000 by Massimo Morin (mmorin@schedsys.com)
|
||
|
// */2000 by Lars Beikirch (Lars.Beikirch@gmx.net)
|
||
|
// 02/2001 by Eva Brucherseifer (eva@rt.e-technik.tu-darmstadt.de)
|
||
|
// 01/2003 by Jens Zurheide (jens.zurheide@gmx.de)
|
||
|
//
|
||
|
// copyright : (C) 1999-2003 by Szymon Stefanek (stefanek@tin.it)
|
||
|
// and
|
||
|
// Falk Brettschneider
|
||
13 years ago
|
// email : falkbr@tdevelop.org (Falk Brettschneider)
|
||
15 years ago
|
//----------------------------------------------------------------------------
|
||
|
//
|
||
|
//----------------------------------------------------------------------------
|
||
|
//
|
||
|
// This program is free software; you can redistribute it and/or modify
|
||
|
// it under the terms of the GNU Library General Public License as
|
||
|
// published by the Free Software Foundation; either version 2 of the
|
||
|
// License, or (at your option) any later version.
|
||
|
//
|
||
|
//----------------------------------------------------------------------------
|
||
|
|
||
12 years ago
|
#include "tdemdichildview.h"
|
||
|
#include "tdemdichildview.moc"
|
||
15 years ago
|
|
||
15 years ago
|
#include <tqdatetime.h>
|
||
|
#include <tqobjectlist.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include "tdemdimainfrm.h"
|
||
|
#include "tdemdichildfrm.h"
|
||
|
#include "tdemdidefines.h"
|
||
15 years ago
|
#include <kdebug.h>
|
||
|
#include <klocale.h>
|
||
15 years ago
|
#include <tqiconset.h>
|
||
15 years ago
|
|
||
|
//============ KMdiChildView ============//
|
||
|
|
||
14 years ago
|
KMdiChildView::KMdiChildView( const TQString& caption, TQWidget* parentWidget, const char* name, WFlags f )
|
||
|
: TQWidget( parentWidget, name, f )
|
||
15 years ago
|
, m_focusedChildWidget( 0L )
|
||
|
, m_firstFocusableChildWidget( 0L )
|
||
|
, m_lastFocusableChildWidget( 0L )
|
||
|
, m_stateChanged( true )
|
||
|
, m_bToolView( false )
|
||
|
, m_bInterruptActivation( false )
|
||
|
, m_bMainframesActivateViewIsPending( false )
|
||
|
, m_bFocusInEventIsPending( false )
|
||
|
, m_trackChanges( 0 )
|
||
|
{
|
||
|
setGeometry( 0, 0, 0, 0 ); // reset
|
||
|
if ( caption != 0L )
|
||
|
m_szCaption = caption;
|
||
|
else
|
||
|
m_szCaption = i18n( "Unnamed" );
|
||
|
|
||
|
m_sTabCaption = m_szCaption;
|
||
14 years ago
|
setFocusPolicy( TQ_ClickFocus );
|
||
15 years ago
|
installEventFilter( this );
|
||
|
|
||
|
// store the current time
|
||
|
updateTimeStamp();
|
||
|
}
|
||
|
|
||
|
|
||
|
//============ KMdiChildView ============//
|
||
|
|
||
14 years ago
|
KMdiChildView::KMdiChildView( TQWidget* parentWidget, const char* name, WFlags f )
|
||
|
: TQWidget( parentWidget, name, f )
|
||
15 years ago
|
, m_focusedChildWidget( 0L )
|
||
|
, m_firstFocusableChildWidget( 0L )
|
||
|
, m_lastFocusableChildWidget( 0L )
|
||
|
, m_stateChanged( true )
|
||
|
, m_bToolView( false )
|
||
|
, m_bInterruptActivation( false )
|
||
|
, m_bMainframesActivateViewIsPending( false )
|
||
|
, m_bFocusInEventIsPending( false )
|
||
|
{
|
||
|
setGeometry( 0, 0, 0, 0 ); // reset
|
||
|
m_szCaption = i18n( "Unnamed" );
|
||
|
m_sTabCaption = m_szCaption;
|
||
14 years ago
|
setFocusPolicy( TQ_ClickFocus );
|
||
15 years ago
|
installEventFilter( this );
|
||
|
|
||
|
// store the current time
|
||
|
updateTimeStamp();
|
||
|
}
|
||
|
|
||
|
//============ ~KMdiChildView ============//
|
||
|
|
||
|
KMdiChildView::~KMdiChildView()
|
||
|
{
|
||
|
kdDebug( 760 ) << k_funcinfo << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
void KMdiChildView::trackIconAndCaptionChanges( TQWidget *view )
|
||
15 years ago
|
{
|
||
|
m_trackChanges = view;
|
||
|
}
|
||
|
|
||
|
|
||
13 years ago
|
//============== internal geometry ==============//
|
||
15 years ago
|
|
||
15 years ago
|
TQRect KMdiChildView::internalGeometry() const
|
||
15 years ago
|
{
|
||
|
if ( mdiParent() )
|
||
|
{ // is attached
|
||
|
// get the client area coordinates inside the MDI child frame
|
||
13 years ago
|
TQRect posInFrame = geometry();
|
||
14 years ago
|
// map these values to the parent of the MDI child frame
|
||
15 years ago
|
// (this usually is the MDI child area) and return
|
||
15 years ago
|
TQPoint ptTopLeft = mdiParent() ->mapToParent( posInFrame.topLeft() );
|
||
|
TQSize sz = size();
|
||
|
return TQRect( ptTopLeft, sz );
|
||
15 years ago
|
}
|
||
|
else
|
||
|
{
|
||
13 years ago
|
TQRect geo = geometry();
|
||
15 years ago
|
TQRect frameGeo = externalGeometry();
|
||
|
return TQRect( frameGeo.x(), frameGeo.y(), geo.width(), geo.height() );
|
||
13 years ago
|
// return geometry();
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
//============== set internal geometry ==============//
|
||
15 years ago
|
|
||
15 years ago
|
void KMdiChildView::setInternalGeometry( const TQRect& newGeometry )
|
||
15 years ago
|
{
|
||
|
if ( mdiParent() )
|
||
|
{ // is attached
|
||
|
// retrieve the frame size
|
||
15 years ago
|
TQRect geo = internalGeometry();
|
||
|
TQRect frameGeo = externalGeometry();
|
||
15 years ago
|
int nFrameSizeTop = geo.y() - frameGeo.y();
|
||
|
int nFrameSizeLeft = geo.x() - frameGeo.x();
|
||
|
|
||
13 years ago
|
// create the new geometry that is accepted by the TQWidget::setGeometry() method
|
||
14 years ago
|
TQRect newGeoTQt;
|
||
|
newGeoTQt.setX( newGeometry.x() - nFrameSizeLeft );
|
||
|
newGeoTQt.setY( newGeometry.y() - nFrameSizeTop );
|
||
15 years ago
|
|
||
14 years ago
|
newGeoTQt.setWidth( newGeometry.width() + nFrameSizeLeft + KMDI_CHILDFRM_DOUBLE_BORDER / 2 );
|
||
|
newGeoTQt.setHeight( newGeometry.height() + nFrameSizeTop + KMDI_CHILDFRM_DOUBLE_BORDER / 2 );
|
||
|
// newGeoTQt.setWidth(newGeometry.width()+KMDI_MDI_CHILDFRM_DOUBLE_BORDER);
|
||
|
// newGeoTQt.setHeight(newGeometry.height()+mdiParent()->captionHeight()+KMDI_MDI_CHILDFRM_DOUBLE_BORDER);
|
||
15 years ago
|
|
||
13 years ago
|
// set the geometry
|
||
14 years ago
|
mdiParent()->setGeometry( newGeoTQt );
|
||
15 years ago
|
}
|
||
|
else
|
||
|
{
|
||
|
// retrieve the frame size
|
||
15 years ago
|
TQRect geo = internalGeometry();
|
||
|
TQRect frameGeo = externalGeometry();
|
||
15 years ago
|
int nFrameSizeTop = geo.y() - frameGeo.y();
|
||
|
int nFrameSizeLeft = geo.x() - frameGeo.x();
|
||
|
|
||
13 years ago
|
// create the new geometry that is accepted by the TQWidget::setGeometry() method
|
||
14 years ago
|
TQRect newGeoTQt;
|
||
15 years ago
|
|
||
14 years ago
|
newGeoTQt.setX( newGeometry.x() - nFrameSizeLeft );
|
||
|
newGeoTQt.setY( newGeometry.y() - nFrameSizeTop );
|
||
15 years ago
|
|
||
14 years ago
|
newGeoTQt.setWidth( newGeometry.width() );
|
||
|
newGeoTQt.setHeight( newGeometry.height() );
|
||
15 years ago
|
|
||
13 years ago
|
// set the geometry
|
||
14 years ago
|
setGeometry( newGeoTQt );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
//============== external geometry ==============//
|
||
15 years ago
|
|
||
15 years ago
|
TQRect KMdiChildView::externalGeometry() const
|
||
15 years ago
|
{
|
||
|
return mdiParent() ? mdiParent()->frameGeometry() : frameGeometry();
|
||
|
}
|
||
|
|
||
13 years ago
|
//============== set external geometry ==============//
|
||
15 years ago
|
|
||
15 years ago
|
void KMdiChildView::setExternalGeometry( const TQRect& newGeometry )
|
||
15 years ago
|
{
|
||
|
if ( mdiParent() )
|
||
|
{ // is attached
|
||
|
mdiParent() ->setGeometry( newGeometry );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// retrieve the frame size
|
||
15 years ago
|
TQRect geo = internalGeometry();
|
||
|
TQRect frameGeo = externalGeometry();
|
||
15 years ago
|
int nTotalFrameWidth = frameGeo.width() - geo.width();
|
||
|
int nTotalFrameHeight = frameGeo.height() - geo.height();
|
||
|
int nFrameSizeTop = geo.y() - frameGeo.y();
|
||
|
int nFrameSizeLeft = geo.x() - frameGeo.x();
|
||
|
|
||
13 years ago
|
// create the new geometry that is accepted by the TQWidget::setGeometry() method
|
||
15 years ago
|
// not attached => the window system makes the frame
|
||
14 years ago
|
TQRect newGeoTQt;
|
||
|
newGeoTQt.setX( newGeometry.x() + nFrameSizeLeft );
|
||
|
newGeoTQt.setY( newGeometry.y() + nFrameSizeTop );
|
||
|
newGeoTQt.setWidth( newGeometry.width() - nTotalFrameWidth );
|
||
|
newGeoTQt.setHeight( newGeometry.height() - nTotalFrameHeight );
|
||
|
|
||
13 years ago
|
// set the geometry
|
||
14 years ago
|
setGeometry( newGeoTQt );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
//============== minimize ==============//
|
||
|
|
||
|
void KMdiChildView::minimize( bool bAnimate )
|
||
|
{
|
||
|
if ( mdiParent() )
|
||
|
{
|
||
|
if ( !isMinimized() )
|
||
|
{
|
||
|
mdiParent() ->setState( KMdiChildFrm::Minimized, bAnimate );
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
showMinimized();
|
||
|
}
|
||
|
|
||
|
void KMdiChildView::showMinimized()
|
||
|
{
|
||
|
emit isMinimizedNow();
|
||
15 years ago
|
TQWidget::showMinimized();
|
||
15 years ago
|
}
|
||
|
|
||
|
//slot:
|
||
|
void KMdiChildView::minimize()
|
||
|
{
|
||
|
minimize( true );
|
||
|
}
|
||
|
|
||
|
//============= maximize ==============//
|
||
|
|
||
|
void KMdiChildView::maximize( bool bAnimate )
|
||
|
{
|
||
|
if ( mdiParent() )
|
||
|
{
|
||
|
if ( !isMaximized() )
|
||
|
{
|
||
|
mdiParent() ->setState( KMdiChildFrm::Maximized, bAnimate );
|
||
|
emit mdiParentNowMaximized( true );
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
showMaximized();
|
||
|
}
|
||
|
|
||
|
void KMdiChildView::showMaximized()
|
||
|
{
|
||
|
emit isMaximizedNow();
|
||
15 years ago
|
TQWidget::showMaximized();
|
||
15 years ago
|
}
|
||
|
|
||
|
//slot:
|
||
|
void KMdiChildView::maximize()
|
||
|
{
|
||
|
maximize( true );
|
||
|
}
|
||
|
|
||
|
//============== restoreGeometry ================//
|
||
|
|
||
15 years ago
|
TQRect KMdiChildView::restoreGeometry()
|
||
15 years ago
|
{
|
||
|
if ( mdiParent() )
|
||
|
return mdiParent() ->restoreGeometry();
|
||
|
else //FIXME not really supported, may be we must use Windows or X11 funtions
|
||
13 years ago
|
return geometry();
|
||
15 years ago
|
}
|
||
|
|
||
|
//============== setRestoreGeometry ================//
|
||
|
|
||
15 years ago
|
void KMdiChildView::setRestoreGeometry( const TQRect& newRestGeo )
|
||
15 years ago
|
{
|
||
|
if ( mdiParent() )
|
||
|
mdiParent()->setRestoreGeometry( newRestGeo );
|
||
|
}
|
||
|
|
||
|
//============== attach ================//
|
||
|
|
||
|
void KMdiChildView::attach()
|
||
|
{
|
||
|
emit attachWindow( this, true );
|
||
|
}
|
||
|
|
||
|
//============== detach =================//
|
||
|
|
||
|
void KMdiChildView::detach()
|
||
|
{
|
||
|
emit detachWindow( this, true );
|
||
|
}
|
||
|
|
||
|
//=============== isMinimized ? =================//
|
||
|
|
||
|
bool KMdiChildView::isMinimized() const
|
||
|
{
|
||
|
if ( mdiParent() )
|
||
|
return ( mdiParent()->state() == KMdiChildFrm::Minimized );
|
||
|
else
|
||
15 years ago
|
return TQWidget::isMinimized();
|
||
15 years ago
|
}
|
||
|
|
||
|
//============== isMaximized ? ==================//
|
||
|
|
||
|
bool KMdiChildView::isMaximized() const
|
||
|
{
|
||
|
if ( mdiParent() )
|
||
|
return ( mdiParent()->state() == KMdiChildFrm::Maximized );
|
||
|
else
|
||
15 years ago
|
return TQWidget::isMaximized();
|
||
15 years ago
|
}
|
||
|
|
||
|
//============== restore ================//
|
||
|
|
||
|
void KMdiChildView::restore()
|
||
|
{
|
||
|
if ( mdiParent() )
|
||
|
{
|
||
|
if ( isMaximized() )
|
||
|
emit mdiParentNowMaximized( false );
|
||
|
|
||
|
if ( isMinimized() || isMaximized() )
|
||
|
mdiParent()->setState( KMdiChildFrm::Normal );
|
||
|
}
|
||
|
else
|
||
|
showNormal();
|
||
|
}
|
||
|
|
||
|
void KMdiChildView::showNormal()
|
||
|
{
|
||
|
emit isRestoredNow();
|
||
15 years ago
|
TQWidget::showNormal();
|
||
15 years ago
|
}
|
||
|
|
||
|
//=============== youAreAttached ============//
|
||
|
|
||
|
void KMdiChildView::youAreAttached( KMdiChildFrm *lpC )
|
||
|
{
|
||
|
lpC->setCaption( m_szCaption );
|
||
|
emit isAttachedNow();
|
||
|
}
|
||
|
|
||
|
//================ youAreDetached =============//
|
||
|
|
||
|
void KMdiChildView::youAreDetached()
|
||
|
{
|
||
|
setCaption( m_szCaption );
|
||
|
|
||
|
setTabCaption( m_sTabCaption );
|
||
|
if ( myIconPtr() )
|
||
|
setIcon( *( myIconPtr() ) );
|
||
|
|
||
14 years ago
|
setFocusPolicy( TQ_StrongFocus );
|
||
15 years ago
|
|
||
|
emit isDetachedNow();
|
||
|
}
|
||
|
|
||
|
//================ setCaption ================//
|
||
|
// this set the caption of only the window
|
||
15 years ago
|
void KMdiChildView::setCaption( const TQString& szCaption )
|
||
15 years ago
|
{
|
||
|
// this will work only for window
|
||
|
m_szCaption = szCaption;
|
||
|
if ( mdiParent() )
|
||
|
mdiParent() ->setCaption( m_szCaption );
|
||
14 years ago
|
else //have to call the parent one
|
||
15 years ago
|
TQWidget::setCaption( m_szCaption );
|
||
15 years ago
|
|
||
|
emit windowCaptionChanged( m_szCaption );
|
||
|
}
|
||
|
|
||
|
//============== closeEvent ================//
|
||
|
|
||
15 years ago
|
void KMdiChildView::closeEvent( TQCloseEvent *e )
|
||
15 years ago
|
{
|
||
|
e->ignore(); //we ignore the event , and then close later if needed.
|
||
|
emit childWindowCloseRequest( this );
|
||
|
}
|
||
|
|
||
|
//================ myIconPtr =================//
|
||
|
|
||
15 years ago
|
TQPixmap* KMdiChildView::myIconPtr()
|
||
15 years ago
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
//============= focusInEvent ===============//
|
||
|
|
||
15 years ago
|
void KMdiChildView::focusInEvent( TQFocusEvent *e )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQWidget::focusInEvent( e );
|
||
15 years ago
|
|
||
|
// every widget get a focusInEvent when a popup menu is opened!?! -> maybe bug of QT
|
||
15 years ago
|
if ( e && ( ( e->reason() ) == TQFocusEvent::Popup ) )
|
||
15 years ago
|
return ;
|
||
|
|
||
|
|
||
|
m_bFocusInEventIsPending = true;
|
||
|
activate();
|
||
|
m_bFocusInEventIsPending = false;
|
||
|
|
||
|
emit gotFocus( this );
|
||
|
}
|
||
|
|
||
|
//============= activate ===============//
|
||
|
|
||
|
void KMdiChildView::activate()
|
||
|
{
|
||
|
// avoid circularity
|
||
|
static bool s_bActivateIsPending = false;
|
||
|
if ( s_bActivateIsPending )
|
||
|
return ;
|
||
|
|
||
|
s_bActivateIsPending = true;
|
||
|
|
||
|
// raise the view and push the taskbar button
|
||
|
if ( !m_bMainframesActivateViewIsPending )
|
||
|
emit focusInEventOccurs( this );
|
||
|
|
||
|
// if this method was called directly, check if the mainframe wants that we interrupt
|
||
|
if ( m_bInterruptActivation )
|
||
|
m_bInterruptActivation = false;
|
||
|
else
|
||
|
{
|
||
|
if ( !m_bFocusInEventIsPending )
|
||
|
setFocus();
|
||
|
|
||
|
kdDebug( 760 ) << k_funcinfo << endl;
|
||
|
emit activated( this );
|
||
|
}
|
||
|
|
||
|
if ( m_focusedChildWidget != 0L )
|
||
|
m_focusedChildWidget->setFocus();
|
||
|
else
|
||
|
{
|
||
|
if ( m_firstFocusableChildWidget != 0L )
|
||
|
{
|
||
|
m_firstFocusableChildWidget->setFocus();
|
||
|
m_focusedChildWidget = m_firstFocusableChildWidget;
|
||
|
}
|
||
|
}
|
||
|
s_bActivateIsPending = false;
|
||
|
}
|
||
|
|
||
|
//============= focusOutEvent ===============//
|
||
|
|
||
15 years ago
|
void KMdiChildView::focusOutEvent( TQFocusEvent* e )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQWidget::focusOutEvent( e );
|
||
15 years ago
|
emit lostFocus( this );
|
||
|
}
|
||
|
|
||
|
//============= resizeEvent ===============//
|
||
|
|
||
15 years ago
|
void KMdiChildView::resizeEvent( TQResizeEvent* e )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQWidget::resizeEvent( e );
|
||
15 years ago
|
|
||
|
if ( m_stateChanged )
|
||
|
{
|
||
|
m_stateChanged = false;
|
||
|
if ( isMaximized() )
|
||
|
{ //maximized
|
||
|
emit isMaximizedNow();
|
||
|
}
|
||
|
else if ( isMinimized() )
|
||
|
{ //minimized
|
||
|
emit isMinimizedNow();
|
||
|
}
|
||
|
else
|
||
|
{ //is restored
|
||
|
emit isRestoredNow();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void KMdiChildView::slot_childDestroyed()
|
||
|
{
|
||
|
// do what we do if a child is removed
|
||
|
|
||
|
// if we lost a child we uninstall ourself as event filter for the lost
|
||
13 years ago
|
// child and its children
|
||
14 years ago
|
const TQObject * pLostChild = TQT_TQOBJECT(const_cast<TQT_BASE_OBJECT_NAME*>(TQT_BASE_OBJECT_NAME::sender()));
|
||
15 years ago
|
if ( pLostChild && ( pLostChild->isWidgetType() ) )
|
||
|
{
|
||
14 years ago
|
TQObjectList* list = ( ( TQObject* ) ( pLostChild ) ) ->queryList( TQWIDGET_OBJECT_NAME_STRING );
|
||
15 years ago
|
list->insert( 0, pLostChild ); // add the lost child to the list too, just to save code
|
||
15 years ago
|
TQObjectListIt it( *list ); // iterate over all lost child widgets
|
||
|
TQObject* obj;
|
||
15 years ago
|
while ( ( obj = it.current() ) != 0 )
|
||
|
{ // for each found object...
|
||
15 years ago
|
TQWidget * widg = ( TQWidget* ) obj;
|
||
15 years ago
|
++it;
|
||
|
widg->removeEventFilter( this );
|
||
|
if ( m_firstFocusableChildWidget == widg )
|
||
|
m_firstFocusableChildWidget = 0L; // reset first widget
|
||
|
|
||
|
if ( m_lastFocusableChildWidget == widg )
|
||
|
m_lastFocusableChildWidget = 0L; // reset last widget
|
||
|
|
||
|
if ( m_focusedChildWidget == widg )
|
||
|
m_focusedChildWidget = 0L; // reset focused widget
|
||
|
}
|
||
|
delete list; // delete the list, not the objects
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//============= eventFilter ===============//
|
||
15 years ago
|
bool KMdiChildView::eventFilter( TQObject *obj, TQEvent *e )
|
||
15 years ago
|
{
|
||
15 years ago
|
if ( e->type() == TQEvent::KeyPress && isAttached() )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQKeyEvent* ke = ( TQKeyEvent* ) e;
|
||
14 years ago
|
if ( ke->key() == TQt::Key_Tab )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQWidget* w = ( TQWidget* ) obj;
|
||
14 years ago
|
TQ_FocusPolicy wfp = w->focusPolicy();
|
||
|
if ( wfp == TQ_StrongFocus || wfp == TQ_TabFocus || w->focusPolicy() == TQ_WheelFocus )
|
||
15 years ago
|
{
|
||
|
if ( m_lastFocusableChildWidget != 0 )
|
||
|
{
|
||
|
if ( w == m_lastFocusableChildWidget )
|
||
|
{
|
||
|
if ( w != m_firstFocusableChildWidget )
|
||
|
m_firstFocusableChildWidget->setFocus();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
15 years ago
|
else if ( e->type() == TQEvent::FocusIn )
|
||
15 years ago
|
{
|
||
|
if ( obj->isWidgetType() )
|
||
|
{
|
||
14 years ago
|
TQObjectList * list = queryList( TQWIDGET_OBJECT_NAME_STRING );
|
||
14 years ago
|
if ( list->find( obj ) != -1 )
|
||
15 years ago
|
m_focusedChildWidget = ( TQWidget* ) obj;
|
||
15 years ago
|
|
||
|
delete list; // delete the list, not the objects
|
||
|
}
|
||
|
if ( !isAttached() )
|
||
|
{ // is toplevel, for attached views activation is done by main frame event filter
|
||
|
static bool m_bActivationIsPending = false;
|
||
|
if ( !m_bActivationIsPending )
|
||
|
{
|
||
|
m_bActivationIsPending = true;
|
||
|
activate(); // sets the focus
|
||
|
m_bActivationIsPending = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
15 years ago
|
else if ( e->type() == TQEvent::ChildRemoved )
|
||
15 years ago
|
{
|
||
|
// if we lost a child we uninstall ourself as event filter for the lost
|
||
13 years ago
|
// child and its children
|
||
14 years ago
|
TQObject * pLostChild = TQT_TQOBJECT(( ( TQChildEvent* ) e ) ->child());
|
||
15 years ago
|
if ( ( pLostChild != 0L ) && ( pLostChild->isWidgetType() ) )
|
||
|
{
|
||
14 years ago
|
TQObjectList * list = pLostChild->queryList( TQWIDGET_OBJECT_NAME_STRING );
|
||
15 years ago
|
list->insert( 0, pLostChild ); // add the lost child to the list too, just to save code
|
||
15 years ago
|
TQObjectListIt it( *list ); // iterate over all lost child widgets
|
||
|
TQObject * o;
|
||
15 years ago
|
while ( ( o = it.current() ) != 0 )
|
||
|
{ // for each found object...
|
||
15 years ago
|
TQWidget * widg = ( TQWidget* ) o;
|
||
15 years ago
|
++it;
|
||
|
widg->removeEventFilter( this );
|
||
14 years ago
|
TQ_FocusPolicy wfp = widg->focusPolicy();
|
||
|
if ( wfp == TQ_StrongFocus || wfp == TQ_TabFocus || widg->focusPolicy() == TQ_WheelFocus )
|
||
15 years ago
|
{
|
||
|
if ( m_firstFocusableChildWidget == widg )
|
||
|
m_firstFocusableChildWidget = 0L; // reset first widget
|
||
|
|
||
|
if ( m_lastFocusableChildWidget == widg )
|
||
|
m_lastFocusableChildWidget = 0L; // reset last widget
|
||
|
}
|
||
|
}
|
||
|
delete list; // delete the list, not the objects
|
||
|
}
|
||
|
}
|
||
15 years ago
|
else if ( e->type() == TQEvent::ChildInserted )
|
||
15 years ago
|
{
|
||
|
// if we got a new child and we are attached to the MDI system we
|
||
13 years ago
|
// install ourself as event filter for the new child and its children
|
||
15 years ago
|
// (as we did when we were added to the MDI system).
|
||
14 years ago
|
TQObject * pNewChild = TQT_TQOBJECT(( ( TQChildEvent* ) e ) ->child());
|
||
15 years ago
|
if ( ( pNewChild != 0L ) && ( pNewChild->isWidgetType() ) )
|
||
|
{
|
||
15 years ago
|
TQWidget * pNewWidget = ( TQWidget* ) pNewChild;
|
||
14 years ago
|
if ( pNewWidget->testWFlags( TQt::WType_Dialog | TQt::WShowModal ) )
|
||
15 years ago
|
return false;
|
||
14 years ago
|
TQObjectList *list = pNewWidget->queryList( TQWIDGET_OBJECT_NAME_STRING );
|
||
15 years ago
|
list->insert( 0, pNewChild ); // add the new child to the list too, just to save code
|
||
15 years ago
|
TQObjectListIt it( *list ); // iterate over all new child widgets
|
||
|
TQObject * o;
|
||
15 years ago
|
while ( ( o = it.current() ) != 0 )
|
||
|
{ // for each found object...
|
||
15 years ago
|
TQWidget * widg = ( TQWidget* ) o;
|
||
15 years ago
|
++it;
|
||
|
widg->installEventFilter( this );
|
||
15 years ago
|
connect( widg, TQT_SIGNAL( destroyed() ), this, TQT_SLOT( slot_childDestroyed() ) );
|
||
14 years ago
|
TQ_FocusPolicy wfp = widg->focusPolicy();
|
||
|
if ( wfp == TQ_StrongFocus || wfp == TQ_TabFocus || widg->focusPolicy() == TQ_WheelFocus )
|
||
15 years ago
|
{
|
||
|
if ( m_firstFocusableChildWidget == 0 )
|
||
|
m_firstFocusableChildWidget = widg; // first widge
|
||
|
|
||
|
m_lastFocusableChildWidget = widg; // last widget
|
||
|
}
|
||
|
}
|
||
|
delete list; // delete the list, not the objects
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
15 years ago
|
if ( e->type() == TQEvent::IconChange )
|
||
15 years ago
|
{
|
||
13 years ago
|
// tqDebug("KMDiChildView:: TQEvent:IconChange intercepted\n");
|
||
14 years ago
|
if ( TQT_BASE_OBJECT(obj) == this )
|
||
15 years ago
|
iconUpdated( this, icon() ? ( *icon() ) : TQPixmap() );
|
||
14 years ago
|
else if ( TQT_BASE_OBJECT(obj) == m_trackChanges )
|
||
15 years ago
|
setIcon( m_trackChanges->icon() ? ( *( m_trackChanges->icon() ) ) : TQPixmap() );
|
||
15 years ago
|
}
|
||
15 years ago
|
if ( e->type() == TQEvent::CaptionChange )
|
||
15 years ago
|
{
|
||
14 years ago
|
if ( TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(this) )
|
||
15 years ago
|
captionUpdated( this, caption() );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return false; // standard event processing
|
||
|
}
|
||
|
|
||
|
/** Switches interposing in event loop of all current child widgets off. */
|
||
|
void KMdiChildView::removeEventFilterForAllChildren()
|
||
|
{
|
||
14 years ago
|
TQObjectList* list = queryList( TQWIDGET_OBJECT_NAME_STRING );
|
||
15 years ago
|
TQObjectListIt it( *list ); // iterate over all child widgets
|
||
|
TQObject* obj;
|
||
15 years ago
|
while ( ( obj = it.current() ) != 0 )
|
||
|
{ // for each found object...
|
||
15 years ago
|
TQWidget* widg = ( TQWidget* ) obj;
|
||
15 years ago
|
++it;
|
||
|
widg->removeEventFilter( this );
|
||
|
}
|
||
|
delete list; // delete the list, not the objects
|
||
|
}
|
||
|
|
||
15 years ago
|
TQWidget* KMdiChildView::focusedChildWidget()
|
||
15 years ago
|
{
|
||
|
return m_focusedChildWidget;
|
||
|
}
|
||
|
|
||
15 years ago
|
void KMdiChildView::setFirstFocusableChildWidget( TQWidget* firstFocusableChildWidget )
|
||
15 years ago
|
{
|
||
|
m_firstFocusableChildWidget = firstFocusableChildWidget;
|
||
|
}
|
||
|
|
||
15 years ago
|
void KMdiChildView::setLastFocusableChildWidget( TQWidget* lastFocusableChildWidget )
|
||
15 years ago
|
{
|
||
|
m_lastFocusableChildWidget = lastFocusableChildWidget;
|
||
|
}
|
||
|
|
||
|
/** Set a new value of the task bar button caption */
|
||
15 years ago
|
void KMdiChildView::setTabCaption ( const TQString& stbCaption )
|
||
15 years ago
|
{
|
||
|
m_sTabCaption = stbCaption;
|
||
|
emit tabCaptionChanged( m_sTabCaption );
|
||
|
}
|
||
|
|
||
15 years ago
|
void KMdiChildView::setMDICaption ( const TQString& caption )
|
||
15 years ago
|
{
|
||
|
setCaption( caption );
|
||
|
setTabCaption( caption );
|
||
|
}
|
||
|
|
||
|
/** sets an ID */
|
||
|
void KMdiChildView::setWindowMenuID( int id )
|
||
|
{
|
||
|
m_windowMenuID = id;
|
||
|
}
|
||
|
|
||
|
//============= slot_clickedInWindowMenu ===============//
|
||
|
|
||
|
/** called if someone click on the "Window" menu item for this child frame window */
|
||
|
void KMdiChildView::slot_clickedInWindowMenu()
|
||
|
{
|
||
|
updateTimeStamp();
|
||
|
emit clickedInWindowMenu( m_windowMenuID );
|
||
|
}
|
||
|
|
||
|
//============= slot_clickedInDockMenu ===============//
|
||
|
|
||
|
/** called if someone click on the "Dock/Undock..." menu item for this child frame window */
|
||
|
void KMdiChildView::slot_clickedInDockMenu()
|
||
|
{
|
||
|
emit clickedInDockMenu( m_windowMenuID );
|
||
|
}
|
||
|
|
||
|
//============= setMinimumSize ===============//
|
||
|
|
||
|
void KMdiChildView::setMinimumSize( int minw, int minh )
|
||
|
{
|
||
15 years ago
|
TQWidget::setMinimumSize( minw, minh );
|
||
15 years ago
|
if ( mdiParent() && mdiParent()->state() != KMdiChildFrm::Minimized )
|
||
|
{
|
||
|
mdiParent() ->setMinimumSize( minw + KMDI_CHILDFRM_DOUBLE_BORDER,
|
||
|
minh + KMDI_CHILDFRM_DOUBLE_BORDER + KMDI_CHILDFRM_SEPARATOR + mdiParent() ->captionHeight() );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//============= setMaximumSize ===============//
|
||
|
|
||
|
void KMdiChildView::setMaximumSize( int maxw, int maxh )
|
||
|
{
|
||
|
if ( mdiParent() && mdiParent()->state() == KMdiChildFrm::Normal )
|
||
|
{
|
||
|
int w = maxw + KMDI_CHILDFRM_DOUBLE_BORDER;
|
||
14 years ago
|
if ( w > TQWIDGETSIZE_MAX )
|
||
|
w = TQWIDGETSIZE_MAX;
|
||
15 years ago
|
|
||
|
int h = maxh + KMDI_CHILDFRM_DOUBLE_BORDER + KMDI_CHILDFRM_SEPARATOR + mdiParent() ->captionHeight();
|
||
14 years ago
|
if ( h > TQWIDGETSIZE_MAX )
|
||
|
h = TQWIDGETSIZE_MAX;
|
||
15 years ago
|
|
||
|
mdiParent()->setMaximumSize( w, h );
|
||
|
}
|
||
15 years ago
|
TQWidget::setMaximumSize( maxw, maxh );
|
||
15 years ago
|
}
|
||
|
|
||
|
//============= show ===============//
|
||
|
|
||
|
void KMdiChildView::show()
|
||
|
{
|
||
|
if ( mdiParent() )
|
||
|
mdiParent()->show();
|
||
|
|
||
15 years ago
|
TQWidget::show();
|
||
15 years ago
|
}
|
||
|
|
||
|
//============= hide ===============//
|
||
|
|
||
|
void KMdiChildView::hide()
|
||
|
{
|
||
|
if ( mdiParent() )
|
||
|
mdiParent()->hide();
|
||
|
|
||
15 years ago
|
TQWidget::hide();
|
||
15 years ago
|
}
|
||
|
|
||
|
//============= raise ===============//
|
||
|
|
||
|
void KMdiChildView::raise()
|
||
|
{
|
||
|
if ( mdiParent() ) //TODO Check Z-order
|
||
|
mdiParent()->raise();
|
||
|
|
||
15 years ago
|
TQWidget::raise();
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
// kate: space-indent off; replace-tabs off; indent-mode csands; tab-width 4;
|