Logo Search packages:      
Sourcecode: kbear version File versions  Download package

void QextMdiChildFrm::setState ( MdiWindowState  state,
bool  bAnimate = TRUE 
)

Minimizes , Maximizes or restores the window.

Definition at line 453 of file qextmdichildfrm.cpp.

References QextMdiChildArea::childMinimized(), QextMdiChildFrmCaption::heightHint(), QextMdiChildView::isMaximized(), m_pClient, QextMdiChildView::m_stateChanged, minimizePressed(), restorePressed(), QextMdiChildView::setMaximumSize(), QextMdiChildView::setMinimumSize(), switchToMinimizeLayout(), and QextMdiChildArea::topChild().

Referenced by QextMdiChildArea::childMinimized(), QextMdiChildArea::destroyChild(), QextMdiChildArea::destroyChildButNotItsView(), QextMdiChildArea::manageChild(), QextMdiChildView::maximize(), maximizePressed(), QextMdiChildView::minimize(), minimizePressed(), QextMdiChildView::restore(), restorePressed(), QextMdiChildArea::setTopChild(), and undockPressed().

{
   if(m_state==Normal){ //save the current rect
      m_restoredRect=QRect(x(),y(),width(),height());
   }
   switch(state){
   case Normal:
      switch(m_state){
      case Maximized:
         m_pClient->m_stateChanged = TRUE;
         m_state=state;
         // client min / max size / layout behaviour don't change
         // set frame max size indirectly by setting the clients max size to 
         // it's current value (calls setMaxSize() of frame)
         m_pClient->setMaximumSize(m_pClient->maximumSize().width(), m_pClient->maximumSize().height());
         m_pMaximize->setPixmap( *m_pMaxButtonPixmap);
         setGeometry(m_restoredRect);
         break;
      case Minimized:
         m_pClient->m_stateChanged = TRUE;
         m_state=state;
         // restore client min / max size / layout behaviour
         m_pClient->setMinimumSize(m_oldClientMinSize.width(),m_oldClientMinSize.height());
         m_pClient->setMaximumSize(m_oldClientMaxSize.width(),m_oldClientMaxSize.height());
         if (m_pClient->layout() != 0L) {
            m_pClient->layout()->setResizeMode(m_oldLayoutResizeMode);
         }
         m_pMinimize->setPixmap( *m_pMinButtonPixmap);
         m_pMaximize->setPixmap( *m_pMaxButtonPixmap);
         QObject::disconnect(m_pMinimize,SIGNAL(clicked()),this,SLOT(restorePressed()));
         QObject::connect(m_pMinimize,SIGNAL(clicked()),this,SLOT(minimizePressed()));
         setGeometry(m_restoredRect);
         break;
      case Normal:
          break;
      }
      break;
   case Maximized:
      switch(m_state){
      case Minimized: {
            m_pClient->m_stateChanged = TRUE;
            m_state=state;
            // restore client min / max size / layout behaviour
            m_pClient->setMinimumSize(m_oldClientMinSize.width(),m_oldClientMinSize.height());
            m_pClient->setMaximumSize(m_oldClientMaxSize.width(),m_oldClientMaxSize.height());
            if (m_pClient->layout() != 0L) {
               m_pClient->layout()->setResizeMode(m_oldLayoutResizeMode);
            }
            setMaximumSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX);
            // reset to maximize-captionbar
            m_pMaximize->setPixmap( *m_pRestoreButtonPixmap);
            m_pMinimize->setPixmap( *m_pMinButtonPixmap);
            QObject::disconnect(m_pMinimize,SIGNAL(clicked()),this,SLOT(restorePressed()));
            QObject::connect(m_pMinimize,SIGNAL(clicked()),this,SLOT(minimizePressed()));
            int nFrameWidth = QEXTMDI_MDI_CHILDFRM_DOUBLE_BORDER;
            int nFrameHeight = QEXTMDI_MDI_CHILDFRM_DOUBLE_BORDER + QEXTMDI_MDI_CHILDFRM_SEPARATOR + 
                               m_pCaption->heightHint();
            setGeometry(-m_pClient->x(), -m_pClient->y(),
                        m_pManager->width() + nFrameWidth,
                        m_pManager->height() + nFrameHeight);
            raise();
         }
         break;
      case Normal: {
            m_pClient->m_stateChanged = TRUE;
            m_state=state;
            // client min / max size / layout behaviour don't change
            setMaximumSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX);
            m_pMaximize->setPixmap( *m_pRestoreButtonPixmap);
            int nFrameWidth = QEXTMDI_MDI_CHILDFRM_DOUBLE_BORDER;
            int nFrameHeight = QEXTMDI_MDI_CHILDFRM_DOUBLE_BORDER + QEXTMDI_MDI_CHILDFRM_SEPARATOR +
                               m_pCaption->heightHint();
            QRect maximizedFrmRect(-m_pClient->x(), -m_pClient->y(),
                                   m_pManager->width() + nFrameWidth,
                                   m_pManager->height() + nFrameHeight);
            if (geometry() != maximizedFrmRect) {
               setGeometry(maximizedFrmRect);
            }
            raise();
         }
         break;
      case Maximized:
         break;
      }
   break;
   case Minimized:
      switch(m_state){
      case Maximized:
         m_pClient->m_stateChanged = TRUE;
         m_state=state;
         // save client min / max size / layout behaviour
         m_oldClientMinSize = m_pClient->minimumSize();
         m_oldClientMaxSize = m_pClient->maximumSize();
         if (m_pClient->layout() != 0L) {
            m_oldLayoutResizeMode = m_pClient->layout()->resizeMode();
         }
         m_pClient->setMinimumSize(0, 0);
         m_pClient->setMaximumSize(0, 0);
         if (m_pClient->layout() != 0L) {
            m_pClient->layout()->setResizeMode(QLayout::FreeResize);
         }
         switchToMinimizeLayout();
         m_pManager->childMinimized(this,TRUE);
         break;
      case Normal:
         m_pClient->m_stateChanged = TRUE;
         m_state=state;
         // save client min / max size / layout behaviour
         m_oldClientMinSize = m_pClient->minimumSize();
         m_oldClientMaxSize = m_pClient->maximumSize();
         if (m_pClient->layout() != 0L) {
            m_oldLayoutResizeMode = m_pClient->layout()->resizeMode();
         }
         m_restoredRect = geometry();
         m_pClient->setMinimumSize(0, 0);
         m_pClient->setMaximumSize(0, 0);
         if (m_pClient->layout() != 0L) {
            m_pClient->layout()->setResizeMode(QLayout::FreeResize);
         }
         switchToMinimizeLayout();
         m_pManager->childMinimized(this,FALSE);
         break;
      case Minimized:
         break;
      }
   break;
   }

   QextMdiChildFrm*     pTopFrame = m_pManager->topChild();
   QextMdiChildView*    pTopChild = 0L;
   if (pTopFrame != 0L) {
      pTopChild = pTopFrame->m_pClient;
   }
   if ( (pTopChild != 0L) && pTopChild->isMaximized() ) {
      m_pManager->setMinimumSize(pTopChild->minimumWidth(), pTopChild->minimumHeight());
      // XXX TODO: setting the maximum size doesn't work properly - fix this later
      // m_pManager->setMaximumSize(pTopChild->maximumWidth(), pTopChild->maximumHeight());
   }
   else {
      m_pManager->setMinimumSize(0, 0);
      m_pManager->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
   }
}


Generated by  Doxygen 1.6.0   Back to index