home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / Apps / Utilities / Unix / aa_m68k_Intel_Only / UNIX-HatersTool.0.1 / Source / MiscSwapKit.subproj / MiscSwapView.h < prev    next >
Encoding:
Text File  |  1994-10-31  |  7.1 KB  |  223 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. + initialize;
  65. - init;
  66. - initFrame:(const NXRect *)frameRect;
  67. - free;
  68.  
  69. // Basic instance-control method and delegate setting.
  70. // More details on buffering are at the top of this header file.
  71.  
  72. - setDelegate:(id)anObject;
  73. - delegate;
  74. - setBackgroundGray:(float)aColor;
  75. - (float)backgroundGray;
  76. - setUseBuffering:(BOOL)flag;
  77. - (BOOL)doesUseBuffering;
  78.  
  79. // The real work..there's some swapping swapping going on...tadadatadaa..
  80.  
  81. - setContentView:aView;
  82. - contentView;
  83. - contentViewsHomeView;
  84.  
  85. // Archiving 
  86.  
  87. - awake;
  88. - write:(NXTypedStream *)stream;
  89. - read:(NXTypedStream *)stream;
  90.  
  91. //- drawSelf:(const NXRect *)rects :(int)rectCount;
  92.  
  93. @end
  94.  
  95. // This method might be implemented by the delegate but is quite useless here
  96. // because somebody has to trigger the swapping an he knows when something 
  97. // changes.
  98. // But once we will handle swapping on our own we might need this.
  99.  
  100. @interface Object(MiscSwapViewDelegate)
  101.  
  102. - viewWillSwap:sender;
  103. - viewDidSwap:sender;
  104.  
  105. @end
  106.  
  107. /*
  108.  * History: 24.02.94 Some changes to support buffering.
  109.  *
  110.  *            24.01.94 Took my old swapView and wrote it again...
  111.  *
  112.  *            21.01.94 Did some work to the resizing of swapView.
  113.  *
  114.  *            19.11.93 Started to do some cleanups in this HeaderFile and
  115.  *                      resizing got implemented into the object.
  116.  *
  117.  *            17.11.93 Played around with resizing and found it right.
  118.  *
  119.  *
  120.  * Bugs: - There might be problems with swapping out a view with an active
  121.  *           colorWell. Here some should take care a deactive them.
  122.  *           You might use the delegate and viewWillSwap.
  123.  *           Normally you will use subviewControllers and they will recieve
  124.  *           swapIn/Out too and can take care of that inside their revert/ok
  125.  *           methods or what ever.
  126.  *
  127.  *         - Using buffering doe disable resizing. Maybe there is a solution to
  128.  *           this porblem. If there is one I might add a setResizing:YES/NO
  129.  *           method.
  130.  *
  131.  *         - Read & write do nothing at all. I'm not even sure wether they should
  132.  *           do something ?
  133.  */
  134.  
  135. /* ------------------------------------------------------------------------- */
  136.  
  137. /* MiscSwapView_ByObject                 
  138.  *
  139.  * This is a MiscSwapView category. I can handle swapping of different 
  140.  * contentViews (controlled by MiscSwapContentsController's) into ourself by
  141.  * comparing trigger objects.
  142.  *
  143.  * Usage: To work properly every contentsController has to register itself
  144.  *          at the corresponding swapView. The object triggering the swap
  145.  *          should invoke the sV-object and this one has to decide which 
  146.  *         contentsController has to come to front.
  147.  *          The trigger instance stores the triggering object to have it at
  148.  *          hand when a findController(..) needs it to make the decision.
  149.  *
  150.  *          For the first time the swapView will be uninitialized! The app
  151.  *          has to trigger some kind of default swap maybe by a 
  152.  *          [swapView swapAction:defaultObject];
  153.  *
  154.  * Notes: To implement a different controller-finding behavior you should only
  155.  *          override the findControllerByTag/object methods. They should return
  156.  *          the contentsController to use next ... or nil.
  157.  *          Sometimes swapAction can provide a trigger adjustment too. As done
  158.  *          with the ..ByMatrix class.
  159.  *
  160.  * Written by:         Thomas Engel
  161.  * Created:            24.01.1994 (Copyleft)
  162.  * Last modified:     08.03.1994
  163.  */
  164.  
  165. @interface MiscSwapView(ByObject)
  166.  
  167. // swapContentView is invoked by the action-buttons.
  168. // And if somebody wants to know who triggered the swap..[trigger]
  169.  
  170. - swapContentView:sender;
  171. - trigger;
  172.  
  173. // Here are some methods that allow some contentsController handling.
  174. // There should be no need to change the list by hand!
  175.  
  176. - addController:sender;
  177. - removeController:sender;
  178. - removeAllControllers;
  179. - controllers;
  180. - contentsController;
  181.  
  182. - setTagComparison:(BOOL)flag;
  183. - (BOOL)doesTagComparison;
  184.  
  185. // These are the methods that decides which controller to show activate next.
  186. // Here is the place to add some custom behavior. The methods byTag/object
  187. // should work with no pain in any subclass too. For details see the popup and
  188. // ByMatrix subclasses of MiscSwapView.
  189. // Sometime you just have to make some minor fixes inside findController.
  190.  
  191. - findControllerForTrigger:aTrigger;
  192. - findControllerByTag:(int)aTag;
  193. - findControllerByObject:aTrigger;
  194.  
  195. @end
  196.  
  197. /*
  198.  * History: 08.03.94 Changed the findMethods to make them nicer for other
  199.  *                     actions.
  200.  *
  201.  *            14.02.94 Some minor changes to make it a swapView category.
  202.  *
  203.  *            24.01.94 Made it a subclass of MiscSwapView
  204.  *
  205.  *            08.01.94 Switched to tagComparison for better reading.
  206.  *                     choosesByTagFirst was not that nice.
  207.  *
  208.  *            21.12.93 Derived from my old swapPopManager this is a simple usable
  209.  *                     and subcallable object.
  210.  *                     Some viewController handling methods added.
  211.  *
  212.  *            04.12.93 Added the delegates methods.
  213.  *
  214.  *          04.11.93 First methods hacked together.
  215.  *
  216.  *
  217.  * Bugs: - not really
  218.  *
  219.  *         - swapContentView. Ok. I could have stay with Greg's swapAction but I
  220.  *           don't find it a good method name. If you like it - creat your own 
  221.  *           compatibility category.
  222.  */
  223.