home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Examples / LazyScrollDir / DirController.m < prev    next >
Encoding:
Text File  |  1996-02-08  |  3.3 KB  |  114 lines

  1. //=============================================================================
  2. //
  3. //        Copyright (C) 1995 by Paul S. McCarthy and Eric Sunshine.
  4. //                Written by Paul S. McCarthy and Eric Sunshine.
  5. //                            All Rights Reserved.
  6. //
  7. //        This notice may not be removed from this source code.
  8. //
  9. //        This object is included in the MiscKit by permission from the authors
  10. //        and its use is governed by the MiscKit license, found in the file
  11. //        "License.rtf" in the MiscKit distribution.    Please refer to that file
  12. //        for a list of all applicable permissions and restrictions.
  13. //
  14. //=============================================================================
  15. //-----------------------------------------------------------------------------
  16. // DirController.m
  17. //
  18. //        Manages application which demonstrates use of TableScroll.
  19. //
  20. //-----------------------------------------------------------------------------
  21. //-----------------------------------------------------------------------------
  22. // $Id$
  23. // $Log$
  24. //-----------------------------------------------------------------------------
  25.  
  26. #import "DirController.h"
  27. #import "DirWindow.h"
  28.  
  29. @implementation DirController
  30.  
  31. //-----------------------------------------------------------------------------
  32. // - init
  33. //-----------------------------------------------------------------------------
  34. - init
  35.     {
  36.     [super init];
  37.     infoPanel = 0;
  38.     return self;
  39.     }
  40.  
  41.  
  42. //-----------------------------------------------------------------------------
  43. // - free
  44. //-----------------------------------------------------------------------------
  45. - free
  46.     {
  47.     if (infoPanel)
  48.         [infoPanel free];
  49.     return [super free];
  50.     }
  51.  
  52.  
  53. //-----------------------------------------------------------------------------
  54. // - appDidInit:
  55. //-----------------------------------------------------------------------------
  56. - appDidInit: sender
  57.     {
  58.     [DirWindow launchDir:0];
  59.     return self;
  60.     }
  61.  
  62.  
  63. //-----------------------------------------------------------------------------
  64. // - new:
  65. //-----------------------------------------------------------------------------
  66. - new:sender
  67.     {
  68.     int rc;
  69.     OpenPanel* panel = [OpenPanel new];
  70.     [panel setTitle: "Open Directory"];
  71.     [panel setPrompt:"Directory:"];
  72.     [panel chooseDirectories: YES];
  73.     [panel allowMultipleFiles: NO];        // OpenPanel screws up multiple dirs.
  74.     [panel setTreatsFilePackagesAsDirectories: YES];
  75.     rc = [panel runModal];
  76.     [panel close];
  77.     if (rc == NX_OKTAG)
  78.         {
  79.         char const* const* filename;
  80.         char const* dir = [panel directory];
  81.         if (dir == 0) dir = "";
  82.         for (filename = [panel filenames];    *filename != 0;     filename++)
  83.             {
  84.             char buff[ FILENAME_MAX * 2 + 1 ];
  85.             strcat( strcat( strcpy( buff, dir ), "/" ), *filename );
  86.             [DirWindow launchDir: buff];
  87.             }
  88.         }
  89.     return self;
  90.     }
  91.  
  92.  
  93. //-----------------------------------------------------------------------------
  94. // - info:
  95. //-----------------------------------------------------------------------------
  96. - info:sender
  97.     {
  98.     if (infoPanel == 0)
  99.         {
  100.         char buff[ FILENAME_MAX + 1 ];
  101.         id const bundle = [NXBundle bundleForClass:[self class]];
  102.         [bundle getPath:buff forResource:"Info" ofType:"nib"];
  103.         [NXApp loadNibFile:buff owner:self withNames:NO fromZone:[self zone]];
  104.  
  105.         if (![bundle getPath:buff forResource:"README" ofType:"rtf"])
  106.              [bundle getPath:buff forResource:"README" ofType:"rtfd"];
  107.         [infoText openRTFDFrom:buff];
  108.         }
  109.     [infoPanel makeKeyAndOrderFront:self];
  110.     return self;
  111.     }
  112.  
  113. @end
  114.