OSDN Git Service

tooltips updated for overlay settings dialog
[tortoisegit/TortoiseGitJp.git] / ext / ResizableLib / ResizableSplitterWnd.cpp
1 // ResizableSplitterWnd.cpp : implementation file\r
2 //\r
3 /////////////////////////////////////////////////////////////////////////////\r
4 //\r
5 // This file is part of ResizableLib\r
6 // http://sourceforge.net/projects/resizablelib\r
7 //\r
8 // Copyright (C) 2000-2004 by Paolo Messina\r
9 // http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com\r
10 //\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
15 //\r
16 // If you find this code useful, credits would be nice!\r
17 //\r
18 /////////////////////////////////////////////////////////////////////////////\r
19 \r
20 #include "stdafx.h"\r
21 #include "ResizableSplitterWnd.h"\r
22 \r
23 #ifdef _DEBUG\r
24 #define new DEBUG_NEW\r
25 #undef THIS_FILE\r
26 static char THIS_FILE[] = __FILE__;\r
27 #endif\r
28 \r
29 /////////////////////////////////////////////////////////////////////////////\r
30 // CResizableSplitterWnd\r
31 \r
32 IMPLEMENT_DYNAMIC(CResizableSplitterWnd, CSplitterWnd)\r
33 \r
34 CResizableSplitterWnd::CResizableSplitterWnd()\r
35 {\r
36 }\r
37 \r
38 CResizableSplitterWnd::~CResizableSplitterWnd()\r
39 {\r
40 }\r
41 \r
42 BEGIN_MESSAGE_MAP(CResizableSplitterWnd, CSplitterWnd)\r
43         //{{AFX_MSG_MAP(CResizableSplitterWnd)\r
44         ON_WM_GETMINMAXINFO()\r
45         //}}AFX_MSG_MAP\r
46 END_MESSAGE_MAP()\r
47 \r
48 /////////////////////////////////////////////////////////////////////////////\r
49 // CResizableSplitterWnd message handlers\r
50 \r
51 void CResizableSplitterWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) \r
52 {\r
53         if ((GetStyle() & SPLS_DYNAMIC_SPLIT) &&\r
54                 GetRowCount() == 1 && GetColumnCount() == 1)\r
55         {\r
56                 CWnd* pPane = GetActivePane();\r
57                 if (pPane != NULL)\r
58                 {\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
64 \r
65                         ChainMinMaxInfo(lpMMI, pPane->m_hWnd, sizeExtra);\r
66                 }\r
67         }\r
68         else if (!(GetStyle() & SPLS_DYNAMIC_SPLIT))\r
69         {\r
70                 ASSERT(m_nCols > 0 && m_nRows > 0);\r
71 \r
72                 CSize sizeMin(0,0), sizeMax(0,0);\r
73                 for (int col = 0; col < m_nCols; ++col)\r
74                 {\r
75                         // calc min and max width for each column\r
76                         int min = 0;\r
77                         int max = LONG_MAX;\r
78                         for (int row = 0; row < m_nRows; ++row)\r
79                         {\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
88                         }\r
89                         // sum all column widths\r
90                         if (sizeMax.cx == LONG_MAX || max == LONG_MAX)\r
91                                 sizeMax.cx = LONG_MAX;\r
92                         else\r
93                                 sizeMax.cx += max + m_cxSplitterGap;\r
94                         sizeMin.cx += min + m_cxSplitterGap;\r
95                 }\r
96                 for (int row = 0; row < m_nRows; ++row)\r
97                 {\r
98                         // calc min and max height for each row\r
99                         int min = 0;\r
100                         int max = LONG_MAX;\r
101                         for (int col = 0; col < m_nCols; ++col)\r
102                         {\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
111                         }\r
112                         // sum all row heights\r
113                         if (sizeMax.cy == LONG_MAX || max == LONG_MAX)\r
114                                 sizeMax.cy = LONG_MAX;\r
115                         else\r
116                                 sizeMax.cy += max + m_cySplitterGap;\r
117                         sizeMin.cy += min + m_cySplitterGap;\r
118                 }\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
131                 // set minmax info\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
136         }\r
137 }\r