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

  1. /* MiscSwapView.h
  2.  *
  3.  * This subclass of View is able to swap different views into itself. It's
  4.  * used to implement any kind of multipage windows. (Inspectors, Prefs...)
  5.  * This object is a redesign of Greg Bruds swapView.
  6.  *
  7.  * Catergories: - ByObject: Handles automatic swapping. See next headersction.
  8.  *
  9.  * Usage: Just instantiate a view inside IB and tell it what view to show
  10.  *          next. The MiscSwapView will take care of putting the views back where
  11.  *          they came from once they will swap out again.
  12.  *          You can used buffered (faster) or nonButffered (less memory and fast
  13.  *          enough) swapping. 
  14.  *
  15.  * Notes: This view by default resizes its subview to it current size. But you
  16.  *          can decide how they are resized by the default NeXTSTEP view resizing
  17.  *          settings as with every view.
  18.  *          When using buffered composing resizing is turned OFF because of some
  19.  *          ugly problems.
  20.  *          
  21.  *           Not using buffered views will save memory and allow resizing 
  22.  *          over the slightly faster swapping. With fast hardware this might not
  23.  *          be of any concern at all...so keep the ports rolling:HP, Sun, PPC...?
  24.  *          To implement buffered views the views windows have to be none 
  25.  *          deffered and retained. You HAVE to make your window non defered 
  26.  *          inside IB. (SwapView makes them retained on its own)
  27.  *          If you know a way to make windows non defered during runtime..please
  28.  *          let me know.
  29.  *
  30.  *          Remember to deactivate objects inside a view that has swapped out.
  31.  *          ColorWell are a good example of such a object!
  32.  *
  33.  * Improved by:        Thomas Engel
  34.  * First changes:   24.01.1994 (Copyright 1994 Thomas Engel)
  35.  * Last modified:     24.02.1994
  36.  */
  37.  
  38. //    This object is included in the MiscKit by permission from the author
  39. //    and its use is governed by the MiscKit license, found in the file
  40. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  41. //    for a list of all applicable permissions and restrictions.
  42.  
  43. #import <appkit/appkit.h>
  44.  
  45. @interface MiscSwapView:View
  46. {
  47.     id        contentView;
  48.     id        contentViewsHomeView;
  49.     NXRect    contentViewsHomeRect;
  50.     id        delegate;
  51.     float    backgroundGray;
  52.     BOOL    useBuffering;
  53.     
  54.     // Instances for the ByObject category
  55.     
  56.     id        trigger;
  57.     id        controllers;
  58.     id        currentController;    
  59.     BOOL    tagComparison;
  60. }
  61.  
  62. // Basic view init and freeing
  63.  
  64. - init;
  65. - initFrame:(const NXRect *)frameRect;
  66. - free;
  67.  
  68. // Basic instance-control method and delegate setting.
  69. // More details on buffering are at the top of this header file.
  70.  
  71. - setDelegate:(id)anObject;
  72. - delegate;
  73. - setBackgroundGray:(float)aColor;
  74. - (float)backgroundGray;
  75. - setUseBuffering:(BOOL)flag;
  76. - (BOOL)doesUseBuffering;
  77.  
  78. // The real work..there's some swapping swapping going on...tadadatadaa..
  79.  
  80. - setContentView:aView;
  81. - contentView;
  82. - contentViewsHomeView;
  83.  
  84. // Archiving 
  85.  
  86. - write:(NXTypedStream *)stream;
  87. - read:(NXTypedStream *)stream;
  88.  
  89. @end
  90.  
  91. // This method might be implemented by the delegate but is quite useless here
  92. // because somebody has to trigger the swapping an he knows when something 
  93. // changes.
  94. // But once we will handle swapping on our own we might need this.
  95.  
  96. @interface Object(MiscSwapViewDelegate)
  97.  
  98. - viewWillSwap:sender;
  99. - viewDidSwap:sender;
  100.  
  101. @end
  102.  
  103. /*
  104.  * History: 24.02.94 Some changes to support buffering.
  105.  *
  106.  *            24.01.94 Took my old swapView and wrote it again...
  107.  *
  108.  *            21.01.94 Did some work to the resizing of swapView.
  109.  *
  110.  *            19.11.93 Started to do some cleanups in this HeaderFile and
  111.  *                      resizing got implemented into the object.
  112.  *
  113.  *            17.11.93 Played around with resizing and found it right.
  114.  *
  115.  *
  116.  * Bugs: - There might be problems with swapping out a view with an active
  117.  *           colorWell. Here some should take care a deactive them.
  118.  *           You might use the delegate and viewWillSwap.
  119.  *           Normally you will use subviewControllers and they will recieve
  120.  *           swapIn/Out too and can take care of that inside their revert/ok
  121.  *           methods or what ever.
  122.  *
  123.  *         - Using buffering doe disable resizing. Maybe there is a solution to
  124.  *           this porblem. If there is one I might add a setResizing:YES/NO
  125.  *           method.
  126.  *
  127.  *         - Read & write do nothing at all. I'm not even sure wether they should
  128.  *           do something ?
  129.  */
  130.  
  131. /* ------------------------------------------------------------------------- */
  132.  
  133. /* MiscSwapView_ByObject                 
  134.  *
  135.  * This is a MiscSwapView category. I can handle swapping of different 
  136.  * contentViews (controlled by MiscSwapContentsController's) into ourself by
  137.  * comparing trigger objects.
  138.  *
  139.  * Usage: To work properly every contentsController has to register itself
  140.  *          at the corresponding swapView. The object triggering the swap
  141.  *          should invoke the sV-object and this one has to decide which 
  142.  *         contentsController has to come to front.
  143.  *          The trigger instance stores the triggering object to have it at
  144.  *          hand when a findController(..) needs it to make the decision.
  145.  *
  146.  *          For the first time the swapView will be uninitialized! The app
  147.  *          has to trigger some kind of default swap maybe by a 
  148.  *          [swapView swapAction:defaultObject];
  149.  *
  150.  * Notes: To implement a different controller-finding behavior you should only
  151.  *          override the findControllerByTag/object methods. They should return
  152.  *          the contentsController to use next ... or nil.
  153.  *          Sometimes swapAction can provide a trigger adjustment too. As done
  154.  *          with the ..ByMatrix class.
  155.  *
  156.  * Written by:         Thomas Engel
  157.  * Created:            24.01.1994 (Copyleft)
  158.  * Last modified:     08.03.1994
  159.  */
  160.  
  161. @interface MiscSwapView(ByObject)
  162.  
  163. // swapContentView is invoked by the action-buttons.
  164. // And if somebody wants to know who triggered the swap..[trigger]
  165.  
  166. - swapContentView:sender;
  167. - trigger;
  168.  
  169. // Here are some methods that allow some contentsController handling.
  170. // There should be no need to change the list by hand!
  171.  
  172. - addController:sender;
  173. - removeController:sender;
  174. - removeAllControllers;
  175. - controllers;
  176. - contentsController;
  177.  
  178. - setTagComparison:(BOOL)flag;
  179. - (BOOL)doesTagComparison;
  180.  
  181. // These are the methods that decides which controller to show activate next.
  182. // Here is the place to add some custom behavior. The methods byTag/object
  183. // should work with no pain in any subclass too. For details see the popup and
  184. // ByMatrix subclasses of MiscSwapView.
  185. // Sometime you just have to make some minor fixes inside findController.
  186.  
  187. - findController;
  188. - findControllerByTag:(int)aTag;
  189. - findControllerByObject:aTrigger;
  190.  
  191. @end
  192.  
  193. /*
  194.  * History: 08.03.94 Chenged the findMethods to make them nicer for other
  195.  *                     actions.
  196.  *
  197.  *            14.02.94 Some minor changes to make it a swapView category.
  198.  *
  199.  *            24.01.94 Made it a subclass of MiscSwapView
  200.  *
  201.  *            08.01.94 Switched to tagComparison for better reading.
  202.  *                     choosesByTagFirst was not that nice.
  203.  *
  204.  *            21.12.93 Derived from my old swapPopManager this is a simple usable
  205.  *                     and subcallable object.
  206.  *                     Some viewController handling methods added.
  207.  *
  208.  *            04.12.93 Added the delegates methods.
  209.  *
  210.  *          04.11.93 First methods hacked together.
  211.  *
  212.  *
  213.  * Bugs: - not really
  214.  *
  215.  *         - swapContentView. Ok. I could have stay with Greg's swapAction but I
  216.  *           don't find it a good method name. If you like it - creat your own 
  217.  *           compatibility category.
  218.  */
  219.