Search
lxdream.org :: lxdream/src/cocoaui/cocoa_path.m :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/cocoaui/cocoa_path.m
changeset 964:f2f3c7612d06
next1036:af7b0c5905dd
author nkeynes
date Mon Feb 09 00:13:46 2009 +0000 (15 years ago)
permissions -rw-r--r--
last change Fail cleanly if the display doesn't actually support GLX, rather than crashing horribly
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/cocoaui/cocoa_path.m Mon Feb 09 00:13:46 2009 +0000
1.3 @@ -0,0 +1,84 @@
1.4 +/**
1.5 + * $Id$
1.6 + *
1.7 + * Construct and manage the paths configuration pane
1.8 + *
1.9 + * Copyright (c) 2008 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +
1.22 +#include "cocoaui.h"
1.23 +#include "config.h"
1.24 +#include "dreamcast.h"
1.25 +
1.26 +@interface LxdreamPrefsPathPane: LxdreamPrefsPane
1.27 +{
1.28 +}
1.29 ++ (LxdreamPrefsPathPane *)new;
1.30 +@end
1.31 +
1.32 +@implementation LxdreamPrefsPathPane
1.33 ++ (LxdreamPrefsPathPane *)new
1.34 +{
1.35 + return [[LxdreamPrefsPathPane alloc] initWithFrame: NSMakeRect(0,0,600,400)];
1.36 +}
1.37 +- (id)initWithFrame: (NSRect)frameRect
1.38 +{
1.39 + if( [super initWithFrame: frameRect title: NS_("Paths")] == nil ) {
1.40 + return nil;
1.41 + } else {
1.42 + int i;
1.43 + int height = [self contentHeight] - TEXT_HEIGHT - TEXT_GAP;
1.44 +
1.45 + for( i=0; i<=CONFIG_KEY_MAX; i++ ) {
1.46 + const struct lxdream_config_entry *entry = lxdream_get_config_entry(i);
1.47 + if( entry->label != NULL ) {
1.48 + NSRect frame = NSMakeRect( TEXT_GAP, height -((TEXT_HEIGHT+TEXT_GAP)*i - 2),
1.49 + 150, LABEL_HEIGHT );
1.50 + NSTextField *label = cocoa_gui_add_label(self, NS_(entry->label), frame);
1.51 + [label setAlignment: NSRightTextAlignment];
1.52 +
1.53 + frame = NSMakeRect( 150 + (TEXT_GAP*2),
1.54 + height -((TEXT_HEIGHT+TEXT_GAP)*i),
1.55 + 360, TEXT_HEIGHT );
1.56 + NSTextField *field = [[NSTextField alloc] initWithFrame: frame];
1.57 + [field setTag: i];
1.58 + [field setStringValue: [NSString stringWithCString: entry->value]];
1.59 + [field setDelegate: self];
1.60 + [field setAutoresizingMask: (NSViewMinYMargin|NSViewWidthSizable)];
1.61 + [self addSubview: label];
1.62 + [self addSubview: field];
1.63 + }
1.64 + }
1.65 + }
1.66 + return self;
1.67 +}
1.68 +- (void)controlTextDidEndEditing:(NSNotification *)notify
1.69 +{
1.70 + int tag = [[notify object] tag];
1.71 + const char *str = [[[notify object] stringValue] UTF8String];
1.72 + const char *oldval = lxdream_get_config_value(tag);
1.73 + if( str[0] == '\0' )
1.74 + str = NULL;
1.75 + if( oldval == NULL ? str != NULL : (str == NULL || strcmp(oldval,str) != 0 ) ) {
1.76 + lxdream_set_global_config_value(tag, str);
1.77 + lxdream_save_config();
1.78 + dreamcast_config_changed();
1.79 + }
1.80 +}
1.81 +@end
1.82 +
1.83 +
1.84 +NSView *cocoa_gui_create_prefs_path_pane()
1.85 +{
1.86 + return [LxdreamPrefsPathPane new];
1.87 +}
.