home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / DevTools / eText5 / Source / AppKernel.subproj / scratch < prev    next >
Encoding:
Text File  |  1994-10-01  |  3.0 KB  |  101 lines

  1. - drawPageBorder:(float)width :(float)height
  2. {
  3.     static const char *months[] = {
  4.         "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  5.         "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };
  6.  
  7.     DPSContext context = DPSGetCurrentContext();
  8.     struct tm *now;
  9.     long t;
  10.  
  11.     /* Let's be moderately well behaved at least. */
  12.     [super drawPageBorder:width :height];
  13.  
  14.     if (context) {
  15.         /* Use Ohlfs 10 point for the header font. */
  16.         DPSPrintf(context, "/Ohlfs findfont\n");
  17.         DPSPrintf(context, "10 scalefont\n");
  18.         DPSPrintf(context, "setfont\n");
  19.  
  20.         /* Print the page number right justified at the top of the
  21.         ** page.
  22.         */
  23.         DPSPrintf(context,
  24.             "/NLPRPageString (Page %d) def\n",
  25.             [[NXApp printInfo] currentPage]);
  26.         DPSPrintf(context,
  27.             "%g NLPRPageString stringwidth pop sub\n", width - 30.);
  28.         DPSPrintf(context,
  29.             "%g moveto\n", height - 30.);
  30.         DPSPrintf(context, "NLPRPageString show\n");
  31.         
  32.         /* Print the date and file name. */
  33.         time(&t);
  34.         now = localtime(&t);
  35.         DPSPrintf(context, "30 %g moveto\n", height - 30.);
  36.         DPSPrintf(context, "(%s %d, %d %d:%d   %s) show\n",
  37.             months[now->tm_mon],
  38.             now->tm_mday,
  39.             now->tm_year + 1900,
  40.             now->tm_hour,
  41.             now->tm_min,
  42.             filename);
  43.         
  44.         /* Draw a line under the thing. */
  45.         DPSPrintf(context,
  46.             "2 setlinewidth 30 %g moveto %g %g lineto stroke\n",
  47.             height - 33.,
  48.             width - 30.,
  49.             height - 33.);
  50.     }
  51.     return self;
  52. }
  53.  
  54.  
  55. - chooseEncoding:sender
  56. {
  57.     int choice = NXRunAlertPanel("Choose Encoding...","You can optimize the HTML generated to work around particular clients. To permanently change your default encoding, \"dwrite eText HTMLEncoding Type\" (look in the app wrapper).", "Strict HTML","XMosaic","OmniWeb");
  58.     switch (choice) {
  59.         case NX_ALERTDEFAULT: NXSetDefault([NXApp appName], "HTMLEncoding", "ASCII"); break;
  60.         case NX_ALERTALTERNATE: NXSetDefault([NXApp appName], "HTMLEncoding", "XMosaic"); break;
  61.         case NX_ALERTOTHER: NXSetDefault([NXApp appName], "HTMLEncoding", "OmniWeb"); break;
  62.     }
  63.     flushHTMLEncoding(); // yeah, it's a memory leak. so f*cking sue me.
  64.     return self;
  65. }
  66.  
  67.  
  68. eTdoc needs -eText
  69.  
  70. - savePanel:(int)fmt
  71. {
  72.     static id it = nil;
  73.     
  74.     if (!it) {
  75.         const char *docdir;    
  76.  
  77.         it = [SavePanel new];
  78.         docdir = NXGetDefaultValue([NXApp appName], "ETFDirectory");
  79.         if (docdir && *docdir) {
  80.             [it setDirectory:docdir];
  81.         }
  82.     }
  83.     [it setAccessoryView:spaView];
  84.     if (fmt>=0)
  85.         [spaM selectCellWithTag:fmt];
  86.     return it;
  87. }
  88. - detachAgent:sender
  89. {    
  90.     if (![[[NXApp mainWindow] delegate] etDoc])
  91.         return nil;
  92.     if (![[[[NXApp mainWindow] delegate] etDoc] acceptsAgent]) {
  93.         int choice = NXRunAlertPanel("Detach Agent",
  94.                     "Are you sure you want to remove the agent currently working with this document? You cannot undo this action.",
  95.                     "Remove", "Cancel", NULL);
  96.         if (choice == NX_ALERTALTERNATE) {return nil;}
  97.         [[[[NXApp mainWindow] delegate] etDoc] detachAgent];
  98.     }
  99.     return self;
  100. }
  101.