30 #include "tdemdichildfrm.h"
31 #include "tdemdichildfrm.moc"
33 #include "tdemdidefines.h"
34 #include "tdemdichildfrmcaption.h"
35 #include "tdemdichildarea.h"
36 #include "tdemdimainfrm.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>
48 #include <tdelocale.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,
"tdemdi_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 )
124 , m_windowMenuID( 0 )
125 , m_pSystemMenu( 0L )
126 , m_oldClientMinSize()
127 , m_oldClientMaxSize()
128 , m_oldLayoutResizeMode( TQLayout::Minimum )
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" );
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() ) );
146 m_pIconButtonPixmap =
new TQPixmap( SmallIcon(
"document-new" ) );
147 if ( m_pIconButtonPixmap->isNull() )
148 * m_pIconButtonPixmap = TQPixmap( filenew );
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 );
159 setFrameStyle( TQFrame::WinPanel | TQFrame::Raised );
160 setFocusPolicy( TQWidget::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( TQt::sizeHorCursor,
true );
243 case KMDI_RESIZE_TOP:
244 case KMDI_RESIZE_BOTTOM:
245 TQApplication::setOverrideCursor( TQt::sizeVerCursor,
true );
247 case KMDI_RESIZE_TOPLEFT:
248 case KMDI_RESIZE_BOTTOMRIGHT:
249 TQApplication::setOverrideCursor( TQt::sizeFDiagCursor,
true );
251 case KMDI_RESIZE_BOTTOMLEFT:
252 case KMDI_RESIZE_TOPRIGHT:
253 TQApplication::setOverrideCursor( TQt::sizeBDiagCursor,
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() & TQt::RightButton ) && !( e->state() & TQt::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 = TQWIDGETSIZE_MAX;
327 int maxHeight = TQWIDGETSIZE_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, TQ_SIGNAL( clicked() ),
this, TQ_SLOT(
restorePressed() ) );
544 TQObject::connect( m_pMinimize, TQ_SIGNAL( clicked() ),
this, TQ_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( TQWIDGETSIZE_MAX, TQWIDGETSIZE_MAX );
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 +
574 setGeometry( -m_pClient->x(), -m_pClient->y(),
575 m_pManager->width() + nFrameWidth,
576 m_pManager->height() + nFrameHeight );
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 +
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( TQWIDGETSIZE_MAX, TQWIDGETSIZE_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, TQImage::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<TQWidget::FocusPolicy>* pFocPolDict =
new TQDict<TQWidget::FocusPolicy>;
754 pFocPolDict->setAutoDelete(
true );
755 TQObjectList *list = m_pClient->queryList(
"TQWidget" );
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 TQWidget::FocusPolicy* pFocPol =
new TQWidget::FocusPolicy;
772 *pFocPol = widg->focusPolicy();
773 pFocPolDict->insert( widg->name(), pFocPol );
778 if ( w->parent() != 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, TQ_SIGNAL( mdiParentNowMaximized(
bool ) ), m_pManager, TQ_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, TQ_SIGNAL( mdiParentNowMaximized(
bool ) ), m_pManager, TQ_SIGNAL( nowMaximized(
bool ) ) );
820 TQDict<TQWidget::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" );
837 TQObjectListIt it( *list );
839 TQWidget* firstFocusableChildWidget = 0;
840 TQWidget* lastFocusableChildWidget = 0;
841 while ( ( obj = it.current() ) != 0 )
843 TQWidget * widg = ( TQWidget* ) obj;
845 TQWidget::FocusPolicy* pFocPol = pFocPolDict->find( widg->name() );
847 widg->setFocusPolicy( *pFocPol );
850 if ( widg->name() == nameOfFocusedWidget )
854 if ( ( widg->focusPolicy() == TQWidget::StrongFocus ) || ( widg->focusPolicy() == TQWidget::TabFocus ) )
856 if ( firstFocusableChildWidget == 0 )
857 firstFocusableChildWidget = widg;
858 lastFocusableChildWidget = widg;
863 if ( widg->focusPolicy() == TQWidget::WheelFocus )
865 if ( firstFocusableChildWidget == 0 )
866 firstFocusableChildWidget = widg;
867 lastFocusableChildWidget = widg;
880 m_pClient->setFocusPolicy( TQWidget::ClickFocus );
890 TQObjectList* list = m_pClient->queryList(
"TQWidget" );
891 TQObjectListIt it( *list );
893 while ( ( obj = it.current() ) != 0 )
895 TQWidget* widg = ( TQWidget* ) obj;
897 TQWidget::FocusPolicy* pFocPol = pFocPolDict->find( widg->name() );
900 widg->setFocusPolicy( *pFocPol );
902 if ( !( widg->inherits(
"TQPopupMenu" ) ) )
903 widg->installEventFilter(
this );
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 );
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<TQWidget::FocusPolicy>* pFocPolDict =
new TQDict<TQWidget::FocusPolicy>;
937 pFocPolDict->setAutoDelete(
true );
939 TQObjectList *list = m_pClient->queryList(
"TQWidget" );
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 TQWidget::FocusPolicy* pFocPol =
new TQWidget::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();
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 = ( pObj == this );
1089 pObj = pObj->parent();
1096 case TQEvent::MouseButtonPress:
1098 if ( !hasParent( m_pClient, obj ) )
1100 bool bIsSecondClick =
false;
1101 if ( m_timeMeasure.elapsed() <= TQApplication::doubleClickInterval() )
1102 bIsSecondClick =
true;
1104 if ( !( ( ( obj == m_pWinIcon ) || ( obj == m_pUnixIcon ) ) && bIsSecondClick ) )
1107 TQFocusEvent focusEvent( TQFocusEvent::FocusIn );
1108 TQApplication::sendEvent( tqApp->mainWidget(), &focusEvent );
1115 if ( ( obj->parent() != m_pCaption ) && ( obj != m_pCaption ) )
1117 TQWidget* w = ( TQWidget* ) obj;
1118 if ( ( w->focusPolicy() == TQWidget::ClickFocus ) || ( w->focusPolicy() == TQWidget::StrongFocus ) )
1124 if ( ( obj == m_pWinIcon ) || ( obj == 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 = ( ( 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 = ( ( TQChildEvent* ) e ) ->child();
1180 if ( ( pNewChild != 0L ) && ::tqt_cast<TQWidget*>( pNewChild ) )
1182 TQWidget * pNewWidget =
static_cast<TQWidget*
>( pNewChild );
1183 TQObjectList *list = pNewWidget->queryList(
"TQWidget" );
1184 list->insert( 0, pNewChild );
1185 TQObjectListIt it( *list );
1187 while ( ( obj = it.current() ) != 0 )
1189 TQWidget * widg = ( TQWidget* ) obj;
1191 if ( !::tqt_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, TQ_SLOT( slot_moveViaSystemMenu() ) );
1239 m_pSystemMenu->insertItem( i18n(
"R&esize" ),
this, TQ_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, TQ_SLOT( slot_moveViaSystemMenu() ) );
1266 if (
state() == Normal )
1267 m_pSystemMenu->insertItem( i18n(
"&Resize" ),
this, TQ_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, TQ_SIGNAL( clicked() ),
this, TQ_SLOT(
minimizePressed() ) );
1305 TQObject::connect( m_pMinimize, TQ_SIGNAL( clicked() ),
this, TQ_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();
void nowMaximized(bool)
Signals that the child frames are maximized now.
KMdiChildFrm * topChild() const
Returns the topmost child (the active one) or 0 if there are no children.
void childMinimized(KMdiChildFrm *lpC, bool bWasMaximized)
Internally used.
void layoutMinimizedChildren()
Position and layout the minimized child frames.
void setTopChild(KMdiChildFrm *child, bool setFocus=false)
Brings the child to the top of the stack The child is focused if setFocus is true.
TQSize m_defaultChildFrmSize
the default size of an newly created childframe
int heightHint()
Returns the caption bar height depending on the used font.
void setCaption(const TQString &text)
Repaint with a new caption bar title.
void setActive(bool bActive)
Repaint the caption bar in active background colors.
a TQCustomEvent for move This special event will be useful, to inform view about child frame event.
a TQCustomEvent for begin of resizing This special event will be useful, to inform view about child f...
a TQCustomEvent for end of resizing This special event will be useful, to inform view about child fra...
void linkChildren(TQDict< TQWidget::FocusPolicy > *pFocPolDict)
Restore the focus policies for all widgets in the view using the list given as parameter.
TQDict< TQWidget::FocusPolicy > * unlinkChildren()
Backups all focus policies of all child widgets in the MDI childview since they get lost during a rep...
void maximizePressed()
Handles a click on the Maximize button.
MdiWindowState state() const
Returns the current state of the window.
virtual void mousePressEvent(TQMouseEvent *e)
Reimplemented from the base class.
virtual void switchToMinimizeLayout()
That means to show a mini window showing the childframe's caption bar, only.
TQRect mdiAreaContentsRect() const
Returns the inner client area of the parent of this (which is KMdiChildArea).
int getResizeCorner(int ax, int ay)
Calculates the corner id for the resize cursor.
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...
virtual void resizeEvent(TQResizeEvent *)
Reimplemented from the base class.
void raiseAndActivate()
Internally called from the signal focusInEventOccurs.
virtual void mouseMoveEvent(TQMouseEvent *e)
Reimplemented from the base class.
void setState(MdiWindowState state, bool bAnimate=true)
Minimizes, Maximizes, or restores the window.
void setRestoreGeometry(const TQRect &newRestGeo)
Sets the geometry that will be restored by calling restore().
void setResizeCursor(int resizeCorner)
Override the cursor appearance depending on the widget corner given as parameter.
TQPixmap * icon() const
Returns the child frame icon.
virtual bool eventFilter(TQObject *, TQEvent *)
Reimplemented from the base class.
TQPopupMenu * systemMenu() const
Returns the system menu.
void restorePressed()
Handles a click on the Restore (Normalize) button.
void enableClose(bool bEnable)
Enables or disables the close button.
virtual void setMinimumSize(int minw, int minh)
Sets the minimum size of the widget to w by h pixels.
TQRect restoreGeometry() const
Returns the geometry that will be restored by calling restore().
void doResize()
Does the actual resize.
void unsetResizeCursor()
Changes from the resize cursor to the normal (previous) cursor.
void unsetClient(TQPoint positionOffset=TQPoint(0, 0))
Reparents the client widget to 0 (desktop), moves with an offset from the original position Removes t...
void setIcon(const TQPixmap &pxm)
Sets the window icon pointer.
void undockPressed()
Handles a click on the Undock (Detach) button.
void minimizePressed()
Handles a click on the Minimize button.
void resizeWindow(int resizeCorner, int x, int y)
Calculates the new geometry from the new mouse position given as parameters and calls KMdiChildFrm::s...
virtual void moveEvent(TQMoveEvent *me)
Reimplemented from the base class.
virtual void leaveEvent(TQEvent *)
Reimplemented from the base class.
void redecorateButtons()
sets new raise behavior and pixmaps of the buttons depending on the current decoration style
void showSystemMenu()
Shows a system menu for child frame windows.
~KMdiChildFrm()
Destroys this KMdiChildFrm If a child is still here managed (no recreation was made) it is destroyed ...
KMdiChildFrm(KMdiChildArea *parent)
Creates a new KMdiChildFrm class.
void closePressed()
Handles a click on the Close button.
TQPopupMenu * m_pSystemMenu
Imitates a system menu for child frame windows.
int captionHeight() const
Returns the caption bar height.
virtual void mouseReleaseEvent(TQMouseEvent *)
Reimplemented from the base class.
void setCaption(const TQString &text)
Sets the caption of this window.
Base class for all your special view windows.
virtual void detach()
Detaches this window from the Mdi manager.
bool isMaximized() const
Tells if the window is minimized when attached to the Mdi manager, otherwise returns false.
void activate()
This method does the same as focusInEvent().
void setFirstFocusableChildWidget(TQWidget *)
Memorizes the first focusable child widget of this widget.
bool m_stateChanged
Holds a temporary information about if the MDI view state has changed but is not processed yet (pendi...
TQWidget * focusedChildWidget()
Returns the current focused child widget of this widget.
void setLastFocusableChildWidget(TQWidget *)
Memorizes the last focusable child widget of this widget.
virtual void setMinimumSize(int minw, int minh)
Sets the minimum size of the widget to w by h pixels.
void updateTimeStamp()
Remember the current time.
virtual void setMaximumSize(int maxw, int maxh)
Sets the maximum size of the widget to w by h pixels.
static int frameDecorOfAttachedViews()