home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / prefs / nsdlg / src / dlgutil.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.8 KB  |  90 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include <windows.h>
  20. #include <windowsx.h>
  21. #include <assert.h>
  22. #include "dlgutil.h"
  23.  
  24. #ifndef _WIN32
  25. BOOL
  26. DrawPushButtonControl(HDC hdc, LPRECT lprc, UINT nState)
  27. {
  28.     RECT    r;
  29.     UINT    nWidth, nHeight;
  30.     HBRUSH    hbrFace = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
  31.     HBRUSH    hbrShadow = CreateSolidBrush(GetSysColor(COLOR_BTNSHADOW));
  32.  
  33.     CopyRect(&r, lprc);
  34.     nWidth = r.right - r.left;
  35.     nHeight = r.bottom - r.top;
  36.  
  37.     if (nState & DPBCS_PUSHED) {
  38.         // Draw the black highlight on the left and top
  39.         PatBlt(hdc, r.left, r.top, nWidth - 1, 1, BLACKNESS);
  40.         PatBlt(hdc, r.left, r.top + 1, 1, nHeight - 2, BLACKNESS);
  41.  
  42.         // Draw the white edge along the bottom and right
  43.         PatBlt(hdc, r.left, r.bottom - 1, nWidth - 1, 1, WHITENESS);
  44.         PatBlt(hdc, r.right - 1, r.top, 1, nHeight, WHITENESS);
  45.     
  46.     } else {
  47.         // Draw the white highlight on the left and top
  48.         PatBlt(hdc, r.left, r.top, nWidth - 1, 1, WHITENESS);
  49.         PatBlt(hdc, r.left, r.top + 1, 1, nHeight - 2, WHITENESS);
  50.     
  51.         // Draw the black edge along the bottom and right
  52.         PatBlt(hdc, r.left, r.bottom - 1, nWidth - 1, 1, BLACKNESS);
  53.         PatBlt(hdc, r.right - 1, r.top, 1, nHeight, BLACKNESS);
  54.     }
  55.  
  56.     // Fill with the button face color
  57.     InflateRect(&r, -1, -1);
  58.     FillRect(hdc, &r, hbrFace);
  59.  
  60.     // Now draw the button shadow lines
  61.     HBRUSH    hOldBrush = SelectBrush(hdc, hbrShadow);
  62.  
  63.     if (nState & DPBCS_PUSHED) {
  64.         // Along the left and top
  65.         PatBlt(hdc, r.left, r.top, nWidth - 3, 1, PATCOPY);
  66.         PatBlt(hdc, r.left, r.top + 1, 1, nHeight - 4, PATCOPY);
  67.  
  68.     } else {
  69.         // Along the bottom and right
  70.         PatBlt(hdc, r.left, r.bottom - 1, nWidth - 2, 1, PATCOPY);
  71.         PatBlt(hdc, r.right - 1, r.top, 1, nHeight - 2, PATCOPY);
  72.     }
  73.  
  74.     SelectBrush(hdc, hOldBrush);
  75.  
  76.     // Delete GDI objects
  77.     DeleteBrush(hbrFace);
  78.     DeleteBrush(hbrShadow);
  79.  
  80.     // Adjust the rect if requested. Note we adjust by 2 pixels on all
  81.     // sides even though we only draw one pixel in some cases. This is
  82.     // for compatibility with the Win32 DrawFrameControl() routine
  83.     if (nState & DPBCS_ADJUSTRECT)
  84.         InflateRect(lprc, -2, -2);
  85.  
  86.     return TRUE;
  87. }
  88. #endif
  89.  
  90.