Ignore:
Timestamp:
Jan 9, 2000, 3:14:25 PM (26 years ago)
Author:
cbratschi
Message:

scrollbar support and many other things

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/new/pmframe.cpp

    r2377 r2381  
    1 /* $Id: pmframe.cpp,v 1.8 2000-01-08 16:47:47 cbratschi Exp $ */
     1/* $Id: pmframe.cpp,v 1.9 2000-01-09 14:14:23 cbratschi Exp $ */
    22/*
    33 * Win32 Frame Managment Code for OS/2
     
    3131//******************************************************************************
    3232//******************************************************************************
    33 VOID Draw3DRect(HPS hps,RECTL rect,LONG colorBR,LONG colorTL)
    34 {
    35   POINTL point;
    36 
    37   GpiSetColor(hps,colorBR);
    38   point.x = rect.xLeft;
    39   point.y = rect.yBottom;
    40   GpiMove(hps,&point);
    41   point.x = rect.xRight-1;
    42   GpiLine(hps,&point);
    43   point.y = rect.yTop-1;
    44   GpiLine(hps,&point);
    45   GpiSetColor(hps,colorTL);
    46   point.x--;
    47   GpiMove(hps,&point);
    48   point.x = rect.xLeft;
    49   GpiLine(hps,&point);
    50   point.y = rect.yBottom+1;
    51   GpiLine(hps,&point);
    52 }
    53 //******************************************************************************
    54 //******************************************************************************
    55 inline VOID DeflateRect(RECTL *rect)
    56 {
    57   rect->xLeft++;
    58   rect->xRight--;
    59   rect->yTop--;
    60   rect->yBottom++;
    61 }
    62 //******************************************************************************
    63 //******************************************************************************
    64 VOID DrawFrame(HPS hps,RECTL *rect,Win32BaseWindow *win32wnd)
    65 {
    66   LONG clrWhite,clrBlack,clrDark,clrLight;
    67   POINTL point;
    68   DWORD dwExStyle = win32wnd->getExStyle();
    69   DWORD dwStyle = win32wnd->getStyle();
    70 
    71   //CB: todo: switch to RGB mode and use win colors
    72   clrWhite = CLR_WHITE;
    73   clrBlack = CLR_BLACK;
    74   clrLight = CLR_PALEGRAY;
    75   clrDark  = CLR_DARKGRAY;
    76 
    77   if (dwExStyle & WS_EX_CLIENTEDGE_W)
    78   {
    79     Draw3DRect(hps,*rect,clrWhite,clrDark);
    80     DeflateRect(rect);
    81     Draw3DRect(hps,*rect,clrLight,clrBlack);
    82   }
    83   else if (dwExStyle & WS_EX_DLGMODALFRAME_W)
    84   {
    85     Draw3DRect(hps,*rect,clrBlack,clrLight);
    86     DeflateRect(rect);
    87     Draw3DRect(hps,*rect,clrDark,clrWhite);
    88     DeflateRect(rect);
    89     Draw3DRect(hps,*rect,clrLight,clrLight);
    90   }
    91   else if (dwExStyle & WS_EX_STATICEDGE_W)
    92   {
    93     Draw3DRect(hps,*rect,clrWhite,clrDark);
    94   }
    95   else if (dwExStyle & WS_EX_WINDOWEDGE_W);
    96   else if (dwStyle & WS_BORDER_W)
    97   {
    98     Draw3DRect(hps,*rect,clrBlack,clrBlack);
    99   }
    100 
    101   DeflateRect(rect);
    102 }
    103 //******************************************************************************
    104 //******************************************************************************
    105 BOOL CanDrawSizeBox(Win32BaseWindow *win32wnd)
    106 {
    107   return ((win32wnd->getStyle() & WS_SIZEBOX_W) && (WinQueryWindowULong(win32wnd->getOS2FrameWindowHandle(),QWL_STYLE) & FS_SIZEBORDER)
    108           && win32wnd->getVertScrollHandle() && WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle()
    109           && win32wnd->getHorzScrollHandle() && WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle());
    110 }
    111 //******************************************************************************
    112 //******************************************************************************
    113 VOID GetSizeBox(Win32BaseWindow *win32wnd,RECTL *rect)
    114 {
    115   SWP swpHorz,swpVert;
    116 
    117   WinQueryWindowPos(win32wnd->getVertScrollHandle(),&swpVert);
    118   WinQueryWindowPos(win32wnd->getHorzScrollHandle(),&swpHorz);
    119   rect->xLeft = swpVert.x;
    120   rect->xRight = swpVert.x+swpVert.cx;
    121   rect->yTop = swpHorz.y+swpHorz.cy;
    122   rect->yBottom = swpHorz.y;
    123 }
    124 //******************************************************************************
    125 //******************************************************************************
    126 BOOL InSizeBox(Win32BaseWindow *win32wnd,POINTS *points)
    127 {
    128   if (CanDrawSizeBox(win32wnd))
    129   {
    130     RECTL rect;
    131     POINTL point;
    132 
    133     point.x = points->x;
    134     point.y = points->y;
    135     GetSizeBox(win32wnd,&rect);
    136     return (WinPtInRect(GetThreadHAB(),&rect,&point));
    137   }
    138 
    139   return FALSE;
    140 }
    141 //******************************************************************************
    142 //******************************************************************************
    143 VOID DrawSizeBox(HPS hps,RECTL rect)
    144 {
    145   POINTL p1,p2;
    146   LONG clrDark = CLR_DARKGRAY,clrWhite = CLR_WHITE;
    147   INT x;
    148 
    149   //CB: todo: switch to RGB mode and use win colors
    150   WinFillRect(hps,&rect,SYSCLR_DIALOGBACKGROUND);
    151   p1.x = rect.xRight-2;
    152   p1.y = rect.yBottom;
    153   p2.x = rect.xRight-1;
    154   p2.y = rect.yBottom+1;
    155   for (x = 0;x < 3;x++)
    156   {
    157     GpiSetColor(hps,clrDark);
    158     GpiMove(hps,&p1);
    159     GpiLine(hps,&p2);
    160     p1.x--;
    161     p2.y++;
    162     GpiMove(hps,&p1);
    163     GpiLine(hps,&p2);
    164     GpiSetColor(hps,clrWhite);
    165     p1.x--;
    166     p2.y++;
    167     GpiMove(hps,&p1);
    168     GpiLine(hps,&p2);
    169     p1.x -= 2;
    170     p2.y += 2;
    171   }
    172 }
    173 //******************************************************************************
    174 //******************************************************************************
    175 void DrawActivate(Win32BaseWindow *win32wnd, HWND hwnd)
    176 {
    177     if (!win32wnd->isChild())
    178     {
    179         if (CanDrawSizeBox(win32wnd))
    180         {
    181           HPS hps;
    182           RECTL rect;
    183 
    184           GetSizeBox(win32wnd,&rect);
    185           hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
    186           DrawSizeBox(hps,rect);
    187           WinReleasePS(hps);
    188 
    189         }
    190     }
    191     else
    192     {
    193         HPS hps;
    194         RECTL rect;
    195 
    196         WinQueryWindowRect(hwnd,&rect);
    197         rect.xRight = rect.xRight-rect.xLeft;
    198         rect.yTop = rect.yTop-rect.yBottom;
    199         rect.xLeft = rect.yBottom = 0;
    200         hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
    201         DrawFrame(hps,&rect,win32wnd);
    202         WinReleasePS(hps);
    203     }
    204 }
    205 //******************************************************************************
    206 //******************************************************************************
    20733VOID FrameTrackFrame(Win32BaseWindow *win32wnd,DWORD flags)
    20834{
     
    594420}
    595421
    596 VOID FrameGetBorderSize(Win32BaseWindow *win32wnd,PWPOINT pSize)
    597 {
    598   WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_QUERYBORDERSIZE,(MPARAM)pSize,(MPARAM)0);
    599 }
    600 
    601 VOID FrameSetBorderSize(Win32BaseWindow *win32wnd,BOOL resize)
    602 {
    603   POINTL point;
    604 
    605   if (!resize)
    606   {
    607     WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
    608 
    609     return;
    610   }
    611 
    612   FrameGetBorderSize(win32wnd,&point);
    613   WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
    614   if ((point.x != win32wnd->getBorderWidth()) || (point.y != win32wnd->getBorderHeight()))
    615   {
    616     INT xDiff = win32wnd->getBorderWidth()-point.x;
    617     INT yDiff = win32wnd->getBorderHeight()-point.y;
    618     SWP swp;
    619 
    620     WinQueryWindowPos(win32wnd->getOS2FrameWindowHandle(),&swp);
    621     swp.x  += xDiff;
    622     swp.y  += yDiff;
    623     swp.cx -= 2*xDiff;
    624     swp.cy -= 2*yDiff;
    625     WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),0,swp.x,swp.y,swp.cx,swp.cy,SWP_MOVE | SWP_SIZE);
    626   }
    627 }
    628 
    629 UINT FrameGetDefSizeBorderSize(VOID)
    630 {
    631   return WinQuerySysValue(HWND_DESKTOP,SV_CXSIZEBORDER);
    632 }
    633 
    634 BOOL FrameCreateScrollBars(Win32BaseWindow *win32wnd,BOOL createHorz,BOOL createVert,BOOL updateFrame,DWORD *flags)
    635 {
    636   HWND hwndHScroll = 0,hwndVScroll = 0;
    637   ULONG updateFlags = 0;
    638 
    639   if (createHorz)
    640   {
    641     hwndHScroll = WinCreateWindow(win32wnd->getOS2FrameWindowHandle(),WC_SCROLLBAR,"",WS_VISIBLE | WS_PARENTCLIP | WS_SYNCPAINT | SBS_HORZ,0,0,0,0,win32wnd->getOS2FrameWindowHandle(),HWND_TOP,FID_HORZSCROLL,NULL,NULL);
    642     if (hwndHScroll) win32wnd->setHorzScrollHandle(hwndHScroll);
    643     else return FALSE;
    644     updateFlags = FCF_HORZSCROLL;
    645   }
    646 
    647   if (createVert)
    648   {
    649     hwndVScroll = WinCreateWindow(win32wnd->getOS2FrameWindowHandle(),WC_SCROLLBAR,"",WS_VISIBLE | WS_PARENTCLIP | WS_SYNCPAINT | SBS_VERT,0,0,0,0,win32wnd->getOS2FrameWindowHandle(),HWND_TOP,FID_VERTSCROLL,NULL,NULL);
    650     if (hwndVScroll) win32wnd->setVertScrollHandle(hwndVScroll); else
    651     {
    652       if (hwndHScroll) WinDestroyWindow(hwndHScroll);
    653 
    654       return FALSE;
    655     }
    656     updateFlags |= FCF_VERTSCROLL;
    657   }
    658 
    659   win32wnd->subclassScrollBars(hwndHScroll,hwndVScroll);
    660 
    661   if (updateFrame && updateFlags) WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)0,(MPARAM)0);
    662   if (flags) *flags = updateFlags;
    663 
    664   return TRUE;
    665 }
    666 
    667 VOID FrameGetScrollBarHandles(Win32BaseWindow *win32wnd,BOOL getHorz,BOOL getVert)
    668 {
    669   if (getHorz) win32wnd->setHorzScrollHandle(WinWindowFromID(win32wnd->getOS2FrameWindowHandle(),FID_HORZSCROLL));
    670   if (getVert) win32wnd->setVertScrollHandle(WinWindowFromID(win32wnd->getOS2FrameWindowHandle(),FID_VERTSCROLL));
    671 }
    672 
    673 BOOL FrameShowScrollBars(Win32BaseWindow *win32wnd,BOOL changeHorz,BOOL changeVert,BOOL fShow,BOOL updateFrame,DWORD *flags)
    674 {
    675   HWND hwndObj = WinQueryObjectWindow(HWND_DESKTOP);
    676   ULONG updateFlags = 0;
    677 
    678   if (changeHorz)
    679   {
    680     HWND hwndCurPar = WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT);
    681 
    682     if ((fShow && (hwndCurPar == hwndObj)) || (!fShow && (hwndCurPar != hwndObj)))
    683     {
    684       WinSetParent(win32wnd->getHorzScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
    685       updateFlags |= FCF_HORZSCROLL;
    686     }
    687   }
    688 
    689   if (changeVert)
    690   {
    691     HWND hwndCurPar = WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT);
    692 
    693     if ((fShow && (hwndCurPar == hwndObj)) || (!fShow && (hwndCurPar != hwndObj)))
    694     {
    695       WinSetParent(win32wnd->getVertScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
    696       updateFlags |= FCF_VERTSCROLL;
    697     }
    698   }
    699 
    700   if (updateFrame && updateFlags) WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)updateFlags,(MPARAM)0);
    701   if (flags) *flags = updateFlags;
    702 
    703   return TRUE;
    704 }
    705 
    706422VOID FrameUpdateFrame(Win32BaseWindow *win32wnd,DWORD flags)
    707423{
    708424  WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)flags,(MPARAM)0);
    709425}
    710 
    711 DWORD FrameHitTest(Win32BaseWindow *win32wnd,INT x,INT y)
    712 {
    713   POINTL point;
    714   HWND hwnd = win32wnd->getOS2FrameWindowHandle(),child;
    715 
    716   if (hwnd == win32wnd->getOS2WindowHandle()) return HTCLIENT_W;
    717   if (win32wnd->getOS2WindowHandle() == WinQueryCapture(HWND_DESKTOP)) return HTCLIENT_W;
    718   point.x = x;
    719   point.y = mapScreenY(y);
    720   WinMapWindowPoints(HWND_DESKTOP,hwnd,&point,1);
    721   child = WinWindowFromPoint(hwnd,&point,FALSE);
    722 
    723   if (child == 0) return HTERROR_W;
    724   if (child == win32wnd->getOS2FrameWindowHandle())
    725   {
    726     RECTL client,frame;
    727 
    728     if (CanDrawSizeBox(win32wnd))
    729     {
    730       RECTL rect;
    731 
    732       GetSizeBox(win32wnd,&rect);
    733       if (WinPtInRect(GetThreadHAB(),&rect,&point)) return HTGROWBOX_W;
    734     }
    735     //somewhere in the border
    736     INT w = WinQuerySysValue(HWND_DESKTOP,SV_CXMINMAXBUTTON);
    737     INT h = WinQuerySysValue(HWND_DESKTOP,SV_CXMINMAXBUTTON);
    738     WinQueryWindowRect(hwnd,&frame);
    739 
    740     if (point.y < h)
    741     {
    742       if (point.x < w) return HTBOTTOMLEFT_W;
    743       if (point.x > frame.xRight-1-w) return HTBOTTOMRIGHT_W;
    744       return HTBOTTOM_W;
    745     }
    746     if (point.y > frame.yTop-1-h)
    747     {
    748       if (point.x < w) return HTTOPLEFT_W;
    749       if (point.x > frame.xRight-1-w) return HTTOPRIGHT_W;
    750       return HTTOP_W;
    751     }
    752     return HTBORDER_W;
    753   } else
    754   {
    755     if (child == WinWindowFromID(hwnd,FID_CLIENT)) return HTCLIENT_W;
    756     if (child == WinWindowFromID(hwnd,FID_VERTSCROLL)) return HTVSCROLL_W;
    757     if (child == WinWindowFromID(hwnd,FID_HORZSCROLL)) return HTHSCROLL_W;
    758     if (child == WinWindowFromID(hwnd,FID_SYSMENU)) return HTSYSMENU_W;
    759     if (child == WinWindowFromID(hwnd,FID_TITLEBAR)) return HTCAPTION_W;
    760     if (child == WinWindowFromID(hwnd,FID_MENU)) return HTMENU_W;
    761     if (child == WinWindowFromID(hwnd,FID_MINMAX))
    762     {
    763       //CB: close, reduce or zoom
    764       return HTZOOM_W;
    765     }
    766 
    767     return HTERROR_W;
    768   }
    769 }
Note: See TracChangeset for help on using the changeset viewer.