#include <sys/param.h> /* for MAXPATHLEN */
#include <string.h>
+#include <vlc/vlc.h>
+#include <vlc_config_cat.h>
+
#include "intf.h"
#include "prefs.h"
+#include "prefs_widgets.h"
#include "vlc_keys.h"
/*****************************************************************************
if( i_return == NSAlertAlternateReturn )
{
config_ResetAll( p_intf );
- [self showViewForID: [[o_tree itemAtRow:[o_tree selectedRow]] getObjectID]
+ [[o_tree itemAtRow:[o_tree selectedRow]] showView:o_prefs_view];
+/* [self showViewForID: [[o_tree itemAtRow:[o_tree selectedRow]] getObjectID]
andName: [[o_tree itemAtRow:[o_tree selectedRow]] getName]];
+*/
}
}
b_advanced = !b_advanced;
[o_advanced_ckb setState: b_advanced];
/* refresh the view of the current treeitem */
- /* [self showViewForID: [[o_tree itemAtRow:[o_tree selectedRow]] getObjectID]
- andName: [[o_tree itemAtRow:[o_tree selectedRow]] getName]]; */
+ [[o_tree itemAtRow:[o_tree selectedRow]] showView:o_prefs_view];
+/* [self showViewForID: [[o_tree itemAtRow:[o_tree selectedRow]] getObjectID]
+ andName: [[o_tree itemAtRow:[o_tree selectedRow]] getName]];
+*/
}
- (void)loadConfigTree
/* update the document view to the view of the selected tree item */
- (void)outlineViewSelectionDidChange:(NSNotification *)o_notification
{
- /*
- [self showViewForID: [[o_tree itemAtRow:[o_tree selectedRow]] getObjectID]
- andName: [[o_tree itemAtRow:[o_tree selectedRow]] getName]];*/
+ [[o_tree itemAtRow:[o_tree selectedRow]] showView: o_prefs_view];
}
@end
#define IsALeafNode ((id)-1)
-- (id)initWithName: (NSString *)o_item_name ID: (int)i_id parent:(VLCTreeItem *)o_parent_item
+- (id)initWithName: (NSString *)o_item_name ID: (int)i_id parent:(VLCTreeItem *)o_parent_item children:(NSMutableArray *)o_children_array whithCategory: (int) i_category
{
self = [super init];
o_name = [o_item_name copy];
i_object_id = i_id;
o_parent = o_parent_item;
+ o_children = o_children_array;
+ i_object_category = i_category;
}
return( self );
}
+ (VLCTreeItem *)rootItem {
- if (o_root_item == nil) o_root_item = [[VLCTreeItem alloc] initWithName:@"main" ID: 0 parent:nil];
+ if (o_root_item == nil) o_root_item = [[VLCTreeItem alloc] initWithName:@"main" ID: 0 parent:nil children:[[NSMutableArray alloc] initWithCapacity:10] whithCategory: -1];
return o_root_item;
}
* Loads children incrementally */
- (NSArray *)children
{
- if( o_children == NULL )
+ if( o_children == IsALeafNode )
+ return o_children;
+ if( [ o_children count] == 0 )
{
intf_thread_t *p_intf = VLCIntf;
vlc_list_t *p_list;
module_t *p_module = NULL;
module_config_t *p_item;
- int i_index,j;
+ int i_index;
/* List the modules */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
if( i_index < p_list->i_count )
{
/* We found the main module */
-
/* Enumerate config categories and store a reference so we can
* generate their config panel them when it is asked by the user. */
+ VLCTreeItem *p_last_category = NULL;
p_item = p_module->p_config;
o_children = [[NSMutableArray alloc] initWithCapacity:10];
-
if( p_item ) do
{
NSString *o_child_name;
-
switch( p_item->i_type )
{
- case CONFIG_HINT_CATEGORY:
- o_child_name = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
- [o_children addObject:[[VLCTreeItem alloc] initWithName: o_child_name
- ID: p_module->i_object_id parent:self]];
+ case CONFIG_CATEGORY:
+ o_child_name = [[VLCMain sharedInstance] localizedString: config_CategoryNameGet(p_item->i_value ) ];
+ p_last_category = [VLCTreeItem alloc];
+ [o_children addObject:[p_last_category initWithName: o_child_name
+ ID: p_item->i_value parent:self children:[[NSMutableArray alloc] initWithCapacity:10] whithCategory: p_item - p_module->p_config]];
+ break;
+ case CONFIG_SUBCATEGORY:
+ o_child_name = [[VLCMain sharedInstance] localizedString: config_CategoryNameGet(p_item->i_value ) ];
+ [p_last_category->o_children addObject:[[VLCTreeItem alloc] initWithName: o_child_name
+ ID: p_item->i_value parent:p_last_category children:[[NSMutableArray alloc] initWithCapacity:10] whithCategory: p_item - p_module->p_config]];
+ break;
+ default:
break;
}
- }
- while( p_item->i_type != CONFIG_HINT_END && p_item++ );
-
- /* Add the modules item */
- [o_children addObject:[[VLCTreeItem alloc] initWithName: _NS("Modules")
- ID: 0 parent:self]];
+ } while( p_item->i_type != CONFIG_HINT_END && p_item++ );
}
- else
- {
- o_children = IsALeafNode;
- }
- }
- else if( [[self getName] isEqualToString: _NS("Modules")] )
- {
+
+ /* Build a tree of the plugins */
/* Add the capabilities */
- o_children = [[NSMutableArray alloc] initWithCapacity:10];
for( i_index = 0; i_index < p_list->i_count; i_index++ )
{
p_module = (module_t *)p_list->p_values[i_index].p_object;
-
+
/* Exclude the main module */
if( !strcmp( p_module->psz_object_name, "main" ) )
continue;
-
- /* Exclude empty modules */
- p_item = p_module->p_config;
+
+ /* Exclude empty plugins (submodules don't have config options, they
+ * are stored in the parent module) */
+ if( p_module->b_submodule )
+ continue;
+ else
+ p_item = p_module->p_config;
+
if( !p_item ) continue;
+ int i_category = -1;
+ int i_subcategory = -1;
+ int i_options = 0;
do
{
+ if( p_item->i_type == CONFIG_CATEGORY )
+ {
+ i_category = p_item->i_value;
+ }
+ else if( p_item->i_type == CONFIG_SUBCATEGORY )
+ {
+ i_subcategory = p_item->i_value;
+ }
if( p_item->i_type & CONFIG_ITEM )
- break;
- }
- while( p_item->i_type != CONFIG_HINT_END && p_item++ );
- if( p_item->i_type == CONFIG_HINT_END ) continue;
-
- /* Create the capability tree if it doesn't already exist */
- NSString *o_capability;
- o_capability = [[VLCMain sharedInstance] localizedString: p_module->psz_capability];
- if( !p_module->psz_capability || !*p_module->psz_capability )
- {
- /* Empty capability ? Let's look at the submodules */
- module_t * p_submodule;
- for( j = 0; j < p_module->i_children; j++ )
+ i_options ++;
+ if( i_options > 0 && i_category >= 0 && i_subcategory >= 0 )
{
- p_submodule = (module_t*)p_module->pp_children[ j ];
- if( p_submodule->psz_capability && *p_submodule->psz_capability )
- {
- o_capability = [[VLCMain sharedInstance] localizedString: p_submodule->psz_capability];
- BOOL b_found = FALSE;
- for( j = 0; j < (int)[o_children count]; j++ )
- {
- if( [[[o_children objectAtIndex:j] getName] isEqualToString: o_capability] )
- {
- b_found = TRUE;
- break;
- }
- }
- if( !b_found )
- {
- [o_children addObject:[[VLCTreeItem alloc] initWithName: o_capability
- ID: 0 parent:self]];
- }
- }
+ break;
}
- }
+ } while( p_item->i_type != CONFIG_HINT_END && p_item++ );
+ if( !i_options ) continue;
- BOOL b_found = FALSE;
- for( j = 0; j < (int)[o_children count]; j++ )
+ /* Find the right category item */
+
+ long cookie;
+ vlc_bool_t b_found = VLC_FALSE;
+ int i;
+ VLCTreeItem* p_category_item, * p_subcategory_item;
+ for (i = 0 ; i < [o_children count] ; i++)
{
- if( [[[o_children objectAtIndex:j] getName] isEqualToString: o_capability] )
+ p_category_item = [o_children objectAtIndex: i];
+ if( p_category_item->i_object_id == i_category )
{
- b_found = TRUE;
+ b_found = VLC_TRUE;
break;
}
}
- if( !b_found )
- {
- [o_children addObject:[[VLCTreeItem alloc] initWithName: o_capability
- ID: 0 parent:self]];
- }
- }
- }
- else if( [[o_parent getName] isEqualToString: _NS("Modules")] )
- {
- /* Now add the modules */
- o_children = [[NSMutableArray alloc] initWithCapacity:10];
- for( i_index = 0; i_index < p_list->i_count; i_index++ )
- {
- p_module = (module_t *)p_list->p_values[i_index].p_object;
-
- /* Exclude the main module */
- if( !strcmp( p_module->psz_object_name, "main" ) )
- continue;
-
- /* Exclude empty modules */
- p_item = p_module->p_config;
- if( !p_item ) continue;
- do
- {
- if( p_item->i_type & CONFIG_ITEM )
- break;
- }
- while( p_item->i_type != CONFIG_HINT_END && p_item++ );
- if( p_item->i_type == CONFIG_HINT_END ) continue;
-
- /* Check the capability */
- NSString *o_capability;
- o_capability = [[VLCMain sharedInstance] localizedString: p_module->psz_capability];
- if( !p_module->psz_capability || !*p_module->psz_capability )
+ if( !b_found ) continue;
+
+ /* Find subcategory item */
+ b_found = VLC_FALSE;
+ cookie = -1;
+ for (i = 0 ; i < [p_category_item->o_children count] ; i++)
{
- /* Empty capability ? Let's look at the submodules */
- module_t * p_submodule;
- for( j = 0; j < p_module->i_children; j++ )
+ p_subcategory_item = [p_category_item->o_children objectAtIndex: i];
+ if( p_subcategory_item->i_object_id == i_subcategory )
{
- p_submodule = (module_t*)p_module->pp_children[ j ];
- if( p_submodule->psz_capability && *p_submodule->psz_capability )
- {
- o_capability = [[VLCMain sharedInstance] localizedString: p_submodule->psz_capability];
- if( [o_capability isEqualToString: [self getName]] )
- {
- [o_children addObject:[[VLCTreeItem alloc] initWithName:
- [[VLCMain sharedInstance] localizedString: p_module->psz_object_name ]
- ID: p_module->i_object_id parent:self]];
- }
- }
+ b_found = VLC_TRUE;
+ break;
}
}
- else if( [o_capability isEqualToString: [self getName]] )
- {
- [o_children addObject:[[VLCTreeItem alloc] initWithName:
- [[VLCMain sharedInstance] localizedString: p_module->psz_object_name ]
- ID: p_module->i_object_id parent:self]];
- }
+ if( !b_found )
+ p_subcategory_item = p_category_item;
+
+ [p_subcategory_item->o_children addObject:[[VLCTreeItem alloc] initWithName:
+ [[VLCMain sharedInstance] localizedString: p_module->psz_object_name ]
+ ID: p_module->i_object_id parent:p_subcategory_item children:IsALeafNode whithCategory: -1]];
+
}
}
- else
- {
- /* all the other stuff are leafs */
- o_children = IsALeafNode;
- }
vlc_list_release( p_list );
}
return o_children;
return( NO );
}
+- (NSView *)showView:(NSScrollView *)o_prefs_view
+{
+fprintf( stderr, "[%s] showView\n", [o_name UTF8String] );
+ vlc_list_t *p_list;
+ intf_thread_t *p_intf = VLCIntf;
+ module_t *p_parser;
+ module_config_t *p_item, *p_first_item;
+ NSView *o_view;
+ NSRect s_rc; /* rect */
+ NSTextField *o_text_field; /* input field / label */
+ NSRect s_vrc; /* view rect */
+ NSString *o_module_name;
+ int i_pos, i_module_tag;
+ NSPoint o_pos;
+ vlc_bool_t b_advanced = VLC_TRUE;
+ s_vrc = [[o_prefs_view contentView] bounds];
+ s_vrc.size.height -= 4;
+
+ o_view = [[NSView alloc] initWithFrame: s_vrc];
+
+ p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
+
+ /* Get a pointer to the module */
+ if( i_object_category == -1 )
+ {
+ p_parser = (module_t *) vlc_object_get( p_intf, i_object_id );
+ if( !p_parser || p_parser->i_object_type != VLC_OBJECT_MODULE )
+ {
+ /* 0OOoo something went really bad */
+ vlc_list_release( p_list );
+ return o_view;
+ }
+ o_module_name = [NSString stringWithUTF8String: p_parser->psz_object_name];
+fprintf( stderr, "showView: going to show [%d] %s\n", i_object_id, p_parser->psz_object_name );
+ p_first_item = p_item = p_parser->p_config;
+ }
+ else
+ {
+ int i_index;
+ if( !p_list ) return o_view;
+
+ /*
+ * Find the main module
+ */
+ 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( !strcmp( p_parser->psz_object_name, "main" ) )
+ break;
+ }
+ if( p_parser == NULL )
+ {
+ msg_Err( p_intf, "could not find the main module in our preferences" );
+ return o_view;
+ }
+ p_first_item = p_item = (p_parser->p_config + i_object_category);
+ }
+ o_view = nil;
+ i_module_tag = 3;
+
+/* These defines should come from "Apple Human Interface Guidelines" */
+#define X_ORIGIN 20
+#define Y_ORIGIN 17
+#define Y_INTER 8
+ /* Init View */
+ s_vrc = [[o_prefs_view contentView] bounds]; s_vrc.size.height -= 4;
+ o_view = [[VLCFlippedView alloc] initWithFrame: s_vrc];
+ [o_view setAutoresizingMask: NSViewWidthSizable];
+
+ o_pos.x = X_ORIGIN;
+ o_pos.y = Y_ORIGIN;
+ BOOL b_right_cat = TRUE;
+
+ if( p_item ) do ; while ( ( p_item->i_type == CONFIG_CATEGORY || p_item->i_type == CONFIG_SUBCATEGORY ) && p_item++ );
+
+ if( p_item ) do
+ {
+fprintf( stderr, "Category: %d\n", p_item->i_type );
+ if( p_item->i_type == CONFIG_HINT_CATEGORY )
+ {
+ if( !strcmp( p_parser->psz_object_name, "main" ) &&
+ [o_name isEqualToString: [[VLCMain sharedInstance] localizedString: p_item->psz_text]] )
+ b_right_cat = TRUE;
+ else if( strcmp( p_parser->psz_object_name, "main" ) )
+ b_right_cat = TRUE;
+ else b_right_cat = FALSE;
+ }
+ else if( p_item->i_type == CONFIG_HINT_END && !strcmp( p_parser->psz_object_name, "main" ) )
+ b_right_cat = FALSE;
+
+ if( (p_item->b_advanced && !b_advanced ) || !b_right_cat )
+ {
+ continue;
+ }
+fprintf( stderr, "Creating view for: %s\n", p_item->psz_name );
+ VLCConfigControl *o_control = nil;
+ switch( p_item->i_type )
+ {
+ case CONFIG_ITEM_STRING:
+ {
+ if( !p_item->i_list )
+ o_control = [StringConfigControl newControl:p_item
+ withView:o_view withObject:p_intf offset: o_pos];
+ else
+ o_control = [StringListConfigControl newControl:p_item
+ withView:o_view withObject:p_intf offset: o_pos];
+ }
+ break;
+ case CONFIG_ITEM_FILE:
+ case CONFIG_ITEM_DIRECTORY:
+ {
+ o_control = [FileConfigControl newControl: p_item withView: o_view
+ withObject: p_intf offset: o_pos];
+ }
+ break;
+ case CONFIG_ITEM_INTEGER:
+ {
+ if( !p_item->i_list )
+ o_control = [IntegerConfigControl newControl:p_item
+ withView:o_view withObject:p_intf offset: o_pos];
+
+ else if( p_item->i_min != 0 || p_item->i_max != 0 )
+ o_control = [RangedIntegerConfigControl newControl:p_item
+ withView:o_view withObject:p_intf offset: o_pos];
+ else
+ o_control = [IntegerListConfigControl newControl:p_item
+ withView:o_view withObject:p_intf offset: o_pos];
+ }
+ break;
+ case CONFIG_ITEM_KEY:
+ {
+ o_control = [KeyConfigControl newControl:p_item withView:o_view withObject:p_intf offset: o_pos];
+ }
+ break;
+ }
+ if( o_control != nil )
+ {
+ [o_view addSubview: o_control];
+ o_pos.y += [o_control frame].size.height + Y_INTER;
+ }
+ #undef Y_ORIGIN
+ #undef X_ORIGIN
+ }
+ while( p_item->i_type != CONFIG_HINT_END && p_item->i_type != CONFIG_CATEGORY && p_item->i_type != CONFIG_SUBCATEGORY && p_item++ );
+
+ vlc_object_release( p_parser );
+ vlc_list_release( p_list );
+
+ [o_prefs_view setDocumentView: o_view];
+ [o_prefs_view setNeedsDisplay: TRUE];
+ return o_view;
+}
+
@end
#define PREFS_WRAP 300
#define OFFSET_RIGHT 20
-#define OFFSET_BETWEEN 10
+#define OFFSET_BETWEEN 2
@implementation VLCConfigControl
}
- (id)initWithFrame: (NSRect)frame
- item: (module_config_t *)p_item
+ item: (module_config_t *)_p_item
withObject: (vlc_object_t *)_p_this
{
self = [super initWithFrame: frame];
if( self != nil )
{
p_this = _p_this;
+ p_item = _p_item;
o_label = NULL;
psz_name = strdup( p_item->psz_name );
i_type = p_item->i_type;
}
-+ (VLCConfigControl *)newControl: (module_config_t *)p_item withView: (NSView *)o_parent_view withObject: (vlc_object_t *)_p_this
++ (VLCConfigControl *)newControl: (module_config_t *)_p_item withView: (NSView *)o_parent_view withObject: (vlc_object_t *)_p_this offset:(NSPoint) offset
{
VLCConfigControl *p_control = NULL;
- NSRect frame = [o_parent_view bounds];
-
- switch( p_item->i_type )
+ NSRect frame = [o_parent_view frame];
+/*FIXME: Why do we need to divide by two ??? */
+ frame.origin.x=offset.x;
+ frame.origin.y=offset.y;
+ frame.size.width-=OFFSET_RIGHT;
+ switch( _p_item->i_type )
{
+#if 0
case CONFIG_ITEM_MODULE:
- p_control = [[ModuleConfigControl alloc] initWithFrame: frame item: p_item withObject: _p_this ];
+ p_control = [[ModuleConfigControl alloc] initWithFrame: frame item: _p_item withObject: _p_this ];
break;
-
+#endif
case CONFIG_ITEM_STRING:
- if( !p_item->i_list )
+ if( !_p_item->i_list )
{
- p_control = [[StringConfigControl alloc] initWithFrame: frame item: p_item withObject: _p_this ];
+ p_control = [[StringConfigControl alloc] initWithFrame: frame item: _p_item withObject: _p_this ];
}
else
{
- p_control = [[StringListConfigControl alloc] initWithFrame: frame item: p_item withObject: _p_this ];
+ p_control = [[StringListConfigControl alloc] initWithFrame: frame item: _p_item withObject: _p_this ];
}
break;
-
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY:
- p_control = [[FileConfigControl alloc] initWithFrame: frame item: p_item withObject: _p_this ];
+ p_control = [[FileConfigControl alloc] initWithFrame: frame item: _p_item withObject: _p_this ];
break;
-
case CONFIG_ITEM_INTEGER:
- if( p_item->i_list )
+ if( _p_item->i_list )
{
- p_control = [[IntegerListConfigControl alloc] initWithFrame: frame item: p_item withObject: _p_this ];
+ p_control = [[IntegerListConfigControl alloc] initWithFrame: frame item: _p_item withObject: _p_this ];
}
- else if( p_item->i_min != 0 || p_item->i_max != 0 )
+ else if( _p_item->i_min != 0 || _p_item->i_max != 0 )
{
- p_control = [[RangedIntegerConfigControl alloc] initWithFrame: frame item: p_item withObject: _p_this ];
+ p_control = [[RangedIntegerConfigControl alloc] initWithFrame: frame item: _p_item withObject: _p_this ];
}
else
{
- p_control = [[IntegerConfigControl alloc] initWithFrame: frame item: p_item withObject: _p_this ];
+ p_control = [[IntegerConfigControl alloc] initWithFrame: frame item: _p_item withObject: _p_this ];
}
break;
-
case CONFIG_ITEM_KEY:
- p_control = [[KeyConfigControl alloc] initWithFrame: frame item: p_item withObject: _p_this ];
+ p_control = [[KeyConfigControl alloc] initWithFrame: frame item: _p_item withObject: _p_this ];
break;
-
+#if 0
case CONFIG_ITEM_FLOAT:
- if( p_item->f_min != 0 || p_item->f_max != 0 )
+ if( _p_item->f_min != 0 || _p_item->f_max != 0 )
{
- p_control = [[RangedFloatConfigControl alloc] initWithFrame: frame item: p_item withObject: _p_this ];
+ p_control = [[RangedFloatConfigControl alloc] initWithFrame: frame item: _p_item withObject: _p_this ];
}
else
{
- p_control = [[FloatConfigControl alloc] initWithFrame: frame item: p_item withObject: _p_this ];
+ p_control = [[FloatConfigControl alloc] initWithFrame: frame item: _p_item withObject: _p_this ];
}
break;
case CONFIG_ITEM_BOOL:
- p_control = [[BoolConfigControl alloc] initWithFrame: frame item: p_item withObject: _p_this ];
+ p_control = [[BoolConfigControl alloc] initWithFrame: frame item: _p_item withObject: _p_this ];
break;
-
+#endif
default:
break;
}
- (NSString *)getName
{
- return [NSApp localizedString: psz_name];
+ return [[VLCMain sharedInstance] localizedString: psz_name];
}
- (int)getType
@end
-
@implementation KeyConfigControl
- (id)initWithFrame: (NSRect)frame
- item: (module_config_t *)p_item
+ item: (module_config_t *)_p_item
withObject: (vlc_object_t *)_p_this
{
frame.size.height = 80;
- if( self = [super initWithFrame: frame item: p_item
- withObject: _p_this] )
+ if( ( self = [super initWithFrame: frame item: _p_item
+ withObject: _p_this] ) )
{
NSRect s_rc = frame;
unsigned int i;
NSButtonCell *o_current_cell = [o_cells objectAtIndex:i];
[o_current_cell setButtonType: NSSwitchButton];
[o_current_cell setControlSize: NSSmallControlSize];
- [o_matrix setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext] toWidth: PREFS_WRAP] forCell: o_current_cell];
+ [o_matrix setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext] toWidth: PREFS_WRAP] forCell: o_current_cell];
switch( i )
{
}
[o_matrix sizeToCells];
[o_matrix setAutoresizingMask:NSViewMaxXMargin ];
- [[self contentView] addSubview: o_matrix];
+ [self addSubview: o_matrix];
/* add the combo box */
s_rc.origin.x += [o_matrix frame].size.width + OFFSET_BETWEEN;
o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain];
[o_combo setAutoresizingMask:NSViewMaxXMargin ];
- [o_combo setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext] toWidth: PREFS_WRAP]];
+ [o_combo setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext] toWidth: PREFS_WRAP]];
for( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++ )
{
if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
- [o_combo addItemWithObjectValue: [NSApp localizedString:vlc_keys[i].psz_key_string]];
+ [o_combo addItemWithObjectValue: [[VLCMain sharedInstance] localizedString:vlc_keys[i].psz_key_string]];
}
- [o_combo setStringValue: [NSApp localizedString:KeyToString(( ((unsigned int)p_item->i_value) & ~KEY_MODIFIER ))]];
- [[self contentView] addSubview: o_combo];
+ [o_combo setStringValue: [[VLCMain sharedInstance] localizedString:KeyToString(( ((unsigned int)p_item->i_value) & ~KEY_MODIFIER ))]];
+ [self addSubview: o_combo];
/* add the label */
s_rc.origin.y += 50;
[o_label setEditable: NO];
[o_label setSelectable: NO];
if ( p_item->psz_text )
- [o_label setStringValue: [NSApp localizedString: p_item->psz_text]];
+ [o_label setStringValue: [[VLCMain sharedInstance] localizedString: p_item->psz_text]];
[o_label sizeToFit];
- [[self contentView] addSubview: o_label];
+ [self addSubview: o_label];
[o_label setAutoresizingMask:NSViewMaxXMargin ];
}
return self;
@end
+#if 0
@implementation ModuleConfigControl
[o_label setEditable: NO];
[o_label setSelectable: NO];
if ( p_item->psz_text )
- [o_label setStringValue: [NSApp localizedString: p_item->psz_text]];
+ [o_label setStringValue: [[VLCMain sharedInstance] localizedString: p_item->psz_text]];
[o_label sizeToFit];
- [[self contentView] addSubview: o_label];
+ [self addSubview: o_label];
[o_label setAutoresizingMask:NSViewMaxXMargin ];
/* build the popup */
s_rc.size.width = 200;
o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain];
- [[self contentView] addSubview: o_popup];
+ [self addSubview: o_popup];
[o_popup setAutoresizingMask:NSViewMinXMargin ];
- [o_popup setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ [o_popup setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
[o_popup addItemWithTitle: _NS("Default")];
[[o_popup lastItem] setTag: -1];
[o_popup selectItem: [o_popup lastItem]];
}
@end
-
+#endif
@implementation StringConfigControl
- (id)initWithFrame: (NSRect)frame
- item: (module_config_t *)p_item
+ 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] )
+ if( ( self = [super initWithFrame: frame item: _p_item
+ withObject: _p_this] ) )
{
NSRect s_rc = frame;
-
+ s_rc.size.height = 17;
+ s_rc.origin.x = 0;
+ s_rc.origin.y = 3;
/* add the label */
o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain];
[o_label setDrawsBackground: 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 setStringValue: [[VLCMain sharedInstance] localizedString: p_item->psz_text]];
[o_label sizeToFit];
- [[self contentView] addSubview: o_label];
+ [self addSubview: o_label];
[o_label setAutoresizingMask:NSViewMaxXMargin ];
/* build the textfield */
s_rc.origin.x = s_rc.size.width - 200 - OFFSET_RIGHT;
+ s_rc.origin.y = 0;
+ s_rc.size.height = 22;
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];
+ [o_textfield setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ if( p_item->psz_value )
+ [o_textfield setStringValue: [[VLCMain sharedInstance] localizedString: p_item->psz_value]];
+ [self addSubview: o_textfield];
}
return self;
}
@implementation StringListConfigControl
- (id)initWithFrame: (NSRect)frame
- item: (module_config_t *)p_item
+ 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] )
+ frame.size.height = 24;
+ if( ( self = [super initWithFrame: frame item: _p_item
+ withObject: _p_this] ) )
{
NSRect s_rc = frame;
int i_index;
+ s_rc.size.height = 17;
+ s_rc.origin.x = 0;
+ s_rc.origin.y = 5;
/* add the label */
o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain];
[o_label setEditable: NO];
[o_label setSelectable: NO];
if( p_item->psz_text )
- [o_label setStringValue: [NSApp localizedString: p_item->psz_text]];
+ [o_label setStringValue: [[VLCMain sharedInstance] localizedString: p_item->psz_text]];
[o_label sizeToFit];
- [[self contentView] addSubview: o_label];
+ [self addSubview: o_label];
[o_label setAutoresizingMask:NSViewMaxXMargin ];
/* build the textfield */
s_rc.origin.x = s_rc.size.width - 200 - OFFSET_RIGHT;
+ s_rc.origin.y = 0;
+ s_rc.size.height = 26;
s_rc.size.width = 200;
o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain];
[o_combo setUsesDataSource:TRUE];
[o_combo setDataSource:self];
[o_combo setNumberOfVisibleItems:10];
+ [o_combo setCompletes:YES];
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 setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
- [[self contentView] addSubview: o_combo];
+ [o_combo setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ [self addSubview: o_combo];
}
return self;
}
- (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
- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
{
- module_config_t *p_item;
- p_item = config_FindConfig( p_this, psz_name );
-
- return p_item->i_list;
+ 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]];
+ 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)initWithFrame: (NSRect)frame
- item: (module_config_t *)p_item
+ 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] )
+ frame.size.height = 53;
+ 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;
+ s_rc.size.height = 17;
+ s_rc.origin.x = 0;
+ s_rc.origin.y = 36;
/* is it a directory */
b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : 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 setStringValue: [[VLCMain sharedInstance] localizedString: p_item->psz_text]];
[o_label sizeToFit];
+ [self addSubview: o_label];
[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;
+ s_rc.origin.y = 0;
+ s_rc.size.height = 32;
o_button = [[[NSButton alloc] initWithFrame: s_rc] retain];
[o_button setButtonType: NSMomentaryPushInButton];
[o_button setBezelStyle: NSRoundedBezelStyle];
[o_button setTitle: _NS("Browse...")];
+/*TODO: enlarge a bit the button...*/
[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 frame].size.width - OFFSET_RIGHT / 2, s_rc.origin.y)];
+ [o_button setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
[o_button setTarget: self];
[o_button setAction: @selector(openFileDialog:)];
+ s_rc.origin.x = 15;
+ s_rc.origin.y = 6;
s_rc.size.height = 22;
- s_rc.size.width = s_rc.size.width - OFFSET_BETWEEN - [o_button frame].size.width - OFFSET_RIGHT;
+ s_rc.size.width = s_rc.size.width - OFFSET_BETWEEN - [o_button frame].size.width - OFFSET_RIGHT / 2 - s_rc.origin.x;
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]];
+ if( p_item->psz_value )
+ [o_textfield setStringValue: [[VLCMain sharedInstance] localizedString: p_item->psz_value]];
+ [o_textfield setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
[o_textfield setAutoresizingMask:NSViewWidthSizable];
- [[self contentView] addSubview: o_textfield];
- [[self contentView] addSubview: o_button];
+ [self addSubview: o_textfield];
+ [self addSubview: o_button];
}
return self;
}
{
NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
- [o_open_panel setTitle: _NS("Select a file or directory")];
+ [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: YES];
- [o_open_panel setCanChooseDirectories: b_advanced];
+ [o_open_panel setCanChooseFiles: !b_directory];
+ [o_open_panel setCanChooseDirectories: b_directory];
[o_open_panel beginSheetForDirectory:nil
file:nil
types:nil
@implementation IntegerConfigControl
- (id)initWithFrame: (NSRect)frame
- item: (module_config_t *)p_item
+ 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] )
+ frame.size.height = 25;
+ if( ( self = [super initWithFrame: frame item: _p_item
+ withObject: _p_this] ) )
{
NSRect s_rc = frame;
-
+ s_rc.size.height = 17;
+ s_rc.origin.x = 0;
+ s_rc.origin.y = 6;
/* add the label */
o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain];
[o_label setDrawsBackground: 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 setStringValue: [[VLCMain sharedInstance] localizedString: p_item->psz_text]];
[o_label sizeToFit];
- [[self contentView] addSubview: o_label];
+ [self addSubview: o_label];
[o_label setAutoresizingMask:NSViewMaxXMargin ];
/* build the stepper */
- s_rc.origin.x = s_rc.size.width - 13 - OFFSET_RIGHT;
+ s_rc.origin.x = s_rc.size.width - 16 - OFFSET_RIGHT;
+ s_rc.origin.y = 0;
+ s_rc.size.height = 21;
o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain];
[o_stepper sizeToFit];
[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];
+ [o_stepper setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ [self 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;
+ s_rc.origin.x = s_rc.size.width - 42 - OFFSET_BETWEEN - 19 - OFFSET_RIGHT;
+ s_rc.origin.y = 3;
+ s_rc.size.width = 42;
+ s_rc.size.height = 22;
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 setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] 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];
+ [self addSubview: o_textfield];
}
return self;
}
@implementation IntegerListConfigControl
- (id)initWithFrame: (NSRect)frame
- item: (module_config_t *)p_item
+ 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] )
+ frame.size.height = 24;
+ if( ( self = [super initWithFrame: frame item: _p_item
+ withObject: _p_this] ) )
{
NSRect s_rc = frame;
int i_index;
+ s_rc.size.height = 17;
+ s_rc.origin.x = 0;
+ s_rc.origin.y = 5;
/* add the label */
o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain];
[o_label setEditable: NO];
[o_label setSelectable: NO];
if( p_item->psz_text )
- [o_label setStringValue: [NSApp localizedString: p_item->psz_text]];
+ [o_label setStringValue: [[VLCMain sharedInstance] localizedString: p_item->psz_text]];
[o_label sizeToFit];
- [[self contentView] addSubview: o_label];
+ [self addSubview: o_label];
[o_label setAutoresizingMask:NSViewMaxXMargin ];
/* build the textfield */
s_rc.origin.x = s_rc.size.width - 200 - OFFSET_RIGHT;
+ s_rc.origin.y = 0;
+ s_rc.size.height = 26;
s_rc.size.width = 200;
o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain];
[o_combo setUsesDataSource:TRUE];
[o_combo setDataSource:self];
[o_combo setNumberOfVisibleItems:10];
+ [o_combo setCompletes:YES];
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 setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
- [[self contentView] addSubview: o_combo];
+ [o_combo setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ [self addSubview: o_combo];
}
return self;
}
- (int)intValue
{
- module_config_t *p_item;
- p_item = config_FindConfig( p_this, psz_name );
-
if( [o_combo indexOfSelectedItem] >= 0 )
return p_item->pi_list[[o_combo indexOfSelectedItem]];
else
- (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]];
+ return [[VLCMain sharedInstance] localizedString: p_item->ppsz_list_text[i_index]];
} else return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
}
@implementation RangedIntegerConfigControl
- (id)initWithFrame: (NSRect)frame
- item: (module_config_t *)p_item
+ item: (module_config_t *)_p_item
withObject: (vlc_object_t *)_p_this
{
- frame.size.height = 50;
- if( self = [super initWithFrame: frame item: p_item
- withObject: _p_this] )
+ frame.size.height = 51;
+ if( ( self = [super initWithFrame: frame item: _p_item
+ withObject: _p_this] ) )
{
NSRect s_rc = frame;
- s_rc.size.height = 20;
- s_rc.origin.y = 30;
-
+ s_rc.size.height = 17;
+ s_rc.origin.x = 0;
+ s_rc.origin.y = 32;
/* add the label */
o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain];
[o_label setDrawsBackground: 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 setStringValue: [[VLCMain sharedInstance] localizedString: p_item->psz_text]];
[o_label sizeToFit];
- [[self contentView] addSubview: o_label];
+ [self addSubview: o_label];
[o_label setAutoresizingMask:NSViewMaxXMargin ];
+ /* current value textfield */
+ s_rc.size.height = 22;
+ s_rc.size.width = 40;
+ s_rc.origin.x = [o_label frame].size.width + OFFSET_RIGHT;
+ s_rc.origin.y = 29;
+ o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain];
+ [o_textfield setAutoresizingMask:NSViewMinXMargin];
+
+ [o_textfield setIntValue: p_item->i_value];
+ [o_textfield setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] 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 addSubview: o_textfield];
+
/* build the slider */
/* min value textfield */
+ s_rc.origin.x = 15;
s_rc.origin.y = 0;
- s_rc.origin.x = 0;
s_rc.size.width = 40;
o_textfield_min = [[[NSTextField alloc] initWithFrame: s_rc] retain];
[o_textfield_min setBordered: NO];
[o_textfield_min setEditable: NO];
[o_textfield_min setSelectable: NO];
-
[o_textfield_min setIntValue: p_item->i_min];
- [o_textfield_min setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
- [[self contentView] addSubview: o_textfield_min];
-
- /* the slider */
- s_rc.size.width = [[self contentView] bounds].size.width - OFFSET_RIGHT - 2*OFFSET_BETWEEN - 3*40;
- s_rc.origin.x = 40 + OFFSET_BETWEEN;
+ [o_textfield_min setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ [self addSubview: o_textfield_min];
- o_slider = [[[NSStepper alloc] initWithFrame: s_rc] retain];
- [o_slider setAutoresizingMask:NSViewWidthSizable];
-
- [o_slider setMaxValue: p_item->i_max];
- [o_slider setMinValue: p_item->i_min];
- [o_slider setIntValue: p_item->i_value];
- [o_slider setTarget: self];
- [o_slider setAction: @selector(sliderChanged:)];
- [o_slider sendActionOn:NSLeftMouseUpMask|NSLeftMouseDownMask|NSLeftMouseDraggedMask];
- [o_slider setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
- [[self contentView] addSubview: o_slider];
-
/* max value textfield */
s_rc.size.width = 40;
- s_rc.origin.x = [[self contentView] bounds].size.width - OFFSET_RIGHT - OFFSET_BETWEEN - 2*40;
+ s_rc.origin.x = [self bounds].size.width - OFFSET_RIGHT - 40;
o_textfield_max = [[[NSTextField alloc] initWithFrame: s_rc] retain];
[o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
[o_textfield_max setBordered: NO];
[o_textfield_max setEditable: NO];
[o_textfield_max setSelectable: NO];
+ [o_textfield_max setAlignment: NSRightTextAlignment];
[o_textfield_max setIntValue: p_item->i_max];
- [o_textfield_max setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
- [[self contentView] addSubview: o_textfield_max];
+ [o_textfield_max setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ [self addSubview: o_textfield_max];
- /* current value textfield */
- s_rc.size.width = 40;
- s_rc.origin.x = [[self contentView] bounds].size.width - OFFSET_RIGHT - 40;
-
- o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain];
- [o_textfield setAutoresizingMask:NSViewMinXMargin];
+ /* the slider */
+ s_rc.size.height = 21;
+ s_rc.size.width = [self bounds].size.width - OFFSET_RIGHT - 2*OFFSET_BETWEEN - 2 * 40;
+ s_rc.origin.x = 40 + OFFSET_BETWEEN;
+ s_rc.origin.y = 1;
- [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];
+ o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain];
+ [o_slider setAutoresizingMask:NSViewWidthSizable];
+ [o_slider setMaxValue: p_item->i_max];
+ [o_slider setMinValue: p_item->i_min];
+ [o_slider setIntValue: p_item->i_value];
+ [o_slider setTarget: self];
+ [o_slider setAction: @selector(sliderChanged:)];
+ [o_slider sendActionOn:NSLeftMouseUpMask|NSLeftMouseDownMask|NSLeftMouseDraggedMask];
+ [o_slider setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ [self addSubview: o_slider];
+
}
return self;
}
}
@end
+#if 0
@implementation FloatConfigControl
[o_label setEditable: NO];
[o_label setSelectable: NO];
if( p_item->psz_text )
- [o_label setStringValue: [NSApp localizedString: p_item->psz_text]];
+ [o_label setStringValue: [[VLCMain sharedInstance] localizedString: p_item->psz_text]];
[o_label sizeToFit];
- [[self contentView] addSubview: o_label];
+ [self addSubview: o_label];
[o_label setAutoresizingMask:NSViewMaxXMargin ];
/* build the textfield */
[o_textfield setAutoresizingMask:NSViewMinXMargin | NSViewWidthSizable ];
[o_textfield setFloatValue: p_item->f_value];
- [o_textfield setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
- [[self contentView] addSubview: o_textfield];
+ [o_textfield setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ [self addSubview: o_textfield];
}
return self;
}
[o_label setEditable: NO];
[o_label setSelectable: NO];
if( p_item->psz_text )
- [o_label setStringValue: [NSApp localizedString: p_item->psz_text]];
+ [o_label setStringValue: [[VLCMain sharedInstance] localizedString: p_item->psz_text]];
[o_label sizeToFit];
- [[self contentView] addSubview: o_label];
+ [self addSubview: o_label];
[o_label setAutoresizingMask:NSViewMaxXMargin ];
/* build the slider */
[o_textfield_min setSelectable: NO];
[o_textfield_min setFloatValue: p_item->f_min];
- [o_textfield_min setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
- [[self contentView] addSubview: o_textfield_min];
+ [o_textfield_min setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ [self addSubview: o_textfield_min];
/* the slider */
- s_rc.size.width = [[self contentView] bounds].size.width - OFFSET_RIGHT - 2*OFFSET_BETWEEN - 3*40;
+ s_rc.size.width = [self bounds].size.width - OFFSET_RIGHT - 2*OFFSET_BETWEEN - 3*40;
s_rc.origin.x = 40 + OFFSET_BETWEEN;
o_slider = [[[NSStepper alloc] initWithFrame: s_rc] retain];
[o_slider setTarget: self];
[o_slider setAction: @selector(sliderChanged:)];
[o_slider sendActionOn:NSLeftMouseUpMask|NSLeftMouseDownMask|NSLeftMouseDraggedMask];
- [o_slider setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
- [[self contentView] addSubview: o_slider];
+ [o_slider setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ [self addSubview: o_slider];
/* max value textfield */
s_rc.size.width = 40;
- s_rc.origin.x = [[self contentView] bounds].size.width - OFFSET_RIGHT - OFFSET_BETWEEN - 2*40;
+ s_rc.origin.x = [self bounds].size.width - OFFSET_RIGHT - OFFSET_BETWEEN - 2*40;
o_textfield_max = [[[NSTextField alloc] initWithFrame: s_rc] retain];
[o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
[o_textfield_max setSelectable: NO];
[o_textfield_max setFloatValue: p_item->f_max];
- [o_textfield_max setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
- [[self contentView] addSubview: o_textfield_max];
+ [o_textfield_max setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ [self addSubview: o_textfield_max];
/* current value textfield */
s_rc.size.width = 40;
- s_rc.origin.x = [[self contentView] bounds].size.width - OFFSET_RIGHT - 40;
+ s_rc.origin.x = [self bounds].size.width - OFFSET_RIGHT - 40;
o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain];
[o_textfield setAutoresizingMask:NSViewMinXMargin];
[o_textfield setFloatValue: p_item->f_value];
- [o_textfield setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ [o_textfield setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] 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];
+ [self addSubview: o_textfield];
}
return self;
o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain];
[o_checkbox setButtonType: NSSwitchButton];
[o_checkbox setIntValue: p_item->i_value];
- [o_checkbox setTitle: [NSApp localizedString: p_item->psz_text]];
- [o_checkbox setToolTip: [NSApp wrapString: [NSApp localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
- [[self contentView] addSubview: o_checkbox];
+ [o_checkbox setTitle: [[VLCMain sharedInstance] localizedString: p_item->psz_text]];
+ [o_checkbox setToolTip: [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]];
+ [self addSubview: o_checkbox];
}
return self;
}
}
@end
+#endif
+