home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Graphics / ToyViewer-2.6a / src / ToyWinPCD.m < prev    next >
Encoding:
Text File  |  1996-03-24  |  1.4 KB  |  62 lines

  1. #import <appkit/Application.h>
  2. #import <appkit/appkit.h>
  3. #import <sys/file.h>
  4. #import <stdio.h>
  5. #import <stdlib.h>
  6. #import <string.h>
  7. #import "ToyWinPCD.h"
  8. #import "PrefControl.h"
  9. #import "strfunc.h"
  10.  
  11. #define  pcdCOMMAND    "hpcdtoppm"
  12.  
  13. static int prefBase = 0;
  14. static int prefBright = 0;
  15.  
  16. @implementation ToyWinPCD
  17.  
  18. + (void)setBase:(int)base bright:(int)bright
  19. {
  20.     prefBase = base;
  21.     prefBright = bright;
  22. }
  23.  
  24. - (commonInfo *)drawToyWin:(const char *)fileName type:(int)type
  25.     map:(unsigned char **)map err:(int *)err
  26. {
  27.     int x;
  28.     char buf[256];
  29.     static const char *const brightTab[] = { ":+", "", ":-" };
  30.     static const char *const baseTab[] = {
  31.         "B-16", "B-4", "B", "B+4", "B+16", "B+64" };
  32.  
  33.     for (x = 0; execList[x]; x++) ;
  34.     execList[x] = (char *)fileName;
  35.     sprintf(buf, "%s(%s%s)", fileName, baseTab[prefBase], brightTab[prefBright]);
  36.     return [super drawToyWin:buf type:type map:map err:err];
  37. }
  38.  
  39. - setting
  40. {
  41.     int n;
  42.     char **list;
  43.     static char buf[128];
  44.     static char *brightTab[] = { "-c+", "-c0", "-c-" };
  45.     static char *baseTab[] = {
  46.         "-1", "-2", "-3", "-4", "-5", "-6" };
  47.  
  48.     list = (char **)malloc(sizeof(char *) * 6);
  49.     n = dircopy(buf, NXArgv[0], YES);
  50.     list[0] = buf;
  51.     strcpy(&buf[n], pcdCOMMAND);
  52.     list[1] = &buf[n];
  53.     list[2] = brightTab[prefBright];
  54.     list[3] = baseTab[prefBase];
  55.     list[4] = NULL;    /* filename */
  56.     list[5] = NULL;
  57.     [self setExecList: list ext: "pcd"];
  58.     return self;
  59. }
  60.  
  61. @end
  62.