]> git.sesse.net Git - vlc/blob - modules/gui/macosx/prefs.m
* added numerous casts to silence compilation warnings introduced with const chars...
[vlc] / modules / gui / macosx / prefs.m
1 /*****************************************************************************
2  * prefs.m: MacOS X module for vlc
3  *****************************************************************************
4  * Copyright (C) 2002-2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8  *          Derk-Jan Hartman <hartman at videolan dot org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /* VLCPrefs manages the main preferences dialog 
26    the class is related to wxwindows intf, PrefsPanel */
27 /* VLCTreeItem should contain:
28    - the children of the treeitem
29    - the associated prefs widgets
30    - the documentview with all the prefs widgets in it
31    - a saveChanges action
32    - a revertChanges action
33    - an advanced action (to hide/show advanced options)
34    - a redraw view action
35    - the children action should generate a list of the treeitems children (to be used by VLCPrefs datasource)
36
37    The class is sort of a mix of wxwindows intfs, PrefsTreeCtrl and ConfigTreeData
38 */
39 /* VLCConfigControl are subclassed NSView's containing and managing individual config items
40    the classes are VERY closely related to wxwindows ConfigControls */
41
42 /*****************************************************************************
43  * Preamble
44  *****************************************************************************/
45 #include <stdlib.h>                                      /* malloc(), free() */
46 #include <sys/param.h>                                    /* for MAXPATHLEN */
47 #include <string.h>
48
49 #include <vlc/vlc.h>
50 #include <vlc_config_cat.h>
51
52 #include "intf.h"
53 #include "prefs.h"
54 #include "prefs_widgets.h"
55 #include "vlc_keys.h"
56
57 /*****************************************************************************
58  * VLCPrefs implementation
59  *****************************************************************************/
60 @implementation VLCPrefs
61
62 static VLCPrefs *_o_sharedMainInstance = nil;
63
64 + (VLCPrefs *)sharedInstance
65 {
66     return _o_sharedMainInstance ? _o_sharedMainInstance : [[self alloc] init];
67 }
68
69 - (id)init
70 {
71     if( _o_sharedMainInstance ) {
72         [self dealloc];
73     }
74     else
75     {
76         _o_sharedMainInstance = [super init];
77         p_intf = VLCIntf;
78         o_empty_view = [[NSView alloc] init];
79     }
80
81     return _o_sharedMainInstance;
82 }
83
84 - (void)dealloc
85 {
86     [o_empty_view release];
87     [super dealloc];
88 }
89
90 - (void)awakeFromNib
91 {
92     p_intf = VLCIntf;
93     b_advanced = config_GetInt( p_intf, "advanced" );
94
95     [self initStrings];
96     [o_advanced_ckb setState: b_advanced];
97     [o_prefs_view setBorderType: NSGrooveBorder];
98     [o_prefs_view setHasVerticalScroller: YES];
99     [o_prefs_view setDrawsBackground: NO];
100     [o_prefs_view setDocumentView: o_empty_view];
101     [o_tree selectRow:0 byExtendingSelection:NO];
102 }
103
104 - (void)setTitle: (NSString *) o_title_name
105 {
106     [o_title setStringValue: o_title_name];
107 }
108
109 - (void)showPrefs
110 {
111     /* load our nib (if not already loaded) */
112     [NSBundle loadNibNamed:@"Preferences" owner:self];
113
114     [o_prefs_window center];
115     [o_prefs_window makeKeyAndOrderFront:self];
116 }
117
118 - (void)initStrings
119 {
120     [o_prefs_window setTitle: _NS("Preferences")];
121     [o_save_btn setTitle: _NS("Save")];
122     [o_cancel_btn setTitle: _NS("Cancel")];
123     [o_reset_btn setTitle: _NS("Reset All")];
124     [o_advanced_ckb setTitle: _NS("Advanced")];
125 }
126
127 - (IBAction)savePrefs: (id)sender
128 {
129     /* TODO: call savePrefs on Root item */
130     [[VLCTreeItem rootItem] applyChanges];
131     config_SaveConfigFile( p_intf, NULL );
132     [o_prefs_window orderOut:self];
133 }
134
135 - (IBAction)closePrefs: (id)sender
136 {
137     [o_prefs_window orderOut:self];
138 }
139
140 - (IBAction)resetAll: (id)sender
141 {
142     NSBeginInformationalAlertSheet(_NS("Reset Preferences"), _NS("Cancel"),
143         _NS("Continue"), nil, o_prefs_window, self,
144         @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,
145         _NS("Beware this will reset the VLC media player preferences.\n"
146             "Are you sure you want to continue?") );
147 }
148
149 - (void)sheetDidEnd:(NSWindow *)o_sheet returnCode:(int)i_return
150     contextInfo:(void *)o_context
151 {
152     if( i_return == NSAlertAlternateReturn )
153     {
154         [o_prefs_view setDocumentView: o_empty_view];
155         config_ResetAll( p_intf );
156         [[VLCTreeItem rootItem] resetView];
157         [[o_tree itemAtRow:[o_tree selectedRow]]
158             showView:o_prefs_view advancedView:
159             ( [o_advanced_ckb state] == NSOnState ) ? VLC_TRUE : VLC_FALSE];
160     }
161 }
162
163 - (IBAction)advancedToggle: (id)sender
164 {
165     b_advanced = !b_advanced;
166     [o_advanced_ckb setState: b_advanced];
167     /* refresh the view of the current treeitem */
168     [[o_tree itemAtRow:[o_tree selectedRow]] showView:o_prefs_view advancedView:
169         ( [o_advanced_ckb state] == NSOnState ) ? VLC_TRUE : VLC_FALSE];
170 }
171
172 - (void)loadConfigTree
173 {
174 }
175
176 - (void)outlineViewSelectionIsChanging:(NSNotification *)o_notification
177 {
178 }
179
180 /* update the document view to the view of the selected tree item */
181 - (void)outlineViewSelectionDidChange:(NSNotification *)o_notification
182 {
183     [[o_tree itemAtRow:[o_tree selectedRow]] showView: o_prefs_view
184         advancedView:( [o_advanced_ckb state] == NSOnState ) ?
185         VLC_TRUE : VLC_FALSE];
186 }
187
188 @end
189
190 @implementation VLCPrefs (NSTableDataSource)
191
192 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
193     return (item == nil) ? [[VLCTreeItem rootItem] numberOfChildren] :
194                             [item numberOfChildren];
195 }
196
197 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
198 {
199     return (item == nil) ? YES : ( ([item numberOfChildren] != -1) && 
200                                    ([item numberOfChildren] != 0));
201 }
202
203 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item {
204     return (item == nil) ? [[VLCTreeItem rootItem] childAtIndex:index] :
205                             (id)[item childAtIndex:index];
206 }
207
208 - (id)outlineView:(NSOutlineView *)outlineView
209     objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
210 {
211     return (item == nil) ? @"" : (id)[item getName];
212 }
213
214 @end
215
216 @implementation VLCTreeItem
217
218 static VLCTreeItem *o_root_item = nil;
219
220 #define IsALeafNode ((id)-1)
221
222 - (id)initWithName: (NSString *)o_item_name
223     withTitle: (NSString *)o_item_title
224     withHelp: (NSString *)o_item_help
225     ID: (int)i_id
226     parent:(VLCTreeItem *)o_parent_item
227     children:(NSMutableArray *)o_children_array
228     whithCategory: (int) i_category
229 {
230     self = [super init];
231
232     if( self != nil )
233     {
234         o_name = [o_item_name copy];
235         o_title= [o_item_title copy];
236         o_help= [o_item_help copy];
237         i_object_id = i_id;
238         o_parent = o_parent_item;
239         o_children = o_children_array;
240         i_object_category = i_category;
241         o_subviews = nil;
242     }
243     return( self );
244 }
245
246 + (VLCTreeItem *)rootItem
247 {
248    if (o_root_item == nil)
249         o_root_item = [[VLCTreeItem alloc] initWithName:@"main" withTitle:@"main" withHelp:@"" ID:0
250             parent:nil children:[[NSMutableArray alloc] initWithCapacity:10]
251             whithCategory: -1];
252    return o_root_item;
253 }
254
255 - (void)dealloc
256 {
257     if (o_children != IsALeafNode) [o_children release];
258     [o_name release];
259     [o_title release];
260     [o_help release];
261     [super dealloc];
262 }
263
264 /* Creates and returns the array of children
265  * Loads children incrementally */
266 - (NSArray *)children
267 {
268     if( o_children == IsALeafNode )
269         return o_children;
270     if( [ o_children count] == 0 )
271     {
272         intf_thread_t   *p_intf = VLCIntf;
273         vlc_list_t      *p_list;
274         module_t        *p_module = NULL;
275         module_t        *p_parser;
276         module_config_t *p_item,
277                         *p_end;
278         int             i_index;
279
280         /* List the modules */
281         p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
282         if( !p_list ) return nil;
283
284         /* get parser */
285         p_parser = (module_t *)p_list->p_values[i_index].p_object;
286         p_end = p_parser->p_config + p_parser->confsize;
287         
288         if( [[self getName] isEqualToString: @"main"] )
289         {
290             /*
291             * Find the main module
292             */
293             for( i_index = 0; i_index < p_list->i_count; i_index++ )
294             {
295                 p_module = (module_t *)p_list->p_values[i_index].p_object;
296                 if( !strcmp( p_module->psz_object_name, "main" ) )
297                     break;
298             }
299             if( p_module == NULL )
300             {
301                 msg_Err( p_intf,
302                     "could not load the preferences" );
303                 return nil;
304             }
305             if( i_index < p_list->i_count )
306             {
307                 /* We found the main module */
308                 /* Enumerate config categories and store a reference so we can
309                  * generate their config panel them when it is asked by the user. */
310                 VLCTreeItem *p_last_category = NULL;
311                 p_item = p_module->p_config;
312                 o_children = [[NSMutableArray alloc] initWithCapacity:10];
313                 if( p_item ) do
314                 {
315                     NSString *o_child_name;
316                     NSString *o_child_title;
317                     NSString *o_child_help;
318                     switch( p_item->i_type )
319                     {
320                     case CONFIG_CATEGORY:
321                                     if( p_item->value.i == -1 ) break;
322
323                         o_child_name = [[VLCMain sharedInstance]
324                             localizedString: config_CategoryNameGet( p_item->value.i )];
325                         o_child_title = o_child_name;
326                         o_child_help = [[VLCMain sharedInstance]
327                             localizedString: config_CategoryHelpGet( p_item->value.i )];
328                         p_last_category = [VLCTreeItem alloc];
329                         [o_children addObject:[p_last_category
330                             initWithName: o_child_name
331                             withTitle: o_child_title
332                             withHelp: o_child_help
333                             ID: p_item->value.i
334                             parent:self
335                             children:[[NSMutableArray alloc]
336                                 initWithCapacity:10]
337                             whithCategory: p_item - p_module->p_config]];
338                         break;
339                     case CONFIG_SUBCATEGORY:
340                                     if( p_item->value.i == -1 ) break;
341
342                         if( p_item->value.i != SUBCAT_PLAYLIST_GENERAL &&
343                             p_item->value.i != SUBCAT_VIDEO_GENERAL &&
344                             p_item->value.i != SUBCAT_INPUT_GENERAL &&
345                             p_item->value.i != SUBCAT_INTERFACE_GENERAL &&
346                             p_item->value.i != SUBCAT_SOUT_GENERAL &&
347                             p_item->value.i != SUBCAT_ADVANCED_MISC &&
348                             p_item->value.i != SUBCAT_AUDIO_GENERAL )
349                         {
350                             o_child_name = [[VLCMain sharedInstance]
351                                 localizedString: config_CategoryNameGet( p_item->value.i ) ];
352                             o_child_title = o_child_name;
353                             o_child_help = [[VLCMain sharedInstance]
354                                 localizedString: config_CategoryHelpGet( p_item->value.i ) ];
355
356                             [p_last_category->o_children
357                                 addObject:[[VLCTreeItem alloc]
358                                 initWithName: o_child_name
359                                 withTitle: o_child_title
360                                 withHelp: o_child_help
361                                 ID: p_item->value.i
362                                 parent:p_last_category
363                                 children:[[NSMutableArray alloc]
364                                     initWithCapacity:10]
365                                 whithCategory: p_item - p_module->p_config]];
366                         }
367                         
368                         break;
369                     default:
370                         break;
371                     }
372                 } while( p_item < p_end && p_item++ );
373             }
374
375             /* Build a tree of the plugins */
376             /* Add the capabilities */
377             for( i_index = 0; i_index < p_list->i_count; i_index++ )
378             {
379                 p_module = (module_t *)p_list->p_values[i_index].p_object;
380
381                 /* Exclude the main module */
382                 if( !strcmp( p_module->psz_object_name, "main" ) )
383                     continue;
384
385                 /* Exclude empty plugins (submodules don't have config */
386                 /* options, they are stored in the parent module) */
387                 if( p_module->b_submodule )
388                     continue;
389                 else
390                     p_item = p_module->p_config;
391
392                 if( !p_item ) continue;
393                 int i_category = -1;
394                 int i_subcategory = -1;
395                 int i_options = 0;
396                 do
397                 {
398                     if( p_item->i_type == CONFIG_CATEGORY )
399                         i_category = p_item->value.i;
400                     else if( p_item->i_type == CONFIG_SUBCATEGORY )
401                         i_subcategory = p_item->value.i;
402
403                     if( p_item->i_type & CONFIG_ITEM )
404                         i_options ++;
405                     if( i_options > 0 && i_category >= 0 && i_subcategory >= 0 )
406                         break;
407                 } while( p_item < p_end && p_item++ );
408                 if( !i_options ) continue;
409
410                 /* Find the right category item */
411
412                 long cookie;
413                 vlc_bool_t b_found = VLC_FALSE;
414                 unsigned int i;
415                 VLCTreeItem* p_category_item, * p_subcategory_item;
416                 for (i = 0 ; i < [o_children count] ; i++)
417                 {
418                     p_category_item = [o_children objectAtIndex: i];
419                     if( p_category_item->i_object_id == i_category )
420                     {
421                         b_found = VLC_TRUE;
422                         break;
423                     }
424                 }
425                 if( !b_found ) continue;
426
427                 /* Find subcategory item */
428                 b_found = VLC_FALSE;
429                 cookie = -1;
430                 for (i = 0 ; i < [p_category_item->o_children count] ; i++)
431                 {
432                     p_subcategory_item = [p_category_item->o_children
433                                             objectAtIndex: i];
434                     if( p_subcategory_item->i_object_id == i_subcategory )
435                     {
436                         b_found = VLC_TRUE;
437                         break;
438                     }
439                 }
440                 if( !b_found )
441                     p_subcategory_item = p_category_item;
442
443                 [p_subcategory_item->o_children addObject:[[VLCTreeItem alloc]
444                     initWithName:[[VLCMain sharedInstance]
445                         localizedString: (char *)p_module->psz_shortname ?
446                         (char *)p_module->psz_shortname : (char *)p_module->psz_object_name ]
447                     withTitle:[[VLCMain sharedInstance]
448                         localizedString: (char *)p_module->psz_longname ?
449                         (char *)p_module->psz_longname : (char *)p_module->psz_object_name ]
450                     withHelp: @""
451                     ID: p_module->i_object_id
452                     parent:p_subcategory_item
453                     children:IsALeafNode
454                     whithCategory: -1]];
455                 }
456         }
457         vlc_list_release( p_list );
458     }
459     return o_children;
460 }
461
462 - (int)getObjectID
463 {
464     return i_object_id;
465 }
466
467 - (NSString *)getName
468 {
469     return o_name;
470 }
471
472 - (NSString *)getTitle
473 {
474     return o_title;
475 }
476
477 - (NSString *)getHelp
478 {
479     return o_help;
480 }
481
482 - (VLCTreeItem *)childAtIndex:(int)i_index
483 {
484     return [[self children] objectAtIndex:i_index];
485 }
486
487 - (int)numberOfChildren {
488     id i_tmp = [self children];
489     return (i_tmp == IsALeafNode) ? (-1) : (int)[i_tmp count];
490 }
491
492 - (BOOL)hasPrefs:(NSString *)o_module_name
493 {
494     intf_thread_t *p_intf = VLCIntf;
495     module_t *p_parser;
496     vlc_list_t *p_list;
497     char *psz_module_name;
498     int i_index;
499
500     psz_module_name = (char *)[o_module_name UTF8String];
501
502     /* look for module */
503     p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
504
505     for( i_index = 0; i_index < p_list->i_count; i_index++ )
506     {
507         p_parser = (module_t *)p_list->p_values[i_index].p_object ;
508
509         if( !strcmp( p_parser->psz_object_name, psz_module_name ) )
510         {
511             BOOL b_has_prefs = p_parser->i_config_items != 0;
512             vlc_list_release( p_list );
513             return( b_has_prefs );
514         }
515     }
516
517     vlc_list_release( p_list );
518
519     return( NO );
520 }
521
522 - (NSView *)showView:(NSScrollView *)o_prefs_view
523     advancedView:(vlc_bool_t) b_advanced
524 {
525     NSRect          s_vrc;
526     NSView          *o_view;
527
528     [[VLCPrefs sharedInstance] setTitle: [self getTitle]];
529     /* NSLog( [self getHelp] ); */ 
530     s_vrc = [[o_prefs_view contentView] bounds]; s_vrc.size.height -= 4;
531     o_view = [[VLCFlippedView alloc] initWithFrame: s_vrc];
532     [o_view setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin |
533                                     NSViewMaxYMargin];
534
535 /* Create all subviews if it isn't already done because we cannot use */
536 /* setHiden for MacOS < 10.3*/
537     if( o_subviews == nil )
538     {
539         intf_thread_t   *p_intf = VLCIntf;
540         vlc_list_t      *p_list;
541         module_t        *p_parser = NULL;
542         module_config_t *p_item,
543                         *p_end = p_parser->p_config + p_parser->confsize; 
544
545         o_subviews = [[NSMutableArray alloc] initWithCapacity:10];
546         /* Get a pointer to the module */
547         if( i_object_category == -1 )
548         {
549             p_parser = (module_t *) vlc_object_get( p_intf, i_object_id );
550             if( !p_parser || p_parser->i_object_type != VLC_OBJECT_MODULE )
551             {
552                 /* 0OOoo something went really bad */
553                 return nil;
554             }
555             p_item = p_parser->p_config;
556
557             p_item = p_parser->p_config + 1;
558
559             do
560             {
561                 if( !p_item )
562                 {
563                     msg_Err( p_intf, "invalid preference item found" );
564                     break;
565                 }
566                 if( p_item < p_end )
567                     break;
568                 switch(p_item->i_type)
569                 {
570                 case CONFIG_SUBCATEGORY:
571                     break;
572                 case CONFIG_CATEGORY:
573                     break;
574                 case CONFIG_SECTION:
575                     break;
576                 case CONFIG_HINT_USAGE:
577                     break;
578                 default:
579                 {
580                     VLCConfigControl *o_control = nil;
581                     o_control = [VLCConfigControl newControl:p_item
582                                                   withView:o_view];
583                     if( o_control != nil )
584                     {
585                         [o_control setAutoresizingMask: NSViewMaxYMargin |
586                             NSViewWidthSizable];
587                         [o_subviews addObject: o_control];
588                     }
589                 }
590                     break;
591                 }
592             } while( p_item < p_end && p_item++ );
593
594             vlc_object_release( p_parser );
595         }
596         else
597         {
598             int i_index;
599             p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
600             if( !p_list ) return o_view;
601
602             /*
603             * Find the main module
604             */
605             for( i_index = 0; i_index < p_list->i_count; i_index++ )
606             {
607                 p_parser = (module_t *)p_list->p_values[i_index].p_object;
608                 if( !strcmp( p_parser->psz_object_name, "main" ) )
609                     break;
610             }
611             if( p_parser == NULL )
612             {
613                 msg_Err( p_intf, "could not load preferences" );
614                 return o_view;
615             }
616             p_item = (p_parser->p_config + i_object_category);
617             if( ( p_item->i_type == CONFIG_CATEGORY ) &&
618               ( ( p_item->value.i == CAT_PLAYLIST )  ||
619                 ( p_item->value.i == CAT_AUDIO )  ||
620                 ( p_item->value.i == CAT_VIDEO ) ||
621                 ( p_item->value.i == CAT_INTERFACE ) ||
622                 ( p_item->value.i == CAT_INPUT ) ||
623                 ( p_item->value.i == CAT_SOUT ) ) )
624                 p_item++;
625
626             do
627             {
628                 p_item++;
629                 if( !p_item )
630                 {
631                     msg_Err( p_intf, "invalid preference item found" );
632                     break;
633                 }
634                 if( p_item < p_end )
635                     break;
636                 switch( p_item->i_type )
637                 {
638                 case CONFIG_SUBCATEGORY:
639                     break;
640                 case CONFIG_CATEGORY:
641                     break;
642                 case CONFIG_SECTION:
643                     break;
644                 case CONFIG_HINT_USAGE:
645                     break;
646                 default:
647                 {
648                     VLCConfigControl *o_control = nil;
649                     if( p_item->b_internal == VLC_TRUE )
650                     {
651                         break;
652                     }
653                     o_control = [VLCConfigControl newControl:p_item
654                                                   withView:o_view];
655                     if( o_control != nil )
656                     {
657                         [o_control setAutoresizingMask: NSViewMaxYMargin |
658                                                         NSViewWidthSizable];
659                         [o_subviews addObject: o_control];
660                     }
661                     break;
662                 }
663                 }
664             } while ( ( p_item < p_end ) &&
665                       ( p_item->i_type != CONFIG_SUBCATEGORY ) );
666
667             vlc_list_release( p_list );
668         }
669     }
670
671     if( o_view != nil )
672     {
673         int i_lastItem = 0;
674         int i_yPos = -2;
675         int i_max_label = 0;
676         int i_show_advanced = 0;
677
678         NSEnumerator *enumerator = [o_subviews objectEnumerator];
679         VLCConfigControl *o_widget;
680         NSRect o_frame;
681         
682         while( ( o_widget = [enumerator nextObject] ) )
683             if( ( [o_widget isAdvanced] ) && (! b_advanced) )
684                 continue;
685             else if( i_max_label < [o_widget getLabelSize] )
686                 i_max_label = [o_widget getLabelSize];
687
688         enumerator = [o_subviews objectEnumerator];
689         while( ( o_widget = [enumerator nextObject] ) )
690         {
691             int i_widget;
692             if( ( [o_widget isAdvanced] ) && (! b_advanced) )
693             {
694                 i_show_advanced++;
695                 continue;
696             }
697
698             i_widget = [o_widget getViewType];
699             i_yPos += [VLCConfigControl calcVerticalMargin:i_widget
700                 lastItem:i_lastItem];
701             [o_widget setYPos:i_yPos];
702             o_frame = [o_widget frame];
703             o_frame.size.width = [o_view frame].size.width -
704                                     LEFTMARGIN - RIGHTMARGIN;
705             [o_widget setFrame:o_frame];
706             [o_widget alignWithXPosition: i_max_label];
707             i_yPos += [o_widget frame].size.height;
708             i_lastItem = i_widget;
709             [o_view addSubview:o_widget];
710          }
711         if( i_show_advanced != 0 )
712         {
713             /* We add the advanced notice... */
714             NSRect s_rc = [o_view frame];
715             NSTextField *o_label;
716             s_rc.size.height = 17;
717             s_rc.origin.x = LEFTMARGIN;
718             s_rc.origin.y = i_yPos += [VLCConfigControl
719                                         calcVerticalMargin:CONFIG_ITEM_STRING
720                                         lastItem:i_lastItem];
721             o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain];
722             [o_label setDrawsBackground: NO];
723             [o_label setBordered: NO];
724             [o_label setEditable: NO];
725             [o_label setSelectable: NO];
726             [o_label setStringValue: _NS("Some options are hidden. " \
727                                 "Check \"Advanced\" to display them.")];
728             [o_label setFont:[NSFont systemFontOfSize:10]];
729             [o_label sizeToFit];
730             [o_view addSubview:o_label];
731             i_yPos += [o_label frame].size.height;
732         }
733         o_frame = [o_view frame];
734         o_frame.size.height = i_yPos;
735         [o_view setFrame:o_frame];
736         [o_prefs_view setDocumentView:o_view];
737
738     }
739     return o_view;
740 }
741
742 - (void)applyChanges
743 {
744     unsigned int i;
745     if( o_subviews != nil )
746         //Item has been shown
747         for( i = 0 ; i < [o_subviews count] ; i++ )
748             [[o_subviews objectAtIndex:i] applyChanges];
749
750     if( o_children != IsALeafNode )
751         for( i = 0 ; i < [o_children count] ; i++ )
752             [[o_children objectAtIndex:i] applyChanges];
753 }
754
755 - (void)resetView
756 {
757     unsigned int i;
758     if( o_subviews != nil )
759     {
760         //Item has been shown
761         [o_subviews release];
762         o_subviews = nil;
763     }
764
765     if( o_children != IsALeafNode )
766         for( i = 0 ; i < [o_children count] ; i++ )
767             [[o_children objectAtIndex:i] resetView];
768 }
769
770 @end
771
772
773 @implementation VLCFlippedView
774
775 - (BOOL)isFlipped
776 {
777     return( YES );
778 }
779
780 @end