📄 prefs_widgets.m
字号:
/* add the label */ if( p_item->psz_text ) o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; else o_labelString = [NSString stringWithString:@""]; ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString ) [o_label setAutoresizingMask:NSViewNotSizable ]; [self addSubview: o_label]; /* build the textfield */ o_textfieldTooltip = [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext] toWidth: PREFS_WRAP]; if( p_item->psz_value ) o_textfieldString = [[VLCMain sharedInstance] localizedString: p_item->psz_value]; else o_textfieldString = [NSString stringWithString: @""]; ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2, 0, mainFrame.size.width - [o_label frame].size.width - 2, o_textfieldTooltip, o_textfieldString ) [o_textfield setAutoresizingMask:NSViewWidthSizable ]; [self addSubview: o_textfield]; } return self;}- (void) alignWithXPosition:(int)i_xPos{ NSRect frame; NSRect superFrame = [self frame]; frame = [o_label frame]; frame.origin.x = i_xPos - frame.size.width - 3; [o_label setFrame:frame]; frame = [o_textfield frame]; frame.origin.x = i_xPos + 2; frame.size.width = superFrame.size.width - frame.origin.x - 1; [o_textfield setFrame:frame];}- (void)dealloc{ [o_textfield release]; [super dealloc];}- (char *)stringValue{ return strdup( [[VLCMain sharedInstance] delocalizeString: [o_textfield stringValue]] );}@end@implementation StringListConfigControl- (id) initWithItem: (module_config_t *)_p_item withView: (NSView *)o_parent_view{ NSRect mainFrame = [o_parent_view frame]; NSString *o_labelString, *o_textfieldTooltip; mainFrame.size.height = 22; mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1; mainFrame.origin.x = LEFTMARGIN; mainFrame.origin.y = 0; if( [super initWithFrame: mainFrame item: _p_item] != nil ) { int i_index; i_view_type = CONFIG_ITEM_STRING_LIST; /* add the label */ if( p_item->psz_text ) o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; else o_labelString = [NSString stringWithString:@""]; ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString ) [o_label setAutoresizingMask:NSViewNotSizable ]; [self addSubview: o_label]; /* build the textfield */ o_textfieldTooltip = [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width, -2, 0, o_textfieldTooltip ) [o_combo setAutoresizingMask:NSViewWidthSizable ]; 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]; [self addSubview: o_combo]; } return self;}- (void) alignWithXPosition:(int)i_xPos{ NSRect frame; NSRect superFrame = [self frame]; frame = [o_label frame]; frame.origin.x = i_xPos - frame.size.width - 3; [o_label setFrame:frame]; frame = [o_combo frame]; frame.origin.x = i_xPos + 2; frame.size.width = superFrame.size.width - frame.origin.x + 2; [o_combo setFrame:frame];}- (void)dealloc{ [o_combo release]; [super dealloc];}- (char *)stringValue{ if( [o_combo indexOfSelectedItem] >= 0 ) return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] ); else return strdup( [[VLCMain sharedInstance] delocalizeString: [o_combo stringValue]] );}@end@implementation StringListConfigControl (NSComboBoxDataSource)- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox{ return p_item->i_list;}- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index{ if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] ) { return [[VLCMain sharedInstance] localizedString: p_item->ppsz_list_text[i_index]]; } else return [[VLCMain sharedInstance] localizedString: p_item->ppsz_list[i_index]];}@end@implementation FileConfigControl- (id) initWithItem: (module_config_t *)_p_item withView: (NSView *)o_parent_view{ NSRect mainFrame = [o_parent_view frame]; NSString *o_labelString, *o_buttonTooltip, *o_textfieldString; NSString *o_textfieldTooltip; mainFrame.size.height = 46; mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN; mainFrame.origin.x = LEFTMARGIN; mainFrame.origin.y = 0; if( [super initWithFrame: mainFrame item: _p_item] != nil ) { i_view_type = CONFIG_ITEM_FILE; /* is it a directory */ b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO; /* add the label */ if( p_item->psz_text ) o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; else o_labelString = [NSString stringWithString:@""]; ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString ) [o_label setAutoresizingMask:NSViewNotSizable ]; [self addSubview: o_label]; /* build the button */ o_buttonTooltip = [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_buttonTooltip, _NS("Browse...") ) [o_button setAutoresizingMask:NSViewMinXMargin ]; [self addSubview: o_button]; /* build the textfield */ o_textfieldTooltip = [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; if( p_item->psz_value ) o_textfieldString = [[VLCMain sharedInstance] localizedString: p_item->psz_value]; else o_textfieldString = [NSString stringWithString: @""]; ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width - 8 - [o_button frame].size.width, o_textfieldTooltip, o_textfieldString ) [o_textfield setAutoresizingMask:NSViewWidthSizable ]; [self addSubview: o_textfield]; } return self;}- (void) alignWithXPosition:(int)i_xPos{ ;}- (void)dealloc{ [o_textfield release]; [o_button release]; [super dealloc];}- (IBAction)openFileDialog: (id)sender{ NSOpenPanel *o_open_panel = [NSOpenPanel openPanel]; [o_open_panel setTitle: (b_directory)? _NS("Select a directory"):_NS("Select a file")]; [o_open_panel setPrompt: _NS("Select")]; [o_open_panel setAllowsMultipleSelection: NO]; [o_open_panel setCanChooseFiles: !b_directory]; [o_open_panel setCanChooseDirectories: b_directory]; [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{ if( [[o_textfield stringValue] length] != 0) return strdup( [[o_textfield stringValue] fileSystemRepresentation] ); else return NULL;}@end@implementation ModuleConfigControl- (id) initWithItem: (module_config_t *)_p_item withView: (NSView *)o_parent_view{ NSRect mainFrame = [o_parent_view frame]; NSString *o_labelString, *o_popupTooltip; mainFrame.size.height = 22; mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1; mainFrame.origin.x = LEFTMARGIN; mainFrame.origin.y = 0; if( [super initWithFrame: mainFrame item: _p_item] != nil ) { int i_index; vlc_list_t *p_list; module_t *p_parser; i_view_type = CONFIG_ITEM_MODULE; /* add the label */ if( p_item->psz_text ) o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; else o_labelString = [NSString stringWithString:@""]; ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString ) [o_label setAutoresizingMask:NSViewNotSizable ]; [self addSubview: o_label]; /* build the popup */ o_popupTooltip = [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width, -2, 0, o_popupTooltip ) [o_popup setAutoresizingMask:NSViewWidthSizable ]; [o_popup addItemWithTitle: _NS("Default")]; [[o_popup lastItem] setTag: -1]; [o_popup selectItem: [o_popup lastItem]]; /* build a list of available modules */ p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE ); for( i_index = 0; i_index < p_list->i_count; i_index++ ) { p_parser = (module_t *)p_list->p_values[i_index].p_object ; if( p_item->i_type == CONFIG_ITEM_MODULE ) { if( !strcmp( p_parser->psz_capability, p_item->psz_type ) ) { NSString *o_description = [[VLCMain sharedInstance] localizedString: p_parser->psz_longname]; [o_popup addItemWithTitle: o_description]; if( p_item->psz_value && !strcmp( p_item->psz_value, p_parser->psz_object_name ) ) [o_popup selectItem:[o_popup lastItem]]; } } else { module_config_t *p_config; if( !strcmp( p_parser->psz_object_name, "main" ) ) continue; p_config = p_parser->p_config; if( p_config ) do { /* Hack: required subcategory is stored in i_min */ if( p_config->i_type == CONFIG_SUBCATEGORY && p_config->i_value == p_item->i_min ) { NSString *o_description = [[VLCMain sharedInstance] localizedString: p_parser->psz_longname]; [o_popup addItemWithTitle: o_description]; if( p_item->psz_value && !strcmp(p_item->psz_value, p_parser->psz_object_name) ) [o_popup selectItem:[o_popup lastItem]]; } } while( p_config->i_type != CONFIG_HINT_END && p_config++ ); } } vlc_list_release( p_list ); [self addSubview: o_popup];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -