Ignore:
Timestamp:
Oct 24, 1999, 1:05:05 AM (26 years ago)
Author:
sandervl
Message:

Combobox + windowpos changes + fixes

Location:
trunk/src/user32
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32

    • Property svn:ignore set to
      user32.lrf
      user32exp.def
      resource.asm
  • trunk/src/user32/pmframe.cpp

    r1408 r1425  
    1 /* $Id: pmframe.cpp,v 1.10 1999-10-23 10:21:43 sandervl Exp $ */
     1/* $Id: pmframe.cpp,v 1.11 1999-10-23 23:04:36 sandervl Exp $ */
    22/*
    33 * Win32 Frame Managment Code for OS/2
     
    2727#define PMFRAMELOG
    2828
     29//******************************************************************************
     30//******************************************************************************
    2931VOID Draw3DRect(HPS hps,RECTL rect,LONG colorBR,LONG colorTL)
    3032{
     
    4749  GpiLine(hps,&point);
    4850}
    49 
     51//******************************************************************************
     52//******************************************************************************
    5053VOID DeflateRect(RECTL *rect)
    5154{
     
    5558  rect->yBottom++;
    5659}
    57 
     60//******************************************************************************
     61//******************************************************************************
    5862VOID DrawFrame(HPS hps,RECTL *rect,Win32BaseWindow *win32wnd)
    5963{
     
    7377    DeflateRect(rect);
    7478    Draw3DRect(hps,*rect,clrLight,clrBlack);
    75   } else if (dwExStyle & WS_EX_DLGMODALFRAME_W)
     79  }
     80  else if (dwExStyle & WS_EX_DLGMODALFRAME_W)
    7681  {
    7782    Draw3DRect(hps,*rect,clrBlack,clrLight);
     
    8085    DeflateRect(rect);
    8186    Draw3DRect(hps,*rect,clrLight,clrLight);
    82   } else if (dwExStyle & WS_EX_STATICEDGE_W)
     87  }
     88  else if (dwExStyle & WS_EX_STATICEDGE_W)
    8389  {
    8490    Draw3DRect(hps,*rect,clrWhite,clrDark);
    85   } else if (dwExStyle & WS_EX_WINDOWEDGE_W);
     91  }
     92  else if (dwExStyle & WS_EX_WINDOWEDGE_W);
    8693  else if (dwStyle & WS_BORDER_W)
    8794  {
     
    9198  DeflateRect(rect);
    9299}
    93 
     100//******************************************************************************
     101//******************************************************************************
    94102BOOL CanDrawSizeBox(Win32BaseWindow *win32wnd)
    95103{
     
    98106          && win32wnd->getHorzScrollHandle() && WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle());
    99107}
    100 
     108//******************************************************************************
     109//******************************************************************************
    101110VOID GetSizeBox(Win32BaseWindow *win32wnd,RECTL *rect)
    102111{
     
    110119  rect->yBottom = swpHorz.y;
    111120}
    112 
     121//******************************************************************************
     122//******************************************************************************
    113123BOOL InSizeBox(Win32BaseWindow *win32wnd,POINTS *points)
    114124{
     
    126136  return FALSE;
    127137}
    128 
     138//******************************************************************************
     139//******************************************************************************
    129140VOID DrawSizeBox(HPS hps,RECTL rect)
    130141{
     
    156167  }
    157168}
    158 
     169//******************************************************************************
     170//******************************************************************************
     171void DrawActivate(Win32BaseWindow *win32wnd, HWND hwnd)
     172{
     173    if (!win32wnd->isChild())
     174    {
     175        if (CanDrawSizeBox(win32wnd))
     176        {
     177          HPS hps;
     178          RECTL rect;
     179
     180          GetSizeBox(win32wnd,&rect);
     181          hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
     182          DrawSizeBox(hps,rect);
     183          WinReleasePS(hps);
     184
     185        }
     186    }
     187    else
     188    {
     189        HPS hps;
     190        RECTL rect;
     191
     192        WinQueryWindowRect(hwnd,&rect);
     193        rect.xRight = rect.xRight-rect.xLeft;
     194        rect.yTop = rect.yTop-rect.yBottom;
     195        rect.xLeft = rect.yBottom = 0;
     196        hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
     197        DrawFrame(hps,&rect,win32wnd);
     198        WinReleasePS(hps);
     199    }
     200}
    159201//******************************************************************************
    160202//Win32 frame message handler
     
    180222  switch(msg)
    181223  {
    182 #if 0
     224#if 1
    183225    case WM_ADJUSTWINDOWPOS:
    184226    {
     
    186228      SWP      swpOld;
    187229      WINDOWPOS wp;
    188       ULONG     parentHeight = 0;
    189       HWND      hParent = NULLHANDLE, hFrame = NULLHANDLE, hwndAfter;
    190 
    191         dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", hwnd, pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     230      HWND      hParent = NULLHANDLE, hwndAfter;
     231
     232        dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    192233
    193234        if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
    194235            goto RunDefFrameProc;
     236
    195237        if(!win32wnd->CanReceiveSizeMsgs()) {
    196             goto RunDefFrameProc;
     238            break;
    197239        }
    198240
     
    208250        }
    209251        hwndAfter = pswp->hwndInsertBehind;
    210         hFrame = win32wnd->getOS2FrameWindowHandle();
    211         OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hFrame);
     252        OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
    212253
    213254        wp.hwnd = win32wnd->getWindowHandle();
     
    219260        if(win32wnd->MsgPosChanging((LPARAM)&wp) == 0)
    220261        {//app or default window handler changed wp
    221             dprintf(("OS2: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
     262            dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
    222263            dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    223             OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, hParent, hFrame);
     264            OSLibMapWINDOWPOStoSWPFrame(&wp, pswp, &swpOld, hParent, hwnd);
    224265            dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    225266            pswp->fl |= SWP_NOADJUST;
    226267            pswp->hwndInsertBehind = hwndAfter;
    227             pswp->hwnd = hFrame;
     268            pswp->hwnd = hwnd;
    228269
    229270            RestoreOS2TIB();
     
    233274    }
    234275
     276    case WM_WINDOWPOSCHANGED:
     277    {
     278      PSWP      pswp   = (PSWP)mp1;
     279      SWP       swpOld = *(pswp + 1);
     280      WINDOWPOS wp;
     281      HWND      hParent = NULLHANDLE;
     282      LONG      yDelta = pswp->cy - swpOld.cy;
     283      LONG      xDelta = pswp->cx - swpOld.cx;
     284
     285        dprintf(("PMFRAME: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     286
     287        RestoreOS2TIB();
     288        rc = OldFrameProc(hwnd,msg,mp1,mp2);
     289        SetWin32TIB();
     290
     291        if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
     292            goto PosChangedEnd;
     293
     294        if(!win32wnd->CanReceiveSizeMsgs())
     295            goto PosChangedEnd;
     296
     297        if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
     298            if (win32wnd->isChild()) {
     299                if(win32wnd->getParent()) {
     300                        hParent = win32wnd->getParent()->getOS2WindowHandle();
     301                }
     302                else    goto PosChangedEnd; //parent has just been destroyed
     303            }
     304        }
     305        OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
     306
     307        //delta is difference between old and new client height
     308        yDelta = swpOld.cy - win32wnd->getWindowHeight();
     309
     310        win32wnd->setWindowRect(wp.x, wp.y, wp.x+wp.cx, wp.y+wp.cy);
     311        win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
     312
     313        wp.hwnd = win32wnd->getWindowHandle();
     314        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
     315        {
     316           Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     317           if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
     318        }
     319
     320        if (yDelta != 0 || xDelta != 0)
     321        {
     322            HENUM henum = WinBeginEnumWindows(WinWindowFromID(pswp->hwnd, FID_CLIENT));
     323            SWP swp[10];
     324            int i = 0;
     325            HWND hwnd;
     326
     327            while ((hwnd = WinGetNextWindow(henum)) != NULLHANDLE)
     328            {
     329#if 0
     330                if (mdiClient )
     331                {
     332                  continue;
     333                }
     334#endif
     335                WinQueryWindowPos(hwnd, &(swp[i]));
     336
     337#ifdef DEBUG
     338                Win32BaseWindow *window = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     339                dprintf(("ENUMERATE %x delta %d (%d,%d) (%d,%d) %x", (window) ? window->getWindowHandle() : hwnd,
     340                         yDelta, swp[i].x, swp[i].y, swp[i].cx, swp[i].cy, swp[i].fl));
     341#endif
     342
     343                if(swp[i].y != 0) {
     344                    //child window at offset <> 0 from client area -> offset now changes
     345                    swp[i].y  += yDelta;
     346                    swp[i].fl &= ~(SWP_NOREDRAW);
     347                }
     348                //else child window with the same start coorindates as the client area
     349                //The app should resize it.
     350
     351               if (i == 9)
     352                {
     353                    WinSetMultWindowPos(GetThreadHAB(), swp, 10);
     354                    i = 0;
     355                }
     356                else
     357                {
     358                    i++;
     359                }
     360            }
     361
     362            WinEndEnumWindows(henum);
     363
     364            if (i)
     365               WinSetMultWindowPos(GetThreadHAB(), swp, i);
     366        }
     367        if (yDelta != 0)
     368        {
     369            POINT pt;
     370            if(GetCaretPos (&pt) == TRUE)
     371            {
     372                pt.y -= yDelta;
     373                SetCaretPos (pt.x, pt.y);
     374            }
     375        }
     376        win32wnd->MsgPosChanged((LPARAM)&wp);
     377
     378PosChangedEnd:
     379        return rc;
     380    }
     381#if 0
     382    case WM_ENABLE:
     383        dprintf(("PMFRAME: WM_ENABLE %x", win32wnd->getWindowHandle()));
     384        win32wnd->MsgEnable(SHORT1FROMMP(mp1));
     385        goto RunDefFrameProc;
     386
     387    case WM_SHOW:
     388        dprintf(("PMFRAME: WM_SHOW %x %d", win32wnd->getWindowHandle(), mp1));
     389        win32wnd->MsgShow((ULONG)mp1);
     390        goto RunDefFrameProc;
     391
     392    case WM_ACTIVATE:
     393    {
     394      HWND hwndActivate = (HWND)mp2;
     395      BOOL fMinimized = FALSE;
     396
     397        dprintf(("PMFRAME: WM_ACTIVATE %x %x", hwnd, hwndActivate));
     398        if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
     399                //another (non-win32) application's window
     400                //set to NULL (allowed according to win32 SDK) to avoid problems
     401                hwndActivate = NULL;
     402        }
     403        if(WinQueryWindowULong(hwnd, QWL_STYLE) & WS_MINIMIZED)
     404        {
     405           fMinimized = TRUE;
     406        }
     407
     408        win32wnd->MsgActivate(SHORT1FROMMP(mp1), fMinimized, Win32BaseWindow::OS2ToWin32Handle(hwndActivate));
     409
     410        RestoreOS2TIB();
     411        MRESULT rc = OldFrameProc(hwnd,msg,mp1,mp2);
     412        DrawActivate(win32wnd, hwnd);
     413        return rc;
     414    }
     415#else
     416    case WM_ACTIVATE:
     417        DrawActivate(win32wnd, hwnd);
     418        goto RunDefFrameProc;
     419#endif
    235420#else
    236421    case WM_ADJUSTWINDOWPOS:
     
    242427      if(wndchild && wndchild->isChild())
    243428      {
     429#if 0
     430       SWP swp = *pswp;
     431
     432        MRESULT rc = OldFrameProc(hwnd, msg, mp1, mp2);
     433        pswp->x = swp.x;
     434        pswp->y = swp.y;
     435        pswp->fl = swp.fl;
     436#endif
    244437        dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", hwnd, pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    245438        RestoreOS2TIB();
     
    249442    }
    250443
     444    case WM_ACTIVATE:
     445        DrawActivate(win32wnd, hwnd);
     446        goto RunDefFrameProc;
    251447#endif
    252448
     
    265461        RestoreOS2TIB();
    266462        return (MRESULT)TRUE;
    267       } else if (win32wnd->isChild()) goto RunDefWndProc;
     463      }
     464      else if (win32wnd->isChild()) goto RunDefWndProc;
    268465      else goto RunDefFrameProc;
    269466
     
    277474        RestoreOS2TIB();
    278475        return (MRESULT)TRUE;
    279       } else if (win32wnd->isChild()) goto RunDefWndProc;
     476      }
     477      else if (win32wnd->isChild()) goto RunDefWndProc;
    280478      else goto RunDefFrameProc;
    281479
     
    288486      else goto RunDefFrameProc;
    289487
    290     case WM_ACTIVATE:
     488    case WM_PAINT:
    291489      #ifdef PMFRAMELOG
    292        dprintf(("PMFRAME: WM_ACTIVATE"));
     490       dprintf(("PMFRAME: WM_PAINT"));
    293491      #endif
    294492      if (!win32wnd->isChild())
     
    311509          RestoreOS2TIB();
    312510          return res;
    313         } else goto RunDefFrameProc;
    314       } else
     511        }
     512        else goto RunDefFrameProc;
     513      }
     514      else
    315515      {
    316         MRESULT res;
     516        RECTL rect;
    317517        HPS hps;
    318         RECTL rect;
    319 
    320         RestoreOS2TIB();
    321         res = OldFrameProc(hwnd,msg,mp1,mp2);
     518
     519        RestoreOS2TIB();
     520        OldFrameProc(hwnd,msg,mp1,mp2);
    322521        SetWin32TIB();
    323522
     
    331530
    332531        RestoreOS2TIB();
    333         return res;
    334       }
    335 
    336     case WM_PAINT:
    337       #ifdef PMFRAMELOG
    338        dprintf(("PMFRAME: WM_PAINT"));
    339       #endif
    340       if (!win32wnd->isChild())
    341       {
    342         if (CanDrawSizeBox(win32wnd))
    343         {
    344           MRESULT res;
    345           HPS hps;
    346           RECTL rect;
    347 
    348           RestoreOS2TIB();
    349           res = OldFrameProc(hwnd,msg,mp1,mp2);
    350           SetWin32TIB();
    351 
    352           GetSizeBox(win32wnd,&rect);
    353           hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
    354           DrawSizeBox(hps,rect);
    355           WinReleasePS(hps);
    356 
    357           RestoreOS2TIB();
    358           return res;
    359         } else goto RunDefFrameProc;
    360       } else
    361       {
    362         RECTL rect;
    363         HPS hps;
    364 
    365         RestoreOS2TIB();
    366         OldFrameProc(hwnd,msg,mp1,mp2);
    367         SetWin32TIB();
    368 
    369         WinQueryWindowRect(hwnd,&rect);
    370         rect.xRight = rect.xRight-rect.xLeft;
    371         rect.yTop = rect.yTop-rect.yBottom;
    372         rect.xLeft = rect.yBottom = 0;
    373         hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
    374         DrawFrame(hps,&rect,win32wnd);
    375         WinReleasePS(hps);
    376 
    377         RestoreOS2TIB();
    378532        return (MRESULT)0;
    379533      }
Note: See TracChangeset for help on using the changeset viewer.