home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / central / CTargetedUpdateMenuRegistry.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.7 KB  |  91 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. //    CTargetedUpdateMenuRegistry.h
  20.  
  21. //
  22. //    CTargetedUpdateMenuRegistry is used in conjunction with LEventDispatchers
  23. //    which are CTargetedUpdateMenuRegistry-aware to enable a more targeted
  24. //    update of menus.
  25. //
  26. //    One common example of this is menu items whose text should change when
  27. //    certain modifiers are held down (Close -> Close All when optionKey is
  28. //    held down, for example).
  29. //
  30. //    Usage notes for callers of UpdateMenus:
  31. //
  32. //        (1) Call SetCommands with a list of commands which should be updated.
  33. //        (2) Call UpdateMenus.
  34. //
  35. //    Usage notes for implementors of UpdateMenus:
  36. //
  37. //        (1) When looping through commands in menus, determine if the registry
  38. //            is active by calling UseRegistryToUpdateMenus.
  39. //        (2) If the registry is active, then check to see if the command is
  40. //            in the registry by calling CommandInRegistry before processing
  41. //            command status for the command.
  42. //
  43. //    Note: For the targeted update to be useful, there should generally be
  44. //    a very small number of targeted commands. In fact, command lookup will
  45. //    slow down if there are too many commands.
  46.  
  47. #ifndef    CTargetedUpdateMenuRegistry_H
  48. #define    CTargetedUpdateMenuRegistry_H
  49. #pragma once
  50.  
  51. // Includes
  52.  
  53. #include <list>
  54. #include <algorithm>
  55.  
  56. #include <LCommander.h>
  57. #include <LEventDispatcher.h>
  58.  
  59. // Class declaration
  60.  
  61. class CTargetedUpdateMenuRegistry
  62. {
  63. public:
  64.     
  65.         // Interface for callers of UpdateMenus
  66.         
  67.     static void                SetCommands(const list<CommandT>& inCommands);
  68.     
  69.     static void                UpdateMenus();
  70.     
  71.         // Interface for implementors of UpdateMenus
  72.         
  73.     static Boolean            CommandInRegistry(CommandT inCommand);
  74.     
  75.     static Boolean            UseRegistryToUpdateMenus();
  76.     
  77. private:    
  78.     static Boolean            sUseRegistryToUpdateMenus;
  79.     static list<CommandT>    sCommands;
  80. };
  81.  
  82. // Inline methods
  83.     
  84. inline
  85. Boolean
  86. CTargetedUpdateMenuRegistry::UseRegistryToUpdateMenus()
  87. {
  88.     return sUseRegistryToUpdateMenus;
  89. }
  90.  
  91. #endif