1 // ResizableSplitterWnd.cpp : implementation file
\r
3 /////////////////////////////////////////////////////////////////////////////
\r
5 // This file is part of ResizableLib
\r
6 // http://sourceforge.net/projects/resizablelib
\r
8 // Copyright (C) 2000-2004 by Paolo Messina
\r
9 // http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com
\r
11 // The contents of this file are subject to the Artistic License (the "License").
\r
12 // You may not use this file except in compliance with the License.
\r
13 // You may obtain a copy of the License at:
\r
14 // http://www.opensource.org/licenses/artistic-license.html
\r
16 // If you find this code useful, credits would be nice!
\r
18 /////////////////////////////////////////////////////////////////////////////
\r
21 #include "ResizableSplitterWnd.h"
\r
24 #define new DEBUG_NEW
\r
26 static char THIS_FILE[] = __FILE__;
\r
29 /////////////////////////////////////////////////////////////////////////////
\r
30 // CResizableSplitterWnd
\r
32 IMPLEMENT_DYNAMIC(CResizableSplitterWnd, CSplitterWnd)
\r
34 CResizableSplitterWnd::CResizableSplitterWnd()
\r
38 CResizableSplitterWnd::~CResizableSplitterWnd()
\r
42 BEGIN_MESSAGE_MAP(CResizableSplitterWnd, CSplitterWnd)
\r
43 //{{AFX_MSG_MAP(CResizableSplitterWnd)
\r
44 ON_WM_GETMINMAXINFO()
\r
48 /////////////////////////////////////////////////////////////////////////////
\r
49 // CResizableSplitterWnd message handlers
\r
51 void CResizableSplitterWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
\r
53 if ((GetStyle() & SPLS_DYNAMIC_SPLIT) &&
\r
54 GetRowCount() == 1 && GetColumnCount() == 1)
\r
56 CWnd* pPane = GetActivePane();
\r
59 // get the extra size from child to parent
\r
60 CRect rectClient, rectWnd;
\r
61 GetWindowRect(rectWnd);
\r
62 pPane->GetWindowRect(rectClient);
\r
63 CSize sizeExtra = rectWnd.Size() - rectClient.Size();
\r
65 ChainMinMaxInfo(lpMMI, pPane->m_hWnd, sizeExtra);
\r
68 else if (!(GetStyle() & SPLS_DYNAMIC_SPLIT))
\r
70 ASSERT(m_nCols > 0 && m_nRows > 0);
\r
72 CSize sizeMin(0,0), sizeMax(0,0);
\r
73 for (int col = 0; col < m_nCols; ++col)
\r
75 // calc min and max width for each column
\r
78 for (int row = 0; row < m_nRows; ++row)
\r
80 CWnd* pWnd = GetPane(row, col);
\r
81 // ask the child window for track size
\r
82 MINMAXINFO mmiChild = *lpMMI;
\r
83 mmiChild.ptMinTrackSize.x = 0;
\r
84 mmiChild.ptMaxTrackSize.x = LONG_MAX;
\r
85 ::SendMessage(pWnd->GetSafeHwnd(), WM_GETMINMAXINFO, 0, (LPARAM)&mmiChild);
\r
86 max = __min(max, mmiChild.ptMaxTrackSize.x);
\r
87 min = __max(min, mmiChild.ptMinTrackSize.x);
\r
89 // sum all column widths
\r
90 if (sizeMax.cx == LONG_MAX || max == LONG_MAX)
\r
91 sizeMax.cx = LONG_MAX;
\r
93 sizeMax.cx += max + m_cxSplitterGap;
\r
94 sizeMin.cx += min + m_cxSplitterGap;
\r
96 for (int row = 0; row < m_nRows; ++row)
\r
98 // calc min and max height for each row
\r
100 int max = LONG_MAX;
\r
101 for (int col = 0; col < m_nCols; ++col)
\r
103 CWnd* pWnd = GetPane(row, col);
\r
104 // ask the child window for track size
\r
105 MINMAXINFO mmiChild = *lpMMI;
\r
106 mmiChild.ptMinTrackSize.y = 0;
\r
107 mmiChild.ptMaxTrackSize.y = LONG_MAX;
\r
108 ::SendMessage(pWnd->GetSafeHwnd(), WM_GETMINMAXINFO, 0, (LPARAM)&mmiChild);
\r
109 max = __min(max, mmiChild.ptMaxTrackSize.y);
\r
110 min = __max(min, mmiChild.ptMinTrackSize.y);
\r
112 // sum all row heights
\r
113 if (sizeMax.cy == LONG_MAX || max == LONG_MAX)
\r
114 sizeMax.cy = LONG_MAX;
\r
116 sizeMax.cy += max + m_cySplitterGap;
\r
117 sizeMin.cy += min + m_cySplitterGap;
\r
119 // adjust total size: add the client border and
\r
120 // we counted one splitter more than necessary
\r
121 sizeMax.cx += 2*m_cxBorder - m_cxSplitterGap;
\r
122 sizeMax.cy += 2*m_cyBorder - m_cySplitterGap;
\r
123 sizeMin.cx += 2*m_cxBorder - m_cxSplitterGap;
\r
124 sizeMin.cy += 2*m_cyBorder - m_cySplitterGap;
\r
125 // add non-client size
\r
126 CRect rectExtra(0,0,0,0);
\r
127 ::AdjustWindowRectEx(&rectExtra, GetStyle(), !(GetStyle() & WS_CHILD) &&
\r
128 ::IsMenu(GetMenu()->GetSafeHmenu()), GetExStyle());
\r
129 sizeMax += rectExtra.Size();
\r
130 sizeMin += rectExtra.Size();
\r
132 lpMMI->ptMinTrackSize.x = __max(lpMMI->ptMinTrackSize.x, sizeMin.cx);
\r
133 lpMMI->ptMinTrackSize.y = __max(lpMMI->ptMinTrackSize.y, sizeMin.cy);
\r
134 lpMMI->ptMaxTrackSize.x = __min(lpMMI->ptMaxTrackSize.x, sizeMax.cx);
\r
135 lpMMI->ptMaxTrackSize.y = __min(lpMMI->ptMaxTrackSize.y, sizeMax.cy);
\r