home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / YellowBox / Kits / MiscTableScroll-138.1 / Examples / LazyScrollDir / DirController.m < prev    next >
Encoding:
Text File  |  1998-03-31  |  4.1 KB  |  135 lines

  1. //=============================================================================
  2. //
  3. //    Copyright (C) 1995-1997 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: DirController.m,v 1.1 97/03/23 01:59:13 sunshine Exp $
  23. // $Log:    DirController.m,v $
  24. // Revision 1.1  97/03/23  01:59:13  sunshine
  25. // v13.1: Application controller.
  26. // 
  27. //-----------------------------------------------------------------------------
  28. #import "DirController.h"
  29. #import "Defaults.h"
  30. #import "DirWindow.h"
  31. #import "SD_PageLayout.h"
  32. #import <AppKit/NSNibLoading.h>
  33. #import <AppKit/NSOpenPanel.h>
  34. #import <AppKit/NSTextField.h>
  35.  
  36. @implementation DirController
  37.  
  38. //-----------------------------------------------------------------------------
  39. // - init
  40. //-----------------------------------------------------------------------------
  41. - (id)init
  42.     {
  43.     [super init];
  44.     infoPanel = 0;
  45.     return self;
  46.     }
  47.  
  48.  
  49. //-----------------------------------------------------------------------------
  50. // - dealloc
  51. //-----------------------------------------------------------------------------
  52. - (void)dealloc
  53.     {
  54.     if (infoPanel)
  55.     [infoPanel release];
  56.     [super dealloc];
  57.     }
  58.  
  59.  
  60. //-----------------------------------------------------------------------------
  61. // - applicationDidFinishLaunching:
  62. //-----------------------------------------------------------------------------
  63. - (void)applicationDidFinishLaunching:(NSNotification*)n
  64.     {
  65.     [DirWindow launchDir:0];
  66.     }
  67.  
  68.  
  69. //-----------------------------------------------------------------------------
  70. // - applicationWillTerminate:
  71. //-----------------------------------------------------------------------------
  72. - (void)applicationWillTerminate:(NSNotification*)n
  73.     {
  74.     [Defaults commit];
  75.     }
  76.  
  77.  
  78. //-----------------------------------------------------------------------------
  79. // - runPageLayout:
  80. //-----------------------------------------------------------------------------
  81. - (void)runPageLayout:(id)sender
  82.     {
  83.     [[SD_PageLayout pageLayout] runModal];
  84.     }
  85.  
  86.  
  87. //-----------------------------------------------------------------------------
  88. // - new:
  89. //-----------------------------------------------------------------------------
  90. - (void)new:(id)sender
  91.     {
  92.     static NSOpenPanel* panel = 0;
  93.     if (panel == 0)
  94.     {
  95.     panel = [[NSOpenPanel openPanel] retain];
  96.     [panel setTitle:@"Open Directory"];
  97.     [panel setPrompt:@"Directory:"];
  98.     [panel setCanChooseDirectories:YES];
  99.     [panel setCanChooseFiles:NO];
  100.     [panel setAllowsMultipleSelection:YES];
  101.     [panel setTreatsFilePackagesAsDirectories:YES];
  102.     }
  103.  
  104.     if ([panel runModal] == NSOKButton)
  105.         {
  106.     unsigned int i;
  107.     NSArray* filenames = [panel filenames];
  108.     for (i = [filenames count]; i-- > 0; )
  109.         [DirWindow launchDir:[filenames objectAtIndex:i]];
  110.     } 
  111.     }
  112.  
  113.  
  114. //-----------------------------------------------------------------------------
  115. // - info:
  116. //-----------------------------------------------------------------------------
  117. - (void)info:(id)sender
  118.     {
  119.     if (infoPanel == 0)
  120.     {
  121.     NSString* s;
  122.     [NSBundle loadNibNamed:@"Info" owner:self];
  123.     s = [[NSBundle bundleForClass:[self class]]
  124.             pathForResource:@"README" ofType:@"rtf"];
  125.     if (s == 0)
  126.         s = [[NSBundle bundleForClass:[self class]]
  127.             pathForResource:@"README" ofType:@"rtfd"];
  128.     if (s != 0)
  129.         [infoText readRTFDFromFile:s];
  130.     }
  131.     [infoPanel makeKeyAndOrderFront:self]; 
  132.     }
  133.  
  134. @end
  135.