Changed russian description a little bit
[gnuplot] / src / OpenStep / GnuView.m
1 #import "GnuView.h"
2
3 @implementation GnuView
4
5 static float xsize= NEXT_XMAX/10+50;
6 static float ysize= NEXT_YMAX/10+50;
7
8 static int printing;
9 static void setprintsize();
10
11 - initWithFrame:(NSRect)rects
12 {
13     [super initWithFrame:rects];
14
15     PSstring = @"";
16     [self display];
17
18     return self;
19 }
20
21
22 /* This is here to fix NeXT bug # 21973:  failure to free D.O. memory */
23 /* Note:  personally I don't think this fixes it. */
24 - (void)dealloc
25 {
26     [super dealloc];
27     [PSstring release];
28 }
29
30 - executePS:(NSString *) PStext
31 {
32     if (PSstring)
33         [PSstring release];
34     PSstring = PStext;
35     [PSstring retain];
36
37     [[self window] makeKeyAndOrderFront:self];
38     [self display];
39
40     return self;
41 }
42
43 - (void) drawRect:(NSRect) rect
44 {
45     DPSContext d;
46
47     d = DPSGetCurrentContext();
48
49     if (!printing) { /* Clear Screen */
50         PSsetgray(NSWhite);
51         NSRectFill([self bounds]);
52         [self setBoundsSize:NSMakeSize(xsize, ysize)];    /* scale to gnuplot coords */
53     }
54     else {
55         setprintsize();
56     }
57     DPSWritePostScript(d, [PSstring cString], [PSstring length]);
58     DPSFlushContext(d);
59 }
60
61
62 - (void)print:(id)sender
63 {
64         printing = 1;
65         [super print:sender];
66         printing = 0;
67 }
68
69 static void setprintsize()
70 {
71     DPSContext d;
72     NSSize paperSize;
73     id prInfo;
74
75     d = DPSGetCurrentContext();
76 #warning PrintingConversion:  The current PrintInfo object now depends on context. '[NSPrintInfo sharedPrintInfo]' used to be '[NSApp printInfo]'. This might want to be [[NSPrintOperation currentOperation] printInfo] or possibly [[PageLayout new] printInfo].
77
78     prInfo = [NSPrintInfo sharedPrintInfo];
79     paperSize = [prInfo paperSize];
80
81     DPSPrintf(d, "grestore\ngrestore\ngrestore\n");
82
83     if ([prInfo orientation] == NSLandscapeOrientation) {
84         DPSPrintf(d, "-90 rotate\n");
85         DPSPrintf(d, "%g 0 translate\n", -1.0 * paperSize.width);
86         DPSPrintf(d, "0 %g translate\n", paperSize.height/20);
87     }
88     else {
89         DPSPrintf(d, "%g %g scale\n", paperSize.width/paperSize.height, paperSize.height/paperSize.width);
90     }
91
92     DPSPrintf(d, "gsave\ngsave\n");
93
94     DPSFlushContext(d);
95
96     return;
97 }
98
99 @end
100
101