File: PRWindowController.m

package info (click to toggle)
price.app 0.5-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,320 kB
  • ctags: 36
  • sloc: objc: 2,787; ansic: 256; makefile: 51
file content (63 lines) | stat: -rw-r--r-- 1,651 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
//  PRWindowController.m
//  PRICE
//
//  Created by Riccardo Mottola on Thu Dec 12 2002.
//  Copyright (c) 2002-2003 Carduus. All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under the terms of the version 2 of the GNU General Public License as published by the Free Software Foundation.
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

#import "PRWindowController.h"
#import "MyDocument.h"


@implementation PRWindowController

- (void)scaleImageTo:(float)_scale
{
    if (_scale > 0)
        scale = _scale;
    [view scaleFrameBy:scale];
    
    /* now we update the controls */
    [zoomControl setFloatValue:(scale * 100)];
    if (scale * 100 > [zoomSlider maxValue])
        [zoomSlider setFloatValue:[zoomSlider maxValue]];
    else if (scale * 100 < [zoomSlider minValue])
        [zoomSlider setFloatValue:[zoomSlider minValue]];
    else
        [zoomSlider setFloatValue:(scale * 100)];
}

- (IBAction)changeScale:(id)sender
{
    [self scaleImageTo:([sender floatValue] / 100.0)];
}

- (void)windowDidLoad
/* some initialization stuff */
{
    /* display the data by MyDocument's activeImage method */
    NSImage *image = [[self document] activeImage];
    
    [view setImage:image];
    [self scaleImageTo:1.0];
}

- (NSView *)view
/* view accessor */
{
    return view;
}
- (void)setImageToDraw:(NSImage *)image
{
    [view setImage:image];
}

-(void) dealloc
{
    [super dealloc];
}

@end