Changeset 1454 for trunk/src


Ignore:
Timestamp:
Oct 26, 1999, 1:16:15 PM (26 years ago)
Author:
sandervl
Message:

(menu) resource changes

Location:
trunk/src/kernel32
Files:
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/KERNEL32.DEF

    r1440 r1454  
    1 ; $Id: KERNEL32.DEF,v 1.44 1999-10-25 18:20:52 achimha Exp $
     1; $Id: KERNEL32.DEF,v 1.45 1999-10-26 11:15:32 sandervl Exp $
    22
    33;Created by BLAST for IBM's compiler
     
    10241024    OS2UnsetExceptionHandler                                      @1254
    10251025
    1026     __ct__12Win32MenuResFP14Win32ImageBaseUlN22                   @1260
    1027     __ct__12Win32MenuResFP14Win32ImageBaseUlN22Pc                 @1261
    1028     __ct__12Win32MenuResFUl                                       @1262
    1029     __ct__12Win32MenuResFPv                                       @1263
    1030 
    10311026; Odin ini management
    10321027
  • trunk/src/kernel32/cvtresource.h

    r956 r1454  
    1 /* $Id: cvtresource.h,v 1.4 1999-09-15 23:38:01 sandervl Exp $ */
     1/* $Id: cvtresource.h,v 1.5 1999-10-26 11:15:33 sandervl Exp $ */
    22
    33#ifndef _CVTRESOURCE_H_
    44#define _CVTRESOURCE_H_
    55
    6 #include <winmenu.h>
    76#include <winicon.h>
    87#include <winaccel.h>
     
    1615void *ConvertIcon(WINBITMAPINFOHEADER *bmpHdr, int size, int *os2size, int offsetBits = 0);
    1716void *ConvertIconGroup(IconHeader *ihdr, int size, Win32ImageBase *module);
    18 void *ConvertMenu(MenuHeader *menu, int size, int cp = 0);
    1917
    2018ULONG QueryConvertedBitmapSize(WINBITMAPINFOHEADER *pBHdr, ULONG ulSize);
  • trunk/src/kernel32/makefile

    r1432 r1454  
    1 # $Id: makefile,v 1.46 1999-10-24 22:51:21 sandervl Exp $
     1# $Id: makefile,v 1.47 1999-10-26 11:15:33 sandervl Exp $
    22
    33#
     
    2626LFILE.OBJ NPIPE.OBJ oslibdos.obj oslibmisc.obj MISC.OBJ EXCEPTUTIL.OBJ \
    2727LANG.OBJ ICCIO.OBJ MAP.OBJ WIN32UTIL.OBJ heap.OBJ heapstring.obj \
    28 os2heap.OBJ vmutex.OBJ initterm.OBJ handlemanager.OBJ winresmenu.obj \
     28os2heap.OBJ vmutex.OBJ initterm.OBJ handlemanager.OBJ \
    2929hmdevice.obj hmopen32.obj hmobjects.obj hmevent.obj hmmutex.obj \
    3030hmsemaphore.obj wprocess.OBJ conprop.OBJ winimagelx.obj \
     
    3434pefile.OBJ winimgres.OBJ wintls.obj async.OBJ fileio.obj \
    3535atom.obj disk.obj directory.obj cvtbitmap.obj hmmmap.obj winfakepeldr.obj \
    36 cvtmenu.obj cvtaccel.obj cvticon.obj cvticongrp.obj oslibexcept.obj \
     36cvtaccel.obj cvticon.obj cvticongrp.obj oslibexcept.obj \
    3737cvtcursor.obj cvtcursorgrp.obj stubs.obj interlock.obj toolhelp.obj
    3838
     
    257257    .\winres.cpp \
    258258    cvtresource.h \
    259     $(PDWIN32_INCLUDE)\winresmenu.h \
    260259    $(PDWIN32_INCLUDE)\winres.h \
    261260    $(PDWIN32_INCLUDE)\winimagebase.h \
     
    349348stubs.obj:     stubs.cpp stubs.h
    350349
    351 winresmenu.obj: winresmenu.cpp $(PDWIN32_INCLUDE)\winresmenu.h $(PDWIN32_INCLUDE)\winres.h
    352 
    353350cvtbitmap.obj: cvtbitmap.cpp $(PDWIN32_INCLUDE)\winicon.h $(PDWIN32_INCLUDE)\misc.h cvtresource.h
    354 cvtmenu.obj: cvtmenu.cpp $(PDWIN32_INCLUDE)\winmenu.h $(PDWIN32_INCLUDE)\misc.h cvtresource.h
    355351cvtaccel.obj: cvtaccel.cpp $(PDWIN32_INCLUDE)\winaccel.h $(PDWIN32_INCLUDE)\misc.h cvtresource.h
    356352cvticon.obj: cvticon.cpp $(PDWIN32_INCLUDE)\winicon.h $(PDWIN32_INCLUDE)\misc.h cvtresource.h
  • trunk/src/kernel32/winimgres.cpp

    r1356 r1454  
    1 /* $Id: winimgres.cpp,v 1.24 1999-10-19 12:51:25 sandervl Exp $ */
     1/* $Id: winimgres.cpp,v 1.25 1999-10-26 11:15:33 sandervl Exp $ */
    22
    33/*
     
    2626#include <winimagelx.h>
    2727#include <winres.h>
    28 #include <winresmenu.h>
    2928#include <unicode.h>
    3029#include <heapstring.h>
     
    306305    else
    307306    {
    308         switch(type) {
    309         case NTRT_MENU:
    310             res = new Win32MenuRes(this, id, type, pData->Size, resdata);
    311             break;
    312         default:
    313             res = new Win32Resource(this, id, type, pData->Size, resdata);
    314             break;
    315         }
    316 
     307        res = new Win32Resource(this, id, type, pData->Size, resdata);
    317308    }
    318309
  • trunk/src/kernel32/winres.cpp

    r1356 r1454  
    1 /* $Id: winres.cpp,v 1.20 1999-10-19 12:51:25 sandervl Exp $ */
     1/* $Id: winres.cpp,v 1.21 1999-10-26 11:15:33 sandervl Exp $ */
    22
    33/*
     
    4242//******************************************************************************
    4343//******************************************************************************
    44 static ULONG CalcBitmapSize(ULONG cBits, LONG cx, LONG cy)
    45 {
    46         ULONG alignment;
    47         ULONG factor;
    48         BOOL flag = TRUE;       //true: '*'     false: '/'
    49 
    50         cy = cy < 0 ? -cy : cy;
    51 
    52         switch(cBits)
    53         {
    54                 case 1:
    55                         factor = 8;
    56                         flag = FALSE;
    57                         break;
    58 
    59                 case 4:
    60                         factor = 2;
    61                         flag = FALSE;
    62                         break;
    63 
    64                 case 8:
    65                         factor = 1;
    66                         break;
    67 
    68                 case 16:
    69                         factor = 2;
    70                         break;
    71 
    72                 case 24:
    73                         factor = 3;
    74                         break;
    75 
    76                 case 32:
    77                         return cx*cy;
    78 
    79                 default:
    80                         return 0;
    81         }
    82 
    83         if (flag)
    84                 alignment = (cx = (cx*factor)) % 4;
    85         else
    86                 alignment = (cx = ((cx+factor-1)/factor)) % 4;
    87 
    88         if (alignment != 0)
    89                 cx += 4 - alignment;
    90 
    91         return cx*cy;
    92 }
    93 
    94 //******************************************************************************
    95 //******************************************************************************
    9644Win32Resource::Win32Resource() :
    9745        os2resdata(NULL), winresdata(NULL), resType(RSRC_CUSTOMNODATA)
     
    10351  type       = -1;
    10452  hres       = 0;
    105   orgos2type = -1;
    10653  OS2ResHandle = 0;
    10754  //resources are in Unicode format by default; indirectly created resources
     
    11158//******************************************************************************
    11259//******************************************************************************
    113 Win32Resource::Win32Resource(Win32ImageBase *module, HRSRC hRes, ULONG id, ULONG type) :
    114         os2resdata(NULL), winresdata(NULL), resType(RSRC_PE2LX)
    115 {
    116  APIRET rc;
    117 
     60Win32Resource::Win32Resource(Win32ImageBase *module, ULONG id, ULONG type,
     61                 ULONG size, char *resdata) : hres(NULL),
     62        os2resdata(NULL), winresdata(NULL), resType(RSRC_PELOADER)
     63{
    11864  resmutex.enter();
    11965  next           = module->winres;
     
    12470  this->id       = id;
    12571  this->type     = type;
    126   this->hres     = hRes;
    127 
    128   switch(type) {
    129     case NTRT_NEWBITMAP:
    130     case NTRT_BITMAP:
    131         orgos2type = RT_BITMAP;
    132         break;
    133     case NTRT_CURSOR:
    134     case NTRT_GROUP_CURSOR:
    135     case NTRT_GROUP_ICON:
    136     case NTRT_ICON:
    137         orgos2type = RT_POINTER;
    138         break;
    139     case NTRT_ACCELERATORS:
    140         orgos2type = RT_ACCELTABLE;
    141     break;
    142     case NTRT_NEWMENU:
    143     case NTRT_MENU:
    144         orgos2type = RT_MENU;
    145         break;
    146     case NTRT_NEWDIALOG:
    147     case NTRT_DIALOG:
    148         orgos2type = RT_DIALOG;
    149         break;
    150     case NTRT_FONTDIR:
    151     case NTRT_FONT:
    152     case NTRT_MESSAGETABLE:
    153     case NTRT_STRING:
    154     case NTRT_RCDATA:
    155     case NTRT_VERSION:
    156     default:
    157         orgos2type = RT_RCDATA;
    158         break;
    159   }
    160   OS2ResHandle = 0;
    161 
    162   rc = DosQueryResourceSize(module->hinstance, orgos2type, id, &ressize);
    163   if(rc) {
    164     dprintf(("Win32Resource ctor: DosQueryResourceSize %x %d %d returned %X\n", module->hinstance, type, id, rc));
    165     ressize = 0;
    166   }
    167   //resources are in Unicode format by default
    168   isUnicode  = TRUE;
    169 }
    170 //******************************************************************************
    171 //******************************************************************************
    172 Win32Resource::Win32Resource(Win32ImageBase *module, ULONG id, ULONG type,
    173                  ULONG size, char *resdata) : hres(NULL),
    174         os2resdata(NULL), winresdata(NULL), resType(RSRC_PELOADER)
    175 {
    176   resmutex.enter();
    177   next           = module->winres;
    178   module->winres = this;
    179   resmutex.leave();
    180 
    181   this->module   = module;
    182   this->id       = id;
    183   this->type     = type;
    184   orgos2type     = -1;
    18572  this->ressize  = size;
    18673  winresdata     = (char *)malloc(size);
     
    20693 Win32Resource *res = module->winres;
    20794
    208   //returned by DosGetResource, so we don't (and mustn't) free it
    20995  if(os2resdata && (resType == RSRC_PELOADER || resType == RSRC_CUSTOMINDIRECT))
    21096    free(os2resdata);
     
    229115PVOID Win32Resource::lockResource()
    230116{
    231  int            restype = 0, newid;
    232  void          *resdata = NULL;
    233  APIRET         rc;
    234  ULONG          os2type = RT_RCDATA;
    235 
    236117  dprintf(("Win32Resource::lockResource %d\n", id));
    237118
     
    239120    return(winresdata);
    240121
    241   switch(type) {
    242     case NTRT_BITMAP:
    243         rc = DosGetResource((HMODULE)module->hinstance, RT_BITMAP, id, (PPVOID)&resdata);
    244         if(rc)  return(NULL);
    245         winresdata = convertOS2Bitmap((BITMAPFILEHEADER2 *)resdata);
    246         break;
    247 
    248     case NTRT_ACCELERATORS:
    249     case NTRT_MENU:
    250     case NTRT_DIALOG:
    251     {
    252 //TODO->!!!!
    253 //        newid = ((Win32Pe2LxImage *)module)->getWin32ResourceId(id);
    254 //TODO->!!!!
    255 
    256         rc = DosGetResource((HMODULE)module->hinstance, RT_RCDATA, (int)newid, (PPVOID)&resdata);
    257         if(rc) {
    258             dprintf(("Can't find original resource!!!\n"));
    259             return(NULL);
    260         }
    261         winresdata = (char *)malloc(ressize);
    262         memcpy(winresdata, resdata, ressize);
    263         break;
    264     }
    265 
    266     //TODO:not yet implemented
    267     case NTRT_FONTDIR:
    268     case NTRT_FONT:
    269     case NTRT_MESSAGETABLE:
    270     case NTRT_NEWBITMAP:
    271     case NTRT_NEWMENU:
    272     case NTRT_NEWDIALOG:
    273         os2type = RT_RCDATA;
    274         break;
    275 
    276     //Can't do this right now (all group icons stored into a single one)
    277     case NTRT_CURSOR:
    278     case NTRT_GROUP_CURSOR:
    279     case NTRT_GROUP_ICON:
    280     case NTRT_ICON:
    281         dprintf(("Can't convert this resource!!!!!\n"));
    282         os2type = RT_POINTER;
    283         break;
    284 
    285     case NTRT_STRING:
    286         rc = DosGetResource((HMODULE)module->hinstance, RT_RCDATA, id, (PPVOID)&resdata);
    287         if(rc) {
    288             dprintf(("Can't find original string!!!\n"));
    289             return(NULL);
    290         }
    291         winresdata = malloc(ressize+sizeof(WCHAR));
    292         memcpy(winresdata, resdata, ressize);
    293     *(USHORT *)(&((char *)winresdata)[ressize]) = 0;
    294         DosFreeResource(resdata);
    295         return((PVOID)((ULONG)winresdata+2));   //skip length word
    296 
    297     //no conversion necessary
    298     case NTRT_RCDATA:
    299     case NTRT_VERSION:
    300     default:
    301         os2type = RT_RCDATA;
    302         break;
    303   }
    304 
    305   if(winresdata == NULL) {
    306         rc = DosGetResource((HMODULE)module->hinstance, os2type, id, (PPVOID)&resdata);
    307         if(rc) {
    308             dprintf(("Can't find original resource!!!\n"));
    309             return(NULL);
    310         }
    311         winresdata = (char *)malloc(ressize);
    312         memcpy(winresdata, resdata, ressize);
    313   }
    314   if(resdata)
    315         DosFreeResource(resdata);
    316 
    317   return winresdata;
     122  dprintf(("Win32Resource::lockResource: NO windows resource!"));
     123  return NULL;
    318124}
    319125//******************************************************************************
     
    326132   dprintf(("Win32Resource::lockOS2Resource %d\n", id));
    327133   if(os2resdata == NULL) {
    328     if(resType == RSRC_PELOADER || resType == RSRC_CUSTOMINDIRECT) {
    329134        os2resdata = convertResource(winresdata);
    330     }
    331     else {
    332         rc = DosGetResource((HMODULE)module->hinstance, orgos2type, id, (PPVOID)&resdata);
    333         if(rc)  return(NULL);
    334         os2resdata = resdata;
    335     }
    336135   }
    337136   return os2resdata;
     
    345144    case NTRT_NEWBITMAP:
    346145    case NTRT_BITMAP:
    347     return QueryConvertedBitmapSize((WINBITMAPINFOHEADER *)winresdata, ressize);
     146        return QueryConvertedBitmapSize((WINBITMAPINFOHEADER *)winresdata, ressize);
    348147
    349148    case NTRT_CURSOR:
    350     return QueryConvertedCursorSize((CursorComponent *)winresdata, ressize);
     149        return QueryConvertedCursorSize((CursorComponent *)winresdata, ressize);
    351150
    352151    case NTRT_ICON:
    353     return QueryConvertedIconSize((WINBITMAPINFOHEADER *)winresdata, ressize);
     152        return QueryConvertedIconSize((WINBITMAPINFOHEADER *)winresdata, ressize);
    354153
    355154    case NTRT_GROUP_ICON:
     
    367166    case NTRT_STRING:
    368167    default:
    369     dprintf(("Win32Resource::getOS2Size SHOULDN'T BE CALLED for this resource type (%d) (NOT IMPLEMENTED)!!", type));
    370     break;
     168        dprintf(("Win32Resource::getOS2Size SHOULDN'T BE CALLED for this resource type (%d) (NOT IMPLEMENTED)!!", type));
     169        break;
    371170  }
    372171  return 0;
     
    381180    case NTRT_NEWBITMAP:
    382181    case NTRT_BITMAP:
    383     return ConvertBitmap((WINBITMAPINFOHEADER *)win32res, ressize, &ressize);
     182        return ConvertBitmap((WINBITMAPINFOHEADER *)win32res, ressize, &ressize);
    384183
    385184    case NTRT_CURSOR:
    386     return ConvertCursor((CursorComponent *)win32res, ressize, &cvtressize);
     185        return ConvertCursor((CursorComponent *)win32res, ressize, &cvtressize);
    387186
    388187    case NTRT_GROUP_CURSOR:
    389     return ConvertCursorGroup((CursorHeader *)win32res, ressize, module);
     188        return ConvertCursorGroup((CursorHeader *)win32res, ressize, module);
    390189
    391190    case NTRT_GROUP_ICON:
    392     return ConvertIconGroup((IconHeader *)win32res, ressize, module);
     191        return ConvertIconGroup((IconHeader *)win32res, ressize, module);
    393192
    394193    case NTRT_ICON:
    395     return ConvertIcon((WINBITMAPINFOHEADER *)win32res, ressize, &cvtressize);
     194        return ConvertIcon((WINBITMAPINFOHEADER *)win32res, ressize, &cvtressize);
    396195
    397196    case NTRT_ACCELERATORS:
    398     return ConvertAccelerator((WINACCEL *)win32res, ressize);
     197        return ConvertAccelerator((WINACCEL *)win32res, ressize);
    399198
    400199    case NTRT_NEWMENU:
    401200    case NTRT_MENU:
    402     return ConvertMenu((MenuHeader *)win32res, ressize, isUnicode);
    403 
    404201    case NTRT_NEWDIALOG:
    405202    case NTRT_DIALOG:
    406     break;
    407203    case NTRT_FONTDIR:
    408204    case NTRT_FONT:
     
    411207    case NTRT_VERSION:
    412208    case NTRT_STRING:
    413     break;
     209        break;
    414210
    415211    default:
     
    418214  dprintf(("Win32Resource::convertResource: Can't convert resource %d (type %d)", id, type));
    419215  return 0;
    420 }
    421 //******************************************************************************
    422 //NOTE: Will be removed once pe2lx rewrite has been completed
    423 //******************************************************************************
    424 PVOID Win32Resource::convertOS2Bitmap(void *bmpdata)
    425 {
    426  BITMAPFILEHEADER2   *bmphdr = (BITMAPFILEHEADER2 *)bmpdata;
    427  WINBITMAPINFOHEADER *winbmphdr;
    428  RGBQUAD             *rgb;
    429  RGB2                *os2rgb;
    430  int                  palsize = 0;
    431  int                  imgsize;
    432 
    433   if(bmphdr->cbSize != sizeof(BITMAPFILEHEADER2)) {
    434     PVOID bmpdat = malloc(ressize);
    435     memcpy(bmpdat, bmpdata, ressize);
    436     return(bmpdat);    //don't convert OS/2 1.x bitmap
    437   }
    438 
    439   if(bmphdr->bmp2.cBitCount < 16) {
    440     palsize = (1 << bmphdr->bmp2.cBitCount) * sizeof(RGBQUAD);
    441   }
    442 
    443   //SvL: Always recalculate bitmap size (donut.exe has wrong size)
    444   imgsize =  CalcBitmapSize(bmphdr->bmp2.cBitCount,
    445                             bmphdr->bmp2.cx,
    446                             bmphdr->bmp2.cy);
    447 
    448   winbmphdr = (WINBITMAPINFOHEADER *)malloc(sizeof(WINBITMAPINFOHEADER) +
    449                         imgsize + palsize);
    450   memset((char *)winbmphdr, 0, sizeof(WINBITMAPINFOHEADER) + imgsize + palsize);
    451 
    452   winbmphdr->biSize          = sizeof(WINBITMAPINFOHEADER);
    453   winbmphdr->biWidth         = bmphdr->bmp2.cx;
    454   winbmphdr->biHeight        = bmphdr->bmp2.cy;
    455   winbmphdr->biPlanes        = bmphdr->bmp2.cPlanes;
    456   winbmphdr->biBitCount      = bmphdr->bmp2.cBitCount;
    457   //TODO: Identical except for BI_BITFIELDS (3L) type!
    458   winbmphdr->biCompression   = bmphdr->bmp2.ulCompression;
    459   winbmphdr->biSizeImage     = imgsize;
    460   //TODO: Doesn't seem to be completely identical..
    461   winbmphdr->biClrUsed       = bmphdr->bmp2.cclrUsed;
    462   winbmphdr->biClrImportant  = bmphdr->bmp2.cclrImportant;
    463   winbmphdr->biXPelsPerMeter = bmphdr->bmp2.cxResolution;
    464   winbmphdr->biYPelsPerMeter = bmphdr->bmp2.cyResolution;
    465 
    466   os2rgb                     = (RGB2 *)(bmphdr+1);
    467   rgb                    = (RGBQUAD *)(winbmphdr+1);
    468 
    469   if(palsize) {
    470     memcpy((char *)rgb, (char *)os2rgb, palsize);
    471     os2rgb = (RGB2    *)((int)os2rgb + palsize);
    472     rgb    = (RGBQUAD *)((int)rgb    + palsize);
    473   }
    474   memcpy((char *)rgb, (char *)os2rgb, imgsize);
    475   return((PVOID)winbmphdr);
    476216}
    477217//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.