Ignore:
Timestamp:
May 11, 2001, 10:39:46 AM (24 years ago)
Author:
sandervl
Message:

client/frame rewrite

File:
1 edited

Legend:

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

    r5512 r5685  
    1 /* $Id: oslibwin.cpp,v 1.91 2001-04-15 17:05:29 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.92 2001-05-11 08:39:43 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, 
     55                          char *pszName, HWND Owner, ULONG fHWND_BOTTOM,
    5656                          ULONG id, BOOL fTaskList,BOOL fShellPosition,
    57                           int classStyle)
     57                          int classStyle, HWND *hwndFrame)
    5858{
    5959 HWND  hwndClient;
    6060 ULONG dwFrameStyle = 0;
    6161
    62   if(pszName && *pszName == 0) {
     62    if(pszName && *pszName == 0) {
    6363        pszName = NULL;
    64   }
    65   if(hwndParent == OSLIB_HWND_DESKTOP) {
     64    }
     65    if(hwndParent == OSLIB_HWND_DESKTOP) {
    6666        hwndParent = HWND_DESKTOP;
    67   }
    68   if(Owner == OSLIB_HWND_DESKTOP) {
     67    }
     68    if(Owner == OSLIB_HWND_DESKTOP) {
    6969        Owner = HWND_DESKTOP;
    70   }
    71 
    72   if(classStyle & CS_SAVEBITS_W) dwWinStyle |= WS_SAVEBITS;
    73   if(classStyle & CS_PARENTDC_W) dwWinStyle |= WS_PARENTCLIP;
    74 
    75   dwWinStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
    76 
    77   if(fTaskList)
    78   {
    79         dwFrameStyle |= FCF_NOMOVEWITHOWNER;
    80   }
    81   if (fShellPosition) dwFrameStyle |= FCF_SHELLPOSITION;
    82 
    83   FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
    84   FCData.flCreateFlags = dwFrameStyle;
    85 
    86   dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x winstyle %x bottom %d", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle, dwWinStyle, fHWND_BOTTOM));
    87 
    88   return WinCreateWindow (hwndParent,
    89                           (hwndParent == HWND_DESKTOP) ? WIN32_STDFRAMECLASS : WIN32_STDCLASS,
    90                           pszName, dwWinStyle, 0, 0, 0, 0,
    91                           Owner, (fHWND_BOTTOM) ? HWND_BOTTOM : HWND_TOP,
    92                           id, NULL, NULL);
     70    }
     71
     72    if(classStyle & CS_SAVEBITS_W) dwWinStyle |= WS_SAVEBITS;
     73    if(classStyle & CS_PARENTDC_W) dwWinStyle |= WS_PARENTCLIP;
     74
     75    dwWinStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
     76
     77    if(fTaskList)
     78    {
     79        dwFrameStyle |= FCF_NOMOVEWITHOWNER;
     80    }
     81    if (fShellPosition) dwFrameStyle |= FCF_SHELLPOSITION;
     82
     83    FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
     84    FCData.flCreateFlags = dwFrameStyle;
     85
     86    dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x winstyle %x bottom %d", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle, dwWinStyle, fHWND_BOTTOM));
     87
     88    //Must not use WS_CLIPCHILDREN style with frame window. Transparency won't work otherwise.
     89    //Eg: dialog parent, groupbox; invalidate part of groupbox -> painting algorithm stops when it finds
     90    //    a window with WS_CLIPCHILDREN -> result: dialog window won't update groupbox background as groupbox only draws the border
     91    *hwndFrame = WinCreateWindow(hwndParent,
     92                           WIN32_STDFRAMECLASS,
     93                           pszName, (dwWinStyle & ~WS_CLIPCHILDREN), 0, 0, 0, 0,
     94                           Owner, (fHWND_BOTTOM) ? HWND_BOTTOM : HWND_TOP,
     95                           id, NULL, NULL);
     96    hwndClient = WinCreateWindow (*hwndFrame, WIN32_STDCLASS,
     97                              NULL, dwWinStyle | WS_VISIBLE, 0, 0, 0, 0,
     98                              *hwndFrame, HWND_TOP, FID_CLIENT, NULL, NULL);
     99    return hwndClient;
    93100}
    94101//******************************************************************************
     
    294301  rc = WinSetActiveWindow(HWND_DESKTOP, hwnd);
    295302  if(rc == FALSE) {
    296         dprintf(("WinSetActiveWindow %x failure: %x", hwnd, OSLibWinGetLastError()));
     303    dprintf(("WinSetActiveWindow %x failure: %x", hwnd, OSLibWinGetLastError()));
    297304  }
    298305  return rc;
     
    394401//******************************************************************************
    395402//******************************************************************************
    396 void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld,
    397                             int parentHeight, int clientOrgX, int clientOrgY,
    398                             HWND hwnd)
     403void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld,
     404                            int parentHeight, HWND hwnd)
    399405{
    400406   HWND hWindow            = pswp->hwnd;
    401407   HWND hWndInsertAfter    = pswp->hwndInsertBehind;
    402    long x                  = pswp->x - clientOrgX;
    403    long y                  = pswp->y + clientOrgY;
     408   long x                  = pswp->x;
     409   long y                  = pswp->y;
    404410   long cx                 = pswp->cx;
    405411   long cy                 = pswp->cy;
     
    467473//******************************************************************************
    468474//******************************************************************************
    469 void OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld, 
    470                             int parentHeight, int clientOrgX, int clientOrgY, HWND hFrame)
     475void OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld,
     476                            int parentHeight, HWND hFrame)
    471477{
    472478 BOOL fCvt = FALSE;
     
    474480   HWND hWnd            = pwpos->hwnd;
    475481   HWND hWndInsertAfter = pwpos->hwndInsertAfter;
    476    long x               = pwpos->x + clientOrgX;
    477    long y               = pwpos->y + clientOrgY;
     482   long x               = pwpos->x;
     483   long y               = pwpos->y;
    478484   long cx              = pwpos->cx;
    479485   long cy              = pwpos->cy;
     
    546552}
    547553//******************************************************************************
    548 //Position in screen coordinates
     554//******************************************************************************
     555void OSLibWinSetClientPos(HWND hwnd, int x, int y, int cx, int cy, int parentHeight)
     556{
     557 SWP swp;
     558 BOOL rc;
     559
     560   swp.hwnd = hwnd;
     561   swp.hwndInsertBehind = 0;
     562   swp.x  = x;
     563   swp.y  = parentHeight - y - cy;
     564   swp.cx = cx;
     565   swp.cy = cy;
     566   swp.fl = SWP_MOVE | SWP_SIZE;
     567
     568   dprintf(("OSLibWinSetClientPos (%d,%d) (%d,%d) -> (%d,%d) (%d,%d)", x, y, x+cx, y+cy, swp.x, swp.y, swp.x+swp.cx, swp.y+swp.cy));
     569
     570   rc = WinSetMultWindowPos(GetThreadHAB(), &swp, 1);
     571   if(rc == FALSE) {
     572        dprintf(("OSLibWinSetClientPos: WinSetMultWindowPos %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
     573   }
     574}
     575//******************************************************************************
    549576//******************************************************************************
    550577BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
     
    716743//******************************************************************************
    717744//******************************************************************************
    718 void OSLibSetWindowStyle(HWND hwnd, ULONG dwStyle, ULONG dwExStyle)
    719 {
    720   ULONG dwWinStyle = WinQueryWindowULong(hwnd, QWL_STYLE);
    721   ULONG dwOldWinStyle = dwWinStyle;
    722 
    723   if(dwStyle & WS_DISABLED_W) {
    724         dwWinStyle |= WS_DISABLED;
    725   }
    726   else  dwWinStyle &= ~WS_DISABLED;
    727 
    728   if(dwStyle & WS_CLIPSIBLINGS_W) {
    729         dwWinStyle |= WS_CLIPSIBLINGS;
    730   }
    731   else  dwWinStyle &= ~WS_CLIPSIBLINGS;
    732 
    733   if(dwStyle & WS_CLIPCHILDREN_W) {
    734         dwWinStyle |= WS_CLIPCHILDREN;
    735   }
    736   else  dwWinStyle &= ~WS_CLIPCHILDREN;
    737 
    738   if(dwWinStyle != dwOldWinStyle) {
    739       WinSetWindowULong(hwnd, QWL_STYLE, dwWinStyle);
    740   }
     745void OSLibSetWindowStyle(HWND hwndFrame, HWND hwndClient, ULONG dwStyle, ULONG dwExStyle)
     746{
     747    ULONG dwWinStyle;
     748    ULONG dwOldWinStyle;
     749
     750    //client window:
     751    dwWinStyle    = WinQueryWindowULong(hwndClient, QWL_STYLE);
     752    dwOldWinStyle = dwWinStyle;
     753
     754    if(dwStyle & WS_CLIPCHILDREN_W) {
     755         dwWinStyle |= WS_CLIPCHILDREN;
     756    }
     757    else dwWinStyle &= ~WS_CLIPCHILDREN;
     758
     759    if(dwWinStyle != dwOldWinStyle) {
     760        WinSetWindowULong(hwndClient, QWL_STYLE, dwWinStyle);
     761    }
     762
     763    //Frame window
     764    dwWinStyle    = WinQueryWindowULong(hwndFrame, QWL_STYLE);
     765    dwOldWinStyle = dwWinStyle;
     766    if(dwStyle & WS_DISABLED_W) {
     767         dwWinStyle |= WS_DISABLED;
     768    }
     769    else dwWinStyle &= ~WS_DISABLED;
     770
     771    if(dwStyle & WS_CLIPSIBLINGS_W) {
     772         dwWinStyle |= WS_CLIPSIBLINGS;
     773    }
     774    else dwWinStyle &= ~WS_CLIPSIBLINGS;
     775
     776    if(dwWinStyle != dwOldWinStyle) {
     777      WinSetWindowULong(hwndFrame, QWL_STYLE, dwWinStyle);
     778    }
    741779}
    742780//******************************************************************************
     
    744782DWORD OSLibQueryWindowStyle(HWND hwnd)
    745783{
    746   return WinQueryWindowULong(hwnd, QWL_STYLE);
     784    return WinQueryWindowULong(hwnd, QWL_STYLE);
    747785}
    748786//******************************************************************************
     
    750788void OSLibWinSetVisibleRegionNotify(HWND hwnd, BOOL fNotify)
    751789{
    752   WinSetVisibleRegionNotify(hwnd, fNotify);
     790    WinSetVisibleRegionNotify(hwnd, fNotify);
    753791}
    754792//******************************************************************************
     
    756794HWND OSLibWinQueryCapture()
    757795{
    758   return WinQueryCapture(HWND_DESKTOP);
     796    return WinQueryCapture(HWND_DESKTOP);
    759797}
    760798//******************************************************************************
     
    762800BOOL OSLibWinSetCapture(HWND hwnd)
    763801{
    764   return WinSetCapture(HWND_DESKTOP, hwnd);
     802    return WinSetCapture(HWND_DESKTOP, hwnd);
    765803}
    766804//******************************************************************************
     
    768806BOOL OSLibWinRemoveFromTasklist(HANDLE hTaskList)
    769807{
    770   return (WinRemoveSwitchEntry(hTaskList)) ? FALSE : TRUE;
     808    return (WinRemoveSwitchEntry(hTaskList)) ? FALSE : TRUE;
    771809}
    772810//******************************************************************************
     
    774812HANDLE OSLibWinAddToTaskList(HWND hwndFrame, char *title, BOOL fVisible)
    775813{
    776  SWCNTRL swctrl;
    777  ULONG   tid;
    778 
    779   swctrl.hwnd          = hwndFrame;
    780   swctrl.hwndIcon      = 0;
    781   swctrl.hprog         = 0;
    782   WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
    783   swctrl.idSession     = 0;
    784   swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
    785   swctrl.fbJump        = SWL_JUMPABLE;
    786   swctrl.bProgType     = PROG_PM;
    787   if(title) {
    788         strncpy(swctrl.szSwtitle, title, MAXNAMEL+4);
    789         swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
    790   }
    791   else {
    792         swctrl.szSwtitle[0] = 0;
    793         swctrl.uchVisibility    = SWL_INVISIBLE;
    794   }
    795   return WinAddSwitchEntry(&swctrl);
     814    SWCNTRL swctrl;
     815    ULONG   tid;
     816
     817    swctrl.hwnd          = hwndFrame;
     818    swctrl.hwndIcon      = 0;
     819    swctrl.hprog         = 0;
     820    WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
     821    swctrl.idSession     = 0;
     822    swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
     823    swctrl.fbJump        = SWL_JUMPABLE;
     824    swctrl.bProgType     = PROG_PM;
     825    if(title) {
     826        strncpy(swctrl.szSwtitle, title, MAXNAMEL+4);
     827        swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
     828    }
     829    else {
     830        swctrl.szSwtitle[0] = 0;
     831        swctrl.uchVisibility    = SWL_INVISIBLE;
     832    }
     833    return WinAddSwitchEntry(&swctrl);
    796834}
    797835//******************************************************************************
     
    799837BOOL OSLibWinChangeTaskList(HANDLE hTaskList, HWND hwndFrame, char *title, BOOL fVisible)
    800838{
    801  SWCNTRL swctrl;
    802  ULONG   tid;
    803  
    804   swctrl.hwnd          = hwndFrame;
    805   swctrl.hwndIcon      = 0;
    806   swctrl.hprog         = 0;
    807   WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
    808   swctrl.idSession     = 0;
    809   swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
    810   swctrl.fbJump        = SWL_JUMPABLE;
    811   swctrl.bProgType     = PROG_PM;
    812   if(title) {
    813         strncpy(swctrl.szSwtitle, title, MAXNAMEL+4);
    814         swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
    815   }
    816   else {
    817         swctrl.szSwtitle[0] = 0;
    818         swctrl.uchVisibility    = SWL_INVISIBLE;
    819   }
    820   return (WinChangeSwitchEntry(hTaskList, &swctrl)) ? FALSE : TRUE;
     839    SWCNTRL swctrl;
     840    ULONG   tid;
     841
     842    swctrl.hwnd          = hwndFrame;
     843    swctrl.hwndIcon      = 0;
     844    swctrl.hprog         = 0;
     845    WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
     846    swctrl.idSession     = 0;
     847    swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
     848    swctrl.fbJump        = SWL_JUMPABLE;
     849    swctrl.bProgType     = PROG_PM;
     850    if(title) {
     851        strncpy(swctrl.szSwtitle, title, MAXNAMEL+4);
     852        swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
     853    }
     854    else {
     855        swctrl.szSwtitle[0] = 0;
     856        swctrl.uchVisibility    = SWL_INVISIBLE;
     857    }
     858    return (WinChangeSwitchEntry(hTaskList, &swctrl)) ? FALSE : TRUE;
    821859}
    822860//******************************************************************************
     
    824862BOOL OSLibWinLockWindowUpdate(HWND hwnd)
    825863{
    826   return WinLockWindowUpdate(HWND_DESKTOP, (HWND)hwnd);
     864    return WinLockWindowUpdate(HWND_DESKTOP, (HWND)hwnd);
    827865}
    828866//******************************************************************************
     
    830868ULONG OSLibGetScreenHeight()
    831869{
    832   return ScreenHeight;
     870    return ScreenHeight;
    833871}
    834872//******************************************************************************
     
    836874ULONG OSLibGetScreenWidth()
    837875{
    838   return ScreenWidth;
     876    return ScreenWidth;
    839877}
    840878//******************************************************************************
     
    845883{
    846884 SWP  swp;
    847  
    848   if(!WinGetMaxPosition(hwndOS2, &swp)) {
    849         dprintf(("WARNING: WinGetMaxPosition %x returned FALSE", hwndOS2));
    850         return FALSE;
    851   }
    852   rect->left   = swp.x;
    853   rect->right  = swp.x + swp.cx;
    854   rect->top    = ScreenHeight - (swp.y + swp.cy);
    855   rect->bottom = ScreenHeight - swp.y;
    856   return TRUE;
     885
     886    if(!WinGetMaxPosition(hwndOS2, &swp)) {
     887        dprintf(("WARNING: WinGetMaxPosition %x returned FALSE", hwndOS2));
     888        return FALSE;
     889    }
     890    rect->left   = swp.x;
     891    rect->right  = swp.x + swp.cx;
     892    rect->top    = ScreenHeight - (swp.y + swp.cy);
     893    rect->bottom = ScreenHeight - swp.y;
     894    return TRUE;
    857895}
    858896//******************************************************************************
     
    860898BOOL OSLibWinShowPointer(BOOL fShow)
    861899{
    862   return WinShowPointer(HWND_DESKTOP, fShow);
    863 }
    864 //******************************************************************************
    865 //******************************************************************************
     900    return WinShowPointer(HWND_DESKTOP, fShow);
     901}
     902//******************************************************************************
     903//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.