GetSystemPaletteEntries returns palette size if entries==NULL.
[wine] / objects / oembitmap.c
1 /*
2  * GDI OEM bitmap objects
3  *
4  * Copyright 1994, 1995 Alexandre Julliard
5  *
6  */
7
8 #include <stdlib.h>
9 #include <string.h>
10 #include "ts_xlib.h"
11 #include "ts_xutil.h"
12 #include "ts_xpm.h"
13 #include "gdi.h"
14 #include "bitmap.h"
15 #include "callback.h"
16 #include "color.h"
17 #include "cursoricon.h"
18 #include "heap.h"
19 #include "tweak.h"
20 #include "debug.h"
21
22   /* Include OEM pixmaps */
23 #include "bitmaps/obm_cdrom"
24 #include "bitmaps/obm_harddisk"
25 #include "bitmaps/obm_drive"
26 #include "bitmaps/obm_folder2"
27 #include "bitmaps/obm_folder"
28 #include "bitmaps/obm_lfarrowi"
29 #include "bitmaps/obm_rgarrowi"
30 #include "bitmaps/obm_dnarrowi"
31 #include "bitmaps/obm_uparrowi"
32 #include "bitmaps/obm_combo"
33 #include "bitmaps/obm_mnarrow"
34 #include "bitmaps/obm_lfarrowd"
35 #include "bitmaps/obm_rgarrowd"
36 #include "bitmaps/obm_dnarrowd"
37 #include "bitmaps/obm_uparrowd"
38 #include "bitmaps/obm_restored"
39 #include "bitmaps/obm_restore"
40 #include "bitmaps/obm_lfarrow"
41 #include "bitmaps/obm_rgarrow"
42 #include "bitmaps/obm_dnarrow"
43 #include "bitmaps/obm_uparrow"
44 #include "bitmaps/obm_old_restore"
45 #include "bitmaps/obm_old_zoom"
46 #include "bitmaps/obm_old_reduce"
47 #include "bitmaps/obm_btncorners"
48 #include "bitmaps/obm_checkboxes"
49 #include "bitmaps/obm_check"
50 #include "bitmaps/obm_btsize"
51 #include "bitmaps/obm_old_lfarrow"
52 #include "bitmaps/obm_old_rgarrow"
53 #include "bitmaps/obm_old_dnarrow"
54 #include "bitmaps/obm_old_uparrow"
55 #include "bitmaps/obm_size"
56 #include "bitmaps/obm_old_close"
57 #include "bitmaps/obm_trtype"
58 #include "bitmaps/obm_radiocheck"
59
60 #include "bitmaps/obm_zoomd"
61 #include "bitmaps/obm_reduced"
62 #include "bitmaps/obm_zoom"
63 #include "bitmaps/obm_reduce"
64 #include "bitmaps/obm_close"
65 #include "bitmaps/obm_zoomd_95"
66 #include "bitmaps/obm_reduced_95"
67 #include "bitmaps/obm_zoom_95"
68 #include "bitmaps/obm_reduce_95"
69 #include "bitmaps/obm_close_95"
70 #include "bitmaps/obm_closed_95"
71 #include "bitmaps/obm_restore_95"
72 #include "bitmaps/obm_restored_95"
73
74
75 #define OBM_FIRST  OBM_RADIOCHECK  /* First OEM bitmap */
76 #define OBM_LAST   OBM_OLD_CLOSE   /* Last OEM bitmap */
77
78 static struct
79 {
80     char** data;   /* Pointer to bitmap data */
81     BOOL32 color;  /* Is it a color bitmap?  */
82 } OBM_Pixmaps_Data[OBM_LAST-OBM_FIRST+1] = {
83     { obm_radiocheck, FALSE },  /* OBM_RADIOCHECK */
84     { obm_trtype, TRUE },       /* OBM_TRTYPE */    
85     { obm_cdrom, TRUE },        /* OBM_CDROM    */
86     { obm_harddisk, TRUE },     /* OBM_HARDDISK */
87     { obm_drive, TRUE },        /* OBM_DRIVE    */
88     { obm_folder2, TRUE },      /* OBM_FOLDER2  */
89     { obm_folder, TRUE },       /* OBM_FOLDER   */
90     { obm_lfarrowi, TRUE },     /* OBM_LFARROWI */
91     { obm_rgarrowi, TRUE },     /* OBM_RGARROWI */
92     { obm_dnarrowi, TRUE },     /* OBM_DNARROWI */
93     { obm_uparrowi, TRUE },     /* OBM_UPARROWI */
94     { obm_combo, FALSE },       /* OBM_COMBO */
95     { obm_mnarrow, FALSE },     /* OBM_MNARROW */
96     { obm_lfarrowd, TRUE },     /* OBM_LFARROWD */
97     { obm_rgarrowd, TRUE },     /* OBM_RGARROWD */
98     { obm_dnarrowd, TRUE },     /* OBM_DNARROWD */
99     { obm_uparrowd, TRUE },     /* OBM_UPARROWD */
100     { obm_restored, TRUE },     /* OBM_RESTORED */
101     { obm_zoomd, TRUE },        /* OBM_ZOOMD */
102     { obm_reduced, TRUE },      /* OBM_REDUCED */
103     { obm_restore, TRUE },      /* OBM_RESTORE */
104     { obm_zoom, TRUE },         /* OBM_ZOOM */
105     { obm_reduce, TRUE },       /* OBM_REDUCE */
106     { obm_lfarrow, TRUE },      /* OBM_LFARROW */
107     { obm_rgarrow, TRUE },      /* OBM_RGARROW */
108     { obm_dnarrow, TRUE },      /* OBM_DNARROW */
109     { obm_uparrow, TRUE },      /* OBM_UPARROW */
110     { obm_close, TRUE },        /* OBM_CLOSE */
111     { obm_old_restore, FALSE }, /* OBM_OLD_RESTORE */
112     { obm_old_zoom, FALSE },    /* OBM_OLD_ZOOM */
113     { obm_old_reduce, FALSE },  /* OBM_OLD_REDUCE */
114     { obm_btncorners, FALSE },  /* OBM_BTNCORNERS */
115     { obm_checkboxes, FALSE },  /* OBM_CHECKBOXES */
116     { obm_check, FALSE },       /* OBM_CHECK */
117     { obm_btsize, FALSE },      /* OBM_BTSIZE */
118     { obm_old_lfarrow, FALSE }, /* OBM_OLD_LFARROW */
119     { obm_old_rgarrow, FALSE }, /* OBM_OLD_RGARROW */
120     { obm_old_dnarrow, FALSE }, /* OBM_OLD_DNARROW */
121     { obm_old_uparrow, FALSE }, /* OBM_OLD_UPARROW */
122     { obm_size, FALSE },        /* OBM_SIZE */
123     { obm_old_close, FALSE },   /* OBM_OLD_CLOSE */
124 };
125
126
127   /* Include OEM icons */
128 #include "bitmaps/oic_sample"
129 #include "bitmaps/oic_hand"
130 #include "bitmaps/oic_ques"
131 #include "bitmaps/oic_bang"
132 #include "bitmaps/oic_note"
133 #include "bitmaps/oic_portrait"
134 #include "bitmaps/oic_landscape"
135 #include "bitmaps/oic_wineicon"
136 #include "bitmaps/oic_hand_95"
137 #include "bitmaps/oic_ques_95"
138 #include "bitmaps/oic_bang_95"
139 #include "bitmaps/oic_note_95"
140
141 #define OIC_FIRST  OIC_SAMPLE      /* First OEM icon */
142 #define OIC_LAST   OIC_WINEICON   /* Last OEM icon */
143
144 static char **OBM_Icons_Data[OIC_LAST-OIC_FIRST+1] =
145 {
146     oic_sample,    /* OIC_SAMPLE */
147     oic_hand,      /* OIC_HAND */
148     oic_ques,      /* OIC_QUES */
149     oic_bang,      /* OIC_BANG */
150     oic_note,      /* OIC_NOTE */
151     oic_portrait,  /* OIC_PORTRAIT */
152     oic_landscape, /* OIC_LANDSCAPE */
153     oic_wineicon   /* OIC_WINEICON */
154 };
155
156
157   /* Include OEM cursors */
158 #include "bitmaps/ocr_normal"
159 #include "bitmaps/ocr_ibeam"
160 #include "bitmaps/ocr_wait"
161 #include "bitmaps/ocr_cross"
162 #include "bitmaps/ocr_up"
163 #include "bitmaps/ocr_size"
164 #include "bitmaps/ocr_icon"
165 #include "bitmaps/ocr_sizenwse"
166 #include "bitmaps/ocr_sizenesw"
167 #include "bitmaps/ocr_sizewe"
168 #include "bitmaps/ocr_sizens"
169 #include "bitmaps/ocr_bummer"
170 #include "bitmaps/ocr_dragobject"
171 /*#include "bitmaps/ocr_sizeall"*/
172 /*#include "bitmaps/ocr_icocur"*/
173 #include "bitmaps/ocr_no"
174 #include "bitmaps/ocr_appstarting"
175 #include "bitmaps/ocr_help"
176
177 /* Cursor are not all contiguous (go figure...) */
178 #define OCR_FIRST0 OCR_BUMMER
179 #define OCR_LAST0  OCR_DRAGOBJECT
180 #define OCR_BASE0       0
181
182 #define OCR_FIRST1 OCR_NORMAL
183 #define OCR_LAST1  OCR_UP
184 #define OCR_BASE1       (OCR_BASE0 + OCR_LAST0 - OCR_FIRST0 + 1)
185
186 #define OCR_FIRST2 OCR_SIZE
187 #define OCR_LAST2  OCR_SIZENS 
188 #define OCR_BASE2       (OCR_BASE1 + OCR_LAST1 - OCR_FIRST1 + 1)
189
190 #define OCR_FIRST3 OCR_NO
191 #define OCR_LAST3  OCR_NO
192 #define OCR_BASE3       (OCR_BASE2 + OCR_LAST2 - OCR_FIRST2 + 1)
193
194 #define OCR_FIRST4 OCR_APPSTARTING
195 #define OCR_LAST4  OCR_APPSTARTING
196 #define OCR_BASE4       (OCR_BASE3 + OCR_LAST3 - OCR_FIRST3 + 1)
197
198 #define OCR_FIRST5 OCR_HELP
199 #define OCR_LAST5  OCR_HELP
200 #define OCR_BASE5       (OCR_BASE4 + OCR_LAST4 - OCR_FIRST4 + 1)
201
202 #define NB_CURSORS (OCR_BASE5 + OCR_LAST5 - OCR_FIRST5 + 1)
203 static char **OBM_Cursors_Data[NB_CURSORS] = 
204 {
205     ocr_bummer,      /* OCR_BUMMER */
206     ocr_dragobject,  /* OCR_DRAGOBJECT */ 
207     ocr_normal,      /* OCR_NORMAL */
208     ocr_ibeam,       /* OCR_IBEAM */
209     ocr_wait,        /* OCR_WAIT */
210     ocr_cross,       /* OCR_CROSS */
211     ocr_up,          /* OCR_UP */
212     ocr_size,        /* OCR_SIZE */
213     ocr_icon,        /* OCR_ICON */
214     ocr_sizenwse,    /* OCR_SIZENWSE */
215     ocr_sizenesw,    /* OCR_SIZENESW */
216     ocr_sizewe,      /* OCR_SIZEWE */
217     ocr_sizens,      /* OCR_SIZENS */
218 #if 0
219     ocr_sizeall,     /* OCR_SIZEALL */
220     ocr_icocur       /* OCR_ICOCUR */
221 #endif
222     ocr_no,          /* OCR_NO */
223     ocr_appstarting, /* OCR_APPSTARTING */
224     ocr_help         /* OCR_HELP */
225 };
226
227 static HGLOBAL16 OBM_Cursors[NB_CURSORS];
228
229
230   /* All the colors used in the xpm files must be included in this   */
231   /* list, to make sure that the loaded bitmaps only use colors from */
232   /* the Windows colormap. Note: the PALETTEINDEX() are not really   */
233   /* palette indexes, but system colors that will be converted to    */
234   /* indexes later on.                                               */
235
236 #if 0
237 static const struct
238 {
239     char *   name;
240     COLORREF color;
241 } OBM_SymbolicColors[] =
242 #endif
243 static XpmColorSymbol OBM_Colors[] =
244 {
245     { "black",            NULL, (Pixel)RGB(0,0,0) },
246     { "white",            NULL, (Pixel)RGB(255,255,255) },
247     { "red",              NULL, (Pixel)RGB(255,0,0) },
248     { "green",            NULL, (Pixel)RGB(0,255,0) },
249     { "blue",             NULL, (Pixel)RGB(0,0,255) },
250     { "yellow",           NULL, (Pixel)RGB(255,255,0) },
251     { "cyan",             NULL, (Pixel)RGB(0,255,255) },    
252     { "dkyellow",         NULL, (Pixel)RGB(128,128,0) },
253     { "purple",           NULL, (Pixel)RGB(128,0,128) },
254     { "ltgray",           NULL, (Pixel)RGB(192,192,192) },
255     { "dkgray",           NULL, (Pixel)RGB(128,128,128) },
256     { "foldercol",        NULL, (Pixel)RGB(0,191,191) },
257     { "button_face",      NULL, (Pixel)PALETTEINDEX(COLOR_BTNFACE) },
258     { "button_shadow",    NULL, (Pixel)PALETTEINDEX(COLOR_BTNSHADOW) },
259     { "button_highlight", NULL, (Pixel)PALETTEINDEX(COLOR_BTNHIGHLIGHT) },
260     { "button_edge",      NULL, (Pixel)PALETTEINDEX(COLOR_BTNHIGHLIGHT) },
261     { "button_text",      NULL, (Pixel)PALETTEINDEX(COLOR_BTNTEXT) },
262     { "window_frame",     NULL, (Pixel)PALETTEINDEX(COLOR_WINDOWFRAME) }
263 };
264
265 #define NB_COLOR_SYMBOLS (sizeof(OBM_Colors)/sizeof(OBM_Colors[0]))
266
267   /* These are the symbolic colors for monochrome bitmaps   */
268   /* This is needed to make sure that black is always 0 and */
269   /* white always 1, as required by Windows.                */
270
271 static XpmColorSymbol OBM_BlackAndWhite[2] =
272 {
273     { "black", NULL, 0 },
274     { "white", NULL, 0xffffffff }
275 };
276
277 /* This structure holds the arguments for OBM_CreateBitmaps() */
278 typedef struct
279 {
280     char     **data;      /* In: bitmap data */
281     BOOL32     color;     /* In: color or monochrome */
282     BOOL32     need_mask; /* In: do we need a mask? */
283     HBITMAP16  bitmap;    /* Out: resulting bitmap */
284     HBITMAP16  mask;      /* Out: resulting mask (if needed) */
285     POINT32    hotspot;   /* Out: bitmap hotspot */
286 } OBM_BITMAP_DESCR;
287
288
289 /***********************************************************************
290  *           OBM_InitColorSymbols
291  */
292 static BOOL32 OBM_InitColorSymbols()
293 {
294     static BOOL32 initialized = FALSE;
295     int i;
296
297     if (initialized) return TRUE;  /* Already initialised */
298     initialized = TRUE;
299
300     for (i = 0; i < NB_COLOR_SYMBOLS; i++)
301     {
302         if (OBM_Colors[i].pixel & 0xff000000)  /* PALETTEINDEX */
303             OBM_Colors[i].pixel = COLOR_ToPhysical( NULL,
304                                     GetSysColor32(OBM_Colors[i].pixel & 0xff));
305         else  /* RGB*/
306             OBM_Colors[i].pixel = COLOR_ToPhysical( NULL, OBM_Colors[i].pixel);
307     }
308     return TRUE;
309 }
310
311
312 /***********************************************************************
313  *           OBM_MakeBitmap
314  *
315  * Allocate a GDI bitmap.
316  */
317 static HBITMAP16 OBM_MakeBitmap( WORD width, WORD height,
318                                  WORD bpp, Pixmap pixmap )
319 {
320     HBITMAP16 hbitmap;
321     BITMAPOBJ * bmpObjPtr;
322     X11DRV_PHYSBITMAP *pbitmap;
323
324     if (!pixmap) return 0;
325
326     hbitmap = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC );
327     if (!hbitmap) return 0;
328
329     bmpObjPtr = (BITMAPOBJ *) GDI_HEAP_LOCK( hbitmap );
330     bmpObjPtr->size.cx = width;
331     bmpObjPtr->size.cy = height;
332     bmpObjPtr->bitmap.bmType       = 0;
333     bmpObjPtr->bitmap.bmWidth      = width;
334     bmpObjPtr->bitmap.bmHeight     = height;
335     bmpObjPtr->bitmap.bmWidthBytes = BITMAP_GetWidthBytes( width, bpp );
336     bmpObjPtr->bitmap.bmPlanes     = 1;
337     bmpObjPtr->bitmap.bmBitsPixel  = bpp;
338     bmpObjPtr->bitmap.bmBits       = NULL;
339     bmpObjPtr->dib                 = NULL;
340
341     pbitmap = X11DRV_AllocBitmap(bmpObjPtr);
342
343     pbitmap->pixmap  = pixmap;
344
345     GDI_HEAP_UNLOCK( hbitmap );
346     return hbitmap;
347 }
348
349
350 /***********************************************************************
351  *           OBM_CreateBitmaps
352  *
353  * Create the 2 bitmaps from XPM data.
354  *
355  * The Xlib critical section must be entered before calling this function.
356  */
357 static BOOL32 OBM_CreateBitmaps( OBM_BITMAP_DESCR *descr )
358 {
359     Pixmap pixmap, pixmask;
360     XpmAttributes *attrs;
361     int err;
362
363     attrs = (XpmAttributes *)HEAP_xalloc( GetProcessHeap(), 0,
364                                           XpmAttributesSize() );
365     attrs->valuemask    = XpmColormap | XpmDepth | XpmColorSymbols |XpmHotspot;
366     attrs->colormap     = COLOR_GetColormap();
367     attrs->depth        = descr->color ? screenDepth : 1;
368     attrs->colorsymbols = (attrs->depth > 1) ? OBM_Colors : OBM_BlackAndWhite;
369     attrs->numsymbols   = (attrs->depth > 1) ? NB_COLOR_SYMBOLS : 2;
370         
371     err = XpmCreatePixmapFromData( display, rootWindow, descr->data,
372                                    &pixmap, &pixmask, attrs );
373
374     if (err != XpmSuccess)
375     {
376         HeapFree( GetProcessHeap(), 0, attrs );
377         return FALSE;
378     }
379     descr->hotspot.x = attrs->x_hotspot;
380     descr->hotspot.y = attrs->y_hotspot;
381     descr->bitmap = OBM_MakeBitmap( attrs->width, attrs->height,
382                                     attrs->depth, pixmap );
383     if (descr->need_mask)
384         descr->mask = OBM_MakeBitmap( attrs->width, attrs->height,
385                                       1, pixmask );
386     HeapFree( GetProcessHeap(), 0, attrs );
387     if (!descr->bitmap)
388     {
389         if (pixmap) XFreePixmap( display, pixmap );
390         if (pixmask) XFreePixmap( display, pixmask );
391         if (descr->bitmap) GDI_FreeObject( descr->bitmap );
392         if (descr->need_mask && descr->mask) GDI_FreeObject( descr->mask );
393         return FALSE;
394     }
395     else return TRUE;
396 }
397
398
399 /***********************************************************************
400  *           OBM_LoadBitmap
401  */
402 HBITMAP16 OBM_LoadBitmap( WORD id )
403 {
404     OBM_BITMAP_DESCR descr;
405
406     if ((id < OBM_FIRST) || (id > OBM_LAST)) return 0;
407     id -= OBM_FIRST;
408
409     if (!OBM_InitColorSymbols()) return 0;
410
411     descr.data      = OBM_Pixmaps_Data[id].data;
412     descr.color     = OBM_Pixmaps_Data[id].color;
413     descr.need_mask = FALSE;
414
415     EnterCriticalSection( &X11DRV_CritSection );
416     if (!CALL_LARGE_STACK( OBM_CreateBitmaps, &descr ))
417     {
418         LeaveCriticalSection( &X11DRV_CritSection );
419         WARN(bitmap, "Error creating OEM bitmap %d\n", OBM_FIRST+id );
420         return 0;
421     }
422     LeaveCriticalSection( &X11DRV_CritSection );
423     return descr.bitmap;
424 }
425
426
427 /***********************************************************************
428  *           OBM_LoadCursorIcon
429  */
430 HGLOBAL16 OBM_LoadCursorIcon( WORD id, BOOL32 fCursor )
431 {
432     OBM_BITMAP_DESCR descr;
433     HGLOBAL16 handle;
434     CURSORICONINFO *pInfo;
435     BITMAPOBJ *bmpXor, *bmpAnd;
436     int sizeXor, sizeAnd;
437
438     if (fCursor)
439     {
440         if ((id >= OCR_FIRST1) && (id <= OCR_LAST1))
441              id = OCR_BASE1 + id - OCR_FIRST1;
442         else if ((id >= OCR_FIRST2) && (id <= OCR_LAST2))
443                   id = OCR_BASE2 + id - OCR_FIRST2;
444              else if ((id >= OCR_FIRST0) && (id <= OCR_LAST0))
445                        id = OCR_BASE0 + id - OCR_FIRST0;
446                   else if ((id >= OCR_FIRST3) && (id <= OCR_LAST3))
447                             id = OCR_BASE3 + id - OCR_FIRST3;
448                        else if ((id >= OCR_FIRST4) && (id <= OCR_LAST4))
449                                  id = OCR_BASE4 + id - OCR_FIRST4;
450                             else if ((id >= OCR_FIRST5) && (id <= OCR_LAST5))
451                                       id = OCR_BASE5 + id - OCR_FIRST5;
452         else return 0;
453         if (OBM_Cursors[id]) return OBM_Cursors[id];
454     }
455     else
456     {
457         if ((id < OIC_FIRST) || (id > OIC_LAST)) return 0;
458         id -= OIC_FIRST;
459     }
460
461     if (!OBM_InitColorSymbols()) return 0;
462     
463     descr.data      = fCursor ? OBM_Cursors_Data[id] : OBM_Icons_Data[id];
464     descr.color     = !fCursor;
465     descr.need_mask = TRUE;
466
467     EnterCriticalSection( &X11DRV_CritSection );
468     if (!CALL_LARGE_STACK( OBM_CreateBitmaps, &descr ))
469     {
470         LeaveCriticalSection( &X11DRV_CritSection );
471         WARN(cursor, "Error creating OEM cursor/icon %d\n", id );
472         return 0;
473     }
474     LeaveCriticalSection( &X11DRV_CritSection );
475
476     bmpXor = (BITMAPOBJ *) GDI_GetObjPtr( descr.bitmap, BITMAP_MAGIC );
477     bmpAnd = (BITMAPOBJ *) GDI_GetObjPtr( descr.mask, BITMAP_MAGIC );
478     sizeXor = bmpXor->bitmap.bmHeight * bmpXor->bitmap.bmWidthBytes;
479     sizeAnd = bmpXor->bitmap.bmHeight * 
480                         BITMAP_GetWidthBytes( bmpXor->bitmap.bmWidth, 1 );
481
482     if (!(handle = GlobalAlloc16( GMEM_MOVEABLE,
483                                   sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
484     {
485         DeleteObject32( descr.bitmap );
486         DeleteObject32( descr.mask );
487         return 0;
488     }
489
490     pInfo = (CURSORICONINFO *)GlobalLock16( handle );
491     pInfo->ptHotSpot.x   = descr.hotspot.x;
492     pInfo->ptHotSpot.y   = descr.hotspot.y;
493     pInfo->nWidth        = bmpXor->bitmap.bmWidth;
494     pInfo->nHeight       = bmpXor->bitmap.bmHeight;
495     pInfo->nWidthBytes   = bmpXor->bitmap.bmWidthBytes;
496     pInfo->bPlanes       = bmpXor->bitmap.bmPlanes;
497     pInfo->bBitsPerPixel = bmpXor->bitmap.bmBitsPixel;
498
499     if (descr.mask)
500     {
501         X11DRV_PHYSBITMAP *pbitmapAnd = bmpAnd->DDBitmap->physBitmap;
502           /* Invert the mask */
503
504         TSXSetFunction( display, BITMAP_monoGC, GXinvert );
505         TSXFillRectangle( display, pbitmapAnd->pixmap, BITMAP_monoGC, 0, 0,
506                         bmpAnd->bitmap.bmWidth, bmpAnd->bitmap.bmHeight );
507         TSXSetFunction( display, BITMAP_monoGC, GXcopy );
508
509           /* Set the masked pixels to black */
510
511         if (bmpXor->bitmap.bmBitsPixel != 1)
512         {
513             X11DRV_PHYSBITMAP *pbitmapXor = bmpXor->DDBitmap->physBitmap;
514             TSXSetForeground( display, BITMAP_colorGC,
515                             COLOR_ToPhysical( NULL, RGB(0,0,0) ));
516             TSXSetBackground( display, BITMAP_colorGC, 0 );
517             TSXSetFunction( display, BITMAP_colorGC, GXor );
518             TSXCopyPlane(display, pbitmapAnd->pixmap, pbitmapXor->pixmap, BITMAP_colorGC,
519                        0, 0, bmpXor->bitmap.bmWidth, bmpXor->bitmap.bmHeight,
520                        0, 0, 1 );
521             TSXSetFunction( display, BITMAP_colorGC, GXcopy );
522         }
523     }
524
525     if (descr.mask) GetBitmapBits32( descr.mask, sizeAnd, (char *)(pInfo + 1));
526     else memset( (char *)(pInfo + 1), 0xff, sizeAnd );
527     GetBitmapBits32( descr.bitmap, sizeXor, (char *)(pInfo + 1) + sizeAnd );
528
529     DeleteObject32( descr.bitmap );
530     DeleteObject32( descr.mask );
531
532     if (fCursor) OBM_Cursors[id] = handle;
533     return handle;
534 }
535
536
537 /***********************************************************************
538  *           OBM_Init
539  *
540  * Initializes the OBM_Pixmaps_Data and OBM_Icons_Data struct
541  */
542 BOOL32 OBM_Init()
543 {
544     if (TWEAK_WineLook == WIN31_LOOK) {
545         OBM_Pixmaps_Data[OBM_ZOOMD - OBM_FIRST].data = obm_zoomd;
546         OBM_Pixmaps_Data[OBM_REDUCED - OBM_FIRST].data = obm_reduced;
547         OBM_Pixmaps_Data[OBM_ZOOM - OBM_FIRST].data = obm_zoom;
548         OBM_Pixmaps_Data[OBM_REDUCE - OBM_FIRST].data = obm_reduce;
549         OBM_Pixmaps_Data[OBM_CLOSE - OBM_FIRST].data = obm_close;
550         OBM_Pixmaps_Data[OBM_RESTORE - OBM_FIRST].data = obm_restore;
551         OBM_Pixmaps_Data[OBM_RESTORED - OBM_FIRST].data = obm_restored;
552
553         OBM_Icons_Data[OIC_HAND - OIC_FIRST] = oic_hand;
554         OBM_Icons_Data[OIC_QUES - OIC_FIRST] = oic_ques;
555         OBM_Icons_Data[OIC_BANG - OIC_FIRST] = oic_bang;
556         OBM_Icons_Data[OIC_NOTE - OIC_FIRST] = oic_note;
557     }
558     else {
559         OBM_Pixmaps_Data[OBM_ZOOMD - OBM_FIRST].data = obm_zoomd_95;
560         OBM_Pixmaps_Data[OBM_REDUCED - OBM_FIRST].data = obm_reduced_95;
561         OBM_Pixmaps_Data[OBM_ZOOM - OBM_FIRST].data = obm_zoom_95;
562         OBM_Pixmaps_Data[OBM_REDUCE - OBM_FIRST].data = obm_reduce_95;
563         OBM_Pixmaps_Data[OBM_CLOSE - OBM_FIRST].data = obm_close_95;
564         OBM_Pixmaps_Data[OBM_RESTORE - OBM_FIRST].data = obm_restore_95;
565         OBM_Pixmaps_Data[OBM_RESTORED - OBM_FIRST].data = obm_restored_95;
566
567         OBM_Icons_Data[OIC_HAND - OIC_FIRST] = oic_hand_95;
568         OBM_Icons_Data[OIC_QUES - OIC_FIRST] = oic_ques_95;
569         OBM_Icons_Data[OIC_BANG - OIC_FIRST] = oic_bang_95;
570         OBM_Icons_Data[OIC_NOTE - OIC_FIRST] = oic_note_95;
571     }
572
573     return 1;
574 }