home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / gui / CShelfMixin.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  2.7 KB  |  114 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. //
  20. // CShelfMixin.cp
  21. //
  22. // Implementation of the CShelf class. See header files for details
  23. //
  24.  
  25. #include "CShelfMixin.h"
  26. #include "prefapi.h"
  27. #include "divview.h"
  28. #include "CTargetFramer.h"
  29.  
  30. #include "LCommander.h"
  31.  
  32.  
  33. //
  34. // Constructor
  35. //
  36. CShelf :: CShelf (  LDividedView* inDivView, const char* inPrefString ) 
  37.     : mPrefString(inPrefString), mShelf(inDivView)
  38. {
  39. }
  40.  
  41.  
  42. //
  43. // Destructor
  44. //
  45. // Don't dispose of anything explicitly.
  46. //
  47. CShelf :: ~CShelf ( )
  48. {
  49. }
  50.  
  51.  
  52. //
  53. // ToggleShelf
  54. //
  55. // Expand or collapse the shelf based on the previous state. Will also update the 
  56. // preference if the parameter flag is true.
  57. //
  58. void 
  59. CShelf :: ToggleShelf ( bool inUpdatePref )
  60. {
  61.     if ( !mShelf )
  62.         return;            // this is the case for composer
  63.     
  64.     mShelf->ToggleFirstPane();
  65.     
  66.     // Update the visible pref. The pref should be true if the pane is showing (!collapsed)
  67.     if ( inUpdatePref && mPrefString.c_str() )
  68.         PREF_SetBoolPref ( mPrefString.c_str(), !mShelf->IsFirstPaneCollapsed() );
  69.     
  70.     // force menu items to update show "Show" and "Hide" string changes are reflected
  71.     LCommander::SetUpdateCommandStatus(true);
  72.     
  73. } // ToggleShelf
  74.  
  75.  
  76. //
  77. // SetShelfState
  78. //
  79. // Explicitly set the state of the shelf (useful for initialization based on a preference).
  80. // This is so confusing because all we can do is toggle the panes in LDividedView.
  81. //
  82. void
  83. CShelf :: SetShelfState ( bool inShelfOpen, bool inUpdatePref )
  84. {
  85.     if ( !mShelf )
  86.         return;            // this is the case for composer
  87.     
  88.     bool isShelfOpenNow = !mShelf->IsFirstPaneCollapsed();
  89.     if ( inShelfOpen ) {
  90.         if ( !isShelfOpenNow )
  91.             ToggleShelf(inUpdatePref);
  92.     }
  93.     else
  94.         if ( isShelfOpenNow )
  95.             ToggleShelf(inUpdatePref);
  96.     
  97. } // SetShelfState
  98.  
  99.  
  100. //
  101. // IsShelfOpen
  102. //
  103. // return the state of the shelf/
  104. //
  105. bool
  106. CShelf :: IsShelfOpen ( )
  107. {
  108.     if ( !mShelf )
  109.         return false;            // this is the case for composer
  110.     
  111.     return ( ! mShelf->IsFirstPaneCollapsed() ) ;
  112.  
  113. } // IsShelfOpen
  114.