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