Changeset 1091 for trunk/src


Ignore:
Timestamp:
Sep 29, 1999, 10:27:16 AM (26 years ago)
Author:
sandervl
Message:

Scrollbar changes

Location:
trunk/src/user32
Files:
5 edited

Legend:

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

    r1057 r1091  
    1 /* $Id: oslibwin.cpp,v 1.9 1999-09-26 10:09:59 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.10 1999-09-29 08:27:15 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    709709   }
    710710   return TRUE;   
     711}
     712//******************************************************************************
     713//******************************************************************************
     714ULONG OSLibWinGetScrollPos(HWND hwndParent, int scrollBar)
     715{
     716 HWND hwndScroll;
     717
     718   if(scrollBar == OSLIB_VSCROLL) {
     719        hwndScroll = WinWindowFromID(hwndParent, FID_VERTSCROLL);
     720   }
     721   else hwndScroll = WinWindowFromID(hwndParent, FID_HORZSCROLL);
     722
     723   if(hwndScroll == NULL)
     724        return 0;
     725
     726   return (ULONG)WinSendMsg(hwndScroll, SBM_QUERYPOS, 0, 0);
     727}
     728//******************************************************************************
     729//******************************************************************************
     730ULONG OSLibWinSetScrollPos(HWND hwndParent, int scrollBar, int pos, int fRedraw)
     731{
     732 HWND  hwndScroll;
     733 ULONG oldPos;
     734
     735   if(scrollBar == OSLIB_VSCROLL) {
     736        hwndScroll = WinWindowFromID(hwndParent, FID_VERTSCROLL);
     737   }
     738   else hwndScroll = WinWindowFromID(hwndParent, FID_HORZSCROLL);
     739
     740   if(hwndScroll == NULL)
     741        return 0;
     742
     743   oldPos = (ULONG)WinSendMsg(hwndScroll, SBM_QUERYPOS, 0, 0);
     744
     745   if(WinSendMsg(hwndScroll, SBM_SETPOS, MPFROMSHORT(pos), MPFROMLONG(fRedraw)) == FALSE)
     746        return 0;
     747
     748   return oldPos;
     749}
     750//******************************************************************************
     751//******************************************************************************
     752BOOL OSLibWinSetScrollRange(HWND hwndParent, int scrollBar, int minpos,
     753                            int maxpos, int fRedraw)
     754{
     755 HWND hwndScroll;
     756
     757   if(scrollBar == OSLIB_VSCROLL) {
     758        hwndScroll = WinWindowFromID(hwndParent, FID_VERTSCROLL);
     759   }
     760   else hwndScroll = WinWindowFromID(hwndParent, FID_HORZSCROLL);
     761
     762   if(hwndScroll == NULL)
     763        return 0;
     764
     765   return (BOOL)WinSendMsg( hwndScroll, SBM_SETSCROLLBAR,
     766                            MPFROMLONG(WinSendMsg(hwndScroll, SBM_QUERYPOS, 0, 0)),
     767                            MPFROM2SHORT( minpos ,maxpos ) );
     768}
     769//******************************************************************************
     770//******************************************************************************
     771BOOL OSLibWinSetScrollPageSize(HWND hwndParent, int scrollBar, int pagesize,
     772                               int totalsize, int fRedraw)
     773{
     774 HWND hwndScroll;
     775
     776   if(scrollBar == OSLIB_VSCROLL) {
     777        hwndScroll = WinWindowFromID(hwndParent, FID_VERTSCROLL);
     778   }
     779   else hwndScroll = WinWindowFromID(hwndParent, FID_HORZSCROLL);
     780
     781   if(hwndScroll == NULL)
     782        return 0;
     783
     784   return (BOOL)WinSendMsg( hwndScroll, SBM_SETTHUMBSIZE,
     785                            MPFROM2SHORT(pagesize, totalsize),
     786                            0);
     787}
     788//******************************************************************************
     789//******************************************************************************
     790void OSLibWinChangeScrollStyle(HWND hwndParent, int scrollBar, int Reserved)
     791{
     792 HWND hwndScroll;
     793
     794   if(scrollBar == OSLIB_VSCROLL) {
     795        hwndScroll = WinWindowFromID(hwndParent, FID_VERTSCROLL);
     796   }
     797   else hwndScroll = WinWindowFromID(hwndParent, FID_HORZSCROLL);
     798
     799   if(hwndScroll == NULL)
     800        return;
     801
     802   WinSetWindowULong(hwndScroll, QWL_STYLE,
     803                     WinQueryWindowULong(hwndScroll, QWL_STYLE) |
     804                     SBS_AUTOTRACK | SBS_AUTOSIZE);
    711805}
    712806//******************************************************************************
  • trunk/src/user32/oslibwin.h

    r1057 r1091  
    1 /* $Id: oslibwin.h,v 1.5 1999-09-26 10:09:59 sandervl Exp $ */
     1/* $Id: oslibwin.h,v 1.6 1999-09-29 08:27:15 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    246246BOOL  OSLibWinEnableScrollBar(HWND hwndParent, int scrollBar, BOOL fEnable);
    247247BOOL  OSLibWinShowScrollBar(HWND hwndParent, int scrollBar, BOOL fShow);
     248ULONG OSLibWinGetScrollPos(HWND hwndParent, int scrollBar);
     249ULONG OSLibWinSetScrollPos(HWND hwndParent, int scrollBar, int pos, int fRedraw);
     250BOOL  OSLibWinSetScrollRange(HWND hwndParent, int scrollBar, int minpos,
     251                             int maxpos, int fRedraw);
     252BOOL  OSLibWinSetScrollPageSize(HWND hwndParent, int scrollBar, int pagesize,
     253                                int totalsize, int fRedraw);
     254void  OSLibWinChangeScrollStyle(HWND hwndParent, int scrollBar, int Reserved);
     255
    248256void  OSLibTranslateScrollCmdAndMsg(ULONG *msg, ULONG *scrollcmd);
    249257
  • trunk/src/user32/scroll.cpp

    r1064 r1091  
    1 /* $Id: scroll.cpp,v 1.3 1999-09-26 15:25:55 sandervl Exp $ */
     1/* $Id: scroll.cpp,v 1.4 1999-09-29 08:27:15 sandervl Exp $ */
    22/*
    33 * Scrollbar control
     
    167167static SCROLLBAR_INFO *SCROLL_GetScrollInfo( HWND hwnd, INT nBar )
    168168{
    169    return SCROLL_GetPtrScrollInfo( hwnd, nBar );
     169 Win32BaseWindow *window;
     170
     171    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     172    if(!window && nBar != SB_CTL) {
     173        dprintf(("SCROLL_GetScrollInfo window %x not found!", hwnd));
     174        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     175        return NULL;
     176    }
     177
     178    if (window) {
     179            return window->getScrollInfo(nBar);
     180    }
     181
     182    return SCROLL_GetPtrScrollInfo( hwnd, nBar );
    170183}
    171184
     
    11251138  Win32BaseWindow *window;
    11261139  INT action;
    1127   INT retVal = SCROLL_SetScrollInfo( hwnd, nBar, info, &action );
     1140  INT retVal;
    11281141
    11291142    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    1130     if(!window) {
     1143    if(!window && nBar != SB_CTL) {
    11311144        dprintf(("SetScrollInfo window not found!"));
    11321145        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    11331146        return FALSE;
    11341147    }
    1135 
     1148    if(window) {
     1149        return window->setScrollInfo(nBar, (SCROLLINFO *)info, bRedraw);
     1150    }
     1151
     1152    retVal = SCROLL_SetScrollInfo( hwnd, nBar, info, &action );
    11361153    if( action & SA_SSI_HIDE )
    11371154        SCROLL_ShowScrollBar( hwnd, nBar, FALSE, FALSE );
     
    11701187
    11711188    /* Set the page size */
    1172 
    11731189    if (info->fMask & SIF_PAGE)
    11741190    {
     
    11821198
    11831199    /* Set the scroll pos */
    1184 
    11851200    if (info->fMask & SIF_POS)
    11861201    {
     
    11941209
    11951210    /* Set the scroll range */
    1196 
    11971211    if (info->fMask & SIF_RANGE)
    11981212    {
     
    12391253
    12401254    /* Check if the scrollbar should be hidden or disabled */
    1241 
    12421255    if (info->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL))
    12431256    {
     
    12881301                LPSCROLLINFO info /* [IO] (info.fMask [I] specifies which values are to retrieve) */)
    12891302{
    1290   Win32BaseWindow *window;
    12911303  SCROLLBAR_INFO *infoPtr;
    12921304
    1293     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    1294     if(!window) {
    1295         dprintf(("GetScrollInfo window not found!"));
    1296         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    1297         return FALSE;
    1298     }
    12991305    if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return FALSE;
    13001306    if (info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) return FALSE;
     
    13301336                BOOL bRedraw /* [I] Should scrollbar be redrawn afterwards ? */ )
    13311337{
    1332   Win32BaseWindow *window;
    13331338  SCROLLINFO info;
    13341339  SCROLLBAR_INFO *infoPtr;
     
    13361341
    13371342    dprintf(("SetScrollPos %x %d %d %d", hwnd, nBar, nPos, bRedraw));
    1338     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    1339     if(!window) {
    1340         dprintf(("SetScrollPos window not found!"));
    1341         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    1342         return FALSE;
    1343     }
    1344 
    13451343    if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return 0;
    13461344    oldPos      = infoPtr->CurVal;
     
    13661364                INT nBar /* [I] One of SB_HORZ, SB_VERT, or SB_CTL */)
    13671365{
    1368   Win32BaseWindow *window;
    13691366  SCROLLBAR_INFO *infoPtr;
    13701367
    13711368    dprintf(("GetScrollPos %x %d", hwnd, nBar));
    13721369
    1373     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    1374     if(!window) {
    1375         dprintf(("GetScrollPos window not found!"));
    1376         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    1377         return 0;
    1378     }
    1379 
    1380     if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return 0;
     1370    infoPtr = SCROLL_GetScrollInfo( hwnd, nBar );
     1371    if (!infoPtr) return 0;
     1372
    13811373    return infoPtr->CurVal;
    13821374}
     
    13931385                BOOL bRedraw /* [I] Should scrollbar be redrawn afterwards ? */)
    13941386{
    1395   Win32BaseWindow *window;
    13961387  SCROLLINFO info;
    13971388
    1398     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    1399     if(!window) {
    1400         dprintf(("SetScrollRange window not found!"));
    1401         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    1402         return FALSE;
    1403     }
    1404 
     1389    dprintf(("SetScrollRange %x %x %d %d %d", hwnd, nBar, MinVal, MaxVal, bRedraw));
    14051390    info.cbSize = sizeof(info);
    14061391    info.nMin   = MinVal;
     
    14551440                LPINT lpMax  /* [O] Where to store maximum value */)
    14561441{
    1457   Win32BaseWindow *window;
    14581442  SCROLLBAR_INFO *infoPtr;
    14591443
    1460     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    1461     if(!window) {
    1462         dprintf(("GetScrollRange window not found!"));
    1463         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    1464         return FALSE;
    1465     }
    1466 
    1467     if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar )))
     1444    infoPtr = SCROLL_GetScrollInfo( hwnd, nBar );
     1445    if (!infoPtr)
    14681446    {
    14691447        if (lpMin) lpMin = 0;
     
    15661544
    15671545    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    1568     if(!window) {
     1546    if(!window && nBar != SB_CTL) {
    15691547        dprintf(("ShowScrollBar window not found!"));
    15701548        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     
    16001578
    16011579    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    1602     if(!window) {
     1580    if(!window && nBar != SB_CTL) {
    16031581        dprintf(("EnableScrollBar window not found!"));
    16041582        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
  • trunk/src/user32/win32wbase.cpp

    r1083 r1091  
    1 /* $Id: win32wbase.cpp,v 1.18 1999-09-28 13:27:52 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.19 1999-09-29 08:27:15 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    122122  PSEraseFlag        = FALSE;
    123123  SupressEraseFlag   = FALSE;
     124
     125  horzScrollInfo     = NULL;
     126  vertScrollInfo     = NULL;
     127
    124128}
    125129//******************************************************************************
     
    146150        free(windowNameW);
    147151        windowNameW = NULL;
     152  }
     153  if(vertScrollInfo) {
     154        free(vertScrollInfo);
     155        vertScrollInfo = NULL;
     156  }
     157  if(horzScrollInfo) {
     158        free(horzScrollInfo);
     159        horzScrollInfo = NULL;
    148160  }
    149161}
     
    361373#endif
    362374
     375  if (cs->style & WS_HSCROLL)
     376  {
     377        horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
     378        horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
     379        horzScrollInfo->MaxVal = 100;
     380        horzScrollInfo->flags  = ESB_ENABLE_BOTH;
     381  }
     382
     383  if (cs->style & WS_VSCROLL)
     384  {
     385        vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
     386        vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
     387        vertScrollInfo->MaxVal = 100;
     388        vertScrollInfo->flags  = ESB_ENABLE_BOTH;
     389  }
     390
    363391  /* Send the WM_GETMINMAXINFO message and fix the size if needed */
    364392  if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
     
    427455        dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
    428456        return FALSE;
     457  }
     458  if(cs->style & WS_HSCROLL) {
     459        OSLibWinChangeScrollStyle(OS2HwndFrame, OSLIB_HSCROLL, 0);
     460  }
     461  if(cs->style & WS_VSCROLL) {
     462        OSLibWinChangeScrollStyle(OS2HwndFrame, OSLIB_VSCROLL, 0);
    429463  }
    430464#if 0
     
    12111245}
    12121246//******************************************************************************
     1247//TODO: Not complete (flags)
     1248//******************************************************************************
     1249SCROLLBAR_INFO *Win32BaseWindow::getScrollInfo(int nBar)
     1250{
     1251    switch(nBar) {
     1252    case SB_HORZ:
     1253        if(horzScrollInfo) {
     1254            horzScrollInfo->CurVal = OSLibWinGetScrollPos(OS2HwndFrame, OSLIB_HSCROLL);
     1255            return horzScrollInfo;
     1256        }
     1257        break;
     1258    case SB_VERT:
     1259        if(vertScrollInfo) {
     1260            vertScrollInfo->CurVal = OSLibWinGetScrollPos(OS2HwndFrame, OSLIB_VSCROLL);
     1261            return vertScrollInfo;
     1262        }
     1263        break;
     1264    }
     1265    return NULL;
     1266}
     1267//******************************************************************************
     1268//TODO: Not complete
     1269//******************************************************************************
     1270LONG Win32BaseWindow::setScrollInfo(int nBar, SCROLLINFO *info, int fRedraw)
     1271{
     1272  SCROLLBAR_INFO *infoPtr;
     1273  ULONG           scrollType;
     1274  int             new_flags;
     1275
     1276    switch(nBar) {
     1277    case SB_HORZ:
     1278        if(!horzScrollInfo) {
     1279            return 0;
     1280        }
     1281        infoPtr = horzScrollInfo;
     1282        scrollType = OSLIB_HSCROLL;
     1283        break;
     1284    case SB_VERT:
     1285        if(!vertScrollInfo) {
     1286            return 0;
     1287        }
     1288        infoPtr = vertScrollInfo;
     1289        scrollType = OSLIB_VSCROLL;
     1290        break;
     1291    default:
     1292        return 0;
     1293    }
     1294
     1295    if (info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) return 0;
     1296    if ((info->cbSize != sizeof(*info)) &&
     1297        (info->cbSize != sizeof(*info)-sizeof(info->nTrackPos))) return 0;
     1298
     1299    /* Set the page size */
     1300    if (info->fMask & SIF_PAGE)
     1301    {
     1302        if( infoPtr->Page != info->nPage )
     1303        {
     1304            infoPtr->Page = info->nPage;
     1305            OSLibWinSetScrollPageSize(OS2HwndFrame, scrollType, info->nPage, infoPtr->MaxVal, fRedraw);
     1306        }
     1307    }
     1308
     1309    /* Set the scroll pos */
     1310    if (info->fMask & SIF_POS)
     1311    {
     1312        if( infoPtr->CurVal != info->nPos )
     1313        {
     1314            infoPtr->CurVal = info->nPos;
     1315            OSLibWinSetScrollPos(OS2HwndFrame, scrollType, info->nPos, fRedraw);
     1316        }
     1317    }
     1318
     1319    /* Set the scroll range */
     1320    if (info->fMask & SIF_RANGE)
     1321    {
     1322        /* Invalid range -> range is set to (0,0) */
     1323        if ((info->nMin > info->nMax) ||
     1324            ((UINT)(info->nMax - info->nMin) >= 0x80000000))
     1325        {
     1326            infoPtr->MinVal = 0;
     1327            infoPtr->MaxVal = 0;
     1328        }
     1329        else
     1330        {
     1331            if( infoPtr->MinVal != info->nMin ||
     1332                infoPtr->MaxVal != info->nMax )
     1333            {
     1334                infoPtr->MinVal = info->nMin;
     1335                infoPtr->MaxVal = info->nMax;
     1336
     1337                OSLibWinSetScrollRange(OS2HwndFrame, scrollType, info->nMin, info->nMax, fRedraw);
     1338            }
     1339        }
     1340    }
     1341
     1342    /* Make sure the page size is valid */
     1343    if (infoPtr->Page < 0) infoPtr->Page = 0;
     1344    else if (infoPtr->Page > infoPtr->MaxVal - infoPtr->MinVal + 1 )
     1345        infoPtr->Page = infoPtr->MaxVal - infoPtr->MinVal + 1;
     1346
     1347    /* Make sure the pos is inside the range */
     1348    if (infoPtr->CurVal < infoPtr->MinVal)
     1349        infoPtr->CurVal = infoPtr->MinVal;
     1350    else if (infoPtr->CurVal > infoPtr->MaxVal - MAX( infoPtr->Page-1, 0 ))
     1351        infoPtr->CurVal = infoPtr->MaxVal - MAX( infoPtr->Page-1, 0 );
     1352
     1353    /* Check if the scrollbar should be hidden or disabled */
     1354    if (info->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL))
     1355    {
     1356        new_flags = infoPtr->flags;
     1357        if (infoPtr->MinVal >= infoPtr->MaxVal - MAX( infoPtr->Page-1, 0 ))
     1358        {
     1359            /* Hide or disable scroll-bar */
     1360            if (info->fMask & SIF_DISABLENOSCROLL)
     1361            {
     1362                new_flags = ESB_DISABLE_BOTH;
     1363                //TODO:
     1364            }
     1365            else if (nBar != SB_CTL)
     1366            {
     1367                //TODO
     1368                goto done;
     1369            }
     1370        }
     1371        else  /* Show and enable scroll-bar */
     1372        {
     1373            //TODO
     1374            new_flags = 0;
     1375        }
     1376
     1377        if (infoPtr->flags != new_flags) /* check arrow flags */
     1378        {
     1379            infoPtr->flags = new_flags;
     1380        }
     1381    }
     1382
     1383done:
     1384    /* Return current position */
     1385
     1386    return infoPtr->CurVal;
     1387}
     1388//******************************************************************************
    12131389//******************************************************************************
    12141390LRESULT Win32BaseWindow::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam)
     
    13501526#if 0
    13511527    case WM_SYSKEYDOWN:
    1352             if(HIWORD(lParam) & KEYDATA_ALT)
    1353             {
    1354             if(wParam == VK_F4) /* try to close the window */
    1355             {
    1356                     HWND hWnd = WIN_GetTopParent( wndPtr->hwndSelf );
    1357                     wndPtr = WIN_FindWndPtr( hWnd );
    1358                     if( wndPtr && !(getClass()->getStyle() & CS_NOCLOSE) )
    1359                             PostMessage(WM_SYSCOMMAND, SC_CLOSE, 0);
    1360             }
    1361         }
    1362         return 0;
     1528        if(HIWORD(lParam) & KEYDATA_ALT)
     1529        {
     1530            if(wParam == VK_F4) /* try to close the window */
     1531            {
     1532                HWND hWnd = WIN_GetTopParent( wndPtr->hwndSelf );
     1533                wndPtr = WIN_FindWndPtr( hWnd );
     1534                if( wndPtr && !(getClass()->getStyle() & CS_NOCLOSE) )
     1535                    PostMessage(WM_SYSCOMMAND, SC_CLOSE, 0);
     1536            }
     1537        }
     1538        return 0;
    13631539#endif
    13641540
  • trunk/src/user32/win32wbase.h

    r1067 r1091  
    1 /* $Id: win32wbase.h,v 1.8 1999-09-26 22:24:31 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.9 1999-09-29 08:27:16 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    2222#include <winres.h>
    2323#include <winconst.h>
     24#include <scroll.h>
    2425
    2526class Win32BaseWindow;
     
    174175
    175176Win32BaseWindow *getTopParent();
     177 SCROLLBAR_INFO *getScrollInfo(int nBar);
     178       LONG      setScrollInfo(int nBar, SCROLLINFO *info, int fRedraw);
    176179
    177180       LRESULT  SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
     
    243246        RECT    rectWindow;
    244247        RECT    rectClient;
     248
     249SCROLLBAR_INFO *vertScrollInfo;
     250SCROLLBAR_INFO *horzScrollInfo;
    245251
    246252Win32WndClass  *windowClass;
Note: See TracChangeset for help on using the changeset viewer.