Ignore:
Timestamp:
Jun 7, 2000, 4:51:33 PM (25 years ago)
Author:
sandervl
Message:

Major rewrite: frame/client -> frame

File:
1 edited

Legend:

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

    r3610 r3662  
    1 /* $Id: oslibwin.cpp,v 1.78 2000-05-26 18:43:34 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.79 2000-06-07 14:51:26 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    5353//******************************************************************************
    5454HWND OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle,
    55                           char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame,
     55                          char *pszName, HWND Owner, ULONG fHWND_BOTTOM,
    5656                          ULONG id, BOOL fTaskList,BOOL fShellPosition,
    5757                          int classStyle)
    5858{
    5959 HWND  hwndClient;
    60 
    61   dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle));
     60 ULONG dwFrameStyle = 0;
    6261
    6362  if(pszName && *pszName == 0) {
     
    7069        Owner = HWND_DESKTOP;
    7170  }
    72   ULONG dwClientStyle = 0;
    73   ULONG dwFrameStyle = 0;
    74 
    7571  BOOL TopLevel = hwndParent == HWND_DESKTOP;
    76 
    77   FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
    7872
    7973  if(classStyle & CS_SAVEBITS_W) dwWinStyle |= WS_SAVEBITS;
    8074  if(classStyle & CS_PARENTDC_W) dwWinStyle |= WS_PARENTCLIP;
    8175
    82   dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP | WS_CLIPSIBLINGS);
    83 
    84   dwFrameStyle |= FCF_NOBYTEALIGN;
     76  dwWinStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
     77
    8578  if(fTaskList)
    8679  {
     
    8982  if (fShellPosition) dwFrameStyle |= FCF_SHELLPOSITION;
    9083
    91   dwWinStyle &= ~WS_CLIPCHILDREN;
     84  FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
    9285  FCData.flCreateFlags = dwFrameStyle;
    9386
    94   *hwndFrame = WinCreateWindow (hwndParent,
    95                                 TopLevel ? WC_FRAME : WIN32_INNERFRAME,
    96                                 pszName, dwWinStyle, 0, 0, 0, 0,
    97                                 Owner, HWND_TOP,
    98                                 id, &FCData, NULL);
    99 
    100   if (*hwndFrame) {
    101     hwndClient = WinCreateWindow (*hwndFrame, (classStyle & CS_SAVEBITS_W) ? WIN32_STDCLASS2:WIN32_STDCLASS,
    102                                   NULL, dwClientStyle, 0, 0, 0, 0,
    103                                   *hwndFrame, HWND_TOP, FID_CLIENT, NULL, NULL);
    104     return hwndClient;
    105   }
    106   dprintf(("OSLibWinCreateWindow: (FRAME) WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
    107   return 0;
     87  dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x winstyle %x", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle, dwWinStyle));
     88
     89#if 1
     90  return WinCreateWindow (hwndParent,
     91//                          TopLevel ? WIN32_STDFRAMECLASS : WIN32_STDCLASS,
     92                          WIN32_STDFRAMECLASS,
     93                          pszName, dwWinStyle, 0, 0, 0, 0,
     94                          Owner, HWND_TOP,
     95                          id, &FCData, NULL);
     96#else
     97  return WinCreateWindow (hwndParent,
     98                          WIN32_STDCLASS,
     99                          pszName, dwWinStyle, 0, 0, 0, 0,
     100                          Owner, HWND_TOP,
     101                          id, NULL, NULL);
     102#endif
    108103}
    109104//******************************************************************************
     
    258253//******************************************************************************
    259254//******************************************************************************
    260 BOOL OSLibWinQueryWindowRect(HWND hwnd, PRECT pRect, int RelativeTo)
     255#if 0
     256BOOL OSLibWinQueryWindowRect(Win32BaseWindow *window, PRECT pRect, int RelativeTo)
    261257{
    262258 BOOL     rc;
    263259 RECTLOS2 rectl;
    264260
    265   rc = WinQueryWindowRect(hwnd, (PRECTL)&rectl);
     261  rc = WinQueryWindowRect(window->getOS2WindowHandle(), (PRECTL)&rectl);
    266262  if(rc) {
    267263        if(RelativeTo == RELATIVE_TO_SCREEN) {
    268                 mapOS2ToWin32Rect(hwnd,OSLIB_HWND_DESKTOP,&rectl,pRect);
     264                mapOS2ToWin32RectFrame(window,windowDesktop,&rectl,pRect);
    269265        }
    270         else    mapOS2ToWin32Rect(hwnd,&rectl,pRect);
     266        else    mapOS2ToWin32RectFrame(window,&rectl,pRect);
    271267  }
    272268  else  memset(pRect, 0, sizeof(RECT));
    273269  return rc;
    274270}
     271#endif
    275272//******************************************************************************
    276273//******************************************************************************
     
    294291BOOL OSLibWinSetActiveWindow(HWND hwnd)
    295292{
    296   return WinSetActiveWindow(HWND_DESKTOP, hwnd);
     293 BOOL rc;
     294
     295  rc = WinSetActiveWindow(HWND_DESKTOP, hwnd);
     296  if(rc == FALSE) {
     297        dprintf(("WinSetActiveWindow %x failure: %x", hwnd, OSLibWinGetLastError()));
     298  }
     299  return rc;
    297300}
    298301//******************************************************************************
     
    392395//******************************************************************************
    393396//******************************************************************************
    394 void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
     397void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld,
     398                            int parentHeight, int clientOrgX, int clientOrgY,
     399                            HWND hwnd)
    395400{
    396401   HWND hWindow            = pswp->hwnd;
    397402   HWND hWndInsertAfter    = pswp->hwndInsertBehind;
    398    long x                  = pswp->x;
    399    long y                  = pswp->y;
     403   long x                  = pswp->x - clientOrgX;
     404   long y                  = pswp->y + clientOrgY;
    400405   long cx                 = pswp->cx;
    401406   long cy                 = pswp->cy;
    402407   UINT fuFlags            = (UINT)pswp->fl;
    403    ULONG parentHeight;
    404408
    405409   HWND   hWinAfter;
    406410   ULONG  flags = 0;
    407    SWP    swpFrame, swpClient;
    408    POINTL point;
    409411
    410412   HWND  hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
     
    429431    if (  fuFlags & SWP_NOADJUST)    flags |= SWP_NOSENDCHANGING_W;
    430432
    431     WinQueryWindowPos(hFrame, &swpFrame);
    432 
    433433    if(fuFlags & (SWP_MOVE | SWP_SIZE))
    434434    {
    435         point.x = swpFrame.x;
    436         point.y = swpFrame.y;
    437 
    438         if (hParent)
    439         {
    440           RECTL parentRect;
    441 
    442           WinQueryWindowRect(hParent,&parentRect);
    443           parentHeight = parentRect.yTop;
    444         } else
    445         {
    446           parentHeight = ScreenHeight;
    447         }
    448 
    449         point.y = parentHeight-point.y-swpFrame.cy;
    450 
    451         cy = swpFrame.cy;
    452         cx = swpFrame.cx;
    453         x  = point.x;
    454         y  = point.y;
     435        y  = parentHeight - y - pswp->cy;
    455436
    456437        if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
     
    470451
    471452    pswpOld->x  = pswp->x;
    472     pswpOld->y  = swpFrame.cy-pswp->y-pswp->cy;
     453    pswpOld->y  = parentHeight-pswp->y-pswp->cy;
    473454    pswpOld->cx = pswp->cx;
    474455    pswpOld->cy = pswp->cy;
     
    487468//******************************************************************************
    488469//******************************************************************************
    489 void OSLibMapSWPtoWINDOWPOSFrame(PSWP pswp, struct tagWINDOWPOS *pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
    490 {
    491    HWND hWindow            = pswp->hwnd;
    492    HWND hWndInsertAfter    = pswp->hwndInsertBehind;
    493    long x                  = pswp->x;
    494    long y                  = pswp->y;
    495    long cx                 = pswp->cx;
    496    long cy                 = pswp->cy;
    497    UINT fuFlags            = (UINT)pswp->fl;
    498    ULONG parentHeight;
    499 
    500    HWND   hWinAfter;
    501    ULONG  flags = 0;
    502    SWP    swpClient;
    503    POINTL point;
    504 
    505    HWND  hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
    506 
    507     if (hWndInsertAfter == HWND_TOP)
    508         hWinAfter = HWND_TOP_W;
    509     else if (hWndInsertAfter == HWND_BOTTOM)
    510         hWinAfter = HWND_BOTTOM_W;
    511     else
    512         hWinAfter = (HWND) hWndInsertAfter;
    513 
    514     //***********************************
    515     // convert PM flags to Windows flags
    516     //***********************************
    517     if (!(fuFlags & SWP_SIZE))       flags |= SWP_NOSIZE_W;
    518     if (!(fuFlags & SWP_MOVE))       flags |= SWP_NOMOVE_W;
    519     if (!(fuFlags & SWP_ZORDER))     flags |= SWP_NOZORDER_W;
    520     if (  fuFlags & SWP_NOREDRAW)    flags |= SWP_NOREDRAW_W;
    521     if (!(fuFlags & SWP_ACTIVATE))   flags |= SWP_NOACTIVATE_W;
    522     if (  fuFlags & SWP_SHOW)        flags |= SWP_SHOWWINDOW_W;
    523     if (  fuFlags & SWP_HIDE)        flags |= SWP_HIDEWINDOW_W;
    524     if (  fuFlags & SWP_NOADJUST)    flags |= SWP_NOSENDCHANGING_W;
    525 
    526     WinQueryWindowPos(WinWindowFromID(hFrame, FID_CLIENT), &swpClient);
    527 
    528     if(fuFlags & (SWP_MOVE | SWP_SIZE))
    529     {
    530         if (hParent)
    531         {
    532           RECTL parentRect;
    533 
    534           WinQueryWindowRect(hParent,&parentRect);
    535           parentHeight = parentRect.yTop;
    536         } else
    537         {
    538           parentHeight = ScreenHeight;
    539         }
    540 
    541         point.x = x;
    542         point.y = parentHeight-y-cy;
    543 
    544         x  = point.x;
    545         y  = point.y;
    546 
    547         if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
    548             flags |= SWP_NOMOVE_W;
    549 
    550         if ((pswp->cx == pswpOld->cx) && (pswp->cy == pswpOld->cy))
    551             flags |= SWP_NOSIZE_W;
    552 
    553         if (fuFlags & SWP_SIZE)
    554         {
    555             if (pswp->cy != pswpOld->cy)
    556             {
    557                 flags &= ~SWP_NOMOVE_W;
    558             }
    559         }
    560     }
    561 
    562     pswpOld->x  = swpClient.x;
    563     pswpOld->y  = pswp->cy-swpClient.y-swpClient.cy;
    564     pswpOld->cx = swpClient.cx;
    565     pswpOld->cy = swpClient.cy;
    566 
    567     dprintf(("window (%d,%d)(%d,%d)  client (%d,%d)(%d,%d)",
    568              x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
    569 
    570     pwpos->flags            = (UINT)flags;
    571     pwpos->cy               = cy;
    572     pwpos->cx               = cx;
    573     pwpos->x                = x;
    574     pwpos->y                = y;
    575     pwpos->hwndInsertAfter  = hWinAfter;
    576     pwpos->hwnd             = hWindow;
    577 }
    578 //******************************************************************************
    579 //******************************************************************************
    580 void OSLibMapWINDOWPOStoSWP(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
     470void OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld,
     471                            int parentHeight, int clientOrgX, int clientOrgY, HWND hFrame)
    581472{
    582473 BOOL fCvt = FALSE;
     
    584475   HWND hWnd            = pwpos->hwnd;
    585476   HWND hWndInsertAfter = pwpos->hwndInsertAfter;
    586    long x               = pwpos->x;
    587    long y               = pwpos->y;
     477   long x               = pwpos->x + clientOrgX;
     478   long y               = pwpos->y + clientOrgY;
    588479   long cx              = pwpos->cx;
    589480   long cy              = pwpos->cy;
    590481   UINT fuFlags         = pwpos->flags;
    591    ULONG parentHeight;
    592482
    593483   HWND  hWinAfter;
     
    617507   if (  fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
    618508
    619    if (flags & (SWP_MOVE | SWP_SIZE))
     509   if(flags & (SWP_MOVE | SWP_SIZE))
    620510   {
    621       if (hParent == NULLHANDLE)
    622         parentHeight = ScreenHeight;
    623       else
    624         parentHeight = OSLibGetWindowHeight(hParent);
    625 
    626       if ((flags & SWP_MOVE) == 0)
     511      if((flags & SWP_MOVE) == 0)
    627512      {
    628513         x = pswpOld->x;
    629514         y = pswpOld->y;
    630515
    631          y = parentHeight-y-pswpOld->cy;
    632       }
    633 
    634       if (flags & SWP_SIZE)
     516         y = parentHeight - y - pswpOld->cy;
     517     }
     518
     519      if(flags & SWP_SIZE)
    635520      {
    636521         if (cy != pswpOld->cy)
     
    642527         cy = pswpOld->cy;
    643528      }
    644       y  = parentHeight-y-cy;
     529      y = parentHeight - y - cy;
    645530
    646531      if ((pswpOld->x == x) && (pswpOld->y == y))
     
    664549//Position in screen coordinates
    665550//******************************************************************************
    666 void OSLibMapWINDOWPOStoSWPFrame(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
    667 {
    668  BOOL fCvt = FALSE;
    669 
    670    HWND hWnd            = pwpos->hwnd;
    671    HWND hWndInsertAfter = pwpos->hwndInsertAfter;
    672    long x               = pwpos->x;
    673    long y               = pwpos->y;
    674    long cx              = pwpos->cx;
    675    long cy              = pwpos->cy;
    676    UINT fuFlags         = pwpos->flags;
    677    ULONG parentHeight;
    678 
    679    HWND  hWinAfter;
    680    ULONG flags = 0;
    681    HWND  hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
    682 
    683    if (hWndInsertAfter == HWND_TOPMOST_W)
    684 //      hWinAfter = HWND_TOPMOST;
    685       hWinAfter = HWND_TOP;
    686    else if (hWndInsertAfter == HWND_NOTOPMOST_W)
    687 //      hWinAfter = HWND_NOTOPMOST;
    688       hWinAfter = HWND_TOP;
    689    else if (hWndInsertAfter == HWND_TOP_W)
    690       hWinAfter = HWND_TOP;
    691    else if (hWndInsertAfter == HWND_BOTTOM_W)
    692       hWinAfter = HWND_BOTTOM;
    693    else
    694       hWinAfter = (HWND) hWndInsertAfter;
    695 
    696    if (!(fuFlags & SWP_NOSIZE_W    )) flags |= SWP_SIZE;
    697    if (!(fuFlags & SWP_NOMOVE_W    )) flags |= SWP_MOVE;
    698    if (!(fuFlags & SWP_NOZORDER_W  )) flags |= SWP_ZORDER;
    699    if (  fuFlags & SWP_NOREDRAW_W  )  flags |= SWP_NOREDRAW;
    700    if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
    701    if (  fuFlags & SWP_SHOWWINDOW_W)  flags |= SWP_SHOW;
    702    if (  fuFlags & SWP_HIDEWINDOW_W)  flags |= SWP_HIDE;
    703    if (  fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
    704 
    705    if (flags & (SWP_MOVE | SWP_SIZE))
    706    {
    707       if (hParent)
    708       {
    709         RECTL parentRect;
    710 
    711         WinQueryWindowRect(hParent,&parentRect);
    712         parentHeight = parentRect.yTop;
    713       } else
    714       {
    715         parentHeight = ScreenHeight;
    716       }
    717 
    718       if (flags & SWP_SIZE)
    719       {
    720          if (cy != pswpOld->cy)
    721             flags |= SWP_MOVE;
    722       }
    723       else
    724       {
    725          cx = pswpOld->cx;
    726          cy = pswpOld->cy;
    727       }
    728       y  = parentHeight-y-cy;
    729 
    730       if ((pswpOld->x == x) && (pswpOld->y == y))
    731          flags &= ~SWP_MOVE;
    732 
    733       if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
    734          flags &= ~SWP_SIZE;
    735    }
    736 
    737    pswp->fl               = flags;
    738    pswp->cy               = cy;
    739    pswp->cx               = cx;
    740    pswp->x                = x;
    741    pswp->y                = y;
    742    pswp->hwndInsertBehind = hWinAfter;
    743    pswp->hwnd             = hWindow;
    744    pswp->ulReserved1      = 0;
    745    pswp->ulReserved2      = 0;
    746 }
    747 //******************************************************************************
    748 //******************************************************************************
    749 BOOL  OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
     551BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
    750552{
    751553 BOOL rc;
Note: See TracChangeset for help on using the changeset viewer.