Changeset 1739 for trunk/src/user32


Ignore:
Timestamp:
Nov 14, 1999, 5:35:58 PM (26 years ago)
Author:
sandervl
Message:

createControls & OSLibEnableWindow bugfixes + LookupIconIdFromDirectory(Ex) port)

Location:
trunk/src/user32
Files:
7 edited

Legend:

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

    r1704 r1739  
    1 /* $Id: oslibwin.cpp,v 1.44 1999-11-11 13:17:29 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.45 1999-11-14 16:35:54 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    433433BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
    434434{
    435   return WinEnableWindow(hwnd, fEnable);
     435 BOOL rc;
     436 HWND hwndClient;
     437
     438  rc = WinEnableWindow(hwnd, fEnable);
     439  hwndClient = WinWindowFromID(hwnd, FID_CLIENT);
     440  if(hwndClient) {
     441        WinEnableWindow(hwndClient, fEnable);
     442  }
     443  return rc;
    436444}
    437445//******************************************************************************
  • trunk/src/user32/user32.cpp

    r1704 r1739  
    1 /* $Id: user32.cpp,v 1.53 1999-11-11 13:17:30 sandervl Exp $ */
     1/* $Id: user32.cpp,v 1.54 1999-11-14 16:35:55 sandervl Exp $ */
    22
    33/*
     
    18831883DWORD WIN32API GetTabbedTextExtentA( HDC hDC, LPCSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions)
    18841884{
    1885 #ifdef DEBUG
    1886     WriteLog("USER32:  GetTabbedTextExtentA\n");
    1887 #endif
     1885    dprintf2(("USER32: GetTabbedTextExtentA %x %s", hDC, lpString));
    18881886    return O32_GetTabbedTextExtent(hDC,lpString,nCount,nTabPositions,lpnTabStopPositions);
    18891887}
     
    18951893 DWORD rc;
    18961894
    1897 #ifdef DEBUG
    1898     WriteLog("USER32:  GetTabbedTextExtentW\n");
    1899 #endif
     1895    dprintf2(("USER32: GetTabbedTextExtentW %x %s", hDC, astring));
    19001896    rc = O32_GetTabbedTextExtent(hDC,astring,nCount,nTabPositions,lpnTabStopPositions);
    19011897    FreeAsciiString(astring);
     
    19241920    FreeAsciiString(astring);
    19251921    return rc;
    1926 }
    1927 
    1928 /* Icon Functions */
    1929 int WIN32API LookupIconIdFromDirectory(PBYTE presbits, BOOL fIcon)
    1930 {
    1931 #ifdef DEBUG
    1932   WriteLog("USER32:  LookupIconIdFromDirectory, not implemented\n");
    1933 #endif
    1934   return(0);
    1935 }
    1936 //******************************************************************************
    1937 //******************************************************************************
    1938 int WIN32API LookupIconIdFromDirectoryEx(PBYTE presbits, BOOL  fIcon,
    1939                         int cxDesired, int cyDesired,
    1940                         UINT Flags)
    1941 {
    1942 #ifdef DEBUG
    1943   WriteLog("USER32:  LookupIconIdFromDirectoryEx, not implemented\n");
    1944 #endif
    1945   return(0);
    19461922}
    19471923
  • trunk/src/user32/win32dlg.cpp

    r1704 r1739  
    1 /* $Id: win32dlg.cpp,v 1.33 1999-11-11 13:17:31 sandervl Exp $ */
     1/* $Id: win32dlg.cpp,v 1.34 1999-11-14 16:35:56 sandervl Exp $ */
    22/*
    33 * Win32 Dialog Code for OS/2
     
    639639             windowNameA = UnicodeToAsciiString((LPWSTR)info.windowName);
    640640        }
     641        else windowNameA = (char *)info.windowName;
     642
    641643        hwndCtrl = ::CreateWindowExA( info.exStyle | WS_EX_NOPARENTNOTIFY,
    642644                                      classNameA,
     
    652654            FreeAsciiString(classNameA);
    653655        }
    654         if(windowNameA) {
     656        if(HIWORD(windowNameA)) {
    655657            FreeAsciiString(windowNameA);
    656658        }
  • trunk/src/user32/win32wbase.cpp

    r1733 r1739  
    1 /* $Id: win32wbase.cpp,v 1.83 1999-11-14 13:07:02 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.84 1999-11-14 16:35:56 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    27632763        case GWL_EXSTYLE:
    27642764                value = dwExStyle;
    2765                 break;
     2765        break;
    27662766        case GWL_STYLE:
    27672767                value = dwStyle;
    2768                 break;
     2768        break;
    27692769        case GWL_WNDPROC:
    27702770                value = (ULONG)getWindowProc();
    2771                 break;
     2771        break;
    27722772        case GWL_HINSTANCE:
    27732773                value = hInstance;
    2774                 break;
     2774        break;
    27752775        case GWL_HWNDPARENT:
    27762776                if(getParent()) {
     
    27782778                }
    27792779                else    value = 0;
    2780                 break;
     2780        break;
    27812781        case GWL_ID:
    27822782                value = getWindowId();
    2783                 break;
     2783        break;
    27842784        case GWL_USERDATA:
    27852785                value = userData;
    2786                 break;
     2786        break;
    27872787        default:
    27882788                if(index >= 0 && index/4 < nrUserWindowLong)
    27892789                {
    27902790                        value = userWindowLong[index/4];
    2791                         break;
     2791            break;
    27922792                }
    27932793                SetLastError(ERROR_INVALID_PARAMETER);
  • trunk/src/user32/window.cpp

    r1732 r1739  
    1 /* $Id: window.cpp,v 1.35 1999-11-14 12:00:01 sandervl Exp $ */
     1/* $Id: window.cpp,v 1.36 1999-11-14 16:35:58 sandervl Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    12631263    }
    12641264    dprintf(("WindowFromPoint (%d,%d) %x->1\n", point.x, point.y, hwndOS2));
    1265     return 1;
     1265    return windowDesktop->getWindowHandle();
    12661266}
    12671267//******************************************************************************
  • trunk/src/user32/windowclass.cpp

    r1733 r1739  
    1 /* $Id: windowclass.cpp,v 1.5 1999-11-14 13:07:03 sandervl Exp $ */
     1/* $Id: windowclass.cpp,v 1.6 1999-11-14 16:35:58 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Code for OS/2
     
    298298 Win32BaseWindow *wnd;
    299299
    300     dprintf(("USER32: SetClassLongA\n"));
     300    dprintf(("USER32: SetClassLongA %x %d %x", hwnd, nIndex, lNewVal));
    301301    wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    302302    if(!wnd) {
     
    354354 Win32BaseWindow *wnd;
    355355
    356     dprintf(("USER32: GetClassLongA\n"));
     356    dprintf(("USER32: GetClassLongA %x %d", hwnd, nIndex));
    357357    wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    358358    if(!wnd) {
  • trunk/src/user32/winicon.cpp

    r1576 r1739  
    1 /* $Id: winicon.cpp,v 1.2 1999-11-03 19:51:44 sandervl Exp $ */
     1/* $Id: winicon.cpp,v 1.3 1999-11-14 16:35:58 sandervl Exp $ */
    22/*
    33 * Win32 Icon Code for OS/2
     
    66 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
    77 *
     8 * LookupIconIdFromDirectory(Ex) (+help functions) ported from Wine (991031)
     9 *
     10 * Copyright 1995 Alexandre Julliard
     11 *           1996 Martin Von Loewis
     12 *           1997 Alex Korobka
     13 *           1998 Turchanov Sergey
    814 *
    915 * Project Odin Software License can be found in LICENSE.TXT
     
    1218#include <os2win.h>
    1319#include <winicon.h>
     20#include <win\cursoricon.h>
    1421
    1522//******************************************************************************
     
    125132    return O32_GetIconInfo(arg1, arg2);
    126133}
    127 //******************************************************************************
    128 //******************************************************************************
     134/**********************************************************************
     135 *          CURSORICON_FindBestIcon
     136 *
     137 * Find the icon closest to the requested size and number of colors.
     138 */
     139static CURSORICONDIRENTRY *CURSORICON_FindBestIcon( CURSORICONDIR *dir, int width,
     140                                                    int height, int colors )
     141{
     142    int i;
     143    CURSORICONDIRENTRY *entry, *bestEntry = NULL;
     144    UINT iTotalDiff, iXDiff=0, iYDiff=0, iColorDiff;
     145    UINT iTempXDiff, iTempYDiff, iTempColorDiff;
     146
     147    if (dir->idCount < 1)
     148    {
     149        dprintf(("Empty directory!\n" ));
     150        return NULL;
     151    }
     152    if (dir->idCount == 1) return &dir->idEntries[0];  /* No choice... */
     153
     154    /* Find Best Fit */
     155    iTotalDiff = 0xFFFFFFFF;
     156    iColorDiff = 0xFFFFFFFF;
     157    for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
     158        {
     159        iTempXDiff = abs(width - entry->ResInfo.icon.bWidth);
     160        iTempYDiff = abs(height - entry->ResInfo.icon.bHeight);
     161
     162        if(iTotalDiff > (iTempXDiff + iTempYDiff))
     163        {
     164            iXDiff = iTempXDiff;
     165            iYDiff = iTempYDiff;
     166            iTotalDiff = iXDiff + iYDiff;
     167        }
     168        }
     169
     170    /* Find Best Colors for Best Fit */
     171    for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
     172        {
     173        if(abs(width - entry->ResInfo.icon.bWidth) == iXDiff &&
     174            abs(height - entry->ResInfo.icon.bHeight) == iYDiff)
     175        {
     176            iTempColorDiff = abs(colors - entry->ResInfo.icon.bColorCount);
     177            if(iColorDiff > iTempColorDiff)
     178        {
     179            bestEntry = entry;
     180                iColorDiff = iTempColorDiff;
     181        }
     182        }
     183    }
     184
     185    return bestEntry;
     186}
     187
     188
     189/**********************************************************************
     190 *          CURSORICON_FindBestCursor
     191 *
     192 * Find the cursor closest to the requested size.
     193 * FIXME: parameter 'color' ignored and entries with more than 1 bpp
     194 *        ignored too
     195 */
     196static CURSORICONDIRENTRY *CURSORICON_FindBestCursor( CURSORICONDIR *dir,
     197                                                  int width, int height, int color)
     198{
     199    int i, maxwidth, maxheight;
     200    CURSORICONDIRENTRY *entry, *bestEntry = NULL;
     201
     202    if (dir->idCount < 1)
     203    {
     204        dprintf(("Empty directory!\n" ));
     205        return NULL;
     206    }
     207    if (dir->idCount == 1) return &dir->idEntries[0]; /* No choice... */
     208
     209    /* Double height to account for AND and XOR masks */
     210
     211    height *= 2;
     212
     213    /* First find the largest one smaller than or equal to the requested size*/
     214
     215    maxwidth = maxheight = 0;
     216    for(i = 0,entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
     217        if ((entry->ResInfo.cursor.wWidth <= width) && (entry->ResInfo.cursor.wHeight <= height) &&
     218            (entry->ResInfo.cursor.wWidth > maxwidth) && (entry->ResInfo.cursor.wHeight > maxheight) &&
     219            (entry->wBitCount == 1))
     220        {
     221            bestEntry = entry;
     222            maxwidth  = entry->ResInfo.cursor.wWidth;
     223            maxheight = entry->ResInfo.cursor.wHeight;
     224        }
     225    if (bestEntry) return bestEntry;
     226
     227    /* Now find the smallest one larger than the requested size */
     228
     229    maxwidth = maxheight = 255;
     230    for(i = 0,entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
     231        if ((entry->ResInfo.cursor.wWidth < maxwidth) && (entry->ResInfo.cursor.wHeight < maxheight) &&
     232            (entry->wBitCount == 1))
     233        {
     234            bestEntry = entry;
     235            maxwidth  = entry->ResInfo.cursor.wWidth;
     236            maxheight = entry->ResInfo.cursor.wHeight;
     237        }
     238
     239    return bestEntry;
     240}
     241/**********************************************************************
     242 *          LookupIconIdFromDirectoryEx16       (USER.364)
     243 *
     244 * FIXME: exact parameter sizes
     245 */
     246INT WIN32API LookupIconIdFromDirectoryEx(LPBYTE xdir, BOOL bIcon,
     247                                         INT width, INT height, UINT cFlag )
     248{
     249    CURSORICONDIR       *dir = (CURSORICONDIR*)xdir;
     250    UINT retVal = 0;
     251
     252    dprintf(("LookupIconIdFromDirectoryEx %x %d (%d,%d)", xdir, bIcon, width, height));
     253    if( dir && !dir->idReserved && (dir->idType & 3) )
     254    {
     255        CURSORICONDIRENTRY* entry;
     256        HDC hdc;
     257        UINT palEnts;
     258        int colors;
     259        hdc = GetDC(0);
     260        palEnts = GetSystemPaletteEntries(hdc, 0, 0, NULL);
     261        if (palEnts == 0)
     262            palEnts = 256;
     263        colors = (cFlag & LR_MONOCHROME) ? 2 : palEnts;
     264
     265        ReleaseDC(0, hdc);
     266
     267        if( bIcon )
     268            entry = CURSORICON_FindBestIcon( dir, width, height, colors );
     269        else
     270            entry = CURSORICON_FindBestCursor( dir, width, height, 1);
     271
     272        if( entry ) retVal = entry->wResId;
     273    }
     274    else dprintf(("invalid resource directory\n"));
     275    return retVal;
     276}
     277/**********************************************************************
     278 *          LookupIconIdFromDirectory           (USER32.379)
     279 */
     280INT WIN32API LookupIconIdFromDirectory( LPBYTE dir, BOOL bIcon )
     281{
     282    return LookupIconIdFromDirectoryEx( dir, bIcon,
     283           bIcon ? GetSystemMetrics(SM_CXICON) : GetSystemMetrics(SM_CXCURSOR),
     284           bIcon ? GetSystemMetrics(SM_CYICON) : GetSystemMetrics(SM_CYCURSOR), bIcon ? 0 : LR_MONOCHROME );
     285}
     286//******************************************************************************
     287//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.