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