| 1 | /* $Id: cvtcursorgrp.cpp,v 1.1 1999-08-19 19:51:00 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 <os2.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 | HRSRC WIN32API FindResourceA(HINSTANCE hModule, LPCSTR lpszName, LPCSTR lpszType);
|
|---|
| 31 |
|
|---|
| 32 | //******************************************************************************
|
|---|
| 33 | //******************************************************************************
|
|---|
| 34 | void *ConvertCursorGroup(CursorHeader *chdr, int size, Win32Image *module)
|
|---|
| 35 | {
|
|---|
| 36 | CursorResDir *rdir = (CursorResDir *)(chdr + 1);
|
|---|
| 37 | int i, groupsize = 0;
|
|---|
| 38 | BITMAPARRAYFILEHEADER *bafh, *orgbafh;
|
|---|
| 39 | CursorComponent *cursorhdr;
|
|---|
| 40 | Win32Resource *winres;
|
|---|
| 41 | void *os2cursor;
|
|---|
| 42 |
|
|---|
| 43 | dprintf(("ConvertCursorGroup"));
|
|---|
| 44 | dprintf(("Cursor Group type : %d", chdr->wType));
|
|---|
| 45 | dprintf(("Cursor Group count: %d", chdr->cwCount));
|
|---|
| 46 | for(i=0;i<chdr->cwCount;i++) {
|
|---|
| 47 | dprintf(("Cursor : %d", rdir->wNameOrdinal));
|
|---|
| 48 | dprintf(("Width : %d", (int)rdir->wWidth));
|
|---|
| 49 | dprintf(("Height : %d", (int)rdir->wHeight));
|
|---|
| 50 | dprintf(("Bits : %d", rdir->wBitCount));
|
|---|
| 51 | dprintf(("ResBytes: %d", rdir->lBytesInRes));
|
|---|
| 52 | groupsize += module->getResourceSizeA((LPSTR)rdir->wNameOrdinal, (LPSTR)NTRT_CURSOR);
|
|---|
| 53 | rdir++;
|
|---|
| 54 | }
|
|---|
| 55 | bafh = (BITMAPARRAYFILEHEADER *)malloc(groupsize+chdr->cwCount*sizeof(BITMAPARRAYFILEHEADER));
|
|---|
| 56 | orgbafh = bafh;
|
|---|
| 57 |
|
|---|
| 58 | rdir = (CursorResDir *)(chdr + 1);
|
|---|
| 59 | for(i=0;i<chdr->cwCount;i++) {
|
|---|
| 60 | bafh->usType = BFT_BITMAPARRAY;
|
|---|
| 61 | bafh->cbSize = sizeof(BITMAPARRAYFILEHEADER);
|
|---|
| 62 | bafh->cxDisplay = 0;
|
|---|
| 63 | bafh->cyDisplay = 0;
|
|---|
| 64 | winres = (Win32Resource *)FindResourceA(module->getInstanceHandle(),
|
|---|
| 65 | (LPCSTR)rdir->wNameOrdinal,
|
|---|
| 66 | (LPSTR)NTRT_CURSOR);
|
|---|
| 67 | if(winres == NULL) {
|
|---|
| 68 | dprintf(("Can't find cursor!"));
|
|---|
| 69 | rdir++;
|
|---|
| 70 | continue;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | if(i != chdr->cwCount -1) {
|
|---|
| 74 | bafh->offNext = (int)&bafh->bfh - (int)orgbafh + winres->getSize();
|
|---|
| 75 | }
|
|---|
| 76 | else bafh->offNext = 0;
|
|---|
| 77 |
|
|---|
| 78 | cursorhdr = (CursorComponent *)winres->lockResource();
|
|---|
| 79 | os2cursor = ConvertCursor(cursorhdr, winres->getSize(), (int)bafh - (int)orgbafh + sizeof(BITMAPARRAYFILEHEADER)-sizeof(BITMAPFILEHEADER));
|
|---|
| 80 |
|
|---|
| 81 | if(os2cursor == NULL) {
|
|---|
| 82 | dprintf(("Can't convert cursor!"));
|
|---|
| 83 | delete winres;
|
|---|
| 84 | rdir++;
|
|---|
| 85 | continue;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | memcpy((char *)&bafh->bfh, os2cursor, winres->getSize());
|
|---|
| 89 | free(os2cursor);
|
|---|
| 90 |
|
|---|
| 91 | bafh = (BITMAPARRAYFILEHEADER *)((int)&bafh->bfh + winres->getSize());
|
|---|
| 92 | delete winres;
|
|---|
| 93 |
|
|---|
| 94 | rdir++;
|
|---|
| 95 | }
|
|---|
| 96 | return (void *)orgbafh;
|
|---|
| 97 | }
|
|---|
| 98 | //******************************************************************************
|
|---|
| 99 | //******************************************************************************
|
|---|