filename | src/cocoaui/cocoa_prefs.c |
changeset | 725:4d4018e8eeb8 |
next | 729:4cc913eabd3d |
author | nkeynes |
date | Sun Jul 06 03:18:55 2008 +0000 (15 years ago) |
permissions | -rw-r--r-- |
last change | Add slightly more detailed about dialog Add (currently empty) preferences dialog (WIP) |
file | annotate | diff | log | raw |
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00001.2 +++ b/src/cocoaui/cocoa_prefs.c Sun Jul 06 03:18:55 2008 +00001.3 @@ -0,0 +1,127 @@1.4 +/**1.5 + * $Id: cocoa_win.c 723 2008-06-25 00:39:02Z nkeynes $1.6 + *1.7 + * Construct and manage the preferences panel under cocoa.1.8 + *1.9 + * Copyright (c) 2008 Nathan Keynes.1.10 + *1.11 + * This program is free software; you can redistribute it and/or modify1.12 + * it under the terms of the GNU General Public License as published by1.13 + * the Free Software Foundation; either version 2 of the License, or1.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 of1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1.19 + * GNU General Public License for more details.1.20 + */1.21 +1.22 +#include "cocoaui/cocoaui.h"1.23 +#include "lxdream.h"1.24 +#include "config.h"1.25 +1.26 +@interface LxdreamPrefsToolbarDelegate : NSObject {1.27 + NSArray *identifiers;1.28 + NSArray *defaults;1.29 + NSDictionary *items;1.30 +}1.31 +- (NSToolbarItem *) createToolbarItem: (NSString *)id label: (NSString *) label1.32 + tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action;1.33 +@end1.34 +1.35 +@implementation LxdreamPrefsToolbarDelegate1.36 +- (id) init1.37 +{1.38 + NSToolbarItem *paths = [self createToolbarItem: @"Paths" label: @"Paths"1.39 + tooltip: @"Configure system paths" icon: @"tb-paths"1.40 + action: @selector(paths_action:)];1.41 + NSToolbarItem *ctrls = [self createToolbarItem: @"Controllers" label: @"Controllers"1.42 + tooltip: @"Configure controllers" icon: @"tb-ctrls"1.43 + action: @selector(controllers_action:)];1.44 + identifiers = [NSArray arrayWithObjects: @"Paths", @"Controllers", nil ];1.45 + defaults = [NSArray arrayWithObjects: @"Paths", @"Controllers", nil ];1.46 + NSArray *values = [NSArray arrayWithObjects: paths, ctrls, nil ];1.47 + items = [NSDictionary dictionaryWithObjects: values forKeys: identifiers];1.48 + return self;1.49 +}1.50 +1.51 +- (NSToolbarItem *) createToolbarItem: (NSString *)id label: (NSString *) label1.52 + tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action1.53 +{1.54 + NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier: id];1.55 + [item setLabel: label];1.56 + [item setToolTip: tooltip];1.57 + [item setTarget: self];1.58 + NSString *iconFile = [[NSBundle mainBundle] pathForResource:icon ofType:@"png"];1.59 + NSImage *image = [[NSImage alloc] initWithContentsOfFile: iconFile];1.60 + [item setImage: image];1.61 + [item setAction: action];1.62 + return item;1.63 +}1.64 +1.65 +- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar1.66 +{1.67 + return identifiers;1.68 +}1.69 +1.70 +- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar1.71 +{1.72 + return defaults;1.73 +}1.74 +1.75 +- (NSArray *)toolbarSelectableItemIdentifiers: (NSToolbar *)toolbar1.76 +{1.77 + return [NSArray arrayWithObjects: @"Paths", @"Controllers", nil];1.78 +}1.79 +1.80 +- (NSToolbarItem *) toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier1.81 + willBeInsertedIntoToolbar:(BOOL)flag1.82 +{1.83 + return [items objectForKey: itemIdentifier];1.84 +}1.85 +- (void)paths_action: (id)sender1.86 +{1.87 +}1.88 +- (void)controllers_action: (id)sender1.89 +{1.90 +}1.91 +@end1.92 +1.93 +@implementation LxdreamPrefsPanel1.94 +- (NSView *)createPathsPane1.95 +{1.96 + NSView *pane = [NSView new];1.97 + int i;1.98 + for( i=0; i<=CONFIG_KEY_MAX; i++ ) {1.99 + lxdream_config_entry_t entry = lxdream_get_config_entry(i);1.100 + if( entry->label != NULL ) {1.101 + }1.102 + }1.103 + return pane;1.104 +}1.105 +- (id)initWithContentRect:(NSRect)contentRect1.106 +{1.107 + if( [super initWithContentRect: contentRect1.108 + styleMask: ( NSTitledWindowMask | NSClosableWindowMask |1.109 + NSMiniaturizableWindowMask | NSResizableWindowMask |1.110 + NSUnifiedTitleAndToolbarWindowMask )1.111 + backing: NSBackingStoreBuffered defer: NO ] == nil ) {1.112 + return nil;1.113 + } else {1.114 + [self setTitle: NS_("Preferences")];1.115 + [self setDelegate: self];1.116 + NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier: @"LxdreamPrefsToolbar"];1.117 + [toolbar setDelegate: [[LxdreamPrefsToolbarDelegate alloc] init]];1.118 + [toolbar setDisplayMode: NSToolbarDisplayModeIconOnly];1.119 + [toolbar setSizeMode: NSToolbarSizeModeSmall];1.120 + [toolbar setSelectedItemIdentifier: @"Paths"];1.121 + [self setToolbar: toolbar];1.122 + [self setContentView: [self createPathsPane]];1.123 + return self;1.124 + }1.125 +}1.126 +- (void)windowWillClose: (NSNotification *)notice1.127 +{1.128 + [NSApp stopModal];1.129 +}1.130 +@end
.