Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

prefs_widgets.m

00001 /*****************************************************************************
00002  * prefs_widgets.m: Preferences controls
00003  *****************************************************************************
00004  * Copyright (C) 2002-2003 the VideoLAN team
00005  * $Id: prefs_widgets.m 12274 2005-08-19 16:16:34Z hartman $
00006  *
00007  * Authors: Derk-Jan Hartman <hartman at videolan.org>
00008  *          Jérôme Decoodt <djc at videolan.org>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  * 
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00023  *****************************************************************************/
00024 
00025 /*****************************************************************************
00026  * Preamble
00027  *****************************************************************************/
00028 #include <stdlib.h>                                      /* malloc(), free() */
00029 #include <string.h>
00030 
00031 #include <vlc/vlc.h>
00032 #include "vlc_keys.h"
00033 
00034 #include "intf.h"
00035 #include "prefs_widgets.h"
00036 
00037 #define PREFS_WRAP 300
00038 #define OFFSET_RIGHT 20
00039 #define OFFSET_BETWEEN 2
00040 
00041 #define UPWARDS_WHITE_ARROW                 "\xE2\x87\xA7" 
00042 #define OPTION_KEY                          "\xE2\x8C\xA5"
00043 #define UP_ARROWHEAD                        "\xE2\x8C\x83"
00044 #define PLACE_OF_INTEREST_SIGN              "\xE2\x8C\x98"
00045 
00046 #define POPULATE_A_KEY( o_menu, string, value )                             \
00047 {                                                                           \
00048     NSMenuItem *o_mi;                                                       \
00049 /*  Normal */                                                               \
00050     o_mi = [[NSMenuItem alloc] initWithTitle:string                         \
00051         action:nil keyEquivalent:@""];                                      \
00052     [o_mi setKeyEquivalentModifierMask:                                     \
00053         0];                                                                 \
00054 if( MACOS_VERSION >= 10.3 )                                                 \
00055     [o_mi setAlternate: NO];                                                \
00056     [o_mi setTag:                                                           \
00057         ( value )];                                                         \
00058     [o_menu addItem: o_mi];                                                 \
00059 if( MACOS_VERSION >= 10.3 )                                                 \
00060 {                                                                           \
00061 /*  Ctrl */                                                                 \
00062     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00063         [[NSString stringWithUTF8String:                                    \
00064             UP_ARROWHEAD                                                    \
00065         ] stringByAppendingString: string]                                  \
00066         action:nil keyEquivalent:@""];                                      \
00067     [o_mi setKeyEquivalentModifierMask:                                     \
00068         NSControlKeyMask];                                                  \
00069     [o_mi setAlternate: YES];                                               \
00070     [o_mi setTag:                                                           \
00071         KEY_MODIFIER_CTRL | ( value )];                                     \
00072     [o_menu addItem: o_mi];                                                 \
00073 /* Ctrl+Alt */                                                              \
00074     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00075         [[NSString stringWithUTF8String:                                    \
00076             UP_ARROWHEAD OPTION_KEY                                         \
00077         ] stringByAppendingString: string]                                  \
00078         action:nil keyEquivalent:@""];                                      \
00079     [o_mi setKeyEquivalentModifierMask:                                     \
00080         NSControlKeyMask | NSAlternateKeyMask];                             \
00081     [o_mi setAlternate: YES];                                               \
00082     [o_mi setTag:                                                           \
00083         (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | ( value )];                \
00084     [o_menu addItem: o_mi];                                                 \
00085 /* Ctrl+Shift */                                                            \
00086     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00087         [[NSString stringWithUTF8String:                                    \
00088             UP_ARROWHEAD UPWARDS_WHITE_ARROW                                \
00089         ] stringByAppendingString: string]                                  \
00090         action:nil keyEquivalent:@""];                                      \
00091     [o_mi setKeyEquivalentModifierMask:                                     \
00092        NSControlKeyMask | NSShiftKeyMask];                                  \
00093     [o_mi setAlternate: YES];                                               \
00094     [o_mi setTag:                                                           \
00095         (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | ( value )];              \
00096     [o_menu addItem: o_mi];                                                 \
00097 /* Ctrl+Apple */                                                            \
00098     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00099         [[NSString stringWithUTF8String:                                    \
00100             UP_ARROWHEAD PLACE_OF_INTEREST_SIGN                             \
00101         ] stringByAppendingString: string]                                  \
00102         action:nil keyEquivalent:@""];                                      \
00103     [o_mi setKeyEquivalentModifierMask:                                     \
00104         NSControlKeyMask | NSCommandKeyMask];                               \
00105     [o_mi setAlternate: YES];                                               \
00106     [o_mi setTag:                                                           \
00107         (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | ( value )];            \
00108     [o_menu addItem: o_mi];                                                 \
00109 /* Ctrl+Alt+Shift */                                                        \
00110     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00111         [[NSString stringWithUTF8String:                                    \
00112             UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW                     \
00113         ] stringByAppendingString: string]                                  \
00114         action:nil keyEquivalent:@""];                                      \
00115     [o_mi setKeyEquivalentModifierMask:                                     \
00116         NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask];            \
00117     [o_mi setAlternate: YES];                                               \
00118     [o_mi setTag:                                                           \
00119         (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) |       \
00120              ( value )];                                                    \
00121     [o_menu addItem: o_mi];                                                 \
00122 /* Ctrl+Alt+Apple */                                                        \
00123     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00124         [[NSString stringWithUTF8String:                                    \
00125             UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN                  \
00126         ] stringByAppendingString: string]                                  \
00127         action:nil keyEquivalent:@""];                                      \
00128     [o_mi setKeyEquivalentModifierMask:                                     \
00129         NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask];          \
00130     [o_mi setAlternate: YES];                                               \
00131     [o_mi setTag:                                                           \
00132         (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) |     \
00133             ( value )];                                                     \
00134     [o_menu addItem: o_mi];                                                 \
00135 /* Ctrl+Shift+Apple */                                                      \
00136     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00137         [[NSString stringWithUTF8String:                                    \
00138             UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN         \
00139         ] stringByAppendingString: string]                                  \
00140         action:nil keyEquivalent:@""];                                      \
00141     [o_mi setKeyEquivalentModifierMask:                                     \
00142         NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask];              \
00143     [o_mi setAlternate: YES];                                               \
00144     [o_mi setTag:                                                           \
00145         (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) |   \
00146             ( value )];                                                     \
00147     [o_menu addItem: o_mi];                                                 \
00148 /* Ctrl+Alt+Shift+Apple */                                                  \
00149     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00150         [[NSString stringWithUTF8String:                                    \
00151             UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW                     \
00152                 PLACE_OF_INTEREST_SIGN                                      \
00153         ] stringByAppendingString: string]                                  \
00154         action:nil keyEquivalent:@""];                                      \
00155     [o_mi setKeyEquivalentModifierMask:                                     \
00156         NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask |            \
00157             NSCommandKeyMask];                                              \
00158     [o_mi setAlternate: YES];                                               \
00159     [o_mi setTag:                                                           \
00160         (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT |        \
00161             KEY_MODIFIER_COMMAND) | ( value )];                             \
00162     [o_menu addItem: o_mi];                                                 \
00163 /* Alt */                                                                   \
00164     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00165         [[NSString stringWithUTF8String:                                    \
00166             OPTION_KEY                                                      \
00167         ] stringByAppendingString: string]                                  \
00168         action:nil keyEquivalent:@""];                                      \
00169     [o_mi setKeyEquivalentModifierMask:                                     \
00170         NSAlternateKeyMask];                                                \
00171     [o_mi setAlternate: YES];                                               \
00172     [o_mi setTag:                                                           \
00173         KEY_MODIFIER_ALT | ( value )];                                      \
00174     [o_menu addItem: o_mi];                                                 \
00175 /* Alt+Shift */                                                             \
00176     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00177         [[NSString stringWithUTF8String:                                    \
00178             OPTION_KEY UPWARDS_WHITE_ARROW                                  \
00179         ] stringByAppendingString: string]                                  \
00180         action:nil keyEquivalent:@""];                                      \
00181     [o_mi setKeyEquivalentModifierMask:                                     \
00182         NSAlternateKeyMask | NSShiftKeyMask];                               \
00183     [o_mi setAlternate: YES];                                               \
00184     [o_mi setTag:                                                           \
00185         (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )];               \
00186     [o_menu addItem: o_mi];                                                 \
00187 /* Alt+Apple */                                                             \
00188     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00189         [[NSString stringWithUTF8String:                                    \
00190             OPTION_KEY PLACE_OF_INTEREST_SIGN                               \
00191         ] stringByAppendingString: string]                                  \
00192         action:nil keyEquivalent:@""];                                      \
00193     [o_mi setKeyEquivalentModifierMask:                                     \
00194         NSAlternateKeyMask | NSCommandKeyMask];                             \
00195     [o_mi setAlternate: YES];                                               \
00196     [o_mi setTag:                                                           \
00197         (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )];             \
00198     [o_menu addItem: o_mi];                                                 \
00199 /* Alt+Shift+Apple */                                                       \
00200     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00201         [[NSString stringWithUTF8String:                                    \
00202             OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN           \
00203         ] stringByAppendingString: string]                                  \
00204         action:nil keyEquivalent:@""];                                      \
00205     [o_mi setKeyEquivalentModifierMask:                                     \
00206         NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask];            \
00207     [o_mi setAlternate: YES];                                               \
00208     [o_mi setTag:                                                           \
00209         (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) |    \
00210             ( value )];                                                     \
00211     [o_menu addItem: o_mi];                                                 \
00212 /* Shift */                                                                 \
00213     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00214         [[NSString stringWithUTF8String:                                    \
00215             UPWARDS_WHITE_ARROW                                             \
00216         ] stringByAppendingString: string]                                  \
00217         action:nil keyEquivalent:@""];                                      \
00218     [o_mi setKeyEquivalentModifierMask:                                     \
00219         NSShiftKeyMask];                                                    \
00220     [o_mi setAlternate: YES];                                               \
00221     [o_mi setTag:                                                           \
00222         KEY_MODIFIER_SHIFT | ( value )];                                    \
00223     [o_menu addItem: o_mi];                                                 \
00224 /* Shift+Apple */                                                           \
00225     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00226         [[NSString stringWithUTF8String:                                    \
00227             UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN                      \
00228         ] stringByAppendingString: string]                                  \
00229         action:nil keyEquivalent:@""];                                      \
00230     [o_mi setKeyEquivalentModifierMask:                                     \
00231         NSShiftKeyMask | NSCommandKeyMask];                                 \
00232     [o_mi setAlternate: YES];                                               \
00233     [o_mi setTag:                                                           \
00234         (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )];           \
00235     [o_menu addItem: o_mi];                                                 \
00236 /* Apple */                                                                 \
00237     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
00238         [[NSString stringWithUTF8String:                                    \
00239         PLACE_OF_INTEREST_SIGN                                              \
00240         ] stringByAppendingString: string]                                  \
00241         action:nil keyEquivalent:@""];                                      \
00242     [o_mi setKeyEquivalentModifierMask:                                     \
00243         NSCommandKeyMask];                                                  \
00244     [o_mi setAlternate: YES];                                               \
00245     [o_mi setTag:                                                           \
00246         KEY_MODIFIER_COMMAND | ( value )];                                  \
00247     [o_menu addItem: o_mi];                                                 \
00248 }                                                                           \
00249 }
00250 
00251 #define ADD_LABEL( o_label, superFrame, x_offset, my_y_offset, label )      \
00252 {                                                                           \
00253     NSRect s_rc = superFrame;                                               \
00254     s_rc.size.height = 17;                                                  \
00255     s_rc.origin.x = x_offset - 3;                                           \
00256     s_rc.origin.y = superFrame.size.height - 17 + my_y_offset;              \
00257     o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain];           \
00258     [o_label setDrawsBackground: NO];                                       \
00259     [o_label setBordered: NO];                                              \
00260     [o_label setEditable: NO];                                              \
00261     [o_label setSelectable: NO];                                            \
00262     [o_label setStringValue: label];                                        \
00263     [o_label setFont:[NSFont systemFontOfSize:0]];                          \
00264     [o_label sizeToFit];                                                    \
00265 }
00266 
00267 #define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset,      \
00268     my_width, tooltip, init_value )                                         \
00269 {                                                                           \
00270     NSRect s_rc = superFrame;                                               \
00271     s_rc.origin.x = x_offset;                                               \
00272     s_rc.origin.y = my_y_offset;                                            \
00273     s_rc.size.height = 22;                                                  \
00274     s_rc.size.width = my_width;                                             \
00275     o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain];       \
00276     [o_textfield setFont:[NSFont systemFontOfSize:0]];                      \
00277     [o_textfield setToolTip: tooltip];                                      \
00278     [o_textfield setStringValue: init_value];                               \
00279 }
00280 
00281 #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset,   \
00282     tooltip )                                                               \
00283 {                                                                           \
00284     NSRect s_rc = superFrame;                                               \
00285     s_rc.origin.x = x_offset + 2;                                           \
00286     s_rc.origin.y = my_y_offset;                                            \
00287     s_rc.size.height = 26;                                                  \
00288     s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x -           \
00289         (x2_offset);                                                        \
00290     o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain];            \
00291     [o_combo setFont:[NSFont systemFontOfSize:0]];                          \
00292     [o_combo setToolTip: tooltip];                                          \
00293     [o_combo setUsesDataSource:TRUE];                                       \
00294     [o_combo setDataSource:self];                                           \
00295     [o_combo setNumberOfVisibleItems:10];                                   \
00296     [o_combo setCompletes:YES];                                             \
00297 }
00298 
00299 #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset,      \
00300     tooltip, title )                                                        \
00301 {                                                                           \
00302     NSRect s_rc = superFrame;                                               \
00303     o_button = [[[NSButton alloc] initWithFrame: s_rc] retain];             \
00304     [o_button setButtonType: NSMomentaryPushInButton];                      \
00305     [o_button setBezelStyle: NSRoundedBezelStyle];                          \
00306     [o_button setTitle: title];                                             \
00307     [o_button setFont:[NSFont systemFontOfSize:0]];                         \
00308     [o_button sizeToFit];                                                   \
00309     s_rc = [o_button frame];                                                \
00310     s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
00311     s_rc.origin.y = my_y_offset - 6;                                        \
00312     s_rc.size.width += 12;                                                  \
00313     [o_button setFrame: s_rc];                                              \
00314     [o_button setToolTip: tooltip];                                         \
00315     [o_button setTarget: self];                                             \
00316     [o_button setAction: @selector(openFileDialog:)];                       \
00317 }
00318 
00319 #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset,   \
00320     tooltip )                                                               \
00321 {                                                                           \
00322     NSRect s_rc = superFrame;                                               \
00323     s_rc.origin.x = x_offset - 1;                                           \
00324     s_rc.origin.y = my_y_offset;                                            \
00325     s_rc.size.height = 26;                                                  \
00326     s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x -           \
00327         (x2_offset);                                                        \
00328     o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain];         \
00329     [o_popup setFont:[NSFont systemFontOfSize:0]];                          \
00330     [o_popup setToolTip: tooltip];                                          \
00331 }
00332 
00333 #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
00334     lower, higher )                                                         \
00335 {                                                                           \
00336     NSRect s_rc = superFrame;                                               \
00337     s_rc.origin.x = x_offset;                                               \
00338     s_rc.origin.y = my_y_offset;                                            \
00339     s_rc.size.height = 23;                                                  \
00340     s_rc.size.width = 23;                                                   \
00341     o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain];           \
00342     [o_stepper setFont:[NSFont systemFontOfSize:0]];                        \
00343     [o_stepper setToolTip: tooltip];                                        \
00344     [o_stepper setMaxValue: higher];                                        \
00345     [o_stepper setMinValue: lower];                                         \
00346     [o_stepper setTarget: self];                                            \
00347     [o_stepper setAction: @selector(stepperChanged:)];                      \
00348     [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |       \
00349         NSLeftMouseDraggedMask];                                            \
00350 }
00351 
00352 #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width,  \
00353     tooltip, lower, higher )                                                \
00354 {                                                                           \
00355     NSRect s_rc = superFrame;                                               \
00356     s_rc.origin.x = x_offset;                                               \
00357     s_rc.origin.y = my_y_offset;                                            \
00358     s_rc.size.height = 21;                                                  \
00359     s_rc.size.width = my_width;                                             \
00360     o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain];             \
00361     [o_slider setFont:[NSFont systemFontOfSize:0]];                         \
00362     [o_slider setToolTip: tooltip];                                         \
00363     [o_slider setMaxValue: higher];                                         \
00364     [o_slider setMinValue: lower];                                          \
00365 }
00366 
00367 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
00368     tooltip, init_value, position )                                         \
00369 {                                                                           \
00370     NSRect s_rc = superFrame;                                               \
00371     s_rc.size.height = 18;                                                  \
00372     s_rc.origin.x = x_offset - 2;                                           \
00373     s_rc.origin.y = superFrame.size.height - 18 + my_y_offset;              \
00374     o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain];           \
00375     [o_checkbox setFont:[NSFont systemFontOfSize:0]];                       \
00376     [o_checkbox setButtonType: NSSwitchButton];                             \
00377     [o_checkbox setImagePosition: position];                                \
00378     [o_checkbox setIntValue: init_value];                                   \
00379     [o_checkbox setTitle: label];                                           \
00380     [o_checkbox setToolTip: tooltip];                                       \
00381     [o_checkbox sizeToFit];                                                 \
00382 }
00383 
00384 @implementation VLCConfigControl
00385 - (id)initWithFrame: (NSRect)frame
00386 {
00387     return [self initWithFrame: frame
00388                     item: nil];
00389 }
00390 
00391 - (id)initWithFrame: (NSRect)frame
00392         item: (module_config_t *)_p_item
00393 {
00394     self = [super initWithFrame: frame];
00395 
00396     if( self != nil )
00397     {
00398         p_item = _p_item;
00399         psz_name = strdup( p_item->psz_name );
00400         o_label = NULL;
00401         i_type = p_item->i_type;
00402         i_view_type = 0;
00403         b_advanced = p_item->b_advanced;
00404         [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
00405     }
00406     return (self);
00407 }
00408 
00409 - (void)setYPos:(int)i_yPos
00410 {
00411     NSRect frame = [self frame];
00412     frame.origin.y = i_yPos;
00413     [self setFrame:frame];
00414 }
00415 
00416 - (void)dealloc
00417 {
00418     if( o_label ) [o_label release];
00419     if( psz_name ) free( psz_name );
00420     [super dealloc];
00421 }
00422 
00423 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
00424 {
00425     int i_margin;
00426     switch( i_curItem )
00427     {
00428     case CONFIG_ITEM_STRING:
00429         switch( i_lastItem )
00430         {
00431         case CONFIG_ITEM_STRING:
00432             i_margin = 8;
00433             break;
00434         case CONFIG_ITEM_STRING_LIST:
00435             i_margin = 7;
00436             break;
00437         case CONFIG_ITEM_FILE:
00438             i_margin = 8;
00439             break;
00440         case CONFIG_ITEM_MODULE:
00441             i_margin = 4;
00442             break;
00443         case CONFIG_ITEM_INTEGER:
00444             i_margin = 7;
00445             break;
00446         case CONFIG_ITEM_RANGED_INTEGER:
00447             i_margin = 5;
00448             break;
00449         case CONFIG_ITEM_BOOL:
00450             i_margin = 7;
00451             break;
00452         case CONFIG_ITEM_KEY_BEFORE_10_3:
00453             i_margin = 7;
00454             break;
00455         case CONFIG_ITEM_KEY_AFTER_10_3:
00456             i_margin = 6;
00457             break;
00458         case CONFIG_ITEM_MODULE_LIST:
00459             i_margin = 8;
00460             break;
00461         default:
00462             i_margin = 20;
00463             break;
00464         }
00465         break;
00466     case CONFIG_ITEM_STRING_LIST:
00467         switch( i_lastItem )
00468         {
00469         case CONFIG_ITEM_STRING:
00470             i_margin = 8;
00471             break;
00472         case CONFIG_ITEM_STRING_LIST:
00473             i_margin = 7;
00474             break;
00475         case CONFIG_ITEM_FILE:
00476             i_margin = 6;
00477             break;
00478         case CONFIG_ITEM_MODULE:
00479             i_margin = 4;
00480             break;
00481         case CONFIG_ITEM_INTEGER:
00482             i_margin = 7;
00483             break;
00484         case CONFIG_ITEM_RANGED_INTEGER:
00485             i_margin = 5;
00486             break;
00487         case CONFIG_ITEM_BOOL:
00488             i_margin = 7;
00489             break;
00490         case CONFIG_ITEM_KEY_BEFORE_10_3:
00491             i_margin = 7;
00492             break;
00493         case CONFIG_ITEM_KEY_AFTER_10_3:
00494             i_margin = 6;
00495             break;
00496         case CONFIG_ITEM_MODULE_LIST:
00497             i_margin = 8;
00498             break;
00499         default:
00500             i_margin = 20;
00501             break;
00502         }
00503         break;
00504     case CONFIG_ITEM_FILE:
00505         switch( i_lastItem )
00506         {
00507         case CONFIG_ITEM_STRING:
00508             i_margin = 13;
00509             break;
00510         case CONFIG_ITEM_STRING_LIST:
00511             i_margin = 10;
00512             break;
00513         case CONFIG_ITEM_FILE:
00514             i_margin = 9;
00515             break;
00516         case CONFIG_ITEM_MODULE:
00517             i_margin = 9;
00518             break;
00519         case CONFIG_ITEM_INTEGER:
00520             i_margin = 10;
00521             break;
00522         case CONFIG_ITEM_RANGED_INTEGER:
00523             i_margin = 8;
00524             break;
00525         case CONFIG_ITEM_BOOL:
00526             i_margin = 10;
00527             break;
00528         case CONFIG_ITEM_KEY_BEFORE_10_3:
00529             i_margin = 10;
00530             break;
00531         case CONFIG_ITEM_KEY_AFTER_10_3:
00532             i_margin = 9;
00533             break;
00534         case CONFIG_ITEM_MODULE_LIST:
00535             i_margin = 11;
00536             break;
00537         default:
00538             i_margin = 23;
00539             break;
00540         }
00541         break;
00542     case CONFIG_ITEM_MODULE:
00543         switch( i_lastItem )
00544         {
00545         case CONFIG_ITEM_STRING:
00546             i_margin = 8;
00547             break;
00548         case CONFIG_ITEM_STRING_LIST:
00549             i_margin = 7;
00550             break;
00551         case CONFIG_ITEM_FILE:
00552             i_margin = 6;
00553             break;
00554         case CONFIG_ITEM_MODULE:
00555             i_margin = 5;
00556             break;
00557         case CONFIG_ITEM_INTEGER:
00558             i_margin = 7;
00559             break;
00560         case CONFIG_ITEM_RANGED_INTEGER:
00561             i_margin = 6;
00562             break;
00563         case CONFIG_ITEM_BOOL:
00564             i_margin = 8;
00565             break;
00566         case CONFIG_ITEM_KEY_BEFORE_10_3:
00567             i_margin = 8;
00568             break;
00569         case CONFIG_ITEM_KEY_AFTER_10_3:
00570             i_margin = 7;
00571             break;
00572         case CONFIG_ITEM_MODULE_LIST:
00573             i_margin = 9;
00574             break;
00575         default:
00576             i_margin = 20;
00577             break;
00578         }
00579         break;
00580     case CONFIG_ITEM_INTEGER:
00581         switch( i_lastItem )
00582         {
00583         case CONFIG_ITEM_STRING:
00584             i_margin = 8;
00585             break;
00586         case CONFIG_ITEM_STRING_LIST:
00587             i_margin = 7;
00588             break;
00589         case CONFIG_ITEM_FILE:
00590             i_margin = 6;
00591             break;
00592         case CONFIG_ITEM_MODULE:
00593             i_margin = 4;
00594             break;
00595         case CONFIG_ITEM_INTEGER:
00596             i_margin = 7;
00597             break;
00598         case CONFIG_ITEM_RANGED_INTEGER:
00599             i_margin = 5;
00600             break;
00601         case CONFIG_ITEM_BOOL:
00602             i_margin = 7;
00603             break;
00604         case CONFIG_ITEM_KEY_BEFORE_10_3:
00605             i_margin = 7;
00606             break;
00607         case CONFIG_ITEM_KEY_AFTER_10_3:
00608             i_margin = 6;
00609             break;
00610         case CONFIG_ITEM_MODULE_LIST:
00611             i_margin = 8;
00612             break;
00613         default:
00614             i_margin = 20;
00615             break;
00616         }
00617         break;
00618     case CONFIG_ITEM_RANGED_INTEGER:
00619         switch( i_lastItem )
00620         {
00621         case CONFIG_ITEM_STRING:
00622             i_margin = 8;
00623             break;
00624         case CONFIG_ITEM_STRING_LIST:
00625             i_margin = 7;
00626             break;
00627         case CONFIG_ITEM_FILE:
00628             i_margin = 8;
00629             break;
00630         case CONFIG_ITEM_MODULE:
00631             i_margin = 4;
00632             break;
00633         case CONFIG_ITEM_INTEGER:
00634             i_margin = 7;
00635             break;
00636         case CONFIG_ITEM_RANGED_INTEGER:
00637             i_margin = 5;
00638             break;
00639         case CONFIG_ITEM_BOOL:
00640             i_margin = 7;
00641             break;
00642         case CONFIG_ITEM_KEY_BEFORE_10_3:
00643             i_margin = 7;
00644             break;
00645         case CONFIG_ITEM_KEY_AFTER_10_3:
00646             i_margin = 6;
00647             break;
00648         case CONFIG_ITEM_MODULE_LIST:
00649             i_margin = 8;
00650             break;
00651         default:
00652             i_margin = 20;
00653             break;
00654         }
00655         break;
00656     case CONFIG_ITEM_BOOL:
00657         switch( i_lastItem )
00658         {
00659         case CONFIG_ITEM_STRING:
00660             i_margin = 10;
00661             break;
00662         case CONFIG_ITEM_STRING_LIST:
00663             i_margin = 9;
00664             break;
00665         case CONFIG_ITEM_FILE:
00666             i_margin = 8;
00667             break;
00668         case CONFIG_ITEM_MODULE:
00669             i_margin = 6;
00670             break;
00671         case CONFIG_ITEM_INTEGER:
00672             i_margin = 9;
00673             break;
00674         case CONFIG_ITEM_RANGED_INTEGER:
00675             i_margin = 7;
00676             break;
00677         case CONFIG_ITEM_BOOL:
00678             i_margin = 7;
00679             break;
00680         case CONFIG_ITEM_KEY_BEFORE_10_3:
00681             i_margin = 7;
00682             break;
00683         case CONFIG_ITEM_KEY_AFTER_10_3:
00684             i_margin = 5;
00685             break;
00686         case CONFIG_ITEM_MODULE_LIST:
00687             i_margin = 10;
00688             break;
00689         default:
00690             i_margin = 20;
00691             break;
00692         }
00693         break;
00694     case CONFIG_ITEM_KEY_BEFORE_10_3:
00695         switch( i_lastItem )
00696         {
00697         case CONFIG_ITEM_STRING:
00698             i_margin = 6;
00699             break;
00700         case CONFIG_ITEM_STRING_LIST:
00701             i_margin = 5;
00702             break;
00703         case CONFIG_ITEM_FILE:
00704             i_margin = 4;
00705             break;
00706         case CONFIG_ITEM_MODULE:
00707             i_margin = 2;
00708             break;
00709         case CONFIG_ITEM_INTEGER:
00710             i_margin = 5;
00711             break;
00712         case CONFIG_ITEM_RANGED_INTEGER:
00713             i_margin = 3;
00714             break;
00715         case CONFIG_ITEM_BOOL:
00716             i_margin = 3;
00717             break;
00718         case CONFIG_ITEM_KEY_BEFORE_10_3:
00719             i_margin = 10;
00720             break;
00721         case CONFIG_ITEM_KEY_AFTER_10_3:
00722             i_margin = 6;
00723             break;
00724         case CONFIG_ITEM_MODULE_LIST:
00725             i_margin = 6;
00726             break;
00727         default:
00728             i_margin = 18;
00729             break;
00730         }
00731         break;
00732     case CONFIG_ITEM_KEY_AFTER_10_3:
00733         switch( i_lastItem )
00734         {
00735         case CONFIG_ITEM_STRING:
00736             i_margin = 8;
00737             break;
00738         case CONFIG_ITEM_STRING_LIST:
00739             i_margin = 7;
00740             break;
00741         case CONFIG_ITEM_FILE:
00742             i_margin = 6;
00743             break;
00744         case CONFIG_ITEM_MODULE:
00745             i_margin = 6;
00746             break;
00747         case CONFIG_ITEM_INTEGER:
00748             i_margin = 7;
00749             break;
00750         case CONFIG_ITEM_RANGED_INTEGER:
00751             i_margin = 5;
00752             break;
00753         case CONFIG_ITEM_BOOL:
00754             i_margin = 7;
00755             break;
00756         case CONFIG_ITEM_KEY_BEFORE_10_3:
00757             i_margin = 7;
00758             break;
00759         case CONFIG_ITEM_KEY_AFTER_10_3:
00760             i_margin = 8;
00761             break;
00762         case CONFIG_ITEM_MODULE_LIST:
00763             i_margin = 10;
00764             break;
00765         default:
00766             i_margin = 20;
00767             break;
00768         }
00769         break;
00770     case CONFIG_ITEM_MODULE_LIST:
00771         switch( i_lastItem )
00772         {
00773         case CONFIG_ITEM_STRING:
00774             i_margin = 10;
00775             break;
00776         case CONFIG_ITEM_STRING_LIST:
00777             i_margin = 7;
00778             break;
00779         case CONFIG_ITEM_FILE:
00780             i_margin = 6;
00781             break;
00782         case CONFIG_ITEM_MODULE:
00783             i_margin = 6;
00784             break;
00785         case CONFIG_ITEM_INTEGER:
00786             i_margin = 9;
00787             break;
00788         case CONFIG_ITEM_RANGED_INTEGER:
00789             i_margin = 5;
00790             break;
00791         case CONFIG_ITEM_BOOL:
00792             i_margin = 7;
00793             break;
00794         case CONFIG_ITEM_KEY_BEFORE_10_3:
00795             i_margin = 7;
00796             break;
00797         case CONFIG_ITEM_KEY_AFTER_10_3:
00798             i_margin = 5;
00799             break;
00800         case CONFIG_ITEM_MODULE_LIST:
00801             i_margin = 8;
00802             break;
00803         default:
00804             i_margin = 20;
00805             break;
00806         }
00807         break;
00808     default:
00809         i_margin = 20;
00810         break;
00811     }
00812     return i_margin;
00813 }
00814 
00815 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
00816                       withView: (NSView *)o_parent_view
00817 {
00818     VLCConfigControl *p_control = NULL;
00819     /* Skip depracated options */
00820     if( _p_item->psz_current )
00821     {
00822         return NULL;
00823     }
00824 
00825     switch( _p_item->i_type )
00826     {
00827     case CONFIG_ITEM_STRING:
00828         if( !_p_item->i_list )
00829         {
00830             p_control = [[StringConfigControl alloc]
00831                     initWithItem: _p_item
00832                     withView: o_parent_view];
00833         }
00834         else
00835         {
00836             p_control = [[StringListConfigControl alloc]
00837                     initWithItem: _p_item
00838                     withView: o_parent_view];
00839         }
00840         break;
00841     case CONFIG_ITEM_FILE:
00842     case CONFIG_ITEM_DIRECTORY:
00843         p_control = [[FileConfigControl alloc]
00844                     initWithItem: _p_item
00845                     withView: o_parent_view];
00846         break;
00847     case CONFIG_ITEM_MODULE:
00848     case CONFIG_ITEM_MODULE_CAT:
00849         p_control = [[ModuleConfigControl alloc]
00850                     initWithItem: _p_item
00851                     withView: o_parent_view];
00852         break;
00853     case CONFIG_ITEM_INTEGER:
00854         if( _p_item->i_list )
00855         {
00856             p_control = [[IntegerListConfigControl alloc]
00857                         initWithItem: _p_item
00858                         withView: o_parent_view];
00859         }
00860         else if( _p_item->i_min != 0 || _p_item->i_max != 0 )
00861         {
00862             p_control = [[RangedIntegerConfigControl alloc]
00863                         initWithItem: _p_item
00864                         withView: o_parent_view];
00865         }
00866         else
00867         {
00868             p_control = [[IntegerConfigControl alloc]
00869                         initWithItem: _p_item
00870                         withView: o_parent_view];
00871         }
00872         break;
00873     case CONFIG_ITEM_BOOL:
00874         p_control = [[BoolConfigControl alloc]
00875                     initWithItem: _p_item
00876                     withView: o_parent_view];
00877         break;
00878     case CONFIG_ITEM_FLOAT:
00879         if( _p_item->f_min != 0 || _p_item->f_max != 0 )
00880         {
00881             p_control = [[RangedFloatConfigControl alloc]
00882                         initWithItem: _p_item
00883                         withView: o_parent_view];
00884         }
00885         else
00886         {
00887             p_control = [[FloatConfigControl alloc]
00888                         initWithItem: _p_item
00889                         withView: o_parent_view];
00890         }
00891         break;
00892     case CONFIG_ITEM_KEY:
00893         if( MACOS_VERSION < 10.3 )
00894         {
00895             p_control = [[KeyConfigControlBefore103 alloc]
00896                         initWithItem: _p_item
00897                         withView: o_parent_view];
00898         }
00899         else
00900         {
00901             p_control = [[KeyConfigControlAfter103 alloc]
00902                         initWithItem: _p_item
00903                         withView: o_parent_view];
00904         }
00905         break;
00906     case CONFIG_ITEM_MODULE_LIST:
00907     case CONFIG_ITEM_MODULE_LIST_CAT:
00908         p_control = [[ModuleListConfigControl alloc]
00909                     initWithItem: _p_item
00910                     withView: o_parent_view];
00911         break;
00912     default:
00913         break;
00914     }
00915     return p_control;
00916 }
00917 
00918 - (NSString *)getName
00919 {
00920     return [[VLCMain sharedInstance] localizedString: psz_name];
00921 }
00922 
00923 - (int)getType
00924 {
00925     return i_type;
00926 }
00927 
00928 - (int)getViewType
00929 {
00930     return i_view_type;
00931 }
00932 
00933 - (BOOL)isAdvanced
00934 {
00935     return b_advanced;
00936 }
00937 
00938 - (int)intValue
00939 {
00940     return 0;
00941 }
00942 
00943 - (float)floatValue
00944 {
00945     return 0;
00946 }
00947 
00948 - (char *)stringValue
00949 {
00950     return NULL;
00951 }
00952 
00953 - (void)applyChanges
00954 {
00955     vlc_value_t val;
00956     switch( p_item->i_type )
00957     {
00958     case CONFIG_ITEM_STRING:
00959     case CONFIG_ITEM_FILE:
00960     case CONFIG_ITEM_DIRECTORY:
00961     case CONFIG_ITEM_MODULE:
00962     case CONFIG_ITEM_MODULE_LIST:
00963     case CONFIG_ITEM_MODULE_LIST_CAT:
00964         config_PutPsz( VLCIntf, psz_name, [self stringValue] );
00965         break;
00966     case CONFIG_ITEM_KEY:
00967         /* So you don't need to restart to have the changes take effect */
00968         val.i_int = [self intValue];
00969         var_Set( VLCIntf->p_vlc, psz_name, val );
00970     case CONFIG_ITEM_INTEGER:
00971     case CONFIG_ITEM_BOOL:
00972         config_PutInt( VLCIntf, psz_name, [self intValue] );
00973         break;
00974     case CONFIG_ITEM_FLOAT:
00975         config_PutFloat( VLCIntf, psz_name, [self floatValue] );
00976         break;
00977     }
00978 }
00979 
00980 - (int)getLabelSize
00981 {
00982     return [o_label frame].size.width;
00983 }
00984 
00985 - (void) alignWithXPosition:(int)i_xPos;
00986 {
00987     /* FIXME: not implemented atm, but created to shut up the warning
00988      * about "method definition not found" -- FK @ 7/24/05 */
00989 }
00990 @end
00991 
00992 @implementation StringConfigControl
00993 - (id) initWithItem: (module_config_t *)_p_item
00994            withView: (NSView *)o_parent_view
00995 {
00996     NSRect mainFrame = [o_parent_view frame];
00997     NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
00998     mainFrame.size.height = 22;
00999     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
01000     mainFrame.origin.x = LEFTMARGIN;
01001     mainFrame.origin.y = 0;
01002 
01003     if( [super initWithFrame: mainFrame item: _p_item] != nil )
01004     {
01005         i_view_type = CONFIG_ITEM_STRING;
01006         /* add the label */
01007         if( p_item->psz_text )
01008             o_labelString = [[VLCMain sharedInstance]
01009                                 localizedString: p_item->psz_text];
01010         else
01011             o_labelString = [NSString stringWithString:@""];
01012         ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
01013         [o_label setAutoresizingMask:NSViewNotSizable ];
01014         [self addSubview: o_label];
01015 
01016         /* build the textfield */
01017         o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
01018             [[VLCMain sharedInstance] localizedString: p_item->psz_longtext]
01019                                          toWidth: PREFS_WRAP];
01020         if( p_item->psz_value )
01021             o_textfieldString = [[VLCMain sharedInstance]
01022                                     localizedString: p_item->psz_value];
01023         else
01024             o_textfieldString = [NSString stringWithString: @""];
01025         ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
01026                         0, mainFrame.size.width - [o_label frame].size.width -
01027                         2, o_textfieldTooltip, o_textfieldString )
01028         [o_textfield setAutoresizingMask:NSViewWidthSizable ];
01029         [self addSubview: o_textfield];
01030     }
01031     return self;
01032 }
01033 
01034 - (void) alignWithXPosition:(int)i_xPos
01035 {
01036     NSRect frame;
01037     NSRect superFrame = [self frame];
01038     frame = [o_label frame];
01039     frame.origin.x = i_xPos - frame.size.width - 3;
01040     [o_label setFrame:frame];
01041 
01042     frame = [o_textfield frame];
01043     frame.origin.x = i_xPos + 2;
01044     frame.size.width = superFrame.size.width - frame.origin.x - 1;
01045     [o_textfield setFrame:frame];
01046 }
01047 
01048 - (void)dealloc
01049 {
01050     [o_textfield release];
01051     [super dealloc];
01052 }
01053 
01054 - (char *)stringValue
01055 {
01056     return strdup( [[VLCMain sharedInstance] delocalizeString:
01057                         [o_textfield stringValue]] );
01058 }
01059 @end
01060 
01061 @implementation StringListConfigControl
01062 - (id) initWithItem: (module_config_t *)_p_item
01063            withView: (NSView *)o_parent_view
01064 {
01065     NSRect mainFrame = [o_parent_view frame];
01066     NSString *o_labelString, *o_textfieldTooltip;
01067     mainFrame.size.height = 22;
01068     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
01069     mainFrame.origin.x = LEFTMARGIN;
01070     mainFrame.origin.y = 0;
01071 
01072     if( [super initWithFrame: mainFrame item: _p_item] != nil )
01073     {
01074         int i_index;
01075         i_view_type = CONFIG_ITEM_STRING_LIST;
01076         /* add the label */
01077         if( p_item->psz_text )
01078             o_labelString = [[VLCMain sharedInstance]
01079                                 localizedString: p_item->psz_text];
01080         else
01081             o_labelString = [NSString stringWithString:@""];
01082         ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
01083         [o_label setAutoresizingMask:NSViewNotSizable ];
01084         [self addSubview: o_label];
01085 
01086         /* build the textfield */
01087         o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
01088             [[VLCMain sharedInstance]
01089                 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
01090         ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
01091             -2, 0, o_textfieldTooltip )
01092         [o_combo setAutoresizingMask:NSViewWidthSizable ];
01093         for( i_index = 0; i_index < p_item->i_list; i_index++ )
01094             if( p_item->psz_value &&
01095                 !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) )
01096                 [o_combo selectItemAtIndex: i_index];
01097         [self addSubview: o_combo];
01098     }
01099     return self;
01100 }
01101 
01102 - (void) alignWithXPosition:(int)i_xPos
01103 {
01104     NSRect frame;
01105     NSRect superFrame = [self frame];
01106     frame = [o_label frame];
01107     frame.origin.x = i_xPos - frame.size.width - 3;
01108     [o_label setFrame:frame];
01109 
01110     frame = [o_combo frame];
01111     frame.origin.x = i_xPos + 2;
01112     frame.size.width = superFrame.size.width - frame.origin.x + 2;
01113     [o_combo setFrame:frame];
01114 }
01115 
01116 - (void)dealloc
01117 {
01118     [o_combo release];
01119     [super dealloc];
01120 }
01121 
01122 - (char *)stringValue
01123 {
01124     if( [o_combo indexOfSelectedItem] >= 0 )
01125         return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
01126     else
01127         return strdup( [[VLCMain sharedInstance]
01128                             delocalizeString: [o_combo stringValue]] );
01129 }
01130 @end
01131 
01132 @implementation StringListConfigControl (NSComboBoxDataSource)
01133 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
01134 {
01135         return p_item->i_list;
01136 }
01137 
01138 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
01139 {
01140     if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
01141     {
01142         return [[VLCMain sharedInstance]
01143                     localizedString: p_item->ppsz_list_text[i_index]];
01144     } else return [[VLCMain sharedInstance]
01145                     localizedString: p_item->ppsz_list[i_index]];
01146 }
01147 @end
01148 
01149 @implementation FileConfigControl
01150 - (id) initWithItem: (module_config_t *)_p_item
01151            withView: (NSView *)o_parent_view
01152 {
01153     NSRect mainFrame = [o_parent_view frame];
01154     NSString *o_labelString, *o_buttonTooltip, *o_textfieldString;
01155     NSString *o_textfieldTooltip;
01156     mainFrame.size.height = 46;
01157     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
01158     mainFrame.origin.x = LEFTMARGIN;
01159     mainFrame.origin.y = 0;
01160 
01161     if( [super initWithFrame: mainFrame item: _p_item] != nil )
01162     {
01163         i_view_type = CONFIG_ITEM_FILE;
01164 
01165         /* is it a directory */
01166         b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
01167 
01168         /* add the label */
01169         if( p_item->psz_text )
01170             o_labelString = [[VLCMain sharedInstance]
01171                                 localizedString: p_item->psz_text];
01172         else
01173             o_labelString = [NSString stringWithString:@""];
01174         ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString )
01175         [o_label setAutoresizingMask:NSViewNotSizable ];
01176         [self addSubview: o_label];
01177 
01178         /* build the button */
01179         o_buttonTooltip = [[VLCMain sharedInstance]
01180                 wrapString: [[VLCMain sharedInstance]
01181                 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
01182         ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_buttonTooltip,
01183                             _NS("Browse...") )
01184         [o_button setAutoresizingMask:NSViewMinXMargin ];
01185         [self addSubview: o_button];
01186 
01187         /* build the textfield */
01188         o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
01189             [[VLCMain sharedInstance]
01190                 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
01191         if( p_item->psz_value )
01192             o_textfieldString = [[VLCMain sharedInstance]
01193                                     localizedString: p_item->psz_value];
01194         else
01195             o_textfieldString = [NSString stringWithString: @""];
01196         ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
01197                         8 - [o_button frame].size.width,
01198                         o_textfieldTooltip, o_textfieldString )
01199         [o_textfield setAutoresizingMask:NSViewWidthSizable ];
01200         [self addSubview: o_textfield];
01201     }
01202     return self;
01203 }
01204 
01205 - (void) alignWithXPosition:(int)i_xPos
01206 {
01207     ;
01208 }
01209 
01210 - (void)dealloc
01211 {
01212     [o_textfield release];
01213     [o_button release];
01214     [super dealloc];
01215 }
01216 
01217 - (IBAction)openFileDialog: (id)sender
01218 {
01219     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
01220 
01221     [o_open_panel setTitle: (b_directory)?
01222         _NS("Select a directory"):_NS("Select a file")];
01223     [o_open_panel setPrompt: _NS("Select")];
01224     [o_open_panel setAllowsMultipleSelection: NO];
01225     [o_open_panel setCanChooseFiles: !b_directory];
01226     [o_open_panel setCanChooseDirectories: b_directory];
01227     [o_open_panel beginSheetForDirectory:nil
01228         file:nil
01229         types:nil
01230         modalForWindow:[sender window]
01231         modalDelegate: self
01232         didEndSelector: @selector(pathChosenInPanel: 
01233                         withReturn:
01234                         contextInfo:)
01235         contextInfo: nil];
01236 }
01237 
01238 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
01239     withReturn:(int)i_return_code contextInfo:(void  *)o_context_info
01240 {
01241     if( i_return_code == NSOKButton )
01242     {
01243         NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
01244         [o_textfield setStringValue: o_path];
01245     }
01246 }
01247 
01248 - (char *)stringValue
01249 {
01250     if( [[o_textfield stringValue] length] != 0)
01251         return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
01252     else
01253         return NULL;
01254 }
01255 @end
01256 
01257 @implementation ModuleConfigControl
01258 - (id) initWithItem: (module_config_t *)_p_item
01259            withView: (NSView *)o_parent_view
01260 {
01261     NSRect mainFrame = [o_parent_view frame];
01262     NSString *o_labelString, *o_popupTooltip;
01263     mainFrame.size.height = 22;
01264     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
01265     mainFrame.origin.x = LEFTMARGIN;
01266     mainFrame.origin.y = 0;
01267 
01268     if( [super initWithFrame: mainFrame item: _p_item] != nil )
01269     {
01270         int i_index;
01271         vlc_list_t *p_list;
01272         module_t *p_parser;
01273         i_view_type = CONFIG_ITEM_MODULE;
01274 
01275         /* add the label */
01276         if( p_item->psz_text )
01277             o_labelString = [[VLCMain sharedInstance]
01278                                 localizedString: p_item->psz_text];
01279         else
01280             o_labelString = [NSString stringWithString:@""];
01281         ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
01282         [o_label setAutoresizingMask:NSViewNotSizable ];
01283         [self addSubview: o_label];
01284 
01285         /* build the popup */
01286         o_popupTooltip = [[VLCMain sharedInstance] wrapString:
01287             [[VLCMain sharedInstance]
01288                 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
01289         ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
01290             -2, 0, o_popupTooltip )
01291         [o_popup setAutoresizingMask:NSViewWidthSizable ];
01292         [o_popup addItemWithTitle: _NS("Default")];
01293         [[o_popup lastItem] setTag: -1];
01294         [o_popup selectItem: [o_popup lastItem]];
01295 
01296         /* build a list of available modules */
01297         p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
01298         for( i_index = 0; i_index < p_list->i_count; i_index++ )
01299         {
01300             p_parser = (module_t *)p_list->p_values[i_index].p_object ;
01301             if( p_item->i_type == CONFIG_ITEM_MODULE )
01302             {
01303                 if( !strcmp( p_parser->psz_capability,
01304                             p_item->psz_type ) )
01305                 {
01306                     NSString *o_description = [[VLCMain sharedInstance]
01307                         localizedString: p_parser->psz_longname];
01308                     [o_popup addItemWithTitle: o_description];
01309 
01310                     if( p_item->psz_value &&
01311                 !strcmp( p_item->psz_value, p_parser->psz_object_name ) )
01312                         [o_popup selectItem:[o_popup lastItem]];
01313                 }
01314             }
01315             else
01316             {
01317                 module_config_t *p_config;
01318                 if( !strcmp( p_parser->psz_object_name, "main" ) )
01319                       continue;
01320 
01321                 p_config = p_parser->p_config;
01322                 if( p_config ) do
01323                 {
01324                     /* Hack: required subcategory is stored in i_min */
01325                     if( p_config->i_type == CONFIG_SUBCATEGORY &&
01326                         p_config->i_value == p_item->i_min )
01327                     {
01328                         NSString *o_description = [[VLCMain sharedInstance]
01329                             localizedString: p_parser->psz_longname];
01330                         [o_popup addItemWithTitle: o_description];
01331 
01332                         if( p_item->psz_value && !strcmp(p_item->psz_value,
01333                                                 p_parser->psz_object_name) )
01334                             [o_popup selectItem:[o_popup lastItem]];
01335                     }
01336                 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
01337             }
01338         }
01339         vlc_list_release( p_list );
01340         [self addSubview: o_popup];
01341     }
01342     return self;
01343 }
01344 
01345 - (void) alignWithXPosition:(int)i_xPos
01346 {
01347     NSRect frame;
01348     NSRect superFrame = [self frame];
01349     frame = [o_label frame];
01350     frame.origin.x = i_xPos - frame.size.width - 3;
01351     [o_label setFrame:frame];
01352 
01353     frame = [o_popup frame];
01354     frame.origin.x = i_xPos - 1;
01355     frame.size.width = superFrame.size.width - frame.origin.x + 2;
01356     [o_popup setFrame:frame];
01357 }
01358 
01359 - (void)dealloc
01360 {
01361     [o_popup release];
01362     [super dealloc];
01363 }
01364 
01365 - (char *)stringValue
01366 {
01367     NSString *newval = [o_popup titleOfSelectedItem];
01368     char *returnval = NULL;
01369     int i_index;
01370     vlc_list_t *p_list;
01371     module_t *p_parser;
01372 
01373     p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
01374     for( i_index = 0; i_index < p_list->i_count; i_index++ )
01375     {
01376         p_parser = (module_t *)p_list->p_values[i_index].p_object ;
01377         if( p_item->i_type == CONFIG_ITEM_MODULE )
01378         {
01379             if( !strcmp( p_parser->psz_capability,
01380                     p_item->psz_type ) )
01381             {
01382                 NSString *o_description = [[VLCMain sharedInstance]
01383                     localizedString: p_parser->psz_longname];
01384                 if( [newval isEqualToString: o_description] )
01385                 {
01386                     returnval = strdup(p_parser->psz_object_name);
01387                     break;
01388                 }
01389             }
01390         }
01391         else
01392         {
01393             module_config_t *p_config;
01394             if( !strcmp( p_parser->psz_object_name, "main" ) )
01395                   continue;
01396 
01397             p_config = p_parser->p_config;
01398             if( p_config ) do
01399             {
01400                 /* Hack: required subcategory is stored in i_min */
01401                 if( p_config->i_type == CONFIG_SUBCATEGORY &&
01402                     p_config->i_value == p_item->i_min )
01403                 {
01404                     NSString *o_description = [[VLCMain sharedInstance]
01405                         localizedString: p_parser->psz_longname];
01406                     if( [newval isEqualToString: o_description] )
01407                     {
01408                         returnval = strdup(p_parser->psz_object_name);
01409                         break;
01410                     }
01411                 }
01412             } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
01413         }
01414     }
01415     vlc_list_release( p_list );
01416     return returnval;
01417 }
01418 @end
01419 
01420 @implementation IntegerConfigControl
01421 - (id) initWithItem: (module_config_t *)_p_item
01422            withView: (NSView *)o_parent_view
01423 {
01424     NSRect mainFrame = [o_parent_view frame];
01425     NSString *o_labelString, *o_tooltip, *o_textfieldString;
01426     mainFrame.size.height = 23;
01427     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
01428     mainFrame.origin.x = LEFTMARGIN;
01429     mainFrame.origin.y = 0;
01430 
01431     if( [super initWithFrame: mainFrame item: _p_item] != nil )
01432     {
01433         i_view_type = CONFIG_ITEM_INTEGER;
01434 
01435         o_tooltip = [[VLCMain sharedInstance] wrapString:
01436             [[VLCMain sharedInstance]
01437                 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
01438 
01439         /* add the label */
01440         if( p_item->psz_text )
01441             o_labelString = [[VLCMain sharedInstance]
01442                                 localizedString: p_item->psz_text];
01443         else
01444             o_labelString = [NSString stringWithString:@""];
01445         ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
01446         [o_label setAutoresizingMask:NSViewNotSizable ];
01447         [self addSubview: o_label];
01448 
01449         /* build the stepper */
01450         ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
01451             0, o_tooltip, -1600, 1600)
01452         [o_stepper setIntValue: p_item->i_value];
01453         [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
01454         [self addSubview: o_stepper];
01455 
01456         /* build the textfield */
01457         if( p_item->psz_value )
01458             o_textfieldString = [[VLCMain sharedInstance]
01459                                     localizedString: p_item->psz_value];
01460         else
01461             o_textfieldString = [NSString stringWithString: @""];
01462         ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
01463             1, 49, o_tooltip, @"" )
01464         [o_textfield setIntValue: p_item->i_value];
01465         [o_textfield setDelegate: self];
01466         [[NSNotificationCenter defaultCenter] addObserver: self
01467             selector: @selector(textfieldChanged:)
01468             name: NSControlTextDidChangeNotification
01469             object: o_textfield];
01470         [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
01471         [self addSubview: o_textfield];
01472     }
01473     return self;
01474 }
01475 
01476 - (void) alignWithXPosition:(int)i_xPos
01477 {
01478     NSRect frame;
01479     frame = [o_label frame];
01480     frame.origin.x = i_xPos - frame.size.width - 3;
01481     [o_label setFrame:frame];
01482 
01483     frame = [o_textfield frame];
01484     frame.origin.x = i_xPos + 2;
01485     [o_textfield setFrame:frame];
01486 
01487     frame = [o_stepper frame];
01488     frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
01489     [o_stepper setFrame:frame];
01490 }
01491 
01492 - (void)dealloc
01493 {
01494     [o_stepper release];
01495     [o_textfield release];
01496     [super dealloc];
01497 }
01498 
01499 - (IBAction)stepperChanged:(id)sender
01500 {
01501     [o_textfield setIntValue: [o_stepper intValue]];
01502 }
01503 
01504 - (void)textfieldChanged:(NSNotification *)o_notification
01505 {
01506     [o_stepper setIntValue: [o_textfield intValue]];
01507 }
01508 
01509 - (int)intValue
01510 {
01511     return [o_textfield intValue];
01512 }
01513 
01514 @end
01515 
01516 @implementation IntegerListConfigControl
01517 
01518 - (id) initWithItem: (module_config_t *)_p_item
01519            withView: (NSView *)o_parent_view
01520 {
01521     NSRect mainFrame = [o_parent_view frame];
01522     NSString *o_labelString, *o_textfieldTooltip;
01523     mainFrame.size.height = 22;
01524     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
01525     mainFrame.origin.x = LEFTMARGIN;
01526     mainFrame.origin.y = 0;
01527 
01528     if( [super initWithFrame: mainFrame item: _p_item] != nil )
01529     {
01530         int i_index;
01531         i_view_type = CONFIG_ITEM_STRING_LIST;
01532 
01533         /* add the label */
01534         if( p_item->psz_text )
01535             o_labelString = [[VLCMain sharedInstance]
01536                 localizedString: p_item->psz_text];
01537         else
01538             o_labelString = [NSString stringWithString:@""];
01539         ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
01540         [o_label setAutoresizingMask:NSViewNotSizable ];
01541         [self addSubview: o_label];
01542 
01543         /* build the textfield */
01544         o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
01545             [[VLCMain sharedInstance]
01546                 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
01547         ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
01548             -2, 0, o_textfieldTooltip )
01549         [o_combo setAutoresizingMask:NSViewWidthSizable ];
01550         for( i_index = 0; i_index < p_item->i_list; i_index++ )
01551         {
01552             if( p_item->i_value == p_item->pi_list[i_index] )
01553             {
01554                 [o_combo selectItemAtIndex: i_index];
01555             }
01556         }
01557         [self addSubview: o_combo];
01558     }
01559     return self;
01560 }
01561 
01562 - (void) alignWithXPosition:(int)i_xPos
01563 {
01564     NSRect frame;
01565     NSRect superFrame = [self frame];
01566     frame = [o_label frame];
01567     frame.origin.x = i_xPos - frame.size.width - 3;
01568     [o_label setFrame:frame];
01569 
01570     frame = [o_combo frame];
01571     frame.origin.x = i_xPos + 2;
01572     frame.size.width = superFrame.size.width - frame.origin.x + 2;
01573     [o_combo setFrame:frame];
01574 }
01575 
01576 - (void)dealloc
01577 {
01578     [o_combo release];
01579     [super dealloc];
01580 }
01581 
01582 - (int)intValue
01583 {
01584     if( [o_combo indexOfSelectedItem] >= 0 )
01585         return p_item->pi_list[[o_combo indexOfSelectedItem]];
01586     else
01587         return [o_combo intValue];
01588 }
01589 @end
01590 
01591 @implementation IntegerListConfigControl (NSComboBoxDataSource)
01592 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
01593 {
01594     return p_item->i_list;
01595 }
01596 
01597 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
01598 {
01599     if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
01600         return [[VLCMain sharedInstance]
01601                     localizedString: p_item->ppsz_list_text[i_index]];
01602     else
01603         return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
01604 }
01605 @end
01606 
01607 @implementation RangedIntegerConfigControl
01608 - (id) initWithItem: (module_config_t *)_p_item
01609            withView: (NSView *)o_parent_view
01610 {
01611     NSRect mainFrame = [o_parent_view frame];
01612     NSString *o_labelString, *o_tooltip;
01613     mainFrame.size.height = 50;
01614     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
01615     mainFrame.origin.x = LEFTMARGIN;
01616     mainFrame.origin.y = 0;
01617 
01618     if( [super initWithFrame: mainFrame item: _p_item] != nil )
01619     {
01620         i_view_type = CONFIG_ITEM_RANGED_INTEGER;
01621 
01622         /* add the label */
01623         if( p_item->psz_text )
01624             o_labelString = [[VLCMain sharedInstance]
01625                                 localizedString: p_item->psz_text];
01626         else
01627             o_labelString = [NSString stringWithString:@""];
01628         ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
01629         [o_label setAutoresizingMask:NSViewNotSizable ];
01630         [self addSubview: o_label];
01631 
01632         /* build the textfield */
01633         o_tooltip = [[VLCMain sharedInstance] wrapString:
01634             [[VLCMain sharedInstance]
01635                 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
01636         ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
01637             28, 49, o_tooltip, @"" )
01638         [o_textfield setIntValue: p_item->i_value];
01639         [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
01640         [o_textfield setDelegate: self];
01641         [[NSNotificationCenter defaultCenter] addObserver: self
01642             selector: @selector(textfieldChanged:)
01643             name: NSControlTextDidChangeNotification
01644             object: o_textfield];
01645         [self addSubview: o_textfield];
01646 
01647         /* build the mintextfield */
01648         ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
01649         [o_textfield_min setIntValue: p_item->i_min];
01650         [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
01651         [o_textfield_min setAlignment:NSRightTextAlignment];
01652         [self addSubview: o_textfield_min];
01653 
01654         /* build the maxtextfield */
01655         ADD_LABEL( o_textfield_max, mainFrame,
01656                     mainFrame.size.width - 31, -30, @"8888" )
01657         [o_textfield_max setIntValue: p_item->i_max];
01658         [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
01659         [self addSubview: o_textfield_max];
01660 
01661         /* build the slider */
01662         ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
01663             [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
01664             [o_textfield_max frame].size.width -
01665             [o_textfield_max frame].size.width - 14 -
01666             [o_textfield_min frame].origin.x, o_tooltip,
01667             p_item->i_min, p_item->i_max )
01668         [o_slider setIntValue: p_item->i_value];
01669         [o_slider setAutoresizingMask:NSViewWidthSizable ];
01670         [o_slider setTarget: self];
01671         [o_slider setAction: @selector(sliderChanged:)];
01672         [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
01673             NSLeftMouseDraggedMask];
01674         [self addSubview: o_slider];
01675 
01676     }
01677     return self;
01678 }
01679 
01680 - (void) alignWithXPosition:(int)i_xPos
01681 {
01682     NSRect frame;
01683     frame = [o_label frame];
01684     frame.origin.x = i_xPos - frame.size.width - 3;
01685     [o_label setFrame:frame];
01686 
01687     frame = [o_textfield frame];
01688     frame.origin.x = i_xPos + 2;
01689     [o_textfield setFrame:frame];
01690 }
01691 
01692 - (void)dealloc
01693 {
01694     [o_textfield release];
01695     [o_textfield_min release];
01696     [o_textfield_max release];
01697     [o_slider release];
01698     [super dealloc];
01699 }
01700 
01701 - (IBAction)sliderChanged:(id)sender
01702 {
01703     [o_textfield setIntValue: [o_slider intValue]];
01704 }
01705 
01706 - (void)textfieldChanged:(NSNotification *)o_notification
01707 {
01708     [o_slider setIntValue: [o_textfield intValue]];
01709 }
01710 
01711 - (int)intValue
01712 {
01713     return [o_slider intValue];
01714 }
01715 @end
01716 
01717 @implementation FloatConfigControl
01718 - (id) initWithItem: (module_config_t *)_p_item
01719            withView: (NSView *)o_parent_view
01720 {
01721     NSRect mainFrame = [o_parent_view frame];
01722     NSString *o_labelString, *o_tooltip, *o_textfieldString;
01723     mainFrame.size.height = 23;
01724     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
01725     mainFrame.origin.x = LEFTMARGIN;
01726     mainFrame.origin.y = 0;
01727 
01728     if( [super initWithFrame: mainFrame item: _p_item] != nil )
01729     {
01730         i_view_type = CONFIG_ITEM_INTEGER;
01731 
01732         o_tooltip = [[VLCMain sharedInstance] wrapString:
01733             [[VLCMain sharedInstance]
01734                 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
01735 
01736         /* add the label */
01737         if( p_item->psz_text )
01738             o_labelString = [[VLCMain sharedInstance]
01739                                 localizedString: p_item->psz_text];
01740         else
01741             o_labelString = [NSString stringWithString:@""];
01742         ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
01743         [o_label setAutoresizingMask:NSViewNotSizable ];
01744         [self addSubview: o_label];
01745 
01746         /* build the stepper */
01747         ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
01748             0, o_tooltip, -1600, 1600)
01749         [o_stepper setFloatValue: p_item->f_value];
01750         [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
01751         [self addSubview: o_stepper];
01752 
01753         /* build the textfield */
01754         if( p_item->psz_value )
01755             o_textfieldString = [[VLCMain sharedInstance]
01756                                     localizedString: p_item->psz_value];
01757         else
01758             o_textfieldString = [NSString stringWithString: @""];
01759         ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
01760             1, 49, o_tooltip, @"" )
01761         [o_textfield setFloatValue: p_item->f_value];
01762         [o_textfield setDelegate: self];
01763         [[NSNotificationCenter defaultCenter] addObserver: self
01764             selector: @selector(textfieldChanged:)
01765             name: NSControlTextDidChangeNotification
01766             object: o_textfield];
01767         [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
01768         [self addSubview: o_textfield];
01769     }
01770     return self;
01771 }
01772 
01773 - (void) alignWithXPosition:(int)i_xPos
01774 {
01775     NSRect frame;
01776     frame = [o_label frame];
01777     frame.origin.x = i_xPos - frame.size.width - 3;
01778     [o_label setFrame:frame];
01779 
01780     frame = [o_textfield frame];
01781     frame.origin.x = i_xPos + 2;
01782     [o_textfield setFrame:frame];
01783 
01784     frame = [o_stepper frame];
01785     frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
01786     [o_stepper setFrame:frame];
01787 }
01788 
01789 - (void)dealloc
01790 {
01791     [o_stepper release];
01792     [o_textfield release];
01793     [super dealloc];
01794 }
01795 
01796 - (IBAction)stepperChanged:(id)sender
01797 {
01798     [o_textfield setFloatValue: [o_stepper floatValue]];
01799 }
01800 
01801 - (void)textfieldChanged:(NSNotification *)o_notification
01802 {
01803     [o_stepper setFloatValue: [o_textfield floatValue]];
01804 }
01805 
01806 - (float)floatValue
01807 {
01808     return [o_stepper floatValue];
01809 }
01810 @end
01811 
01812 @implementation RangedFloatConfigControl
01813 - (id) initWithItem: (module_config_t *)_p_item
01814            withView: (NSView *)o_parent_view
01815 {
01816     NSRect mainFrame = [o_parent_view frame];
01817     NSString *o_labelString, *o_tooltip;
01818     mainFrame.size.height = 50;
01819     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
01820     mainFrame.origin.x = LEFTMARGIN;
01821     mainFrame.origin.y = 0;
01822 
01823     if( [super initWithFrame: mainFrame item: _p_item] != nil )
01824     {
01825         i_view_type = CONFIG_ITEM_RANGED_INTEGER;
01826 
01827         /* add the label */
01828         if( p_item->psz_text )
01829             o_labelString = [[VLCMain sharedInstance]
01830                                 localizedString: p_item->psz_text];
01831         else
01832             o_labelString = [NSString stringWithString:@""];
01833         ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
01834         [o_label setAutoresizingMask:NSViewNotSizable ];
01835         [self addSubview: o_label];
01836 
01837         /* build the textfield */
01838         o_tooltip = [[VLCMain sharedInstance] wrapString:
01839             [[VLCMain sharedInstance]
01840                 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
01841         ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
01842             28, 49, o_tooltip, @"" )
01843         [o_textfield setFloatValue: p_item->f_value];
01844         [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
01845         [o_textfield setDelegate: self];
01846         [[NSNotificationCenter defaultCenter] addObserver: self
01847             selector: @selector(textfieldChanged:)
01848             name: NSControlTextDidChangeNotification
01849             object: o_textfield];
01850         [self addSubview: o_textfield];
01851 
01852         /* build the mintextfield */
01853         ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
01854         [o_textfield_min setFloatValue: p_item->f_min];
01855         [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
01856         [o_textfield_min setAlignment:NSRightTextAlignment];
01857         [self addSubview: o_textfield_min];
01858 
01859         /* build the maxtextfield */
01860         ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
01861             -30, @"8888" )
01862         [o_textfield_max setFloatValue: p_item->f_max];
01863         [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
01864         [self addSubview: o_textfield_max];
01865 
01866         /* build the slider */
01867         ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
01868             [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
01869             [o_textfield_max frame].size.width -
01870             [o_textfield_max frame].size.width - 14 -
01871             [o_textfield_min frame].origin.x, o_tooltip, p_item->f_min,
01872             p_item->f_max )
01873         [o_slider setFloatValue: p_item->f_value];
01874         [o_slider setAutoresizingMask:NSViewWidthSizable ];
01875         [o_slider setTarget: self];
01876         [o_slider setAction: @selector(sliderChanged:)];
01877         [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
01878             NSLeftMouseDraggedMask];
01879         [self addSubview: o_slider];
01880 
01881     }
01882     return self;
01883 }
01884 
01885 - (void) alignWithXPosition:(int)i_xPos
01886 {
01887     NSRect frame;
01888     frame = [o_label frame];
01889     frame.origin.x = i_xPos - frame.size.width - 3;
01890     [o_label setFrame:frame];
01891 
01892     frame = [o_textfield frame];
01893     frame.origin.x = i_xPos + 2;
01894     [o_textfield setFrame:frame];
01895 }
01896 
01897 - (void)dealloc
01898 {
01899     [o_textfield release];
01900     [o_textfield_min release];
01901     [o_textfield_max release];
01902     [o_slider release];
01903     [super dealloc];
01904 }
01905 
01906 - (IBAction)sliderChanged:(id)sender
01907 {
01908     [o_textfield setFloatValue: [o_slider floatValue]];
01909 }
01910 
01911 - (void)textfieldChanged:(NSNotification *)o_notification
01912 {
01913     [o_slider setFloatValue: [o_textfield floatValue]];
01914 }
01915 
01916 - (float)floatValue
01917 {
01918     return [o_slider floatValue];
01919 }
01920 
01921 @end
01922 
01923 @implementation BoolConfigControl
01924 
01925 - (id) initWithItem: (module_config_t *)_p_item
01926            withView: (NSView *)o_parent_view
01927 {
01928     NSRect mainFrame = [o_parent_view frame];
01929     NSString *o_labelString, *o_tooltip;
01930     mainFrame.size.height = 17;
01931     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
01932     mainFrame.origin.x = LEFTMARGIN;
01933     mainFrame.origin.y = 0;
01934 
01935     if( [super initWithFrame: mainFrame item: _p_item] != nil )
01936     {
01937         i_view_type = CONFIG_ITEM_BOOL;
01938 
01939         /* add the checkbox */
01940         o_tooltip = [[VLCMain sharedInstance]
01941             wrapString: [[VLCMain sharedInstance]
01942             localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
01943         ADD_CHECKBOX( o_checkbox, mainFrame, 0,
01944                         0, @"", o_tooltip, p_item->i_value, NSImageLeft)
01945         [o_checkbox setAutoresizingMask:NSViewNotSizable ];
01946         [self addSubview: o_checkbox];
01947         /* add the label */
01948         if( p_item->psz_text )
01949             o_labelString = [[VLCMain sharedInstance]
01950                                 localizedString: p_item->psz_text];
01951         else
01952             o_labelString = [NSString stringWithString:@""];
01953         ADD_LABEL( o_label, mainFrame, [o_checkbox frame].size.width, 0, o_labelString )
01954         [o_label setAutoresizingMask:NSViewNotSizable ];
01955         [self addSubview: o_label];
01956     }
01957     return self;
01958 }
01959 
01960 - (void)dealloc
01961 {
01962     [o_checkbox release];
01963     [super dealloc];
01964 }
01965 
01966 - (int)intValue
01967 {
01968     return [o_checkbox intValue];
01969 }
01970 
01971 @end
01972 
01973 @implementation KeyConfigControlBefore103
01974 
01975 - (id) initWithItem: (module_config_t *)_p_item
01976            withView: (NSView *)o_parent_view
01977 {
01978     NSRect mainFrame = [o_parent_view frame];
01979     NSString *o_labelString, *o_tooltip;
01980     mainFrame.size.height = 37;
01981     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
01982     mainFrame.origin.x = LEFTMARGIN;
01983     mainFrame.origin.y = 0;
01984 
01985     if( [super initWithFrame: mainFrame item: _p_item] != nil )
01986     {
01987         i_view_type = CONFIG_ITEM_KEY_BEFORE_10_3;
01988 
01989         /* add the label */
01990         if( p_item->psz_text )
01991             o_labelString = [[VLCMain sharedInstance]
01992                                 localizedString: p_item->psz_text];
01993         else
01994             o_labelString = [NSString stringWithString:@""];
01995         ADD_LABEL( o_label, mainFrame, 0, -10, o_labelString )
01996         [o_label setAutoresizingMask:NSViewNotSizable ];
01997         [self addSubview: o_label];
01998 
01999         /* add the checkboxes */
02000         o_tooltip = [[VLCMain sharedInstance] wrapString:
02001             [[VLCMain sharedInstance]
02002                 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
02003         ADD_CHECKBOX( o_cmd_checkbox, mainFrame,
02004             [o_label frame].size.width + 2, 0,
02005             [NSString stringWithUTF8String:PLACE_OF_INTEREST_SIGN], o_tooltip,
02006             ((((unsigned int)p_item->i_value) & KEY_MODIFIER_COMMAND)?YES:NO),
02007             NSImageLeft )
02008         [o_cmd_checkbox setState: p_item->i_value & KEY_MODIFIER_COMMAND];
02009         ADD_CHECKBOX( o_ctrl_checkbox, mainFrame,
02010             [o_cmd_checkbox frame].size.width +
02011             [o_cmd_checkbox frame].origin.x + 6, 0,
02012             [NSString stringWithUTF8String:UP_ARROWHEAD], o_tooltip,
02013             ((((unsigned int)p_item->i_value) & KEY_MODIFIER_CTRL)?YES:NO),
02014             NSImageLeft )
02015         [o_ctrl_checkbox setState: p_item->i_value & KEY_MODIFIER_CTRL];
02016         ADD_CHECKBOX( o_alt_checkbox, mainFrame, [o_label frame].size.width +
02017             2, -2 - [o_cmd_checkbox frame].size.height,
02018             [NSString stringWithUTF8String:OPTION_KEY], o_tooltip,
02019             ((((unsigned int)p_item->i_value) & KEY_MODIFIER_ALT)?YES:NO),
02020             NSImageLeft )
02021         [o_alt_checkbox setState: p_item->i_value & KEY_MODIFIER_ALT];
02022         ADD_CHECKBOX( o_shift_checkbox, mainFrame,
02023             [o_cmd_checkbox frame].size.width +
02024             [o_cmd_checkbox frame].origin.x + 6, -2 -
02025             [o_cmd_checkbox frame].size.height,
02026             [NSString stringWithUTF8String:UPWARDS_WHITE_ARROW], o_tooltip,
02027             ((((unsigned int)p_item->i_value) & KEY_MODIFIER_SHIFT)?YES:NO),
02028             NSImageLeft )
02029         [o_shift_checkbox setState: p_item->i_value & KEY_MODIFIER_SHIFT];
02030         [self addSubview: o_cmd_checkbox];
02031         [self addSubview: o_ctrl_checkbox];
02032         [self addSubview: o_alt_checkbox];
02033         [self addSubview: o_shift_checkbox];
02034 
02035         /* build the popup */
02036         ADD_POPUP( o_popup, mainFrame, [o_shift_checkbox frame].origin.x +
02037             [o_shift_checkbox frame].size.width + 4,
02038             4, 0, o_tooltip )
02039         [o_popup setAutoresizingMask:NSViewWidthSizable ];
02040 
02041         if( o_keys_menu == nil )
02042         {
02043             unsigned int i;
02044             o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
02045             for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
02046                 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
02047                     POPULATE_A_KEY( o_keys_menu,
02048                         [NSString stringWithCString:vlc_keys[i].psz_key_string]
02049                         , vlc_keys[i].i_key_code)
02050         }
02051         [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
02052         [o_popup selectItemWithTitle: [[VLCMain sharedInstance]
02053             localizedString:KeyToString(
02054             (((unsigned int)p_item->i_value) & ~KEY_MODIFIER ))]];
02055         [self addSubview: o_popup];
02056     }
02057     return self;
02058 }
02059 
02060 - (void) alignWithXPosition:(int)i_xPos
02061 {
02062     NSRect frame;
02063     NSRect superFrame = [self frame];
02064     frame = [o_label frame];
02065     frame.origin.x = i_xPos - frame.size.width - 3;
02066     [o_label setFrame:frame];
02067 
02068     frame = [o_cmd_checkbox frame];
02069     frame.origin.x = i_xPos;
02070     [o_cmd_checkbox setFrame:frame];
02071 
02072     frame = [o_ctrl_checkbox frame];
02073     frame.origin.x = [o_cmd_checkbox frame].size.width +
02074                         [o_cmd_checkbox frame].origin.x + 4;
02075     [o_ctrl_checkbox setFrame:frame];
02076 
02077     frame = [o_alt_checkbox frame];
02078     frame.origin.x = i_xPos;
02079     [o_alt_checkbox setFrame:frame];
02080 
02081     frame = [o_shift_checkbox frame];
02082     frame.origin.x = [o_cmd_checkbox frame].size.width +
02083                         [o_cmd_checkbox frame].origin.x + 4;
02084     [o_shift_checkbox setFrame:frame];
02085 
02086     frame = [o_popup frame];
02087     frame.origin.x = [o_shift_checkbox frame].origin.x +
02088                         [o_shift_checkbox frame].size.width + 3;
02089     frame.size.width = superFrame.size.width - frame.origin.x + 2;
02090     [o_popup setFrame:frame];
02091 }
02092 
02093 - (void)dealloc
02094 {
02095     [o_cmd_checkbox release];
02096     [o_ctrl_checkbox release];
02097     [o_alt_checkbox release];
02098     [o_shift_checkbox release];
02099     [o_popup release];
02100     [super dealloc];
02101 }
02102 
02103 - (int)intValue
02104 {
02105     unsigned int i_new_key = 0;
02106 
02107     i_new_key |= ([o_cmd_checkbox state] == NSOnState) ?
02108         KEY_MODIFIER_COMMAND : 0;
02109     i_new_key |= ([o_ctrl_checkbox state] == NSOnState) ?
02110         KEY_MODIFIER_CTRL : 0;
02111     i_new_key |= ([o_alt_checkbox state] == NSOnState) ?
02112         KEY_MODIFIER_ALT : 0;
02113     i_new_key |= ([o_shift_checkbox state] == NSOnState) ?
02114         KEY_MODIFIER_SHIFT : 0;
02115 
02116     i_new_key |= StringToKey((char *)[[[o_popup selectedItem] title] cString]);
02117     return i_new_key;
02118 }
02119 @end
02120 
02121 @implementation KeyConfigControlAfter103
02122 - (id) initWithItem: (module_config_t *)_p_item
02123            withView: (NSView *)o_parent_view
02124 {
02125     NSRect mainFrame = [o_parent_view frame];
02126     NSString *o_labelString, *o_tooltip;
02127     mainFrame.size.height = 22;
02128     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
02129     mainFrame.origin.x = LEFTMARGIN;
02130     mainFrame.origin.y = 0;
02131 
02132     if( [super initWithFrame: mainFrame item: _p_item] != nil )
02133     {
02134         i_view_type = CONFIG_ITEM_KEY_AFTER_10_3;
02135 
02136         /* add the label */
02137         if( p_item->psz_text )
02138             o_labelString = [[VLCMain sharedInstance]
02139                 localizedString: p_item->psz_text];
02140         else
02141             o_labelString = [NSString stringWithString:@""];
02142         ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
02143         [o_label setAutoresizingMask:NSViewNotSizable ];
02144         [self addSubview: o_label];
02145 
02146         /* build the popup */
02147         o_tooltip = [[VLCMain sharedInstance] wrapString:
02148             [[VLCMain sharedInstance]
02149                 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
02150         ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
02151             [o_label frame].size.width + 3,
02152             -2, 0, o_tooltip )
02153         [o_popup setAutoresizingMask:NSViewWidthSizable ];
02154 
02155         if( o_keys_menu == nil )
02156         {
02157             unsigned int i;
02158             o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
02159             for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
02160                 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
02161                     POPULATE_A_KEY( o_keys_menu,
02162                         [NSString stringWithCString:vlc_keys[i].psz_key_string]
02163                         , vlc_keys[i].i_key_code)
02164         }
02165         [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
02166         [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->i_value]];
02167         [self addSubview: o_popup];
02168 
02169     }
02170     return self;
02171 }
02172 
02173 - (void) alignWithXPosition:(int)i_xPos
02174 {
02175     NSRect frame;
02176     NSRect superFrame = [self frame];
02177     frame = [o_label frame];
02178     frame.origin.x = i_xPos - frame.size.width - 3;
02179     [o_label setFrame:frame];
02180 
02181     frame = [o_popup frame];
02182     frame.origin.x = i_xPos - 1;
02183     frame.size.width = superFrame.size.width - frame.origin.x + 2;
02184     [o_popup setFrame:frame];
02185 }
02186 
02187 - (void)dealloc
02188 {
02189     [o_popup release];
02190     [super dealloc];
02191 }
02192 
02193 - (int)intValue
02194 {
02195     return [o_popup selectedTag];
02196 }
02197 @end
02198 
02199 @implementation ModuleListConfigControl
02200 - (id) initWithItem: (module_config_t *)_p_item
02201            withView: (NSView *)o_parent_view
02202 {
02203 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
02204 //TODO....
02205         return nil;
02206 
02207 //Fill our array to know how may items we have...
02208     vlc_list_t *p_list;
02209     module_t *p_parser;
02210     int i_index;
02211     NSRect mainFrame = [o_parent_view frame];
02212     NSString *o_labelString, *o_textfieldString, *o_tooltip;
02213 
02214     o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
02215     /* build a list of available modules */
02216     p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
02217     for( i_index = 0; i_index < p_list->i_count; i_index++ )
02218     {
02219         p_parser = (module_t *)p_list->p_values[i_index].p_object ;
02220 
02221         if( !strcmp( p_parser->psz_object_name, "main" ) )
02222             continue;
02223 
02224         module_config_t *p_config = p_parser->p_config;
02225         if( p_config ) do
02226         {
02227             NSString *o_modulelongname, *o_modulename;
02228             NSNumber *o_moduleenabled = nil;
02229             /* Hack: required subcategory is stored in i_min */
02230             if( p_config->i_type == CONFIG_SUBCATEGORY &&
02231                 p_config->i_value == _p_item->i_min )
02232             {
02233                 o_modulelongname = [NSString stringWithUTF8String:
02234                                         p_parser->psz_longname];
02235                 o_modulename = [NSString stringWithUTF8String:
02236                                         p_parser->psz_object_name];
02237 
02238                 if( _p_item->psz_value &&
02239                     strstr( _p_item->psz_value, p_parser->psz_object_name ) )
02240                     o_moduleenabled = [NSNumber numberWithBool:YES];
02241                 else
02242                     o_moduleenabled = [NSNumber numberWithBool:NO];
02243 
02244                 [o_modulearray addObject:[NSMutableArray
02245                     arrayWithObjects: o_modulename, o_modulelongname,
02246                     o_moduleenabled, nil]];
02247             }
02248         } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
02249     }
02250     vlc_list_release( p_list );
02251 
02252     mainFrame.size.height = 30 + 18 * [o_modulearray count];
02253     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
02254     mainFrame.origin.x = LEFTMARGIN;
02255     mainFrame.origin.y = 0;
02256     if( [super initWithFrame: mainFrame item: _p_item] != nil )
02257     {
02258         i_view_type = CONFIG_ITEM_MODULE_LIST;
02259 
02260         /* add the label */
02261         if( p_item->psz_text )
02262             o_labelString = [[VLCMain sharedInstance]
02263                                 localizedString: p_item->psz_text];
02264         else
02265             o_labelString = [NSString stringWithString:@""];
02266         ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
02267         [o_label setAutoresizingMask:NSViewNotSizable ];
02268         [self addSubview: o_label];
02269 
02270         /* build the textfield */
02271         o_tooltip = [[VLCMain sharedInstance] wrapString:
02272             [[VLCMain sharedInstance]
02273                 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
02274         if( p_item->psz_value )
02275             o_textfieldString = [[VLCMain sharedInstance]
02276                 localizedString: p_item->psz_value];
02277         else
02278             o_textfieldString = [NSString stringWithString: @""];
02279         ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
02280             mainFrame.size.height - 22, mainFrame.size.width -
02281             [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
02282         [o_textfield setAutoresizingMask:NSViewWidthSizable ];
02283         [self addSubview: o_textfield];
02284 
02285 
02286 {
02287     NSRect s_rc = mainFrame;
02288     s_rc.size.height = mainFrame.size.height - 30;
02289     s_rc.size.width = mainFrame.size.width - 12;
02290     s_rc.origin.x = 12;
02291     s_rc.origin.y = 0;
02292     o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
02293     [o_scrollview setDrawsBackground: NO];
02294     [o_scrollview setBorderType: NSBezelBorder];
02295     if( MACOS_VERSION >= 10.3 )
02296         [o_scrollview setAutohidesScrollers:YES];
02297 
02298     NSTableView *o_tableview;
02299     o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
02300     if( MACOS_VERSION >= 10.3 )
02301         [o_tableview setUsesAlternatingRowBackgroundColors:YES];
02302     [o_tableview setHeaderView:nil];
02303 /* TODO: find a good way to fix the row height and text size*/
02304 /* FIXME: support for multiple selection... */
02305 //    [o_tableview setAllowsMultipleSelection:YES];
02306 
02307     NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
02308     NSCell *o_dataCell = [[NSButtonCell alloc] init];
02309     [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
02310     [o_dataCell setTitle:@""];
02311     [o_dataCell setFont:[NSFont systemFontOfSize:0]];
02312     NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
02313         initWithIdentifier:[NSString stringWithCString: "Enabled"]];
02314     [o_tableColumn setHeaderCell: o_headerCell];
02315     [o_tableColumn setDataCell: o_dataCell];
02316     [o_tableColumn setWidth:17];
02317     [o_tableview addTableColumn: o_tableColumn];
02318 
02319     o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
02320     o_dataCell = [[NSTextFieldCell alloc] init];
02321     [o_dataCell setFont:[NSFont systemFontOfSize:12]];
02322     o_tableColumn = [[NSTableColumn alloc]
02323         initWithIdentifier:[NSString stringWithCString: "Module"]];
02324     [o_tableColumn setHeaderCell: o_headerCell];
02325     [o_tableColumn setDataCell: o_dataCell];
02326     [o_tableColumn setWidth:388 - 17];
02327     [o_tableview addTableColumn: o_tableColumn];
02328     [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
02329             @"VLC media player module", nil]];
02330 
02331     [o_tableview setDataSource:self];
02332     [o_tableview setTarget: self];
02333     [o_tableview setAction: @selector(tableChanged:)];
02334     [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
02335         NSLeftMouseDraggedMask];
02336     [o_scrollview setDocumentView: o_tableview];
02337 }
02338     [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
02339     [self addSubview: o_scrollview];
02340 
02341 
02342     }
02343     return self;
02344 }
02345 
02346 - (void) alignWithXPosition:(int)i_xPos
02347 {
02348     ;
02349 }
02350 
02351 - (IBAction)tableChanged:(id)sender
02352 {
02353     NSString *o_newstring = @"";
02354     unsigned int i;
02355     for( i = 0 ; i < [o_modulearray count] ; i++ )
02356         if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
02357             boolValue] != NO )
02358         {
02359             o_newstring = [o_newstring stringByAppendingString:
02360                 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
02361             o_newstring = [o_newstring stringByAppendingString:@":"];
02362         }
02363 
02364     [o_textfield setStringValue: [o_newstring
02365         substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
02366 }
02367 
02368 - (void)dealloc
02369 {
02370     [o_scrollview release];
02371     [super dealloc];
02372 }
02373 
02374 
02375 - (char *)stringValue
02376 {
02377     return strdup( [[o_textfield stringValue] cString] );
02378 }
02379 
02380 @end
02381 
02382 @implementation ModuleListConfigControl (NSTableDataSource)
02383 
02384 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
02385     toPasteboard:(NSPasteboard*)pb
02386 {
02387     // We only want to allow dragging of selected rows.
02388     NSEnumerator    *iter = [rows objectEnumerator];
02389     NSNumber        *row;
02390     while ((row = [iter nextObject]) != nil)
02391     {
02392         if (![table isRowSelected:[row intValue]])
02393             return NO;
02394     }
02395 
02396     [pb declareTypes:[NSArray
02397         arrayWithObject:@"VLC media player module"] owner:nil];
02398     [pb setPropertyList:rows forType:@"VLC media player module"];
02399     return YES;
02400 }
02401 
02402 - (NSDragOperation)tableView:(NSTableView*)table
02403     validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row
02404     proposedDropOperation:(NSTableViewDropOperation)op
02405 {
02406     // Make drops at the end of the table go to the end.
02407     if (row == -1)
02408     {
02409         row = [table numberOfRows];
02410         op = NSTableViewDropAbove;
02411         [table setDropRow:row dropOperation:op];
02412     }
02413 
02414     // We don't ever want to drop onto a row, only between rows.
02415     if (op == NSTableViewDropOn)
02416         [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
02417     return NSTableViewDropAbove;
02418 }
02419 
02420 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
02421     row:(int)dropRow dropOperation:(NSTableViewDropOperation)op;
02422 {
02423     NSPasteboard    *pb = [info draggingPasteboard];
02424     NSDragOperation srcMask = [info draggingSourceOperationMask];
02425     BOOL accepted = NO;
02426 
02427     NS_DURING
02428 
02429         NSArray *array;
02430 
02431         // Intra-table drag - data is the array of rows.
02432         if (!accepted && (array =
02433             [pb propertyListForType:@"VLC media player module"]) != NULL)
02434         {
02435             NSEnumerator *iter = nil;
02436             id val;
02437             BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
02438             // Move the modules
02439             iter = [array objectEnumerator];
02440             while ((val = [iter nextObject]) != NULL)
02441             {
02442                 NSArray *o_tmp = [[o_modulearray objectAtIndex:
02443                     [val intValue]] mutableCopyWithZone:nil];
02444                 [o_modulearray removeObject:o_tmp];
02445                 [o_modulearray insertObject:o_tmp
02446                     atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
02447                 dropRow++;
02448             }
02449 
02450             // Select the newly-dragged items.
02451             iter = [array objectEnumerator];
02452 //TODO...
02453             [table deselectAll:self];
02454 
02455             [self tableChanged:self];
02456             [table setNeedsDisplay:YES];
02457             // Indicate that we finished the drag.
02458             accepted = YES;
02459         }
02460         [table reloadData];
02461         [table setNeedsDisplay:YES];
02462 
02463         NS_HANDLER
02464 
02465             // An exception occurred. Uh-oh. Update the track table so that
02466             // it stays consistent, and re-raise the exception.
02467             [table reloadData];
02468             [localException raise];
02469             [table setNeedsDisplay:YES];
02470     NS_ENDHANDLER
02471 
02472     return accepted;
02473 }
02474 
02475 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
02476 {
02477     return [o_modulearray count];
02478 }
02479 
02480 - (id)tableView:(NSTableView *)aTableView
02481     objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
02482 {
02483     if( [[aTableColumn identifier] isEqualToString:
02484         [NSString stringWithCString:"Enabled"]] )
02485         return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
02486     if( [[aTableColumn identifier] isEqualToString:
02487         [NSString stringWithCString:"Module"]] )
02488         return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
02489 
02490     return nil;
02491 }
02492 
02493 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
02494     forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
02495 {
02496     [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
02497         withObject: anObject];
02498 }
02499 @end

Generated on Tue Dec 20 10:14:38 2005 for vlc-0.8.4a by  doxygen 1.4.2