filename | src/cocoaui/cocoa_path.c |
changeset | 888:9892c970b95a |
prev | 881:10b67e485aa4 |
author | nkeynes |
date | Wed Oct 29 23:51:58 2008 +0000 (15 years ago) |
permissions | -rw-r--r-- |
last change | Use regparam calling conventions for all functions called from translated code, along with a few other high-use functions. Can probably extend this to all functions, but as it is this is a nice performance boost |
view | annotate | diff | log | raw |
1 /**
2 * $Id$
3 *
4 * Construct and manage the paths configuration pane
5 *
6 * Copyright (c) 2008 Nathan Keynes.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
19 #include "cocoaui.h"
20 #include "config.h"
21 #include "dreamcast.h"
23 @interface LxdreamPrefsPathPane: LxdreamPrefsPane
24 {
25 }
26 + (LxdreamPrefsPathPane *)new;
27 @end
29 @implementation LxdreamPrefsPathPane
30 + (LxdreamPrefsPathPane *)new
31 {
32 return [[LxdreamPrefsPathPane alloc] initWithFrame: NSMakeRect(0,0,600,400)];
33 }
34 - (id)initWithFrame: (NSRect)frameRect
35 {
36 if( [super initWithFrame: frameRect title: NS_("Paths")] == nil ) {
37 return nil;
38 } else {
39 int i;
40 int height = [self contentHeight] - TEXT_HEIGHT - TEXT_GAP;
42 for( i=0; i<=CONFIG_KEY_MAX; i++ ) {
43 const struct lxdream_config_entry *entry = lxdream_get_config_entry(i);
44 if( entry->label != NULL ) {
45 NSRect frame = NSMakeRect( TEXT_GAP, height -((TEXT_HEIGHT+TEXT_GAP)*i - 2),
46 150, LABEL_HEIGHT );
47 NSTextField *label = cocoa_gui_add_label(self, NS_(entry->label), frame);
48 [label setAlignment: NSRightTextAlignment];
50 frame = NSMakeRect( 150 + (TEXT_GAP*2),
51 height -((TEXT_HEIGHT+TEXT_GAP)*i),
52 360, TEXT_HEIGHT );
53 NSTextField *field = [[NSTextField alloc] initWithFrame: frame];
54 [field setTag: i];
55 [field setStringValue: [NSString stringWithCString: entry->value]];
56 [field setDelegate: self];
57 [field setAutoresizingMask: (NSViewMinYMargin|NSViewWidthSizable)];
58 [self addSubview: label];
59 [self addSubview: field];
60 }
61 }
62 }
63 return self;
64 }
65 - (void)controlTextDidEndEditing:(NSNotification *)notify
66 {
67 int tag = [[notify object] tag];
68 const char *str = [[[notify object] stringValue] UTF8String];
69 const char *oldval = lxdream_get_config_value(tag);
70 if( str[0] == '\0' )
71 str = NULL;
72 if( oldval == NULL ? str != NULL : (str == NULL || strcmp(oldval,str) != 0 ) ) {
73 lxdream_set_global_config_value(tag, str);
74 lxdream_save_config();
75 dreamcast_config_changed();
76 }
77 }
78 @end
81 NSView *cocoa_gui_create_prefs_path_pane()
82 {
83 return [LxdreamPrefsPathPane new];
84 }
.