2 * PROJECT: ReactOS Applications Manager
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/rapps/splitter.c
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);
81 GetWindowWidth(hTreeView
) + SPLIT_WIDTH
,
85 SWP_NOZORDER
|SWP_NOACTIVATE
);
91 GetWindowWidth(hTreeView
) + SPLIT_WIDTH
,
92 GetWindowHeight(hToolBar
),
94 Point
.y
- GetWindowHeight(hToolBar
),
95 SWP_NOZORDER
|SWP_NOACTIVATE
);
101 GetWindowWidth(hTreeView
) + SPLIT_WIDTH
,
102 Point
.y
+ SPLIT_WIDTH
,
104 GetClientWindowHeight(hMainWnd
) - (Point
.y
+ SPLIT_WIDTH
+ GetWindowHeight(hStatusBar
)),
105 SWP_NOZORDER
|SWP_NOACTIVATE
);
107 EndDeferWindowPos(hdwp
);
112 return DefWindowProc(hwnd
, Msg
, wParam
, lParam
);
115 /* Create horizontal splitter bar */
117 CreateHSplitBar(HWND hwnd
)
119 WCHAR szWindowClass
[] = L
"HSplitterWindowClass";
120 WNDCLASSEXW WndClass
= {0};
122 WndClass
.cbSize
= sizeof(WNDCLASSEXW
);
123 WndClass
.lpszClassName
= szWindowClass
;
124 WndClass
.lpfnWndProc
= HSplitterWindowProc
;
125 WndClass
.hInstance
= hInst
;
126 WndClass
.style
= CS_HREDRAW
| CS_VREDRAW
;
127 WndClass
.hCursor
= LoadCursor(0, IDC_SIZENS
);
128 WndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
130 if (RegisterClassExW(&WndClass
) == (ATOM
) 0)
132 /* TODO: Show error message */
136 hHSplitter
= CreateWindowExW(WS_EX_TRANSPARENT
,
139 WS_CHILD
| WS_VISIBLE
,
140 205, 180, 465, SPLIT_WIDTH
,
147 if (hHSplitter
== NULL
)
149 /* TODO: Show error message */
153 ShowWindow(hHSplitter
, SW_SHOW
);
154 UpdateWindow(hHSplitter
);
159 /* Callback for vertical splitter bar */
161 VSplitterWindowProc(HWND hwnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
)
171 if (GetCapture() == hwnd
)
178 if (GetCapture() == hwnd
)
183 GetCursorPos(&Point
);
184 ScreenToClient(hMainWnd
, &Point
);
186 if ((GetClientWindowWidth(hMainWnd
) - SPLIT_WIDTH
) < Point
.x
)
189 if (SPLIT_WIDTH
> Point
.x
)
192 hdwp
= BeginDeferWindowPos(5);
199 GetWindowHeight(hToolBar
),
201 GetClientWindowHeight(hMainWnd
) - GetWindowHeight(hToolBar
) - GetWindowHeight(hStatusBar
),
202 SWP_NOZORDER
|SWP_NOACTIVATE
);
209 GetWindowHeight(hToolBar
),
211 GetClientWindowHeight(hMainWnd
) - GetWindowHeight(hToolBar
) - GetWindowHeight(hStatusBar
),
212 SWP_NOZORDER
|SWP_NOACTIVATE
);
218 Point
.x
+ SPLIT_WIDTH
,
219 GetWindowHeight(hToolBar
),
220 GetClientWindowWidth(hMainWnd
) - (Point
.x
+ SPLIT_WIDTH
),
221 GetHSplitterPos() - GetWindowHeight(hToolBar
),
222 SWP_NOZORDER
|SWP_NOACTIVATE
);
227 Point
.x
+ SPLIT_WIDTH
,
228 GetHSplitterPos() + SPLIT_WIDTH
,
229 GetClientWindowWidth(hMainWnd
) - (Point
.x
+ SPLIT_WIDTH
),
230 GetClientWindowHeight(hMainWnd
) - (GetHSplitterPos() + SPLIT_WIDTH
+ GetWindowHeight(hStatusBar
)),
231 SWP_NOZORDER
|SWP_NOACTIVATE
);
236 Point
.x
+ SPLIT_WIDTH
,
238 GetClientWindowWidth(hMainWnd
) - (Point
.x
+ SPLIT_WIDTH
),
240 SWP_NOZORDER
|SWP_NOACTIVATE
);
242 EndDeferWindowPos(hdwp
);
247 return DefWindowProc(hwnd
, Msg
, wParam
, lParam
);
250 /* Create vertical splitter bar */
252 CreateVSplitBar(HWND hwnd
)
254 WCHAR szWindowClass
[] = L
"VSplitterWindowClass";
255 WNDCLASSEXW WndClass
= {0};
257 WndClass
.cbSize
= sizeof(WNDCLASSEXW
);
258 WndClass
.lpszClassName
= szWindowClass
;
259 WndClass
.lpfnWndProc
= VSplitterWindowProc
;
260 WndClass
.hInstance
= hInst
;
261 WndClass
.style
= CS_HREDRAW
| CS_VREDRAW
;
262 WndClass
.hCursor
= LoadCursor(0, IDC_SIZEWE
);
263 WndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
265 if (RegisterClassExW(&WndClass
) == (ATOM
) 0)
267 /* TODO: Show error message */
271 hVSplitter
= CreateWindowExW(WS_EX_TRANSPARENT
,
274 WS_CHILD
| WS_VISIBLE
,
275 201, 28, SPLIT_WIDTH
, 350,
284 /* TODO: Show error message */
288 ShowWindow(hVSplitter
, SW_SHOW
);
289 UpdateWindow(hVSplitter
);