home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / Apps / DevTools / MachOViewer / Source / Controller.m < prev    next >
Encoding:
Text File  |  1994-05-29  |  1.8 KB  |  105 lines

  1. #import "Controller.h"
  2.  
  3. @implementation Controller
  4.  
  5. /* $Log:    Controller.m,v $
  6. Revision 1.4  94/05/29  20:14:32  ediger
  7. help/explanation panel support
  8.  
  9. Revision 1.3  94/05/29  14:59:51  ediger
  10. cleanup to eliminate compiler warning
  11.  
  12. Revision 1.2  94/02/03  19:54:34  ediger
  13. cleanup of commented out code
  14.  
  15. Revision 1.1  93/12/19  13:02:54  ediger
  16. Initial revision
  17.  
  18.  */
  19.  
  20. static char rcsident[] = "$Id: Controller.m,v 1.4 94/05/29 20:14:32 ediger Exp Locker: ediger $";
  21.  
  22. static BOOL
  23. fGetOpenPath(char *pcName, int iBufferLength, char *pcType)
  24. {
  25.     BOOL fSuccess = NO;
  26.     static char *ppcFileTypes[2] = {NULL, NULL};
  27.     static id openPanel = Nil;
  28.  
  29.     assert(pcName != NULL);
  30.     
  31.     if (openPanel == Nil)
  32.         openPanel = [OpenPanel new];
  33.  
  34.     assert(openPanel != Nil);
  35.     
  36.     if (pcType != NULL && *pcType != '\0')
  37.         ppcFileTypes[0] = pcType;
  38.     
  39.     [NXApp setAutoupdate:NO];
  40.     
  41.     if ([openPanel runModalForTypes:ppcFileTypes])
  42.     {    const char *pcNameTmp = [openPanel filename];
  43.         strncpy(pcName, pcNameTmp, iBufferLength);
  44.         fSuccess = YES;
  45.     }
  46.     
  47.     [NXApp setAutoupdate:YES];
  48.  
  49.     return fSuccess;
  50. }
  51.  
  52.  
  53. - init
  54. {
  55.     infoPanel = Nil;
  56.     return self;
  57. }
  58.  
  59. - closeFile:sender
  60. {
  61.     id oCurrentMainWindow;
  62.  
  63.     oCurrentMainWindow = [NXApp mainWindow];
  64.     [oCurrentMainWindow close];
  65.     [oCurrentMainWindow free];
  66.  
  67.     return self;
  68. }
  69.  
  70. - openNewFile:sender
  71. {
  72.     char pcPath[1024];
  73.  
  74.     if (fGetOpenPath(pcPath, 1024, NULL))
  75.     {    id p = [[Document alloc] init];
  76.         [p openFileNamed:pcPath];
  77.         [p show:self];
  78.     }
  79.  
  80.     return self;
  81. }
  82.  
  83. - showInfoPanel:sender
  84. {
  85.     if (infoPanel == nil)
  86.         if (![NXApp loadNibSection:"Info.nib" owner:self])
  87.             return nil;
  88.     
  89.     [infoPanel makeKeyAndOrderFront:self];
  90.     return self;
  91. }
  92.  
  93. - showHelpPanel:sender
  94. {
  95.     if (helpPanel == nil)
  96.         if (![NXApp loadNibSection:"HelpPanel.nib" owner:self])
  97.             return nil;
  98.     
  99.     [helpPanel makeKeyAndOrderFront:self];
  100.     return self;
  101. }
  102.  
  103.  
  104. @end
  105.