Ignore:
Timestamp:
Jan 15, 2000, 3:18:18 PM (26 years ago)
Author:
cbratschi
Message:

several nc changes

File:
1 edited

Legend:

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

    r2440 r2444  
    1 /* $Id: win32wbasenonclient.cpp,v 1.7 2000-01-14 17:48:33 cbratschi Exp $ */
     1/* $Id: win32wbasenonclient.cpp,v 1.8 2000-01-15 14:18:18 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2 (non-client methods)
     
    7474  WORD wStateChange;
    7575
     76  //CB: only caption is changed on activation
     77  if (!(dwStyle & WS_CAPTION)) return TRUE;
     78
    7679  if( wParam ) wStateChange = !(flags & WIN_NCACTIVATED);
    7780  else wStateChange = flags & WIN_NCACTIVATED;
     
    115118  hdc = GetWindowDC(Win32Hwnd);
    116119  if (wParam == HTMINBUTTON)
    117     DrawMinButton(hdc,TRUE,FALSE);
     120    DrawMinButton(hdc,NULL,TRUE,FALSE);
    118121  else
    119     DrawMaxButton(hdc,TRUE,FALSE);
     122    DrawMaxButton(hdc,NULL,TRUE,FALSE);
    120123  do
    121124  {
     
    127130    {
    128131      if (wParam == HTMINBUTTON)
    129         DrawMinButton(hdc,pressed,FALSE);
     132        DrawMinButton(hdc,NULL,pressed,FALSE);
    130133      else
    131         DrawMaxButton(hdc,pressed,FALSE);
     134        DrawMaxButton(hdc,NULL,pressed,FALSE);
    132135    }
    133136  } while (msg.message != WM_LBUTTONUP);
    134137  if (wParam == HTMINBUTTON)
    135     DrawMinButton(hdc,FALSE,FALSE);
     138    DrawMinButton(hdc,NULL,FALSE,FALSE);
    136139  else
    137     DrawMaxButton(hdc,FALSE,FALSE);
     140    DrawMaxButton(hdc,NULL,FALSE,FALSE);
    138141  ReleaseCapture();
    139142  ReleaseDC(Win32Hwnd,hdc);
     
    164167  hdc = GetWindowDC(Win32Hwnd);
    165168  SetCapture(Win32Hwnd);
    166   DrawCloseButton(hdc,TRUE,FALSE);
     169  DrawCloseButton(hdc,NULL,TRUE,FALSE);
    167170  do
    168171  {
     
    172175    pressed = (HandleNCHitTest(msg.pt) == wParam);
    173176    if (pressed != oldstate)
    174       DrawCloseButton(hdc, pressed, FALSE);
     177      DrawCloseButton(hdc,NULL,pressed,FALSE);
    175178  } while (msg.message != WM_LBUTTONUP);
    176   DrawCloseButton(hdc,FALSE,FALSE);
     179  DrawCloseButton(hdc,NULL,FALSE,FALSE);
    177180  ReleaseCapture();
    178181  ReleaseDC(Win32Hwnd,hdc);
     
    244247      if(dwStyle & WS_SYSMENU )
    245248      {
    246         if( !(dwStyle & WS_MINIMIZE) )
    247         {
    248           HDC hDC = GetWindowDC(Win32Hwnd);
    249           DrawSysButton(hDC,TRUE);
    250           ReleaseDC(Win32Hwnd,hDC);
    251         }
    252249        SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTSYSMENU,lParam);
    253250      }
     
    606603//******************************************************************************
    607604//******************************************************************************
    608 BOOL Win32BaseWindow::DrawSysButton(HDC hdc,BOOL down)
     605BOOL Win32BaseWindow::DrawSysButton(HDC hdc,RECT *rect)
    609606{
    610607  if(!(flags & WIN_MANAGED))
    611608  {
    612609    HICON  hIcon;
    613     RECT rect;
    614 
    615     GetInsideRect(&rect);
     610    RECT r;
     611
     612    if (!rect) GetInsideRect(&r);
     613    else r = *rect;
    616614
    617615    hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
     
    625623
    626624    if (hIcon)
    627       DrawIconEx (hdc, rect.left + 2, rect.top + 2, hIcon,
    628                   GetSystemMetrics(SM_CXSMICON),
    629                   GetSystemMetrics(SM_CYSMICON),
    630                   0, 0, DI_NORMAL);
     625      DrawIconEx(hdc,r.left+2,r.top+2,hIcon,
     626                 GetSystemMetrics(SM_CXSMICON),
     627                 GetSystemMetrics(SM_CYSMICON),
     628                 0, 0, DI_NORMAL);
    631629
    632630    return (hIcon != 0);
     
    683681//******************************************************************************
    684682//******************************************************************************
    685 VOID Win32BaseWindow::DrawCloseButton(HDC hdc,BOOL down,BOOL bGrayed)
    686 {
    687   RECT rect;
     683VOID Win32BaseWindow::DrawCloseButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
     684{
     685  RECT r;
    688686  HDC hdcMem;
    689687
     
    693691    HBITMAP hBmp, hOldBmp;
    694692
    695     GetInsideRect(&rect);
     693    if (!rect) GetInsideRect(&r);
     694    else r = *rect;
    696695
    697696    hdcMem = CreateCompatibleDC( hdc );
     
    700699    GetObjectA (hBmp, sizeof(BITMAP), &bmp);
    701700
    702     BitBlt (hdc, rect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
    703             rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
     701    BitBlt (hdc, r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
     702            r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
    704703            bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
    705704
    706705    if(bGrayed)
    707       DrawGrayButton(hdc,rect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
    708                      rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
     706      DrawGrayButton(hdc,r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
     707                     r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
    709708
    710709    SelectObject (hdcMem, hOldBmp);
     
    714713//******************************************************************************
    715714//******************************************************************************
    716 VOID Win32BaseWindow::DrawMaxButton(HDC hdc,BOOL down,BOOL bGrayed)
    717 {
    718   RECT rect;
     715VOID Win32BaseWindow::DrawMaxButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
     716{
     717  RECT r;
    719718  HDC hdcMem;
    720719
     
    724723    HBITMAP  hBmp,hOldBmp;
    725724
    726     GetInsideRect(&rect);
     725    if (!rect) GetInsideRect(&r);
     726    else r = *rect;
    727727    hdcMem = CreateCompatibleDC( hdc );
    728728    hBmp = IsZoomed(Win32Hwnd) ?
     
    733733
    734734    if (dwStyle & WS_SYSMENU)
    735       rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
    736 
    737     BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
    738           rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
     735      r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
     736
     737    BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
     738          r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
    739739          bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
    740740
    741741    if(bGrayed)
    742       DrawGrayButton(hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
    743                       rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
     742      DrawGrayButton(hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
     743                      r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
    744744
    745745
     
    750750//******************************************************************************
    751751//******************************************************************************
    752 VOID Win32BaseWindow::DrawMinButton(HDC hdc,BOOL down,BOOL bGrayed)
    753 {
    754   RECT rect;
     752VOID Win32BaseWindow::DrawMinButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
     753{
     754  RECT r;
    755755  HDC hdcMem;
    756756
     
    761761    HBITMAP  hBmp,hOldBmp;
    762762
    763     GetInsideRect(&rect);
     763    if (!rect) GetInsideRect(&r);
     764    else r = *rect;
    764765
    765766    hdcMem = CreateCompatibleDC( hdc );
     
    769770
    770771    if (dwStyle & WS_SYSMENU)
    771       rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
     772      r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
    772773
    773774    /* In win 95 there is always a Maximize box when there is a Minimize one */
    774775    if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
    775       rect.right += -1 - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2;
    776 
    777     BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
    778           rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
     776      r.right -= bmp.bmWidth;
     777
     778    BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
     779          r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
    779780          bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
    780781
    781782    if(bGrayed)
    782       DrawGrayButton(hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
    783                       rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
     783      DrawGrayButton(hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
     784                      r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
    784785
    785786
     
    793794VOID Win32BaseWindow::DrawCaption(HDC hdc,RECT *rect,BOOL active,BOOL redrawText)
    794795{
    795   RECT  r = *rect;
     796  RECT  r = *rect,r2;
    796797  char  buffer[256];
    797798  HPEN  hPrevPen;
     799  HDC memDC;
     800  HBITMAP memBmp,oldBmp;
    798801
    799802  if (flags & WIN_MANAGED) return;
    800803
    801   hPrevPen = SelectObject( hdc, GetSysColorPen(COLOR_3DFACE) );
    802   MoveToEx( hdc, r.left, r.bottom - 1, NULL );
    803   LineTo( hdc, r.right, r.bottom - 1 );
    804   SelectObject( hdc, hPrevPen );
     804  memDC = CreateCompatibleDC(hdc);
     805  r.right -= r.left;
     806  r.bottom -= r.top;
     807  r.left = r.top = 0;
     808  r2 = r;
     809  memBmp = CreateCompatibleBitmap(hdc,r.right,r.bottom);
     810  oldBmp = SelectObject(memDC,memBmp);
     811
     812  hPrevPen = SelectObject(memDC,GetSysColorPen(COLOR_3DFACE));
     813  MoveToEx(memDC,r.left,r.bottom-1,NULL);
     814  LineTo(memDC,r.right,r.bottom-1);
     815  SelectObject(memDC,hPrevPen);
    805816  r.bottom--;
    806817
     
    810821
    811822    if (startColor == endColor)
    812       FillRect(hdc,&r,GetSysColorBrush(startColor));
     823      FillRect(memDC,&r,GetSysColorBrush(startColor));
    813824    else
    814825    {
     
    831842        r2.left = r2.right;
    832843        r2.right = r.left+w*x/steps;
    833         FillRect(hdc,&r2,brush);
     844        FillRect(memDC,&r2,brush);
    834845        DeleteObject(brush);
    835846      }
    836847    }
    837   } else FillRect(hdc,&r,GetSysColorBrush(active ? COLOR_ACTIVECAPTION:COLOR_INACTIVECAPTION));
     848  } else FillRect(memDC,&r,GetSysColorBrush(active ? COLOR_ACTIVECAPTION:COLOR_INACTIVECAPTION));
    838849
    839850  if (!hbitmapClose)
     
    851862  if ((dwStyle & WS_SYSMENU) && !(dwExStyle & WS_EX_TOOLWINDOW))
    852863  {
    853     if (redrawText || DrawSysButton(hdc,FALSE))
     864    if (redrawText || DrawSysButton(memDC,&r))
    854865      r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
    855866  }
     
    865876
    866877      /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
    867       DrawCloseButton(hdc, FALSE,
     878      DrawCloseButton(memDC,&r2,FALSE,
    868879                      ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
    869880    }
     
    876887
    877888      if (!redrawText)
    878         DrawMaxButton(hdc, FALSE, (!(dwStyle & WS_MAXIMIZEBOX)));
     889        DrawMaxButton(memDC,&r2,FALSE,(!(dwStyle & WS_MAXIMIZEBOX)));
    879890      r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
    880891
    881892      if (!redrawText)
    882         DrawMinButton(hdc, FALSE,  (!(dwStyle & WS_MINIMIZEBOX)));
     893        DrawMinButton(memDC,&r2,FALSE,  (!(dwStyle & WS_MINIMIZEBOX)));
    883894      r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
    884895    }
     
    889900    NONCLIENTMETRICSA nclm;
    890901    HFONT hFont, hOldFont;
     902
    891903    nclm.cbSize = sizeof(NONCLIENTMETRICSA);
    892904    SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
     
    895907    else
    896908      hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
    897     hOldFont = SelectObject (hdc, hFont);
    898     SetTextColor(hdc,GetSysColor(active ? COLOR_CAPTIONTEXT:COLOR_INACTIVECAPTIONTEXT));
    899     SetBkMode( hdc, TRANSPARENT );
     909    hOldFont = SelectObject (memDC, hFont);
     910    SetTextColor(memDC,GetSysColor(active ? COLOR_CAPTIONTEXT:COLOR_INACTIVECAPTIONTEXT));
     911    SetBkMode(memDC, TRANSPARENT );
    900912    r.left += 2;
    901     DrawTextA( hdc, buffer, -1, &r,
     913    DrawTextA(memDC, buffer, -1, &r,
    902914             DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
    903     DeleteObject (SelectObject (hdc, hOldFont));
    904   }
     915    DeleteObject (SelectObject (memDC, hOldFont));
     916  }
     917
     918  BitBlt(hdc,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,memDC,0,0,SRCCOPY);
     919  SelectObject(memDC,oldBmp);
     920  DeleteObject(memBmp);
     921  DeleteDC(memDC);
    905922}
    906923//******************************************************************************
     
    10541071    r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
    10551072
    1056     rect.top += MENU_DrawMenuBar( hdc, &r, Win32Hwnd, suppress_menupaint ) + 1;
     1073    rect.top += MENU_DrawMenuBar(hdc,&r,Win32Hwnd,suppress_menupaint)+1;
    10571074  }
    10581075
     
    11681185  return 0;
    11691186}
     1187//******************************************************************************
     1188//******************************************************************************
     1189LONG Win32BaseWindow::HandleNCRButtonUp(WPARAM wParam,LPARAM lParam)
     1190{
     1191  if (wParam == HTCAPTION)
     1192  {
     1193    if (GetActiveWindow() != Win32Hwnd)
     1194        SetActiveWindow();
     1195
     1196    if ((GetActiveWindow() == Win32Hwnd) && (dwStyle & WS_SYSMENU))
     1197    {
     1198      SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTCAPTION,lParam);
     1199    }
     1200  }
     1201
     1202  return 0;
     1203}
    11701204/***********************************************************************
    11711205 *           NC_HandleSysCommand
     
    11731207 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
    11741208 *
    1175  * TODO: Not done (see #if 0)
    11761209 */
    11771210LONG Win32BaseWindow::HandleSysCommand(WPARAM wParam,POINT *pt32)
     
    11791212    UINT uCommand = wParam & 0xFFF0;
    11801213
    1181 /* //CB: don't need this, perhaps recycle for menus
    1182     if ((getStyle() & WS_CHILD) && (uCommand != SC_KEYMENU))
    1183         ScreenToClient(getParent()->getWindowHandle(), pt32 );
    1184 */
    11851214    switch (uCommand)
    11861215    {
Note: See TracChangeset for help on using the changeset viewer.