home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Viewers / aa_m68k_Intel_Only / ToyViewer1.2 / Source / ToyWinPCD.m < prev    next >
Encoding:
Text File  |  1995-11-12  |  1.2 KB  |  53 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. @implementation ToyWinPCD
  14.  
  15. - (int)drawToyWin:(const char *)fileName Type:(int)type Num:(int)num
  16. {
  17.     int x;
  18.     char buf[256];
  19.     static const char *const brightTab[] = { ":+", "", ":-" };
  20.     static const char *const baseTab[] = {
  21.         "B-16", "B-4", "B", "B+4", "B+16", "B+64" };
  22.  
  23.     for (x = 0; execList[x]; x++) ;
  24.     execList[x] = (char *)fileName;
  25.     sprintf(buf, "%s(%s%s)", fileName, baseTab[base], brightTab[bright]);
  26.     return [super drawToyWin: buf Type: type Num: num];
  27. }
  28.  
  29. - setPreference: pref
  30. {
  31.     int n;
  32.     char **list;
  33.     static char buf[128];
  34.     static char *brightTab[] = { "-c+", "-c0", "-c-" };
  35.     static char *baseTab[] = {
  36.         "-1", "-2", "-3", "-4", "-5", "-6" };
  37.  
  38.     list = (char **)malloc(sizeof(char *) * 6);
  39.     n = dircopy(buf, NXArgv[0], YES);
  40.     list[0] = buf;
  41.     strcpy(&buf[n], pcdCOMMAND);
  42.     list[1] = &buf[n];
  43.     [pref pcdSize: &base bright: &bright];
  44.     list[2] = brightTab[bright];
  45.     list[3] = baseTab[base];
  46.     list[4] = NULL;    /* filename */
  47.     list[5] = NULL;
  48.     [self setExecList: list ext: "pcd"];
  49.     return self;
  50. }
  51.  
  52. @end
  53.