prefs_widgets.m
来自「VLC媒体播放程序」· M 代码 · 共 1,164 行 · 第 1/3 页
M
1,164 行
if( !strcmp( p_parser->psz_capability, p_item->psz_type ) ) { NSString *o_description = [NSApp localizedString: p_parser->psz_longname]; if( [newval isEqualToString: o_description] ) { returnval = strdup(p_parser->psz_object_name); break; } } } vlc_list_release( p_list ); return returnval;}@end@implementation StringConfigControl- (id)initWithFrame: (NSRect)frame item: (module_config_t *)p_item withObject: (vlc_object_t *)_p_this{ frame.size.height = 22; if( self = [super initWithFrame: frame item: p_item withObject: _p_this] ) { NSRect s_rc = frame; /* add the label */ o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; [o_label setDrawsBackground: NO]; [o_label setBordered: NO]; [o_label setEditable: NO]; [o_label setSelectable: NO]; if( p_item->psz_text ) [o_label setStringValue: [NSApp localizedString: p_item->psz_text]]; [o_label sizeToFit]; [[self contentView] addSubview: o_label]; [o_label setAutoresizingMask:NSViewMaxXMargin ]; /* build the textfield */ s_rc.origin.x = s_rc.size.width - 200 - OFFSET_RIGHT; s_rc.size.width = 200; o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; [o_textfield setAutoresizingMask:NSViewMinXMargin | NSViewWidthSizable ]; [o_textfield setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]]; [o_textfield setStringValue: [NSApp localizedString: p_item->psz_value]]; [[self contentView] addSubview: o_textfield]; } return self;}- (void)dealloc{ [o_textfield release]; [super dealloc];}- (char *)stringValue{ return strdup( [NSApp delocalizeString:[o_textfield stringValue]] );}@end@implementation StringListConfigControl- (id)initWithFrame: (NSRect)frame item: (module_config_t *)p_item withObject: (vlc_object_t *)_p_this{ frame.size.height = 20; if( self = [super initWithFrame: frame item: p_item withObject: _p_this] ) { NSRect s_rc = frame; int i_index; /* add the label */ o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; [o_label setDrawsBackground: NO]; [o_label setBordered: NO]; [o_label setEditable: NO]; [o_label setSelectable: NO]; if( p_item->psz_text ) [o_label setStringValue: [NSApp localizedString: p_item->psz_text]]; [o_label sizeToFit]; [[self contentView] addSubview: o_label]; [o_label setAutoresizingMask:NSViewMaxXMargin ]; /* build the textfield */ s_rc.origin.x = s_rc.size.width - 200 - OFFSET_RIGHT; s_rc.size.width = 200; o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; [o_combo setAutoresizingMask:NSViewMinXMargin | NSViewWidthSizable ]; [o_combo setUsesDataSource:TRUE]; [o_combo setDataSource:self]; [o_combo setNumberOfVisibleItems:10]; for( i_index = 0; i_index < p_item->i_list; i_index++ ) { if( p_item->psz_value && !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) ) { [o_combo selectItemAtIndex: i_index]; } } [o_combo setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]]; [[self contentView] addSubview: o_combo]; } return self;}- (void)dealloc{ [o_combo release]; [super dealloc];}- (char *)stringValue{ module_config_t *p_item; p_item = config_FindConfig( p_this, psz_name ); if( [o_combo indexOfSelectedItem] >= 0 ) return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] ); else return strdup( [NSApp delocalizeString: [o_combo stringValue]] );}@end@implementation StringListConfigControl (NSComboBoxDataSource)- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox{ module_config_t *p_item; p_item = config_FindConfig( p_this, psz_name ); return p_item->i_list;}- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index{ module_config_t *p_item; p_item = config_FindConfig( p_this, psz_name ); if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] ) { return [NSApp localizedString: p_item->ppsz_list_text[i_index]]; } else return [NSApp localizedString: p_item->ppsz_list[i_index]];}@end@implementation FileConfigControl- (id)initWithFrame: (NSRect)frame item: (module_config_t *)p_item withObject: (vlc_object_t *)_p_this{ frame.size.height = 49; if( self = [super initWithFrame: frame item: p_item withObject: _p_this] ) { NSRect s_rc = frame; s_rc.origin.y = 29; s_rc.size.height = 20; /* is it a directory */ b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO; /* add the label */ o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; [o_label setDrawsBackground: NO]; [o_label setBordered: NO]; [o_label setEditable: NO]; [o_label setSelectable: NO]; if( p_item->psz_text ) [o_label setStringValue: [NSApp localizedString: p_item->psz_text]]; [o_label sizeToFit]; [o_label setAutoresizingMask:NSViewMaxXMargin ]; [[self contentView] addSubview: o_label]; /* build the button */ s_rc.origin.y = s_rc.origin.x = 0; s_rc.size.height = 22; o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; [o_button setButtonType: NSMomentaryPushInButton]; [o_button setBezelStyle: NSRoundedBezelStyle]; [o_button setTitle: _NS("Browse...")]; [o_button sizeToFit]; [o_button setAutoresizingMask:NSViewMinXMargin]; [o_button setFrameOrigin: NSMakePoint( s_rc.size.width - [o_button frame].size.width - OFFSET_RIGHT, s_rc.origin.y)]; [o_button setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]]; [o_button setTarget: self]; [o_button setAction: @selector(openFileDialog:)]; s_rc.size.height = 22; s_rc.size.width = s_rc.size.width - OFFSET_BETWEEN - [o_button frame].size.width - OFFSET_RIGHT; o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; [o_textfield setStringValue: [NSApp localizedString: p_item->psz_value]]; [o_textfield setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]]; [o_textfield setAutoresizingMask:NSViewWidthSizable]; [[self contentView] addSubview: o_textfield]; [[self contentView] addSubview: o_button]; } return self;}- (void)dealloc{ [o_textfield release]; [o_button release]; [super dealloc];}- (IBAction)openFileDialog: (id)sender{ NSOpenPanel *o_open_panel = [NSOpenPanel openPanel]; [o_open_panel setTitle: _NS("Select a file or directory")]; [o_open_panel setPrompt: _NS("Select")]; [o_open_panel setAllowsMultipleSelection: NO]; [o_open_panel setCanChooseFiles: YES]; [o_open_panel setCanChooseDirectories: b_advanced]; [o_open_panel beginSheetForDirectory:nil file:nil types:nil modalForWindow:[sender window] modalDelegate: self didEndSelector: @selector(pathChosenInPanel: withReturn: contextInfo:) contextInfo: nil];}- (void)pathChosenInPanel:(NSOpenPanel *)o_sheet withReturn:(int)i_return_code contextInfo:(void *)o_context_info{ if( i_return_code == NSOKButton ) { NSString *o_path = [[o_sheet filenames] objectAtIndex: 0]; [o_textfield setStringValue: o_path]; }}- (char *)stringValue{ return strdup( [NSApp delocalizeString: [o_textfield stringValue]] );}@end@implementation IntegerConfigControl- (id)initWithFrame: (NSRect)frame item: (module_config_t *)p_item withObject: (vlc_object_t *)_p_this{ frame.size.height = 22; if( self = [super initWithFrame: frame item: p_item withObject: _p_this] ) { NSRect s_rc = frame; /* add the label */ o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; [o_label setDrawsBackground: NO]; [o_label setBordered: NO]; [o_label setEditable: NO]; [o_label setSelectable: NO]; if( p_item->psz_text ) [o_label setStringValue: [NSApp localizedString: p_item->psz_text]]; [o_label sizeToFit]; [[self contentView] addSubview: o_label]; [o_label setAutoresizingMask:NSViewMaxXMargin ]; /* build the stepper */ s_rc.origin.x = s_rc.size.width - 13 - OFFSET_RIGHT; o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; [o_stepper sizeToFit]; [o_stepper setAutoresizingMask:NSViewMinXMargin]; [o_stepper setMaxValue: 1600]; [o_stepper setMinValue: -1600]; [o_stepper setIntValue: p_item->i_value]; [o_stepper setTarget: self]; [o_stepper setAction: @selector(stepperChanged:)]; [o_stepper sendActionOn:NSLeftMouseUpMask|NSLeftMouseDownMask|NSLeftMouseDraggedMask]; [o_stepper setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]]; [[self contentView] addSubview: o_stepper]; /* build the textfield */ s_rc.origin.x = s_rc.size.width - 60 - OFFSET_BETWEEN - 13 - OFFSET_RIGHT; s_rc.size.width = 60; o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; [o_textfield setAutoresizingMask:NSViewMinXMargin | NSViewWidthSizable ]; [o_textfield setIntValue: p_item->i_value]; [o_textfield setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]]; [o_textfield setDelegate: self]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(textfieldChanged:) name: NSControlTextDidChangeNotification object: o_textfield]; [[self contentView] addSubview: o_textfield]; } return self;}- (void)dealloc{ [o_stepper release]; [o_textfield release]; [super dealloc];}- (IBAction)stepperChanged:(id)sender{ [o_textfield setIntValue: [o_stepper intValue]];}- (void)textfieldChanged:(NSNotification *)o_notification{ [o_stepper setIntValue: [o_textfield intValue]];}- (int)getIntValue{ return [o_stepper intValue];}@end@implementation IntegerListConfigControl- (id)initWithFrame: (NSRect)frame item: (module_config_t *)p_item withObject: (vlc_object_t *)_p_this{ frame.size.height = 20; if( self = [super initWithFrame: frame item: p_item withObject: _p_this] ) { NSRect s_rc = frame; int i_index; /* add the label */ o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; [o_label setDrawsBackground: NO]; [o_label setBordered: NO]; [o_label setEditable: NO]; [o_label setSelectable: NO]; if( p_item->psz_text ) [o_label setStringValue: [NSApp localizedString: p_item->psz_text]]; [o_label sizeToFit]; [[self contentView] addSubview: o_label]; [o_label setAutoresizingMask:NSViewMaxXMargin ]; /* build the textfield */ s_rc.origin.x = s_rc.size.width - 200 - OFFSET_RIGHT; s_rc.size.width = 200; o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; [o_combo setAutoresizingMask:NSViewMinXMargin | NSViewWidthSizable ]; [o_combo setUsesDataSource:TRUE]; [o_combo setDataSource:self]; [o_combo setNumberOfVisibleItems:10]; for( i_index = 0; i_index < p_item->i_list; i_index++ )
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?