00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "kmdichildfrm.h"
00031 #include "kmdichildfrm.moc"
00032
00033 #include "kmdidefines.h"
00034 #include "kmdichildfrmcaption.h"
00035 #include "kmdichildarea.h"
00036 #include "kmdimainfrm.h"
00037
00038 #include <qpainter.h>
00039 #include <qapplication.h>
00040 #include <qcursor.h>
00041 #include <qobjectlist.h>
00042 #include <qframe.h>
00043 #include <qpopupmenu.h>
00044 #include <qtoolbutton.h>
00045 #include <qnamespace.h>
00046 #include <qimage.h>
00047
00048 #include <klocale.h>
00049 #include <kiconloader.h>
00050
00052
00054
00055 #define KMDI_NORESIZE 0
00056 #define KMDI_RESIZE_TOP 1
00057 #define KMDI_RESIZE_LEFT 2
00058 #define KMDI_RESIZE_RIGHT 4
00059 #define KMDI_RESIZE_BOTTOM 8
00060 #define KMDI_RESIZE_TOPLEFT (1|2)
00061 #define KMDI_RESIZE_TOPRIGHT (1|4)
00062 #define KMDI_RESIZE_BOTTOMLEFT (8|2)
00063 #define KMDI_RESIZE_BOTTOMRIGHT (8|4)
00064
00065 #include "filenew.xpm"
00066 #include "win_closebutton.xpm"
00067 #include "win_minbutton.xpm"
00068 #include "win_maxbutton.xpm"
00069 #include "win_restorebutton.xpm"
00070 #include "win_undockbutton.xpm"
00071 #include "kde_closebutton.xpm"
00072 #include "kde_minbutton.xpm"
00073 #include "kde_maxbutton.xpm"
00074 #include "kde_restorebutton.xpm"
00075 #include "kde_undockbutton.xpm"
00076 #include "kde2_closebutton.xpm"
00077 #include "kde2_minbutton.xpm"
00078 #include "kde2_maxbutton.xpm"
00079 #include "kde2_restorebutton.xpm"
00080 #include "kde2_undockbutton.xpm"
00081 #include "kde2laptop_closebutton.xpm"
00082 #include "kde2laptop_minbutton.xpm"
00083 #include "kde2laptop_maxbutton.xpm"
00084 #include "kde2laptop_restorebutton.xpm"
00085 #include "kde2laptop_undockbutton.xpm"
00086
00087
00088 KMdiWin32IconButton::KMdiWin32IconButton( QWidget* parent, const char* name )
00089 : QLabel( parent, name )
00090 {}
00091
00092
00093
00094 void KMdiWin32IconButton::mousePressEvent( QMouseEvent* )
00095 {
00096
00097 }
00098
00099
00100
00101 KMdiChildFrm::KMdiChildFrm( KMdiChildArea *parent )
00102 : QFrame( parent, "kmdi_childfrm" )
00103 , m_pClient( 0L )
00104 , m_pManager( 0L )
00105 , m_pCaption( 0L )
00106 , m_pWinIcon( 0L )
00107 , m_pUnixIcon( 0L )
00108 , m_pMinimize( 0L )
00109 , m_pMaximize( 0L )
00110 , m_pClose( 0L )
00111 , m_pUndock( 0L )
00112 , m_state( Normal )
00113 , m_restoredRect()
00114 , m_iResizeCorner( KMDI_NORESIZE )
00115 , m_iLastCursorCorner( KMDI_NORESIZE )
00116 , m_bResizing( false )
00117 , m_bDragging( false )
00118 , m_pIconButtonPixmap( 0L )
00119 , m_pMinButtonPixmap( 0L )
00120 , m_pMaxButtonPixmap( 0L )
00121 , m_pRestoreButtonPixmap( 0L )
00122 , m_pCloseButtonPixmap( 0L )
00123 , m_pUndockButtonPixmap( 0L )
00124 , m_windowMenuID( 0 )
00125 , m_pSystemMenu( 0L )
00126 , m_oldClientMinSize()
00127 , m_oldClientMaxSize()
00128 , m_oldLayoutResizeMode( QLayout::Minimum )
00129 {
00130 m_pCaption = new KMdiChildFrmCaption( this );
00131
00132 m_pManager = parent;
00133
00134 m_pWinIcon = new KMdiWin32IconButton( m_pCaption, "kmdi_iconbutton_icon" );
00135 m_pUnixIcon = new QToolButton( m_pCaption, "kmdi_toolbutton_icon" );
00136 m_pMinimize = new QToolButton( m_pCaption, "kmdi_toolbutton_min" );
00137 m_pMaximize = new QToolButton( m_pCaption, "kmdi_toolbutton_max" );
00138 m_pClose = new QToolButton( m_pCaption, "kmdi_toolbutton_close" );
00139 m_pUndock = new QToolButton( m_pCaption, "kmdi_toolbutton_undock" );
00140
00141 QObject::connect( m_pMinimize, SIGNAL( clicked() ), this, SLOT( minimizePressed() ) );
00142 QObject::connect( m_pMaximize, SIGNAL( clicked() ), this, SLOT( maximizePressed() ) );
00143 QObject::connect( m_pClose, SIGNAL( clicked() ), this, SLOT( closePressed() ) );
00144 QObject::connect( m_pUndock, SIGNAL( clicked() ), this, SLOT( undockPressed() ) );
00145
00146 m_pIconButtonPixmap = new QPixmap( SmallIcon( "filenew" ) );
00147 if ( m_pIconButtonPixmap->isNull() )
00148 * m_pIconButtonPixmap = QPixmap( filenew );
00149
00150 redecorateButtons();
00151
00152 m_pWinIcon->setFocusPolicy( NoFocus );
00153 m_pUnixIcon->setFocusPolicy( NoFocus );
00154 m_pClose->setFocusPolicy( NoFocus );
00155 m_pMinimize->setFocusPolicy( NoFocus );
00156 m_pMaximize->setFocusPolicy( NoFocus );
00157 m_pUndock->setFocusPolicy( NoFocus );
00158
00159 setFrameStyle( QFrame::WinPanel | QFrame::Raised );
00160 setFocusPolicy( NoFocus );
00161
00162 setMouseTracking( true );
00163
00164 setMinimumSize( KMDI_CHILDFRM_MIN_WIDTH, m_pCaption->heightHint() );
00165
00166 m_pSystemMenu = new QPopupMenu();
00167 }
00168
00169
00170
00171 KMdiChildFrm::~KMdiChildFrm()
00172 {
00173 delete m_pMinButtonPixmap;
00174 delete m_pMaxButtonPixmap;
00175 delete m_pRestoreButtonPixmap;
00176 delete m_pCloseButtonPixmap;
00177 delete m_pUndockButtonPixmap;
00178 delete m_pSystemMenu;
00179 delete m_pIconButtonPixmap;
00180 }
00181
00182
00183 void KMdiChildFrm::mousePressEvent( QMouseEvent *e )
00184 {
00185 if ( m_bResizing )
00186 {
00187 if ( QApplication::overrideCursor() )
00188 QApplication::restoreOverrideCursor();
00189
00190 m_bResizing = false;
00191 releaseMouse();
00192 }
00193
00194 m_pCaption->setActive( true );
00195 m_pManager->setTopChild( this, false );
00196
00197 m_iResizeCorner = getResizeCorner( e->pos().x(), e->pos().y() );
00198 if ( m_iResizeCorner != KMDI_NORESIZE )
00199 {
00200 m_bResizing = true;
00201
00202 KMdiChildFrmResizeBeginEvent ue( e );
00203 if ( m_pClient != 0L )
00204 QApplication::sendEvent( m_pClient, &ue );
00205 }
00206 }
00207
00208
00209
00210 void KMdiChildFrm::mouseReleaseEvent( QMouseEvent *e )
00211 {
00212 if ( m_bResizing )
00213 {
00214 if ( QApplication::overrideCursor() )
00215 QApplication::restoreOverrideCursor();
00216
00217 m_bResizing = false;
00218
00219 KMdiChildFrmResizeEndEvent ue( e );
00220 if ( m_pClient != 0L )
00221 QApplication::sendEvent( m_pClient, &ue );
00222 }
00223 }
00224
00225
00226
00227 void KMdiChildFrm::setResizeCursor( int resizeCorner )
00228 {
00229 if ( resizeCorner == m_iLastCursorCorner )
00230 return ;
00231
00232 m_iLastCursorCorner = resizeCorner;
00233 switch ( resizeCorner )
00234 {
00235 case KMDI_NORESIZE:
00236 if ( QApplication::overrideCursor() )
00237 QApplication::restoreOverrideCursor();
00238 break;
00239 case KMDI_RESIZE_LEFT:
00240 case KMDI_RESIZE_RIGHT:
00241 QApplication::setOverrideCursor( Qt::sizeHorCursor, true );
00242 break;
00243 case KMDI_RESIZE_TOP:
00244 case KMDI_RESIZE_BOTTOM:
00245 QApplication::setOverrideCursor( Qt::sizeVerCursor, true );
00246 break;
00247 case KMDI_RESIZE_TOPLEFT:
00248 case KMDI_RESIZE_BOTTOMRIGHT:
00249 QApplication::setOverrideCursor( Qt::sizeFDiagCursor, true );
00250 break;
00251 case KMDI_RESIZE_BOTTOMLEFT:
00252 case KMDI_RESIZE_TOPRIGHT:
00253 QApplication::setOverrideCursor( Qt::sizeBDiagCursor, true );
00254 break;
00255 }
00256 }
00257
00258
00259
00260 void KMdiChildFrm::unsetResizeCursor()
00261 {
00262 if ( !m_bResizing && m_iResizeCorner != KMDI_NORESIZE )
00263 {
00264 m_iResizeCorner = KMDI_NORESIZE;
00265 m_iLastCursorCorner = KMDI_NORESIZE;
00266 if ( QApplication::overrideCursor() )
00267 QApplication::restoreOverrideCursor();
00268 }
00269 }
00270
00271
00272
00273 void KMdiChildFrm::mouseMoveEvent( QMouseEvent *e )
00274 {
00275 if ( m_state != Normal )
00276 return;
00277
00278 if ( !m_pClient )
00279 return;
00280
00281 if ( m_pClient->minimumSize() == m_pClient->maximumSize() )
00282 return;
00283
00284 if ( m_bResizing )
00285 {
00286 if ( !( e->state() & RightButton ) && !( e->state() & MidButton ) )
00287 {
00288
00289 QPoint p = parentWidget()->mapFromGlobal( e->globalPos() );
00290 resizeWindow( m_iResizeCorner, p.x(), p.y() );
00291 }
00292 else
00293 m_bResizing = false;
00294 }
00295 else
00296 {
00297 m_iResizeCorner = getResizeCorner( e->pos().x(), e->pos().y() );
00298 setResizeCursor( m_iResizeCorner );
00299 }
00300 }
00301
00302
00303
00304 void KMdiChildFrm::moveEvent( QMoveEvent* me )
00305 {
00306
00307 KMdiChildFrmMoveEvent cfme( me );
00308 if ( m_pClient != 0L )
00309 QApplication::sendEvent( m_pClient, &cfme );
00310 }
00311
00312
00313
00314 void KMdiChildFrm::leaveEvent( QEvent * )
00315 {
00316 unsetResizeCursor();
00317 }
00318
00319 void KMdiChildFrm::resizeWindow( int resizeCorner, int xPos, int yPos )
00320 {
00321 QRect resizeRect( x(), y(), width(), height() );
00322
00323
00324 int minWidth = 0;
00325 int minHeight = 0;
00326 int maxWidth = QWIDGETSIZE_MAX;
00327 int maxHeight = QWIDGETSIZE_MAX;
00328
00329
00330 if ( m_pClient )
00331 {
00332 minWidth = m_pClient->minimumSize().width() + KMDI_CHILDFRM_DOUBLE_BORDER;
00333 minHeight = m_pClient->minimumSize().height() + KMDI_CHILDFRM_DOUBLE_BORDER +
00334 m_pCaption->heightHint() + KMDI_CHILDFRM_SEPARATOR;
00335 maxWidth = m_pClient->maximumSize().width() + KMDI_CHILDFRM_DOUBLE_BORDER;
00336 maxHeight = m_pClient->maximumSize().height() + KMDI_CHILDFRM_DOUBLE_BORDER +
00337 m_pCaption->heightHint() + KMDI_CHILDFRM_SEPARATOR;
00338 }
00339
00340 if ( minWidth < minimumWidth() )
00341 minWidth = minimumWidth();
00342
00343 if ( minHeight < minimumHeight() )
00344 minHeight = minimumHeight();
00345
00346 if ( maxWidth > maximumWidth() )
00347 maxWidth = maximumWidth();
00348
00349 if ( maxHeight > maximumHeight() )
00350 maxHeight = maximumHeight();
00351
00352 QPoint mousePos( xPos, yPos );
00353
00354
00355 switch ( resizeCorner )
00356 {
00357
00358 case KMDI_RESIZE_TOPLEFT:
00359 case KMDI_RESIZE_LEFT:
00360 case KMDI_RESIZE_BOTTOMLEFT:
00361 resizeRect.setLeft( mousePos.x() );
00362 if ( resizeRect.width() < minWidth )
00363 resizeRect.setLeft( resizeRect.right() - minWidth + 1 );
00364 if ( resizeRect.width() > maxWidth )
00365 resizeRect.setLeft( resizeRect.right() - maxWidth + 1 );
00366 break;
00367
00368 case KMDI_RESIZE_TOPRIGHT:
00369 case KMDI_RESIZE_RIGHT:
00370 case KMDI_RESIZE_BOTTOMRIGHT:
00371 resizeRect.setRight( mousePos.x() );
00372 if ( resizeRect.width() < minWidth )
00373 resizeRect.setRight( resizeRect.left() + minWidth - 1 );
00374 if ( resizeRect.width() > maxWidth )
00375 resizeRect.setRight( resizeRect.left() + maxWidth - 1 );
00376 break;
00377 default:
00378 break;
00379 }
00380
00381
00382 switch ( resizeCorner )
00383 {
00384 case KMDI_RESIZE_TOPLEFT:
00385 case KMDI_RESIZE_TOP:
00386 case KMDI_RESIZE_TOPRIGHT:
00387 resizeRect.setTop( mousePos.y() );
00388 if ( resizeRect.height() < minHeight )
00389 resizeRect.setTop( resizeRect.bottom() - minHeight + 1 );
00390 if ( resizeRect.height() > maxHeight )
00391 resizeRect.setTop( resizeRect.bottom() - maxHeight + 1 );
00392 break;
00393 case KMDI_RESIZE_BOTTOMLEFT:
00394 case KMDI_RESIZE_BOTTOM:
00395 case KMDI_RESIZE_BOTTOMRIGHT:
00396 resizeRect.setBottom( mousePos.y() );
00397 if ( resizeRect.height() < minHeight )
00398 resizeRect.setBottom( resizeRect.top() + minHeight - 1 );
00399 if ( resizeRect.height() > maxHeight )
00400 resizeRect.setBottom( resizeRect.top() + maxHeight - 1 );
00401 break;
00402 default:
00403
00404 break;
00405 }
00406
00407 setGeometry( resizeRect );
00408
00409 if ( m_state == Maximized )
00410 {
00411 m_state = Normal;
00412 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
00413 }
00414 }
00415
00416
00417
00418 int KMdiChildFrm::getResizeCorner( int ax, int ay )
00419 {
00420 int ret = KMDI_NORESIZE;
00421 if ( m_pClient->minimumWidth() != m_pClient->maximumWidth() )
00422 {
00423 if ( ( ax > 0 ) && ( ax < ( KMDI_CHILDFRM_BORDER + 2 ) ) )
00424 ret |= KMDI_RESIZE_LEFT;
00425
00426 if ( ( ax < width() ) && ( ax > ( width() - ( KMDI_CHILDFRM_BORDER + 2 ) ) ) )
00427 ret |= KMDI_RESIZE_RIGHT;
00428 }
00429 if ( m_pClient->minimumHeight() != m_pClient->maximumHeight() )
00430 {
00431 if ( ( ay > 0 ) && ( ay < ( KMDI_CHILDFRM_BORDER + 2 ) ) )
00432 ret |= KMDI_RESIZE_TOP;
00433
00434 if ( ( ay < ( height() ) ) && ( ay > ( height() - ( KMDI_CHILDFRM_BORDER + 2 ) ) ) )
00435 ret |= KMDI_RESIZE_BOTTOM;
00436 }
00437 return ret;
00438 }
00439
00440
00441
00442 void KMdiChildFrm::maximizePressed()
00443 {
00444 switch ( m_state )
00445 {
00446 case Maximized:
00447 emit m_pManager->nowMaximized( false );
00448 setState( Normal );
00449 break;
00450 case Normal:
00451 case Minimized:
00452 setState( Maximized );
00453 emit m_pManager->nowMaximized( true );
00454 break;
00455 }
00456 }
00457
00458 void KMdiChildFrm::restorePressed()
00459 {
00460 if ( m_state == Normal )
00461 return ;
00462
00463 if ( m_state == Maximized )
00464 emit m_pManager->nowMaximized( false );
00465
00466 setState( Normal );
00467 }
00468
00469
00470
00471 void KMdiChildFrm::minimizePressed()
00472 {
00473 switch ( m_state )
00474 {
00475 case Minimized:
00476 setState( Normal );
00477 break;
00478 case Normal:
00479 setState( Minimized );
00480 break;
00481 case Maximized:
00482 emit m_pManager->nowMaximized( false );
00483 setState( Normal );
00484 setState( Minimized );
00485 break;
00486 }
00487 }
00488
00489
00490
00491 void KMdiChildFrm::closePressed()
00492 {
00493 if ( m_pClient )
00494 m_pClient->close();
00495 }
00496
00497
00498
00499 void KMdiChildFrm::undockPressed()
00500 {
00501 if ( m_pClient )
00502 {
00503 if ( m_state == Minimized )
00504 setState( Normal );
00505 m_pClient->detach();
00506 }
00507 }
00508
00509
00510
00511 void KMdiChildFrm::setState( MdiWindowState state, bool )
00512 {
00513 if ( m_state == Normal )
00514 m_restoredRect = QRect( x(), y(), width(), height() );
00515
00516 switch ( state )
00517 {
00518 case Normal:
00519 switch ( m_state )
00520 {
00521 case Maximized:
00522 m_pClient->m_stateChanged = true;
00523 m_state = state;
00524
00525
00526
00527 m_pClient->setMaximumSize( m_pClient->maximumSize().width(), m_pClient->maximumSize().height() );
00528 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
00529 setGeometry( m_restoredRect );
00530 break;
00531 case Minimized:
00532 m_pClient->m_stateChanged = true;
00533 m_state = state;
00534
00535 m_pClient->setMinimumSize( m_oldClientMinSize.width(), m_oldClientMinSize.height() );
00536 m_pClient->setMaximumSize( m_oldClientMaxSize.width(), m_oldClientMaxSize.height() );
00537 if ( m_pClient->layout() != 0L )
00538 {
00539 m_pClient->layout() ->setResizeMode( m_oldLayoutResizeMode );
00540 }
00541 m_pMinimize->setPixmap( *m_pMinButtonPixmap );
00542 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
00543 QObject::disconnect( m_pMinimize, SIGNAL( clicked() ), this, SLOT( restorePressed() ) );
00544 QObject::connect( m_pMinimize, SIGNAL( clicked() ), this, SLOT( minimizePressed() ) );
00545 setGeometry( m_restoredRect );
00546 break;
00547 case Normal:
00548 break;
00549 }
00550 break;
00551 case Maximized:
00552 switch ( m_state )
00553 {
00554 case Minimized:
00555 {
00556 m_pClient->m_stateChanged = true;
00557 m_state = state;
00558
00559 m_pClient->setMinimumSize( m_oldClientMinSize.width(), m_oldClientMinSize.height() );
00560 m_pClient->setMaximumSize( m_oldClientMaxSize.width(), m_oldClientMaxSize.height() );
00561 if ( m_pClient->layout() != 0L )
00562 {
00563 m_pClient->layout() ->setResizeMode( m_oldLayoutResizeMode );
00564 }
00565 setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
00566
00567 m_pMaximize->setPixmap( *m_pRestoreButtonPixmap );
00568 m_pMinimize->setPixmap( *m_pMinButtonPixmap );
00569 QObject::disconnect( m_pMinimize, SIGNAL( clicked() ), this, SLOT( restorePressed() ) );
00570 QObject::connect( m_pMinimize, SIGNAL( clicked() ), this, SLOT( minimizePressed() ) );
00571 int nFrameWidth = KMDI_CHILDFRM_DOUBLE_BORDER;
00572 int nFrameHeight = KMDI_CHILDFRM_DOUBLE_BORDER + KMDI_CHILDFRM_SEPARATOR +
00573 m_pCaption->heightHint();
00574 setGeometry( -m_pClient->x(), -m_pClient->y(),
00575 m_pManager->width() + nFrameWidth,
00576 m_pManager->height() + nFrameHeight );
00577 raise();
00578 }
00579 break;
00580 case Normal:
00581 {
00582 m_pClient->m_stateChanged = true;
00583 m_state = state;
00584
00585 setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
00586 m_pMaximize->setPixmap( *m_pRestoreButtonPixmap );
00587 int nFrameWidth = KMDI_CHILDFRM_DOUBLE_BORDER;
00588 int nFrameHeight = KMDI_CHILDFRM_DOUBLE_BORDER + KMDI_CHILDFRM_SEPARATOR +
00589 m_pCaption->heightHint();
00590 QRect maximizedFrmRect( -m_pClient->x(), -m_pClient->y(),
00591 m_pManager->width() + nFrameWidth,
00592 m_pManager->height() + nFrameHeight );
00593 if ( geometry() != maximizedFrmRect )
00594 {
00595 setGeometry( maximizedFrmRect );
00596 }
00597 raise();
00598 }
00599 break;
00600 case Maximized:
00601 break;
00602 }
00603 break;
00604 case Minimized:
00605 switch ( m_state )
00606 {
00607 case Maximized:
00608 m_pClient->m_stateChanged = true;
00609 m_state = state;
00610
00611 m_oldClientMinSize = m_pClient->minimumSize();
00612 m_oldClientMaxSize = m_pClient->maximumSize();
00613 if ( m_pClient->layout() != 0L )
00614 {
00615 m_oldLayoutResizeMode = m_pClient->layout() ->resizeMode();
00616 }
00617 m_pClient->setMinimumSize( 0, 0 );
00618 m_pClient->setMaximumSize( 0, 0 );
00619 if ( m_pClient->layout() != 0L )
00620 {
00621 m_pClient->layout() ->setResizeMode( QLayout::FreeResize );
00622 }
00623 switchToMinimizeLayout();
00624 m_pManager->childMinimized( this, true );
00625 break;
00626 case Normal:
00627 m_pClient->m_stateChanged = true;
00628 m_state = state;
00629
00630 m_oldClientMinSize = m_pClient->minimumSize();
00631 m_oldClientMaxSize = m_pClient->maximumSize();
00632 if ( m_pClient->layout() != 0L )
00633 {
00634 m_oldLayoutResizeMode = m_pClient->layout() ->resizeMode();
00635 }
00636 m_restoredRect = geometry();
00637 m_pClient->setMinimumSize( 0, 0 );
00638 m_pClient->setMaximumSize( 0, 0 );
00639 if ( m_pClient->layout() != 0L )
00640 {
00641 m_pClient->layout() ->setResizeMode( QLayout::FreeResize );
00642 }
00643 switchToMinimizeLayout();
00644 m_pManager->childMinimized( this, false );
00645 break;
00646 case Minimized:
00647 break;
00648 }
00649 break;
00650 }
00651
00652 KMdiChildFrm* pTopFrame = m_pManager->topChild();
00653 KMdiChildView* pTopChild = 0L;
00654 if ( pTopFrame != 0L )
00655 {
00656 pTopChild = pTopFrame->m_pClient;
00657 }
00658 if ( ( pTopChild != 0L ) && pTopChild->isMaximized() )
00659 {
00660 m_pManager->setMinimumSize( pTopChild->minimumWidth(), pTopChild->minimumHeight() );
00663 }
00664 else
00665 {
00666 m_pManager->setMinimumSize( 0, 0 );
00667 m_pManager->setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
00668 }
00669 }
00670
00671
00672
00673 QRect KMdiChildFrm::restoreGeometry() const
00674 {
00675 return m_restoredRect;
00676 }
00677
00678
00679
00680 void KMdiChildFrm::setRestoreGeometry( const QRect& newRestGeo )
00681 {
00682 m_restoredRect = newRestGeo;
00683 }
00684
00685
00686
00687 void KMdiChildFrm::setCaption( const QString& text )
00688 {
00689 m_pCaption->setCaption( text );
00690 }
00691
00692
00693
00694 void KMdiChildFrm::enableClose( bool bEnable )
00695 {
00696 m_pClose->setEnabled( bEnable );
00697 m_pClose->repaint( false );
00698 }
00699
00700
00701
00702 void KMdiChildFrm::setIcon( const QPixmap& pxm )
00703 {
00704 QPixmap p = pxm;
00705 if ( p.width() != 18 || p.height() != 18 )
00706 {
00707 QImage img = p.convertToImage();
00708 p = img.smoothScale( 18, 18, QImage::ScaleMin );
00709 }
00710 const bool do_resize = m_pIconButtonPixmap->size() != p.size();
00711 *m_pIconButtonPixmap = p;
00712 m_pWinIcon->setPixmap( p );
00713 m_pUnixIcon->setPixmap( p );
00714 if ( do_resize )
00715 doResize( true );
00716 }
00717
00718
00719
00720 QPixmap* KMdiChildFrm::icon() const
00721 {
00722 return m_pIconButtonPixmap;
00723 }
00724
00725
00726 void KMdiChildFrm::setClient( KMdiChildView *w, bool bAutomaticResize )
00727 {
00728 m_pClient = w;
00729
00730 if ( w->icon() )
00731 setIcon( *( w->icon() ) );
00732
00733
00734 int clientYPos = m_pCaption->heightHint() + KMDI_CHILDFRM_SEPARATOR + KMDI_CHILDFRM_BORDER;
00735 if ( bAutomaticResize || w->size().isEmpty() || ( w->size() == QSize( 1, 1 ) ) )
00736 {
00737 if ( m_pManager->topChild() )
00738 {
00739 resize( m_pManager->topChild() ->size() );
00740 }
00741 else
00742 {
00743 resize( m_pManager->m_defaultChildFrmSize.width() + KMDI_CHILDFRM_DOUBLE_BORDER,
00744 m_pManager->m_defaultChildFrmSize.height() + KMDI_CHILDFRM_BORDER + clientYPos );
00745 }
00746 }
00747 else
00748 {
00749 resize( w->width() + KMDI_CHILDFRM_DOUBLE_BORDER, w->height() + KMDI_CHILDFRM_BORDER + clientYPos );
00750 }
00751
00752
00753 QDict<FocusPolicy>* pFocPolDict = new QDict<FocusPolicy>;
00754 pFocPolDict->setAutoDelete( true );
00755 QObjectList *list = m_pClient->queryList( "QWidget" );
00756 QObjectListIt it( *list );
00757 QObject * obj;
00758 int i = 1;
00759 while ( ( obj = it.current() ) != 0 )
00760 {
00761 ++it;
00762 QWidget* widg = ( QWidget* ) obj;
00763 if ( widg->name( 0 ) == 0 )
00764 {
00765 QString tmpStr;
00766 tmpStr.setNum( i );
00767 tmpStr = "unnamed" + tmpStr;
00768 widg->setName( tmpStr.latin1() );
00769 i++;
00770 }
00771 FocusPolicy* pFocPol = new FocusPolicy;
00772 *pFocPol = widg->focusPolicy();
00773 pFocPolDict->insert( widg->name(), pFocPol );
00774 }
00775 delete list;
00776
00777
00778 if ( w->parent() != this )
00779 {
00780
00781 QPoint pnt2( KMDI_CHILDFRM_BORDER, clientYPos );
00782 QSize mincs = w->minimumSize();
00783 QSize maxcs = w->maximumSize();
00784 w->setMinimumSize( 0, 0 );
00785 w->setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
00786
00787
00788 w->reparent( this, 0, pnt2, w->isVisible() );
00789
00790 w->setMinimumSize( mincs.width(), mincs.height() );
00791 w->setMaximumSize( maxcs.width(), maxcs.height() );
00792 }
00793 else
00794 w->move( KMDI_CHILDFRM_BORDER, clientYPos );
00795
00796 linkChildren( pFocPolDict );
00797
00798 QObject::connect( m_pClient, SIGNAL( mdiParentNowMaximized( bool ) ), m_pManager, SIGNAL( nowMaximized( bool ) ) );
00799
00800 if ( m_pClient->minimumWidth() > m_pManager->m_defaultChildFrmSize.width() )
00801 setMinimumWidth( m_pClient->minimumSize().width() + KMDI_CHILDFRM_DOUBLE_BORDER );
00802
00803 if ( m_pClient->minimumHeight() > m_pManager->m_defaultChildFrmSize.height() )
00804 {
00805 setMinimumHeight( m_pClient->minimumSize().height() + KMDI_CHILDFRM_DOUBLE_BORDER +
00806 m_pCaption->heightHint() + KMDI_CHILDFRM_SEPARATOR );
00807 }
00808 }
00809
00810
00811
00812 void KMdiChildFrm::unsetClient( QPoint positionOffset )
00813 {
00814 if ( !m_pClient )
00815 return ;
00816
00817 QObject::disconnect( m_pClient, SIGNAL( mdiParentNowMaximized( bool ) ), m_pManager, SIGNAL( nowMaximized( bool ) ) );
00818
00819
00820 QDict<FocusPolicy>* pFocPolDict;
00821 pFocPolDict = unlinkChildren();
00822
00823
00824 QWidget* focusedChildWidget = m_pClient->focusedChildWidget();
00825 const char* nameOfFocusedWidget = "";
00826 if ( focusedChildWidget != 0 )
00827 nameOfFocusedWidget = focusedChildWidget->name();
00828
00829 QSize mins = m_pClient->minimumSize();
00830 QSize maxs = m_pClient->maximumSize();
00831 m_pClient->reparent( 0, 0, mapToGlobal( pos() ) - pos() + positionOffset, isVisible() );
00832 m_pClient->setMinimumSize( mins.width(), mins.height() );
00833 m_pClient->setMaximumSize( maxs.width(), maxs.height() );
00834
00835
00836 QObjectList *list = m_pClient->queryList( "QWidget" );
00837 QObjectListIt it( *list );
00838 QObject * obj;
00839 QWidget* firstFocusableChildWidget = 0;
00840 QWidget* lastFocusableChildWidget = 0;
00841 while ( ( obj = it.current() ) != 0 )
00842 {
00843 QWidget * widg = ( QWidget* ) obj;
00844 ++it;
00845 FocusPolicy* pFocPol = pFocPolDict->find( widg->name() );
00846 if ( pFocPol )
00847 widg->setFocusPolicy( *pFocPol );
00848
00849
00850 if ( widg->name() == nameOfFocusedWidget )
00851 widg->setFocus();
00852
00853
00854 if ( ( widg->focusPolicy() == QWidget::StrongFocus ) || ( widg->focusPolicy() == QWidget::TabFocus ) )
00855 {
00856 if ( firstFocusableChildWidget == 0 )
00857 firstFocusableChildWidget = widg;
00858 lastFocusableChildWidget = widg;
00859
00860 }
00861 else
00862 {
00863 if ( widg->focusPolicy() == QWidget::WheelFocus )
00864 {
00865 if ( firstFocusableChildWidget == 0 )
00866 firstFocusableChildWidget = widg;
00867 lastFocusableChildWidget = widg;
00868
00869 }
00870 }
00871 }
00872 delete list;
00873 delete pFocPolDict;
00874
00875
00876 m_pClient->setFirstFocusableChildWidget( firstFocusableChildWidget );
00877 m_pClient->setLastFocusableChildWidget( lastFocusableChildWidget );
00878
00879
00880 m_pClient->setFocusPolicy( QWidget::ClickFocus );
00881
00882
00883 m_pClient = 0;
00884 }
00885
00886
00887 void KMdiChildFrm::linkChildren( QDict<FocusPolicy>* pFocPolDict )
00888 {
00889
00890 QObjectList* list = m_pClient->queryList( "QWidget" );
00891 QObjectListIt it( *list );
00892 QObject* obj;
00893 while ( ( obj = it.current() ) != 0 )
00894 {
00895 QWidget* widg = ( QWidget* ) obj;
00896 ++it;
00897 FocusPolicy* pFocPol = pFocPolDict->find( widg->name() );
00898
00899 if ( pFocPol != 0 )
00900 widg->setFocusPolicy( *pFocPol );
00901
00902 if ( !( widg->inherits( "QPopupMenu" ) ) )
00903 widg->installEventFilter( this );
00904
00905 }
00906 delete list;
00907 delete pFocPolDict;
00908
00909
00910 m_pWinIcon->setFocusPolicy( QWidget::NoFocus );
00911 m_pUnixIcon->setFocusPolicy( QWidget::NoFocus );
00912 m_pClient->setFocusPolicy( QWidget::ClickFocus );
00913 m_pCaption->setFocusPolicy( QWidget::NoFocus );
00914 m_pUndock->setFocusPolicy( QWidget::NoFocus );
00915 m_pMinimize->setFocusPolicy( QWidget::NoFocus );
00916 m_pMaximize->setFocusPolicy( QWidget::NoFocus );
00917 m_pClose->setFocusPolicy( QWidget::NoFocus );
00918
00919
00920 m_pWinIcon->installEventFilter( this );
00921 m_pUnixIcon->installEventFilter( this );
00922 m_pCaption->installEventFilter( this );
00923 m_pUndock->installEventFilter( this );
00924 m_pMinimize->installEventFilter( this );
00925 m_pMaximize->installEventFilter( this );
00926 m_pClose->installEventFilter( this );
00927 m_pClient->installEventFilter( this );
00928
00929 }
00930
00931
00932
00933 QDict<QWidget::FocusPolicy>* KMdiChildFrm::unlinkChildren()
00934 {
00935
00936 QDict<FocusPolicy>* pFocPolDict = new QDict<FocusPolicy>;
00937 pFocPolDict->setAutoDelete( true );
00938
00939 QObjectList *list = m_pClient->queryList( "QWidget" );
00940 QObjectListIt it( *list );
00941 QObject * obj;
00942 int i = 1;
00943 while ( ( obj = it.current() ) != 0 )
00944 {
00945 ++it;
00946 QWidget* w = ( QWidget* ) obj;
00947
00948 if ( w->name( 0 ) == 0 )
00949 {
00950 QString tmpStr;
00951 tmpStr.setNum( i );
00952 tmpStr = "unnamed" + tmpStr;
00953 w->setName( tmpStr.latin1() );
00954 i++;
00955 }
00956 FocusPolicy* pFocPol = new FocusPolicy;
00957 *pFocPol = w->focusPolicy();
00958
00959 pFocPolDict->insert( w->name(), pFocPol );
00960
00961 ( ( QWidget* ) obj ) ->removeEventFilter( this );
00962 }
00963 delete list;
00964
00965
00966 m_pWinIcon->removeEventFilter( this );
00967 m_pUnixIcon->removeEventFilter( this );
00968 m_pCaption->removeEventFilter( this );
00969 m_pUndock->removeEventFilter( this );
00970 m_pMinimize->removeEventFilter( this );
00971 m_pMaximize->removeEventFilter( this );
00972 m_pClose->removeEventFilter( this );
00973 m_pClient->removeEventFilter( this );
00974
00975
00976
00977 return pFocPolDict;
00978 }
00979
00980
00981
00982 void KMdiChildFrm::resizeEvent( QResizeEvent * )
00983 {
00984 doResize();
00985 }
00986
00987 void KMdiChildFrm::doResize()
00988 {
00989 doResize( false );
00990 }
00991
00992 void KMdiChildFrm::doResize( bool captionOnly )
00993 {
00994
00995 int captionHeight = m_pCaption->heightHint();
00996 int captionWidth = width() - KMDI_CHILDFRM_DOUBLE_BORDER;
00997 int buttonHeight = m_pClose->pixmap() ->height();
00998 int buttonWidth = m_pClose->pixmap() ->width();
00999 int heightOffset = captionHeight / 2 - buttonHeight / 2;
01000 int rightOffset1 = 1;
01001 int rightOffset2 = 1;
01002 int frmIconHeight = m_pWinIcon->pixmap() ->height();
01003 int frmIconWidth = m_pWinIcon->pixmap() ->width();
01004 int frmIconOffset = 1;
01005 QWidget* pIconWidget = m_pWinIcon;
01006 m_pCaption->setGeometry( KMDI_CHILDFRM_BORDER, KMDI_CHILDFRM_BORDER, captionWidth, captionHeight );
01007
01008
01009 if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::Win95Look )
01010 {
01011 rightOffset2 += 2;
01012 m_pUnixIcon->hide();
01013 }
01014 else if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::KDE1Look )
01015 {
01016 buttonWidth += 4;
01017 buttonHeight += 4;
01018 heightOffset -= 2;
01019 rightOffset1 = 0;
01020 rightOffset2 = 0;
01021 m_pWinIcon->hide();
01022 frmIconHeight = buttonHeight;
01023 frmIconWidth = buttonWidth;
01024 frmIconOffset = 0;
01025 pIconWidget = m_pUnixIcon;
01026 }
01027 else if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::KDELook )
01028 {
01029 buttonWidth += 3;
01030 buttonHeight += 3;
01031 heightOffset -= 1;
01032 m_pUnixIcon->hide();
01033 }
01034 if ( KMdiMainFrm::frameDecorOfAttachedViews() != KMdi::KDELaptopLook )
01035 {
01036 pIconWidget->setGeometry( frmIconOffset, captionHeight / 2 - frmIconHeight / 2, frmIconWidth, frmIconHeight );
01037 m_pClose->setGeometry( ( captionWidth - buttonWidth ) - rightOffset1, heightOffset, buttonWidth, buttonHeight );
01038 m_pMaximize->setGeometry( ( captionWidth - ( buttonWidth * 2 ) ) - rightOffset2, heightOffset, buttonWidth, buttonHeight );
01039 m_pMinimize->setGeometry( ( captionWidth - ( buttonWidth * 3 ) ) - rightOffset2, heightOffset, buttonWidth, buttonHeight );
01040 m_pUndock->setGeometry( ( captionWidth - ( buttonWidth * 4 ) ) - rightOffset2, heightOffset, buttonWidth, buttonHeight );
01041 }
01042 else
01043 {
01044 m_pWinIcon->hide();
01045 m_pUnixIcon->hide();
01046 buttonHeight += 5;
01047 heightOffset -= 2;
01048 m_pClose->setGeometry ( 0, heightOffset, 27, buttonHeight );
01049 m_pMaximize->setGeometry( captionWidth - 27, heightOffset, 27, buttonHeight );
01050 m_pMinimize->setGeometry( captionWidth - 27 * 2, heightOffset, 27, buttonHeight );
01051 m_pUndock->setGeometry ( captionWidth - 27 * 3, heightOffset, 27, buttonHeight );
01052 }
01053
01054
01055 if ( !captionOnly && m_pClient )
01056 {
01057 QSize newClientSize( captionWidth,
01058 height() - ( KMDI_CHILDFRM_DOUBLE_BORDER + captionHeight + KMDI_CHILDFRM_SEPARATOR ) );
01059 if ( newClientSize != m_pClient->size() )
01060 {
01061 m_pClient->setGeometry( KMDI_CHILDFRM_BORDER,
01062 m_pCaption->heightHint() + KMDI_CHILDFRM_SEPARATOR + KMDI_CHILDFRM_BORDER,
01063 newClientSize.width(), newClientSize.height() );
01064 }
01065 }
01066 }
01067
01068 static bool hasParent( QObject* par, QObject* o )
01069 {
01070 while ( o && o != par )
01071 o = o->parent();
01072 return o == par;
01073 }
01074
01075
01076
01077 bool KMdiChildFrm::eventFilter( QObject *obj, QEvent *e )
01078 {
01079 switch ( e->type() )
01080 {
01081 case QEvent::Enter:
01082 {
01083
01084 bool bIsChild = false;
01085 QObject* pObj = obj;
01086 while ( ( pObj != 0L ) && !bIsChild )
01087 {
01088 bIsChild = ( pObj == this );
01089 pObj = pObj->parent();
01090 }
01091
01092 if ( bIsChild )
01093 unsetResizeCursor();
01094 }
01095 break;
01096 case QEvent::MouseButtonPress:
01097 {
01098 if ( !hasParent( m_pClient, obj ) )
01099 {
01100 bool bIsSecondClick = false;
01101 if ( m_timeMeasure.elapsed() <= QApplication::doubleClickInterval() )
01102 bIsSecondClick = true;
01103
01104 if ( !( ( ( obj == m_pWinIcon ) || ( obj == m_pUnixIcon ) ) && bIsSecondClick ) )
01105 {
01106
01107 QFocusEvent focusEvent( QFocusEvent::FocusIn );
01108 QApplication::sendEvent( qApp->mainWidget(), &focusEvent );
01109 if ( m_pClient )
01110 {
01111 m_pClient->updateTimeStamp();
01112 m_pClient->activate();
01113 }
01114
01115 if ( ( obj->parent() != m_pCaption ) && ( obj != m_pCaption ) )
01116 {
01117 QWidget* w = ( QWidget* ) obj;
01118 if ( ( w->focusPolicy() == QWidget::ClickFocus ) || ( w->focusPolicy() == QWidget::StrongFocus ) )
01119 {
01120 w->setFocus();
01121 }
01122 }
01123 }
01124 if ( ( obj == m_pWinIcon ) || ( obj == m_pUnixIcon ) )
01125 {
01126
01127 if ( m_timeMeasure.elapsed() > QApplication::doubleClickInterval() )
01128 {
01129 showSystemMenu();
01130 m_timeMeasure.start();
01131 }
01132 else
01133 closePressed();
01134
01135 return true;
01136 }
01137 }
01138 }
01139 break;
01140 case QEvent::Resize:
01141 {
01142 if ( ( ( QWidget* ) obj == m_pClient ) && ( m_state == Normal ) )
01143 {
01144 QResizeEvent* re = ( QResizeEvent* ) e;
01145 int captionHeight = m_pCaption->heightHint();
01146 QSize newChildFrmSize( re->size().width() + KMDI_CHILDFRM_DOUBLE_BORDER,
01147 re->size().height() + captionHeight + KMDI_CHILDFRM_SEPARATOR + KMDI_CHILDFRM_DOUBLE_BORDER );
01148 if ( newChildFrmSize != size() )
01149 resize( newChildFrmSize );
01150 }
01151 }
01152 break;
01153 case QEvent::ChildRemoved:
01154 {
01155
01156
01157 QObject* pLostChild = ( ( QChildEvent* ) e )->child();
01158 if ( ( pLostChild != 0L ) )
01159 {
01160 QObjectList* list = pLostChild->queryList();
01161 list->insert( 0, pLostChild );
01162 QObjectListIt it( *list );
01163 QObject* obj;
01164 while ( ( obj = it.current() ) != 0 )
01165 {
01166 QWidget* widg = ( QWidget* ) obj;
01167 ++it;
01168 widg->removeEventFilter( this );
01169 }
01170 delete list;
01171 }
01172 }
01173 break;
01174 case QEvent::ChildInserted:
01175 {
01176
01177
01178
01179 QObject* pNewChild = ( ( QChildEvent* ) e ) ->child();
01180 if ( ( pNewChild != 0L ) && ::qt_cast<QWidget*>( pNewChild ) )
01181 {
01182 QWidget * pNewWidget = static_cast<QWidget*>( pNewChild );
01183 QObjectList *list = pNewWidget->queryList( "QWidget" );
01184 list->insert( 0, pNewChild );
01185 QObjectListIt it( *list );
01186 QObject * obj;
01187 while ( ( obj = it.current() ) != 0 )
01188 {
01189 QWidget * widg = ( QWidget* ) obj;
01190 ++it;
01191 if ( !::qt_cast<QPopupMenu*>( widg ) )
01192 {
01193 widg->installEventFilter( this );
01194 }
01195 }
01196 delete list;
01197 }
01198 }
01199 break;
01200 default:
01201 break;
01202 }
01203
01204 return false;
01205 }
01206
01207
01208
01209 void KMdiChildFrm::raiseAndActivate()
01210 {
01211 m_pCaption->setActive( true );
01212 m_pManager->setTopChild( this, false );
01213 }
01214
01215
01216
01217 void KMdiChildFrm::setMinimumSize ( int minw, int minh )
01218 {
01219 QWidget::setMinimumSize( minw, minh );
01220 if ( m_state == Maximized )
01221 {
01222 m_pManager->setMinimumSize( minw, minh );
01223 }
01224 }
01225
01226
01227
01228 QPopupMenu* KMdiChildFrm::systemMenu() const
01229 {
01230 if ( m_pSystemMenu == 0 )
01231 return 0;
01232
01233 m_pSystemMenu->clear();
01234
01235 if ( KMdiMainFrm::frameDecorOfAttachedViews() != KMdi::Win95Look )
01236 {
01237 m_pSystemMenu->insertItem( i18n( "&Restore" ), this, SLOT( restorePressed() ) );
01238 m_pSystemMenu->insertItem( i18n( "&Move" ), m_pCaption, SLOT( slot_moveViaSystemMenu() ) );
01239 m_pSystemMenu->insertItem( i18n( "R&esize" ), this, SLOT( slot_resizeViaSystemMenu() ) );
01240 m_pSystemMenu->insertItem( i18n( "M&inimize" ), this, SLOT( minimizePressed() ) );
01241 m_pSystemMenu->insertItem( i18n( "M&aximize" ), this, SLOT( maximizePressed() ) );
01242 if ( state() == Normal )
01243 m_pSystemMenu->setItemEnabled( m_pSystemMenu->idAt( 0 ), false );
01244 else if ( state() == Maximized )
01245 {
01246 m_pSystemMenu->setItemEnabled( m_pSystemMenu->idAt( 1 ), false );
01247 m_pSystemMenu->setItemEnabled( m_pSystemMenu->idAt( 2 ), false );
01248 m_pSystemMenu->setItemEnabled( m_pSystemMenu->idAt( 4 ), false );
01249 }
01250 else if ( state() == Minimized )
01251 {
01252 m_pSystemMenu->setItemEnabled( m_pSystemMenu->idAt( 2 ), false );
01253 m_pSystemMenu->setItemEnabled( m_pSystemMenu->idAt( 3 ), false );
01254 }
01255 }
01256 else
01257 {
01258 if ( state() != Normal )
01259 m_pSystemMenu->insertItem( i18n( "&Restore" ), this, SLOT( restorePressed() ) );
01260 if ( state() != Maximized )
01261 m_pSystemMenu->insertItem( i18n( "&Maximize" ), this, SLOT( maximizePressed() ) );
01262 if ( state() != Minimized )
01263 m_pSystemMenu->insertItem( i18n( "&Minimize" ), this, SLOT( minimizePressed() ) );
01264 if ( state() != Maximized )
01265 m_pSystemMenu->insertItem( i18n( "M&ove" ), m_pCaption, SLOT( slot_moveViaSystemMenu() ) );
01266 if ( state() == Normal )
01267 m_pSystemMenu->insertItem( i18n( "&Resize" ), this, SLOT( slot_resizeViaSystemMenu() ) );
01268 }
01269
01270 m_pSystemMenu->insertItem( i18n( "&Undock" ), this, SLOT( undockPressed() ) );
01271 m_pSystemMenu->insertSeparator();
01272 m_pSystemMenu->insertItem( i18n( "&Close" ), this, SLOT( closePressed() ) );
01273
01274 return m_pSystemMenu;
01275 }
01276
01278 void KMdiChildFrm::showSystemMenu()
01279 {
01280 if ( KMdiMainFrm::frameDecorOfAttachedViews() != KMdi::Win95Look )
01281 m_pUnixIcon->setDown( false );
01282
01283 QPoint popupmenuPosition;
01284
01285 QRect iconGeom;
01286 if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::Win95Look )
01287 iconGeom = m_pWinIcon->geometry();
01288 else
01289 iconGeom = m_pUnixIcon->geometry();
01290
01291 popupmenuPosition = QPoint( iconGeom.x(), iconGeom.y() + captionHeight() + KMDI_CHILDFRM_BORDER );
01292 systemMenu() ->popup( mapToGlobal( popupmenuPosition ) );
01293 }
01294
01295 void KMdiChildFrm::switchToMinimizeLayout()
01296 {
01297 setMinimumWidth( KMDI_CHILDFRM_MIN_WIDTH );
01298 setFixedHeight( m_pCaption->height() + KMDI_CHILDFRM_DOUBLE_BORDER );
01299
01300 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
01301
01302
01303 m_pMinimize->setPixmap( *m_pRestoreButtonPixmap );
01304 QObject::disconnect( m_pMinimize, SIGNAL( clicked() ), this, SLOT( minimizePressed() ) );
01305 QObject::connect( m_pMinimize, SIGNAL( clicked() ), this, SLOT( restorePressed() ) );
01306
01307
01308 resize( 300, minimumHeight() );
01309
01310
01311 m_pManager->layoutMinimizedChildren();
01312 }
01313
01314 void KMdiChildFrm::slot_resizeViaSystemMenu()
01315 {
01316 grabMouse();
01317 m_bResizing = true;
01318 m_iResizeCorner = KMDI_RESIZE_BOTTOMLEFT;
01319 setResizeCursor( m_iResizeCorner );
01320 }
01321
01322 void KMdiChildFrm::redecorateButtons()
01323 {
01324 delete m_pMinButtonPixmap;
01325 delete m_pMaxButtonPixmap;
01326 delete m_pRestoreButtonPixmap;
01327 delete m_pCloseButtonPixmap;
01328 delete m_pUndockButtonPixmap;
01329
01330 if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::Win95Look )
01331 {
01332 m_pMinButtonPixmap = new QPixmap( win_minbutton );
01333 m_pMaxButtonPixmap = new QPixmap( win_maxbutton );
01334 m_pRestoreButtonPixmap = new QPixmap( win_restorebutton );
01335 m_pCloseButtonPixmap = new QPixmap( win_closebutton );
01336 m_pUndockButtonPixmap = new QPixmap( win_undockbutton );
01337 }
01338 else if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::KDE1Look )
01339 {
01340 m_pMinButtonPixmap = new QPixmap( kde_minbutton );
01341 m_pMaxButtonPixmap = new QPixmap( kde_maxbutton );
01342 m_pRestoreButtonPixmap = new QPixmap( kde_restorebutton );
01343 m_pCloseButtonPixmap = new QPixmap( kde_closebutton );
01344 m_pUndockButtonPixmap = new QPixmap( kde_undockbutton );
01345 }
01346 else if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::KDELook )
01347 {
01348 m_pMinButtonPixmap = new QPixmap( kde2_minbutton );
01349 m_pMaxButtonPixmap = new QPixmap( kde2_maxbutton );
01350 m_pRestoreButtonPixmap = new QPixmap( kde2_restorebutton );
01351 m_pCloseButtonPixmap = new QPixmap( kde2_closebutton );
01352 m_pUndockButtonPixmap = new QPixmap( kde2_undockbutton );
01353 }
01354 else
01355 {
01356 m_pMinButtonPixmap = new QPixmap( kde2laptop_minbutton );
01357 m_pMaxButtonPixmap = new QPixmap( kde2laptop_maxbutton );
01358 m_pRestoreButtonPixmap = new QPixmap( kde2laptop_restorebutton );
01359 m_pCloseButtonPixmap = new QPixmap( kde2laptop_closebutton );
01360 m_pUndockButtonPixmap = new QPixmap( kde2laptop_undockbutton );
01361 }
01362
01363 m_pUnixIcon->setAutoRaise( true );
01364 if ( KMdiMainFrm::frameDecorOfAttachedViews() == KMdi::KDE1Look )
01365 {
01366 m_pMinimize->setAutoRaise( true );
01367 m_pMaximize->setAutoRaise( true );
01368 m_pClose->setAutoRaise( true );
01369 m_pUndock->setAutoRaise( true );
01370 }
01371 else
01372 {
01373 m_pMinimize->setAutoRaise( false );
01374 m_pMaximize->setAutoRaise( false );
01375 m_pClose->setAutoRaise( false );
01376 m_pUndock->setAutoRaise( false );
01377 }
01378
01379 if ( m_pClient && m_pClient->icon() )
01380 {
01381 m_pWinIcon->setPixmap( *( m_pClient )->icon() );
01382 m_pUnixIcon->setPixmap( *( m_pClient )->icon() );
01383 }
01384 else
01385 {
01386 m_pWinIcon->setPixmap( *m_pIconButtonPixmap );
01387 m_pUnixIcon->setPixmap( *m_pIconButtonPixmap );
01388 }
01389 m_pClose->setPixmap( *m_pCloseButtonPixmap );
01390 m_pMinimize->setPixmap( *m_pMinButtonPixmap );
01391 m_pMaximize->setPixmap( *m_pMaxButtonPixmap );
01392 m_pUndock->setPixmap( *m_pUndockButtonPixmap );
01393 }
01394
01395 QRect KMdiChildFrm::mdiAreaContentsRect() const
01396 {
01397 QFrame * p = ( QFrame* ) parentWidget();
01398 if ( p )
01399 {
01400 return p->contentsRect();
01401 }
01402 else
01403 {
01404 QRect empty;
01405 return empty;
01406 }
01407 }
01408
01409