Ignore:
Timestamp:
Jan 14, 2000, 6:48:33 PM (26 years ago)
Author:
cbratschi
Message:

DrawCaption performance improvements for window text updates

File:
1 edited

Legend:

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

    r2435 r2440  
    1 /* $Id: win32wbasenonclient.cpp,v 1.6 2000-01-14 13:16:58 sandervl Exp $ */
     1/* $Id: win32wbasenonclient.cpp,v 1.7 2000-01-14 17:48:33 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2 (non-client methods)
     
    789789}
    790790//******************************************************************************
    791 //******************************************************************************
    792 VOID Win32BaseWindow::DrawCaption(HDC hdc,RECT *rect,BOOL active)
     791// redrawText: only redraws text
     792//******************************************************************************
     793VOID Win32BaseWindow::DrawCaption(HDC hdc,RECT *rect,BOOL active,BOOL redrawText)
    793794{
    794795  RECT  r = *rect;
     
    850851  if ((dwStyle & WS_SYSMENU) && !(dwExStyle & WS_EX_TOOLWINDOW))
    851852  {
    852     if (DrawSysButton(hdc,FALSE))
     853    if (redrawText || DrawSysButton(hdc,FALSE))
    853854      r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
    854855  }
     
    858859    UINT state;
    859860
    860     /* Go get the sysmenu */
    861     state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
    862 
    863     /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
    864     DrawCloseButton(hdc, FALSE,
    865                     ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
     861    if (!redrawText)
     862    {
     863      /* Go get the sysmenu */
     864      state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
     865
     866      /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
     867      DrawCloseButton(hdc, FALSE,
     868                      ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
     869    }
    866870    r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
    867871
     
    871875      /* But if the menu item is not in the menu they're disabled*/
    872876
    873       DrawMaxButton(hdc, FALSE, (!(dwStyle & WS_MAXIMIZEBOX)));
     877      if (!redrawText)
     878        DrawMaxButton(hdc, FALSE, (!(dwStyle & WS_MAXIMIZEBOX)));
    874879      r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
    875880
    876       DrawMinButton(hdc, FALSE,  (!(dwStyle & WS_MINIMIZEBOX)));
    877             r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
     881      if (!redrawText)
     882        DrawMinButton(hdc, FALSE,  (!(dwStyle & WS_MINIMIZEBOX)));
     883      r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
    878884    }
    879885  }
     
    890896      hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
    891897    hOldFont = SelectObject (hdc, hFont);
    892     if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
    893     else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
     898    SetTextColor(hdc,GetSysColor(active ? COLOR_CAPTIONTEXT:COLOR_INACTIVECAPTIONTEXT));
    894899    SetBkMode( hdc, TRANSPARENT );
    895900    r.left += 2;
     
    897902             DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
    898903    DeleteObject (SelectObject (hdc, hOldFont));
     904  }
     905}
     906//******************************************************************************
     907//******************************************************************************
     908VOID Win32BaseWindow::UpdateCaptionText()
     909{
     910  BOOL active = flags & WIN_NCACTIVATED;
     911  HDC hdc;
     912  RECT rect,r;
     913  HRGN hrgn;
     914
     915  if (!((dwStyle & WS_CAPTION) == WS_CAPTION)) return;
     916
     917  rect.top = rect.left = 0;
     918  rect.right  = rectWindow.right - rectWindow.left;
     919  rect.bottom = rectWindow.bottom - rectWindow.top;
     920  if(!(flags & WIN_MANAGED))
     921  {
     922    if (HAS_BIGFRAME( dwStyle, dwExStyle))
     923    {
     924      InflateRect(&rect,-2,-2);
     925    }
     926
     927    if (HAS_THICKFRAME(dwStyle,dwExStyle))
     928    {
     929      INT width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXEDGE);
     930      INT height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYEDGE);
     931
     932      InflateRect(&rect,-width,-height);
     933    }
     934    else if (HAS_DLGFRAME(dwStyle,dwExStyle))
     935    {
     936      INT width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
     937      INT height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
     938
     939      InflateRect(&rect,-width,-height);
     940    }
     941    else if (HAS_THINFRAME(dwStyle))
     942    {
     943    }
     944
     945    r = rect;
     946    if (dwExStyle & WS_EX_TOOLWINDOW)
     947    {
     948      r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
     949    }
     950    else
     951    {
     952      r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
     953    }
     954
     955    //clip the buttons
     956    if ((dwStyle & WS_SYSMENU) && !(dwExStyle & WS_EX_TOOLWINDOW))
     957    {
     958      HICON hIcon;
     959
     960      hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
     961      if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
     962      if (hIcon)
     963        rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
     964    }
     965    if (dwStyle & WS_SYSMENU)
     966    {
     967      rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
     968
     969      if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
     970      {
     971        rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
     972        rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
     973      }
     974    }
     975
     976    hrgn = CreateRectRgnIndirect(&rect);
     977    hdc = GetDCEx(Win32Hwnd,hrgn,DCX_USESTYLE | DCX_WINDOW | DCX_INTERSECTRGN);
     978    SelectObject(hdc,GetSysColorPen(COLOR_WINDOWFRAME));
     979    DrawCaption(hdc,&r,active,TRUE);
     980    DeleteObject(hrgn);
     981    ReleaseDC(Win32Hwnd,hdc);
    899982  }
    900983}
     
    9221005
    9231006  if( clip > 1 )
     1007  {
     1008    //CB: unknown WINE handling (clip == 1), clip client?
    9241009    GetRgnBox( clip, &rectClip );
    925   else
     1010  } else
    9261011  {
    9271012    clip = 0;
     
    9611046      }
    9621047      if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
    963         DrawCaption(hdc, &r, active);
     1048        DrawCaption(hdc,&r,active,FALSE);
    9641049    }
    9651050  }
Note: See TracChangeset for help on using the changeset viewer.