home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Graphics / ToyViewer-2.6a / src / ADController.bproj / ADSlave.m < prev    next >
Encoding:
Text File  |  1996-12-14  |  1.5 KB  |  81 lines

  1. #import "ADSlave.h"
  2. #import "../ADController.h"
  3. #import "../TVController.h"
  4. #import "../ToyWin.h"
  5. #import "../common.h"
  6. #import "../strfunc.h"
  7.  
  8. #define  WinBufSIZE    4
  9.  
  10. static id windowBuffer[WinBufSIZE];
  11. static int    wbp = 0;
  12.  
  13. @implementation ADSlave
  14.  
  15. - init:sender with:controller dir:(const char *)path
  16. {
  17.     adCtrl = sender;
  18.     tvCtrl = controller;
  19.     directory = str_dup(path);
  20.     return self;
  21. }
  22.  
  23. - free
  24. {
  25.     free((void *)directory);
  26.     [super free];
  27.     return nil;
  28. }
  29.  
  30. /* Local Method */
  31. - doNextImage: sender
  32. {
  33.     const char *nextfile;
  34.     char    fn[MAXFILENAMELEN];
  35.     id    tw, oldtw, win;
  36.     int    n;
  37.     BOOL    fixpos, oldflag = NO;
  38.  
  39.     if ((nextfile = [adCtrl nextFilename]) == NULL)
  40.         return nil;
  41.     sprintf(fn, "%s/%s", directory, nextfile);
  42.     if ([tvCtrl isOpened: fn]) /* already opened */
  43.         return self;
  44.     n = getExtension(nextfile);
  45.     fixpos = [adCtrl scanFixPosition];
  46.     if (fixpos)
  47.         oldflag = [ToyWin displayOverKeyWindow: YES];
  48.     tw = [tvCtrl drawFile: fn : &nextfile[n]];
  49.     if (fixpos)
  50.         (void)[ToyWin displayOverKeyWindow: oldflag];
  51.     if (tw) {
  52.         oldtw = windowBuffer[wbp];
  53.         if (tw != oldtw /* coincidental */
  54.         && oldtw != nil && [tvCtrl checkWindow:oldtw delete:NO]) {
  55.             win = [oldtw window];
  56.             if ([win counterpart] == nil)
  57.                 /* has not been miniaturized */
  58.                 [win performClose: self];
  59.         }
  60.         windowBuffer[wbp] = tw;
  61.         wbp = (wbp + 1) % WinBufSIZE;
  62.     }
  63.     return self;
  64. }
  65.  
  66. - donext: sender
  67. {
  68.     id r = [self doNextImage: sender];
  69.     [adCtrl continueLoop:(r != nil)];
  70.     return r;
  71. }
  72.  
  73. - dostep: sender
  74. {
  75.     id r = [self doNextImage: sender];
  76.     [adCtrl continueLoop: NO];
  77.     return r;
  78. }
  79.  
  80. @end
  81.