File: ConversionList.m

package info (click to toggle)
wcalc 2.2.2-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,228 kB
  • ctags: 698
  • sloc: ansic: 6,918; objc: 1,835; sh: 766; yacc: 644; lex: 573; makefile: 78
file content (57 lines) | stat: -rw-r--r-- 1,497 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
#include "conversion.h"
#include "ConversionList.h"
#ifdef MEMWATCH
#include "memwatch.h"
#endif

@implementation ConversionList
- (IBAction)newType:(id)sender
{
	if ([toList selectedRow]>-1)
		[toList deselectAll:sender];
	if ([fromList selectedRow]>-1)
		[fromList deselectAll:sender];
	[toList reloadData];
	[fromList reloadData];
}

- (int)numberOfRowsInTableView:(NSTableView *)atv
{
	switch ([theType indexOfSelectedItem]) {
		case LENGTH_C: return LENGTH_UNIT_COUNT;
		case AREA_C: return AREA_UNIT_COUNT;
		case VOLUME_C: return VOLUME_UNIT_COUNT;
		case MASS_C: return MASS_UNIT_COUNT;
		case SPEED_C: return SPEED_UNIT_COUNT;
		case POWER_C: return POWER_UNIT_COUNT;
		case FORCE_C: return FORCE_UNIT_COUNT;
		case ACCELERATION_C: return ACCELERATION_UNIT_COUNT;
		case TEMPERATURE_C: return TEMPERATURE_UNIT_COUNT;
		default:
			return 0;
	}
}

- (id)tableView:(NSTableView *)atv objectValueForTableColumn:(NSTableColumn*)col row:(int)rowIndex
{
	int type = [theType indexOfSelectedItem];
	static NSString * reamur = NULL;
	if (! reamur) {
		reamur = [NSString stringWithFormat:@"R%Caumur", 0x00e9];
		[reamur retain];
	}
	if (type != TEMPERATURE_C) {
		return [NSString stringWithUTF8String:conversions[type][rowIndex].name];
	} else {
		switch (rowIndex) {
			case KELVIN: return @"Kelvin";
			case CELSIUS: return @"Celsius";
			case RANKINE: return @"Rankine";
			case FARENHEIT: return @"Farenheit";
			case REAUMUR: return reamur;
			default:
				return @"UNKNOWN";
		}
	}
}
@end