📄 prefs_widgets.m
字号:
} 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_popup frame]; frame.origin.x = i_xPos - 1; frame.size.width = superFrame.size.width - frame.origin.x + 2; [o_popup setFrame:frame];}- (void)dealloc{ [o_popup release]; [super dealloc];}- (char *)stringValue{ NSString *newval = [o_popup titleOfSelectedItem]; char *returnval = NULL; int i_index; vlc_list_t *p_list; module_t *p_parser; 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]; if( [newval isEqualToString: o_description] ) { returnval = strdup(p_parser->psz_object_name); break; } } } 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]; if( [newval isEqualToString: o_description] ) { returnval = strdup(p_parser->psz_object_name); break; } } } while( p_config->i_type != CONFIG_HINT_END && p_config++ ); } } vlc_list_release( p_list ); return returnval;}@end@implementation IntegerConfigControl- (id) initWithItem: (module_config_t *)_p_item withView: (NSView *)o_parent_view{ NSRect mainFrame = [o_parent_view frame]; NSString *o_labelString, *o_tooltip, *o_textfieldString; mainFrame.size.height = 23; 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 ) { i_view_type = CONFIG_ITEM_INTEGER; o_tooltip = [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; /* 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 stepper */ ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19, 0, o_tooltip, -1600, 1600) [o_stepper setIntValue: p_item->i_value]; [o_stepper setAutoresizingMask:NSViewMaxXMargin ]; [self addSubview: o_stepper]; /* build the textfield */ if( p_item->psz_value ) o_textfieldString = [[VLCMain sharedInstance] localizedString: p_item->psz_value]; else o_textfieldString = [NSString stringWithString: @""]; ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52, 1, 49, o_tooltip, @"" ) [o_textfield setIntValue: p_item->i_value]; [o_textfield setDelegate: self]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(textfieldChanged:) name: NSControlTextDidChangeNotification object: o_textfield]; [o_textfield setAutoresizingMask:NSViewMaxXMargin ]; [self addSubview: o_textfield]; } return self;}- (void) alignWithXPosition:(int)i_xPos{ NSRect 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; [o_textfield setFrame:frame]; frame = [o_stepper frame]; frame.origin.x = i_xPos + [o_textfield frame].size.width + 5; [o_stepper setFrame:frame];}- (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)intValue{ return [o_textfield intValue];}@end@implementation IntegerListConfigControl- (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->i_value == p_item->pi_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];}- (int)intValue{ if( [o_combo indexOfSelectedItem] >= 0 ) return p_item->pi_list[[o_combo indexOfSelectedItem]]; else return [o_combo intValue];}@end@implementation IntegerListConfigControl (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 [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];}@end@implementation RangedIntegerConfigControl- (id) initWithItem: (module_config_t *)_p_item withView: (NSView *)o_parent_view{ NSRect mainFrame = [o_parent_view frame]; NSString *o_labelString, *o_tooltip; mainFrame.size.height = 50; 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_RANGED_INTEGER; /* 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_tooltip = [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2, 28, 49, o_tooltip, @"" ) [o_textfield setIntValue: p_item->i_value]; [o_textfield setAutoresizingMask:NSViewMaxXMargin ]; [o_textfield setDelegate: self]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(textfieldChanged:) name: NSControlTextDidChangeNotification object: o_textfield]; [self addSubview: o_textfield]; /* build the mintextfield */ ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" ) [o_textfield_min setIntValue: p_item->i_min]; [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ]; [o_textfield_min setAlignment:NSRightTextAlignment]; [self addSubview: o_textfield_min]; /* build the maxtextfield */ ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31, -30, @"8888" ) [o_textfield_max setIntValue: p_item->i_max]; [o_textfield_max setAutoresizingMask:NSViewMinXMargin ]; [self addSubview: o_textfield_max]; /* build the slider */ ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x + [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width - [o_textfield_max frame].size.width - [o_textfield_max frame].size.width - 14 - [o_textfield_min frame].origin.x, o_tooltip, p_item->i_min, p_item->i_max ) [o_slider setIntValue: p_item->i_value]; [o_slider setAutoresizingMask:NSViewWidthSizable ]; [o_slider setTarget: self]; [o_slider setAction: @selector(sliderChanged:)]; [o_slider se
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -