File: PRCBriCon.m

package info (click to toggle)
price.app 0.8.3%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,808 kB
  • ctags: 46
  • sloc: objc: 3,480; ansic: 284; makefile: 41
file content (124 lines) | stat: -rw-r--r-- 3,355 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//
//  PRCBriCon.m
//  PRICE
//
//  Created by Riccardo Mottola on Thu Mar 3 2005.
//  Copyright (c) 2005 Carduus. All rights reserved.
//
// This application is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
// 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.

// for values > 1
// the minimum is from 126 to 127: 1.008
// 125 to 127: 1.015
// the maximum is from 1 to 127: 127

#include <stdlib.h>

#import "PRCBriCon.h"
#import "MyDocument.h"

#include <limits.h>

#define HALF_CHAR (UCHAR_MAX >> 1)

@implementation PRCBriCon


- (IBAction)showBriCon:(id)sender
{
    if (!briconWindow)
        [NSBundle loadNibNamed:@"BriCon" owner:self];
    [briconWindow makeKeyAndOrderFront:nil];
}

- (IBAction)briconOk:(id)sender
{
    float contrast;
    int level;

    level = [conVal intValue];
    contrast = 1 + (float)abs(level)/HALF_CHAR;
    if (level < 0)
        contrast = 1 / contrast;
    [[[NSDocumentController sharedDocumentController] currentDocument] makeBriCon :[briVal intValue] :contrast];
    if ([[NSApp delegate] prefClosePanels])
        [briconWindow performClose:nil];
}

- (IBAction)briconCancel:(id)sender
{
    [briconWindow performClose:nil];
}

- (IBAction)briconReset:(id)sender
{
    [briSlider setIntValue:0];
    [briStep setIntValue:0];
    [briVal setIntValue:0];
    [conSlider setFloatValue:0.0];
    [conStep setFloatValue:0.0];
    [conVal setFloatValue:0.0];
}

- (IBAction)changeBri:(id)sender
{
    if (sender == briVal)
    {
        int tempVal;
        
        tempVal = [sender intValue];
        if (tempVal > 255)
        {
            tempVal = 255;
            [briVal setIntValue:tempVal];
        } else if (tempVal < -255)
        {
            tempVal = -255;
            [briVal setIntValue:tempVal];
        }
        [briSlider setIntValue:tempVal];
        [briStep setIntValue:tempVal];
    } else if (sender == briStep)
    {
        [briSlider setIntValue:[sender intValue]];
        [briVal setIntValue:[sender intValue]];
    } else if (sender == briSlider)
    {
        [briVal setIntValue:[sender intValue]];
        [briStep setIntValue:[sender intValue]];
    } else
        NSLog(@"undexpected sender value in changeBri");
}

- (IBAction)changeCon:(id)sender
{
    if (sender == conVal)
    {
        int tempVal;
        
        tempVal = [sender intValue];
        if (tempVal > 127)
        {
            tempVal = 127;
            [briVal setIntValue:tempVal];
        } else if (tempVal < -127)
        {
            tempVal = -127;
            [briVal setIntValue:tempVal];
        }
        [conSlider setIntValue:tempVal];
        [conStep setIntValue:tempVal];
    } else if (sender == conStep)
    {
        [conSlider setIntValue:[sender intValue]];
        [conVal setIntValue:[sender intValue]];
    } else if (sender == conSlider)
    {
        [conVal setIntValue:[sender intValue]];
        [conStep setIntValue:[sender intValue]];
    } else
        NSLog(@"undexpected sender value in changeBri");
}

@end