2 * X11DRV OEM bitmap objects
4 * Copyright 1994, 1995 Alexandre Julliard
15 #else /* defined(HAVE_LIBXXPM) */
16 typedef unsigned long Pixel;
17 #endif /* defined(HAVE_LIBXXPM) */
25 #include "wine/winuser16.h"
29 #include "cursoricon.h"
30 #include "debugtools.h"
33 #include "user.h" /* for TWEAK_WineLook (FIXME) */
36 /* Include OEM pixmaps */
37 #include "bitmaps/obm_lfarrowi"
38 #include "bitmaps/obm_rgarrowi"
39 #include "bitmaps/obm_dnarrowi"
40 #include "bitmaps/obm_uparrowi"
41 #include "bitmaps/obm_combo"
42 #include "bitmaps/obm_mnarrow"
43 #include "bitmaps/obm_lfarrowd"
44 #include "bitmaps/obm_rgarrowd"
45 #include "bitmaps/obm_dnarrowd"
46 #include "bitmaps/obm_uparrowd"
47 #include "bitmaps/obm_restored"
48 #include "bitmaps/obm_restore"
49 #include "bitmaps/obm_lfarrow"
50 #include "bitmaps/obm_rgarrow"
51 #include "bitmaps/obm_dnarrow"
52 #include "bitmaps/obm_uparrow"
53 #include "bitmaps/obm_old_restore"
54 #include "bitmaps/obm_old_zoom"
55 #include "bitmaps/obm_old_reduce"
56 #include "bitmaps/obm_btncorners"
57 #include "bitmaps/obm_checkboxes"
58 #include "bitmaps/obm_check"
59 #include "bitmaps/obm_btsize"
60 #include "bitmaps/obm_old_lfarrow"
61 #include "bitmaps/obm_old_rgarrow"
62 #include "bitmaps/obm_old_dnarrow"
63 #include "bitmaps/obm_old_uparrow"
64 #include "bitmaps/obm_size"
65 #include "bitmaps/obm_old_close"
66 #include "bitmaps/obm_trtype"
68 #include "bitmaps/obm_zoomd"
69 #include "bitmaps/obm_reduced"
70 #include "bitmaps/obm_zoom"
71 #include "bitmaps/obm_reduce"
72 #include "bitmaps/obm_close"
73 #include "bitmaps/obm_zoomd_95"
74 #include "bitmaps/obm_reduced_95"
75 #include "bitmaps/obm_zoom_95"
76 #include "bitmaps/obm_reduce_95"
77 #include "bitmaps/obm_close_95"
78 #include "bitmaps/obm_closed_95"
79 #include "bitmaps/obm_restore_95"
80 #include "bitmaps/obm_restored_95"
82 DECLARE_DEBUG_CHANNEL(bitmap);
83 DECLARE_DEBUG_CHANNEL(cursor);
84 DECLARE_DEBUG_CHANNEL(x11drv);
87 #define OBM_FIRST OBM_CLOSED /* First OEM bitmap */
88 #define OBM_LAST OBM_OLD_CLOSE /* Last OEM bitmap */
92 char** data; /* Pointer to bitmap data */
93 BOOL color; /* Is it a color bitmap? */
94 } OBM_Pixmaps_Data[OBM_LAST-OBM_FIRST+1] = {
95 { obm_closed_95,TRUE}, /* OBM_CLOSED */
96 { obm_trtype, TRUE }, /* OBM_TRTYPE */
97 { NULL, FALSE }, /* unused */
98 { obm_lfarrowi, TRUE }, /* OBM_LFARROWI */
99 { obm_rgarrowi, TRUE }, /* OBM_RGARROWI */
100 { obm_dnarrowi, TRUE }, /* OBM_DNARROWI */
101 { obm_uparrowi, TRUE }, /* OBM_UPARROWI */
102 { obm_combo, FALSE }, /* OBM_COMBO */
103 { obm_mnarrow, FALSE }, /* OBM_MNARROW */
104 { obm_lfarrowd, TRUE }, /* OBM_LFARROWD */
105 { obm_rgarrowd, TRUE }, /* OBM_RGARROWD */
106 { obm_dnarrowd, TRUE }, /* OBM_DNARROWD */
107 { obm_uparrowd, TRUE }, /* OBM_UPARROWD */
108 { obm_restored, TRUE }, /* OBM_RESTORED */
109 { obm_zoomd, TRUE }, /* OBM_ZOOMD */
110 { obm_reduced, TRUE }, /* OBM_REDUCED */
111 { obm_restore, TRUE }, /* OBM_RESTORE */
112 { obm_zoom, TRUE }, /* OBM_ZOOM */
113 { obm_reduce, TRUE }, /* OBM_REDUCE */
114 { obm_lfarrow, TRUE }, /* OBM_LFARROW */
115 { obm_rgarrow, TRUE }, /* OBM_RGARROW */
116 { obm_dnarrow, TRUE }, /* OBM_DNARROW */
117 { obm_uparrow, TRUE }, /* OBM_UPARROW */
118 { obm_close, TRUE }, /* OBM_CLOSE */
119 { obm_old_restore, FALSE }, /* OBM_OLD_RESTORE */
120 { obm_old_zoom, FALSE }, /* OBM_OLD_ZOOM */
121 { obm_old_reduce, FALSE }, /* OBM_OLD_REDUCE */
122 { obm_btncorners, FALSE }, /* OBM_BTNCORNERS */
123 { obm_checkboxes, FALSE }, /* OBM_CHECKBOXES */
124 { obm_check, FALSE }, /* OBM_CHECK */
125 { obm_btsize, FALSE }, /* OBM_BTSIZE */
126 { obm_old_lfarrow, FALSE }, /* OBM_OLD_LFARROW */
127 { obm_old_rgarrow, FALSE }, /* OBM_OLD_RGARROW */
128 { obm_old_dnarrow, FALSE }, /* OBM_OLD_DNARROW */
129 { obm_old_uparrow, FALSE }, /* OBM_OLD_UPARROW */
130 { obm_size, FALSE }, /* OBM_SIZE */
131 { obm_old_close, FALSE }, /* OBM_OLD_CLOSE */
135 /* All the colors used in the xpm files must be included in this */
136 /* list, to make sure that the loaded bitmaps only use colors from */
137 /* the Windows colormap. Note: the PALETTEINDEX() are not really */
138 /* palette indexes, but system colors that will be converted to */
139 /* indexes later on. */
142 static XpmColorSymbol
143 #else /* defined(HAVE_LIBXXPM) */
150 #endif /* defined(HAVE_LIBXXPM) */
153 { "black", NULL, (Pixel)RGB(0,0,0) },
154 { "white", NULL, (Pixel)RGB(255,255,255) },
155 { "red", NULL, (Pixel)RGB(255,0,0) },
156 { "green", NULL, (Pixel)RGB(0,255,0) },
157 { "blue", NULL, (Pixel)RGB(0,0,255) },
158 { "yellow", NULL, (Pixel)RGB(255,255,0) },
159 { "cyan", NULL, (Pixel)RGB(0,255,255) },
160 { "dkyellow", NULL, (Pixel)RGB(128,128,0) },
161 { "purple", NULL, (Pixel)RGB(128,0,128) },
162 { "ltgray", NULL, (Pixel)RGB(192,192,192) },
163 { "dkgray", NULL, (Pixel)RGB(128,128,128) },
164 { "button_face", NULL, (Pixel)PALETTEINDEX(COLOR_BTNFACE) },
165 { "button_shadow", NULL, (Pixel)PALETTEINDEX(COLOR_BTNSHADOW) },
166 { "button_highlight", NULL, (Pixel)PALETTEINDEX(COLOR_BTNHIGHLIGHT) },
167 { "button_edge", NULL, (Pixel)PALETTEINDEX(COLOR_BTNHIGHLIGHT) },
168 { "button_text", NULL, (Pixel)PALETTEINDEX(COLOR_BTNTEXT) },
169 { "window_frame", NULL, (Pixel)PALETTEINDEX(COLOR_WINDOWFRAME) }
172 #define NB_COLOR_SYMBOLS (sizeof(OBM_Colors)/sizeof(OBM_Colors[0]))
174 /* These are the symbolic colors for monochrome bitmaps */
175 /* This is needed to make sure that black is always 0 and */
176 /* white always 1, as required by Windows. */
179 static XpmColorSymbol OBM_BlackAndWhite[2] =
181 { "black", NULL, 0 },
182 { "white", NULL, 0xffffffff }
184 #endif /* defined(HAVE_LIBXXPM) */
188 /***********************************************************************
189 * OBM_InitColorSymbols
191 static BOOL OBM_InitColorSymbols()
193 static BOOL initialized = FALSE;
196 if (initialized) return TRUE; /* Already initialised */
199 for (i = 0; i < NB_COLOR_SYMBOLS; i++)
201 if (OBM_Colors[i].pixel & 0xff000000) /* PALETTEINDEX */
202 OBM_Colors[i].pixel = X11DRV_PALETTE_ToPhysical( NULL,
203 GetSysColor(OBM_Colors[i].pixel & 0xff));
205 OBM_Colors[i].pixel = X11DRV_PALETTE_ToPhysical( NULL, OBM_Colors[i].pixel);
211 /***********************************************************************
214 * Allocate a GDI bitmap.
217 static HBITMAP16 OBM_MakeBitmap( WORD width, WORD height,
218 WORD bpp, Pixmap pixmap )
221 BITMAPOBJ * bmpObjPtr;
223 if (!pixmap) return 0;
225 if (!(bmpObjPtr = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC, &hbitmap ))) return 0;
226 bmpObjPtr->size.cx = width;
227 bmpObjPtr->size.cy = height;
228 bmpObjPtr->bitmap.bmType = 0;
229 bmpObjPtr->bitmap.bmWidth = width;
230 bmpObjPtr->bitmap.bmHeight = height;
231 bmpObjPtr->bitmap.bmWidthBytes = BITMAP_GetWidthBytes( width, bpp );
232 bmpObjPtr->bitmap.bmPlanes = 1;
233 bmpObjPtr->bitmap.bmBitsPixel = bpp;
234 bmpObjPtr->bitmap.bmBits = NULL;
235 bmpObjPtr->dib = NULL;
237 bmpObjPtr->funcs = &X11DRV_DC_Funcs;
238 bmpObjPtr->physBitmap = (void *)pixmap;
240 GDI_ReleaseObj( hbitmap );
243 #endif /* defined(HAVE_LIBXXPM) */
246 /***********************************************************************
249 * Create the 2 bitmaps from XPM data.
251 static BOOL OBM_CreateBitmaps( char **data, BOOL color,
252 HBITMAP16 *bitmap, HBITMAP16 *mask, POINT *hotspot )
255 XpmAttributes *attrs;
256 Pixmap pixmap, pixmask;
259 attrs = (XpmAttributes *)HeapAlloc( GetProcessHeap(), 0, XpmAttributesSize() );
260 if (attrs == NULL) return FALSE;
261 attrs->valuemask = XpmColormap | XpmDepth | XpmColorSymbols | XpmHotspot;
262 attrs->colormap = X11DRV_PALETTE_PaletteXColormap;
263 attrs->depth = color ? screen_depth : 1;
264 attrs->colorsymbols = (attrs->depth > 1) ? OBM_Colors : OBM_BlackAndWhite;
265 attrs->numsymbols = (attrs->depth > 1) ? NB_COLOR_SYMBOLS : 2;
267 err = TSXpmCreatePixmapFromData( gdi_display, root_window, data, &pixmap, &pixmask, attrs );
268 if (err != XpmSuccess)
270 HeapFree( GetProcessHeap(), 0, attrs );
276 hotspot->x = attrs->x_hotspot;
277 hotspot->y = attrs->y_hotspot;
281 *bitmap = OBM_MakeBitmap( attrs->width, attrs->height,
282 attrs->depth, pixmap );
285 *mask = OBM_MakeBitmap( attrs->width, attrs->height,
288 HeapFree( GetProcessHeap(), 0, attrs );
290 if (pixmap && (!bitmap || !*bitmap)) TSXFreePixmap( gdi_display, pixmap );
291 if (pixmask && (!mask || !*mask)) TSXFreePixmap( gdi_display, pixmask );
293 if (bitmap && !*bitmap)
295 if (mask && *mask) DeleteObject( *mask );
299 #else /* defined(HAVE_LIBXXPM) */
301 "Xpm support not in the binary, "
302 "please install the Xpm and Xpm-devel packages and recompile\n"
305 #endif /* defined(HAVE_LIBXXPM) */
309 /***********************************************************************
312 static HBITMAP16 OBM_LoadBitmap( WORD id )
316 if ((id < OBM_FIRST) || (id > OBM_LAST)) return 0;
318 if (!OBM_Pixmaps_Data[id].data) return 0;
320 if (!OBM_InitColorSymbols()) return 0;
322 if (!OBM_CreateBitmaps( OBM_Pixmaps_Data[id].data, OBM_Pixmaps_Data[id].color,
323 &bitmap, NULL, NULL ))
325 WARN_(bitmap)("Error creating OEM bitmap %d\n", OBM_FIRST+id );
332 /***********************************************************************
333 * X11DRV_LoadOEMResource (X11DRV.@)
336 HANDLE X11DRV_LoadOEMResource(WORD resid, WORD type)
340 return OBM_LoadBitmap(resid);
343 ERR_(x11drv)("Unknown type\n");
349 /***********************************************************************
352 * Initializes the OBM_Pixmaps_Data and OBM_Icons_Data struct
354 BOOL X11DRV_OBM_Init(void)
356 if (TWEAK_WineLook == WIN31_LOOK) {
357 OBM_Pixmaps_Data[OBM_ZOOMD - OBM_FIRST].data = obm_zoomd;
358 OBM_Pixmaps_Data[OBM_REDUCED - OBM_FIRST].data = obm_reduced;
359 OBM_Pixmaps_Data[OBM_ZOOM - OBM_FIRST].data = obm_zoom;
360 OBM_Pixmaps_Data[OBM_REDUCE - OBM_FIRST].data = obm_reduce;
361 OBM_Pixmaps_Data[OBM_CLOSE - OBM_FIRST].data = obm_close;
362 OBM_Pixmaps_Data[OBM_RESTORE - OBM_FIRST].data = obm_restore;
363 OBM_Pixmaps_Data[OBM_RESTORED - OBM_FIRST].data = obm_restored;
366 OBM_Pixmaps_Data[OBM_ZOOMD - OBM_FIRST].data = obm_zoomd_95;
367 OBM_Pixmaps_Data[OBM_REDUCED - OBM_FIRST].data = obm_reduced_95;
368 OBM_Pixmaps_Data[OBM_ZOOM - OBM_FIRST].data = obm_zoom_95;
369 OBM_Pixmaps_Data[OBM_REDUCE - OBM_FIRST].data = obm_reduce_95;
370 OBM_Pixmaps_Data[OBM_CLOSE - OBM_FIRST].data = obm_close_95;
371 OBM_Pixmaps_Data[OBM_RESTORE - OBM_FIRST].data = obm_restore_95;
372 OBM_Pixmaps_Data[OBM_RESTORED - OBM_FIRST].data = obm_restored_95;