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

  1. //
  2. //    MiscTree.h -- a generic class to build tree data structures
  3. //        Written by Don Yacktman Copyright (c) 1993 by Don Yacktman.
  4. //                Version 1.0.  All rights reserved.
  5. //
  6. //        This notice may not be removed from this source code.
  7. //
  8. //        This is a free object!  Contact the author for the latest version.
  9. //        Don Yacktman, 4279 N. Ivy Lane, Provo, UT, 84604
  10. //        e-mail:  Don_Yacktman@byu.edu
  11. //
  12. //    This object is included in the MiscKit by permission from the author
  13. //    and its use is governed by the MiscKit license, found in the file
  14. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  15. //    for a list of all applicable permissions and restrictions.
  16. //    
  17.  
  18. #import <appkit/appkit.h>     // superclass is in there
  19.  
  20. @interface MiscTree:Object
  21. {
  22.     id branches;    // an instance of the list class
  23.     id label;    // node name
  24.     id value;       // must be a MiscString
  25.     BOOL notCollapsed;    // print children when dumping if true.
  26. }
  27.  
  28.  
  29. // init with null label
  30. - init;
  31.  
  32. // designated initializer
  33. - initLabel:(const char *)newLabel;    // send a char* string
  34. - initLabelString:string;        // send a String object
  35.  
  36. // access to the label of this node
  37. - setLabel:(const char *)newLabel;      // send a char* string
  38. - (const char *)label;
  39.  
  40. // access to the value of this node
  41. - setValue:newValue;                    // send a String object
  42. - (const char *)value;
  43.  
  44. // clean up our mess
  45. - free;
  46.  
  47. // add a new child node
  48. - addBranch:child;
  49.  
  50. // Print the tree to a stream (file, whatever).  Call the root with level
  51. // set to zero, and set the indent string however you like; the indent
  52. // string should be something like "  " or "\t" to show how to indent to
  53. // the next level.  This method recursively traverses the tree's children.
  54. - dumpTree:(NXStream *)file level:(int)lev indent:(const char *)ind;
  55.  
  56. // set whether or not we print the children (we don't if collapsed)
  57. // when dumping.  This does NOT affect the tree's width or depth!
  58. - collapse;
  59. - uncollapse;
  60. - (BOOL)collapsed;
  61.  
  62. // when dumping the tree, if you want to add extra data to the output
  63. // before the newline and before children are printed, add it here.  If
  64. // you return NO, then the children won't be printed; this is how the
  65. // collapse stuff works.  Be sure to call super and honor a NO return value!
  66. - (BOOL)moreData:(NXStream *)file level:(int)lev indent:(const char *)ind;
  67.  
  68. // How deep or wide is the tree?
  69. - (int) width;
  70. - (int) depth;
  71.  
  72. // Return the List object that contains ids of all the kids.
  73. - branches;
  74.  
  75. @end
  76.