30 #include "kmdichildfrm.h"
31 #include "kmdichildfrm.moc"
33 #include "kmdidefines.h"
34 #include "kmdichildfrmcaption.h"
35 #include "kmdichildarea.h"
36 #include "kmdimainfrm.h"
38 #include <tqpainter.h>
39 #include <tqapplication.h>
41 #include <tqobjectlist.h>
43 #include <tqpopupmenu.h>
44 #include <tqtoolbutton.h>
45 #include <tqnamespace.h>
49 #include <kiconloader.h>
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)
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"
88 KMdiWin32IconButton::KMdiWin32IconButton( TQWidget* parent,
const char* name )
89 : TQLabel( parent, name )
94 void KMdiWin32IconButton::mousePressEvent( TQMouseEvent* )
102 : TQFrame( parent,
"kmdi_childfrm" )
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 )
126 , m_oldClientMinSize()
127 , m_oldClientMaxSize()
128 , m_oldLayoutResizeMode( TQLayout::Minimum )
135 m_pUnixIcon =
new TQToolButton( m_pCaption,
"kmdi_toolbutton_icon" );
136 m_pMinimize =
new TQToolButton( m_pCaption,
"kmdi_toolbutton_min" );
137 m_pMaximize =
new TQToolButton( m_pCaption,
"kmdi_toolbutton_max" );
138 m_pClose =
new TQToolButton( m_pCaption,
"kmdi_toolbutton_close" );
139 m_pUndock =
new TQToolButton( m_pCaption,
"kmdi_toolbutton_undock" );
141 TQObject::connect( m_pMinimize, TQT_SIGNAL( clicked() ),
this, TQT_SLOT(
minimizePressed() ) );
142 TQObject::connect( m_pMaximize, TQT_SIGNAL( clicked() ),
this, TQT_SLOT(
maximizePressed() ) );
143 TQObject::connect( m_pClose, TQT_SIGNAL( clicked() ),
this, TQT_SLOT(
closePressed() ) );
144 TQObject::connect( m_pUndock, TQT_SIGNAL( clicked() ),
this, TQT_SLOT(
undockPressed() ) );
146 m_pIconButtonPixmap =
new TQPixmap( SmallIcon(
"filenew" ) );
147 if ( m_pIconButtonPixmap->isNull() )
148 * m_pIconButtonPixmap = TQPixmap( filenew );
152 m_pWinIcon->setFocusPolicy( TQ_NoFocus );
153 m_pUnixIcon->setFocusPolicy( TQ_NoFocus );
154 m_pClose->setFocusPolicy( TQ_NoFocus );
155 m_pMinimize->setFocusPolicy( TQ_NoFocus );
156 m_pMaximize->setFocusPolicy( TQ_NoFocus );
157 m_pUndock->setFocusPolicy( TQ_NoFocus );
159 setFrameStyle( TQFrame::WinPanel | TQFrame::Raised );
160 setFocusPolicy( TQ_NoFocus );
162 setMouseTracking(
true );
173 delete m_pMinButtonPixmap;
174 delete m_pMaxButtonPixmap;
175 delete m_pRestoreButtonPixmap;
176 delete m_pCloseButtonPixmap;
177 delete m_pUndockButtonPixmap;
179 delete m_pIconButtonPixmap;
187 if ( TQApplication::overrideCursor() )
188 TQApplication::restoreOverrideCursor();
198 if ( m_iResizeCorner != KMDI_NORESIZE )
203 if ( m_pClient != 0L )
204 TQApplication::sendEvent( m_pClient, &ue );
214 if ( TQApplication::overrideCursor() )
215 TQApplication::restoreOverrideCursor();
220 if ( m_pClient != 0L )
221 TQApplication::sendEvent( m_pClient, &ue );
229 if ( resizeCorner == m_iLastCursorCorner )
232 m_iLastCursorCorner = resizeCorner;
233 switch ( resizeCorner )
236 if ( TQApplication::overrideCursor() )
237 TQApplication::restoreOverrideCursor();
239 case KMDI_RESIZE_LEFT:
240 case KMDI_RESIZE_RIGHT:
241 TQApplication::setOverrideCursor( tqsizeHorCursor,
true );
243 case KMDI_RESIZE_TOP:
244 case KMDI_RESIZE_BOTTOM:
245 TQApplication::setOverrideCursor( tqsizeVerCursor,
true );
247 case KMDI_RESIZE_TOPLEFT:
248 case KMDI_RESIZE_BOTTOMRIGHT:
249 TQApplication::setOverrideCursor( tqsizeFDiagCursor,
true );
251 case KMDI_RESIZE_BOTTOMLEFT:
252 case KMDI_RESIZE_TOPRIGHT:
253 TQApplication::setOverrideCursor( tqsizeBDiagCursor,
true );
262 if ( !m_bResizing && m_iResizeCorner != KMDI_NORESIZE )
264 m_iResizeCorner = KMDI_NORESIZE;
265 m_iLastCursorCorner = KMDI_NORESIZE;
266 if ( TQApplication::overrideCursor() )
267 TQApplication::restoreOverrideCursor();
275 if ( m_state != Normal )
281 if ( m_pClient->minimumSize() == m_pClient->maximumSize() )
286 if ( !( e->state() & Qt::RightButton ) && !( e->state() & Qt::MidButton ) )
289 TQPoint p = parentWidget()->mapFromGlobal( e->globalPos() );
308 if ( m_pClient != 0L )
309 TQApplication::sendEvent( m_pClient, &cfme );
321 TQRect resizeRect( x(), y(), width(), height() );
326 int maxWidth = QWIDGETSIZE_MAX;
327 int maxHeight = QWIDGETSIZE_MAX;
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;
340 if ( minWidth < minimumWidth() )
341 minWidth = minimumWidth();
343 if ( minHeight < minimumHeight() )
344 minHeight = minimumHeight();
346 if ( maxWidth > maximumWidth() )
347 maxWidth = maximumWidth();
349 if ( maxHeight > maximumHeight() )
350 maxHeight = maximumHeight();
352 TQPoint mousePos( xPos, yPos );
355 switch ( resizeCorner )
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 );
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 );
382 switch ( resizeCorner )
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 );
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 );
407 setGeometry( resizeRect );
409 if ( m_state == Maximized )
412 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
420 int ret = KMDI_NORESIZE;
421 if ( m_pClient->minimumWidth() != m_pClient->maximumWidth() )
423 if ( ( ax > 0 ) && ( ax < ( KMDI_CHILDFRM_BORDER + 2 ) ) )
424 ret |= KMDI_RESIZE_LEFT;
426 if ( ( ax < width() ) && ( ax > ( width() - ( KMDI_CHILDFRM_BORDER + 2 ) ) ) )
427 ret |= KMDI_RESIZE_RIGHT;
429 if ( m_pClient->minimumHeight() != m_pClient->maximumHeight() )
431 if ( ( ay > 0 ) && ( ay < ( KMDI_CHILDFRM_BORDER + 2 ) ) )
432 ret |= KMDI_RESIZE_TOP;
434 if ( ( ay < ( height() ) ) && ( ay > ( height() - ( KMDI_CHILDFRM_BORDER + 2 ) ) ) )
435 ret |= KMDI_RESIZE_BOTTOM;
460 if ( m_state == Normal )
463 if ( m_state == Maximized )
503 if ( m_state == Minimized )
513 if ( m_state == Normal )
514 m_restoredRect = TQRect( x(), y(), width(), height() );
527 m_pClient->
setMaximumSize( m_pClient->maximumSize().width(), m_pClient->maximumSize().height() );
528 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
529 setGeometry( m_restoredRect );
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 )
539 m_pClient->layout() ->setResizeMode( m_oldLayoutResizeMode );
541 m_pMinimize->setPixmap( *m_pMinButtonPixmap );
542 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
543 TQObject::disconnect( m_pMinimize, TQT_SIGNAL( clicked() ),
this, TQT_SLOT(
restorePressed() ) );
544 TQObject::connect( m_pMinimize, TQT_SIGNAL( clicked() ),
this, TQT_SLOT(
minimizePressed() ) );
545 setGeometry( m_restoredRect );
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 )
563 m_pClient->layout() ->setResizeMode( m_oldLayoutResizeMode );
565 setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
567 m_pMaximize->setPixmap( *m_pRestoreButtonPixmap );
568 m_pMinimize->setPixmap( *m_pMinButtonPixmap );
569 TQObject::disconnect( m_pMinimize, TQT_SIGNAL( clicked() ),
this, TQT_SLOT(
restorePressed() ) );
570 TQObject::connect( m_pMinimize, TQT_SIGNAL( clicked() ),
this, TQT_SLOT(
minimizePressed() ) );
571 int nFrameWidth = KMDI_CHILDFRM_DOUBLE_BORDER;
572 int nFrameHeight = KMDI_CHILDFRM_DOUBLE_BORDER + KMDI_CHILDFRM_SEPARATOR +
574 setGeometry( -m_pClient->x(), -m_pClient->y(),
575 m_pManager->width() + nFrameWidth,
576 m_pManager->height() + nFrameHeight );
585 setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
586 m_pMaximize->setPixmap( *m_pRestoreButtonPixmap );
587 int nFrameWidth = KMDI_CHILDFRM_DOUBLE_BORDER;
588 int nFrameHeight = KMDI_CHILDFRM_DOUBLE_BORDER + KMDI_CHILDFRM_SEPARATOR +
590 TQRect maximizedFrmRect( -m_pClient->x(), -m_pClient->y(),
591 m_pManager->width() + nFrameWidth,
592 m_pManager->height() + nFrameHeight );
593 if ( geometry() != maximizedFrmRect )
595 setGeometry( maximizedFrmRect );
611 m_oldClientMinSize = m_pClient->minimumSize();
612 m_oldClientMaxSize = m_pClient->maximumSize();
613 if ( m_pClient->layout() != 0L )
615 m_oldLayoutResizeMode = m_pClient->layout() ->resizeMode();
619 if ( m_pClient->layout() != 0L )
621 m_pClient->layout() ->setResizeMode( TQLayout::FreeResize );
630 m_oldClientMinSize = m_pClient->minimumSize();
631 m_oldClientMaxSize = m_pClient->maximumSize();
632 if ( m_pClient->layout() != 0L )
634 m_oldLayoutResizeMode = m_pClient->layout() ->resizeMode();
636 m_restoredRect = geometry();
639 if ( m_pClient->layout() != 0L )
641 m_pClient->layout() ->setResizeMode( TQLayout::FreeResize );
654 if ( pTopFrame != 0L )
656 pTopChild = pTopFrame->m_pClient;
658 if ( ( pTopChild != 0L ) && pTopChild->
isMaximized() )
660 m_pManager->setMinimumSize( pTopChild->minimumWidth(), pTopChild->minimumHeight() );
666 m_pManager->setMinimumSize( 0, 0 );
667 m_pManager->setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
675 return m_restoredRect;
682 m_restoredRect = newRestGeo;
696 m_pClose->setEnabled( bEnable );
697 m_pClose->repaint(
false );
705 if ( p.width() != 18 || p.height() != 18 )
707 TQImage img = p.convertToImage();
708 p = img.smoothScale( 18, 18, TQ_ScaleMin );
710 const bool do_resize = m_pIconButtonPixmap->size() != p.size();
711 *m_pIconButtonPixmap = p;
712 m_pWinIcon->setPixmap( p );
713 m_pUnixIcon->setPixmap( p );
722 return m_pIconButtonPixmap;
734 int clientYPos = m_pCaption->
heightHint() + KMDI_CHILDFRM_SEPARATOR + KMDI_CHILDFRM_BORDER;
735 if ( bAutomaticResize || w->size().isEmpty() || ( w->size() == TQSize( 1, 1 ) ) )
739 resize( m_pManager->
topChild() ->size() );
749 resize( w->width() + KMDI_CHILDFRM_DOUBLE_BORDER, w->height() + KMDI_CHILDFRM_BORDER + clientYPos );
753 TQDict<TQ_FocusPolicy>* pFocPolDict =
new TQDict<TQ_FocusPolicy>;
754 pFocPolDict->setAutoDelete(
true );
755 TQObjectList *list = m_pClient->queryList( TQWIDGET_OBJECT_NAME_STRING );
756 TQObjectListIt it( *list );
759 while ( ( obj = it.current() ) != 0 )
762 TQWidget* widg = ( TQWidget* ) obj;
763 if ( widg->name( 0 ) == 0 )
767 tmpStr =
"unnamed" + tmpStr;
768 widg->setName( tmpStr.latin1() );
771 TQ_FocusPolicy* pFocPol =
new TQ_FocusPolicy;
772 *pFocPol = widg->focusPolicy();
773 pFocPolDict->insert( widg->name(), pFocPol );
778 if ( TQT_BASE_OBJECT(w->parent()) != TQT_BASE_OBJECT(
this) )
781 TQPoint pnt2( KMDI_CHILDFRM_BORDER, clientYPos );
782 TQSize mincs = w->minimumSize();
783 TQSize maxcs = w->maximumSize();
788 w->reparent(
this, 0, pnt2, w->isVisible() );
794 w->move( KMDI_CHILDFRM_BORDER, clientYPos );
798 TQObject::connect( m_pClient, TQT_SIGNAL( mdiParentNowMaximized(
bool ) ), m_pManager, TQT_SIGNAL( nowMaximized(
bool ) ) );
801 setMinimumWidth( m_pClient->minimumSize().width() + KMDI_CHILDFRM_DOUBLE_BORDER );
805 setMinimumHeight( m_pClient->minimumSize().height() + KMDI_CHILDFRM_DOUBLE_BORDER +
806 m_pCaption->
heightHint() + KMDI_CHILDFRM_SEPARATOR );
817 TQObject::disconnect( m_pClient, TQT_SIGNAL( mdiParentNowMaximized(
bool ) ), m_pManager, TQT_SIGNAL( nowMaximized(
bool ) ) );
820 TQDict<TQ_FocusPolicy>* pFocPolDict;
825 const char* nameOfFocusedWidget =
"";
826 if ( focusedChildWidget != 0 )
827 nameOfFocusedWidget = focusedChildWidget->name();
829 TQSize mins = m_pClient->minimumSize();
830 TQSize maxs = m_pClient->maximumSize();
831 m_pClient->reparent( 0, 0, mapToGlobal( pos() ) - pos() + positionOffset, isVisible() );
836 TQObjectList *list = m_pClient->queryList( TQWIDGET_OBJECT_NAME_STRING );
837 TQObjectListIt it( *list );
839 TQWidget* firstFocusableChildWidget = 0;
840 TQWidget* lastFocusableChildWidget = 0;
841 while ( ( obj = it.current() ) != 0 )
843 TQWidget * widg = ( TQWidget* ) obj;
845 TQ_FocusPolicy* pFocPol = pFocPolDict->find( widg->name() );
847 widg->setFocusPolicy( *pFocPol );
850 if ( widg->name() == nameOfFocusedWidget )
854 if ( ( widg->focusPolicy() == TQ_StrongFocus ) || ( widg->focusPolicy() == TQ_TabFocus ) )
856 if ( firstFocusableChildWidget == 0 )
857 firstFocusableChildWidget = widg;
858 lastFocusableChildWidget = widg;
863 if ( widg->focusPolicy() == TQ_WheelFocus )
865 if ( firstFocusableChildWidget == 0 )
866 firstFocusableChildWidget = widg;
867 lastFocusableChildWidget = widg;
880 m_pClient->setFocusPolicy( TQ_ClickFocus );
890 TQObjectList* list = m_pClient->queryList( TQWIDGET_OBJECT_NAME_STRING );
891 TQObjectListIt it( *list );
893 while ( ( obj = it.current() ) != 0 )
895 TQWidget* widg = ( TQWidget* ) obj;
897 TQ_FocusPolicy* pFocPol = pFocPolDict->find( widg->name() );
900 widg->setFocusPolicy( *pFocPol );
902 if ( !( widg->inherits( TQPOPUPMENU_OBJECT_NAME_STRING ) ) )
903 widg->installEventFilter(
this );
910 m_pWinIcon->setFocusPolicy( TQ_NoFocus );
911 m_pUnixIcon->setFocusPolicy( TQ_NoFocus );
912 m_pClient->setFocusPolicy( TQ_ClickFocus );
913 m_pCaption->setFocusPolicy( TQ_NoFocus );
914 m_pUndock->setFocusPolicy( TQ_NoFocus );
915 m_pMinimize->setFocusPolicy( TQ_NoFocus );
916 m_pMaximize->setFocusPolicy( TQ_NoFocus );
917 m_pClose->setFocusPolicy( TQ_NoFocus );
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 );
936 TQDict<TQ_FocusPolicy>* pFocPolDict =
new TQDict<TQ_FocusPolicy>;
937 pFocPolDict->setAutoDelete(
true );
939 TQObjectList *list = m_pClient->queryList( TQWIDGET_OBJECT_NAME_STRING );
940 TQObjectListIt it( *list );
943 while ( ( obj = it.current() ) != 0 )
946 TQWidget* w = ( TQWidget* ) obj;
948 if ( w->name( 0 ) == 0 )
952 tmpStr =
"unnamed" + tmpStr;
953 w->setName( tmpStr.latin1() );
956 TQ_FocusPolicy* pFocPol =
new TQ_FocusPolicy;
957 *pFocPol = w->focusPolicy();
959 pFocPolDict->insert( w->name(), pFocPol );
961 ( ( TQWidget* ) obj ) ->removeEventFilter(
this );
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 );
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 );
1012 m_pUnixIcon->hide();
1022 frmIconHeight = buttonHeight;
1023 frmIconWidth = buttonWidth;
1025 pIconWidget = m_pUnixIcon;
1032 m_pUnixIcon->hide();
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 );
1045 m_pUnixIcon->hide();
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 );
1055 if ( !captionOnly && m_pClient )
1057 TQSize newClientSize( captionWidth,
1058 height() - ( KMDI_CHILDFRM_DOUBLE_BORDER + captionHeight + KMDI_CHILDFRM_SEPARATOR ) );
1059 if ( newClientSize != m_pClient->size() )
1061 m_pClient->setGeometry( KMDI_CHILDFRM_BORDER,
1062 m_pCaption->
heightHint() + KMDI_CHILDFRM_SEPARATOR + KMDI_CHILDFRM_BORDER,
1063 newClientSize.width(), newClientSize.height() );
1068 static bool hasParent( TQObject* par, TQObject* o )
1070 while ( o && o != par )
1079 switch ( e->type() )
1081 case TQEvent::Enter:
1084 bool bIsChild =
false;
1085 TQObject* pObj = obj;
1086 while ( ( pObj != 0L ) && !bIsChild )
1088 bIsChild = ( TQT_BASE_OBJECT(pObj) == TQT_BASE_OBJECT(
this) );
1089 pObj = pObj->parent();
1096 case TQEvent::MouseButtonPress:
1098 if ( !hasParent( TQT_TQOBJECT(m_pClient), obj ) )
1100 bool bIsSecondClick =
false;
1101 if ( m_timeMeasure.elapsed() <= TQApplication::doubleClickInterval() )
1102 bIsSecondClick =
true;
1104 if ( !( ( ( TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(m_pWinIcon) ) || ( TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(m_pUnixIcon) ) ) && bIsSecondClick ) )
1107 TQFocusEvent focusEvent( TQFocusEvent::FocusIn );
1108 TQApplication::sendEvent( tqApp->mainWidget(), &focusEvent );
1115 if ( ( TQT_BASE_OBJECT(obj->parent()) != TQT_BASE_OBJECT(m_pCaption) ) && ( TQT_BASE_OBJECT(obj) != TQT_BASE_OBJECT(m_pCaption) ) )
1117 TQWidget* w = ( TQWidget* ) obj;
1118 if ( ( w->focusPolicy() == TQ_ClickFocus ) || ( w->focusPolicy() == TQ_StrongFocus ) )
1124 if ( ( TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(m_pWinIcon) ) || ( TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(m_pUnixIcon) ) )
1127 if ( m_timeMeasure.elapsed() > TQApplication::doubleClickInterval() )
1130 m_timeMeasure.start();
1140 case TQEvent::Resize:
1142 if ( ( ( TQWidget* ) obj == m_pClient ) && ( m_state == Normal ) )
1144 TQResizeEvent* re = ( TQResizeEvent* ) e;
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 );
1153 case TQEvent::ChildRemoved:
1157 TQObject* pLostChild = TQT_TQOBJECT(( ( TQChildEvent* ) e )->child());
1158 if ( ( pLostChild != 0L ) )
1160 TQObjectList* list = pLostChild->queryList();
1161 list->insert( 0, pLostChild );
1162 TQObjectListIt it( *list );
1164 while ( ( obj = it.current() ) != 0 )
1166 TQWidget* widg = ( TQWidget* ) obj;
1168 widg->removeEventFilter(
this );
1174 case TQEvent::ChildInserted:
1179 TQObject* pNewChild = TQT_TQOBJECT(( ( TQChildEvent* ) e ) ->child());
1180 if ( ( pNewChild != 0L ) && ::tqqt_cast<TQWidget*>( pNewChild ) )
1182 TQWidget * pNewWidget = TQT_TQWIDGET( pNewChild );
1183 TQObjectList *list = pNewWidget->queryList( TQWIDGET_OBJECT_NAME_STRING );
1184 list->insert( 0, pNewChild );
1185 TQObjectListIt it( *list );
1187 while ( ( obj = it.current() ) != 0 )
1189 TQWidget * widg = ( TQWidget* ) obj;
1191 if ( !::tqqt_cast<TQPopupMenu*>( widg ) )
1193 widg->installEventFilter(
this );
1219 TQWidget::setMinimumSize( minw, minh );
1220 if ( m_state == Maximized )
1222 m_pManager->setMinimumSize( minw, minh );
1238 m_pSystemMenu->insertItem( i18n(
"&Move" ), m_pCaption, TQT_SLOT( slot_moveViaSystemMenu() ) );
1239 m_pSystemMenu->insertItem( i18n(
"R&esize" ),
this, TQT_SLOT( slot_resizeViaSystemMenu() ) );
1242 if (
state() == Normal )
1244 else if (
state() == Maximized )
1250 else if (
state() == Minimized )
1258 if (
state() != Normal )
1260 if (
state() != Maximized )
1262 if (
state() != Minimized )
1264 if (
state() != Maximized )
1265 m_pSystemMenu->insertItem( i18n(
"M&ove" ), m_pCaption, TQT_SLOT( slot_moveViaSystemMenu() ) );
1266 if (
state() == Normal )
1267 m_pSystemMenu->insertItem( i18n(
"&Resize" ),
this, TQT_SLOT( slot_resizeViaSystemMenu() ) );
1281 m_pUnixIcon->setDown(
false );
1283 TQPoint popupmenuPosition;
1287 iconGeom = m_pWinIcon->geometry();
1289 iconGeom = m_pUnixIcon->geometry();
1291 popupmenuPosition = TQPoint( iconGeom.x(), iconGeom.y() +
captionHeight() + KMDI_CHILDFRM_BORDER );
1292 systemMenu() ->popup( mapToGlobal( popupmenuPosition ) );
1297 setMinimumWidth( KMDI_CHILDFRM_MIN_WIDTH );
1298 setFixedHeight( m_pCaption->height() + KMDI_CHILDFRM_DOUBLE_BORDER );
1300 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
1303 m_pMinimize->setPixmap( *m_pRestoreButtonPixmap );
1304 TQObject::disconnect( m_pMinimize, TQT_SIGNAL( clicked() ),
this, TQT_SLOT(
minimizePressed() ) );
1305 TQObject::connect( m_pMinimize, TQT_SIGNAL( clicked() ),
this, TQT_SLOT(
restorePressed() ) );
1308 resize( 300, minimumHeight() );
1314 void KMdiChildFrm::slot_resizeViaSystemMenu()
1318 m_iResizeCorner = KMDI_RESIZE_BOTTOMLEFT;
1324 delete m_pMinButtonPixmap;
1325 delete m_pMaxButtonPixmap;
1326 delete m_pRestoreButtonPixmap;
1327 delete m_pCloseButtonPixmap;
1328 delete m_pUndockButtonPixmap;
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 );
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 );
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 );
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 );
1363 m_pUnixIcon->setAutoRaise(
true );
1366 m_pMinimize->setAutoRaise(
true );
1367 m_pMaximize->setAutoRaise(
true );
1368 m_pClose->setAutoRaise(
true );
1369 m_pUndock->setAutoRaise(
true );
1373 m_pMinimize->setAutoRaise(
false );
1374 m_pMaximize->setAutoRaise(
false );
1375 m_pClose->setAutoRaise(
false );
1376 m_pUndock->setAutoRaise(
false );
1379 if ( m_pClient && m_pClient->icon() )
1381 m_pWinIcon->setPixmap( *( m_pClient )->
icon() );
1382 m_pUnixIcon->setPixmap( *( m_pClient )->
icon() );
1386 m_pWinIcon->setPixmap( *m_pIconButtonPixmap );
1387 m_pUnixIcon->setPixmap( *m_pIconButtonPixmap );
1389 m_pClose->setPixmap( *m_pCloseButtonPixmap );
1390 m_pMinimize->setPixmap( *m_pMinButtonPixmap );
1391 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
1392 m_pUndock->setPixmap( *m_pUndockButtonPixmap );
1397 TQFrame * p = ( TQFrame* ) parentWidget();
1400 return p->contentsRect();