| 1 | /* $Id: cvtcursorgrp.cpp,v 1.9 2000-03-13 13:10:09 sandervl Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * PE2LX cursor group code | 
|---|
| 5 | * | 
|---|
| 6 | * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl) | 
|---|
| 7 | * | 
|---|
| 8 | * | 
|---|
| 9 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 10 | * | 
|---|
| 11 | */ | 
|---|
| 12 | #define INCL_GPIBITMAPS | 
|---|
| 13 | #define INCL_BITMAPFILEFORMAT | 
|---|
| 14 | #define INCL_DOSFILEMGR          /* File Manager values      */ | 
|---|
| 15 | #define INCL_DOSERRORS           /* DOS Error values         */ | 
|---|
| 16 | #define INCL_DOSPROCESS          /* DOS Process values       */ | 
|---|
| 17 | #define INCL_DOSMISC             /* DOS Miscellanous values  */ | 
|---|
| 18 | #define INCL_WIN | 
|---|
| 19 | #include <os2wrap.h> | 
|---|
| 20 | #include <stdio.h> | 
|---|
| 21 | #include <string.h> | 
|---|
| 22 | #include <stdlib.h> | 
|---|
| 23 | #include <string.h> | 
|---|
| 24 | #include <win32type.h> | 
|---|
| 25 | #include <wincursor.h> | 
|---|
| 26 | #include <winres.h> | 
|---|
| 27 | #include <misc.h> | 
|---|
| 28 | #include "cvtresource.h" | 
|---|
| 29 |  | 
|---|
| 30 | #define DBG_LOCALLOG    DBG_cvtcursorgrp | 
|---|
| 31 | #include "dbglocal.h" | 
|---|
| 32 |  | 
|---|
| 33 | HRSRC WIN32API FindResourceA(HINSTANCE hModule, LPCSTR lpszName, LPCSTR lpszType); | 
|---|
| 34 |  | 
|---|
| 35 | //****************************************************************************** | 
|---|
| 36 | //****************************************************************************** | 
|---|
| 37 | void *ConvertCursorGroup(CursorHeader *chdr, int size, Win32ImageBase *module) | 
|---|
| 38 | { | 
|---|
| 39 | CursorResDir *rdir = (CursorResDir *)(chdr + 1); | 
|---|
| 40 | int i, groupsize = 0, os2cursorsize; | 
|---|
| 41 | BITMAPARRAYFILEHEADER2 *bafh, *orgbafh; | 
|---|
| 42 | CursorComponent       *cursorhdr; | 
|---|
| 43 | Win32Resource         *winres; | 
|---|
| 44 | void                  *os2cursor; | 
|---|
| 45 |  | 
|---|
| 46 | dprintf(("ConvertCursorGroup")); | 
|---|
| 47 | dprintf(("Cursor Group type : %d", chdr->wType)); | 
|---|
| 48 | dprintf(("Cursor Group count: %d", chdr->cwCount)); | 
|---|
| 49 | for(i=0;i<chdr->cwCount;i++) { | 
|---|
| 50 | dprintf2(("Cursor  : %d", rdir->wNameOrdinal)); | 
|---|
| 51 | dprintf2(("Width   : %d", (int)rdir->wWidth)); | 
|---|
| 52 | dprintf2(("Height  : %d", (int)rdir->wHeight)); | 
|---|
| 53 | dprintf2(("Bits    : %d", rdir->wBitCount)); | 
|---|
| 54 | dprintf2(("ResBytes: %d", rdir->lBytesInRes)); | 
|---|
| 55 | winres     = (Win32Resource *)FindResourceA(module->getInstanceHandle(), | 
|---|
| 56 | (LPCSTR)rdir->wNameOrdinal, | 
|---|
| 57 | (LPSTR)NTRT_CURSOR); | 
|---|
| 58 | groupsize += winres->getOS2Size(); | 
|---|
| 59 | rdir++; | 
|---|
| 60 | } | 
|---|
| 61 | bafh    = (BITMAPARRAYFILEHEADER2 *)malloc(groupsize+chdr->cwCount*sizeof(BITMAPARRAYFILEHEADER2)); | 
|---|
| 62 | orgbafh = bafh; | 
|---|
| 63 |  | 
|---|
| 64 | rdir = (CursorResDir *)(chdr + 1); | 
|---|
| 65 | for(i=0;i<chdr->cwCount;i++) { | 
|---|
| 66 | bafh->usType    = BFT_BITMAPARRAY; | 
|---|
| 67 | bafh->cbSize    = sizeof(BITMAPARRAYFILEHEADER2); | 
|---|
| 68 | bafh->cxDisplay = 0; | 
|---|
| 69 | bafh->cyDisplay = 0; | 
|---|
| 70 | winres          = (Win32Resource *)FindResourceA(module->getInstanceHandle(), | 
|---|
| 71 | (LPCSTR)rdir->wNameOrdinal, | 
|---|
| 72 | (LPSTR)NTRT_CURSOR); | 
|---|
| 73 | if(winres == NULL) { | 
|---|
| 74 | dprintf(("Can't find cursor!")); | 
|---|
| 75 | rdir++; | 
|---|
| 76 | continue; | 
|---|
| 77 | } | 
|---|
| 78 |  | 
|---|
| 79 | cursorhdr = (CursorComponent *)winres->lockResource(); | 
|---|
| 80 | os2cursor = ConvertCursor(cursorhdr, winres->getSize(), &os2cursorsize, (int)bafh - (int)orgbafh + sizeof(BITMAPARRAYFILEHEADER2)-sizeof(BITMAPFILEHEADER2)); | 
|---|
| 81 |  | 
|---|
| 82 | if(os2cursor == NULL) { | 
|---|
| 83 | dprintf(("Can't convert cursor!")); | 
|---|
| 84 | delete winres; | 
|---|
| 85 | rdir++; | 
|---|
| 86 | continue; | 
|---|
| 87 | } | 
|---|
| 88 |  | 
|---|
| 89 | if(i != chdr->cwCount -1) { | 
|---|
| 90 | bafh->offNext = (int)&bafh->bfh2 - (int)orgbafh + os2cursorsize; | 
|---|
| 91 | } | 
|---|
| 92 | else    bafh->offNext = 0; | 
|---|
| 93 |  | 
|---|
| 94 | memcpy((char *)&bafh->bfh2, os2cursor, os2cursorsize); | 
|---|
| 95 | free(os2cursor); | 
|---|
| 96 |  | 
|---|
| 97 | bafh = (BITMAPARRAYFILEHEADER2 *)((int)&bafh->bfh2 + os2cursorsize); | 
|---|
| 98 | delete winres; | 
|---|
| 99 |  | 
|---|
| 100 | rdir++; | 
|---|
| 101 | } | 
|---|
| 102 | return (void *)orgbafh; | 
|---|
| 103 | } | 
|---|
| 104 | //****************************************************************************** | 
|---|
| 105 | //****************************************************************************** | 
|---|