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