home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / styles.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.8 KB  |  135 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. // STyles.cpp : implementation file
  20. //
  21. #include "stdafx.h"
  22. #include "styles.h"
  23. #include "nethelp.h"
  24.  
  25. #ifdef _DEBUG
  26. #undef THIS_FILE
  27. static char BASED_CODE THIS_FILE[] = __FILE__;
  28. #endif
  29.  
  30. //
  31. // Draw a framed rectangle of the current color
  32. //
  33. void WFE_DrawSwatch(CWnd * parent, UINT ID, COLORREF color)
  34. {
  35.     CWnd * widget = parent->GetDlgItem(ID);
  36.     CDC * pDC = widget->GetDC();
  37.     CRect rect;
  38.  
  39.     // find out how much area we can draw into
  40.     widget->GetClientRect(&rect);
  41.  
  42.     // color for the inside
  43.     CBrush brush(color);
  44.     CBrush * oldBrush = (CBrush *) pDC->SelectObject(&brush);
  45.  
  46.     pDC->LPtoDP(&rect);
  47.  
  48.     // flush any drawing
  49.     widget->Invalidate();
  50.     widget->UpdateWindow();
  51.  
  52.     // draw the frame
  53.     pDC->Rectangle(rect);
  54.  
  55.     // select the old brush
  56.     pDC->SelectObject(oldBrush);
  57.  
  58.     // set the background color
  59.     pDC->SetBkColor(color);
  60.  
  61.     // give the CDC back to the system
  62.     widget->ReleaseDC(pDC);
  63.  
  64. }
  65.  
  66. // CLM: Added params to pass in Caption ID
  67. CNetscapePropertyPage::CNetscapePropertyPage(UINT nID, UINT nIDCaption, UINT nIDFocus)
  68.     : CPropertyPage(nID, nIDCaption),
  69.       m_nIDFocus(nIDFocus)
  70. {
  71. }
  72.  
  73. // Return with this at end of OnSetActive()
  74. //  to set focus to a specific control
  75. // Either pass an ID in call, or set it in constructor
  76. BOOL CNetscapePropertyPage::SetInitialFocus( UINT nID )
  77. {
  78.     if ( nID || m_nIDFocus ){
  79.         CWnd * pWnd = GetDlgItem(nID ? nID : m_nIDFocus);
  80.         if( pWnd ){
  81.             pWnd->SetFocus();
  82.             return FALSE;
  83.         }
  84.     }
  85.     return TRUE;
  86. }
  87.  
  88. // Use instead of MFC's CancelToClose, which doesn't work as advertised (wrong only in Win16?)
  89. void CNetscapePropertyPage::OkToClose()
  90. {
  91.     CWnd *pApply = GetParent()->GetDlgItem(ID_APPLY_NOW);
  92.  
  93.     // Do nothing if we don't have an Apply button    
  94.     if( pApply && pApply->IsWindowVisible() ){
  95.         // We always do this after using the Apply button
  96.         SetModified(FALSE);
  97.  
  98.         // Get the Property sheet parent of the property page
  99.         CWnd *pWnd = GetParent()->GetDlgItem(IDOK);
  100.  
  101.         if( pWnd ){
  102.             // Change "OK" button text to "Close"
  103.             pWnd->SetWindowText(szLoadString(IDS_CLOSE_BUTTON));
  104.  
  105.             // Move focus from the Apply button to the Close button
  106.             if( GetFocus() == pApply ){
  107.                 pWnd->SetFocus();
  108.             }
  109.         }
  110.  
  111.         // Disable the Cancel button
  112.         pWnd = GetParent()->GetDlgItem(IDCANCEL);
  113.         if( pWnd ){
  114.             pWnd->EnableWindow(FALSE);
  115.         }
  116.     }
  117. }
  118.  
  119. void CNetscapePropertyPage::OnHelp() 
  120. {
  121.     NetHelp("PREFERENCES_GENERAL_APPEARANCE");
  122. }
  123. // the ID_HELP message actually goes to our parent CNetscapePropertySheet
  124. //   which passes it along to us, can't use message map
  125. BEGIN_MESSAGE_MAP(CNetscapePropertyPage, CPropertyPage)
  126. END_MESSAGE_MAP()
  127.  
  128. // Called by the security library to indicate whether the user is or is
  129. // not using a password
  130. //
  131. // XXX - jsw - remove me
  132. void FE_SetPasswordEnabled(MWContext *context, PRBool usePW)
  133. {
  134. }
  135.