1 /*
 2  *     Generated by the NeXT Interface Builder.
 3  * 
 4  * History:
 5  *  27 Feb 91 Modified TBL to initialise NXArgv early on
 6  *  19 Mar 91 Page info deafults
 7  */
 8 
 9 #import <stdlib.h>
10 #import <appkit/Application.h>
11 // #import <appkit/defaults.h>      /* TBL */
12 #import "HTUtils.h"       /* TBL */
13 #import <string.h>        /* TBL */
14 #import <libc.h>        /* TBL */
15 #import <appkit/PrintInfo.h>      /* TBL */
16 #import <appkit/defaults.h>     /* TBL */
17 
18 extern char * appDirectory; /* Name of the directory containing the application */
19 
20 /*  Get Integer default value
21 */
22 static int int_default(const char * param)
23 {
24     int result = 0;
25     const char * string = NXGetDefaultValue("WorldWideWeb", param);
26     if (string) sscanf(string, "%i", &result);
27     return result;
28 }
29 
30 void main(int argc, char *argv[])
31 {
32 //    NXArgc = argc;    /* TBL */
33 //    NXArgv = argv;    /* TBL */
34 
35     char *p;
36 
37     static NXDefaultsVector myDefaults = {
38         { "PaperType", "Letter"},   // Non-USA users will have to override
39   { "LeftMargin", "72"},//  (72) Space for ring binding
40   { "RightMargin", "36"}, //  (72) Note printers need some margin 
41   { "TopMargin", "36"}, // (108) All margins in points
42   { "BottomMargin", "36"},// (108) PrintInfo defaults in brackets
43   { NULL, NULL} // Terminate list.
44     };
45 
46 
47     appDirectory = malloc(strlen(argv[0]));
48     strcpy(appDirectory, argv[0]);
49     if (p = strrchr(appDirectory, '/')) p[1]=0; /* Chop home directory after slash */
50     if (TRACE) printf("WWW: Run from %s\n", appDirectory);
51 
52     NXApp = [Application new];
53     NXRegisterDefaults("WorldWideWeb", myDefaults);
54     [NXApp loadNibSection:"WorldWideWeb.nib" owner:NXApp];
55 
56 //  The deafult Margins seem to be 72, 72, 108, 108 which is a lot.    
57     {
58   int leftM = int_default("LeftMargin");
59   int rightM = int_default("RightMargin");
60   int topM = int_default("TopMargin");
61   int bottomM = int_default("BottomMargin");
62 
63         PrintInfo * pi = [NXApp printInfo];
64         [pi setPaperType:NXGetDefaultValue("WorldWideWeb", "PaperType") andAdjust:YES];
65   [pi setVertCentered:NO];
66   [pi setMarginLeft:leftM right:rightM top:topM bottom:bottomM]; // Points.
67     }
68 
69     [NXApp run];
70     [NXApp free];
71     exit(0);
72 }