void CTabSplitterWnd::OnKillFocus(CWnd* pNewWnd) { CSplitterWnd::OnKillFocus(pNewWnd); // TODO: Add your message handler code here GetActivePane(&m_nCurRow,&m_nCurCol); }
void CSplitterWndEx::ShowPane(CWnd * pWnd,BOOL bShow) { if(m_pwnd1==NULL){ m_pwnd1=GetPane(0,0); m_pwnd2=GetPane(!IsHorizontal(),IsHorizontal()); } ASSERT(pWnd==m_pwnd1 || pWnd==m_pwnd2); int &nRowCols=IsHorizontal()?m_nCols:m_nRows; if(bShow){ if(!pWnd->IsWindowVisible()){ if(m_bParentHide){ ((CSplitterWndEx *)GetParent())->ShowPane(this,TRUE); // Ensure the correct pane reappears if(GetPane(0,0)!=pWnd){ // Need to swap the entries SwapRowColInfo(); } m_bParentHide=FALSE; } else { // maybe nothing to do nRowCols++; if(pWnd==m_pwnd1){ // Need to swap the entries SwapRowColInfo(); } } pWnd->ShowWindow(SW_SHOW); } if(pWnd==m_pwnd1){ m_pwnd1->SetDlgCtrlID(AFX_IDW_PANE_FIRST); m_pwnd2->SetDlgCtrlID(AFX_IDW_PANE_FIRST+(IsHorizontal()?1:16)); } } else { if(pWnd->IsWindowVisible()){ pWnd->ShowWindow(SW_HIDE); if(nRowCols == 1) { m_bParentHide=TRUE; ((CSplitterWndEx *)GetParent())->ShowPane(this,FALSE); } else { // Both panes currently active int rowActive, colActive; if (GetActivePane(&rowActive, &colActive) != NULL && pWnd==GetPane(rowActive, colActive)){ int bHorz=IsHorizontal(); SetActivePane((!bHorz)&(rowActive^1), (bHorz)&(colActive^1)); } if(pWnd==m_pwnd1){ SwapRowColInfo(); m_pwnd2->SetDlgCtrlID(AFX_IDW_PANE_FIRST); m_pwnd1->SetDlgCtrlID(AFX_IDW_PANE_FIRST+1); } nRowCols--; } } } RecalcLayout(); }
void CTabSplitterWnd::StopTracking(BOOL bAccept) { // save old active view CWnd* pOldActiveView = GetActivePane(); CSplitterWnd::StopTracking(bAccept); if (bAccept) { if (pOldActiveView == GetActivePane()) { if (pOldActiveView == NULL) { if (m_nCols > 1) SetActivePane(0, 1); // pOldActiveView->SetFocus(); // make sure focus is restored if (m_nRows > 1) SetActivePane(0, 0); } } SaveSize(); } }
void COXSplitterWnd::DeleteView(int row, int col) { ASSERT_VALID(this); // if active child is being deleted - activate next CWnd* pPane=GetPane(row,col); ASSERT_VALID(pPane); if(GetActivePane()==pPane) { ActivateNext(FALSE); } // default implementation assumes view will auto delete in PostNcDestroy pPane->DestroyWindow(); }
void CCustInfoSplitterWnd ::HideColumn(int nColHide) { ASSERT_VALID( this ); ASSERT( m_nCols > 1 ); ASSERT( nColHide < m_nCols ); ASSERT( m_nHiddenCol == -1 ); m_nHiddenCol = nColHide; // if the column has an active window -- change it int nActiveRow, nActiveCol; if( GetActivePane( &nActiveRow, &nActiveCol ) != NULL ) { if( nActiveCol == nColHide ) { if( ++nActiveCol >= m_nCols ) nActiveCol = 0; SetActivePane( nActiveRow, nActiveCol ); } } // hide all column panes for( int nRow = 0; nRow < m_nRows; nRow++) { CWnd* pPaneHide = GetPane(nRow, nColHide); ASSERT( pPaneHide != NULL ); pPaneHide->ShowWindow(SW_HIDE); pPaneHide->SetDlgCtrlID( AFX_IDW_PANE_FIRST+nRow +16*m_nCols ); for( int nCol = nColHide + 1; nCol < m_nCols; nCol++ ) { CWnd* pPane = GetPane( nRow, nCol ); ASSERT( pPane != NULL ); pPane->SetDlgCtrlID( IdFromRowCol( nRow, nCol - 1 )); } } m_nCols--; m_pColInfo[m_nCols].nCurSize = m_pColInfo[nColHide].nCurSize; RecalcLayout(); }
void CTabSplitterWnd::ActivateNext(BOOL bPrev) { ASSERT_VALID(this); // find the coordinate of the current pane int row, col; if (GetActivePane(&row, &col) == NULL) { SetActivePane(0,0); return; } ASSERT(row >= 0 && row < m_nRows); ASSERT(col >= 0 && col < m_nCols); // determine next pane if (bPrev) { // prev if (--col < 0) { col = m_nCols - 1; if (--row < 0) row = m_nRows - 1; } } else { // next if (++col >= m_nCols) { col = 0; if (++row >= m_nRows) row = 0; } } // set newly active pane SetActivePane(row, col); }
void CResizableSplitterWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { if ((GetStyle() & SPLS_DYNAMIC_SPLIT) && GetRowCount() == 1 && GetColumnCount() == 1) { CWnd* pPane = GetActivePane(); if (pPane != NULL) { // get the extra size from child to parent CRect rectClient, rectWnd; GetWindowRect(rectWnd); pPane->GetWindowRect(rectClient); CSize sizeExtra = rectWnd.Size() - rectClient.Size(); ChainMinMaxInfo(lpMMI, pPane->m_hWnd, sizeExtra); } } else if (!(GetStyle() & SPLS_DYNAMIC_SPLIT)) { ASSERT(m_nCols > 0 && m_nRows > 0); CSize sizeMin(0,0), sizeMax(0,0); for (int col = 0; col < m_nCols; ++col) { // calc min and max width for each column int min = 0; int max = LONG_MAX; for (int row = 0; row < m_nRows; ++row) { CWnd* pWnd = GetPane(row, col); // ask the child window for track size MINMAXINFO mmiChild = *lpMMI; mmiChild.ptMinTrackSize.x = 0; mmiChild.ptMaxTrackSize.x = LONG_MAX; ::SendMessage(pWnd->GetSafeHwnd(), WM_GETMINMAXINFO, 0, (LPARAM)&mmiChild); max = __min(max, mmiChild.ptMaxTrackSize.x); min = __max(min, mmiChild.ptMinTrackSize.x); } // sum all column widths if (sizeMax.cx == LONG_MAX || max == LONG_MAX) sizeMax.cx = LONG_MAX; else sizeMax.cx += max + m_cxSplitterGap; sizeMin.cx += min + m_cxSplitterGap; } for (int row = 0; row < m_nRows; ++row) { // calc min and max height for each row int min = 0; int max = LONG_MAX; for (int col = 0; col < m_nCols; ++col) { CWnd* pWnd = GetPane(row, col); // ask the child window for track size MINMAXINFO mmiChild = *lpMMI; mmiChild.ptMinTrackSize.y = 0; mmiChild.ptMaxTrackSize.y = LONG_MAX; ::SendMessage(pWnd->GetSafeHwnd(), WM_GETMINMAXINFO, 0, (LPARAM)&mmiChild); max = __min(max, mmiChild.ptMaxTrackSize.y); min = __max(min, mmiChild.ptMinTrackSize.y); } // sum all row heights if (sizeMax.cy == LONG_MAX || max == LONG_MAX) sizeMax.cy = LONG_MAX; else sizeMax.cy += max + m_cySplitterGap; sizeMin.cy += min + m_cySplitterGap; } // adjust total size: add the client border and // we counted one splitter more than necessary sizeMax.cx += 2*m_cxBorder - m_cxSplitterGap; sizeMax.cy += 2*m_cyBorder - m_cySplitterGap; sizeMin.cx += 2*m_cxBorder - m_cxSplitterGap; sizeMin.cy += 2*m_cyBorder - m_cySplitterGap; // add non-client size CRect rectExtra(0,0,0,0); ::AdjustWindowRectEx(&rectExtra, GetStyle(), !(GetStyle() & WS_CHILD) && ::IsMenu(GetMenu()->GetSafeHmenu()), GetExStyle()); sizeMax += rectExtra.Size(); sizeMin += rectExtra.Size(); // set minmax info lpMMI->ptMinTrackSize.x = __max(lpMMI->ptMinTrackSize.x, sizeMin.cx); lpMMI->ptMinTrackSize.y = __max(lpMMI->ptMinTrackSize.y, sizeMin.cy); lpMMI->ptMaxTrackSize.x = __min(lpMMI->ptMaxTrackSize.x, sizeMax.cx); lpMMI->ptMaxTrackSize.y = __min(lpMMI->ptMaxTrackSize.y, sizeMax.cy); } }
CWnd *CTabSplitterWnd::GetActiveWnd() { int row, col; return GetActivePane(row,col); }
void CDynSplitterWnd::StopTracking(BOOL bAccept) { ASSERT_VALID(this); if (!m_bTracking) return; ReleaseCapture(); // erase tracker rectangle OnInvertTracker(m_rectTracker); if (m_bTracking2) OnInvertTracker(m_rectTracker2); m_bTracking = m_bTracking2 = FALSE; // save old active view CWnd* pOldActiveView = GetActivePane(); // m_rectTracker is set to the new splitter position (without border) // (so, adjust relative to where the border will be) m_rectTracker.OffsetRect(-CX_BORDER , -CY_BORDER); m_rectTracker2.OffsetRect(-CX_BORDER, -CY_BORDER); if (bAccept) { if (m_htTrack == vSplitterBox) { SplitRow(m_rectTracker.top); } else if (m_htTrack >= vSplitterBar1 && m_htTrack <= vSplitterBar15) { // set row height TrackRowSize(m_rectTracker.top, m_htTrack - vSplitterBar1); RecalcLayout(); } else if (m_htTrack == hSplitterBox) { SplitColumn(m_rectTracker.left); } else if (m_htTrack >= hSplitterBar1 && m_htTrack <= hSplitterBar15) { // set column width TrackColumnSize(m_rectTracker.left, m_htTrack - hSplitterBar1); RecalcLayout(); } else if (m_htTrack >= splitterIntersection1 && m_htTrack <= splitterIntersection225) { // set row height and column width int row = (m_htTrack - splitterIntersection1) / 15; int col = (m_htTrack - splitterIntersection1) % 15; TrackRowSize(m_rectTracker.top, row); TrackColumnSize(m_rectTracker2.left, col); RecalcLayout(); } else if (m_htTrack == bothSplitterBox) { // rectTracker is vSplitter (splits rows) // rectTracker2 is hSplitter (splits cols) SplitRow(m_rectTracker.top); SplitColumn(m_rectTracker2.left); } } if ( (pOldActiveView == GetActivePane()) && (pOldActiveView != NULL) ) SetActivePane(-1, -1, pOldActiveView); // re-activate }