Ignore:
Timestamp:
Sep 21, 1999, 10:24:05 AM (26 years ago)
Author:
sandervl
Message:

Edgar Buerkle's fixes for GetDesktopWindow, icons + WM_TIMER support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/oslibres.cpp

    r949 r996  
    1 /* $Id: oslibres.cpp,v 1.1 1999-09-15 23:18:54 sandervl Exp $ */
     1/* $Id: oslibres.cpp,v 1.2 1999-09-21 08:24:04 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    5757
    5858    if(iconbitmap == NULL) {
    59         dprintf(("OSLibWinCreateIcon iconbitmap == NULL!!"));
    60         return 0;
     59        dprintf(("OSLibWinCreateIcon iconbitmap == NULL!!"));
     60        return 0;
    6161    }
    6262    if(bafh->usType == BFT_BITMAPARRAY && bafh->cbSize == sizeof(BITMAPARRAYFILEHEADER2)) {
    63         bfhBW    = &bafh->bfh2;
    64         bfhColor = (BITMAPFILEHEADER2 *)((char *)&bafh->bfh2 + sizeof(RGB2)*2 + sizeof(BITMAPFILEHEADER2));
     63        // search best icon for the current screen,
     64        // TODO: maybe compare icon size with screen size.
     65        // Some bugs with black/white Icons ?
     66        BITMAPARRAYFILEHEADER2 *next, *found;
     67        LONG bitcountScreen, bitcountIcon=-1, cxIcon=-1, cyIcon=-1;
     68
     69        HPS hps = WinGetPS(HWND_DESKTOP);
     70        HDC hdc = GpiQueryDevice(hps);
     71        DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, &bitcountScreen);
     72        WinReleasePS(hps);
     73
     74        next = found = bafh;
     75        while(TRUE)
     76        {
     77            bfhColor = (BITMAPFILEHEADER2 *)((char *)&next->bfh2 + sizeof(RGB2)*2 + sizeof(BITMAPFILEHEADER2));
     78            if(bfhColor->bmp2.cBitCount <= bitcountScreen &&
     79               bfhColor->bmp2.cBitCount > bitcountIcon ||
     80               (bfhColor->bmp2.cBitCount == bitcountIcon &&
     81               (cxIcon < bfhColor->bmp2.cx || cyIcon < bfhColor->bmp2.cy)))
     82            {
     83                found = next;
     84                bitcountIcon = bfhColor->bmp2.cBitCount;
     85                cxIcon = bfhColor->bmp2.cx;
     86                cyIcon = bfhColor->bmp2.cy;
     87            }
     88            if(next->offNext != 0)
     89                next = (BITMAPARRAYFILEHEADER2 *) ((char *)bafh + next->offNext);
     90            else
     91                break;
     92        }
     93        bfhBW    = &found->bfh2;
     94        bfhColor = (BITMAPFILEHEADER2 *)((char *)bfhBW + sizeof(RGB2)*2 + sizeof(BITMAPFILEHEADER2));
    6595    }
    6696    else {//single icon
    67         bfhBW    = (BITMAPFILEHEADER2 *)iconbitmap;
    68         bfhColor = (BITMAPFILEHEADER2 *)((char *)bfhBW + sizeof(RGB2)*2 + sizeof(BITMAPFILEHEADER2));
    69         bafh     = (BITMAPARRAYFILEHEADER2 *)bfhBW; //for calculation bitmap offset
     97        bfhBW    = (BITMAPFILEHEADER2 *)iconbitmap;
     98        bfhColor = (BITMAPFILEHEADER2 *)((char *)bfhBW + sizeof(RGB2)*2 + sizeof(BITMAPFILEHEADER2));
     99        bafh     = (BITMAPARRAYFILEHEADER2 *)bfhBW; //for calculation bitmap offset
    70100    }
    71101    hps = WinGetScreenPS(HWND_DESKTOP);
    72102
    73     hbmColor = GpiCreateBitmap(hps, &bfhColor->bmp2, CBM_INIT, 
    74                                (char *)bafh + bfhColor->offBits,
     103    hbmColor = GpiCreateBitmap(hps, &bfhColor->bmp2, CBM_INIT,
     104                               (char *)bafh + bfhColor->offBits,
    75105                               (BITMAPINFO2 *)&bfhColor->bmp2);
    76106    if(hbmColor == GPI_ERROR) {
     
    79109        return 0;
    80110    }
    81     hbmMask = GpiCreateBitmap(hps, &bfhBW->bmp2, CBM_INIT, 
    82                               (char *)bafh + bfhBW->offBits,
     111    hbmMask = GpiCreateBitmap(hps, &bfhBW->bmp2, CBM_INIT,
     112                              (char *)bafh + bfhBW->offBits,
    83113                              (BITMAPINFO2 *)&bfhBW->bmp2);
    84114    if(hbmMask == GPI_ERROR) {
     
    114144
    115145    if(cursorbitmap == NULL) {
    116         dprintf(("OSLibWinCreatePointer cursorbitmap == NULL!!"));
    117         return 0;
     146        dprintf(("OSLibWinCreatePointer cursorbitmap == NULL!!"));
     147        return 0;
    118148    }
    119149    //skip xor/and mask
    120150    hps = WinGetScreenPS(HWND_DESKTOP);
    121     hbmColor = GpiCreateBitmap(hps, &bfh->bmp2, CBM_INIT, 
    122                                (char *)bfh + bfh->offBits,
     151    hbmColor = GpiCreateBitmap(hps, &bfh->bmp2, CBM_INIT,
     152                           (char *)bfh + bfh->offBits,
    123153                               (BITMAPINFO2 *)&bfh->bmp2);
    124154    if(hbmColor == GPI_ERROR) {
     
    148178
    149179    switch(type) {
    150         case IDI_APPLICATION_W:
    151                 os2type = SPTR_PROGRAM;
    152                 break;
    153         case IDI_HAND_W:
    154                 os2type = SPTR_ICONWARNING;
    155                 break;
    156         case IDI_QUESTION_W:
    157                 os2type = SPTR_ICONQUESTION;
    158                 break;
    159         case IDI_EXCLAMATION_W:
    160                 os2type = SPTR_ICONWARNING;
    161                 break;
    162         case IDI_ASTERISK_W:
    163                 os2type = SPTR_ICONINFORMATION;
    164                 break;
    165         default:
    166                 return 0;
     180        case IDI_APPLICATION_W:
     181        os2type = SPTR_PROGRAM;
     182        break;
     183    case IDI_HAND_W:
     184        os2type = SPTR_ICONWARNING;
     185        break;
     186    case IDI_QUESTION_W:
     187        os2type = SPTR_ICONQUESTION;
     188        break;
     189    case IDI_EXCLAMATION_W:
     190        os2type = SPTR_ICONWARNING;
     191        break;
     192    case IDI_ASTERISK_W:
     193        os2type = SPTR_ICONINFORMATION;
     194        break;
     195    default:
     196        return 0;
    167197    }
    168198
     
    176206
    177207    switch(type) {
    178         case IDC_ARROW_W:
    179                 os2type = SPTR_ARROW;
    180                 break;
    181         case IDC_UPARROW_W:
    182                 os2type = SPTR_ARROW;
    183                 break;
    184         case IDC_IBEAM_W:
    185                 os2type = SPTR_TEXT;
    186                 break;
    187         case IDC_ICON_W:
    188                 os2type = SPTR_PROGRAM;
    189                 break;
    190         case IDC_NO_W:
    191                 os2type = SPTR_ILLEGAL;
    192                 break;
    193         case IDC_CROSS_W:
    194                 os2type = SPTR_MOVE;
    195                 break;
    196         case IDC_SIZE_W:
    197                 os2type = SPTR_MOVE;
    198                 break;
    199         case IDC_SIZEALL_W:
    200                 os2type = SPTR_MOVE;
    201                 break;
    202         case IDC_SIZENESW_W:
    203                 os2type = SPTR_SIZENESW;
    204                 break;
    205         case IDC_SIZENS_W:
    206                 os2type = SPTR_SIZENS;
    207                 break;
    208         case IDC_SIZENWSE_W:
    209                 os2type = SPTR_SIZENWSE;
    210                 break;
    211         case IDC_SIZEWE_W:
    212                 os2type = SPTR_SIZEWE;
    213                 break;
    214         case IDC_WAIT_W:
    215                 os2type = SPTR_WAIT;
    216                 break;
    217         case IDC_APPSTARTING_W:
    218                 os2type = SPTR_WAIT;
    219                 break;
    220         case IDC_HELP_W: //TODO: Create a cursor for this one
    221                 os2type = SPTR_WAIT;
    222                 break;
    223         default:
    224                 return 0;
     208        case IDC_ARROW_W:
     209        os2type = SPTR_ARROW;
     210        break;
     211        case IDC_UPARROW_W:
     212        os2type = SPTR_ARROW;
     213        break;
     214        case IDC_IBEAM_W:
     215        os2type = SPTR_TEXT;
     216        break;
     217        case IDC_ICON_W:
     218        os2type = SPTR_PROGRAM;
     219        break;
     220        case IDC_NO_W:
     221        os2type = SPTR_ILLEGAL;
     222        break;
     223        case IDC_CROSS_W:
     224        os2type = SPTR_MOVE;
     225        break;
     226        case IDC_SIZE_W:
     227        os2type = SPTR_MOVE;
     228        break;
     229        case IDC_SIZEALL_W:
     230        os2type = SPTR_MOVE;
     231        break;
     232        case IDC_SIZENESW_W:
     233        os2type = SPTR_SIZENESW;
     234        break;
     235        case IDC_SIZENS_W:
     236        os2type = SPTR_SIZENS;
     237        break;
     238        case IDC_SIZENWSE_W:
     239        os2type = SPTR_SIZENWSE;
     240        break;
     241        case IDC_SIZEWE_W:
     242        os2type = SPTR_SIZEWE;
     243        break;
     244        case IDC_WAIT_W:
     245        os2type = SPTR_WAIT;
     246        break;
     247        case IDC_APPSTARTING_W:
     248        os2type = SPTR_WAIT;
     249        break;
     250    case IDC_HELP_W: //TODO: Create a cursor for this one
     251        os2type = SPTR_WAIT;
     252        break;
     253    default:
     254        return 0;
    225255    }
    226256    return WinQuerySysPointer(HWND_DESKTOP, os2type, TRUE);
Note: See TracChangeset for help on using the changeset viewer.