2 * PROJECT: ReactOS Applications Manager
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/rapps_new/splitter.cpp
5 * PURPOSE: SplitterBar functions
6 * PROGRAMMERS: Dmitry Chapyshev (dmitry@reactos.org)
11 HWND hVSplitter
= NULL
;
12 HWND hHSplitter
= NULL
;
14 static int HSplitterPos
= 0;
23 SetHSplitterPos(int Pos
)
28 /* Callback for horizontal splitter bar */
30 HSplitterWindowProc(HWND hwnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
)
36 SetHSplitterPos(GetWindowHeight(hListView
));
48 if (GetCapture() == hwnd
)
55 if (GetCapture() == hwnd
)
57 int Width
= GetClientWindowWidth(hMainWnd
) - GetWindowWidth(hTreeView
) - SPLIT_WIDTH
;
63 ScreenToClient(hMainWnd
, &Point
);
67 if ((GetClientWindowHeight(hMainWnd
) - GetWindowHeight(hStatusBar
) - SPLIT_WIDTH
) < NewPos
)
70 if ((GetWindowHeight(hToolBar
) + SPLIT_WIDTH
) > NewPos
)
73 SetHSplitterPos(NewPos
);
75 hdwp
= BeginDeferWindowPos(3);
79 hdwp
= DeferWindowPos(hdwp
,
82 GetWindowWidth(hTreeView
) + SPLIT_WIDTH
,
86 SWP_NOZORDER
|SWP_NOACTIVATE
);
90 hdwp
= DeferWindowPos(hdwp
,
93 GetWindowWidth(hTreeView
) + SPLIT_WIDTH
,
94 GetWindowHeight(hToolBar
),
96 Point
.y
- GetWindowHeight(hToolBar
),
97 SWP_NOZORDER
|SWP_NOACTIVATE
);
101 hdwp
= DeferWindowPos(hdwp
,
104 GetWindowWidth(hTreeView
) + SPLIT_WIDTH
,
105 Point
.y
+ SPLIT_WIDTH
,
107 GetClientWindowHeight(hMainWnd
) - (Point
.y
+ SPLIT_WIDTH
+ GetWindowHeight(hStatusBar
)),
108 SWP_NOZORDER
|SWP_NOACTIVATE
);
111 EndDeferWindowPos(hdwp
);
116 return DefWindowProc(hwnd
, Msg
, wParam
, lParam
);
119 /* Create horizontal splitter bar */
121 CreateHSplitBar(HWND hwnd
)
123 WCHAR szWindowClass
[] = L
"HSplitterWindowClass";
124 WNDCLASSEXW WndClass
= {0};
126 WndClass
.cbSize
= sizeof(WndClass
);
127 WndClass
.lpszClassName
= szWindowClass
;
128 WndClass
.lpfnWndProc
= HSplitterWindowProc
;
129 WndClass
.hInstance
= hInst
;
130 WndClass
.style
= CS_HREDRAW
| CS_VREDRAW
;
131 WndClass
.hCursor
= LoadCursor(0, IDC_SIZENS
);
132 WndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
134 if (RegisterClassExW(&WndClass
) == (ATOM
) 0)
136 /* TODO: Show error message */
140 hHSplitter
= CreateWindowExW(WS_EX_TRANSPARENT
,
143 WS_CHILD
| WS_VISIBLE
,
144 205, 180, 465, SPLIT_WIDTH
,
151 if (hHSplitter
== NULL
)
153 /* TODO: Show error message */
157 ShowWindow(hHSplitter
, SW_SHOW
);
158 UpdateWindow(hHSplitter
);
163 /* Callback for vertical splitter bar */
165 VSplitterWindowProc(HWND hwnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
)
175 if (GetCapture() == hwnd
)
182 if (GetCapture() == hwnd
)
187 GetCursorPos(&Point
);
188 ScreenToClient(hMainWnd
, &Point
);
190 if ((GetClientWindowWidth(hMainWnd
) - SPLIT_WIDTH
) < Point
.x
)
193 if (SPLIT_WIDTH
> Point
.x
)
196 hdwp
= BeginDeferWindowPos(5);
200 hdwp
= DeferWindowPos(hdwp
,
204 GetWindowHeight(hToolBar
),
206 GetClientWindowHeight(hMainWnd
) - GetWindowHeight(hToolBar
) - GetWindowHeight(hStatusBar
),
207 SWP_NOZORDER
|SWP_NOACTIVATE
);
211 hdwp
= DeferWindowPos(hdwp
,
215 GetWindowHeight(hToolBar
),
217 GetClientWindowHeight(hMainWnd
) - GetWindowHeight(hToolBar
) - GetWindowHeight(hStatusBar
),
218 SWP_NOZORDER
|SWP_NOACTIVATE
);
222 hdwp
= DeferWindowPos(hdwp
,
225 Point
.x
+ SPLIT_WIDTH
,
226 GetWindowHeight(hToolBar
),
227 GetClientWindowWidth(hMainWnd
) - (Point
.x
+ SPLIT_WIDTH
),
228 GetHSplitterPos() - GetWindowHeight(hToolBar
),
229 SWP_NOZORDER
|SWP_NOACTIVATE
);
232 hdwp
= DeferWindowPos(hdwp
,
235 Point
.x
+ SPLIT_WIDTH
,
236 GetHSplitterPos() + SPLIT_WIDTH
,
237 GetClientWindowWidth(hMainWnd
) - (Point
.x
+ SPLIT_WIDTH
),
238 GetClientWindowHeight(hMainWnd
) - (GetHSplitterPos() + SPLIT_WIDTH
+ GetWindowHeight(hStatusBar
)),
239 SWP_NOZORDER
|SWP_NOACTIVATE
);
242 hdwp
= DeferWindowPos(hdwp
,
245 Point
.x
+ SPLIT_WIDTH
,
247 GetClientWindowWidth(hMainWnd
) - (Point
.x
+ SPLIT_WIDTH
),
249 SWP_NOZORDER
|SWP_NOACTIVATE
);
252 EndDeferWindowPos(hdwp
);
257 return DefWindowProc(hwnd
, Msg
, wParam
, lParam
);
260 /* Create vertical splitter bar */
262 CreateVSplitBar(HWND hwnd
)
264 WCHAR szWindowClass
[] = L
"VSplitterWindowClass";
265 WNDCLASSEXW WndClass
= {0};
267 WndClass
.cbSize
= sizeof(WndClass
);
268 WndClass
.lpszClassName
= szWindowClass
;
269 WndClass
.lpfnWndProc
= VSplitterWindowProc
;
270 WndClass
.hInstance
= hInst
;
271 WndClass
.style
= CS_HREDRAW
| CS_VREDRAW
;
272 WndClass
.hCursor
= LoadCursor(0, IDC_SIZEWE
);
273 WndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
275 if (RegisterClassExW(&WndClass
) == (ATOM
) 0)
277 /* TODO: Show error message */
281 hVSplitter
= CreateWindowExW(WS_EX_TRANSPARENT
,
284 WS_CHILD
| WS_VISIBLE
,
285 201, 28, SPLIT_WIDTH
, 350,
294 /* TODO: Show error message */
298 ShowWindow(hVSplitter
, SW_SHOW
);
299 UpdateWindow(hVSplitter
);