ReactOS  0.4.11-dev-946-g431643b
splitter.cpp
Go to the documentation of this file.
1 /*
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)
7  */
8 
9 #include "rapps.h"
10 
13 
14 static int HSplitterPos = 0;
15 
16 int
18 {
19  return HSplitterPos;
20 }
21 
22 VOID
24 {
25  HSplitterPos = Pos;
26 }
27 
28 /* Callback for horizontal splitter bar */
31 {
32  switch (Msg)
33  {
34  case WM_CREATE:
35  {
37  }
38  break;
39 
40  case WM_LBUTTONDOWN:
41  {
42  SetCapture(hwnd);
43  }
44  break;
45 
46  case WM_LBUTTONUP:
47  case WM_RBUTTONDOWN:
48  if (GetCapture() == hwnd)
49  {
51  }
52  break;
53 
54  case WM_MOUSEMOVE:
55  if (GetCapture() == hwnd)
56  {
57  int Width = GetClientWindowWidth(hMainWnd) - GetWindowWidth(hTreeView) - SPLIT_WIDTH;
58  int NewPos;
59  HDWP hdwp;
60  POINT Point;
61 
62  GetCursorPos(&Point);
63  ScreenToClient(hMainWnd, &Point);
64 
65  NewPos = Point.y;
66 
68  break;
69 
70  if ((GetWindowHeight(hToolBar) + SPLIT_WIDTH) > NewPos)
71  break;
72 
73  SetHSplitterPos(NewPos);
74 
75  hdwp = BeginDeferWindowPos(3);
76 
77  /* Size HSplitBar */
78  if (hdwp)
79  hdwp = DeferWindowPos(hdwp,
80  hHSplitter,
81  0,
82  GetWindowWidth(hTreeView) + SPLIT_WIDTH,
83  Point.y,
84  Width,
87 
88  /* Size ListView */
89  if (hdwp)
90  hdwp = DeferWindowPos(hdwp,
91  hListView,
92  0,
93  GetWindowWidth(hTreeView) + SPLIT_WIDTH,
95  Width,
96  Point.y - GetWindowHeight(hToolBar),
98 
99  /* Size RichEdit */
100  if (hdwp)
101  hdwp = DeferWindowPos(hdwp,
102  hRichEdit,
103  0,
104  GetWindowWidth(hTreeView) + SPLIT_WIDTH,
105  Point.y + SPLIT_WIDTH,
106  Width,
109 
110  if (hdwp)
111  EndDeferWindowPos(hdwp);
112  }
113  break;
114  }
115 
116  return DefWindowProc(hwnd, Msg, wParam, lParam);
117 }
118 
119 /* Create horizontal splitter bar */
120 BOOL
122 {
123  WCHAR szWindowClass[] = L"HSplitterWindowClass";
124  WNDCLASSEXW WndClass = {0};
125 
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);
133 
134  if (RegisterClassExW(&WndClass) == (ATOM) 0)
135  {
136  /* TODO: Show error message */
137  return FALSE;
138  }
139 
140  hHSplitter = CreateWindowExW(WS_EX_TRANSPARENT,
141  szWindowClass,
142  NULL,
144  205, 180, 465, SPLIT_WIDTH,
145  hwnd,
146  NULL,
147  hInst,
148  NULL);
149 
150  if (hHSplitter == NULL)
151  {
152  /* TODO: Show error message */
153  return FALSE;
154  }
155 
156  ShowWindow(hHSplitter, SW_SHOW);
157  UpdateWindow(hHSplitter);
158 
159  return TRUE;
160 }
161 
162 /* Callback for vertical splitter bar */
165 {
166  switch (Msg)
167  {
168  case WM_LBUTTONDOWN:
169  SetCapture(hwnd);
170  break;
171 
172  case WM_LBUTTONUP:
173  case WM_RBUTTONDOWN:
174  if (GetCapture() == hwnd)
175  {
176  ReleaseCapture();
177  }
178  break;
179 
180  case WM_MOUSEMOVE:
181  if (GetCapture() == hwnd)
182  {
183  HDWP hdwp;
184  POINT Point;
185 
186  GetCursorPos(&Point);
187  ScreenToClient(hMainWnd, &Point);
188 
189  if ((GetClientWindowWidth(hMainWnd) - SPLIT_WIDTH) < Point.x)
190  break;
191 
192  if (SPLIT_WIDTH > Point.x)
193  break;
194 
195  hdwp = BeginDeferWindowPos(5);
196 
197  /* Size VSplitBar */
198  if (hdwp)
199  hdwp = DeferWindowPos(hdwp,
200  hwnd,
201  0,
202  Point.x,
204  SPLIT_WIDTH,
207 
208  /* Size TreeView */
209  if (hdwp)
210  hdwp = DeferWindowPos(hdwp,
211  hTreeView,
212  0,
213  0,
215  Point.x,
218 
219  /* Size ListView */
220  if (hdwp)
221  hdwp = DeferWindowPos(hdwp,
222  hListView,
223  0,
224  Point.x + SPLIT_WIDTH,
229 
230  if (hdwp)
231  hdwp = DeferWindowPos(hdwp,
232  hRichEdit,
233  0,
234  Point.x + SPLIT_WIDTH,
239 
240  if (hdwp)
241  hdwp = DeferWindowPos(hdwp,
242  hHSplitter,
243  0,
244  Point.x + SPLIT_WIDTH,
245  GetHSplitterPos(),
247  SPLIT_WIDTH,
249 
250  if (hdwp)
251  EndDeferWindowPos(hdwp);
252  }
253  break;
254  }
255 
256  return DefWindowProc(hwnd, Msg, wParam, lParam);
257 }
258 
259 /* Create vertical splitter bar */
260 BOOL
262 {
263  WCHAR szWindowClass[] = L"VSplitterWindowClass";
264  WNDCLASSEXW WndClass = {0};
265 
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);
273 
274  if (RegisterClassExW(&WndClass) == (ATOM) 0)
275  {
276  /* TODO: Show error message */
277  return FALSE;
278  }
279 
280  hVSplitter = CreateWindowExW(WS_EX_TRANSPARENT,
281  szWindowClass,
282  NULL,
284  201, 28, SPLIT_WIDTH, 350,
285  hwnd,
286  NULL,
287  hInst,
288  NULL);
289 
290  if (!hVSplitter)
291  {
292  /* TODO: Show error message */
293  return FALSE;
294  }
295 
296  ShowWindow(hVSplitter, SW_SHOW);
297  UpdateWindow(hVSplitter);
298 
299  return TRUE;
300 }
#define IDC_SIZEWE
Definition: winuser.h:689
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HDWP WINAPI BeginDeferWindowPos(_In_ int)
#define TRUE
Definition: types.h:120
long y
Definition: polytest.cpp:48
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
long x
Definition: polytest.cpp:48
WORD ATOM
Definition: dimm.idl:113
__wchar_t WCHAR
Definition: xmlstorage.h:180
static int HSplitterPos
Definition: splitter.cpp:14
LRESULT CALLBACK VSplitterWindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: splitter.cpp:164
#define CALLBACK
Definition: compat.h:27
ush Pos
Definition: deflate.h:92
BOOL WINAPI UpdateWindow(_In_ HWND)
#define WS_EX_TRANSPARENT
Definition: pedump.c:649
#define CS_HREDRAW
Definition: winuser.h:648
HWND hHSplitter
Definition: splitter.cpp:12
HWND hToolBar
Definition: mplay32.c:17
#define WS_CHILD
Definition: pedump.c:617
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
HWND hVSplitter
Definition: splitter.cpp:11
WPARAM wParam
Definition: combotst.c:138
#define SPLIT_WIDTH
Definition: eventvwr.c:62
#define IDC_SIZENS
Definition: winuser.h:690
struct @1571 Msg[]
UINT_PTR WPARAM
Definition: windef.h:207
VOID SetHSplitterPos(int Pos)
Definition: splitter.cpp:23
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
const TCHAR szWindowClass[]
Definition: magnifier.c:29
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
HWND WINAPI GetCapture(void)
Definition: message.c:2855
smooth NULL
Definition: ftsmooth.c:416
#define SW_SHOW
Definition: winuser.h:769
LPCWSTR lpszClassName
Definition: winuser.h:3179
#define DefWindowProc
Definition: ros2win.h:31
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
#define CS_VREDRAW
Definition: winuser.h:653
unsigned int BOOL
Definition: ntddk_ex.h:94
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
HBRUSH hbrBackground
Definition: winuser.h:3177
UINT cbSize
Definition: winuser.h:3169
#define SWP_NOACTIVATE
Definition: winuser.h:1227
INT GetClientWindowWidth(HWND hwnd)
Definition: misc.cpp:33
unsigned int UINT
Definition: ndis.h:50
HWND hStatusBar
Definition: main.cpp:35
BOOL CreateHSplitBar(HWND hwnd)
Definition: splitter.cpp:121
HINSTANCE hInstance
Definition: winuser.h:3174
int GetHSplitterPos(VOID)
Definition: splitter.cpp:17
HWND hMainWnd
Definition: magnifier.c:33
struct Point Point
static const WCHAR L[]
Definition: oid.c:1087
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL CreateVSplitBar(HWND hwnd)
Definition: splitter.cpp:261
#define COLOR_BTNFACE
Definition: winuser.h:918
INT GetWindowHeight(HWND hwnd)
Definition: misc.cpp:25
HCURSOR hCursor
Definition: winuser.h:3176
UINT style
Definition: winuser.h:3170
#define LoadCursor
Definition: winuser.h:5678
WNDPROC lpfnWndProc
Definition: winuser.h:3171
HWND hListView
Definition: gui.cpp:29
HWND WINAPI SetCapture(_In_ HWND hWnd)
HINSTANCE hInst
Definition: dxdiag.c:13
#define WM_LBUTTONUP
Definition: winuser.h:1753
INT GetWindowWidth(HWND hwnd)
Definition: misc.cpp:17
LRESULT CALLBACK HSplitterWindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: splitter.cpp:30
#define WM_MOUSEMOVE
Definition: winuser.h:1751
INT GetClientWindowHeight(HWND hwnd)
Definition: misc.cpp:41
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2864
#define WM_CREATE
Definition: winuser.h:1590
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
LONG_PTR LRESULT
Definition: windef.h:209
#define WS_VISIBLE
Definition: pedump.c:620
LPARAM lParam
Definition: combotst.c:139
WCHAR WndClass[]
Definition: capicon.c:23