fixed line endings on all files
[reactos.git] / reactos / lib / comctl32 / flatsb.c
1 /*
2 * Flat Scrollbar control
3 *
4 * Copyright 1998, 1999 Eric Kohl
5 * Copyright 1998 Alex Priem
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * NOTES
22 * This is just a dummy control. An author is needed! Any volunteers?
23 * I will only improve this control once in a while.
24 * Eric <ekohl@abo.rhein-zeitung.de>
25 *
26 * TODO:
27 * - All messages.
28 * - All notifications.
29 *
30 */
31
32 #include <stdarg.h>
33 #include <string.h>
34 #include "windef.h"
35 #include "winbase.h"
36 #include "winerror.h"
37 #include "wingdi.h"
38 #include "winuser.h"
39 #include "winnls.h"
40 #include "commctrl.h"
41 #include "comctl32.h"
42 #include "wine/debug.h"
43
44 WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
45
46 typedef struct
47 {
48 DWORD dwDummy; /* just to keep the compiler happy ;-) */
49 } FLATSB_INFO, *LPFLATSB_INFO;
50
51 #define FlatSB_GetInfoPtr(hwnd) ((FLATSB_INFO*)GetWindowLongA (hwnd, 0))
52
53
54 /***********************************************************************
55 * InitializeFlatSB (COMCTL32.@)
56 *
57 * returns nonzero if successful, zero otherwise
58 *
59 */
60 BOOL WINAPI InitializeFlatSB(HWND hwnd)
61 {
62 TRACE("[%p]\n", hwnd);
63 FIXME("stub\n");
64 return FALSE;
65 }
66
67 /***********************************************************************
68 * UninitializeFlatSB (COMCTL32.@)
69 *
70 * returns:
71 * E_FAIL if one of the scroll bars is currently in use
72 * S_FALSE if InitializeFlatSB was never called on this hwnd
73 * S_OK otherwise
74 *
75 */
76 HRESULT WINAPI UninitializeFlatSB(HWND hwnd)
77 {
78 TRACE("[%p]\n", hwnd);
79 FIXME("stub\n");
80 return S_FALSE;
81 }
82
83 /***********************************************************************
84 * FlatSB_GetScrollProp (COMCTL32.@)
85 *
86 * Returns nonzero if successful, or zero otherwise. If index is WSB_PROP_HSTYLE,
87 * the return is nonzero if InitializeFlatSB has been called for this window, or
88 * zero otherwise.
89 *
90 */
91 BOOL WINAPI
92 FlatSB_GetScrollProp(HWND hwnd, INT propIndex, LPINT prop)
93 {
94 TRACE("[%p] propIndex=%d\n", hwnd, propIndex);
95 FIXME("stub\n");
96 return FALSE;
97 }
98
99 /***********************************************************************
100 * FlatSB_SetScrollProp (COMCTL32.@)
101 */
102 BOOL WINAPI
103 FlatSB_SetScrollProp(HWND hwnd, UINT index, INT newValue, BOOL flag)
104 {
105 TRACE("[%p] index=%u newValue=%d flag=%d\n", hwnd, index, newValue, flag);
106 FIXME("stub\n");
107 return FALSE;
108 }
109
110 /***********************************************************************
111 * From the Microsoft docs:
112 * "If flat scroll bars haven't been initialized for the
113 * window, the flat scroll bar APIs will defer to the corresponding
114 * standard APIs. This allows the developer to turn flat scroll
115 * bars on and off without having to write conditional code."
116 *
117 * So, if we just call the standard functions until we implement
118 * the flat scroll bar functions, flat scroll bars will show up and
119 * behave properly, as though they had simply not been setup to
120 * have flat properties.
121 *
122 * Susan <sfarley@codeweavers.com>
123 *
124 */
125
126 /***********************************************************************
127 * FlatSB_EnableScrollBar (COMCTL32.@)
128 */
129 BOOL WINAPI
130 FlatSB_EnableScrollBar(HWND hwnd, int nBar, UINT flags)
131 {
132 return EnableScrollBar(hwnd, nBar, flags);
133 }
134
135 /***********************************************************************
136 * FlatSB_ShowScrollBar (COMCTL32.@)
137 */
138 BOOL WINAPI
139 FlatSB_ShowScrollBar(HWND hwnd, int nBar, BOOL fShow)
140 {
141 return ShowScrollBar(hwnd, nBar, fShow);
142 }
143
144 /***********************************************************************
145 * FlatSB_GetScrollRange (COMCTL32.@)
146 */
147 BOOL WINAPI
148 FlatSB_GetScrollRange(HWND hwnd, int nBar, LPINT min, LPINT max)
149 {
150 return GetScrollRange(hwnd, nBar, min, max);
151 }
152
153 /***********************************************************************
154 * FlatSB_GetScrollInfo (COMCTL32.@)
155 */
156 BOOL WINAPI
157 FlatSB_GetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info)
158 {
159 return GetScrollInfo(hwnd, nBar, info);
160 }
161
162 /***********************************************************************
163 * FlatSB_GetScrollPos (COMCTL32.@)
164 */
165 INT WINAPI
166 FlatSB_GetScrollPos(HWND hwnd, int nBar)
167 {
168 return GetScrollPos(hwnd, nBar);
169 }
170
171 /***********************************************************************
172 * FlatSB_SetScrollPos (COMCTL32.@)
173 */
174 INT WINAPI
175 FlatSB_SetScrollPos(HWND hwnd, int nBar, INT pos, BOOL bRedraw)
176 {
177 return SetScrollPos(hwnd, nBar, pos, bRedraw);
178 }
179
180 /***********************************************************************
181 * FlatSB_SetScrollInfo (COMCTL32.@)
182 */
183 INT WINAPI
184 FlatSB_SetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info, BOOL bRedraw)
185 {
186 return SetScrollInfo(hwnd, nBar, info, bRedraw);
187 }
188
189 /***********************************************************************
190 * FlatSB_SetScrollRange (COMCTL32.@)
191 */
192 INT WINAPI
193 FlatSB_SetScrollRange(HWND hwnd, int nBar, INT min, INT max, BOOL bRedraw)
194 {
195 return SetScrollRange(hwnd, nBar, min, max, bRedraw);
196 }
197
198
199 static LRESULT
200 FlatSB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
201 {
202 TRACE("[%p] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam);
203 return 0;
204 }
205
206
207 static LRESULT
208 FlatSB_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
209 {
210 TRACE("[%p] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam);
211 return 0;
212 }
213
214
215 static LRESULT WINAPI
216 FlatSB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
217 {
218 if (!FlatSB_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
219 return DefWindowProcA( hwnd, uMsg, wParam, lParam );
220
221 switch (uMsg)
222 {
223 case WM_CREATE:
224 return FlatSB_Create (hwnd, wParam, lParam);
225
226 case WM_DESTROY:
227 return FlatSB_Destroy (hwnd, wParam, lParam);
228
229 default:
230 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
231 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
232 uMsg, wParam, lParam);
233 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
234 }
235 return 0;
236 }
237
238
239 VOID
240 FLATSB_Register (void)
241 {
242 WNDCLASSA wndClass;
243
244 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
245 wndClass.style = CS_GLOBALCLASS;
246 wndClass.lpfnWndProc = (WNDPROC)FlatSB_WindowProc;
247 wndClass.cbClsExtra = 0;
248 wndClass.cbWndExtra = sizeof(FLATSB_INFO *);
249 wndClass.hCursor = LoadCursorA (0, (LPSTR)IDC_ARROW);
250 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
251 wndClass.lpszClassName = FLATSB_CLASSA;
252
253 RegisterClassA (&wndClass);
254 }
255
256
257 VOID
258 FLATSB_Unregister (void)
259 {
260 UnregisterClassA (FLATSB_CLASSA, NULL);
261 }