| 1 | /* $Id: cvtcursorgrp.cpp,v 1.10 2000-05-28 16:45:12 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 <win32api.h>
|
|---|
| 26 | #include <winconst.h>
|
|---|
| 27 | #include <wincursor.h>
|
|---|
| 28 | #include <misc.h>
|
|---|
| 29 | #include "cvtresource.h"
|
|---|
| 30 | #include <winres.h>
|
|---|
| 31 |
|
|---|
| 32 | #define DBG_LOCALLOG DBG_cvtcursorgrp
|
|---|
| 33 | #include "dbglocal.h"
|
|---|
| 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 | void *os2cursor;
|
|---|
| 44 | HRSRC hRes;
|
|---|
| 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 | hRes = FindResourceA(module->getInstanceHandle(),
|
|---|
| 56 | (LPCSTR)rdir->wNameOrdinal, (LPSTR)NTRT_CURSOR);
|
|---|
| 57 |
|
|---|
| 58 | groupsize += QueryConvertedResourceSize(module->getInstanceHandle(), (char *)NTRT_CURSOR, hRes);
|
|---|
| 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 | hRes = FindResourceA(module->getInstanceHandle(),
|
|---|
| 71 | (LPCSTR)rdir->wNameOrdinal, (LPSTR)NTRT_CURSOR);
|
|---|
| 72 |
|
|---|
| 73 | if(hRes == NULL) {
|
|---|
| 74 | dprintf(("Can't find cursor!"));
|
|---|
| 75 | rdir++;
|
|---|
| 76 | continue;
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | cursorhdr = (CursorComponent *)LockResource(LoadResource(module->getInstanceHandle(), hRes));
|
|---|
| 80 | os2cursor = ConvertCursor(cursorhdr, SizeofResource(module->getInstanceHandle(), hRes), &os2cursorsize, (int)bafh - (int)orgbafh + sizeof(BITMAPARRAYFILEHEADER2)-sizeof(BITMAPFILEHEADER2));
|
|---|
| 81 |
|
|---|
| 82 | if(os2cursor == NULL) {
|
|---|
| 83 | dprintf(("Can't convert cursor!"));
|
|---|
| 84 | rdir++;
|
|---|
| 85 | continue;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | if(i != chdr->cwCount -1) {
|
|---|
| 89 | bafh->offNext = (int)&bafh->bfh2 - (int)orgbafh + os2cursorsize;
|
|---|
| 90 | }
|
|---|
| 91 | else bafh->offNext = 0;
|
|---|
| 92 |
|
|---|
| 93 | memcpy((char *)&bafh->bfh2, os2cursor, os2cursorsize);
|
|---|
| 94 | free(os2cursor);
|
|---|
| 95 |
|
|---|
| 96 | bafh = (BITMAPARRAYFILEHEADER2 *)((int)&bafh->bfh2 + os2cursorsize);
|
|---|
| 97 |
|
|---|
| 98 | rdir++;
|
|---|
| 99 | }
|
|---|
| 100 | return (void *)orgbafh;
|
|---|
| 101 | }
|
|---|
| 102 | //******************************************************************************
|
|---|
| 103 | //******************************************************************************
|
|---|