Keep track of per-column information inside the listview.
[wine] / dlls / user / user16.c
1 /*
2  * Misc 16-bit USER functions
3  *
4  * Copyright 2002 Patrik Stridvall
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "wine/winuser16.h"
22 #include "winbase.h"
23 #include "wownt32.h"
24 #include "user.h"
25
26 /* handle to handle 16 conversions */
27 #define HANDLE_16(h32)          (LOWORD(h32))
28
29 /* handle16 to handle conversions */
30 #define HANDLE_32(h16)          ((HANDLE)(ULONG_PTR)(h16))
31 #define HINSTANCE_32(h16)       ((HINSTANCE)(ULONG_PTR)(h16))
32
33 WORD WINAPI DestroyIcon32(HGLOBAL16, UINT16);
34
35
36 /***********************************************************************
37  *              SetCursor (USER.69)
38  */
39 HCURSOR16 WINAPI SetCursor16(HCURSOR16 hCursor)
40 {
41   return HCURSOR_16(SetCursor(HCURSOR_32(hCursor)));
42 }
43
44 /***********************************************************************
45  *              ShowCursor (USER.71)
46  */
47 INT16 WINAPI ShowCursor16(BOOL16 bShow)
48 {
49   return ShowCursor(bShow);
50 }
51
52 /***********************************************************************
53  *              DrawIcon (USER.84)
54  */
55 BOOL16 WINAPI DrawIcon16(HDC16 hdc, INT16 x, INT16 y, HICON16 hIcon)
56 {
57   return DrawIcon(HDC_32(hdc), x, y, HICON_32(hIcon));
58 }
59
60 /***********************************************************************
61  *              IconSize (USER.86)
62  *
63  * See "Undocumented Windows". Used by W2.0 paint.exe.
64  */
65 DWORD WINAPI IconSize16(void)
66 {
67   return MAKELONG(GetSystemMetrics(SM_CYICON), GetSystemMetrics(SM_CXICON));
68 }
69
70 /***********************************************************************
71  *              LoadCursor (USER.173)
72  */
73 HCURSOR16 WINAPI LoadCursor16(HINSTANCE16 hInstance, LPCSTR name)
74 {
75   return HCURSOR_16(LoadCursorA(HINSTANCE_32(hInstance), name));
76 }
77
78
79 /***********************************************************************
80  *              LoadIcon (USER.174)
81  */
82 HICON16 WINAPI LoadIcon16(HINSTANCE16 hInstance, LPCSTR name)
83 {
84   return HICON_16(LoadIconA(HINSTANCE_32(hInstance), name));
85 }
86
87 /**********************************************************************
88  *              LoadBitmap (USER.175)
89  */
90 HBITMAP16 WINAPI LoadBitmap16(HINSTANCE16 hInstance, LPCSTR name)
91 {
92   return HBITMAP_16(LoadBitmapA(HINSTANCE_32(hInstance), name));
93 }
94
95 /***********************************************************************
96  *              GetCursor (USER.247)
97  */
98 HCURSOR16 WINAPI GetCursor16(void)
99 {
100   return HCURSOR_16(GetCursor());
101 }
102
103 /***********************************************************************
104  *              GlobalAddAtom (USER.268)
105  */
106 ATOM WINAPI GlobalAddAtom16(LPCSTR lpString)
107 {
108   return GlobalAddAtomA(lpString);
109 }
110
111 /***********************************************************************
112  *              GlobalDeleteAtom (USER.269)
113  */
114 ATOM WINAPI GlobalDeleteAtom16(ATOM nAtom)
115 {
116   return GlobalDeleteAtom(nAtom);
117 }
118
119 /***********************************************************************
120  *              GlobalFindAtom (USER.270)
121  */
122 ATOM WINAPI GlobalFindAtom16(LPCSTR lpString)
123 {
124   return GlobalFindAtomA(lpString);
125 }
126
127 /***********************************************************************
128  *              GlobalGetAtomName (USER.271)
129  */
130 UINT16 WINAPI GlobalGetAtomName16(ATOM nAtom, LPSTR lpBuffer, INT16 nSize)
131 {
132   return GlobalGetAtomNameA(nAtom, lpBuffer, nSize);
133 }
134
135 /***********************************************************************
136  *              SelectPalette (USER.282)
137  */
138 HPALETTE16 WINAPI SelectPalette16( HDC16 hdc, HPALETTE16 hpal, BOOL16 bForceBackground )
139 {
140     return HPALETTE_16( SelectPalette( HDC_32(hdc), HPALETTE_32(hpal), bForceBackground ));
141 }
142
143 /***********************************************************************
144  *              RealizePalette (USER.283)
145  */
146 UINT16 WINAPI RealizePalette16( HDC16 hdc )
147 {
148     return UserRealizePalette( HDC_32(hdc) );
149 }
150
151 /***********************************************************************
152  *              LoadImage (USER.389)
153  *
154  */
155 HANDLE16 WINAPI LoadImage16(HINSTANCE16 hinst, LPCSTR name, UINT16 type,
156                             INT16 desiredx, INT16 desiredy, UINT16 loadflags)
157 {
158   return HANDLE_16(LoadImageA(HINSTANCE_32(hinst), name, type, desiredx,
159                               desiredy, loadflags));
160 }
161
162 /******************************************************************************
163  *              CopyImage (USER.390) Creates new image and copies attributes to it
164  *
165  */
166 HICON16 WINAPI CopyImage16(HANDLE16 hnd, UINT16 type, INT16 desiredx,
167                            INT16 desiredy, UINT16 flags)
168 {
169   return HICON_16(CopyImage(HANDLE_32(hnd), (UINT)type, (INT)desiredx,
170                             (INT)desiredy, (UINT)flags));
171 }
172
173 /**********************************************************************
174  *              DrawIconEx (USER.394)
175  */
176 BOOL16 WINAPI DrawIconEx16(HDC16 hdc, INT16 xLeft, INT16 yTop, HICON16 hIcon,
177                            INT16 cxWidth, INT16 cyWidth, UINT16 istep,
178                            HBRUSH16 hbr, UINT16 flags)
179 {
180   return DrawIconEx(HDC_32(hdc), xLeft, yTop, HICON_32(hIcon), cxWidth, cyWidth,
181                     istep, HBRUSH_32(hbr), flags);
182 }
183
184 /**********************************************************************
185  *              GetIconInfo (USER.395)
186  */
187 BOOL16 WINAPI GetIconInfo16(HICON16 hIcon, LPICONINFO16 iconinfo)
188 {
189   ICONINFO ii32;
190   BOOL16 ret = GetIconInfo(HICON_32(hIcon), &ii32);
191
192   iconinfo->fIcon = ii32.fIcon;
193   iconinfo->xHotspot = ii32.xHotspot;
194   iconinfo->yHotspot = ii32.yHotspot;
195   iconinfo->hbmMask  = HBITMAP_16(ii32.hbmMask);
196   iconinfo->hbmColor = HBITMAP_16(ii32.hbmColor);
197   return ret;
198 }
199
200 /***********************************************************************
201  *              CreateCursor (USER.406)
202  */
203 HCURSOR16 WINAPI CreateCursor16(HINSTANCE16 hInstance,
204                                 INT16 xHotSpot, INT16 yHotSpot,
205                                 INT16 nWidth, INT16 nHeight,
206                                 LPCVOID lpANDbits, LPCVOID lpXORbits)
207 {
208   CURSORICONINFO info;
209
210   info.ptHotSpot.x = xHotSpot;
211   info.ptHotSpot.y = yHotSpot;
212   info.nWidth = nWidth;
213   info.nHeight = nHeight;
214   info.nWidthBytes = 0;
215   info.bPlanes = 1;
216   info.bBitsPerPixel = 1;
217
218   return CreateCursorIconIndirect16(hInstance, &info, lpANDbits, lpXORbits);
219 }
220
221 /**********************************************************************
222  *              CreateIconFromResourceEx (USER.450)
223  *
224  * FIXME: not sure about exact parameter types
225  */
226 HICON16 WINAPI CreateIconFromResourceEx16(LPBYTE bits, UINT16 cbSize,
227                                           BOOL16 bIcon, DWORD dwVersion,
228                                           INT16 width, INT16 height,
229                                           UINT16 cFlag)
230 {
231   return HICON_16(CreateIconFromResourceEx(bits, cbSize, bIcon, dwVersion,
232                                            width, height, cFlag));
233 }
234
235 /***********************************************************************
236  *              DestroyIcon (USER.457)
237  */
238 BOOL16 WINAPI DestroyIcon16(HICON16 hIcon)
239 {
240   return DestroyIcon32(hIcon, 0);
241 }
242
243 /***********************************************************************
244  *              DestroyCursor (USER.458)
245  */
246 BOOL16 WINAPI DestroyCursor16(HCURSOR16 hCursor)
247 {
248   return DestroyIcon32(hCursor, 0);
249 }