1
2
3
4
5
6
7
8
9 #import <stdlib.h>
10 #import <appkit/Application.h>
11
12 #import "HTUtils.h"
13 #import <string.h>
14 #import <libc.h>
15 #import <appkit/PrintInfo.h>
16 #import <appkit/defaults.h>
17
18 extern char * appDirectory;
19
20
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
33
34
35 char *p;
36
37 static NXDefaultsVector myDefaults = {
38 { "PaperType", "Letter"},
39 { "LeftMargin", "72"},
40 { "RightMargin", "36"},
41 { "TopMargin", "36"},
42 { "BottomMargin", "36"},
43 { NULL, NULL}
44 };
45
46
47 appDirectory = malloc(strlen(argv[0]));
48 strcpy(appDirectory, argv[0]);
49 if (p = strrchr(appDirectory, '/')) p[1]=0;
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
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];
67 }
68
69 [NXApp run];
70 [NXApp free];
71 exit(0);
72 }