Commit 0bb73cd8 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

macosx: Simplify prefs.m.

parent 54f11e39
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
@class VLCTreeItem; @class VLCTreeMainItem;
/***************************************************************************** /*****************************************************************************
* VLCPrefs interface * VLCPrefs interface
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
@interface VLCPrefs : NSObject @interface VLCPrefs : NSObject
{ {
intf_thread_t *p_intf; intf_thread_t *p_intf;
VLCTreeItem *o_config_tree; VLCTreeMainItem * _rootTreeItem;
NSView *o_empty_view; NSView *o_empty_view;
NSMutableDictionary *o_save_prefs; NSMutableDictionary *o_save_prefs;
......
...@@ -62,38 +62,59 @@ ...@@ -62,38 +62,59 @@
@interface VLCTreeItem : NSObject @interface VLCTreeItem : NSObject
{ {
NSString *o_name; NSString *_name;
NSString *o_title; NSMutableArray *_children;
NSString *o_help; NSMutableArray *_subviews;
vlc_object_t * _vlc_object; module_config_t * _configItem;
VLCTreeItem *o_parent; }
NSMutableArray *o_children; - (id)initWithConfigItem:(module_config_t *)configItem;
int i_object_category;
NSMutableArray *o_subviews; - (id)initWithName:(NSString*)name andConfigItem:(module_config_t *)configItem;
}
- (id)initWithName: (NSString *)o_item_name
withTitle: (NSString *)o_item_title
withHelp: (NSString *)o_item_help
withObject: (vlc_object_t *)object
parent:(VLCTreeItem *)o_parent_item
children:(NSMutableArray *)o_children_array
whithCategory: (int) i_category;
+ (VLCTreeItem *)rootItem;
- (int)numberOfChildren; - (int)numberOfChildren;
- (VLCTreeItem *)childAtIndex:(int)i_index; - (VLCTreeItem *)childAtIndex:(int)i_index;
- (vlc_object_t*)vlcObject;
- (module_config_t *)configItem;
- (NSString *)name; - (NSString *)name;
- (NSString *)title; - (NSMutableArray *)children;
- (NSString *)help; - (void)showView:(NSScrollView *)o_prefs_view;
- (BOOL)hasPrefs:(NSString *)o_module_name;
- (NSView *)showView:(NSScrollView *)o_prefs_view;
- (void)applyChanges; - (void)applyChanges;
- (void)resetView; - (void)resetView;
@end @end
@interface VLCTreeSubCategoryItem : VLCTreeItem
{
int _subCategory;
}
+ (VLCTreeSubCategoryItem *)subCategoryTreeItemWithSubCategory:(int)category;
- (id)initWithSubCategory:(int)subCategory;
- (int)subCategory;
@end
@interface VLCTreeCategoryItem : VLCTreeItem
{
int _category;
}
+ (VLCTreeCategoryItem *)categoryTreeItemWithCategory:(int)category;
- (id)initWithCategory:(int)category;
- (int)category;
- (VLCTreeSubCategoryItem *)itemRepresentingSubCategory:(int)category;
@end
@interface VLCTreeLeafItem : VLCTreeItem
{ }
@end
@interface VLCTreeMainItem : VLCTreeItem
{
module_config_t * _configItems;
}
- (VLCTreeCategoryItem *)itemRepresentingCategory:(int)category;
@end
#pragma mark - #pragma mark -
/***************************************************************************** /*****************************************************************************
...@@ -118,6 +139,7 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -118,6 +139,7 @@ static VLCPrefs *_o_sharedMainInstance = nil;
_o_sharedMainInstance = [super init]; _o_sharedMainInstance = [super init];
p_intf = VLCIntf; p_intf = VLCIntf;
o_empty_view = [[NSView alloc] init]; o_empty_view = [[NSView alloc] init];
_rootTreeItem = [[VLCTreeMainItem alloc] init];
} }
return _o_sharedMainInstance; return _o_sharedMainInstance;
...@@ -126,6 +148,7 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -126,6 +148,7 @@ static VLCPrefs *_o_sharedMainInstance = nil;
- (void)dealloc - (void)dealloc
{ {
[o_empty_view release]; [o_empty_view release];
[_rootTreeItem release];
[super dealloc]; [super dealloc];
} }
...@@ -168,7 +191,7 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -168,7 +191,7 @@ static VLCPrefs *_o_sharedMainInstance = nil;
- (IBAction)savePrefs: (id)sender - (IBAction)savePrefs: (id)sender
{ {
/* TODO: call savePrefs on Root item */ /* TODO: call savePrefs on Root item */
[[VLCTreeItem rootItem] applyChanges]; [_rootTreeItem applyChanges];
config_SaveConfigFile( p_intf, NULL ); config_SaveConfigFile( p_intf, NULL );
[o_prefs_window orderOut:self]; [o_prefs_window orderOut:self];
} }
...@@ -194,7 +217,7 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -194,7 +217,7 @@ static VLCPrefs *_o_sharedMainInstance = nil;
{ {
[o_prefs_view setDocumentView: o_empty_view]; [o_prefs_view setDocumentView: o_empty_view];
config_ResetAll( p_intf ); config_ResetAll( p_intf );
[[VLCTreeItem rootItem] resetView]; [_rootTreeItem resetView];
[[o_tree itemAtRow:[o_tree selectedRow]] [[o_tree itemAtRow:[o_tree selectedRow]]
showView:o_prefs_view]; showView:o_prefs_view];
} }
...@@ -226,504 +249,321 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -226,504 +249,321 @@ static VLCPrefs *_o_sharedMainInstance = nil;
@implementation VLCPrefs (NSTableDataSource) @implementation VLCPrefs (NSTableDataSource)
- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item { - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
return (item == nil) ? [[VLCTreeItem rootItem] numberOfChildren] : {
[item numberOfChildren]; return (item == nil) ? [_rootTreeItem numberOfChildren] : [item numberOfChildren];
} }
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{ {
return (item == nil) ? YES : ( ([item numberOfChildren] != -1) && return ![item isKindOfClass:[VLCTreeSubCategoryItem class]];
([item numberOfChildren] != 0));
} }
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item { - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
return (item == nil) ? [[VLCTreeItem rootItem] childAtIndex:index] : {
(id)[item childAtIndex:index]; return (item == nil) ? (id)[_rootTreeItem childAtIndex:index]: (id)[item childAtIndex:index];
} }
- (id)outlineView:(NSOutlineView *)outlineView - (id)outlineView:(NSOutlineView *)outlineView
objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{ {
return (item == nil) ? @"" : (id)[item name]; return (item == nil) ? @"" : [item name];
} }
@end @end
@implementation VLCTreeItem #pragma mark -
@implementation VLCTreeMainItem
static VLCTreeItem *o_root_item = nil;
#define IsALeafNode ((id)-1)
- (id)initWithName: (NSString *)o_item_name - (VLCTreeCategoryItem *)itemRepresentingCategory:(int)category
withTitle: (NSString *)o_item_title
withHelp: (NSString *)o_item_help
withObject: (vlc_object_t *)object
parent:(VLCTreeItem *)o_parent_item
children:(NSMutableArray *)o_children_array
whithCategory: (int) i_category
{ {
self = [super init]; for( int i = 0; i < [[self children] count]; i++ )
if( self != nil )
{ {
o_name = [o_item_name copy]; VLCTreeCategoryItem * categoryItem = [[self children] objectAtIndex:i];
o_title= [o_item_title copy]; if( [categoryItem category] == category )
o_help= [o_item_help copy]; return categoryItem;
_vlc_object = object ? vlc_object_hold( object ) : NULL;
o_parent = o_parent_item;
o_children = o_children_array;
i_object_category = i_category;
o_subviews = nil;
} }
return( self ); return nil;
}
+ (VLCTreeItem *)rootItem
{
if (o_root_item == nil)
o_root_item = [[VLCTreeItem alloc] initWithName:@"main" withTitle:@"main" withHelp:@"" withObject:NULL
parent:nil children:[[NSMutableArray alloc] initWithCapacity:10]
whithCategory: -1];
return o_root_item;
} }
- (void)dealloc - (void)dealloc
{ {
if(_vlc_object) vlc_object_release( _vlc_object ); module_config_free( _configItems );
if (o_children != IsALeafNode) [o_children release];
[o_name release];
[o_title release];
[o_help release];
[super dealloc]; [super dealloc];
} }
/* Creates and returns the array of children /* Creates and returns the array of children
* Loads children incrementally */ * Loads children incrementally */
- (NSArray *)children - (NSMutableArray *)children
{ {
if( o_children == IsALeafNode ) if( _children ) return _children;
return o_children; _children = [[NSMutableArray alloc] init];
if( [ o_children count] == 0 )
{
intf_thread_t *p_intf = VLCIntf;
module_t **p_list;
module_t *p_module = NULL;
module_t *p_main_module;
module_config_t *p_items;
if( [[self name] isEqualToString: @"main"] )
{
p_main_module = module_get_main( p_intf );
assert( p_main_module );
/* 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;
unsigned int i_confsize;
p_items = module_config_get( p_main_module, &i_confsize );
o_children = [[NSMutableArray alloc] initWithCapacity:10];
for( int i = 0; i < i_confsize; i++ )
{
NSString *o_child_name;
NSString *o_child_title;
NSString *o_child_help;
switch( p_items[i].i_type )
{
case CONFIG_CATEGORY:
if( p_items[i].value.i == -1 ) break;
o_child_name = [[VLCMain sharedInstance]
localizedString: config_CategoryNameGet( p_items[i].value.i )];
o_child_title = o_child_name;
o_child_help = [[VLCMain sharedInstance]
localizedString: config_CategoryHelpGet( p_items[i].value.i )];
p_last_category = [VLCTreeItem alloc];
[o_children addObject:[p_last_category
initWithName: o_child_name
withTitle: o_child_title
withHelp: o_child_help
withObject: (vlc_object_t*)p_main_module
parent:self
children:[[NSMutableArray alloc]
initWithCapacity:10]
whithCategory: p_items[i].value.i]];
break;
case CONFIG_SUBCATEGORY:
if( p_items[i].value.i == -1 ) break;
if( p_items[i].value.i != SUBCAT_PLAYLIST_GENERAL &&
p_items[i].value.i != SUBCAT_VIDEO_GENERAL &&
p_items[i].value.i != SUBCAT_INPUT_GENERAL &&
p_items[i].value.i != SUBCAT_INTERFACE_GENERAL &&
p_items[i].value.i != SUBCAT_SOUT_GENERAL &&
p_items[i].value.i != SUBCAT_ADVANCED_MISC &&
p_items[i].value.i != SUBCAT_AUDIO_GENERAL )
{
o_child_name = [[VLCMain sharedInstance]
localizedString: config_CategoryNameGet( p_items[i].value.i ) ];
o_child_title = o_child_name;
o_child_help = [[VLCMain sharedInstance]
localizedString: config_CategoryHelpGet( p_items[i].value.i ) ];
[p_last_category->o_children
addObject:[[VLCTreeItem alloc]
initWithName: o_child_name
withTitle: o_child_title
withHelp: o_child_help
withObject: (vlc_object_t*)p_main_module
parent:p_last_category
children:[[NSMutableArray alloc]
initWithCapacity:10]
whithCategory: p_items[i].value.i]];
}
break;
default:
break;
}
}
vlc_object_release( (vlc_object_t *)p_main_module ); intf_thread_t *p_intf = VLCIntf;
/* List the modules */ /* List the modules */
p_list = module_list_get( NULL ); size_t count, i;
if( !p_list ) return nil; module_t ** modules = module_list_get( &count );
if( !modules ) return nil;
/* Build a tree of the plugins */ /* Build a tree of the plugins */
/* Add the capabilities */ /* Add the capabilities */
for( size_t i = 0; p_list[i]; i++ ) for( i = 0; i < count; i++ )
{ {
unsigned int confsize; module_t * p_module = modules[i];
p_module = p_list[i];
/* Exclude the main module */
if( module_is_main( p_module ) )
continue;
/* Exclude empty plugins (submodules don't have config */
/* options, they are stored in the parent module) */
p_items = module_config_get( p_module, &confsize );
unsigned int j; /* Exclude empty plugins (submodules don't have config */
/* options, they are stored in the parent module) */
unsigned int confsize;
_configItems = module_config_get( p_module, &confsize );
int i_category = -1; VLCTreeCategoryItem * categoryItem = nil;
int i_subcategory = -1; VLCTreeSubCategoryItem * subCategoryItem = nil;
bool b_item = false;
for( j = 0; j < confsize; j++ ) unsigned int j;
for( j = 0; j < confsize; j++ )
{
int configType = _configItems[j].i_type;
if( configType == CONFIG_CATEGORY )
{
categoryItem = [self itemRepresentingCategory:_configItems[j].value.i];
if(!categoryItem)
{ {
if( p_items[j].i_type == CONFIG_CATEGORY ) categoryItem = [VLCTreeCategoryItem categoryTreeItemWithCategory:_configItems[j].value.i];
i_category = p_items[j].value.i; if(categoryItem) [[self children] addObject:categoryItem];
else if( p_items[j].i_type == CONFIG_SUBCATEGORY )
i_subcategory = p_items[j].value.i;
if( p_items[j].i_type & CONFIG_ITEM )
b_item = true;
if( b_item && i_category >= 0 && i_subcategory >= 0 )
break;
} }
}
if( !b_item ) continue; else if( configType == CONFIG_SUBCATEGORY && categoryItem )
{
/* Find the right category item */ subCategoryItem = [categoryItem itemRepresentingSubCategory:_configItems[j].value.i];
if(!subCategoryItem)
long cookie;
bool b_found = false;
VLCTreeItem* p_category_item, * p_subcategory_item;
for (j = 0 ; j < [o_children count] ; j++)
{ {
p_category_item = [o_children objectAtIndex: j]; subCategoryItem = [VLCTreeSubCategoryItem subCategoryTreeItemWithSubCategory:_configItems[j].value.i];
if( p_category_item->i_object_category == i_category ) if(subCategoryItem) [[categoryItem children] addObject:subCategoryItem];
{
b_found = true;
break;
}
} }
if( !b_found ) continue; }
else if( (configType & CONFIG_ITEM) && subCategoryItem )
{
[[subCategoryItem children] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&_configItems[j]]];
}
/* Find subcategory item */
b_found = false;
cookie = -1;
for (j = 0 ; j < [p_category_item->o_children count] ; j++)
{
p_subcategory_item = [p_category_item->o_children
objectAtIndex: j];
if( p_subcategory_item->i_object_category == i_subcategory )
{
b_found = true;
break;
}
}
if( !b_found )
p_subcategory_item = p_category_item;
[p_subcategory_item->o_children addObject:[[VLCTreeItem alloc]
initWithName:[[VLCMain sharedInstance]
localizedString: module_get_name( p_module, false ) ]
withTitle:[[VLCMain sharedInstance]
localizedString: module_GetLongName( p_module ) ]
withHelp: @""
withObject: (vlc_object_t*)p_main_module
parent:p_subcategory_item
children:IsALeafNode
whithCategory: -1]];
}
module_list_free( p_list );
} }
} }
return o_children; module_list_free( modules );
return _children;
} }
@end
- (vlc_object_t *)vlcObject #pragma mark -
@implementation VLCTreeCategoryItem
+ (VLCTreeCategoryItem *)categoryTreeItemWithCategory:(int)category
{
return [[[[self class] alloc] initWithCategory:category] autorelease];
}
- (id)initWithCategory:(int)category
{ {
return vlc_object_hold(_vlc_object); if(!config_CategoryNameGet( category )) return nil;
NSString * name = [[VLCMain sharedInstance] localizedString: config_CategoryNameGet( category )];
if(self = [super initWithName:name andConfigItem:nil])
{
_category = category;
//_help = [[[VLCMain sharedInstance] localizedString: config_CategoryHelpGet( category )] retain];
}
return self;
} }
- (NSString *)name - (VLCTreeSubCategoryItem *)itemRepresentingSubCategory:(int)subCategory
{ {
return [[o_name retain] autorelease]; assert( [self isKindOfClass:[VLCTreeCategoryItem class]] );
for( int i = 0; i < [[self children] count]; i++ )
{
VLCTreeSubCategoryItem * subCategoryItem = [[self children] objectAtIndex:i];
if( [subCategoryItem subCategory] == subCategory )
return subCategoryItem;
}
return nil;
} }
- (NSString *)title - (int)category
{ {
return [[o_title retain] autorelease]; return _category;
} }
@end
- (NSString *)help #pragma mark -
@implementation VLCTreeSubCategoryItem
- (id)initWithSubCategory:(int)subCategory
{ {
return [[o_help retain] autorelease]; if(!config_CategoryNameGet( subCategory )) return nil;
NSString * name = [[VLCMain sharedInstance] localizedString: config_CategoryNameGet( subCategory )];
if(self = [super initWithName:name andConfigItem:NULL])
{
_subCategory = subCategory;
//_help = [[[VLCMain sharedInstance] localizedString: config_CategoryHelpGet( subCategory )] retain];
}
return self;
} }
- (VLCTreeItem *)childAtIndex:(int)i_index + (VLCTreeSubCategoryItem *)subCategoryTreeItemWithSubCategory:(int)subCategory
{ {
return [[self children] objectAtIndex:i_index]; return [[[[self class] alloc] initWithSubCategory:subCategory] autorelease];
} }
- (int)numberOfChildren { - (int)subCategory
id i_tmp = [self children]; {
return (i_tmp == IsALeafNode) ? (-1) : (int)[i_tmp count]; return _subCategory;
} }
- (BOOL)hasPrefs:(NSString *)o_module_name @end
#pragma mark -
@implementation VLCTreeLeafItem
@end
#pragma mark -
#pragma mark (Root class for all TreeItems)
@implementation VLCTreeItem
- (id)initWithConfigItem: (module_config_t *) configItem
{ {
unsigned int confsize; NSString * name = [[VLCMain sharedInstance] localizedString:configItem->psz_name];
return [self initWithName:name andConfigItem:configItem];
}
intf_thread_t *p_intf = VLCIntf; - (id)initWithName:(NSString*)name andConfigItem:(module_config_t *)configItem
module_t *p_parser; {
self = [super init];
if( self != nil )
{
_name = [name retain];
_configItem = configItem;
}
return self;
}
- (void)dealloc
{
[_children release];
[_name release];
[_subviews release];
[super dealloc];
}
const char *psz_module_name = (char *)[o_module_name UTF8String]; - (VLCTreeItem *)childAtIndex:(int)i_index
{
return [[self children] objectAtIndex:i_index];
}
/* look for module */ - (int)numberOfChildren
p_parser = module_find( p_intf, psz_module_name ); {
if( !p_parser ) return [[self children] count];
return( NO ); }
module_config_get( p_parser, &confsize ); - (NSString *)name
BOOL b_has_prefs = confsize != 0; {
module_release( p_parser ); return [[_name retain] autorelease];
return( b_has_prefs );
} }
- (NSView *)showView:(NSScrollView *)o_prefs_view - (void)showView:(NSScrollView *)prefsView
{ {
NSRect s_vrc; NSRect s_vrc;
NSView *o_view; NSView *view;
[[VLCPrefs sharedInstance] setTitle: [self title]];
/* NSLog( [self getHelp] ); */
s_vrc = [[o_prefs_view contentView] bounds]; s_vrc.size.height -= 4;
o_view = [[VLCFlippedView alloc] initWithFrame: s_vrc];
[o_view setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin |
NSViewMaxYMargin];
/* Create all subviews if it isn't already done because we cannot use */
/* setHiden for MacOS < 10.3*/
if( o_subviews == nil )
{
intf_thread_t *p_intf = VLCIntf;
vlc_list_t *p_list;
module_t *p_module = NULL;
module_t *p_main_module;
module_config_t *p_items;
unsigned int confsize;
o_subviews = [[NSMutableArray alloc] initWithCapacity:10]; [[VLCPrefs sharedInstance] setTitle: [self name]];
/* Get a pointer to the module */ s_vrc = [[prefsView contentView] bounds]; s_vrc.size.height -= 4;
if( i_object_category == -1 ) view = [[VLCFlippedView alloc] initWithFrame: s_vrc];
{ [view setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin | NSViewMaxYMargin];
p_module = (module_t *) [self vlcObject];
assert( p_module );
p_items = module_config_get( p_module, &confsize ); if(!_subviews)
{
_subviews = [[NSMutableArray alloc] initWithCapacity:10];
for( unsigned int i = 0; i < confsize; i++ ) long i;
{ for( i = 0; i < [[self children] count]; i++)
switch( p_items[i].i_type )
{
case CONFIG_SUBCATEGORY:
case CONFIG_CATEGORY:
case CONFIG_SECTION:
case CONFIG_HINT_USAGE:
break;
default:
{
VLCConfigControl *o_control = nil;
o_control = [VLCConfigControl newControl:&p_items[i]
withView:o_view];
if( o_control )
{
[o_control setAutoresizingMask: NSViewMaxYMargin |
NSViewWidthSizable];
[o_subviews addObject: o_control];
}
}
break;
}
}
vlc_object_release( (vlc_object_t*)p_module );
}
else
{ {
p_main_module = module_get_main( p_intf ); VLCTreeItem * item = [[self children] objectAtIndex:i];
assert( p_main_module ); if(![item isKindOfClass:[VLCTreeLeafItem class]]) continue;
module_config_t *p_items;
unsigned int i, confsize;
p_items = module_config_get( p_main_module, &confsize );
/* We need to first, find the right (sub)category,
* and then abort when we find a new (sub)category. Part of the Ugliness. */
bool in_right_category = false;
bool in_subcategory = false;
bool done = false;
for( i = 0; i < confsize; i++ )
{
if( !p_items[i].i_type )
{
msg_Err( p_intf, "invalid preference item found" );
break;
}
switch( p_items[i].i_type ) VLCConfigControl *control;
{ control = [VLCConfigControl newControl:[item configItem] withView:view];
case CONFIG_CATEGORY: if( control )
if(!in_right_category && p_items[i].value.i == i_object_category) {
in_right_category = true; [control setAutoresizingMask: NSViewMaxYMargin | NSViewWidthSizable];
else if(in_right_category) [_subviews addObject: control];
done = true;
break;
case CONFIG_SUBCATEGORY:
if(!in_right_category && p_items[i].value.i == i_object_category)
{
in_right_category = true;
in_subcategory = true;
}
else if(in_right_category && in_subcategory)
done = true;
break;
case CONFIG_SECTION:
case CONFIG_HINT_USAGE:
break;
default:
{
if(!in_right_category) break;
VLCConfigControl *o_control = nil;
o_control = [VLCConfigControl newControl:&p_items[i]
withView:o_view];
if( o_control != nil )
{
[o_control setAutoresizingMask: NSViewMaxYMargin |
NSViewWidthSizable];
[o_subviews addObject: o_control];
}
break;
}
}
if( done ) break;
} }
vlc_object_release( (vlc_object_t*)p_main_module );
} }
} }
if( o_view != nil ) assert(view);
{
int i_lastItem = 0; int i_lastItem = 0;
int i_yPos = -2; int i_yPos = -2;
int i_max_label = 0; int i_max_label = 0;
NSEnumerator *enumerator = [o_subviews objectEnumerator]; NSEnumerator *enumerator = [_subviews objectEnumerator];
VLCConfigControl *o_widget; VLCConfigControl *widget;
NSRect o_frame; NSRect frame;
while( ( o_widget = [enumerator nextObject] ) )
if( i_max_label < [o_widget getLabelSize] )
i_max_label = [o_widget getLabelSize];
enumerator = [o_subviews objectEnumerator];
while( ( o_widget = [enumerator nextObject] ) )
{
int i_widget;
i_widget = [o_widget getViewType];
i_yPos += [VLCConfigControl calcVerticalMargin:i_widget
lastItem:i_lastItem];
[o_widget setYPos:i_yPos];
o_frame = [o_widget frame];
o_frame.size.width = [o_view frame].size.width -
LEFTMARGIN - RIGHTMARGIN;
[o_widget setFrame:o_frame];
[o_widget alignWithXPosition: i_max_label];
i_yPos += [o_widget frame].size.height;
i_lastItem = i_widget;
[o_view addSubview:o_widget];
}
o_frame = [o_view frame];
o_frame.size.height = i_yPos;
[o_view setFrame:o_frame];
[o_prefs_view setDocumentView:o_view];
while( ( widget = [enumerator nextObject] ) )
if( i_max_label < [widget getLabelSize] )
i_max_label = [widget getLabelSize];
enumerator = [_subviews objectEnumerator];
while( ( widget = [enumerator nextObject] ) )
{
int i_widget;
i_widget = [widget getViewType];
i_yPos += [VLCConfigControl calcVerticalMargin:i_widget lastItem:i_lastItem];
[widget setYPos:i_yPos];
frame = [widget frame];
frame.size.width = [view frame].size.width - LEFTMARGIN - RIGHTMARGIN;
[widget setFrame:frame];
[widget alignWithXPosition: i_max_label];
i_yPos += [widget frame].size.height;
i_lastItem = i_widget;
[view addSubview:widget];
} }
return o_view;
frame = [view frame];
frame.size.height = i_yPos;
[view setFrame:frame];
[prefsView setDocumentView:view];
} }
- (void)applyChanges - (void)applyChanges
{ {
unsigned int i; unsigned int i;
if( o_subviews != nil ) for( i = 0 ; i < [_subviews count] ; i++ )
//Item has been shown [[_subviews objectAtIndex:i] applyChanges];
for( i = 0 ; i < [o_subviews count] ; i++ )
[[o_subviews objectAtIndex:i] applyChanges];
if( o_children != IsALeafNode ) for( i = 0 ; i < [_children count] ; i++ )
for( i = 0 ; i < [o_children count] ; i++ ) [[_children objectAtIndex:i] applyChanges];
[[o_children objectAtIndex:i] applyChanges];
} }
- (void)resetView - (void)resetView
{ {
[_subviews release];
_subviews = nil;
unsigned int i; unsigned int i;
if( o_subviews != nil ) for( i = 0 ; i < [_children count] ; i++ )
{ [[_children objectAtIndex:i] resetView];
//Item has been shown }
[o_subviews release];
o_subviews = nil;
}
if( o_children != IsALeafNode ) - (NSMutableArray *)children
for( i = 0 ; i < [o_children count] ; i++ ) {
[[o_children objectAtIndex:i] resetView]; if(!_children) _children = [[NSMutableArray alloc] init];
return _children;
} }
- (module_config_t *)configItem
{
return _configItem;
}
@end @end
#pragma mark -
@implementation VLCFlippedView @implementation VLCFlippedView
- (BOOL)isFlipped - (BOOL)isFlipped
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment