void CGuiSplitterWnd::OnPaint() { //vil plagio del original ASSERT_VALID(this); CPaintDC dc(this); CRect rectClient; GetClientRect(&rectClient); rectClient.InflateRect(-m_cxBorder, -m_cyBorder); CRect rectInside; GetInsideRect(rectInside); // draw the splitter boxes if (m_bHasVScroll && m_nRows < m_nMaxRows) { OnDrawSplitter(&dc, splitBox, CRect(rectInside.right , rectClient.top, rectClient.right, rectClient.top + m_cySplitter)); } if (m_bHasHScroll && m_nCols < m_nMaxCols) { OnDrawSplitter(&dc, splitBox, CRect(rectClient.left, rectInside.bottom, rectClient.left + m_cxSplitter, rectClient.bottom)); } // extend split bars to window border (past margins) DrawAllSplitBars(&dc, rectInside.right, rectInside.bottom); }
void CSplitterWndEx::RecalcLayout() { ASSERT_VALID(this); ASSERT(m_nRows > 0 && m_nCols > 0); // must have at least one pane CRect rectClient; GetClientRect(rectClient); rectClient.InflateRect(-m_cxBorder, -m_cyBorder); rectClient.top += m_upBorder; CRect rectInside; GetInsideRect(rectInside); // layout columns (restrict to possible sizes) LayoutRowCol(m_pColInfo, m_nCols, rectInside.Width(), m_cxSplitterGap); LayoutRowCol(m_pRowInfo, m_nRows, rectInside.Height(), m_cySplitterGap); // adjust the panes (and optionally scroll bars) // give the hint for the maximum number of HWNDs AFX_SIZEPARENTPARAMS layout; layout.hDWP = ::BeginDeferWindowPos((m_nCols + 1) * (m_nRows + 1) + 1); // size of scrollbars int cx = (rectClient.right - rectInside.right - bNotWin4);// - afxData.bNotWin4; int cy = (rectClient.bottom - rectInside.bottom - bNotWin4);// - afxData.bNotWin4; // reposition size box if (m_bHasHScroll && m_bHasVScroll) { CWnd* pScrollBar = GetDlgItem(AFX_IDW_SIZE_BOX); ASSERT(pScrollBar != NULL); // fix style if necessary BOOL bSizingParent = (GetSizingParent() != NULL); // modifyStyle returns TRUE if style changes if (pScrollBar->ModifyStyle(SBS_SIZEGRIP|SBS_SIZEBOX, bSizingParent ? SBS_SIZEGRIP : SBS_SIZEBOX)) pScrollBar->Invalidate(); pScrollBar->EnableWindow(bSizingParent); // reposition the size box DeferClientPos(&layout, pScrollBar, rectInside.right + bNotWin4, rectInside.bottom + bNotWin4, cx, cy, TRUE); } // reposition scroll bars if (m_bHasHScroll) { int cxSplitterBox = m_cxSplitter + bNotWin4;// split box bigger int x = rectClient.left; int y = rectInside.bottom + bNotWin4; for (int col = 0; col < m_nCols; col++) { CWnd* pScrollBar = GetDlgItem(AFX_IDW_HSCROLL_FIRST + col); ASSERT(pScrollBar != NULL); int cx = m_pColInfo[col].nCurSize; if (col == 0 && m_nCols < m_nMaxCols) x += cxSplitterBox, cx -= cxSplitterBox; DeferClientPos(&layout, pScrollBar, x, y, cx, cy, TRUE); x += cx + m_cxSplitterGap; } } if (m_bHasVScroll) { int cySplitterBox = m_cySplitter + bNotWin4;// split box bigger int x = rectInside.right + bNotWin4; int y = rectClient.top; for (int row = 0; row < m_nRows; row++) { CWnd* pScrollBar = GetDlgItem(AFX_IDW_VSCROLL_FIRST + row); ASSERT(pScrollBar != NULL); int cy = m_pRowInfo[row].nCurSize; if (row == 0 && m_nRows < m_nMaxRows) y += cySplitterBox, cy -= cySplitterBox; DeferClientPos(&layout, pScrollBar, x, y, cx, cy, TRUE); y += cy + m_cySplitterGap; } } //BLOCK: Reposition all the panes { int x = rectClient.left; for (int col = 0; col < m_nCols; col++) { int cx = m_pColInfo[col].nCurSize; int y = rectClient.top; for (int row = 0; row < m_nRows; row++) { int cy = m_pRowInfo[row].nCurSize; CWnd* pWnd = GetPane(row, col); DeferClientPos(&layout, pWnd, x, y, cx, cy, FALSE); y += cy + m_cySplitterGap; } x += cx + m_cxSplitterGap; } } // move and resize all the windows at once! if (layout.hDWP == NULL || !::EndDeferWindowPos(layout.hDWP)) TRACE0("Warning: DeferWindowPos failed - low system resources.\n"); // invalidate all the splitter bars (with NULL pDC) DrawAllSplitBars(NULL, rectInside.right, rectInside.bottom); }