1 /*****************************************************************************
2 * prefs_widgets.m: Preferences controls
3 *****************************************************************************
4 * Copyright (C) 2002-2003 VideoLAN
7 * Authors: Derk-Jan Hartman <hartman at videolan.org>
8 * Jérôme Decoodt <djc at videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
35 #include "prefs_widgets.h"
37 #define PREFS_WRAP 300
38 #define OFFSET_RIGHT 20
39 #define OFFSET_BETWEEN 2
41 #define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
42 @"/System/Library/CoreServices/SystemVersion.plist"] \
43 objectForKey: @"ProductVersion"] floatValue]
45 #define UPWARDS_WHITE_ARROW "\xE2\x87\xA7"
46 #define OPTION_KEY "\xE2\x8C\xA5"
47 #define UP_ARROWHEAD "\xE2\x8C\x83"
48 #define PLACE_OF_INTEREST_SIGN "\xE2\x8C\x98"
50 #define POPULATE_A_KEY( o_menu, string, value ) \
54 o_mi = [[NSMenuItem alloc] initWithTitle:string \
55 action:nil keyEquivalent:@""]; \
56 [o_mi setKeyEquivalentModifierMask: \
58 if( MACOS_VERSION >= 10.3 ) \
59 [o_mi setAlternate: NO]; \
62 [o_menu addItem: o_mi]; \
63 if( MACOS_VERSION >= 10.3 ) \
66 o_mi = [[NSMenuItem alloc] initWithTitle: \
67 [[NSString stringWithUTF8String: \
69 ] stringByAppendingString: string] \
70 action:nil keyEquivalent:@""]; \
71 [o_mi setKeyEquivalentModifierMask: \
73 [o_mi setAlternate: YES]; \
75 KEY_MODIFIER_CTRL | ( value )]; \
76 [o_menu addItem: o_mi]; \
78 o_mi = [[NSMenuItem alloc] initWithTitle: \
79 [[NSString stringWithUTF8String: \
80 UP_ARROWHEAD OPTION_KEY \
81 ] stringByAppendingString: string] \
82 action:nil keyEquivalent:@""]; \
83 [o_mi setKeyEquivalentModifierMask: \
84 NSControlKeyMask | NSAlternateKeyMask]; \
85 [o_mi setAlternate: YES]; \
87 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | ( value )]; \
88 [o_menu addItem: o_mi]; \
90 o_mi = [[NSMenuItem alloc] initWithTitle: \
91 [[NSString stringWithUTF8String: \
92 UP_ARROWHEAD UPWARDS_WHITE_ARROW \
93 ] stringByAppendingString: string] \
94 action:nil keyEquivalent:@""]; \
95 [o_mi setKeyEquivalentModifierMask: \
96 NSControlKeyMask | NSShiftKeyMask]; \
97 [o_mi setAlternate: YES]; \
99 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | ( value )]; \
100 [o_menu addItem: o_mi]; \
102 o_mi = [[NSMenuItem alloc] initWithTitle: \
103 [[NSString stringWithUTF8String: \
104 UP_ARROWHEAD PLACE_OF_INTEREST_SIGN \
105 ] stringByAppendingString: string] \
106 action:nil keyEquivalent:@""]; \
107 [o_mi setKeyEquivalentModifierMask: \
108 NSControlKeyMask | NSCommandKeyMask]; \
109 [o_mi setAlternate: YES]; \
111 (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | ( value )]; \
112 [o_menu addItem: o_mi]; \
113 /* Ctrl+Alt+Shift */ \
114 o_mi = [[NSMenuItem alloc] initWithTitle: \
115 [[NSString stringWithUTF8String: \
116 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
117 ] stringByAppendingString: string] \
118 action:nil keyEquivalent:@""]; \
119 [o_mi setKeyEquivalentModifierMask: \
120 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
121 [o_mi setAlternate: YES]; \
123 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | \
125 [o_menu addItem: o_mi]; \
126 /* Ctrl+Alt+Apple */ \
127 o_mi = [[NSMenuItem alloc] initWithTitle: \
128 [[NSString stringWithUTF8String: \
129 UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN \
130 ] stringByAppendingString: string] \
131 action:nil keyEquivalent:@""]; \
132 [o_mi setKeyEquivalentModifierMask: \
133 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
134 [o_mi setAlternate: YES]; \
136 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
138 [o_menu addItem: o_mi]; \
139 /* Ctrl+Shift+Apple */ \
140 o_mi = [[NSMenuItem alloc] initWithTitle: \
141 [[NSString stringWithUTF8String: \
142 UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
143 ] stringByAppendingString: string] \
144 action:nil keyEquivalent:@""]; \
145 [o_mi setKeyEquivalentModifierMask: \
146 NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
147 [o_mi setAlternate: YES]; \
149 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
151 [o_menu addItem: o_mi]; \
152 /* Ctrl+Alt+Shift+Apple */ \
153 o_mi = [[NSMenuItem alloc] initWithTitle: \
154 [[NSString stringWithUTF8String: \
155 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
156 PLACE_OF_INTEREST_SIGN \
157 ] stringByAppendingString: string] \
158 action:nil keyEquivalent:@""]; \
159 [o_mi setKeyEquivalentModifierMask: \
160 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
162 [o_mi setAlternate: YES]; \
164 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
165 KEY_MODIFIER_COMMAND) | ( value )]; \
166 [o_menu addItem: o_mi]; \
168 o_mi = [[NSMenuItem alloc] initWithTitle: \
169 [[NSString stringWithUTF8String: \
171 ] stringByAppendingString: string] \
172 action:nil keyEquivalent:@""]; \
173 [o_mi setKeyEquivalentModifierMask: \
174 NSAlternateKeyMask]; \
175 [o_mi setAlternate: YES]; \
177 KEY_MODIFIER_ALT | ( value )]; \
178 [o_menu addItem: o_mi]; \
180 o_mi = [[NSMenuItem alloc] initWithTitle: \
181 [[NSString stringWithUTF8String: \
182 OPTION_KEY UPWARDS_WHITE_ARROW \
183 ] stringByAppendingString: string] \
184 action:nil keyEquivalent:@""]; \
185 [o_mi setKeyEquivalentModifierMask: \
186 NSAlternateKeyMask | NSShiftKeyMask]; \
187 [o_mi setAlternate: YES]; \
189 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )]; \
190 [o_menu addItem: o_mi]; \
192 o_mi = [[NSMenuItem alloc] initWithTitle: \
193 [[NSString stringWithUTF8String: \
194 OPTION_KEY PLACE_OF_INTEREST_SIGN \
195 ] stringByAppendingString: string] \
196 action:nil keyEquivalent:@""]; \
197 [o_mi setKeyEquivalentModifierMask: \
198 NSAlternateKeyMask | NSCommandKeyMask]; \
199 [o_mi setAlternate: YES]; \
201 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )]; \
202 [o_menu addItem: o_mi]; \
203 /* Alt+Shift+Apple */ \
204 o_mi = [[NSMenuItem alloc] initWithTitle: \
205 [[NSString stringWithUTF8String: \
206 OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
207 ] stringByAppendingString: string] \
208 action:nil keyEquivalent:@""]; \
209 [o_mi setKeyEquivalentModifierMask: \
210 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
211 [o_mi setAlternate: YES]; \
213 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
215 [o_menu addItem: o_mi]; \
217 o_mi = [[NSMenuItem alloc] initWithTitle: \
218 [[NSString stringWithUTF8String: \
219 UPWARDS_WHITE_ARROW \
220 ] stringByAppendingString: string] \
221 action:nil keyEquivalent:@""]; \
222 [o_mi setKeyEquivalentModifierMask: \
224 [o_mi setAlternate: YES]; \
226 KEY_MODIFIER_SHIFT | ( value )]; \
227 [o_menu addItem: o_mi]; \
229 o_mi = [[NSMenuItem alloc] initWithTitle: \
230 [[NSString stringWithUTF8String: \
231 UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
232 ] stringByAppendingString: string] \
233 action:nil keyEquivalent:@""]; \
234 [o_mi setKeyEquivalentModifierMask: \
235 NSShiftKeyMask | NSCommandKeyMask]; \
236 [o_mi setAlternate: YES]; \
238 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \
239 [o_menu addItem: o_mi]; \
241 o_mi = [[NSMenuItem alloc] initWithTitle: \
242 [[NSString stringWithUTF8String: \
243 PLACE_OF_INTEREST_SIGN \
244 ] stringByAppendingString: string] \
245 action:nil keyEquivalent:@""]; \
246 [o_mi setKeyEquivalentModifierMask: \
248 [o_mi setAlternate: YES]; \
250 KEY_MODIFIER_COMMAND | ( value )]; \
251 [o_menu addItem: o_mi]; \
255 #define ADD_LABEL( o_label, superFrame, x_offset, my_y_offset, label ) \
257 NSRect s_rc = superFrame; \
258 s_rc.size.height = 17; \
259 s_rc.origin.x = x_offset - 3; \
260 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
261 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
262 [o_label setDrawsBackground: NO]; \
263 [o_label setBordered: NO]; \
264 [o_label setEditable: NO]; \
265 [o_label setSelectable: NO]; \
266 [o_label setStringValue: label]; \
267 [o_label setFont:[NSFont systemFontOfSize:0]]; \
268 [o_label sizeToFit]; \
271 #define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \
272 my_width, tooltip, init_value ) \
274 NSRect s_rc = superFrame; \
275 s_rc.origin.x = x_offset; \
276 s_rc.origin.y = my_y_offset; \
277 s_rc.size.height = 22; \
278 s_rc.size.width = my_width; \
279 o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
280 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
281 [o_textfield setToolTip: tooltip]; \
282 [o_textfield setStringValue: init_value]; \
285 #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
288 NSRect s_rc = superFrame; \
289 s_rc.origin.x = x_offset + 2; \
290 s_rc.origin.y = my_y_offset; \
291 s_rc.size.height = 26; \
292 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
294 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
295 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
296 [o_combo setToolTip: tooltip]; \
297 [o_combo setUsesDataSource:TRUE]; \
298 [o_combo setDataSource:self]; \
299 [o_combo setNumberOfVisibleItems:10]; \
300 [o_combo setCompletes:YES]; \
303 #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, \
306 NSRect s_rc = superFrame; \
307 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
308 [o_button setButtonType: NSMomentaryPushInButton]; \
309 [o_button setBezelStyle: NSRoundedBezelStyle]; \
310 [o_button setTitle: title]; \
311 [o_button setFont:[NSFont systemFontOfSize:0]]; \
312 [o_button sizeToFit]; \
313 s_rc = [o_button frame]; \
314 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
315 s_rc.origin.y = my_y_offset - 6; \
316 s_rc.size.width += 12; \
317 [o_button setFrame: s_rc]; \
318 [o_button setToolTip: tooltip]; \
319 [o_button setTarget: self]; \
320 [o_button setAction: @selector(openFileDialog:)]; \
323 #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
326 NSRect s_rc = superFrame; \
327 s_rc.origin.x = x_offset - 1; \
328 s_rc.origin.y = my_y_offset; \
329 s_rc.size.height = 26; \
330 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
332 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
333 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
334 [o_popup setToolTip: tooltip]; \
337 #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
340 NSRect s_rc = superFrame; \
341 s_rc.origin.x = x_offset; \
342 s_rc.origin.y = my_y_offset; \
343 s_rc.size.height = 23; \
344 s_rc.size.width = 23; \
345 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
346 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
347 [o_stepper setToolTip: tooltip]; \
348 [o_stepper setMaxValue: higher]; \
349 [o_stepper setMinValue: lower]; \
350 [o_stepper setTarget: self]; \
351 [o_stepper setAction: @selector(stepperChanged:)]; \
352 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
353 NSLeftMouseDraggedMask]; \
356 #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, \
357 tooltip, lower, higher ) \
359 NSRect s_rc = superFrame; \
360 s_rc.origin.x = x_offset; \
361 s_rc.origin.y = my_y_offset; \
362 s_rc.size.height = 21; \
363 s_rc.size.width = my_width; \
364 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
365 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
366 [o_slider setToolTip: tooltip]; \
367 [o_slider setMaxValue: higher]; \
368 [o_slider setMinValue: lower]; \
371 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
372 tooltip, init_value, position ) \
374 NSRect s_rc = superFrame; \
375 s_rc.size.height = 18; \
376 s_rc.origin.x = x_offset - 2; \
377 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
378 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
379 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
380 [o_checkbox setButtonType: NSSwitchButton]; \
381 [o_checkbox setImagePosition: position]; \
382 [o_checkbox setIntValue: init_value]; \
383 [o_checkbox setTitle: label]; \
384 [o_checkbox setToolTip: tooltip]; \
385 [o_checkbox sizeToFit]; \
388 @implementation VLCConfigControl
389 - (id)initWithFrame: (NSRect)frame
391 return [self initWithFrame: frame
395 - (id)initWithFrame: (NSRect)frame
396 item: (module_config_t *)_p_item
398 self = [super initWithFrame: frame];
403 psz_name = strdup( p_item->psz_name );
405 i_type = p_item->i_type;
407 b_advanced = p_item->b_advanced;
408 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
413 - (void)setYPos:(int)i_yPos
415 NSRect frame = [self frame];
416 frame.origin.y = i_yPos;
417 [self setFrame:frame];
422 if( o_label ) [o_label release];
423 if( psz_name ) free( psz_name );
427 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
432 case CONFIG_ITEM_STRING:
435 case CONFIG_ITEM_STRING:
438 case CONFIG_ITEM_STRING_LIST:
441 case CONFIG_ITEM_FILE:
444 case CONFIG_ITEM_MODULE:
447 case CONFIG_ITEM_INTEGER:
450 case CONFIG_ITEM_RANGED_INTEGER:
453 case CONFIG_ITEM_BOOL:
456 case CONFIG_ITEM_KEY_BEFORE_10_3:
459 case CONFIG_ITEM_KEY_AFTER_10_3:
462 case CONFIG_ITEM_MODULE_LIST:
470 case CONFIG_ITEM_STRING_LIST:
473 case CONFIG_ITEM_STRING:
476 case CONFIG_ITEM_STRING_LIST:
479 case CONFIG_ITEM_FILE:
482 case CONFIG_ITEM_MODULE:
485 case CONFIG_ITEM_INTEGER:
488 case CONFIG_ITEM_RANGED_INTEGER:
491 case CONFIG_ITEM_BOOL:
494 case CONFIG_ITEM_KEY_BEFORE_10_3:
497 case CONFIG_ITEM_KEY_AFTER_10_3:
500 case CONFIG_ITEM_MODULE_LIST:
508 case CONFIG_ITEM_FILE:
511 case CONFIG_ITEM_STRING:
514 case CONFIG_ITEM_STRING_LIST:
517 case CONFIG_ITEM_FILE:
520 case CONFIG_ITEM_MODULE:
523 case CONFIG_ITEM_INTEGER:
526 case CONFIG_ITEM_RANGED_INTEGER:
529 case CONFIG_ITEM_BOOL:
532 case CONFIG_ITEM_KEY_BEFORE_10_3:
535 case CONFIG_ITEM_KEY_AFTER_10_3:
538 case CONFIG_ITEM_MODULE_LIST:
546 case CONFIG_ITEM_MODULE:
549 case CONFIG_ITEM_STRING:
552 case CONFIG_ITEM_STRING_LIST:
555 case CONFIG_ITEM_FILE:
558 case CONFIG_ITEM_MODULE:
561 case CONFIG_ITEM_INTEGER:
564 case CONFIG_ITEM_RANGED_INTEGER:
567 case CONFIG_ITEM_BOOL:
570 case CONFIG_ITEM_KEY_BEFORE_10_3:
573 case CONFIG_ITEM_KEY_AFTER_10_3:
576 case CONFIG_ITEM_MODULE_LIST:
584 case CONFIG_ITEM_INTEGER:
587 case CONFIG_ITEM_STRING:
590 case CONFIG_ITEM_STRING_LIST:
593 case CONFIG_ITEM_FILE:
596 case CONFIG_ITEM_MODULE:
599 case CONFIG_ITEM_INTEGER:
602 case CONFIG_ITEM_RANGED_INTEGER:
605 case CONFIG_ITEM_BOOL:
608 case CONFIG_ITEM_KEY_BEFORE_10_3:
611 case CONFIG_ITEM_KEY_AFTER_10_3:
614 case CONFIG_ITEM_MODULE_LIST:
622 case CONFIG_ITEM_RANGED_INTEGER:
625 case CONFIG_ITEM_STRING:
628 case CONFIG_ITEM_STRING_LIST:
631 case CONFIG_ITEM_FILE:
634 case CONFIG_ITEM_MODULE:
637 case CONFIG_ITEM_INTEGER:
640 case CONFIG_ITEM_RANGED_INTEGER:
643 case CONFIG_ITEM_BOOL:
646 case CONFIG_ITEM_KEY_BEFORE_10_3:
649 case CONFIG_ITEM_KEY_AFTER_10_3:
652 case CONFIG_ITEM_MODULE_LIST:
660 case CONFIG_ITEM_BOOL:
663 case CONFIG_ITEM_STRING:
666 case CONFIG_ITEM_STRING_LIST:
669 case CONFIG_ITEM_FILE:
672 case CONFIG_ITEM_MODULE:
675 case CONFIG_ITEM_INTEGER:
678 case CONFIG_ITEM_RANGED_INTEGER:
681 case CONFIG_ITEM_BOOL:
684 case CONFIG_ITEM_KEY_BEFORE_10_3:
687 case CONFIG_ITEM_KEY_AFTER_10_3:
690 case CONFIG_ITEM_MODULE_LIST:
698 case CONFIG_ITEM_KEY_BEFORE_10_3:
701 case CONFIG_ITEM_STRING:
704 case CONFIG_ITEM_STRING_LIST:
707 case CONFIG_ITEM_FILE:
710 case CONFIG_ITEM_MODULE:
713 case CONFIG_ITEM_INTEGER:
716 case CONFIG_ITEM_RANGED_INTEGER:
719 case CONFIG_ITEM_BOOL:
722 case CONFIG_ITEM_KEY_BEFORE_10_3:
725 case CONFIG_ITEM_KEY_AFTER_10_3:
728 case CONFIG_ITEM_MODULE_LIST:
736 case CONFIG_ITEM_KEY_AFTER_10_3:
739 case CONFIG_ITEM_STRING:
742 case CONFIG_ITEM_STRING_LIST:
745 case CONFIG_ITEM_FILE:
748 case CONFIG_ITEM_MODULE:
751 case CONFIG_ITEM_INTEGER:
754 case CONFIG_ITEM_RANGED_INTEGER:
757 case CONFIG_ITEM_BOOL:
760 case CONFIG_ITEM_KEY_BEFORE_10_3:
763 case CONFIG_ITEM_KEY_AFTER_10_3:
766 case CONFIG_ITEM_MODULE_LIST:
774 case CONFIG_ITEM_MODULE_LIST:
777 case CONFIG_ITEM_STRING:
780 case CONFIG_ITEM_STRING_LIST:
783 case CONFIG_ITEM_FILE:
786 case CONFIG_ITEM_MODULE:
789 case CONFIG_ITEM_INTEGER:
792 case CONFIG_ITEM_RANGED_INTEGER:
795 case CONFIG_ITEM_BOOL:
798 case CONFIG_ITEM_KEY_BEFORE_10_3:
801 case CONFIG_ITEM_KEY_AFTER_10_3:
804 case CONFIG_ITEM_MODULE_LIST:
819 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
820 withView: (NSView *)o_parent_view
822 VLCConfigControl *p_control = NULL;
823 switch( _p_item->i_type )
825 case CONFIG_ITEM_STRING:
826 if( !_p_item->i_list )
828 p_control = [[StringConfigControl alloc]
829 initWithItem: _p_item
830 withView: o_parent_view];
834 p_control = [[StringListConfigControl alloc]
835 initWithItem: _p_item
836 withView: o_parent_view];
839 case CONFIG_ITEM_FILE:
840 case CONFIG_ITEM_DIRECTORY:
841 p_control = [[FileConfigControl alloc]
842 initWithItem: _p_item
843 withView: o_parent_view];
845 case CONFIG_ITEM_MODULE:
846 case CONFIG_ITEM_MODULE_CAT:
847 p_control = [[ModuleConfigControl alloc]
848 initWithItem: _p_item
849 withView: o_parent_view];
851 case CONFIG_ITEM_INTEGER:
852 if( _p_item->i_list )
854 p_control = [[IntegerListConfigControl alloc]
855 initWithItem: _p_item
856 withView: o_parent_view];
858 else if( _p_item->i_min != 0 || _p_item->i_max != 0 )
860 p_control = [[RangedIntegerConfigControl alloc]
861 initWithItem: _p_item
862 withView: o_parent_view];
866 p_control = [[IntegerConfigControl alloc]
867 initWithItem: _p_item
868 withView: o_parent_view];
871 case CONFIG_ITEM_BOOL:
872 p_control = [[BoolConfigControl alloc]
873 initWithItem: _p_item
874 withView: o_parent_view];
876 case CONFIG_ITEM_FLOAT:
877 if( _p_item->f_min != 0 || _p_item->f_max != 0 )
879 p_control = [[RangedFloatConfigControl alloc]
880 initWithItem: _p_item
881 withView: o_parent_view];
885 p_control = [[FloatConfigControl alloc]
886 initWithItem: _p_item
887 withView: o_parent_view];
890 case CONFIG_ITEM_KEY:
891 if( MACOS_VERSION < 10.3 )
893 p_control = [[KeyConfigControlBefore103 alloc]
894 initWithItem: _p_item
895 withView: o_parent_view];
899 p_control = [[KeyConfigControlAfter103 alloc]
900 initWithItem: _p_item
901 withView: o_parent_view];
904 case CONFIG_ITEM_MODULE_LIST:
905 case CONFIG_ITEM_MODULE_LIST_CAT:
906 p_control = [[ModuleListConfigControl alloc]
907 initWithItem: _p_item
908 withView: o_parent_view];
916 - (NSString *)getName
918 return [[VLCMain sharedInstance] localizedString: psz_name];
946 - (char *)stringValue
954 switch( p_item->i_type )
956 case CONFIG_ITEM_STRING:
957 case CONFIG_ITEM_FILE:
958 case CONFIG_ITEM_DIRECTORY:
959 case CONFIG_ITEM_MODULE:
960 case CONFIG_ITEM_MODULE_LIST:
961 case CONFIG_ITEM_MODULE_LIST_CAT:
962 config_PutPsz( VLCIntf, psz_name, [self stringValue] );
964 case CONFIG_ITEM_KEY:
965 /* So you don't need to restart to have the changes take effect */
966 val.i_int = [self intValue];
967 var_Set( VLCIntf->p_vlc, psz_name, val );
968 case CONFIG_ITEM_INTEGER:
969 case CONFIG_ITEM_BOOL:
970 config_PutInt( VLCIntf, psz_name, [self intValue] );
972 case CONFIG_ITEM_FLOAT:
973 config_PutFloat( VLCIntf, psz_name, [self floatValue] );
980 return [o_label frame].size.width;
984 @implementation StringConfigControl
985 - (id) initWithItem: (module_config_t *)_p_item
986 withView: (NSView *)o_parent_view
988 NSRect mainFrame = [o_parent_view frame];
989 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
990 mainFrame.size.height = 22;
991 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
992 mainFrame.origin.x = LEFTMARGIN;
993 mainFrame.origin.y = 0;
995 if( [super initWithFrame: mainFrame item: _p_item] != nil )
997 i_view_type = CONFIG_ITEM_STRING;
999 if( p_item->psz_text )
1000 o_labelString = [[VLCMain sharedInstance]
1001 localizedString: p_item->psz_text];
1003 o_labelString = [NSString stringWithString:@""];
1004 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1005 [o_label setAutoresizingMask:NSViewNotSizable ];
1006 [self addSubview: o_label];
1008 /* build the textfield */
1009 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1010 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext]
1011 toWidth: PREFS_WRAP];
1012 if( p_item->psz_value )
1013 o_textfieldString = [[VLCMain sharedInstance]
1014 localizedString: p_item->psz_value];
1016 o_textfieldString = [NSString stringWithString: @""];
1017 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1018 0, mainFrame.size.width - [o_label frame].size.width -
1019 2, o_textfieldTooltip, o_textfieldString )
1020 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1021 [self addSubview: o_textfield];
1026 - (void) alignWithXPosition:(int)i_xPos
1029 NSRect superFrame = [self frame];
1030 frame = [o_label frame];
1031 frame.origin.x = i_xPos - frame.size.width - 3;
1032 [o_label setFrame:frame];
1034 frame = [o_textfield frame];
1035 frame.origin.x = i_xPos + 2;
1036 frame.size.width = superFrame.size.width - frame.origin.x - 1;
1037 [o_textfield setFrame:frame];
1042 [o_textfield release];
1046 - (char *)stringValue
1048 return strdup( [[VLCMain sharedInstance] delocalizeString:
1049 [o_textfield stringValue]] );
1053 @implementation StringListConfigControl
1054 - (id) initWithItem: (module_config_t *)_p_item
1055 withView: (NSView *)o_parent_view
1057 NSRect mainFrame = [o_parent_view frame];
1058 NSString *o_labelString, *o_textfieldTooltip;
1059 mainFrame.size.height = 22;
1060 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1061 mainFrame.origin.x = LEFTMARGIN;
1062 mainFrame.origin.y = 0;
1064 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1067 i_view_type = CONFIG_ITEM_STRING_LIST;
1069 if( p_item->psz_text )
1070 o_labelString = [[VLCMain sharedInstance]
1071 localizedString: p_item->psz_text];
1073 o_labelString = [NSString stringWithString:@""];
1074 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1075 [o_label setAutoresizingMask:NSViewNotSizable ];
1076 [self addSubview: o_label];
1078 /* build the textfield */
1079 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1080 [[VLCMain sharedInstance]
1081 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1082 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1083 -2, 0, o_textfieldTooltip )
1084 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1085 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1086 if( p_item->psz_value &&
1087 !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) )
1088 [o_combo selectItemAtIndex: i_index];
1089 [self addSubview: o_combo];
1094 - (void) alignWithXPosition:(int)i_xPos
1097 NSRect superFrame = [self frame];
1098 frame = [o_label frame];
1099 frame.origin.x = i_xPos - frame.size.width - 3;
1100 [o_label setFrame:frame];
1102 frame = [o_combo frame];
1103 frame.origin.x = i_xPos + 2;
1104 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1105 [o_combo setFrame:frame];
1114 - (char *)stringValue
1116 if( [o_combo indexOfSelectedItem] >= 0 )
1117 return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
1119 return strdup( [[VLCMain sharedInstance]
1120 delocalizeString: [o_combo stringValue]] );
1124 @implementation StringListConfigControl (NSComboBoxDataSource)
1125 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1127 return p_item->i_list;
1130 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1132 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1134 return [[VLCMain sharedInstance]
1135 localizedString: p_item->ppsz_list_text[i_index]];
1136 } else return [[VLCMain sharedInstance]
1137 localizedString: p_item->ppsz_list[i_index]];
1141 @implementation FileConfigControl
1142 - (id) initWithItem: (module_config_t *)_p_item
1143 withView: (NSView *)o_parent_view
1145 NSRect mainFrame = [o_parent_view frame];
1146 NSString *o_labelString, *o_buttonTooltip, *o_textfieldString;
1147 NSString *o_textfieldTooltip;
1148 mainFrame.size.height = 46;
1149 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1150 mainFrame.origin.x = LEFTMARGIN;
1151 mainFrame.origin.y = 0;
1153 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1155 i_view_type = CONFIG_ITEM_FILE;
1157 /* is it a directory */
1158 b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
1161 if( p_item->psz_text )
1162 o_labelString = [[VLCMain sharedInstance]
1163 localizedString: p_item->psz_text];
1165 o_labelString = [NSString stringWithString:@""];
1166 ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString )
1167 [o_label setAutoresizingMask:NSViewNotSizable ];
1168 [self addSubview: o_label];
1170 /* build the button */
1171 o_buttonTooltip = [[VLCMain sharedInstance]
1172 wrapString: [[VLCMain sharedInstance]
1173 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1174 ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_buttonTooltip,
1176 [o_button setAutoresizingMask:NSViewMinXMargin ];
1177 [self addSubview: o_button];
1179 /* build the textfield */
1180 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1181 [[VLCMain sharedInstance]
1182 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1183 if( p_item->psz_value )
1184 o_textfieldString = [[VLCMain sharedInstance]
1185 localizedString: p_item->psz_value];
1187 o_textfieldString = [NSString stringWithString: @""];
1188 ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1189 8 - [o_button frame].size.width,
1190 o_textfieldTooltip, o_textfieldString )
1191 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1192 [self addSubview: o_textfield];
1197 - (void) alignWithXPosition:(int)i_xPos
1204 [o_textfield release];
1209 - (IBAction)openFileDialog: (id)sender
1211 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1213 [o_open_panel setTitle: (b_directory)?
1214 _NS("Select a directory"):_NS("Select a file")];
1215 [o_open_panel setPrompt: _NS("Select")];
1216 [o_open_panel setAllowsMultipleSelection: NO];
1217 [o_open_panel setCanChooseFiles: !b_directory];
1218 [o_open_panel setCanChooseDirectories: b_directory];
1219 [o_open_panel beginSheetForDirectory:nil
1222 modalForWindow:[sender window]
1224 didEndSelector: @selector(pathChosenInPanel:
1230 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
1231 withReturn:(int)i_return_code contextInfo:(void *)o_context_info
1233 if( i_return_code == NSOKButton )
1235 NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
1236 [o_textfield setStringValue: o_path];
1240 - (char *)stringValue
1242 if( [[o_textfield stringValue] length] != 0)
1243 return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
1249 @implementation ModuleConfigControl
1250 - (id) initWithItem: (module_config_t *)_p_item
1251 withView: (NSView *)o_parent_view
1253 NSRect mainFrame = [o_parent_view frame];
1254 NSString *o_labelString, *o_popupTooltip;
1255 mainFrame.size.height = 22;
1256 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1257 mainFrame.origin.x = LEFTMARGIN;
1258 mainFrame.origin.y = 0;
1260 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1265 i_view_type = CONFIG_ITEM_MODULE;
1268 if( p_item->psz_text )
1269 o_labelString = [[VLCMain sharedInstance]
1270 localizedString: p_item->psz_text];
1272 o_labelString = [NSString stringWithString:@""];
1273 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
1274 [o_label setAutoresizingMask:NSViewNotSizable ];
1275 [self addSubview: o_label];
1277 /* build the popup */
1278 o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1279 [[VLCMain sharedInstance]
1280 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1281 ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
1282 -2, 0, o_popupTooltip )
1283 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1284 [o_popup addItemWithTitle: _NS("Default")];
1285 [[o_popup lastItem] setTag: -1];
1286 [o_popup selectItem: [o_popup lastItem]];
1288 /* build a list of available modules */
1289 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1290 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1292 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
1293 if( p_item->i_type == CONFIG_ITEM_MODULE )
1295 if( !strcmp( p_parser->psz_capability,
1296 p_item->psz_type ) )
1298 NSString *o_description = [[VLCMain sharedInstance]
1299 localizedString: p_parser->psz_longname];
1300 [o_popup addItemWithTitle: o_description];
1302 if( p_item->psz_value &&
1303 !strcmp( p_item->psz_value, p_parser->psz_object_name ) )
1304 [o_popup selectItem:[o_popup lastItem]];
1309 module_config_t *p_config;
1310 if( !strcmp( p_parser->psz_object_name, "main" ) )
1313 p_config = p_parser->p_config;
1316 /* Hack: required subcategory is stored in i_min */
1317 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1318 p_config->i_value == p_item->i_min )
1320 NSString *o_description = [[VLCMain sharedInstance]
1321 localizedString: p_parser->psz_longname];
1322 [o_popup addItemWithTitle: o_description];
1324 if( p_item->psz_value && !strcmp(p_item->psz_value,
1325 p_parser->psz_object_name) )
1326 [o_popup selectItem:[o_popup lastItem]];
1328 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
1331 vlc_list_release( p_list );
1332 [self addSubview: o_popup];
1337 - (void) alignWithXPosition:(int)i_xPos
1340 NSRect superFrame = [self frame];
1341 frame = [o_label frame];
1342 frame.origin.x = i_xPos - frame.size.width - 3;
1343 [o_label setFrame:frame];
1345 frame = [o_popup frame];
1346 frame.origin.x = i_xPos - 1;
1347 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1348 [o_popup setFrame:frame];
1357 - (char *)stringValue
1359 NSString *newval = [o_popup titleOfSelectedItem];
1360 char *returnval = NULL;
1365 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1366 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1368 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
1369 if( p_item->i_type == CONFIG_ITEM_MODULE )
1371 if( !strcmp( p_parser->psz_capability,
1372 p_item->psz_type ) )
1374 NSString *o_description = [[VLCMain sharedInstance]
1375 localizedString: p_parser->psz_longname];
1376 if( [newval isEqualToString: o_description] )
1378 returnval = strdup(p_parser->psz_object_name);
1385 module_config_t *p_config;
1386 if( !strcmp( p_parser->psz_object_name, "main" ) )
1389 p_config = p_parser->p_config;
1392 /* Hack: required subcategory is stored in i_min */
1393 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1394 p_config->i_value == p_item->i_min )
1396 NSString *o_description = [[VLCMain sharedInstance]
1397 localizedString: p_parser->psz_longname];
1398 if( [newval isEqualToString: o_description] )
1400 returnval = strdup(p_parser->psz_object_name);
1404 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
1407 vlc_list_release( p_list );
1412 @implementation IntegerConfigControl
1413 - (id) initWithItem: (module_config_t *)_p_item
1414 withView: (NSView *)o_parent_view
1416 NSRect mainFrame = [o_parent_view frame];
1417 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1418 mainFrame.size.height = 23;
1419 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1420 mainFrame.origin.x = LEFTMARGIN;
1421 mainFrame.origin.y = 0;
1423 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1425 i_view_type = CONFIG_ITEM_INTEGER;
1427 o_tooltip = [[VLCMain sharedInstance] wrapString:
1428 [[VLCMain sharedInstance]
1429 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1432 if( p_item->psz_text )
1433 o_labelString = [[VLCMain sharedInstance]
1434 localizedString: p_item->psz_text];
1436 o_labelString = [NSString stringWithString:@""];
1437 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1438 [o_label setAutoresizingMask:NSViewNotSizable ];
1439 [self addSubview: o_label];
1441 /* build the stepper */
1442 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1443 0, o_tooltip, -1600, 1600)
1444 [o_stepper setIntValue: p_item->i_value];
1445 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1446 [self addSubview: o_stepper];
1448 /* build the textfield */
1449 if( p_item->psz_value )
1450 o_textfieldString = [[VLCMain sharedInstance]
1451 localizedString: p_item->psz_value];
1453 o_textfieldString = [NSString stringWithString: @""];
1454 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1455 1, 49, o_tooltip, @"" )
1456 [o_textfield setIntValue: p_item->i_value];
1457 [o_textfield setDelegate: self];
1458 [[NSNotificationCenter defaultCenter] addObserver: self
1459 selector: @selector(textfieldChanged:)
1460 name: NSControlTextDidChangeNotification
1461 object: o_textfield];
1462 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1463 [self addSubview: o_textfield];
1468 - (void) alignWithXPosition:(int)i_xPos
1471 frame = [o_label frame];
1472 frame.origin.x = i_xPos - frame.size.width - 3;
1473 [o_label setFrame:frame];
1475 frame = [o_textfield frame];
1476 frame.origin.x = i_xPos + 2;
1477 [o_textfield setFrame:frame];
1479 frame = [o_stepper frame];
1480 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1481 [o_stepper setFrame:frame];
1486 [o_stepper release];
1487 [o_textfield release];
1491 - (IBAction)stepperChanged:(id)sender
1493 [o_textfield setIntValue: [o_stepper intValue]];
1496 - (void)textfieldChanged:(NSNotification *)o_notification
1498 [o_stepper setIntValue: [o_textfield intValue]];
1503 return [o_textfield intValue];
1508 @implementation IntegerListConfigControl
1510 - (id) initWithItem: (module_config_t *)_p_item
1511 withView: (NSView *)o_parent_view
1513 NSRect mainFrame = [o_parent_view frame];
1514 NSString *o_labelString, *o_textfieldTooltip;
1515 mainFrame.size.height = 22;
1516 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1517 mainFrame.origin.x = LEFTMARGIN;
1518 mainFrame.origin.y = 0;
1520 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1523 i_view_type = CONFIG_ITEM_STRING_LIST;
1526 if( p_item->psz_text )
1527 o_labelString = [[VLCMain sharedInstance]
1528 localizedString: p_item->psz_text];
1530 o_labelString = [NSString stringWithString:@""];
1531 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1532 [o_label setAutoresizingMask:NSViewNotSizable ];
1533 [self addSubview: o_label];
1535 /* build the textfield */
1536 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1537 [[VLCMain sharedInstance]
1538 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1539 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1540 -2, 0, o_textfieldTooltip )
1541 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1542 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1544 if( p_item->i_value == p_item->pi_list[i_index] )
1546 [o_combo selectItemAtIndex: i_index];
1549 [self addSubview: o_combo];
1554 - (void) alignWithXPosition:(int)i_xPos
1557 NSRect superFrame = [self frame];
1558 frame = [o_label frame];
1559 frame.origin.x = i_xPos - frame.size.width - 3;
1560 [o_label setFrame:frame];
1562 frame = [o_combo frame];
1563 frame.origin.x = i_xPos + 2;
1564 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1565 [o_combo setFrame:frame];
1576 if( [o_combo indexOfSelectedItem] >= 0 )
1577 return p_item->pi_list[[o_combo indexOfSelectedItem]];
1579 return [o_combo intValue];
1583 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1584 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1586 return p_item->i_list;
1589 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1591 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1592 return [[VLCMain sharedInstance]
1593 localizedString: p_item->ppsz_list_text[i_index]];
1595 return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1599 @implementation RangedIntegerConfigControl
1600 - (id) initWithItem: (module_config_t *)_p_item
1601 withView: (NSView *)o_parent_view
1603 NSRect mainFrame = [o_parent_view frame];
1604 NSString *o_labelString, *o_tooltip;
1605 mainFrame.size.height = 50;
1606 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1607 mainFrame.origin.x = LEFTMARGIN;
1608 mainFrame.origin.y = 0;
1610 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1612 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1615 if( p_item->psz_text )
1616 o_labelString = [[VLCMain sharedInstance]
1617 localizedString: p_item->psz_text];
1619 o_labelString = [NSString stringWithString:@""];
1620 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1621 [o_label setAutoresizingMask:NSViewNotSizable ];
1622 [self addSubview: o_label];
1624 /* build the textfield */
1625 o_tooltip = [[VLCMain sharedInstance] wrapString:
1626 [[VLCMain sharedInstance]
1627 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1628 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1629 28, 49, o_tooltip, @"" )
1630 [o_textfield setIntValue: p_item->i_value];
1631 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1632 [o_textfield setDelegate: self];
1633 [[NSNotificationCenter defaultCenter] addObserver: self
1634 selector: @selector(textfieldChanged:)
1635 name: NSControlTextDidChangeNotification
1636 object: o_textfield];
1637 [self addSubview: o_textfield];
1639 /* build the mintextfield */
1640 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1641 [o_textfield_min setIntValue: p_item->i_min];
1642 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1643 [o_textfield_min setAlignment:NSRightTextAlignment];
1644 [self addSubview: o_textfield_min];
1646 /* build the maxtextfield */
1647 ADD_LABEL( o_textfield_max, mainFrame,
1648 mainFrame.size.width - 31, -30, @"8888" )
1649 [o_textfield_max setIntValue: p_item->i_max];
1650 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1651 [self addSubview: o_textfield_max];
1653 /* build the slider */
1654 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1655 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1656 [o_textfield_max frame].size.width -
1657 [o_textfield_max frame].size.width - 14 -
1658 [o_textfield_min frame].origin.x, o_tooltip,
1659 p_item->i_min, p_item->i_max )
1660 [o_slider setIntValue: p_item->i_value];
1661 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1662 [o_slider setTarget: self];
1663 [o_slider setAction: @selector(sliderChanged:)];
1664 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1665 NSLeftMouseDraggedMask];
1666 [self addSubview: o_slider];
1672 - (void) alignWithXPosition:(int)i_xPos
1675 frame = [o_label frame];
1676 frame.origin.x = i_xPos - frame.size.width - 3;
1677 [o_label setFrame:frame];
1679 frame = [o_textfield frame];
1680 frame.origin.x = i_xPos + 2;
1681 [o_textfield setFrame:frame];
1686 [o_textfield release];
1687 [o_textfield_min release];
1688 [o_textfield_max release];
1693 - (IBAction)sliderChanged:(id)sender
1695 [o_textfield setIntValue: [o_slider intValue]];
1698 - (void)textfieldChanged:(NSNotification *)o_notification
1700 [o_slider setIntValue: [o_textfield intValue]];
1705 return [o_slider intValue];
1709 @implementation FloatConfigControl
1710 - (id) initWithItem: (module_config_t *)_p_item
1711 withView: (NSView *)o_parent_view
1713 NSRect mainFrame = [o_parent_view frame];
1714 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1715 mainFrame.size.height = 23;
1716 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1717 mainFrame.origin.x = LEFTMARGIN;
1718 mainFrame.origin.y = 0;
1720 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1722 i_view_type = CONFIG_ITEM_INTEGER;
1724 o_tooltip = [[VLCMain sharedInstance] wrapString:
1725 [[VLCMain sharedInstance]
1726 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1729 if( p_item->psz_text )
1730 o_labelString = [[VLCMain sharedInstance]
1731 localizedString: p_item->psz_text];
1733 o_labelString = [NSString stringWithString:@""];
1734 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
1735 [o_label setAutoresizingMask:NSViewNotSizable ];
1736 [self addSubview: o_label];
1738 /* build the stepper */
1739 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1740 0, o_tooltip, -1600, 1600)
1741 [o_stepper setFloatValue: p_item->f_value];
1742 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1743 [self addSubview: o_stepper];
1745 /* build the textfield */
1746 if( p_item->psz_value )
1747 o_textfieldString = [[VLCMain sharedInstance]
1748 localizedString: p_item->psz_value];
1750 o_textfieldString = [NSString stringWithString: @""];
1751 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1752 1, 49, o_tooltip, @"" )
1753 [o_textfield setFloatValue: p_item->f_value];
1754 [o_textfield setDelegate: self];
1755 [[NSNotificationCenter defaultCenter] addObserver: self
1756 selector: @selector(textfieldChanged:)
1757 name: NSControlTextDidChangeNotification
1758 object: o_textfield];
1759 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1760 [self addSubview: o_textfield];
1765 - (void) alignWithXPosition:(int)i_xPos
1768 frame = [o_label frame];
1769 frame.origin.x = i_xPos - frame.size.width - 3;
1770 [o_label setFrame:frame];
1772 frame = [o_textfield frame];
1773 frame.origin.x = i_xPos + 2;
1774 [o_textfield setFrame:frame];
1776 frame = [o_stepper frame];
1777 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1778 [o_stepper setFrame:frame];
1783 [o_stepper release];
1784 [o_textfield release];
1788 - (IBAction)stepperChanged:(id)sender
1790 [o_textfield setFloatValue: [o_stepper floatValue]];
1793 - (void)textfieldChanged:(NSNotification *)o_notification
1795 [o_stepper setFloatValue: [o_textfield floatValue]];
1800 return [o_stepper floatValue];
1804 @implementation RangedFloatConfigControl
1805 - (id) initWithItem: (module_config_t *)_p_item
1806 withView: (NSView *)o_parent_view
1808 NSRect mainFrame = [o_parent_view frame];
1809 NSString *o_labelString, *o_tooltip;
1810 mainFrame.size.height = 50;
1811 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1812 mainFrame.origin.x = LEFTMARGIN;
1813 mainFrame.origin.y = 0;
1815 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1817 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1820 if( p_item->psz_text )
1821 o_labelString = [[VLCMain sharedInstance]
1822 localizedString: p_item->psz_text];
1824 o_labelString = [NSString stringWithString:@""];
1825 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1826 [o_label setAutoresizingMask:NSViewNotSizable ];
1827 [self addSubview: o_label];
1829 /* build the textfield */
1830 o_tooltip = [[VLCMain sharedInstance] wrapString:
1831 [[VLCMain sharedInstance]
1832 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1833 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1834 28, 49, o_tooltip, @"" )
1835 [o_textfield setFloatValue: p_item->f_value];
1836 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1837 [o_textfield setDelegate: self];
1838 [[NSNotificationCenter defaultCenter] addObserver: self
1839 selector: @selector(textfieldChanged:)
1840 name: NSControlTextDidChangeNotification
1841 object: o_textfield];
1842 [self addSubview: o_textfield];
1844 /* build the mintextfield */
1845 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1846 [o_textfield_min setFloatValue: p_item->f_min];
1847 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1848 [o_textfield_min setAlignment:NSRightTextAlignment];
1849 [self addSubview: o_textfield_min];
1851 /* build the maxtextfield */
1852 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
1854 [o_textfield_max setFloatValue: p_item->f_max];
1855 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1856 [self addSubview: o_textfield_max];
1858 /* build the slider */
1859 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1860 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1861 [o_textfield_max frame].size.width -
1862 [o_textfield_max frame].size.width - 14 -
1863 [o_textfield_min frame].origin.x, o_tooltip, p_item->f_min,
1865 [o_slider setFloatValue: p_item->f_value];
1866 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1867 [o_slider setTarget: self];
1868 [o_slider setAction: @selector(sliderChanged:)];
1869 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1870 NSLeftMouseDraggedMask];
1871 [self addSubview: o_slider];
1877 - (void) alignWithXPosition:(int)i_xPos
1880 frame = [o_label frame];
1881 frame.origin.x = i_xPos - frame.size.width - 3;
1882 [o_label setFrame:frame];
1884 frame = [o_textfield frame];
1885 frame.origin.x = i_xPos + 2;
1886 [o_textfield setFrame:frame];
1891 [o_textfield release];
1892 [o_textfield_min release];
1893 [o_textfield_max release];
1898 - (IBAction)sliderChanged:(id)sender
1900 [o_textfield setFloatValue: [o_slider floatValue]];
1903 - (void)textfieldChanged:(NSNotification *)o_notification
1905 [o_slider setFloatValue: [o_textfield floatValue]];
1910 return [o_slider floatValue];
1915 @implementation BoolConfigControl
1917 - (id) initWithItem: (module_config_t *)_p_item
1918 withView: (NSView *)o_parent_view
1920 NSRect mainFrame = [o_parent_view frame];
1921 NSString *o_labelString, *o_tooltip;
1922 mainFrame.size.height = 17;
1923 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1924 mainFrame.origin.x = LEFTMARGIN;
1925 mainFrame.origin.y = 0;
1927 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1929 i_view_type = CONFIG_ITEM_BOOL;
1932 if( p_item->psz_text )
1933 o_labelString = [[VLCMain sharedInstance]
1934 localizedString: p_item->psz_text];
1936 o_labelString = [NSString stringWithString:@""];
1937 ADD_LABEL( o_label, mainFrame, 0, 0, o_labelString )
1938 [o_label setAutoresizingMask:NSViewNotSizable ];
1939 [self addSubview: o_label];
1940 /* add the checkbox */
1941 o_tooltip = [[VLCMain sharedInstance]
1942 wrapString: [[VLCMain sharedInstance]
1943 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1944 ADD_CHECKBOX( o_checkbox, mainFrame, [o_label frame].size.width,
1945 0, @"", o_tooltip, p_item->i_value, NSImageLeft)
1946 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1947 [self addSubview: o_checkbox];
1952 - (void) alignWithXPosition:(int)i_xPos
1955 frame = [o_label frame];
1956 frame.origin.x = i_xPos - frame.size.width - 3;
1957 [o_label setFrame:frame];
1959 frame = [o_checkbox frame];
1960 frame.origin.x = i_xPos;
1961 [o_checkbox setFrame:frame];
1966 [o_checkbox release];
1972 return [o_checkbox intValue];
1977 @implementation KeyConfigControlBefore103
1979 - (id) initWithItem: (module_config_t *)_p_item
1980 withView: (NSView *)o_parent_view
1982 NSRect mainFrame = [o_parent_view frame];
1983 NSString *o_labelString, *o_tooltip;
1984 mainFrame.size.height = 37;
1985 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1986 mainFrame.origin.x = LEFTMARGIN;
1987 mainFrame.origin.y = 0;
1989 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1991 i_view_type = CONFIG_ITEM_KEY_BEFORE_10_3;
1994 if( p_item->psz_text )
1995 o_labelString = [[VLCMain sharedInstance]
1996 localizedString: p_item->psz_text];
1998 o_labelString = [NSString stringWithString:@""];
1999 ADD_LABEL( o_label, mainFrame, 0, -10, o_labelString )
2000 [o_label setAutoresizingMask:NSViewNotSizable ];
2001 [self addSubview: o_label];
2003 /* add the checkboxes */
2004 o_tooltip = [[VLCMain sharedInstance] wrapString:
2005 [[VLCMain sharedInstance]
2006 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2007 ADD_CHECKBOX( o_cmd_checkbox, mainFrame,
2008 [o_label frame].size.width + 2, 0,
2009 [NSString stringWithUTF8String:PLACE_OF_INTEREST_SIGN], o_tooltip,
2010 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_COMMAND)?YES:NO),
2012 [o_cmd_checkbox setState: p_item->i_value & KEY_MODIFIER_COMMAND];
2013 ADD_CHECKBOX( o_ctrl_checkbox, mainFrame,
2014 [o_cmd_checkbox frame].size.width +
2015 [o_cmd_checkbox frame].origin.x + 6, 0,
2016 [NSString stringWithUTF8String:UP_ARROWHEAD], o_tooltip,
2017 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_CTRL)?YES:NO),
2019 [o_ctrl_checkbox setState: p_item->i_value & KEY_MODIFIER_CTRL];
2020 ADD_CHECKBOX( o_alt_checkbox, mainFrame, [o_label frame].size.width +
2021 2, -2 - [o_cmd_checkbox frame].size.height,
2022 [NSString stringWithUTF8String:OPTION_KEY], o_tooltip,
2023 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_ALT)?YES:NO),
2025 [o_alt_checkbox setState: p_item->i_value & KEY_MODIFIER_ALT];
2026 ADD_CHECKBOX( o_shift_checkbox, mainFrame,
2027 [o_cmd_checkbox frame].size.width +
2028 [o_cmd_checkbox frame].origin.x + 6, -2 -
2029 [o_cmd_checkbox frame].size.height,
2030 [NSString stringWithUTF8String:UPWARDS_WHITE_ARROW], o_tooltip,
2031 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_SHIFT)?YES:NO),
2033 [o_shift_checkbox setState: p_item->i_value & KEY_MODIFIER_SHIFT];
2034 [self addSubview: o_cmd_checkbox];
2035 [self addSubview: o_ctrl_checkbox];
2036 [self addSubview: o_alt_checkbox];
2037 [self addSubview: o_shift_checkbox];
2039 /* build the popup */
2040 ADD_POPUP( o_popup, mainFrame, [o_shift_checkbox frame].origin.x +
2041 [o_shift_checkbox frame].size.width + 4,
2043 [o_popup setAutoresizingMask:NSViewWidthSizable ];
2045 if( o_keys_menu == nil )
2048 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
2049 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
2050 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
2051 POPULATE_A_KEY( o_keys_menu,
2052 [NSString stringWithCString:vlc_keys[i].psz_key_string]
2053 , vlc_keys[i].i_key_code)
2055 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2056 [o_popup selectItemWithTitle: [[VLCMain sharedInstance]
2057 localizedString:KeyToString(
2058 (((unsigned int)p_item->i_value) & ~KEY_MODIFIER ))]];
2059 [self addSubview: o_popup];
2064 - (void) alignWithXPosition:(int)i_xPos
2067 NSRect superFrame = [self frame];
2068 frame = [o_label frame];
2069 frame.origin.x = i_xPos - frame.size.width - 3;
2070 [o_label setFrame:frame];
2072 frame = [o_cmd_checkbox frame];
2073 frame.origin.x = i_xPos;
2074 [o_cmd_checkbox setFrame:frame];
2076 frame = [o_ctrl_checkbox frame];
2077 frame.origin.x = [o_cmd_checkbox frame].size.width +
2078 [o_cmd_checkbox frame].origin.x + 4;
2079 [o_ctrl_checkbox setFrame:frame];
2081 frame = [o_alt_checkbox frame];
2082 frame.origin.x = i_xPos;
2083 [o_alt_checkbox setFrame:frame];
2085 frame = [o_shift_checkbox frame];
2086 frame.origin.x = [o_cmd_checkbox frame].size.width +
2087 [o_cmd_checkbox frame].origin.x + 4;
2088 [o_shift_checkbox setFrame:frame];
2090 frame = [o_popup frame];
2091 frame.origin.x = [o_shift_checkbox frame].origin.x +
2092 [o_shift_checkbox frame].size.width + 3;
2093 frame.size.width = superFrame.size.width - frame.origin.x + 2;
2094 [o_popup setFrame:frame];
2099 [o_cmd_checkbox release];
2100 [o_ctrl_checkbox release];
2101 [o_alt_checkbox release];
2102 [o_shift_checkbox release];
2109 unsigned int i_new_key = 0;
2111 i_new_key |= ([o_cmd_checkbox state] == NSOnState) ?
2112 KEY_MODIFIER_COMMAND : 0;
2113 i_new_key |= ([o_ctrl_checkbox state] == NSOnState) ?
2114 KEY_MODIFIER_CTRL : 0;
2115 i_new_key |= ([o_alt_checkbox state] == NSOnState) ?
2116 KEY_MODIFIER_ALT : 0;
2117 i_new_key |= ([o_shift_checkbox state] == NSOnState) ?
2118 KEY_MODIFIER_SHIFT : 0;
2120 i_new_key |= StringToKey([[[o_popup selectedItem] title] cString]);
2125 @implementation KeyConfigControlAfter103
2126 - (id) initWithItem: (module_config_t *)_p_item
2127 withView: (NSView *)o_parent_view
2129 NSRect mainFrame = [o_parent_view frame];
2130 NSString *o_labelString, *o_tooltip;
2131 mainFrame.size.height = 22;
2132 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
2133 mainFrame.origin.x = LEFTMARGIN;
2134 mainFrame.origin.y = 0;
2136 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2138 i_view_type = CONFIG_ITEM_KEY_AFTER_10_3;
2141 if( p_item->psz_text )
2142 o_labelString = [[VLCMain sharedInstance]
2143 localizedString: p_item->psz_text];
2145 o_labelString = [NSString stringWithString:@""];
2146 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
2147 [o_label setAutoresizingMask:NSViewNotSizable ];
2148 [self addSubview: o_label];
2150 /* build the popup */
2151 o_tooltip = [[VLCMain sharedInstance] wrapString:
2152 [[VLCMain sharedInstance]
2153 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2154 ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
2155 [o_label frame].size.width + 3,
2157 [o_popup setAutoresizingMask:NSViewWidthSizable ];
2159 if( o_keys_menu == nil )
2162 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
2163 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
2164 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
2165 POPULATE_A_KEY( o_keys_menu,
2166 [NSString stringWithCString:vlc_keys[i].psz_key_string]
2167 , vlc_keys[i].i_key_code)
2169 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2170 [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->i_value]];
2171 [self addSubview: o_popup];
2177 - (void) alignWithXPosition:(int)i_xPos
2180 NSRect superFrame = [self frame];
2181 frame = [o_label frame];
2182 frame.origin.x = i_xPos - frame.size.width - 3;
2183 [o_label setFrame:frame];
2185 frame = [o_popup frame];
2186 frame.origin.x = i_xPos - 1;
2187 frame.size.width = superFrame.size.width - frame.origin.x + 2;
2188 [o_popup setFrame:frame];
2199 return [o_popup selectedTag];
2203 @implementation ModuleListConfigControl
2204 - (id) initWithItem: (module_config_t *)_p_item
2205 withView: (NSView *)o_parent_view
2207 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
2211 //Fill our array to know how may items we have...
2215 NSRect mainFrame = [o_parent_view frame];
2216 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2218 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2219 /* build a list of available modules */
2220 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
2221 for( i_index = 0; i_index < p_list->i_count; i_index++ )
2223 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
2225 if( !strcmp( p_parser->psz_object_name, "main" ) )
2228 module_config_t *p_config = p_parser->p_config;
2231 NSString *o_modulelongname, *o_modulename;
2232 NSNumber *o_moduleenabled = nil;
2233 /* Hack: required subcategory is stored in i_min */
2234 if( p_config->i_type == CONFIG_SUBCATEGORY &&
2235 p_config->i_value == _p_item->i_min )
2237 o_modulelongname = [NSString stringWithUTF8String:
2238 p_parser->psz_longname];
2239 o_modulename = [NSString stringWithUTF8String:
2240 p_parser->psz_object_name];
2242 if( _p_item->psz_value &&
2243 strstr( _p_item->psz_value, p_parser->psz_object_name ) )
2244 o_moduleenabled = [NSNumber numberWithBool:YES];
2246 o_moduleenabled = [NSNumber numberWithBool:NO];
2248 [o_modulearray addObject:[NSMutableArray
2249 arrayWithObjects: o_modulename, o_modulelongname,
2250 o_moduleenabled, nil]];
2252 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
2254 vlc_list_release( p_list );
2256 mainFrame.size.height = 30 + 18 * [o_modulearray count];
2257 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2258 mainFrame.origin.x = LEFTMARGIN;
2259 mainFrame.origin.y = 0;
2260 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2262 i_view_type = CONFIG_ITEM_MODULE_LIST;
2265 if( p_item->psz_text )
2266 o_labelString = [[VLCMain sharedInstance]
2267 localizedString: p_item->psz_text];
2269 o_labelString = [NSString stringWithString:@""];
2270 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
2271 [o_label setAutoresizingMask:NSViewNotSizable ];
2272 [self addSubview: o_label];
2274 /* build the textfield */
2275 o_tooltip = [[VLCMain sharedInstance] wrapString:
2276 [[VLCMain sharedInstance]
2277 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2278 if( p_item->psz_value )
2279 o_textfieldString = [[VLCMain sharedInstance]
2280 localizedString: p_item->psz_value];
2282 o_textfieldString = [NSString stringWithString: @""];
2283 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
2284 mainFrame.size.height - 22, mainFrame.size.width -
2285 [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
2286 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2287 [self addSubview: o_textfield];
2291 NSRect s_rc = mainFrame;
2292 s_rc.size.height = mainFrame.size.height - 30;
2293 s_rc.size.width = mainFrame.size.width - 12;
2296 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2297 [o_scrollview setDrawsBackground: NO];
2298 [o_scrollview setBorderType: NSBezelBorder];
2299 [o_scrollview setAutohidesScrollers:YES];
2301 NSTableView *o_tableview;
2302 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2303 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2304 [o_tableview setHeaderView:nil];
2305 /* TODO: find a good way to fix the row height and text size*/
2306 /* FIXME: support for multiple selection... */
2307 // [o_tableview setAllowsMultipleSelection:YES];
2309 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2310 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2311 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2312 [o_dataCell setTitle:@""];
2313 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2314 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2315 initWithIdentifier:[NSString stringWithCString: "Enabled"]];
2316 [o_tableColumn setHeaderCell: o_headerCell];
2317 [o_tableColumn setDataCell: o_dataCell];
2318 [o_tableColumn setWidth:17];
2319 [o_tableview addTableColumn: o_tableColumn];
2321 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2322 o_dataCell = [[NSTextFieldCell alloc] init];
2323 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2324 o_tableColumn = [[NSTableColumn alloc]
2325 initWithIdentifier:[NSString stringWithCString: "Module"]];
2326 [o_tableColumn setHeaderCell: o_headerCell];
2327 [o_tableColumn setDataCell: o_dataCell];
2328 [o_tableColumn setWidth:388 - 17];
2329 [o_tableview addTableColumn: o_tableColumn];
2330 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2331 @"VLC media player module", nil]];
2333 [o_tableview setDataSource:self];
2334 [o_tableview setTarget: self];
2335 [o_tableview setAction: @selector(tableChanged:)];
2336 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2337 NSLeftMouseDraggedMask];
2338 [o_scrollview setDocumentView: o_tableview];
2340 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2341 [self addSubview: o_scrollview];
2348 - (void) alignWithXPosition:(int)i_xPos
2353 - (IBAction)tableChanged:(id)sender
2355 NSString *o_newstring = @"";
2357 for( i = 0 ; i < [o_modulearray count] ; i++ )
2358 if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2361 o_newstring = [o_newstring stringByAppendingString:
2362 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2363 o_newstring = [o_newstring stringByAppendingString:@","];
2366 [o_textfield setStringValue: [o_newstring
2367 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2372 [o_scrollview release];
2377 - (char *)stringValue
2379 return strdup( [[o_textfield stringValue] cString] );
2384 @implementation ModuleListConfigControl (NSTableDataSource)
2386 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2387 toPasteboard:(NSPasteboard*)pb
2389 // We only want to allow dragging of selected rows.
2390 NSEnumerator *iter = [rows objectEnumerator];
2392 while ((row = [iter nextObject]) != nil)
2394 if (![table isRowSelected:[row intValue]])
2398 [pb declareTypes:[NSArray
2399 arrayWithObject:@"VLC media player module"] owner:nil];
2400 [pb setPropertyList:rows forType:@"VLC media player module"];
2404 - (NSDragOperation)tableView:(NSTableView*)table
2405 validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row
2406 proposedDropOperation:(NSTableViewDropOperation)op
2408 // Make drops at the end of the table go to the end.
2411 row = [table numberOfRows];
2412 op = NSTableViewDropAbove;
2413 [table setDropRow:row dropOperation:op];
2416 // We don't ever want to drop onto a row, only between rows.
2417 if (op == NSTableViewDropOn)
2418 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2419 return NSTableViewDropAbove;
2422 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2423 row:(int)dropRow dropOperation:(NSTableViewDropOperation)op;
2425 NSPasteboard *pb = [info draggingPasteboard];
2426 NSDragOperation srcMask = [info draggingSourceOperationMask];
2433 // Intra-table drag - data is the array of rows.
2434 if (!accepted && (array =
2435 [pb propertyListForType:@"VLC media player module"]) != NULL)
2437 NSEnumerator *iter = nil;
2439 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2441 iter = [array objectEnumerator];
2442 while ((val = [iter nextObject]) != NULL)
2444 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2445 [val intValue]] mutableCopyWithZone:nil];
2446 [o_modulearray removeObject:o_tmp];
2447 [o_modulearray insertObject:o_tmp
2448 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2452 // Select the newly-dragged items.
2453 iter = [array objectEnumerator];
2455 [table deselectAll:self];
2457 [self tableChanged:self];
2458 [table setNeedsDisplay:YES];
2459 // Indicate that we finished the drag.
2463 [table setNeedsDisplay:YES];
2467 // An exception occurred. Uh-oh. Update the track table so that
2468 // it stays consistent, and re-raise the exception.
2470 [localException raise];
2471 [table setNeedsDisplay:YES];
2477 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
2479 return [o_modulearray count];
2482 - (id)tableView:(NSTableView *)aTableView
2483 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2485 if( [[aTableColumn identifier] isEqualToString:
2486 [NSString stringWithCString:"Enabled"]] )
2487 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2488 if( [[aTableColumn identifier] isEqualToString:
2489 [NSString stringWithCString:"Module"]] )
2490 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2495 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2496 forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2498 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2499 withObject: anObject];