blob: 817120238f0bd9a69cfbc0d71fcd8064d9d7d36d [file] [log] [blame]
Alexandre Julliard0e607781993-11-03 19:23:37 +00001/*
2 * Static control
3 *
4 * Copyright David W. Metcalfe, 1993
5 *
Alexandre Julliard8664b891996-04-05 14:58:24 +00006 */
Alexandre Julliard0e607781993-11-03 19:23:37 +00007
Alexandre Julliard530ee841996-10-23 16:59:13 +00008#include "windows.h"
Alexandre Julliard0e607781993-11-03 19:23:37 +00009#include "win.h"
Alexandre Julliard491502b1997-11-01 19:08:16 +000010#include "bitmap.h"
11#include "cursoricon.h"
Alexandre Julliardaca05781994-10-17 18:12:41 +000012#include "static.h"
Alexandre Julliardd37eb361997-07-20 16:23:21 +000013#include "heap.h"
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000014#include "debug.h"
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000015#include "tweak.h"
Alexandre Julliard0e607781993-11-03 19:23:37 +000016
Alexandre Julliard530ee841996-10-23 16:59:13 +000017static void STATIC_PaintTextfn( WND *wndPtr, HDC32 hdc );
18static void STATIC_PaintRectfn( WND *wndPtr, HDC32 hdc );
19static void STATIC_PaintIconfn( WND *wndPtr, HDC32 hdc );
Alexandre Julliard491502b1997-11-01 19:08:16 +000020static void STATIC_PaintBitmapfn( WND *wndPtr, HDC32 hdc );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000021static void STATIC_PaintEtchedfn( WND *wndPtr, HDC32 hdc );
Alexandre Julliard0e607781993-11-03 19:23:37 +000022
Alexandre Julliardaca05781994-10-17 18:12:41 +000023static COLORREF color_windowframe, color_background, color_window;
Alexandre Julliard0e607781993-11-03 19:23:37 +000024
Alexandre Julliard0e607781993-11-03 19:23:37 +000025
Alexandre Julliard530ee841996-10-23 16:59:13 +000026typedef void (*pfPaint)( WND *, HDC32 );
Alexandre Julliardaca05781994-10-17 18:12:41 +000027
Alexandre Julliard491502b1997-11-01 19:08:16 +000028static pfPaint staticPaintFunc[SS_TYPEMASK+1] =
Alexandre Julliard0e607781993-11-03 19:23:37 +000029{
Alexandre Julliard8664b891996-04-05 14:58:24 +000030 STATIC_PaintTextfn, /* SS_LEFT */
31 STATIC_PaintTextfn, /* SS_CENTER */
32 STATIC_PaintTextfn, /* SS_RIGHT */
33 STATIC_PaintIconfn, /* SS_ICON */
34 STATIC_PaintRectfn, /* SS_BLACKRECT */
35 STATIC_PaintRectfn, /* SS_GRAYRECT */
36 STATIC_PaintRectfn, /* SS_WHITERECT */
37 STATIC_PaintRectfn, /* SS_BLACKFRAME */
38 STATIC_PaintRectfn, /* SS_GRAYFRAME */
39 STATIC_PaintRectfn, /* SS_WHITEFRAME */
Alexandre Julliardaca05781994-10-17 18:12:41 +000040 NULL, /* Not defined */
Alexandre Julliard8664b891996-04-05 14:58:24 +000041 STATIC_PaintTextfn, /* SS_SIMPLE */
Alexandre Julliard491502b1997-11-01 19:08:16 +000042 STATIC_PaintTextfn, /* SS_LEFTNOWORDWRAP */
43 NULL, /* SS_OWNERDRAW */
44 STATIC_PaintBitmapfn, /* SS_BITMAP */
45 NULL, /* SS_ENHMETAFILE */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000046 STATIC_PaintEtchedfn, /* SS_ETCHEDHORIZ */
47 STATIC_PaintEtchedfn, /* SS_ETCHEDVERT */
48 STATIC_PaintEtchedfn, /* SS_ETCHEDFRAME */
Alexandre Julliard0e607781993-11-03 19:23:37 +000049};
50
51
Alexandre Julliardaca05781994-10-17 18:12:41 +000052/***********************************************************************
53 * STATIC_SetIcon
54 *
55 * Set the icon for an SS_ICON control.
56 */
Alexandre Julliard8cc3a5e1996-08-11 15:49:51 +000057static HICON16 STATIC_SetIcon( WND *wndPtr, HICON16 hicon )
Alexandre Julliardaca05781994-10-17 18:12:41 +000058{
Alexandre Julliard8cc3a5e1996-08-11 15:49:51 +000059 HICON16 prevIcon;
Alexandre Julliardaca05781994-10-17 18:12:41 +000060 STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
Alexandre Julliard670cdc41997-08-24 16:00:30 +000061 CURSORICONINFO *info = hicon?(CURSORICONINFO *) GlobalLock16( hicon ):NULL;
Alexandre Julliardaca05781994-10-17 18:12:41 +000062
Alexandre Julliard491502b1997-11-01 19:08:16 +000063 if ((wndPtr->dwStyle & SS_TYPEMASK) != SS_ICON) return 0;
Alexandre Julliard670cdc41997-08-24 16:00:30 +000064 if (hicon && !info) {
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000065 ERR(static, "huh? hicon!=0, but info=0???\n");
Alexandre Julliard670cdc41997-08-24 16:00:30 +000066 return 0;
67 }
Alexandre Julliard7d654eb1996-02-25 11:36:22 +000068 prevIcon = infoPtr->hIcon;
Alexandre Julliardaca05781994-10-17 18:12:41 +000069 infoPtr->hIcon = hicon;
70 if (hicon)
71 {
Alexandre Julliard01d63461997-01-20 19:43:45 +000072 SetWindowPos32( wndPtr->hwndSelf, 0, 0, 0, info->nWidth, info->nHeight,
73 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000074 GlobalUnlock16( hicon );
Alexandre Julliardaca05781994-10-17 18:12:41 +000075 }
Alexandre Julliard7d654eb1996-02-25 11:36:22 +000076 return prevIcon;
Alexandre Julliardaca05781994-10-17 18:12:41 +000077}
78
Alexandre Julliard491502b1997-11-01 19:08:16 +000079/***********************************************************************
80 * STATIC_SetBitmap
81 *
82 * Set the bitmap for an SS_BITMAP control.
83 */
84static HICON16 STATIC_SetBitmap( WND *wndPtr, HICON16 hicon )
85{
86 HICON16 prevIcon;
87 STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000088 BITMAPOBJ *info = (BITMAPOBJ *)GDI_HEAP_LOCK(hicon);
Alexandre Julliard491502b1997-11-01 19:08:16 +000089
90 if ((wndPtr->dwStyle & SS_TYPEMASK) != SS_BITMAP) return 0;
91 if (hicon && !info) {
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000092 ERR(static, "huh? hicon!=0, but info=0???\n");
Alexandre Julliard491502b1997-11-01 19:08:16 +000093 return 0;
94 }
95 prevIcon = infoPtr->hIcon;
96 infoPtr->hIcon = hicon;
97 if (hicon)
98 {
99 SetWindowPos32( wndPtr->hwndSelf, 0, 0, 0, info->bitmap.bmWidth, info->bitmap.bmHeight,
100 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
101 }
102 GDI_HEAP_UNLOCK( hicon );
103 return prevIcon;
104}
105
Alexandre Julliardaca05781994-10-17 18:12:41 +0000106
107/***********************************************************************
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000108 * STATIC_LoadIcon
109 *
110 * Load the icon for an SS_ICON control.
111 */
112static HICON16 STATIC_LoadIcon( WND *wndPtr, LPCSTR name )
113{
114 HICON16 hicon;
115
116 if (wndPtr->flags & WIN_ISWIN32)
117 {
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000118 if (!HIWORD(wndPtr->hInstance)) {
119 LPSTR segname = SEGPTR_STRDUP(name);
120 hicon = LoadIcon16( wndPtr->hInstance, SEGPTR_GET(segname) );
121 SEGPTR_FREE(segname);
122 } else
123 hicon = LoadIcon32A( wndPtr->hInstance, name );
124 } else {
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000125 LPSTR segname = SEGPTR_STRDUP(name);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000126
127 if (HIWORD(wndPtr->hInstance))
128 FIXME(static,"win16 window class, but win32 hinstance??\n");
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000129 hicon = LoadIcon16( wndPtr->hInstance, SEGPTR_GET(segname) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000130 SEGPTR_FREE(segname);
131 }
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000132 if (!hicon)
133 hicon = LoadIcon32A( 0, name );
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000134 return hicon;
135}
136
Alexandre Julliard491502b1997-11-01 19:08:16 +0000137/***********************************************************************
138 * STATIC_LoadBitmap
139 *
140 * Load the bitmap for an SS_BITMAP control.
141 */
142static HBITMAP16 STATIC_LoadBitmap( WND *wndPtr, LPCSTR name )
143{
144 HBITMAP16 hbitmap;
145
146 if (wndPtr->flags & WIN_ISWIN32)
147 {
148 hbitmap = LoadBitmap32A( wndPtr->hInstance, name );
149 if (!hbitmap) /* Try OEM icon (FIXME: is this right?) */
150 hbitmap = LoadBitmap32A( 0, name );
151 }
152 else
153 {
154 LPSTR segname = SEGPTR_STRDUP(name);
155 hbitmap = LoadBitmap16( wndPtr->hInstance, SEGPTR_GET(segname) );
156 if (!hbitmap) /* Try OEM icon (FIXME: is this right?) */
157 hbitmap = LoadBitmap32A( 0, segname );
158 SEGPTR_FREE(segname);
159 }
160 return hbitmap;
161}
162
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000163
164/***********************************************************************
Alexandre Julliardaca05781994-10-17 18:12:41 +0000165 * StaticWndProc
166 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000167LRESULT WINAPI StaticWndProc( HWND32 hWnd, UINT32 uMsg, WPARAM32 wParam,
168 LPARAM lParam )
Alexandre Julliard0e607781993-11-03 19:23:37 +0000169{
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000170 LRESULT lResult = 0;
171 WND *wndPtr = WIN_FindWndPtr(hWnd);
Alexandre Julliard491502b1997-11-01 19:08:16 +0000172 LONG style = wndPtr->dwStyle & SS_TYPEMASK;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000173 STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000174
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000175 switch (uMsg)
176 {
Marcus Meissner0108d641998-10-24 11:04:56 +0000177 case WM_NCCREATE: {
178 CREATESTRUCT32A *cs = (CREATESTRUCT32A *)lParam;
179
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000180 if ((TWEAK_WineLook > WIN31_LOOK) && (wndPtr->dwStyle & SS_SUNKEN))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000181 wndPtr->dwExStyle |= WS_EX_STATICEDGE;
182
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000183 if (style == SS_ICON)
184 {
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000185 if (cs->lpszName)
186 STATIC_SetIcon( wndPtr,
187 STATIC_LoadIcon( wndPtr, cs->lpszName ));
188 return 1;
189 }
Alexandre Julliard491502b1997-11-01 19:08:16 +0000190 if (style == SS_BITMAP)
191 {
Alexandre Julliard491502b1997-11-01 19:08:16 +0000192 if (cs->lpszName)
193 STATIC_SetBitmap( wndPtr,
194 STATIC_LoadBitmap( wndPtr, cs->lpszName ));
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000195 WARN(static, "style SS_BITMAP, dwStyle is 0x%08lx\n",
196 wndPtr->dwStyle);
Alexandre Julliard491502b1997-11-01 19:08:16 +0000197 return 1;
198 }
Marcus Meissner4ef4d6d1998-10-31 12:07:51 +0000199 if (!HIWORD(cs->lpszName) && (cs->lpszName)) {
Marcus Meissner0108d641998-10-24 11:04:56 +0000200 FIXME(static,"windowName is 0x%04x, not doing DefWindowProc\n",
201 LOWORD(cs->lpszName)
202 );
203 return 1;
204 }
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000205 return DefWindowProc32A( hWnd, uMsg, wParam, lParam );
Marcus Meissner0108d641998-10-24 11:04:56 +0000206 }
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000207 case WM_CREATE:
Alexandre Julliard491502b1997-11-01 19:08:16 +0000208 if (style < 0L || style > SS_TYPEMASK)
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000209 {
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000210 ERR(static, "Unknown style 0x%02lx\n", style );
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000211 lResult = -1L;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000212 break;
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000213 }
214 /* initialise colours */
215 color_windowframe = GetSysColor32(COLOR_WINDOWFRAME);
216 color_background = GetSysColor32(COLOR_BACKGROUND);
217 color_window = GetSysColor32(COLOR_WINDOW);
218 break;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000219
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000220 case WM_NCDESTROY:
Huw D M Davies1fea6b91998-12-07 12:50:14 +0000221 if (style == SS_ICON) {
222/*
223 * FIXME
224 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
225 *
226 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
227 * had already been loaded by the application the last thing we want to do is
228 * GlobalFree16 the handle.
229 */
230 } else {
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000231 lResult = DefWindowProc32A( hWnd, uMsg, wParam, lParam );
Huw D M Davies1fea6b91998-12-07 12:50:14 +0000232 }
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000233 break;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000234
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000235 case WM_PAINT:
236 {
237 PAINTSTRUCT32 ps;
238 BeginPaint32( hWnd, &ps );
239 if (staticPaintFunc[style])
240 (staticPaintFunc[style])( wndPtr, ps.hdc );
241 EndPaint32( hWnd, &ps );
242 }
243 break;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000244
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000245 case WM_ENABLE:
246 InvalidateRect32( hWnd, NULL, FALSE );
247 break;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000248
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000249 case WM_SYSCOLORCHANGE:
250 color_windowframe = GetSysColor32(COLOR_WINDOWFRAME);
251 color_background = GetSysColor32(COLOR_BACKGROUND);
252 color_window = GetSysColor32(COLOR_WINDOW);
253 InvalidateRect32( hWnd, NULL, TRUE );
254 break;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000255
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000256 case WM_SETTEXT:
257 if (style == SS_ICON)
258 /* FIXME : should we also return the previous hIcon here ??? */
259 STATIC_SetIcon( wndPtr, STATIC_LoadIcon( wndPtr, (LPCSTR)lParam ));
Alexandre Julliard491502b1997-11-01 19:08:16 +0000260 else if (style == SS_BITMAP)
261 STATIC_SetBitmap(wndPtr,STATIC_LoadBitmap(wndPtr,(LPCSTR)lParam ));
262 else
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000263 DEFWND_SetText( wndPtr, (LPCSTR)lParam );
264 InvalidateRect32( hWnd, NULL, FALSE );
265 UpdateWindow32( hWnd );
266 break;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000267
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000268 case WM_SETFONT:
269 if (style == SS_ICON) return 0;
Alexandre Julliard491502b1997-11-01 19:08:16 +0000270 if (style == SS_BITMAP) return 0;
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000271 infoPtr->hFont = (HFONT16)wParam;
272 if (LOWORD(lParam))
273 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000274 InvalidateRect32( hWnd, NULL, FALSE );
Alexandre Julliard21979011997-03-05 08:22:35 +0000275 UpdateWindow32( hWnd );
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000276 }
277 break;
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000278
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000279 case WM_GETFONT:
280 return infoPtr->hFont;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000281
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000282 case WM_NCHITTEST:
283 return HTTRANSPARENT;
284
285 case WM_GETDLGCODE:
286 return DLGC_STATIC;
287
Alexandre Julliard491502b1997-11-01 19:08:16 +0000288 case STM_GETIMAGE:
289 case STM_GETICON16:
290 case STM_GETICON32:
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000291 return infoPtr->hIcon;
292
Alexandre Julliard491502b1997-11-01 19:08:16 +0000293 case STM_SETIMAGE:
294 /* FIXME: handle wParam */
295 lResult = STATIC_SetBitmap( wndPtr, (HBITMAP32)lParam );
296 InvalidateRect32( hWnd, NULL, FALSE );
297 UpdateWindow32( hWnd );
298 break;
Alexandre Julliarda0d77311998-09-13 16:32:00 +0000299
Alexandre Julliard491502b1997-11-01 19:08:16 +0000300 case STM_SETICON16:
301 case STM_SETICON32:
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000302 lResult = STATIC_SetIcon( wndPtr, (HICON16)wParam );
303 InvalidateRect32( hWnd, NULL, FALSE );
304 UpdateWindow32( hWnd );
305 break;
306
307 default:
308 lResult = DefWindowProc32A(hWnd, uMsg, wParam, lParam);
309 break;
310 }
311
312 return lResult;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000313}
314
315
Alexandre Julliard530ee841996-10-23 16:59:13 +0000316static void STATIC_PaintTextfn( WND *wndPtr, HDC32 hdc )
Alexandre Julliard0e607781993-11-03 19:23:37 +0000317{
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000318 RECT32 rc;
319 HBRUSH32 hBrush;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000320 WORD wFormat;
321
Alexandre Julliard0e607781993-11-03 19:23:37 +0000322 LONG style = wndPtr->dwStyle;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000323 STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000324
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000325 GetClientRect32( wndPtr->hwndSelf, &rc);
Alexandre Julliard0e607781993-11-03 19:23:37 +0000326
Alexandre Julliard491502b1997-11-01 19:08:16 +0000327 switch (style & SS_TYPEMASK)
Alexandre Julliard0e607781993-11-03 19:23:37 +0000328 {
329 case SS_LEFT:
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000330 wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000331 break;
332
333 case SS_CENTER:
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000334 wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000335 break;
336
337 case SS_RIGHT:
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000338 wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000339 break;
340
341 case SS_SIMPLE:
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000342 wFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOCLIP;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000343 break;
344
345 case SS_LEFTNOWORDWRAP:
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000346 wFormat = DT_LEFT | DT_SINGLELINE | DT_EXPANDTABS | DT_VCENTER | DT_NOCLIP;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000347 break;
Alexandre Julliard7cbe6571995-01-09 18:21:16 +0000348
349 default:
350 return;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000351 }
352
353 if (style & SS_NOPREFIX)
354 wFormat |= DT_NOPREFIX;
355
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000356 if (infoPtr->hFont) SelectObject32( hdc, infoPtr->hFont );
Alexandre Julliardd1ce8b21996-09-02 16:46:30 +0000357 hBrush = SendMessage32A( GetParent32(wndPtr->hwndSelf), WM_CTLCOLORSTATIC,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000358 hdc, wndPtr->hwndSelf );
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000359 if (!hBrush) hBrush = GetStockObject32(WHITE_BRUSH);
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000360 FillRect32( hdc, &rc, hBrush );
361 if (wndPtr->text) DrawText32A( hdc, wndPtr->text, -1, &rc, wFormat );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000362}
363
Alexandre Julliard530ee841996-10-23 16:59:13 +0000364static void STATIC_PaintRectfn( WND *wndPtr, HDC32 hdc )
Alexandre Julliard0e607781993-11-03 19:23:37 +0000365{
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000366 RECT32 rc;
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000367 HBRUSH32 hBrush;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000368
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000369 GetClientRect32( wndPtr->hwndSelf, &rc);
Alexandre Julliard0e607781993-11-03 19:23:37 +0000370
Alexandre Julliard491502b1997-11-01 19:08:16 +0000371 switch (wndPtr->dwStyle & SS_TYPEMASK)
Alexandre Julliard0e607781993-11-03 19:23:37 +0000372 {
373 case SS_BLACKRECT:
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000374 hBrush = CreateSolidBrush32(color_windowframe);
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000375 FillRect32( hdc, &rc, hBrush );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000376 break;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000377 case SS_GRAYRECT:
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000378 hBrush = CreateSolidBrush32(color_background);
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000379 FillRect32( hdc, &rc, hBrush );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000380 break;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000381 case SS_WHITERECT:
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000382 hBrush = CreateSolidBrush32(color_window);
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000383 FillRect32( hdc, &rc, hBrush );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000384 break;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000385 case SS_BLACKFRAME:
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000386 hBrush = CreateSolidBrush32(color_windowframe);
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000387 FrameRect32( hdc, &rc, hBrush );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000388 break;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000389 case SS_GRAYFRAME:
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000390 hBrush = CreateSolidBrush32(color_background);
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000391 FrameRect32( hdc, &rc, hBrush );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000392 break;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000393 case SS_WHITEFRAME:
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000394 hBrush = CreateSolidBrush32(color_window);
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000395 FrameRect32( hdc, &rc, hBrush );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000396 break;
Alexandre Julliard7cbe6571995-01-09 18:21:16 +0000397 default:
398 return;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000399 }
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000400 DeleteObject32( hBrush );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000401}
402
403
Alexandre Julliard530ee841996-10-23 16:59:13 +0000404static void STATIC_PaintIconfn( WND *wndPtr, HDC32 hdc )
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000405{
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000406 RECT32 rc;
407 HBRUSH32 hbrush;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000408 STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000409
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000410 GetClientRect32( wndPtr->hwndSelf, &rc );
Alexandre Julliardd1ce8b21996-09-02 16:46:30 +0000411 hbrush = SendMessage32A( GetParent32(wndPtr->hwndSelf), WM_CTLCOLORSTATIC,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000412 hdc, wndPtr->hwndSelf );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000413 FillRect32( hdc, &rc, hbrush );
414 if (infoPtr->hIcon) DrawIcon32( hdc, rc.left, rc.top, infoPtr->hIcon );
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000415}
Alexandre Julliard491502b1997-11-01 19:08:16 +0000416
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000417static void STATIC_PaintBitmapfn(WND *wndPtr, HDC32 hdc )
Alexandre Julliard491502b1997-11-01 19:08:16 +0000418{
419 RECT32 rc;
420 HBRUSH32 hbrush;
421 STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
422 HDC32 hMemDC;
423 HBITMAP32 oldbitmap;
424
425 GetClientRect32( wndPtr->hwndSelf, &rc );
426 hbrush = SendMessage32A( GetParent32(wndPtr->hwndSelf), WM_CTLCOLORSTATIC,
427 hdc, wndPtr->hwndSelf );
428 FillRect32( hdc, &rc, hbrush );
429 if (infoPtr->hIcon) {
430 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_HEAP_LOCK( infoPtr->hIcon );
431
432 if (!bmp) return;
433 if (!(hMemDC = CreateCompatibleDC32( hdc ))) return;
434
435 oldbitmap = SelectObject32(hMemDC,infoPtr->hIcon);
436 BitBlt32(hdc,bmp->size.cx,bmp->size.cy,bmp->bitmap.bmWidth,bmp->bitmap.bmHeight,hMemDC,0,0,SRCCOPY);
437 DeleteDC32(hMemDC);
438 GDI_HEAP_UNLOCK(infoPtr->hIcon);
439 }
440}
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000441
442
443static void STATIC_PaintEtchedfn( WND *wndPtr, HDC32 hdc )
444{
445 RECT32 rc;
446 HBRUSH32 hbrush;
447 HPEN32 hpen;
448
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000449 if (TWEAK_WineLook == WIN31_LOOK)
450 return;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000451
452 GetClientRect32( wndPtr->hwndSelf, &rc );
453 hbrush = SendMessage32A( GetParent32(wndPtr->hwndSelf), WM_CTLCOLORSTATIC,
454 hdc, wndPtr->hwndSelf );
455 FillRect32( hdc, &rc, hbrush );
456
457 switch (wndPtr->dwStyle & SS_TYPEMASK)
458 {
459 case SS_ETCHEDHORZ:
460 hpen = SelectObject32 (hdc, GetSysColorPen32 (COLOR_3DSHADOW));
461 MoveToEx32 (hdc, rc.left, rc.bottom / 2 - 1, NULL);
462 LineTo32 (hdc, rc.right - 1, rc.bottom / 2 - 1);
463 SelectObject32 (hdc, GetSysColorPen32 (COLOR_3DHIGHLIGHT));
464 MoveToEx32 (hdc, rc.left, rc.bottom / 2, NULL);
465 LineTo32 (hdc, rc.right, rc.bottom / 2);
466 LineTo32 (hdc, rc.right, rc.bottom / 2 - 1);
467 SelectObject32 (hdc, hpen);
468 break;
469
470 case SS_ETCHEDVERT:
471 hpen = SelectObject32 (hdc, GetSysColorPen32 (COLOR_3DSHADOW));
472 MoveToEx32 (hdc, rc.right / 2 - 1, rc.top, NULL);
473 LineTo32 (hdc, rc.right / 2 - 1, rc.bottom - 1);
474 SelectObject32 (hdc, GetSysColorPen32 (COLOR_3DHIGHLIGHT));
475 MoveToEx32 (hdc, rc.right / 2, rc.top, NULL);
476 LineTo32 (hdc, rc.right / 2, rc.bottom);
477 LineTo32 (hdc, rc.right / 2 -1 , rc.bottom);
478 SelectObject32 (hdc, hpen);
479 break;
480
481 case SS_ETCHEDFRAME:
482 DrawEdge32 (hdc, &rc, EDGE_ETCHED, BF_RECT);
483 break;
484 }
485}
486