home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / prefs / nsprefui / src / pagesite.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.2 KB  |  107 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 "pch.h"
  20. #include <assert.h>
  21. #include "prefpriv.h"
  22. #include "prefui.h"
  23. #include "framedlg.h"
  24. #include "pagesite.h"
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CPropertyPageSite implementation
  28.  
  29. // Constructor
  30. CPropertyPageSite::CPropertyPageSite(CPropertyFrameDialog *pFrame)
  31. {
  32.     m_pFrame = pFrame;
  33. }
  34.  
  35. // *** IUnknown methods ***
  36.  
  37. // Returns a pointer to a specified interface on an object to which a client
  38. // currently holds an interface pointer
  39. STDMETHODIMP CPropertyPageSite::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
  40. {
  41.     *ppvObj = NULL;
  42.  
  43.     if (riid == IID_IUnknown || riid == IID_IPropertyPageSite)
  44.         *ppvObj = (LPVOID)this;
  45.  
  46.     if (*ppvObj) {
  47.         AddRef();
  48.         return NOERROR;
  49.     }
  50.  
  51.     return ResultFromScode(E_NOINTERFACE);
  52. }
  53.  
  54. // Increments the reference count for an interface on an object
  55. STDMETHODIMP_(ULONG) CPropertyPageSite::AddRef()
  56. {
  57.     return ++m_uRef;
  58. }
  59.  
  60. // Decrements the reference count for the calling interface on a object. If the
  61. // reference count on the object falls to 0, the object is freed from memory
  62. STDMETHODIMP_(ULONG) CPropertyPageSite::Release()
  63. {
  64.     if (--m_uRef == 0) {
  65. #ifdef _DEBUG
  66.         OutputDebugString("Destroying property page site.\n");
  67. #endif
  68.            delete this;
  69.         return 0;
  70.     }
  71.  
  72.     return m_uRef;
  73. }
  74.  
  75. // *** IPropertyPageSite methods ***
  76.  
  77. // Informs the frame that the property page managed by this site has changed its
  78. // state, that is, one or more property values have been changed in the page
  79. STDMETHODIMP CPropertyPageSite::OnStatusChange(DWORD flags)
  80. {
  81.     return NOERROR;
  82. }
  83.  
  84. // Returns the locale identifier (an LCID) that a property page can use to adjust
  85. // itself to the language in use and other country-specific settings
  86. STDMETHODIMP CPropertyPageSite::GetLocaleID(LCID FAR* pLocalID)
  87. {
  88.     return ResultFromScode(E_NOTIMPL);
  89. }
  90.  
  91. // Returns an IUnknown pointer to the object representing the entire property
  92. // frame dialog box that contains all the pages
  93. STDMETHODIMP CPropertyPageSite::GetPageContainer(LPUNKNOWN FAR* ppUnk)
  94. {
  95.     // There are no "container" interfaces currently defined for this role
  96.     return ResultFromScode(E_NOTIMPL);
  97. }
  98.  
  99. // Called by the property page to give the property frame a chance
  100. // to translate accelerators
  101. STDMETHODIMP CPropertyPageSite::TranslateAccelerator(LPMSG lpMsg)
  102. {
  103.     assert(m_pFrame);
  104.     return m_pFrame ? m_pFrame->TranslateAccelerator(lpMsg) : ResultFromScode(S_FALSE);
  105. }
  106.  
  107.