2 * PROJECT: ReactOS Applications Manager
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/rapps/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
,
150 if (hHSplitter
== NULL
)
152 /* TODO: Show error message */
156 ShowWindow(hHSplitter
, SW_SHOW
);
157 UpdateWindow(hHSplitter
);
162 /* Callback for vertical splitter bar */
164 VSplitterWindowProc(HWND hwnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
)
174 if (GetCapture() == hwnd
)
181 if (GetCapture() == hwnd
)
186 GetCursorPos(&Point
);
187 ScreenToClient(hMainWnd
, &Point
);
189 if ((GetClientWindowWidth(hMainWnd
) - SPLIT_WIDTH
) < Point
.x
)
192 if (SPLIT_WIDTH
> Point
.x
)
195 hdwp
= BeginDeferWindowPos(5);
199 hdwp
= DeferWindowPos(hdwp
,
203 GetWindowHeight(hToolBar
),
205 GetClientWindowHeight(hMainWnd
) - GetWindowHeight(hToolBar
) - GetWindowHeight(hStatusBar
),
206 SWP_NOZORDER
|SWP_NOACTIVATE
);
210 hdwp
= DeferWindowPos(hdwp
,
214 GetWindowHeight(hToolBar
),
216 GetClientWindowHeight(hMainWnd
) - GetWindowHeight(hToolBar
) - GetWindowHeight(hStatusBar
),
217 SWP_NOZORDER
|SWP_NOACTIVATE
);
221 hdwp
= DeferWindowPos(hdwp
,
224 Point
.x
+ SPLIT_WIDTH
,
225 GetWindowHeight(hToolBar
),
226 GetClientWindowWidth(hMainWnd
) - (Point
.x
+ SPLIT_WIDTH
),
227 GetHSplitterPos() - GetWindowHeight(hToolBar
),
228 SWP_NOZORDER
|SWP_NOACTIVATE
);
231 hdwp
= DeferWindowPos(hdwp
,
234 Point
.x
+ SPLIT_WIDTH
,
235 GetHSplitterPos() + SPLIT_WIDTH
,
236 GetClientWindowWidth(hMainWnd
) - (Point
.x
+ SPLIT_WIDTH
),
237 GetClientWindowHeight(hMainWnd
) - (GetHSplitterPos() + SPLIT_WIDTH
+ GetWindowHeight(hStatusBar
)),
238 SWP_NOZORDER
|SWP_NOACTIVATE
);
241 hdwp
= DeferWindowPos(hdwp
,
244 Point
.x
+ SPLIT_WIDTH
,
246 GetClientWindowWidth(hMainWnd
) - (Point
.x
+ SPLIT_WIDTH
),
248 SWP_NOZORDER
|SWP_NOACTIVATE
);
251 EndDeferWindowPos(hdwp
);
256 return DefWindowProc(hwnd
, Msg
, wParam
, lParam
);
259 /* Create vertical splitter bar */
261 CreateVSplitBar(HWND hwnd
)
263 WCHAR szWindowClass
[] = L
"VSplitterWindowClass";
264 WNDCLASSEXW WndClass
= {0};
266 WndClass
.cbSize
= sizeof(WndClass
);
267 WndClass
.lpszClassName
= szWindowClass
;
268 WndClass
.lpfnWndProc
= VSplitterWindowProc
;
269 WndClass
.hInstance
= hInst
;
270 WndClass
.style
= CS_HREDRAW
| CS_VREDRAW
;
271 WndClass
.hCursor
= LoadCursor(0, IDC_SIZEWE
);
272 WndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
274 if (RegisterClassExW(&WndClass
) == (ATOM
) 0)
276 /* TODO: Show error message */
280 hVSplitter
= CreateWindowExW(WS_EX_TRANSPARENT
,
283 WS_CHILD
| WS_VISIBLE
,
284 201, 28, SPLIT_WIDTH
, 350,
292 /* TODO: Show error message */
296 ShowWindow(hVSplitter
, SW_SHOW
);
297 UpdateWindow(hVSplitter
);