Changeset 12841


Ignore:
Timestamp:
Dec 29, 1999, 11:54:04 PM (25 years ago)
Author:
cbratschi
Message:

new mapping functions, fixed 1 pixel and window handle bugs

Location:
tags/trunk/src/user32
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified tags/trunk/src/user32/caret.cpp

    r12530 r12841  
    1 /* $Id: caret.cpp,v 1.8 1999-12-02 16:34:43 cbratschi Exp $ */
     1/* $Id: caret.cpp,v 1.9 1999-12-29 22:53:59 cbratschi Exp $ */
    22
    33/*
     
    148148        else
    149149        {
    150            long height = wnd->getWindowHeight();
     150           long height = wnd->getClientHeight();
    151151           caretPos.y = height - caretPos.y - 1;
    152152           xNew = caretPos.x;
     
    197197            cursorInfo.y = caretPos.y;
    198198         } else {
    199             long height  = wnd->getWindowHeight();
     199            long height  = wnd->getClientHeight();
    200200            caretPos.y  += cursorInfo.cy;
    201201            cursorInfo.y = height - caretPos.y - 1;
  • TabularUnified tags/trunk/src/user32/dc.cpp

    r12786 r12841  
    1 /* $Id: dc.cpp,v 1.30 1999-12-24 21:44:03 sandervl Exp $ */
     1/* $Id: dc.cpp,v 1.31 1999-12-29 22:53:59 cbratschi Exp $ */
    22
    33/*
     
    302302   {
    303303      if (wnd)
    304          return (wnd->getWindowHeight());
     304         return (wnd->getClientHeight());
    305305      else
    306306         return OSLibQueryScreenHeight();
     
    437437
    438438   if(hWnd == 0x6800003a) {
    439         hwnd = 0x6800003a;
     439        hwnd = 0x6800003a;
    440440   }
    441441   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    443443   if ((hwnd != HWND_DESKTOP) && wnd->isOwnDC())
    444444   {
    445         hPS_ownDC = wnd->getOwnDC();
    446         //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
    447         if(hPS_ownDC) {
    448                 pHps = (pDCData)GpiQueryDCData(hPS_ownDC);
    449                 if (!pHps)
    450                 {
    451                         O32_SetLastError (ERROR_INVALID_PARAMETER);
    452                         return (HDC)NULLHANDLE;
    453                 }
    454         }
     445        hPS_ownDC = wnd->getOwnDC();
     446        //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
     447        if(hPS_ownDC) {
     448                pHps = (pDCData)GpiQueryDCData(hPS_ownDC);
     449                if (!pHps)
     450                {
     451                        O32_SetLastError (ERROR_INVALID_PARAMETER);
     452                        return (HDC)NULLHANDLE;
     453                }
     454        }
    455455   }
    456456
     
    473473
    474474   if(!wnd->isSuppressErase()) {
    475         wnd->setSuppressErase(TRUE);
     475        wnd->setSuppressErase(TRUE);
    476476        wnd->setEraseBkgnd (FALSE, !wnd->MsgEraseBackGround(lpps->hdc));
    477477   }
     
    480480   if (!hPS_ownDC)
    481481   {
    482       long height  = wnd->getWindowHeight();
     482      long height  = wnd->getClientHeight();
    483483      rect.yTop    = height - rect.yTop;
    484484      rect.yBottom = height - rect.yBottom;
     
    531531BOOL WIN32API GetUpdateRect (HWND hwnd, LPRECT pRect, BOOL erase)
    532532{
    533    if (hwnd)
     533   if (!hwnd)
    534534   {
    535535      O32_SetLastError (ERROR_INVALID_HANDLE);
     
    540540   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    541541
    542    BOOL updateRegionExists = WinQueryUpdateRect (hwnd, pRect ? &rectl : NULL);
     542   if (!wnd)
     543   {
     544      O32_SetLastError (ERROR_INVALID_HANDLE);
     545      return FALSE;
     546   }
     547
     548   BOOL updateRegionExists = WinQueryUpdateRect (wnd->getOS2WindowHandle(), pRect ? &rectl : NULL);
    543549   if (!pRect) {
    544550      return (updateRegionExists);
     
    562568      else
    563569      {
    564          long height   = wnd->getWindowHeight();
     570         long height   = wnd->getClientHeight();
    565571         rectl.yTop    = height - rectl.yTop;
    566572         rectl.yBottom = height - rectl.yBottom;
     
    586592   LONG Complexity;
    587593
    588    Complexity = O32_GetUpdateRgn (hwnd, hrgn, FALSE);
    589    if (erase && (Complexity > NULLREGION_W)) {
    590        Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    591        sendEraseBkgnd (wnd);
    592    }
     594   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     595
     596   if (!wnd)
     597   {
     598      O32_SetLastError (ERROR_INVALID_HANDLE);
     599      return ERROR_W;
     600   }
     601
     602   Complexity = O32_GetUpdateRgn (wnd->getOS2WindowHandle(), hrgn, FALSE);
     603   if (erase && (Complexity > NULLREGION_W)) sendEraseBkgnd (wnd);
    593604
    594605   return Complexity;
     
    615626   if (hwnd)
    616627   {
    617         wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    618         if(wnd == NULL) {
    619                 dprintf (("ERROR: User32: GetDCEx bad window handle %X!!!!!", hwnd));
    620                 O32_SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    621                 return 0;
    622         }
     628        wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     629        if(wnd == NULL) {
     630                dprintf (("ERROR: User32: GetDCEx bad window handle %X!!!!!", hwnd));
     631                O32_SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     632                return 0;
     633        }
    623634//SvL: Experimental change (doesn't work right)
    624635#if 0
    625         if(wnd->fHasParentDC() && wnd->getParent()) {
    626                 wnd = wnd->getParent();
    627         }
     636        if(wnd->fHasParentDC() && wnd->getParent()) {
     637                wnd = wnd->getParent();
     638        }
    628639#endif
    629         if (flags & DCX_WINDOW_W)
    630                 hWindow = wnd->getOS2FrameWindowHandle();
    631         else
    632                 hWindow = wnd->getOS2WindowHandle();
     640        if (flags & DCX_WINDOW_W)
     641                hWindow = wnd->getOS2FrameWindowHandle();
     642        else
     643                hWindow = wnd->getOS2WindowHandle();
    633644   }
    634645   else
     
    906917      PRECTL pr;
    907918      int i;
    908       LONG height = wnd ? wnd->getWindowHeight() : OSLibQueryScreenHeight();
     919      LONG height = wnd ? wnd->getClientHeight() : OSLibQueryScreenHeight();
    909920
    910921      if (!hrgn)
     
    930941   else if (pRect)
    931942   {
    932       LONG height = wnd ? wnd->getWindowHeight() : OSLibQueryScreenHeight();
     943      LONG height = wnd ? wnd->getClientHeight() : OSLibQueryScreenHeight();
    933944
    934945      PMRECT_FROM_WINRECT (rectl, *pRect);
     
    11971208
    11981209   RECT winRectUpdate;
    1199    LONG height = wnd->getWindowHeight();
     1210   LONG height = wnd->getClientHeight();
    12001211
    12011212   winRectUpdate.left   = rectlUpdate.xLeft;
     
    12321243    }
    12331244    dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
    1234     MapWin32ToOS2Rectl(window->getOS2WindowHandle(),window->getClientRect(), (PRECTLOS2)&clientRect);
     1245    mapWin32ToOS2Rect(window,window->getClientRect(), (PRECTLOS2)&clientRect);
    12351246    //Rectangle could be relative to parent window, so fix this
    12361247    if(clientRect.yBottom != 0) {
     
    12431254    }
    12441255    if(pScroll) {
    1245          MapWin32ToOS2Rectl(window->getOS2WindowHandle(),(RECT *)pScroll, (PRECTLOS2)&scrollRect);
     1256         mapWin32ToOS2Rect(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);
    12461257         pScrollRect = &scrollRect;
    12471258
     
    12561267
    12571268    if(pClip) {
    1258          MapWin32ToOS2Rectl(window->getOS2WindowHandle(),(RECT *)pClip, (PRECTLOS2)&clipRect);
     1269         mapWin32ToOS2Rect(window,(RECT *)pClip, (PRECTLOS2)&clipRect);
    12591270         pClipRect = &clipRect;
    12601271
     
    13001311    if (scrollFlag & SW_SCROLLCHILDREN_W)  scrollFlags |= SW_SCROLLCHILDREN;
    13011312
    1302     if(pScroll) MapWin32ToOS2Rectl(window->getOS2WindowHandle(),(RECT *)pScroll, (PRECTLOS2)&scrollRect);
    1303     if(pClip)   MapWin32ToOS2Rectl(window->getOS2WindowHandle(),(RECT *)pClip, (PRECTLOS2)&clipRect);
     1313    if(pScroll) mapWin32ToOS2Rect(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);
     1314    if(pClip)   mapWin32ToOS2Rect(window,(RECT *)pClip, (PRECTLOS2)&clipRect);
    13041315
    13051316    RECTL rectlUpdate;
     
    13241335
    13251336    RECT winRectUpdate;
    1326     LONG height = window->getWindowHeight();
     1337    LONG height = window->getClientHeight();
    13271338
    13281339    winRectUpdate.left   = rectlUpdate.xLeft;
     
    13911402{
    13921403    if(lprc) {
    1393         dprintf(("USER32: ValidateRect %x (%d,%d)(%d,%d)", hwnd, lprc->left, lprc->top, lprc->right, lprc->bottom));
    1394     } 
    1395     else dprintf(("USER32: ValidateRect %x", hwnd)); 
    1396    
     1404        dprintf(("USER32: ValidateRect %x (%d,%d)(%d,%d)", hwnd, lprc->left, lprc->top, lprc->right, lprc->bottom));
     1405    }
     1406    else dprintf(("USER32: ValidateRect %x", hwnd));
     1407
    13971408    return RedrawWindow( hwnd, lprc, 0, RDW_VALIDATE_W | RDW_NOCHILDREN_W | (hwnd==0 ? RDW_UPDATENOW_W : 0));
    13981409}
  • TabularUnified tags/trunk/src/user32/edit.cpp

    r12812 r12841  
    1 /* $Id: edit.cpp,v 1.28 1999-12-28 17:04:22 cbratschi Exp $ */
     1/* $Id: edit.cpp,v 1.29 1999-12-29 22:53:59 cbratschi Exp $ */
    22/*
    33 *      Edit control
     
    2020    new in Win98, Win2k: for single line too
    2121  - WinNT/Win2k: higher size limits (single: 0x7FFFFFFE, multi: none)
    22   - too many GetDC/ReleaseDC calls -> GetDC is very slow!
    23     EM_REPLACESEL: calls more than 10 times GetDC/ReleaseDC!
    24     add HDC parameter
     22  - too many redraws and recalculations!
    2523*/
    2624
     
    154152 *      Helper functions only valid for one type of control
    155153 */
    156 static void     EDIT_BuildLineDefs_ML(HWND hwnd, EDITSTATE *es);
     154static void     EDIT_BuildLineDefs_ML(HWND hwnd,EDITSTATE *es);
    157155static LPSTR    EDIT_GetPasswordPointer_SL(HWND hwnd, EDITSTATE *es);
    158156static void     EDIT_MoveDown_ML(HWND hwnd, EDITSTATE *es, BOOL extend);
     
    167165static INT      EDIT_CharFromPos(HWND hwnd, EDITSTATE *es, INT x, INT y, LPBOOL after_wrap);
    168166static void     EDIT_ConfinePoint(HWND hwnd, EDITSTATE *es, LPINT x, LPINT y);
    169 static void     EDIT_GetLineRect(HWND hwnd, EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc);
     167static void     EDIT_GetLineRect(HWND hwnd,HDC dc,EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc);
    170168static void     EDIT_InvalidateText(HWND hwnd, EDITSTATE *es, INT start, INT end);
    171169static void     EDIT_LockBuffer(HWND hwnd, EDITSTATE *es);
     
    208206static INT      EDIT_EM_LineLength(HWND hwnd, EDITSTATE *es, INT index);
    209207static BOOL     EDIT_EM_LineScroll(HWND hwnd, EDITSTATE *es, INT dx, INT dy);
    210 static LRESULT  EDIT_EM_PosFromChar(HWND hwnd, EDITSTATE *es, INT index, BOOL after_wrap);
     208static LRESULT  EDIT_EM_PosFromChar(HWND hwnd,HDC dc, EDITSTATE *es, INT index, BOOL after_wrap);
    211209static void     EDIT_EM_ReplaceSel(HWND hwnd, EDITSTATE *es, BOOL can_undo, LPCSTR lpsz_replace);
    212210static LRESULT  EDIT_EM_Scroll(HWND hwnd, EDITSTATE *es, INT action);
     
    565563        case EM_POSFROMCHAR:
    566564                //DPRINTF_EDIT_MSG32("EM_POSFROMCHAR");
    567                 result = EDIT_EM_PosFromChar(hwnd, es, (INT)wParam, FALSE);
     565                result = EDIT_EM_PosFromChar(hwnd,0, es, (INT)wParam, FALSE);
    568566                break;
    569567
     
    768766 *
    769767 */
    770 static void EDIT_BuildLineDefs_ML(HWND hwnd, EDITSTATE *es)
    771 {
    772         HDC dc = 0;
     768static void EDIT_BuildLineDefs_ML(HWND hwnd,EDITSTATE *es)
     769{
     770        HDC hdc = 0;
    773771        HFONT old_font = 0;
    774772        LPSTR start, cp;
     
    809807                }
    810808
    811                 if (!dc)
     809                if (!hdc)
    812810                {
    813                   dc = GetDC(hwnd);
     811                  hdc = GetDC(hwnd);
    814812                  if (es->font)
    815                     old_font = SelectObject(dc, es->font);
     813                    old_font = SelectObject(hdc, es->font);
    816814                }
    817815
    818                 current_def->width = (INT)LOWORD(GetTabbedTextExtentA(dc,
     816                current_def->width = (INT)LOWORD(GetTabbedTextExtentA(hdc,
    819817                                        start, current_def->net_length,
    820818                                        es->tabs_count, es->tabs));
     
    827825                                next = EDIT_CallWordBreakProc(hwnd, es, start - es->text,
    828826                                                prev + 1, current_def->net_length, WB_RIGHT);
    829                                 current_def->width = (INT)LOWORD(GetTabbedTextExtentA(dc,
     827                                current_def->width = (INT)LOWORD(GetTabbedTextExtentA(hdc,
    830828                                                        start, next, es->tabs_count, es->tabs));
    831829                        } while (current_def->width <= fw);
     
    835833                                        prev = next;
    836834                                        next++;
    837                                         current_def->width = (INT)LOWORD(GetTabbedTextExtentA(dc,
     835                                        current_def->width = (INT)LOWORD(GetTabbedTextExtentA(hdc,
    838836                                                                start, next, es->tabs_count, es->tabs));
    839837                                } while (current_def->width <= fw);
     
    843841                        current_def->net_length = prev;
    844842                        current_def->ending = END_WRAP;
    845                         current_def->width = (INT)LOWORD(GetTabbedTextExtentA(dc, start,
     843                        current_def->width = (INT)LOWORD(GetTabbedTextExtentA(hdc, start,
    846844                                                current_def->net_length, es->tabs_count, es->tabs));
    847845                }
     
    864862                es->line_count++;
    865863        } while (current_def->ending != END_0);
    866         if (dc)
     864        if (hdc)
    867865        {
    868866          if (es->font)
    869                   SelectObject(dc, old_font);
    870           ReleaseDC(hwnd, dc);
     867                  SelectObject(hdc, old_font);
     868          ReleaseDC(hwnd, hdc);
    871869        }
    872870        EDIT_UpdateScrollBars(hwnd,es,TRUE,TRUE);
     
    10581056 *
    10591057 */
    1060 static void EDIT_GetLineRect(HWND hwnd, EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc)
     1058static void EDIT_GetLineRect(HWND hwnd,HDC dc,EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc)
    10611059{
    10621060        INT line_index =  EDIT_EM_LineIndex(hwnd, es, line);
     
    10681066        rc->bottom = rc->top + es->line_height;
    10691067
    1070         rc->left = (scol == 0) ? es->format_rect.left : SLOWORD(EDIT_EM_PosFromChar(hwnd, es, line_index + scol, TRUE));
    1071         rc->right = (ecol == -1) ? es->format_rect.right : SLOWORD(EDIT_EM_PosFromChar(hwnd, es, line_index + ecol, TRUE))+1;
     1068        rc->left = (scol == 0) ? es->format_rect.left : SLOWORD(EDIT_EM_PosFromChar(hwnd,dc, es, line_index + scol, TRUE));
     1069        rc->right = (ecol == -1) ? es->format_rect.right : SLOWORD(EDIT_EM_PosFromChar(hwnd,dc, es, line_index + ecol, TRUE))+1;
    10721070}
    10731071
     
    11341132        RECT rc;
    11351133
    1136         EDIT_GetLineRect(hwnd, es, 0, start, end, &line_rect);
     1134        EDIT_GetLineRect(hwnd,0, es, 0, start, end, &line_rect);
    11371135
    11381136        if (IntersectRect(&rc, &line_rect, &es->format_rect))
     
    11831181        HideCaret(hwnd);
    11841182        if (sl == el) {
    1185                 EDIT_GetLineRect(hwnd, es, sl, sc, ec, &rcLine);
     1183                EDIT_GetLineRect(hwnd,0, es, sl, sc, ec, &rcLine);
    11861184
    11871185                if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
    11881186                        InvalidateRect(hwnd, &rcUpdate, TRUE);
    11891187        } else {
    1190                 EDIT_GetLineRect(hwnd, es, sl, sc,
     1188                EDIT_GetLineRect(hwnd,0, es, sl, sc,
    11911189                                EDIT_EM_LineLength(hwnd, es,
    11921190                                        EDIT_EM_LineIndex(hwnd, es, sl)),
     
    11951193                        InvalidateRect(hwnd, &rcUpdate, TRUE);
    11961194                for (l = sl + 1 ; l < el ; l++) {
    1197                         EDIT_GetLineRect(hwnd, es, l, 0,
     1195                        EDIT_GetLineRect(hwnd,0, es, l, 0,
    11981196                                EDIT_EM_LineLength(hwnd, es,
    11991197                                        EDIT_EM_LineIndex(hwnd, es, l)),
     
    12021200                                InvalidateRect(hwnd, &rcUpdate, TRUE);
    12031201                }
    1204                 EDIT_GetLineRect(hwnd, es, el, 0, ec, &rcLine);
     1202                EDIT_GetLineRect(hwnd,0, es, el, 0, ec, &rcLine);
    12051203                if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
    12061204                        InvalidateRect(hwnd, &rcUpdate, TRUE);
     
    13531351        INT e = es->selection_end;
    13541352        BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
    1355         LRESULT pos = EDIT_EM_PosFromChar(hwnd, es, e, after_wrap);
     1353        LRESULT pos = EDIT_EM_PosFromChar(hwnd,0, es, e, after_wrap);
    13561354        INT x = SLOWORD(pos);
    13571355        INT y = SHIWORD(pos);
     
    13781376        if (es->style & ES_MULTILINE)
    13791377                e = EDIT_CharFromPos(hwnd, es, 0x3fffffff,
    1380                         HIWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap);
     1378                        HIWORD(EDIT_EM_PosFromChar(hwnd,0, es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap);
    13811379        else
    13821380                e = lstrlenA(es->text);
     
    14231421        if (es->style & ES_MULTILINE)
    14241422                e = EDIT_CharFromPos(hwnd, es, -es->x_offset,
    1425                         HIWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP)), NULL);
     1423                        HIWORD(EDIT_EM_PosFromChar(hwnd,0, es, es->selection_end, es->flags & EF_AFTER_WRAP)), NULL);
    14261424        else
    14271425                e = 0;
     
    14451443        INT e = es->selection_end;
    14461444        BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
    1447         LRESULT pos = EDIT_EM_PosFromChar(hwnd, es, e, after_wrap);
     1445        LRESULT pos = EDIT_EM_PosFromChar(hwnd,0, es, e, after_wrap);
    14481446        INT x = SLOWORD(pos);
    14491447        INT y = SHIWORD(pos);
     
    14731471        INT e = es->selection_end;
    14741472        BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
    1475         LRESULT pos = EDIT_EM_PosFromChar(hwnd, es, e, after_wrap);
     1473        LRESULT pos = EDIT_EM_PosFromChar(hwnd,0, es, e, after_wrap);
    14761474        INT x = SLOWORD(pos);
    14771475        INT y = SHIWORD(pos);
     
    15011499        INT e = es->selection_end;
    15021500        BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
    1503         LRESULT pos = EDIT_EM_PosFromChar(hwnd, es, e, after_wrap);
     1501        LRESULT pos = EDIT_EM_PosFromChar(hwnd,0, es, e, after_wrap);
    15041502        INT x = SLOWORD(pos);
    15051503        INT y = SHIWORD(pos);
     
    15991597        //TRACE_(edit)("line=%d\n", line);
    16001598
    1601         pos = EDIT_EM_PosFromChar(hwnd, es, EDIT_EM_LineIndex(hwnd, es, line), FALSE);
     1599        pos = EDIT_EM_PosFromChar(hwnd,dc, es, EDIT_EM_LineIndex(hwnd, es, line), FALSE);
    16021600        x = SLOWORD(pos);
    16031601        y = SHIWORD(pos);
     
    17181716                             BOOL after_wrap)
    17191717{
    1720         LRESULT res = EDIT_EM_PosFromChar(hwnd, es, pos, after_wrap);
     1718        LRESULT res = EDIT_EM_PosFromChar(hwnd,0, es, pos, after_wrap);
    17211719        INT x = SLOWORD(res);
    17221720        INT y = SHIWORD(res);
     
    17641762                es->format_rect.bottom = es->format_rect.top + es->line_height;
    17651763        if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL))
    1766                 EDIT_BuildLineDefs_ML(hwnd, es);
     1764                EDIT_BuildLineDefs_ML(hwnd,es);
    17671765        EDIT_UpdateScrollBars(hwnd,es,TRUE,TRUE);
    17681766}
     
    22262224                IntersectRect(&rc, &rc1, &es->format_rect);
    22272225
    2228                 ScrollWindowEx(hwnd, -dx, dy,
    2229                                 NULL, &rc, (HRGN)NULL, NULL, SW_INVALIDATE);
     2226                ScrollWindowEx(hwnd,-dx,dy,NULL,&rc,(HRGN)NULL,NULL,SW_INVALIDATE);
    22302227                es->y_offset = nyoff;
    22312228                es->x_offset += dx;
     
    22422239 *
    22432240 */
    2244 static LRESULT EDIT_EM_PosFromChar(HWND hwnd, EDITSTATE *es, INT index, BOOL after_wrap)
     2241static LRESULT EDIT_EM_PosFromChar(HWND hwnd,HDC dc, EDITSTATE *es, INT index, BOOL after_wrap)
    22452242{
    22462243        INT len = lstrlenA(es->text);
     
    22492246        INT x;
    22502247        INT y = 0;
    2251         HDC dc = 0;
     2248        BOOL createdDC = FALSE;
    22522249        HFONT old_font = 0;
    22532250        SIZE size;
     
    22592256          if (es->font)
    22602257            old_font = SelectObject(dc, es->font);
     2258          createdDC = TRUE;
    22612259        }
    22622260        if (es->style & ES_MULTILINE) {
     
    22962294        x += es->format_rect.left;
    22972295        y += es->format_rect.top;
    2298         if (es->font)
    2299                 SelectObject(dc, old_font);
    2300         ReleaseDC(hwnd, dc);
     2296        if (createdDC)
     2297        {
     2298          if (es->font)
     2299            SelectObject(dc, old_font);
     2300          ReleaseDC(hwnd, dc);
     2301        }
    23012302        return MAKELONG((INT16)x, (INT16)y);
    23022303}
     
    24242425        /* FIXME: really inefficient */
    24252426        if (es->style & ES_MULTILINE)
    2426                 EDIT_BuildLineDefs_ML(hwnd, es);
     2427                EDIT_BuildLineDefs_ML(hwnd,es);
    24272428
    24282429        EDIT_EM_SetSel(hwnd, es, s, s, FALSE);
     
    24982499                l = EDIT_EM_LineFromChar(hwnd, es, es->selection_end);
    24992500                li = EDIT_EM_LineIndex(hwnd, es, l);
    2500                 x = SLOWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP));
     2501                x = SLOWORD(EDIT_EM_PosFromChar(hwnd,0, es, es->selection_end, es->flags & EF_AFTER_WRAP));
    25012502                vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
    25022503                if (l >= es->y_offset + vlc)
     
    25192520                        return;
    25202521
    2521                 x = SLOWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, FALSE));
     2522                x = SLOWORD(EDIT_EM_PosFromChar(hwnd,0, es, es->selection_end, FALSE));
    25222523                format_width = es->format_rect.right - es->format_rect.left;
    25232524                if (x < es->format_rect.left)
     
    25262527                        do {
    25272528                                es->x_offset--;
    2528                                 x = SLOWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, FALSE));
     2529                                x = SLOWORD(EDIT_EM_PosFromChar(hwnd,0, es, es->selection_end, FALSE));
    25292530                        } while ((x < goal) && es->x_offset);
    25302531                        /* FIXME: use ScrollWindow() somehow to improve performance */
     
    25382539                        do {
    25392540                                es->x_offset++;
    2540                                 x = SLOWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, FALSE));
    2541                                 x_last = SLOWORD(EDIT_EM_PosFromChar(hwnd, es, len, FALSE));
     2541                                x = SLOWORD(EDIT_EM_PosFromChar(hwnd,0, es, es->selection_end, FALSE));
     2542                                x_last = SLOWORD(EDIT_EM_PosFromChar(hwnd,0, es, len, FALSE));
    25422543                        } while ((x > goal) && (x_last > es->format_rect.right));
    25432544                        /* FIXME: use ScrollWindow() somehow to improve performance */
     
    26062607        es->flags &= ~EF_MODIFIED;
    26072608        es->flags &= ~EF_UPDATE;
    2608         EDIT_BuildLineDefs_ML(hwnd, es);
     2609        EDIT_BuildLineDefs_ML(hwnd,es);
    26092610        EDIT_Refresh(hwnd,es,FALSE);
    26102611        EDIT_EM_ScrollCaret(hwnd, es);
     
    26712672          EDIT_SetRectNP(hwnd, es, &r);
    26722673          if (es->style & ES_MULTILINE)
    2673                   EDIT_BuildLineDefs_ML(hwnd, es);
     2674                  EDIT_BuildLineDefs_ML(hwnd,es);
    26742675
    26752676          EDIT_Refresh(hwnd,es,FALSE);
     
    28402841        es->word_break_procA = wbp;
    28412842        if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) {
    2842                 EDIT_BuildLineDefs_ML(hwnd, es);
     2843                EDIT_BuildLineDefs_ML(hwnd,es);
    28432844                EDIT_Refresh(hwnd,es,FALSE);
    28442845        }
     
    37393740    for (i = es->y_offset ; i <= MIN(es->y_offset + vlc, es->y_offset + es->line_count - 1) ; i++)
    37403741    {
    3741       EDIT_GetLineRect(hwnd, es, i, 0, -1, &rcLine);
     3742      EDIT_GetLineRect(hwnd,hdc, es, i, 0, -1, &rcLine);
    37423743      if (IntersectRect(&rc, &rcRgn, &rcLine))
    37433744        EDIT_PaintLine(hwnd, es, hdc, i, rev);
     
    37453746  } else
    37463747  {
    3747     EDIT_GetLineRect(hwnd, es, 0, 0, -1, &rcLine);
     3748    EDIT_GetLineRect(hwnd,hdc, es, 0, 0, -1, &rcLine);
    37483749    if (IntersectRect(&rc, &rcRgn, &rcLine))
    37493750      EDIT_PaintLine(hwnd, es, hdc, 0, rev);
     
    38903891        EDIT_SetRectNP(hwnd, es, &r);
    38913892        if (es->style & ES_MULTILINE)
    3892                 EDIT_BuildLineDefs_ML(hwnd, es);
     3893                EDIT_BuildLineDefs_ML(hwnd,es);
    38933894
    38943895        if (redraw)
  • TabularUnified tags/trunk/src/user32/oslibgdi.cpp

    r12812 r12841  
    1 /* $Id: oslibgdi.cpp,v 1.6 1999-12-28 17:04:23 cbratschi Exp $ */
     1/* $Id: oslibgdi.cpp,v 1.7 1999-12-29 22:54:00 cbratschi Exp $ */
    22/*
    33 * Window GDI wrapper functions for OS/2
     
    55 *
    66 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
    7  *
     7 * Copyright 1999 Christoph Bratschi (cbratschi@datacomm.ch)
    88 *
    99 * Project Odin Software License can be found in LICENSE.TXT
     
    2121#include "win32wbase.h"
    2222
    23 //CB: new mapping infrastructure to avoid transformation bugs -> available soon
    24 
    2523/*
    26 All mapScreen/Window can be used to transform from Win32 to OS/2 and vice versa
    2724First letter is lower case to avoid conflicts with Win32 API names
     25All transformations are for screen or client windows, for frame windows use OS/2 API's
    2826
    2927Single y mapping:
    3028 mapScreenY()
    31  mapClientY()
    32  mapChildY()
     29 mapY()
     30 mapOS2ToWin32Y()
     31 mapWin32ToOS2Y()
     32 mapWin32Y()
    3333
    3434Single point mapping:
    3535 mapScreenPoint()
    36  mapClientPoint()
    37  mapChildPoint()
     36 mapPoint()
     37 mapOS2ToWin32Point()
     38 mapWin32ToOS2Point()
     39 mapWin32Point()
    3840
    3941Single rect mapping:
    40  mapScreenRect()
    41  mapClientRect()
     42 mapOS2ToWin32ScreenRect()
     43 mapWin32ToOS2ScreenRect()
     44 mapOS2ToWin32Rect()
     45 mapWin32ToOS2Rect()
     46 mapWin32Rect()
    4247
    4348Rect transformation:
    44  copyOS2Rect()
    45  copyWin32Rect()
     49 copyOS2ToWin32Rect()
     50 copyWin32ToOS2Rect()
     51
     52Child origin:
     53 mapOS2ToWin32ChildOrigin()
    4654*/
    4755
     56//******************************************************************************
     57// To translation between OS/2 <-> Win32
     58//******************************************************************************
    4859INT mapScreenY(INT screenPosY)
    4960{
    50   return WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN)-1-screenPosY;
    51 }
    52 //******************************************************************************
     61  return ScreenHeight-1-screenPosY;
     62}
     63//******************************************************************************
     64// To translation between OS/2 <-> Win32
    5365//******************************************************************************
    5466INT mapScreenY(INT screenH,INT screenPosY)
     
    5769}
    5870//******************************************************************************
    59 //******************************************************************************
    60 INT mapClientY(INT clientH,INT clientPosY)
    61 {
    62   return clientH-1-clientPosY;
    63 }
    64 //******************************************************************************
    65 //******************************************************************************
    66 INT mapClientY(HWND os2Client,INT clientPosY)
     71// To translation between OS/2 <-> Win32
     72//******************************************************************************
     73INT mapY(HWND os2Client,INT clientPosY)
    6774{
    6875  RECTL rect;
     
    7077  if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //client shouldn't be desktop
    7178  if (!WinQueryWindowRect(os2Client,&rect)) return 0;
     79
    7280  return rect.yTop-1-clientPosY;
    7381}
    7482//******************************************************************************
    75 //******************************************************************************
    76 INT mapClientY(Win32BaseWindow *win32wnd,INT clientPosY)
    77 {
    78   return win32wnd->getWindowHeight()-1-clientPosY;
    79 }
    80 //******************************************************************************
    81 //******************************************************************************
    82 INT mapChildY(INT parentH,INT childY,INT childPosY)
    83 {
    84   return parentH-1-childY-childPosY;
    85 }
    86 //******************************************************************************
    87 //******************************************************************************
    88 INT mapChildY(HWND os2Parent,INT childY,INT childPosY)
    89 {
    90   RECTL rect;
    91 
    92   if (os2Parent == OSLIB_HWND_DESKTOP) os2Parent = HWND_DESKTOP;
    93   if (!WinQueryWindowRect(os2Parent,&rect)) return 0;
    94   return rect.yTop-1-childY-childPosY;
    95 }
    96 //******************************************************************************
    97 //******************************************************************************
    98 INT mapChildY(HWND os2Parent,HWND os2Child,INT childPosY)
    99 {
    100   RECTL rect;
    101   SWP swp;
    102 
    103   if (os2Parent == OSLIB_HWND_DESKTOP) os2Parent = HWND_DESKTOP;
    104   if (!WinQueryWindowRect(os2Parent,&rect)) return 0;
    105   if (!WinQueryWindowPos(os2Child,&swp)) return 0;
    106   return rect.yTop-1-swp.y-childPosY;
    107 }
    108 //******************************************************************************
     83// To translation between OS/2 <-> Win32
     84//******************************************************************************
     85INT mapY(Win32BaseWindow *win32wnd,INT clientPosY)
     86{
     87  if (!win32wnd) return 0;
     88
     89  return win32wnd->getClientHeight()-1-clientPosY;
     90}
     91//******************************************************************************
     92//******************************************************************************
     93INT mapOS2ToWin32Y(HWND os2From,HWND os2To,INT fromPosY)
     94{
     95  POINTL pt;
     96  RECTL rect;
     97
     98  if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
     99  if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
     100  if (os2From != os2To)
     101  {
     102    pt.x = 0;
     103    pt.y = fromPosY;
     104    if (!WinMapWindowPoints(os2From,os2To,&pt,1)) return 0;
     105  } else pt.y = fromPosY;
     106  if (!WinQueryWindowRect(os2To,&rect)) return 0;
     107
     108  return rect.yTop-1-pt.y;
     109}
     110//******************************************************************************
     111//******************************************************************************
     112INT mapOS2ToWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY)
     113{
     114  POINTL pt;
     115
     116  if (!wndFrom || !wndTo) return 0;
     117  if (wndFrom != wndTo)
     118  {
     119    pt.x = 0;
     120    pt.y = fromPosY;
     121    if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),&pt,1)) return 0;
     122  } else pt.y = fromPosY;
     123
     124  return wndTo->getClientHeight()-1-pt.y;
     125}
     126//******************************************************************************
     127//******************************************************************************
     128INT mapWin32Y(HWND os2From,HWND os2To,INT fromPosY)
     129{
     130  POINTL pt;
     131  RECTL rect;
     132
     133  if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
     134  if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
     135  if (os2From == os2To) return fromPosY;
     136  if (!WinQueryWindowRect(os2From,&rect)) return 0;
     137  pt.y = rect.yTop-1-fromPosY;
     138  pt.x = 0;
     139  if (!WinMapWindowPoints(os2From,os2To,&pt,1)) return 0;
     140  if (!WinQueryWindowRect(os2To,&rect)) return 0;
     141
     142  return rect.yTop-1-pt.y;
     143}
     144//******************************************************************************
     145//******************************************************************************
     146INT mapWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY)
     147{
     148  POINTL pt;
     149
     150  if (!wndFrom || !wndTo) return 0;
     151  if (wndFrom == wndTo) return fromPosY;
     152  pt.y = wndFrom->getClientHeight()-1-fromPosY;
     153  pt.x = 0;
     154  if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),&pt,1)) return 0;
     155
     156  return wndTo->getClientHeight()-1-pt.y;
     157}
     158//******************************************************************************
     159// To translation between OS/2 <-> Win32
    109160//******************************************************************************
    110161BOOL mapScreenPoint(OSLIBPOINT *screenPt)
    111162{
    112163  if(!screenPt) return FALSE;
    113   screenPt->y = WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN)-1-screenPt->y;
    114   return TRUE;
    115 }
    116 //******************************************************************************
    117 //******************************************************************************
    118 INT mapScreenY(INT screenH,OSLIBPOINT *screenPt)
     164  screenPt->y = ScreenHeight-1-screenPt->y;
     165
     166  return TRUE;
     167}
     168//******************************************************************************
     169// To translation between OS/2 <-> Win32
     170//******************************************************************************
     171BOOL mapScreenPoint(INT screenH,OSLIBPOINT *screenPt)
    119172{
    120173  if (!screenPt) return FALSE;
    121174  screenPt->y = screenH-1-screenPt->y;
    122   return TRUE;
    123 }
    124 
    125 //old mapping functions
    126 
    127 //******************************************************************************
    128 //******************************************************************************
    129 inline ULONG MAPWIN32POINT(RECTLOS2 *parent, ULONG cy, ULONG y)
    130 {
    131     return (parent->yTop - parent->yBottom - cy - y);
    132 }
    133 //******************************************************************************
    134 //Map win32 y coordinate (in parent window coordinates) to OS/2 y coord. (in parent window coordinates)
    135 //******************************************************************************
    136 ULONG MapOS2ToWin32Y(HWND hwndParent, ULONG cy, ULONG y)
    137 {
    138  RECTLOS2 rectParent = {0};
    139 
    140     if(hwndParent == OSLIB_HWND_DESKTOP) {
    141         hwndParent = HWND_DESKTOP;
    142     }
    143     WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
    144     return MAPWIN32POINT(&rectParent, cy, y);
    145 }
    146 //******************************************************************************
    147 //******************************************************************************
    148 BOOL MapOS2ToWin32Point(HWND hwndParent, HWND hwndChild, OSLIBPOINT *point)
    149 {
    150  RECTLOS2 rectParent = {0};
    151 
    152     if(hwndParent == OSLIB_HWND_DESKTOP) {
    153         hwndParent = HWND_DESKTOP;
    154     }
    155     if(WinMapWindowPoints(hwndChild, hwndParent, (POINTL *)point, 1) != TRUE) {
    156         dprintf(("MapOS2ToWin32Point:WinMapWindowPoint %x %x returned false", hwndParent, hwndChild));
    157         return FALSE;
    158     }
    159     WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
    160     point->y = rectParent.yTop - point->y - 1;
    161     return TRUE;
    162 }
    163 //******************************************************************************
    164 // MapOS2ToWin32Rect
    165 //   Map os/2 rectangle to screen coordinates and convert to win32 rect
    166 //
    167 // Parameters:
    168 //   hwndParent: Parent window handle
    169 //   hwndChild:  Child window handle
    170 //   rectOS2:    OS/2 child window RECTL
    171 //   rectWin32:  Win32 Child window RECT   (IN)
    172 //
    173 // Returns:
    174 //   TRUE:      Success
    175 //   FALSE:     Failures
    176 //******************************************************************************
    177 BOOL MapOS2ToWin32Rectl(HWND hwndParent, HWND hwndChild, PRECTLOS2 rectOS2, PRECT rectWin32)
    178 {
    179  RECTLOS2 rectParent = {0};
    180  Win32BaseWindow *window;
    181  LONG height;
    182 
    183     if(hwndParent == OSLIB_HWND_DESKTOP) {
    184         hwndParent = HWND_DESKTOP;
    185     }
    186     if(WinMapWindowPoints(hwndChild, hwndParent, (PPOINTL)rectOS2, 2) != TRUE) {
    187         dprintf(("MapOS2ToWin32Rect:WinMapWindowPoint %x %x returned false", hwndParent, hwndChild));
    188         return FALSE;
    189     }
    190 
    191     if(hwndParent != HWND_DESKTOP)
    192     {
    193          window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndParent);
    194          if(window == NULL)
    195                 return FALSE;
    196          height = window->getWindowHeight();
    197     }
    198     else height = OSLibQueryScreenHeight();
    199 
    200     rectWin32->bottom = height - rectOS2->yBottom;
    201     rectWin32->top    = height - rectOS2->yTop;
    202     rectWin32->left   = rectOS2->xLeft;
    203     rectWin32->right  = rectOS2->xRight;
    204 
    205     return TRUE;
    206 }
    207 //******************************************************************************
    208 // MapOS2ToWin32Rectl
    209 //   Convert OS/2 to Win32 RECTL structure
    210 //
    211 // Parameters:
    212 //   hwnd:       OS/2 window handle
    213 //   rectOS2:    OS/2 child window RECTL
    214 //   rectWin32:  Win32 Child window RECT   (IN)
    215 //
    216 // Returns:
    217 //   TRUE:      Success
    218 //   FALSE:     Failures
    219 //******************************************************************************
    220 BOOL MapOS2ToWin32Rectl(HWND hwnd,PRECTLOS2 rectOS2, PRECT rectWin32)
    221 {
    222    RECTL rect;
    223 
    224    if (!WinQueryWindowRect(hwnd,&rect)) return FALSE;
    225 
    226    rectWin32->bottom = rect.yTop-rectOS2->yBottom;
    227    rectWin32->top    = rect.yTop-rectOS2->yTop;
    228    rectWin32->left   = rectOS2->xLeft;
    229    rectWin32->right  = rectOS2->xRight;
    230 
    231    return TRUE;
    232 }
    233 //******************************************************************************
    234 // MapWin32ToOS2Rectl
    235 //   Convert Win32 to OS/2 RECTL structure
    236 //
    237 // Parameters:
    238 //   hwnd:       OS/2 window handle
    239 //   rectWin32:  Win32 Child window RECT   (IN)
    240 //   rectOS2:    OS/2  Child window RECTL  (OUT)
    241 // Returns:
    242 //   TRUE:       Success
    243 //   FALSE:      Failures
    244 //******************************************************************************
    245 BOOL MapWin32ToOS2Rectl(HWND hwnd,PRECT rectWin32, PRECTLOS2 rectOS2)
    246 {
    247     RECTL rect;
    248 
    249     if (!WinQueryWindowRect(hwnd,&rect)) return FALSE;
    250 
    251     rectOS2->yBottom = rect.yTop-rectWin32->bottom;
    252     rectOS2->yTop    = rect.yTop-rectWin32->top;
    253     rectOS2->xLeft   = rectWin32->left;
    254     rectOS2->xRight  = rectWin32->right;
    255 
    256     return TRUE;
    257 }
    258 //******************************************************************************
    259 //******************************************************************************
    260 BOOL MapOS2ToWin32WindowRect(PRECTLOS2 rectOS2,PRECT rectWin32)
    261 {
    262   rectWin32->bottom = rectOS2->yTop;
    263   rectWin32->top    = rectOS2->yBottom;
     175
     176  return TRUE;
     177}
     178//******************************************************************************
     179// To translation between OS/2 <-> Win32
     180//******************************************************************************
     181BOOL mapPoint(HWND os2Client,OSLIBPOINT *clientPt)
     182{
     183  RECTL rect;
     184
     185  if (!clientPt) return FALSE;
     186  if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //client shouldn't be desktop
     187  if (!WinQueryWindowRect(os2Client,&rect)) return 0;
     188  clientPt->y = rect.yTop-1-clientPt->y;
     189
     190  return TRUE;
     191}
     192//******************************************************************************
     193// To translation between OS/2 <-> Win32
     194//******************************************************************************
     195BOOL mapPoint(Win32BaseWindow *win32wnd,OSLIBPOINT *clientPt)
     196{
     197  if (!win32wnd || !clientPt) return FALSE;
     198  clientPt->y = win32wnd->getClientHeight()-1-clientPt->y;
     199
     200  return TRUE;
     201}
     202//******************************************************************************
     203//******************************************************************************
     204BOOL mapOS2ToWin32Point(HWND os2From,HWND os2To,OSLIBPOINT *fromPt)
     205{
     206  RECTL rect;
     207
     208  if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
     209  if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
     210  if (os2From != os2To)
     211  {
     212    if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)fromPt,1)) return FALSE;
     213  }
     214  if (!WinQueryWindowRect(os2To,&rect)) return FALSE;
     215  fromPt->y = rect.yTop-1-fromPt->y;
     216
     217  return TRUE;
     218}
     219//******************************************************************************
     220//******************************************************************************
     221BOOL mapOS2ToWin32Point(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,OSLIBPOINT *fromPt)
     222{
     223  if (!wndFrom || !wndTo) return 0;
     224  if (wndFrom != wndTo)
     225  {
     226    if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)fromPt,1)) return FALSE;
     227  }
     228  fromPt->y = wndTo->getClientHeight()-1-fromPt->y;
     229
     230  return TRUE;
     231}
     232//******************************************************************************
     233//******************************************************************************
     234BOOL mapWin32Point(HWND os2From,HWND os2To,OSLIBPOINT *fromPt)
     235{
     236  RECTL rect;
     237
     238  if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
     239  if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
     240  if (os2From == os2To) return TRUE;
     241  if (!WinQueryWindowRect(os2From,&rect)) return 0;
     242  fromPt->y = rect.yTop-1-fromPt->y;
     243  if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)fromPt,1)) return 0;
     244  if (!WinQueryWindowRect(os2To,&rect)) return 0;
     245  fromPt->y = rect.yTop-1-fromPt->y;
     246
     247  return TRUE;
     248}
     249//******************************************************************************
     250//******************************************************************************
     251BOOL mapWin32Point(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,OSLIBPOINT *fromPt)
     252{
     253  if (!wndFrom || !wndTo) return FALSE;
     254  if (wndFrom == wndTo) return TRUE;
     255  fromPt->y = wndFrom->getClientHeight()-1-fromPt->y;
     256  if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)fromPt,1)) return 0;
     257  fromPt->y = wndTo->getClientHeight()-1-fromPt->y;
     258
     259  return TRUE;
     260}
     261//******************************************************************************
     262//******************************************************************************
     263BOOL mapOS2ToWin32ScreenRect(PRECTLOS2 rectOS2,PRECT rectWin32)
     264{
     265  if (!rectOS2 || !rectWin32) return FALSE;
     266  rectWin32->bottom = ScreenHeight-rectOS2->yBottom;
     267  rectWin32->top    = ScreenHeight-rectOS2->yTop;
    264268  rectWin32->left   = rectOS2->xLeft;
    265269  rectWin32->right  = rectOS2->xRight;
     
    269273//******************************************************************************
    270274//******************************************************************************
    271 BOOL MapWin32ToOS2WindowRect(PRECT rectWin32,PRECTLOS2 rectOS2)
    272 {
    273   rectOS2->yBottom = rectWin32->top;
    274   rectOS2->yTop    = rectWin32->bottom;
     275BOOL mapWin32ToOS2ScreenRect(PRECT rectWin32,PRECTLOS2 rectOS2)
     276{
     277  if (!rectOS2 || !rectWin32) return FALSE;
     278  rectOS2->yBottom = ScreenHeight-rectWin32->bottom;
     279  rectOS2->yTop    = ScreenHeight-rectWin32->top;
    275280  rectOS2->xLeft   = rectWin32->left;
    276281  rectOS2->xRight  = rectWin32->right;
    277282
    278283  return TRUE;
     284}
     285//******************************************************************************
     286//******************************************************************************
     287BOOL mapOS2ToWin32Rect(HWND os2Client,PRECTLOS2 rectOS2,PRECT rectWin32)
     288{
     289  RECTL rect;
     290
     291  if (!rectOS2 || !rectWin32) return FALSE;
     292  if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //shouldn't be the case
     293  if (!WinQueryWindowRect(os2Client,&rect)) return FALSE;
     294  rectWin32->bottom = rect.yTop-rectOS2->yBottom;
     295  rectWin32->top    = rect.yTop-rectOS2->yTop;
     296  rectWin32->left   = rectOS2->xLeft;
     297  rectWin32->right  = rectOS2->xRight;
     298
     299  return TRUE;
     300}
     301//******************************************************************************
     302//******************************************************************************
     303BOOL mapOS2ToWin32Rect(Win32BaseWindow *win32wnd,PRECTLOS2 rectOS2,PRECT rectWin32)
     304{
     305  INT windowH;
     306
     307  if (!win32wnd || !rectOS2 || !rectWin32) return FALSE;
     308  windowH = win32wnd->getClientHeight();
     309  rectWin32->bottom = windowH-rectOS2->yBottom;
     310  rectWin32->top    = windowH-rectOS2->yTop;
     311  rectWin32->left   = rectOS2->xLeft;
     312  rectWin32->right  = rectOS2->xRight;
     313
     314  return TRUE;
     315}
     316//******************************************************************************
     317//******************************************************************************
     318BOOL mapOS2ToWin32Rect(HWND os2From,HWND os2To,PRECTLOS2 rectOS2,PRECT rectWin32)
     319{
     320  RECTL rect,temp;
     321
     322  if (!rectOS2 || !rectWin32) return FALSE;
     323  if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
     324  if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
     325  temp = *((PRECTL)rectOS2);
     326  if (os2From != os2To)
     327  {
     328    if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)&temp,2)) return FALSE;
     329  }
     330  if (!WinQueryWindowRect(os2To,&rect)) return FALSE;
     331  rectWin32->bottom = rect.yTop-temp.yBottom;
     332  rectWin32->top    = rect.yTop-temp.yTop;
     333  rectWin32->left   = temp.xLeft;
     334  rectWin32->right  = temp.xRight;
     335
     336  return TRUE;
     337}
     338//******************************************************************************
     339//******************************************************************************
     340BOOL mapOS2ToWin32Rect(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,PRECTLOS2 rectOS2,PRECT rectWin32)
     341{
     342  RECTL temp;
     343  INT windowH;
     344
     345  if (!wndFrom || !wndTo || !rectOS2 || !rectWin32) return FALSE;
     346  temp = *((PRECTL)rectOS2);
     347  if (wndFrom != wndTo)
     348  {
     349    if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)&temp,2)) return FALSE;
     350  }
     351  windowH = wndTo->getClientHeight();
     352  rectWin32->bottom = windowH-temp.yBottom;
     353  rectWin32->top    = windowH-temp.yTop;
     354  rectWin32->left   = temp.xLeft;
     355  rectWin32->right  = temp.xRight;
     356
     357  return TRUE;
     358}
     359//******************************************************************************
     360//******************************************************************************
     361BOOL mapWin32ToOS2Rect(HWND os2Client,PRECT rectWin32,PRECTLOS2 rectOS2)
     362{
     363  RECTL rect;
     364
     365  if (!rectOS2 || !rectWin32) return FALSE;
     366  if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //shouldn't be the case
     367  if (!WinQueryWindowRect(os2Client,&rect)) return FALSE;
     368  rectOS2->yBottom = rect.yTop-rectWin32->bottom;
     369  rectOS2->yTop    = rect.yTop-rectWin32->top;
     370  rectOS2->xLeft   = rectWin32->left;
     371  rectOS2->xRight  = rectWin32->right;
     372
     373  return TRUE;
     374}
     375//******************************************************************************
     376//******************************************************************************
     377BOOL mapWin32ToOS2Rect(Win32BaseWindow *win32wnd,PRECT rectWin32,PRECTLOS2 rectOS2)
     378{
     379  INT windowH;
     380
     381  if (!win32wnd || !rectOS2 || !rectWin32) return FALSE;
     382  windowH = win32wnd->getClientHeight();
     383  rectOS2->yBottom = windowH-rectWin32->bottom;
     384  rectOS2->yTop    = windowH-rectWin32->top;
     385  rectOS2->xLeft   = rectWin32->left;
     386  rectOS2->xRight  = rectWin32->right;
     387
     388  return TRUE;
     389}
     390//******************************************************************************
     391//******************************************************************************
     392BOOL mapWin32ToOS2Rect(HWND os2From,HWND os2To,PRECT rectWin32,PRECTLOS2 rectOS2)
     393{
     394  RECTL rect;
     395
     396  if (!rectOS2 || !rectWin32) return FALSE;
     397  if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
     398  if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
     399  if (!WinQueryWindowRect(os2From,&rect)) return FALSE;
     400  rectOS2->yBottom = rect.yTop-rectWin32->bottom;
     401  rectOS2->yTop    = rect.yTop-rectWin32->top;
     402  rectOS2->xLeft   = rectWin32->left;
     403  rectOS2->xRight  = rectWin32->right;
     404  if (os2From != os2To)
     405  {
     406    if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)rectOS2,2)) return FALSE;
     407  }
     408
     409  return TRUE;
     410}
     411//******************************************************************************
     412//******************************************************************************
     413BOOL mapWin32ToOS2Rect(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,PRECT rectWin32,PRECTLOS2 rectOS2)
     414{
     415  INT windowH;
     416
     417  if (!wndFrom || !wndTo || !rectOS2 || !rectWin32) return FALSE;
     418  windowH = wndFrom->getClientHeight();
     419  rectOS2->yBottom = windowH-rectWin32->bottom;
     420  rectOS2->yTop    = windowH-rectWin32->top;
     421  rectOS2->xLeft   = rectWin32->left;
     422  rectOS2->xRight  = rectWin32->right;
     423  if (wndFrom != wndTo)
     424  {
     425    if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)rectOS2,2)) return FALSE;
     426  }
     427
     428  return TRUE;
     429}
     430//******************************************************************************
     431//******************************************************************************
     432BOOL copyOS2ToWin32Rect(PRECTLOS2 rectOS2,PRECT rectWin32)
     433{
     434  rectWin32->bottom = rectOS2->yBottom;
     435  rectWin32->top    = rectOS2->yTop;
     436  rectWin32->left   = rectOS2->xLeft;
     437  rectWin32->right  = rectOS2->xRight;
     438
     439  return TRUE;
     440}
     441//******************************************************************************
     442//******************************************************************************
     443BOOL copyWin32ToOS2WindowRect(PRECT rectWin32,PRECTLOS2 rectOS2)
     444{
     445  rectOS2->yBottom = rectWin32->bottom;
     446  rectOS2->yTop    = rectWin32->top;
     447  rectOS2->xLeft   = rectWin32->left;
     448  rectOS2->xRight  = rectWin32->right;
     449
     450  return TRUE;
     451}
     452//******************************************************************************
     453//******************************************************************************
     454INT mapOS2ToWin32ChildOrigin(INT parentH,INT parentPosY,INT childH)
     455{
     456  return parentH-parentPosY-childH;//Does: parentH-1-parentPosY-(childH-1)
    279457}
    280458//******************************************************************************
     
    289467        return 0;
    290468    }
    291     MapOS2ToWin32Rectl(hwnd,(RECTLOS2 *)&rectl, rectWin32);
     469    mapOS2ToWin32Rect(hwnd,(RECTLOS2 *)&rectl, rectWin32);
    292470    return WinBeginPaint(hwnd, NULLHANDLE, &rectl);
    293471}
     
    320498
    321499    if(pRect) {
    322         MapWin32ToOS2Rectl(hwnd,pRect, &rectl);
     500        mapWin32ToOS2Rect(hwnd,pRect, &rectl);
    323501        return WinInvalidateRect(hwnd, (PRECTL)&rectl, fIncludeChildren);
    324502    }
     
    335513  rc = WinQueryUpdateRect(hwnd, (PRECTL)&rectl);
    336514  if(rc) {
    337         MapOS2ToWin32Rectl(hwnd,&rectl, pRect);
     515        mapOS2ToWin32Rect(hwnd,&rectl, pRect);
    338516  }
    339517  else  memset(pRect, 0, sizeof(RECT));
  • TabularUnified tags/trunk/src/user32/oslibgdi.h

    r12435 r12841  
    1 /* $Id: oslibgdi.h,v 1.2 1999-11-26 17:06:07 cbratschi Exp $ */
     1/* $Id: oslibgdi.h,v 1.3 1999-12-29 22:54:00 cbratschi Exp $ */
    22/*
    33 * Window GDI wrapper functions for OS/2
     
    4141BOOL  OSLibWinQueryUpdateRect(HWND hwnd, PRECT pRect);
    4242
    43 //******************************************************************************
    44 //Map win32 y coordinate (in window coordinates) to OS/2 y coord. (in window coordinates)
    45 //******************************************************************************
    46 inline ULONG MapOS2ToWin32Y(Win32BaseWindow *window, ULONG y)
    47 {
    48     return window->getWindowHeight() - y - 1;
    49 }
     43//Mapping functions
    5044
    51 ULONG MapOS2ToWin32Y(HWND hwndParent, ULONG cy, ULONG y);
    52 BOOL  MapOS2ToWin32Point(HWND hwndParent, HWND hwndChild, OSLIBPOINT *point);
    53 
    54 //map os/2 rectangle to screen coordinates and convert to win32 rect
    55 BOOL  MapOS2ToWin32Rectl(HWND hwndParent, HWND hwndChild, PRECTLOS2 rectOS2, PRECT rectWin32);
    56 
    57 BOOL  MapOS2ToWin32Rectl(HWND hwnd,PRECTLOS2 rectOS2, PRECT rectWin32);
    58 BOOL  MapWin32ToOS2Rectl(HWND hwnd,PRECT rectWin32, PRECTLOS2 rectOS2);
    59 
    60 BOOL  MapOS2ToWin32WindowRect(PRECTLOS2 rectOS2,PRECT rectWin32);
    61 BOOL  MapWin32ToOS2WindowRect(PRECT rectWin32,PRECTLOS2 rectOS2);
     45INT  mapScreenY(INT screenPosY);
     46INT  mapScreenY(INT screenH,INT screenPosY);
     47INT  mapY(HWND os2Client,INT clientPosY);
     48INT  mapY(Win32BaseWindow *win32wnd,INT clientPosY);
     49INT  mapOS2ToWin32Y(HWND os2From,HWND os2To,INT fromPosY);
     50INT  mapOS2ToWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY);
     51INT  mapWin32Y(HWND os2From,HWND os2To,INT fromPosY);
     52INT  mapWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY);
     53BOOL mapScreenPoint(OSLIBPOINT *screenPt);
     54BOOL mapScreenPoint(INT screenH,OSLIBPOINT *screenPt);
     55BOOL mapPoint(HWND os2Client,OSLIBPOINT *clientPt);
     56BOOL mapPoint(Win32BaseWindow *win32wnd,OSLIBPOINT *clientPt);
     57BOOL mapOS2ToWin32Point(HWND os2From,HWND os2To,OSLIBPOINT *fromPt);
     58BOOL mapOS2ToWin32Point(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,OSLIBPOINT *fromPt);
     59BOOL mapWin32Point(HWND os2From,HWND os2To,OSLIBPOINT *fromPt);
     60BOOL mapWin32Point(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,OSLIBPOINT *fromPt);
     61BOOL mapOS2ToWin32ScreenRect(PRECTLOS2 rectOS2,PRECT rectWin32);
     62BOOL mapWin32ToOS2ScreenRect(PRECT rectWin32,PRECTLOS2 rectOS2);
     63BOOL mapOS2ToWin32Rect(HWND os2Client,PRECTLOS2 rectOS2,PRECT rectWin32);
     64BOOL mapOS2ToWin32Rect(Win32BaseWindow *win32wnd,PRECTLOS2 rectOS2,PRECT rectWin32);
     65BOOL mapOS2ToWin32Rect(HWND os2From,HWND os2To,PRECTLOS2 rectOS2,PRECT rectWin32);
     66BOOL mapOS2ToWin32Rect(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,PRECTLOS2 rectOS2,PRECT rectWin32);
     67BOOL mapWin32ToOS2Rect(HWND os2Client,PRECT rectWin32,PRECTLOS2 rectOS2);
     68BOOL mapWin32ToOS2Rect(Win32BaseWindow *win32wnd,PRECT rectWin32,PRECTLOS2 rectOS2);
     69BOOL mapWin32ToOS2Rect(HWND os2From,HWND os2To,PRECT rectWin32,PRECTLOS2 rectOS2);
     70BOOL mapWin32ToOS2Rect(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,PRECT rectWin32,PRECTLOS2 rectOS2);
     71BOOL copyOS2ToWin32Rect(PRECTLOS2 rectOS2,PRECT rectWin32);
     72BOOL copyWin32ToOS2WindowRect(PRECT rectWin32,PRECTLOS2 rectOS2);
     73INT  mapOS2ToWin32ChildOrigin(INT parentH,INT parentPosY,INT childH);
    6274
    6375#endif //__OSLIBGDI_H__
  • TabularUnified tags/trunk/src/user32/oslibmsg.cpp

    r12834 r12841  
    1 /* $Id: oslibmsg.cpp,v 1.18 1999-12-29 14:37:16 sandervl Exp $ */
     1/* $Id: oslibmsg.cpp,v 1.19 1999-12-29 22:54:00 cbratschi Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    348348   }
    349349   //convert to windows coordinates
    350    return MAKEULONG(ptl.x, ScreenHeight - ptl.y - 1);
     350   return MAKEULONG(ptl.x,mapScreenY(ptl.y));
    351351}
    352352//******************************************************************************
  • TabularUnified tags/trunk/src/user32/oslibmsgtranslate.cpp

    r12834 r12841  
    1 /* $Id: oslibmsgtranslate.cpp,v 1.5 1999-12-29 14:37:16 sandervl Exp $ */
     1/* $Id: oslibmsgtranslate.cpp,v 1.6 1999-12-29 22:54:01 cbratschi Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    119119  winMsg->time = os2Msg->time;
    120120  winMsg->pt.x = os2Msg->ptl.x;
    121   winMsg->pt.y = ScreenHeight - os2Msg->ptl.y - 1;
     121  winMsg->pt.y = mapScreenY(os2Msg->ptl.y);
    122122  if(win32wnd) //==0 for WM_CREATE
    123123    winMsg->hwnd = win32wnd->getWindowHandle();
     
    292292            point.y         = (*(POINTS *)&os2Msg->mp1).y;
    293293            ClientPoint.x   = point.x;
    294             ClientPoint.y   = MapOS2ToWin32Y(os2Msg->hwnd, 1, point.y);
     294            ClientPoint.y   = mapY(os2Msg->hwnd,point.y);
    295295
    296296            winMsg->message = WINWM_LBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
     
    335335        {
    336336          winMsg->wParam = (WPARAM)keystate;
    337           winMsg->lParam  = MAKELONG(SHORT1FROMMP(os2Msg->mp1), MapOS2ToWin32Y(win32wnd, SHORT2FROMMP(os2Msg->mp1)));
     337          winMsg->lParam  = MAKELONG(SHORT1FROMMP(os2Msg->mp1),mapY(win32wnd,SHORT2FROMMP(os2Msg->mp1)));
    338338        }
    339339        //OS/2 Window coordinates -> Win32 Window coordinates
     
    363363            WinQueryPointerPos(HWND_DESKTOP, &pointl);
    364364            x = pointl.x;
    365             y = ScreenHeight - y;
     365            y = mapScreenY(y);
    366366        }
    367367        switch(SHORT1FROMMP(os2Msg->mp1)) {
     
    571571        pt.y = (*(POINTS *)&os2Msg->mp1).y;
    572572
    573         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP,os2Msg->hwnd,&pt);
     573        mapOS2ToWin32Point(os2Msg->hwnd,OSLIB_HWND_DESKTOP,&pt);
    574574        winMsg->message  = WINWM_NCHITTEST;
    575575        winMsg->wParam  = 0;
     
    580580    case WM_CONTEXTMENU:
    581581    {
    582         POINTL pt;
     582        OSLIBPOINT pt;
    583583
    584584        pt.x = (*(POINTS *)&os2Msg->mp1).x;
    585585        pt.y = (*(POINTS *)&os2Msg->mp1).y;
    586         WinMapWindowPoints(os2Msg->hwnd,HWND_DESKTOP,&pt,1);
    587         pt.y = WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN) - pt.y -1;
     586        mapOS2ToWin32Point(os2Msg->hwnd,OSLIB_HWND_DESKTOP,&pt);
    588587        winMsg->message = WINWM_CONTEXTMENU;
    589588        winMsg->wParam  = (WPARAM)win32wnd->getWindowHandle();
  • TabularUnified tags/trunk/src/user32/oslibwin.cpp

    r12830 r12841  
    1 /* $Id: oslibwin.cpp,v 1.55 1999-12-29 12:39:44 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.56 1999-12-29 22:54:01 cbratschi Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    325325//******************************************************************************
    326326//******************************************************************************
    327 BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx,
    328                           LONG cy, ULONG fl)
    329 {
    330  HWND hwndParent = hwndInsertBehind;
    331  BOOL rc;
    332 
    333     if(fl & SWP_MOVE) {
    334         switch(hwndParent)
    335         {
    336             case HWNDOS_TOP:
    337             case HWNDOS_BOTTOM:
    338                 hwndParent = HWND_DESKTOP;
    339                 break;
    340         }
    341         y = MapOS2ToWin32Y(hwndParent, cy, y);
    342     }
    343     rc = WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
    344     dprintf(("WinSetWindowPos %x %x %d %d %d %d %x returned %d (%x)", hwnd, hwndInsertBehind, x, y, cx, cy, fl, rc, WinGetLastError(GetThreadHAB())));
    345     return rc;
    346 }
    347 //******************************************************************************
    348 //******************************************************************************
    349327BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num)
    350328{
     
    383361  if(rc) {
    384362        if(RelativeTo == RELATIVE_TO_SCREEN) {
    385                 MapOS2ToWin32Rectl(OSLIB_HWND_DESKTOP, hwnd, &rectl, pRect);
     363                mapOS2ToWin32Rect(hwnd,OSLIB_HWND_DESKTOP,&rectl,pRect);
    386364        }
    387         else    MapOS2ToWin32WindowRect(&rectl, pRect);
     365        else    mapOS2ToWin32Rect(hwnd,&rectl,pRect);
    388366  }
    389367  else  memset(pRect, 0, sizeof(RECT));
     
    556534                WinMapWindowPoints(hParent, HWND_DESKTOP, &point, 1);
    557535        }
    558         point.y = OSLibQueryScreenHeight() - point.y - swpFrame.cy;
     536        point.y = ScreenHeight-point.y-swpFrame.cy;
    559537
    560538        cy = swpFrame.cy;
     
    579557
    580558    pswpOld->x  = pswp->x;
    581     pswpOld->y  = swpFrame.cy - pswp->y - pswp->cy;
     559    pswpOld->y  = swpFrame.cy-pswp->y-pswp->cy;
    582560    pswpOld->cx = pswp->cx;
    583561    pswpOld->cy = pswp->cy;
     
    643621                WinMapWindowPoints(hParent, HWND_DESKTOP, &point, 1);
    644622        }
    645         point.y = OSLibQueryScreenHeight() - point.y - cy;
     623        point.y = ScreenHeight-point.y-cy;
    646624
    647625        x  = point.x;
     
    664642
    665643    pswpOld->x  = swpClient.x;
    666     pswpOld->y  = pswp->cy - swpClient.y - swpClient.cy;
     644    pswpOld->y  = pswp->cy-swpClient.y-swpClient.cy;
    667645    pswpOld->cx = swpClient.cx;
    668646    pswpOld->cy = swpClient.cy;
     
    734712         if (!((y == 0) && (pswpOld->cy == 0)))
    735713         {
    736             y = parentHeight - y - pswpOld->cy;
     714            y = parentHeight-y-pswpOld->cy;
    737715         }
    738716      }
     
    748726         cy = pswpOld->cy;
    749727      }
    750       y  = parentHeight - y - cy;
     728      y  = parentHeight-y-cy;
    751729
    752730
     
    819797            parentHeight = OSLibGetWindowHeight(hParent);
    820798
    821             point.y = ScreenHeight - point.y - cy;
     799            point.y = ScreenHeight-point.y-cy;
    822800            WinMapWindowPoints(HWND_DESKTOP, hParent, &point, 1);
    823             point.y = parentHeight - point.y - cy;
     801            point.y = parentHeight-point.y-cy;
    824802      }
    825803      else  parentHeight = ScreenHeight;
     
    838816         cy = pswpOld->cy;
    839817      }
    840       y  = parentHeight - y - cy;
     818      y  = parentHeight-y-cy;
    841819
    842820
  • TabularUnified tags/trunk/src/user32/oslibwin.h

    r12830 r12841  
    1 /* $Id: oslibwin.h,v 1.30 1999-12-29 12:39:44 sandervl Exp $ */
     1/* $Id: oslibwin.h,v 1.31 1999-12-29 22:54:01 cbratschi Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    201201#define HWNDOS_BOTTOM                   (HWND)4
    202202
    203 BOOL  OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx, LONG cy, ULONG fl);
    204203BOOL  OSLibWinSetMultWindowPos(struct _SWP *pswp, ULONG num);
    205204BOOL  OSLibWinShowWindow(HWND hwnd, ULONG fl);
  • TabularUnified tags/trunk/src/user32/pmframe.cpp

    r12788 r12841  
    1 /* $Id: pmframe.cpp,v 1.30 1999-12-26 17:30:16 cbratschi Exp $ */
     1/* $Id: pmframe.cpp,v 1.31 1999-12-29 22:54:01 cbratschi Exp $ */
    22/*
    33 * Win32 Frame Managment Code for OS/2
     
    103103BOOL CanDrawSizeBox(Win32BaseWindow *win32wnd)
    104104{
    105   return (win32wnd->getStyle() & WS_SIZEBOX_W && WinQueryWindowULong(win32wnd->getOS2FrameWindowHandle(),QWL_STYLE) & FS_SIZEBORDER
     105  return ((win32wnd->getStyle() & WS_SIZEBOX_W) && (WinQueryWindowULong(win32wnd->getOS2FrameWindowHandle(),QWL_STYLE) & FS_SIZEBORDER)
    106106          && win32wnd->getVertScrollHandle() && WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle()
    107107          && win32wnd->getHorzScrollHandle() && WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle());
     
    347347        DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
    348348
    349         if (dwStyle & CS_HREDRAW_W && newRect->xRight-newRect->xLeft != oldRect->xRight-oldRect->xLeft)
     349        if ((dwStyle & CS_HREDRAW_W) && (newRect->xRight-newRect->xLeft != oldRect->xRight-oldRect->xLeft))
    350350          res |= CVR_REDRAW;
    351         else if (dwStyle & CS_VREDRAW_W && newRect->yTop-newRect->yBottom != oldRect->yTop-oldRect->yBottom)
     351        else if ((dwStyle & CS_VREDRAW_W) && (newRect->yTop-newRect->yBottom != oldRect->yTop-oldRect->yBottom))
    352352          res |= CVR_REDRAW;
    353353      } else res |= CVR_REDRAW;
     
    514514  FrameGetBorderSize(win32wnd,&point);
    515515  WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
    516   if (point.x != win32wnd->getBorderWidth() || point.y != win32wnd->getBorderHeight())
     516  if ((point.x != win32wnd->getBorderWidth()) || (point.y != win32wnd->getBorderHeight()))
    517517  {
    518518    INT xDiff = win32wnd->getBorderWidth()-point.x;
     
    582582    HWND hwndCurPar = WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT);
    583583
    584     if ((fShow && hwndCurPar == hwndObj) || (!fShow && hwndCurPar != hwndObj))
     584    if ((fShow && (hwndCurPar == hwndObj)) || (!fShow && (hwndCurPar != hwndObj)))
    585585    {
    586586      WinSetParent(win32wnd->getHorzScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
     
    593593    HWND hwndCurPar = WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT);
    594594
    595     if ((fShow && hwndCurPar == hwndObj) || (!fShow && hwndCurPar != hwndObj))
     595    if ((fShow && (hwndCurPar == hwndObj)) || (!fShow && (hwndCurPar != hwndObj)))
    596596    {
    597597      WinSetParent(win32wnd->getVertScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
     
    619619  if (win32wnd->getOS2WindowHandle() == WinQueryCapture(HWND_DESKTOP)) return HTCLIENT_W;
    620620  point.x = x;
    621   point.y = WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN)-y-1;
     621  point.y = mapScreenY(y);
    622622  WinMapWindowPoints(HWND_DESKTOP,hwnd,&point,1);
    623623  child = WinWindowFromPoint(hwnd,&point,FALSE);
  • TabularUnified tags/trunk/src/user32/pmwindow.cpp

    r12834 r12841  
    1 /* $Id: pmwindow.cpp,v 1.73 1999-12-29 14:37:16 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.74 1999-12-29 22:54:02 cbratschi Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    6565        //CB: only fail on real error
    6666        error = WinGetLastError(hab) & 0xFFFF; //error code
    67         if (!hab || error != PMERR_MSG_QUEUE_ALREADY_EXISTS)
     67        if (!hab || (error != PMERR_MSG_QUEUE_ALREADY_EXISTS))
    6868        {
    6969            dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
  • TabularUnified tags/trunk/src/user32/win32wbase.cpp

    r12834 r12841  
    1 /* $Id: win32wbase.cpp,v 1.124 1999-12-29 14:37:17 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.125 1999-12-29 22:54:02 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    118118  }
    119119
    120   OSLibWinQueryWindowRect(OS2Hwnd,&rectWindow);
    121   rectClient = rectWindow;
    122   rectClient.bottom -= rectClient.top;
    123   rectClient.top = 0;
    124   rectClient.right -= rectClient.left;
    125   rectClient.left = 0;
     120  OSLibWinQueryWindowRect(OS2Hwnd,&rectClient,RELATIVE_TO_WINDOW);
     121  OSLibWinQueryWindowRect(OS2Hwnd,&rectWindow,RELATIVE_TO_SCREEN);
    126122
    127123  setOldWndProc(SubclassWithDefHandler(OS2Hwnd));
  • TabularUnified tags/trunk/src/user32/win32wbase.h

    r12834 r12841  
    1 /* $Id: win32wbase.h,v 1.59 1999-12-29 14:37:18 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.60 1999-12-29 22:54:03 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    8080         ULONG  MsgPaint(ULONG tmp1, BOOL select = TRUE);
    8181         ULONG  MsgEraseBackGround(HDC hdc);
    82         ULONG  MsgInitMenu(MSG *msg);
    83         ULONG  MsgHitTest(MSG *msg);
     82        ULONG  MsgInitMenu(MSG *msg);
     83        ULONG  MsgHitTest(MSG *msg);
    8484         ULONG  MsgNCPaint();
    85         ULONG  DispatchMsgA(MSG *msg);
    86         ULONG  DispatchMsgW(MSG *msg);
     85        ULONG  DispatchMsgA(MSG *msg);
     86        ULONG  DispatchMsgW(MSG *msg);
    8787
    8888         ULONG  MsgSetText(LPSTR lpsz, LONG cch);
     
    124124        DWORD   getWindowId()                   { return windowId; };
    125125         void   setWindowId(DWORD id);
    126          ULONG  getWindowHeight()               { return rectClient.bottom - rectClient.top; };
    127          ULONG  getWindowWidth()                { return rectClient.right - rectClient.left; };
     126         ULONG  getWindowHeight()               { return rectWindow.bottom - rectWindow.top; };
     127         ULONG  getWindowWidth()                { return rectWindow.right - rectWindow.left; };
     128         ULONG  getClientHeight()               { return rectClient.bottom - rectClient.top; };
     129         ULONG  getClientWidth()                { return rectClient.right - rectClient.left; };
    128130         BOOL   isChild();
    129131         PRECT  getClientRect()                 { return &rectClient; };
  • TabularUnified tags/trunk/src/user32/win32wmdiclient.cpp

    r12834 r12841  
    1 /* $Id: win32wmdiclient.cpp,v 1.19 1999-12-29 14:37:18 sandervl Exp $ */
     1/* $Id: win32wmdiclient.cpp,v 1.20 1999-12-29 22:54:03 cbratschi Exp $ */
    22/*
    33 * Win32 MDI Client Window Class for OS/2
     
    10341034    GetScrollRange(hWnd,SB_HORZ,&minPos,&maxPos);
    10351035    curPos = GetScrollPos(hWnd,SB_HORZ);
    1036     length = win32wnd->getWindowWidth()/2;
     1036    length = win32wnd->getClientWidth()/2;
    10371037    shift = GetSystemMetrics(SM_CYHSCROLL);
    10381038  } else if (uMsg == WM_VSCROLL)
     
    10401040    GetScrollRange(hWnd,SB_VERT,&minPos,&maxPos);
    10411041    curPos = GetScrollPos(hWnd,SB_VERT);
    1042     length = win32wnd->getWindowHeight()/2;
     1042    length = win32wnd->getClientHeight()/2;
    10431043    shift = GetSystemMetrics(SM_CXVSCROLL);
    10441044  } else return;
  • TabularUnified tags/trunk/src/user32/window.cpp

    r12795 r12841  
    1 /* $Id: window.cpp,v 1.45 1999-12-27 17:08:09 cbratschi Exp $ */
     1/* $Id: window.cpp,v 1.46 1999-12-29 22:54:04 cbratschi Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    847847    dprintf(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
    848848    point.x = lpPoints->x;
    849     point.y = wndfrom->getWindowHeight()-1-lpPoints->y;
    850 
    851     OSLibWinMapWindowPoints(wndfrom->getOS2WindowHandle(), wndto->getOS2WindowHandle(), &point, 1);
    852     point.y = wndto->getWindowHeight()-1-point.y;
     849    point.y = lpPoints->y;
     850    if (!mapWin32Point(wndfrom,wndto,&point))
     851    {
     852      SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     853      return 0;
     854    }
    853855
    854856    short int xinc = point.x - lpPoints->x;
     
    875877    wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
    876878    if (!wnd) return (TRUE);
    877 
    878     rcl   = wnd->getClientRect();
    879     pt->y = ScreenHeight - pt->y;
    880     OSLibWinMapWindowPoints (OSLIB_HWND_DESKTOP, wnd->getOS2WindowHandle(), (OSLIBPOINT *)pt, 1);
    881     pt->y = (rcl->bottom - rcl->top) - pt->y;
    882     dprintf(("ScreenToClient %x returned (%d,%d)\n", hwnd, pt->x, pt->y));
    883     return (TRUE);
     879    return mapWin32Point(OSLIB_HWND_DESKTOP,wnd->getOS2WindowHandle(),(OSLIBPOINT*)pt);
    884880}
    885881//******************************************************************************
     
    10041000        return (FALSE);
    10051001    }
    1006 
    1007     rcl  = wnd->getClientRect();
    1008     pt->y = (rcl->bottom - rcl->top) - pt->y;
    1009     OSLibWinMapWindowPoints (wnd->getOS2WindowHandle(), OSLIB_HWND_DESKTOP, (OSLIBPOINT *)pt, 1);
    1010     pt->y = ScreenHeight - pt->y;
    1011     dprintf(("ClientToScreen returned (%d,%d)\n", pt->x, pt->y));
    1012     return (TRUE);
     1002    return mapWin32Point(wnd->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,(OSLIBPOINT*)pt);
    10131003}
    10141004//******************************************************************************
     
    12631253
    12641254    wPoint.x = point.x;
    1265     wPoint.y = windowDesktop->getWindowHeight() - point.y;
     1255    wPoint.y = mapScreenY(point.y);
    12661256
    12671257    hwndOS2 = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&wPoint);
Note: See TracChangeset for help on using the changeset viewer.