| 1 | /* $Id: icongrp.cpp,v 1.4 1999-07-20 17:50:19 sandervl Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * PE2LX Icon 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 <iostream.h> | 
|---|
| 24 | #include <string.h> | 
|---|
| 25 | #include "pefile.h" | 
|---|
| 26 | #include "lx.h" | 
|---|
| 27 | #include "icon.h" | 
|---|
| 28 | #include "icongrp.h" | 
|---|
| 29 | #include "misc.h" | 
|---|
| 30 |  | 
|---|
| 31 | //****************************************************************************** | 
|---|
| 32 | //****************************************************************************** | 
|---|
| 33 | #ifdef __WATCOMC__ | 
|---|
| 34 | #pragma off (unreferenced) | 
|---|
| 35 | #endif | 
|---|
| 36 | void ShowGroupIcon(int id, IconHeader *ihdr, int size) | 
|---|
| 37 | #ifdef __WATCOMC__ | 
|---|
| 38 | #pragma on (unreferenced) | 
|---|
| 39 | #endif | 
|---|
| 40 | { | 
|---|
| 41 | ResourceDirectory *rdir = (ResourceDirectory *)(ihdr + 1); | 
|---|
| 42 | int i, groupsize = 0; | 
|---|
| 43 | BITMAPARRAYFILEHEADER2 *bafh, *orgbafh; | 
|---|
| 44 | OS2Icon *icon; | 
|---|
| 45 |  | 
|---|
| 46 | cout << "Icon Group id   :" << id << endl; | 
|---|
| 47 | cout << "Icon Group type :" << ihdr->wType << endl; | 
|---|
| 48 | cout << "Icon Group count:" << ihdr->wCount << endl; | 
|---|
| 49 | for(i=0;i<ihdr->wCount;i++) { | 
|---|
| 50 | cout << "Icon    :" << rdir->wNameOrdinal << endl; | 
|---|
| 51 | cout << "Width   :" << (int)rdir->bWidth << endl; | 
|---|
| 52 | cout << "Height  :" << (int)rdir->bHeight << endl; | 
|---|
| 53 | cout << "Colors  :" << (int)rdir->bColorCount << endl; | 
|---|
| 54 | cout << "Bits    :" << rdir->wBitCount << endl; | 
|---|
| 55 | cout << "ResBytes:" << rdir->lBytesInRes << endl; | 
|---|
| 56 | icon       = OS2Icon::GetIcon(rdir->wNameOrdinal); | 
|---|
| 57 | if(icon) | 
|---|
| 58 | groupsize += icon->QueryIconSize(); | 
|---|
| 59 | rdir++; | 
|---|
| 60 | } | 
|---|
| 61 | bafh    = (BITMAPARRAYFILEHEADER2 *)malloc(groupsize+ihdr->wCount*sizeof(BITMAPARRAYFILEHEADER2)); | 
|---|
| 62 | orgbafh = bafh; | 
|---|
| 63 |  | 
|---|
| 64 | rdir = (ResourceDirectory *)(ihdr + 1); | 
|---|
| 65 | for(i=0;i<ihdr->wCount;i++) { | 
|---|
| 66 | bafh->usType    = BFT_BITMAPARRAY; | 
|---|
| 67 | bafh->cbSize    = sizeof(BITMAPARRAYFILEHEADER2); | 
|---|
| 68 | bafh->cxDisplay = 0; | 
|---|
| 69 | bafh->cyDisplay = 0; | 
|---|
| 70 | icon            = OS2Icon::GetIcon(rdir->wNameOrdinal); | 
|---|
| 71 | if(icon == NULL) { | 
|---|
| 72 | cout << "Can't find icon!" << endl; | 
|---|
| 73 | rdir++; | 
|---|
| 74 | continue; | 
|---|
| 75 | } | 
|---|
| 76 | if(i != ihdr->wCount -1) { | 
|---|
| 77 | bafh->offNext = (int)&bafh->bfh2 - (int)orgbafh + icon->QueryIconSize(); | 
|---|
| 78 | } | 
|---|
| 79 | else    bafh->offNext = 0; | 
|---|
| 80 |  | 
|---|
| 81 | icon->SetIconHdrOffset((int)bafh - (int)orgbafh + sizeof(BITMAPARRAYFILEHEADER2)-sizeof(BITMAPFILEHEADER2)); | 
|---|
| 82 |  | 
|---|
| 83 | memcpy((char *)&bafh->bfh2, (char *)icon->GetIconHeader(), icon->QueryIconSize()); | 
|---|
| 84 | bafh = (BITMAPARRAYFILEHEADER2 *)((int)&bafh->bfh2 + icon->QueryIconSize()); | 
|---|
| 85 | rdir++; | 
|---|
| 86 | } | 
|---|
| 87 | OS2Exe.StoreResource(id, RT_POINTER, groupsize+ihdr->wCount*sizeof(BITMAPARRAYFILEHEADER2), (char *)orgbafh); | 
|---|
| 88 | free((char *)orgbafh); | 
|---|
| 89 | } | 
|---|
| 90 | //****************************************************************************** | 
|---|
| 91 | //****************************************************************************** | 
|---|