Commit 60ab318b authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: fixed wrong calculation of ModuleListConfigControl's size when drawn in the complete prefs

refs #3947
parent f6931951
/***************************************************************************** /*****************************************************************************
* prefs_widgets.m: Preferences controls * prefs_widgets.m: Preferences controls
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2007 the VideoLAN team * Copyright (C) 2002-2011 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Derk-Jan Hartman <hartman at videolan.org> * Authors: Derk-Jan Hartman <hartman at videolan.org>
...@@ -2146,15 +2146,15 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ ...@@ -2146,15 +2146,15 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \
withView: (NSView *)o_parent_view withView: (NSView *)o_parent_view
{ {
if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
//TODO.... //TODO....
return nil; return nil;
//Fill our array to know how may items we have... //Fill our array to know how may items we have...
module_t *p_parser, **p_list; module_t *p_parser, **p_list;
size_t i_module_index; size_t i_module_index;
NSRect mainFrame = [o_parent_view frame]; NSRect mainFrame = [o_parent_view frame];
NSString *o_labelString, *o_textfieldString, *o_tooltip; NSString *o_labelString, *o_textfieldString, *o_tooltip;
o_modulearray = [[NSMutableArray alloc] initWithCapacity:10]; o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
/* build a list of available modules */ /* build a list of available modules */
p_list = module_list_get( NULL ); p_list = module_list_get( NULL );
...@@ -2162,132 +2162,132 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ ...@@ -2162,132 +2162,132 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \
{ {
int i; int i;
p_parser = p_list[i_module_index]; p_parser = p_list[i_module_index];
if( module_is_main( p_parser ) ) if( module_is_main( p_parser ) )
continue; continue;
unsigned int confsize; unsigned int confsize;
module_config_t *p_configlist = module_config_get( p_parser, &confsize ); module_config_t *p_configlist = module_config_get( p_parser, &confsize );
for ( i = 0; i < confsize; i++ ) for ( i = 0; i < confsize; i++ )
{ {
unsigned int unused; unsigned int unused;
module_config_t *p_config = &p_configlist[i]; module_config_t *p_config = &p_configlist[i];
NSString *o_modulelongname, *o_modulename; NSString *o_modulelongname, *o_modulename;
NSNumber *o_moduleenabled = nil; NSNumber *o_moduleenabled = nil;
/* Hack: required subcategory is stored in i_min */ /* Hack: required subcategory is stored in i_min */
if( p_config->i_type == CONFIG_SUBCATEGORY && if( p_config->i_type == CONFIG_SUBCATEGORY &&
p_config->value.i == _p_item->min.i ) p_config->value.i == _p_item->min.i )
{ {
o_modulelongname = [NSString stringWithUTF8String: o_modulelongname = [NSString stringWithUTF8String:
module_get_name( p_parser, TRUE )]; module_get_name( p_parser, TRUE )];
o_modulename = [NSString stringWithUTF8String: o_modulename = [NSString stringWithUTF8String:
module_get_object( p_parser )]; module_get_object( p_parser )];
if( _p_item->value.psz && if( _p_item->value.psz &&
strstr( _p_item->value.psz, module_get_object( p_parser ) ) ) strstr( _p_item->value.psz, module_get_object( p_parser ) ) )
o_moduleenabled = [NSNumber numberWithBool:YES]; o_moduleenabled = [NSNumber numberWithBool:YES];
else else
o_moduleenabled = [NSNumber numberWithBool:NO]; o_moduleenabled = [NSNumber numberWithBool:NO];
[o_modulearray addObject:[NSMutableArray [o_modulearray addObject:[NSMutableArray
arrayWithObjects: o_modulename, o_modulelongname, arrayWithObjects: o_modulename, o_modulelongname,
o_moduleenabled, nil]]; o_moduleenabled, nil]];
} }
} }
module_config_free( p_configlist ); module_config_free( p_configlist );
} }
module_list_free( p_list ); module_list_free( p_list );
mainFrame.size.height = 30 + 18 * [o_modulearray count]; mainFrame.size.height = 30 + 20 * [o_modulearray count];
mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN; mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
mainFrame.origin.x = LEFTMARGIN; mainFrame.origin.x = LEFTMARGIN;
mainFrame.origin.y = 0; mainFrame.origin.y = 0;
if( [super initWithFrame: mainFrame item: _p_item] != nil ) if( [super initWithFrame: mainFrame item: _p_item] != nil )
{ {
i_view_type = CONFIG_ITEM_MODULE_LIST; i_view_type = CONFIG_ITEM_MODULE_LIST;
o_tooltip = [[VLCMain sharedInstance] wrapString: o_tooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] [[VLCMain sharedInstance]
localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP]; localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
/* add the label */ /* add the label */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] o_labelString = [[VLCMain sharedInstance]
localizedString: (char *)p_item->psz_text]; localizedString: (char *)p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip ) ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
[o_label setAutoresizingMask:NSViewNotSizable ]; [o_label setAutoresizingMask:NSViewNotSizable ];
[self addSubview: o_label]; [self addSubview: o_label];
/* build the textfield */ /* build the textfield */
if( p_item->value.psz ) if( p_item->value.psz )
o_textfieldString = [[VLCMain sharedInstance] o_textfieldString = [[VLCMain sharedInstance]
localizedString: (char *)p_item->value.psz]; localizedString: (char *)p_item->value.psz];
else else
o_textfieldString = [NSString stringWithString: @""]; o_textfieldString = [NSString stringWithString: @""];
ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2, ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
mainFrame.size.height - 22, mainFrame.size.width - mainFrame.size.height - 22, mainFrame.size.width -
[o_label frame].size.width - 2, o_tooltip, o_textfieldString ) [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
[o_textfield setAutoresizingMask:NSViewWidthSizable ]; [o_textfield setAutoresizingMask:NSViewWidthSizable ];
[self addSubview: o_textfield]; [self addSubview: o_textfield];
{ {
NSRect s_rc = mainFrame; NSRect s_rc = mainFrame;
s_rc.size.height = mainFrame.size.height - 30; s_rc.size.height = mainFrame.size.height - 30;
s_rc.size.width = mainFrame.size.width - 12; s_rc.size.width = mainFrame.size.width - 12;
s_rc.origin.x = 12; s_rc.origin.x = 12;
s_rc.origin.y = 0; s_rc.origin.y = 0;
o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain]; o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
[o_scrollview setDrawsBackground: NO]; [o_scrollview setDrawsBackground: NO];
[o_scrollview setBorderType: NSBezelBorder]; [o_scrollview setBorderType: NSBezelBorder];
[o_scrollview setAutohidesScrollers:YES]; [o_scrollview setAutohidesScrollers:YES];
NSTableView *o_tableview; NSTableView *o_tableview;
o_tableview = [[NSTableView alloc] initWithFrame : s_rc]; o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
[o_tableview setUsesAlternatingRowBackgroundColors:YES]; [o_tableview setUsesAlternatingRowBackgroundColors:YES];
[o_tableview setHeaderView:nil]; [o_tableview setHeaderView:nil];
/* TODO: find a good way to fix the row height and text size*/ /* TODO: find a good way to fix the row height and text size*/
/* FIXME: support for multiple selection... */ /* FIXME: support for multiple selection... */
// [o_tableview setAllowsMultipleSelection:YES]; // [o_tableview setAllowsMultipleSelection:YES];
NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"]; NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
NSCell *o_dataCell = [[NSButtonCell alloc] init]; NSCell *o_dataCell = [[NSButtonCell alloc] init];
[(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton]; [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
[o_dataCell setTitle:@""]; [o_dataCell setTitle:@""];
[o_dataCell setFont:[NSFont systemFontOfSize:0]]; [o_dataCell setFont:[NSFont systemFontOfSize:0]];
NSTableColumn *o_tableColumn = [[NSTableColumn alloc] NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
initWithIdentifier:@"Enabled"]; initWithIdentifier:@"Enabled"];
[o_tableColumn setHeaderCell: o_headerCell]; [o_tableColumn setHeaderCell: o_headerCell];
[o_tableColumn setDataCell: o_dataCell]; [o_tableColumn setDataCell: o_dataCell];
[o_tableColumn setWidth:17]; [o_tableColumn setWidth:17];
[o_tableview addTableColumn: o_tableColumn]; [o_tableview addTableColumn: o_tableColumn];
o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"]; o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
o_dataCell = [[NSTextFieldCell alloc] init]; o_dataCell = [[NSTextFieldCell alloc] init];
[o_dataCell setFont:[NSFont systemFontOfSize:12]]; [o_dataCell setFont:[NSFont systemFontOfSize:12]];
o_tableColumn = [[NSTableColumn alloc] o_tableColumn = [[NSTableColumn alloc]
initWithIdentifier:@"Module"]; initWithIdentifier:@"Module"];
[o_tableColumn setHeaderCell: o_headerCell]; [o_tableColumn setHeaderCell: o_headerCell];
[o_tableColumn setDataCell: o_dataCell]; [o_tableColumn setDataCell: o_dataCell];
[o_tableColumn setWidth:388 - 17]; [o_tableColumn setWidth:s_rc.size.width - 34];
[o_tableview addTableColumn: o_tableColumn]; [o_tableview addTableColumn: o_tableColumn];
[o_tableview registerForDraggedTypes:[NSArray arrayWithObjects: [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
@"VLC media player module", nil]]; @"VLC media player module", nil]];
[o_tableview setDataSource:self]; [o_tableview setDataSource:self];
[o_tableview setTarget: self]; [o_tableview setTarget: self];
[o_tableview setAction: @selector(tableChanged:)]; [o_tableview setAction: @selector(tableChanged:)];
[o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
NSLeftMouseDraggedMask]; NSLeftMouseDraggedMask];
[o_scrollview setDocumentView: o_tableview]; [o_scrollview setDocumentView: o_tableview];
} }
[o_scrollview setAutoresizingMask:NSViewWidthSizable ]; [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
[self addSubview: o_scrollview]; [o_scrollview setAutohidesScrollers:YES];
[self addSubview: o_scrollview];
} }
return self; return self;
......
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