home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / MiscKit / Headers / misckit / MiscInspectorManager.h < prev    next >
Encoding:
Text File  |  1994-03-23  |  6.6 KB  |  185 lines

  1. /* MiscInspectorManager.h                 
  2.  *
  3.  * This is a general class that should make it easy to implement Inspectors
  4.  * as we know them from the WM or IB...but more general purpose.
  5.  * Anyway. It's not a real inspector. It's the class the manages the selection
  6.  * and all the different inspectors.
  7.  *
  8.  * Usage: Just create an subclass of this object and provide it with the
  9.  *          necessary NIB + connections. The default might work with little
  10.  *          or no changes for a lot of apps.
  11.  *
  12.  *          Every possible inspector has to register her to be added to the list
  13.  *          of inspectors. Finding inspectors for a certain selecton goes this
  14.  *          way: - Every inspector is asked if he wants to inspect the selection.
  15.  *                 This is done in the same order they have been added (0...n)
  16.  *
  17.  *               - If an inspector feed like doing some work it will be added
  18.  *                 to the swapViews controller list.
  19.  *
  20.  *               - There can be only one inspector(viewController ) for one
  21.  *                 trigger. So the last inspector has the highest priority and
  22.  *                 can replace inspectors registered before.
  23.  *                 This feature is used to handle default inspectors. For more
  24.  *                 details see below.
  25.  *
  26.  *          If selectionCount > 1 then selection returns a List !! that holds
  27.  *          the objects to be inspected. 
  28.  *
  29.  *          Don't try [[inpsector window] makeKeyAndOrderFront:self]. Use the
  30.  *          inspectors method instead. Otherwise the shown inspectors might not
  31.  *          be correct. This is not a bug. Its really a feature.
  32.  *
  33.  * Notes: InspectorWrappers appear like single inspectors but normally will
  34.  *          register for more than one trigger(attribute). For more detail
  35.  *          see the notes for a wrapper.
  36.  *
  37.  *          The title of the Inspector window is set by the single inspectors
  38.  *          acording to the title of their views window!
  39.  *
  40.  * Written by:         Thomas Engel
  41.  * Created:            08.02.1994 (Copyright 1994 Thomas Engel)
  42.  * Last modified:     25.02.1994
  43.  */
  44.  
  45. //    This object is included in the MiscKit by permission from the author
  46. //    and its use is governed by the MiscKit license, found in the file
  47. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  48. //    for a list of all applicable permissions and restrictions.
  49.  
  50. #import <appkit/appkit.h>
  51.  
  52. @interface MiscInspectorManager:Object
  53. {
  54.     id            window;
  55.     id            okButton;
  56.     id            revertButton;
  57.     id            buttonsSuperview;
  58.     BOOL        buttonsVisible;
  59.     id            swapView;
  60.     id            selection;
  61.     unsigned    selectionCount;
  62.     
  63.     id    inspectors;
  64.     id    notApplInspector;
  65.     id    noSelInspector;
  66.     id    multiSelInspector;
  67. }
  68.  
  69. // During the init we will load the NIB.
  70. // This is the easiest way we can ensure that keyboard shortcuts insie the 
  71. // inspector popup will work before we have seen the inspector for the first
  72. // time.
  73. // If you want to save space and don't like this early init just override it.
  74. // If you want a different filename for you main inspector NIB then override
  75. // the loadNibSection.
  76.  
  77. - init;
  78. - loadNibSection;
  79.  
  80. - makeKeyAndOrderFront:sender;
  81.  
  82. // These are the methods for setting the selection. You might inspecto single
  83. // objects or a List of objects. However. When you inspect a List the has only 
  84. // one object inside it has the same affect as useing the simple inspect.
  85. // So if you want multiple selections...just always use a list. I will work
  86. // with no pain.
  87.  
  88. - inspect:anObject;
  89. - inspectList:aList;
  90. - selection;
  91. - (unsigned)selectionCount;
  92.  
  93. // UpdateInspectors does the real work of finding all the useful inspectors
  94. // for the current selection and updating the swapViews controllerList.
  95. // If a registered object knows the addWrappedControllers method the manager
  96. // will use this method and let the inspector register himself at the swapView.
  97. // This is how wrappers work.
  98. //
  99. // Add default inspectors is called during the init.
  100. // This simple inspectorManager does only add NoSelection, NotApplicable, 
  101. // MultiSelection (for more details set the single classes)
  102. // Normally each app has a set of inspectors it might want to preload at 
  103. // startup and not at runtime. So this is the place.
  104. // Add your default inspectors in your masterInspector class. But remember to 
  105. // [super addDefaultInspectors] if you want to keep the three Misc DefaultInsp.
  106. // Also be aware that the order of adding is significant!
  107.  
  108. - addInspector:anInspector;
  109. - addDefaultInspectors;
  110. - updateInspectors;
  111.  
  112. // Here are some interface handling methods.
  113.  
  114. - setSwapView:anObject;
  115. - swapView;
  116.  
  117. - window;
  118. - setOkButton:aButton;
  119. - okButton;
  120. - setRevertButton:aButton;
  121. - revertButton;
  122. - setShowButtons:(BOOL)flag;
  123.  
  124. // oK and revert try to hand the action down to the current Inspector.
  125.  
  126. - ok:sender;
  127. - revert:sender;
  128.  
  129. - touch:sender;
  130. - textDidChange:sender;
  131.  
  132. // We will be the swapViews delegate so we can take care of some swapping
  133. // cleanups etc.
  134. // Remember to include a call to super. (First place in Will, last in Did)
  135. // Otherwise the command-keys of the popUp might not work!
  136.  
  137. - viewWillSwap:sender;
  138. - viewDidSwap:sender;
  139.  
  140. @end
  141.  
  142. /*
  143.  * History: 25.02.94 Seems like I forgot the ok,revert here ... hmm
  144.  *
  145.  *            08.02.94 A complete redesign for the MiscKit. Only the basic idea
  146.  *                     remains the same as in earlier versins.
  147.  *
  148.  *            20.12.93 Moved some code to a MasterInspector and made this class
  149.  *                     more abstract and general purpose.
  150.  *
  151.  *            18.12.93 Decided to provide a master-control-system :-)
  152.  *                     All inspectors have to register themselves.
  153.  *
  154.  *            14.12.93 Added some methods for easy object inspection. Some of
  155.  *                     them should be move to the MultipagePanel someday.
  156.  *
  157.  *            25.11.93 Created a copy of the pref-manager.
  158.  *
  159.  *
  160.  * Hints: Leaving the decision to the inspector wether he can handle a
  161.  *          selection or not frees the inspector from a limitation in the kind
  162.  *          of possible selections. This way its easy to allow multiple
  163.  *          selections to be inspected properly.
  164.  *          For more flexibility it is recommended to use a list Object for
  165.  *          storing the selections. Thats how mixed-selections are made.
  166.  *
  167.  *
  168.  * Future: Should add the methods for setting a selection like: addToSelection:
  169.  *           removeFromSelection, setSelection:, inspectSelection.
  170.  *           This way the inspector would store the selection(List).
  171.  *           But normally the selection changes with switching to a different
  172.  *           main window so I makes more sense to store selection infos inside
  173.  *           a window or document.
  174.  *           So this feature might not get implemented here anytime soon.
  175.  *
  176.  *            What I might add is that hiding the ok/revert buttons might
  177.  *           cause the swapView to become larger. I not really sure about this
  178.  *           one but it sounds a little bit useful. Let's see.
  179.  *
  180.  *
  181.  * Bugs: - unknown to me :-)
  182.  *
  183.  *         - Well. Ok/revert buttons must have the same superview. But this is 
  184.  *           not a bug.
  185.  */