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 [o_mi setAlternate: NO]; \
61 [o_menu addItem: o_mi]; \
62 if( MACOS_VERSION >= 10.3 ) \
65 o_mi = [[NSMenuItem alloc] initWithTitle: \
66 [[NSString stringWithUTF8String: \
68 ] stringByAppendingString: string] \
69 action:nil keyEquivalent:@""]; \
70 [o_mi setKeyEquivalentModifierMask: \
72 [o_mi setAlternate: YES]; \
74 KEY_MODIFIER_CTRL | ( value )]; \
75 [o_menu addItem: o_mi]; \
77 o_mi = [[NSMenuItem alloc] initWithTitle: \
78 [[NSString stringWithUTF8String: \
79 UP_ARROWHEAD OPTION_KEY \
80 ] stringByAppendingString: string] \
81 action:nil keyEquivalent:@""]; \
82 [o_mi setKeyEquivalentModifierMask: \
83 NSControlKeyMask | NSAlternateKeyMask]; \
84 [o_mi setAlternate: YES]; \
86 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | ( value )]; \
87 [o_menu addItem: o_mi]; \
89 o_mi = [[NSMenuItem alloc] initWithTitle: \
90 [[NSString stringWithUTF8String: \
91 UP_ARROWHEAD UPWARDS_WHITE_ARROW \
92 ] stringByAppendingString: string] \
93 action:nil keyEquivalent:@""]; \
94 [o_mi setKeyEquivalentModifierMask: \
95 NSControlKeyMask | NSShiftKeyMask]; \
96 [o_mi setAlternate: YES]; \
98 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | ( value )]; \
99 [o_menu addItem: o_mi]; \
101 o_mi = [[NSMenuItem alloc] initWithTitle: \
102 [[NSString stringWithUTF8String: \
103 UP_ARROWHEAD PLACE_OF_INTEREST_SIGN \
104 ] stringByAppendingString: string] \
105 action:nil keyEquivalent:@""]; \
106 [o_mi setKeyEquivalentModifierMask: \
107 NSControlKeyMask | NSCommandKeyMask]; \
108 [o_mi setAlternate: YES]; \
110 (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | ( value )]; \
111 [o_menu addItem: o_mi]; \
112 /* Ctrl+Alt+Shift */ \
113 o_mi = [[NSMenuItem alloc] initWithTitle: \
114 [[NSString stringWithUTF8String: \
115 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
116 ] stringByAppendingString: string] \
117 action:nil keyEquivalent:@""]; \
118 [o_mi setKeyEquivalentModifierMask: \
119 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
120 [o_mi setAlternate: YES]; \
122 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | \
124 [o_menu addItem: o_mi]; \
125 /* Ctrl+Alt+Apple */ \
126 o_mi = [[NSMenuItem alloc] initWithTitle: \
127 [[NSString stringWithUTF8String: \
128 UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN \
129 ] stringByAppendingString: string] \
130 action:nil keyEquivalent:@""]; \
131 [o_mi setKeyEquivalentModifierMask: \
132 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
133 [o_mi setAlternate: YES]; \
135 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
137 [o_menu addItem: o_mi]; \
138 /* Ctrl+Shift+Apple */ \
139 o_mi = [[NSMenuItem alloc] initWithTitle: \
140 [[NSString stringWithUTF8String: \
141 UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
142 ] stringByAppendingString: string] \
143 action:nil keyEquivalent:@""]; \
144 [o_mi setKeyEquivalentModifierMask: \
145 NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
146 [o_mi setAlternate: YES]; \
148 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
150 [o_menu addItem: o_mi]; \
151 /* Ctrl+Alt+Shift+Apple */ \
152 o_mi = [[NSMenuItem alloc] initWithTitle: \
153 [[NSString stringWithUTF8String: \
154 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
155 PLACE_OF_INTEREST_SIGN \
156 ] stringByAppendingString: string] \
157 action:nil keyEquivalent:@""]; \
158 [o_mi setKeyEquivalentModifierMask: \
159 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
161 [o_mi setAlternate: YES]; \
163 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
164 KEY_MODIFIER_COMMAND) | ( value )]; \
165 [o_menu addItem: o_mi]; \
167 o_mi = [[NSMenuItem alloc] initWithTitle: \
168 [[NSString stringWithUTF8String: \
170 ] stringByAppendingString: string] \
171 action:nil keyEquivalent:@""]; \
172 [o_mi setKeyEquivalentModifierMask: \
173 NSAlternateKeyMask]; \
174 [o_mi setAlternate: YES]; \
176 KEY_MODIFIER_ALT | ( value )]; \
177 [o_menu addItem: o_mi]; \
179 o_mi = [[NSMenuItem alloc] initWithTitle: \
180 [[NSString stringWithUTF8String: \
181 OPTION_KEY UPWARDS_WHITE_ARROW \
182 ] stringByAppendingString: string] \
183 action:nil keyEquivalent:@""]; \
184 [o_mi setKeyEquivalentModifierMask: \
185 NSAlternateKeyMask | NSShiftKeyMask]; \
186 [o_mi setAlternate: YES]; \
188 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )]; \
189 [o_menu addItem: o_mi]; \
191 o_mi = [[NSMenuItem alloc] initWithTitle: \
192 [[NSString stringWithUTF8String: \
193 OPTION_KEY PLACE_OF_INTEREST_SIGN \
194 ] stringByAppendingString: string] \
195 action:nil keyEquivalent:@""]; \
196 [o_mi setKeyEquivalentModifierMask: \
197 NSAlternateKeyMask | NSCommandKeyMask]; \
198 [o_mi setAlternate: YES]; \
200 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )]; \
201 [o_menu addItem: o_mi]; \
202 /* Alt+Shift+Apple */ \
203 o_mi = [[NSMenuItem alloc] initWithTitle: \
204 [[NSString stringWithUTF8String: \
205 OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
206 ] stringByAppendingString: string] \
207 action:nil keyEquivalent:@""]; \
208 [o_mi setKeyEquivalentModifierMask: \
209 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
210 [o_mi setAlternate: YES]; \
212 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
214 [o_menu addItem: o_mi]; \
216 o_mi = [[NSMenuItem alloc] initWithTitle: \
217 [[NSString stringWithUTF8String: \
218 UPWARDS_WHITE_ARROW \
219 ] stringByAppendingString: string] \
220 action:nil keyEquivalent:@""]; \
221 [o_mi setKeyEquivalentModifierMask: \
223 [o_mi setAlternate: YES]; \
225 KEY_MODIFIER_SHIFT | ( value )]; \
226 [o_menu addItem: o_mi]; \
228 o_mi = [[NSMenuItem alloc] initWithTitle: \
229 [[NSString stringWithUTF8String: \
230 UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
231 ] stringByAppendingString: string] \
232 action:nil keyEquivalent:@""]; \
233 [o_mi setKeyEquivalentModifierMask: \
234 NSShiftKeyMask | NSCommandKeyMask]; \
235 [o_mi setAlternate: YES]; \
237 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \
238 [o_menu addItem: o_mi]; \
240 o_mi = [[NSMenuItem alloc] initWithTitle: \
241 [[NSString stringWithUTF8String: \
242 PLACE_OF_INTEREST_SIGN \
243 ] stringByAppendingString: string] \
244 action:nil keyEquivalent:@""]; \
245 [o_mi setKeyEquivalentModifierMask: \
247 [o_mi setAlternate: YES]; \
249 KEY_MODIFIER_COMMAND | ( value )]; \
250 [o_menu addItem: o_mi]; \
254 #define ADD_LABEL( o_label, superFrame, x_offset, my_y_offset, label ) \
256 NSRect s_rc = superFrame; \
257 s_rc.size.height = 17; \
258 s_rc.origin.x = x_offset - 3; \
259 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
260 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
261 [o_label setDrawsBackground: NO]; \
262 [o_label setBordered: NO]; \
263 [o_label setEditable: NO]; \
264 [o_label setSelectable: NO]; \
265 [o_label setStringValue: label]; \
266 [o_label setFont:[NSFont systemFontOfSize:0]]; \
267 [o_label sizeToFit]; \
270 #define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \
271 my_width, tooltip, init_value ) \
273 NSRect s_rc = superFrame; \
274 s_rc.origin.x = x_offset; \
275 s_rc.origin.y = my_y_offset; \
276 s_rc.size.height = 22; \
277 s_rc.size.width = my_width; \
278 o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
279 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
280 [o_textfield setToolTip: tooltip]; \
281 [o_textfield setStringValue: init_value]; \
284 #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
287 NSRect s_rc = superFrame; \
288 s_rc.origin.x = x_offset + 2; \
289 s_rc.origin.y = my_y_offset; \
290 s_rc.size.height = 26; \
291 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
293 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
294 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
295 [o_combo setToolTip: tooltip]; \
296 [o_combo setUsesDataSource:TRUE]; \
297 [o_combo setDataSource:self]; \
298 [o_combo setNumberOfVisibleItems:10]; \
299 [o_combo setCompletes:YES]; \
302 #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, \
305 NSRect s_rc = superFrame; \
306 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
307 [o_button setButtonType: NSMomentaryPushInButton]; \
308 [o_button setBezelStyle: NSRoundedBezelStyle]; \
309 [o_button setTitle: title]; \
310 [o_button setFont:[NSFont systemFontOfSize:0]]; \
311 [o_button sizeToFit]; \
312 s_rc = [o_button frame]; \
313 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
314 s_rc.origin.y = my_y_offset - 6; \
315 s_rc.size.width += 12; \
316 [o_button setFrame: s_rc]; \
317 [o_button setToolTip: tooltip]; \
318 [o_button setTarget: self]; \
319 [o_button setAction: @selector(openFileDialog:)]; \
322 #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
325 NSRect s_rc = superFrame; \
326 s_rc.origin.x = x_offset - 1; \
327 s_rc.origin.y = my_y_offset; \
328 s_rc.size.height = 26; \
329 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
331 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
332 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
333 [o_popup setToolTip: tooltip]; \
336 #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
339 NSRect s_rc = superFrame; \
340 s_rc.origin.x = x_offset; \
341 s_rc.origin.y = my_y_offset; \
342 s_rc.size.height = 23; \
343 s_rc.size.width = 23; \
344 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
345 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
346 [o_stepper setToolTip: tooltip]; \
347 [o_stepper setMaxValue: higher]; \
348 [o_stepper setMinValue: lower]; \
349 [o_stepper setTarget: self]; \
350 [o_stepper setAction: @selector(stepperChanged:)]; \
351 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
352 NSLeftMouseDraggedMask]; \
355 #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, \
356 tooltip, lower, higher ) \
358 NSRect s_rc = superFrame; \
359 s_rc.origin.x = x_offset; \
360 s_rc.origin.y = my_y_offset; \
361 s_rc.size.height = 21; \
362 s_rc.size.width = my_width; \
363 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
364 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
365 [o_slider setToolTip: tooltip]; \
366 [o_slider setMaxValue: higher]; \
367 [o_slider setMinValue: lower]; \
370 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
371 tooltip, init_value, position ) \
373 NSRect s_rc = superFrame; \
374 s_rc.size.height = 18; \
375 s_rc.origin.x = x_offset - 2; \
376 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
377 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
378 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
379 [o_checkbox setButtonType: NSSwitchButton]; \
380 [o_checkbox setImagePosition: position]; \
381 [o_checkbox setIntValue: init_value]; \
382 [o_checkbox setTitle: label]; \
383 [o_checkbox setToolTip: tooltip]; \
384 [o_checkbox sizeToFit]; \
387 @implementation VLCConfigControl
388 - (id)initWithFrame: (NSRect)frame
390 return [self initWithFrame: frame
394 - (id)initWithFrame: (NSRect)frame
395 item: (module_config_t *)_p_item
397 self = [super initWithFrame: frame];
402 psz_name = strdup( p_item->psz_name );
404 i_type = p_item->i_type;
406 b_advanced = p_item->b_advanced;
407 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
412 - (void)setYPos:(int)i_yPos
414 NSRect frame = [self frame];
415 frame.origin.y = i_yPos;
416 [self setFrame:frame];
421 if( o_label ) [o_label release];
422 if( psz_name ) free( psz_name );
426 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
431 case CONFIG_ITEM_STRING:
434 case CONFIG_ITEM_STRING:
437 case CONFIG_ITEM_STRING_LIST:
440 case CONFIG_ITEM_FILE:
443 case CONFIG_ITEM_MODULE:
446 case CONFIG_ITEM_INTEGER:
449 case CONFIG_ITEM_RANGED_INTEGER:
452 case CONFIG_ITEM_BOOL:
455 case CONFIG_ITEM_KEY_BEFORE_10_3:
458 case CONFIG_ITEM_KEY_AFTER_10_3:
461 case CONFIG_ITEM_MODULE_LIST:
469 case CONFIG_ITEM_STRING_LIST:
472 case CONFIG_ITEM_STRING:
475 case CONFIG_ITEM_STRING_LIST:
478 case CONFIG_ITEM_FILE:
481 case CONFIG_ITEM_MODULE:
484 case CONFIG_ITEM_INTEGER:
487 case CONFIG_ITEM_RANGED_INTEGER:
490 case CONFIG_ITEM_BOOL:
493 case CONFIG_ITEM_KEY_BEFORE_10_3:
496 case CONFIG_ITEM_KEY_AFTER_10_3:
499 case CONFIG_ITEM_MODULE_LIST:
507 case CONFIG_ITEM_FILE:
510 case CONFIG_ITEM_STRING:
513 case CONFIG_ITEM_STRING_LIST:
516 case CONFIG_ITEM_FILE:
519 case CONFIG_ITEM_MODULE:
522 case CONFIG_ITEM_INTEGER:
525 case CONFIG_ITEM_RANGED_INTEGER:
528 case CONFIG_ITEM_BOOL:
531 case CONFIG_ITEM_KEY_BEFORE_10_3:
534 case CONFIG_ITEM_KEY_AFTER_10_3:
537 case CONFIG_ITEM_MODULE_LIST:
545 case CONFIG_ITEM_MODULE:
548 case CONFIG_ITEM_STRING:
551 case CONFIG_ITEM_STRING_LIST:
554 case CONFIG_ITEM_FILE:
557 case CONFIG_ITEM_MODULE:
560 case CONFIG_ITEM_INTEGER:
563 case CONFIG_ITEM_RANGED_INTEGER:
566 case CONFIG_ITEM_BOOL:
569 case CONFIG_ITEM_KEY_BEFORE_10_3:
572 case CONFIG_ITEM_KEY_AFTER_10_3:
575 case CONFIG_ITEM_MODULE_LIST:
583 case CONFIG_ITEM_INTEGER:
586 case CONFIG_ITEM_STRING:
589 case CONFIG_ITEM_STRING_LIST:
592 case CONFIG_ITEM_FILE:
595 case CONFIG_ITEM_MODULE:
598 case CONFIG_ITEM_INTEGER:
601 case CONFIG_ITEM_RANGED_INTEGER:
604 case CONFIG_ITEM_BOOL:
607 case CONFIG_ITEM_KEY_BEFORE_10_3:
610 case CONFIG_ITEM_KEY_AFTER_10_3:
613 case CONFIG_ITEM_MODULE_LIST:
621 case CONFIG_ITEM_RANGED_INTEGER:
624 case CONFIG_ITEM_STRING:
627 case CONFIG_ITEM_STRING_LIST:
630 case CONFIG_ITEM_FILE:
633 case CONFIG_ITEM_MODULE:
636 case CONFIG_ITEM_INTEGER:
639 case CONFIG_ITEM_RANGED_INTEGER:
642 case CONFIG_ITEM_BOOL:
645 case CONFIG_ITEM_KEY_BEFORE_10_3:
648 case CONFIG_ITEM_KEY_AFTER_10_3:
651 case CONFIG_ITEM_MODULE_LIST:
659 case CONFIG_ITEM_BOOL:
662 case CONFIG_ITEM_STRING:
665 case CONFIG_ITEM_STRING_LIST:
668 case CONFIG_ITEM_FILE:
671 case CONFIG_ITEM_MODULE:
674 case CONFIG_ITEM_INTEGER:
677 case CONFIG_ITEM_RANGED_INTEGER:
680 case CONFIG_ITEM_BOOL:
683 case CONFIG_ITEM_KEY_BEFORE_10_3:
686 case CONFIG_ITEM_KEY_AFTER_10_3:
689 case CONFIG_ITEM_MODULE_LIST:
697 case CONFIG_ITEM_KEY_BEFORE_10_3:
700 case CONFIG_ITEM_STRING:
703 case CONFIG_ITEM_STRING_LIST:
706 case CONFIG_ITEM_FILE:
709 case CONFIG_ITEM_MODULE:
712 case CONFIG_ITEM_INTEGER:
715 case CONFIG_ITEM_RANGED_INTEGER:
718 case CONFIG_ITEM_BOOL:
721 case CONFIG_ITEM_KEY_BEFORE_10_3:
724 case CONFIG_ITEM_KEY_AFTER_10_3:
727 case CONFIG_ITEM_MODULE_LIST:
735 case CONFIG_ITEM_KEY_AFTER_10_3:
738 case CONFIG_ITEM_STRING:
741 case CONFIG_ITEM_STRING_LIST:
744 case CONFIG_ITEM_FILE:
747 case CONFIG_ITEM_MODULE:
750 case CONFIG_ITEM_INTEGER:
753 case CONFIG_ITEM_RANGED_INTEGER:
756 case CONFIG_ITEM_BOOL:
759 case CONFIG_ITEM_KEY_BEFORE_10_3:
762 case CONFIG_ITEM_KEY_AFTER_10_3:
765 case CONFIG_ITEM_MODULE_LIST:
773 case CONFIG_ITEM_MODULE_LIST:
776 case CONFIG_ITEM_STRING:
779 case CONFIG_ITEM_STRING_LIST:
782 case CONFIG_ITEM_FILE:
785 case CONFIG_ITEM_MODULE:
788 case CONFIG_ITEM_INTEGER:
791 case CONFIG_ITEM_RANGED_INTEGER:
794 case CONFIG_ITEM_BOOL:
797 case CONFIG_ITEM_KEY_BEFORE_10_3:
800 case CONFIG_ITEM_KEY_AFTER_10_3:
803 case CONFIG_ITEM_MODULE_LIST:
818 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
819 withView: (NSView *)o_parent_view
821 VLCConfigControl *p_control = NULL;
822 switch( _p_item->i_type )
824 case CONFIG_ITEM_STRING:
825 if( !_p_item->i_list )
827 p_control = [[StringConfigControl alloc]
828 initWithItem: _p_item
829 withView: o_parent_view];
833 p_control = [[StringListConfigControl alloc]
834 initWithItem: _p_item
835 withView: o_parent_view];
838 case CONFIG_ITEM_FILE:
839 case CONFIG_ITEM_DIRECTORY:
840 p_control = [[FileConfigControl alloc]
841 initWithItem: _p_item
842 withView: o_parent_view];
844 case CONFIG_ITEM_MODULE:
845 case CONFIG_ITEM_MODULE_CAT:
846 p_control = [[ModuleConfigControl alloc]
847 initWithItem: _p_item
848 withView: o_parent_view];
850 case CONFIG_ITEM_INTEGER:
851 if( _p_item->i_list )
853 p_control = [[IntegerListConfigControl alloc]
854 initWithItem: _p_item
855 withView: o_parent_view];
857 else if( _p_item->i_min != 0 || _p_item->i_max != 0 )
859 p_control = [[RangedIntegerConfigControl alloc]
860 initWithItem: _p_item
861 withView: o_parent_view];
865 p_control = [[IntegerConfigControl alloc]
866 initWithItem: _p_item
867 withView: o_parent_view];
870 case CONFIG_ITEM_BOOL:
871 p_control = [[BoolConfigControl alloc]
872 initWithItem: _p_item
873 withView: o_parent_view];
875 case CONFIG_ITEM_FLOAT:
876 if( _p_item->f_min != 0 || _p_item->f_max != 0 )
878 p_control = [[RangedFloatConfigControl alloc]
879 initWithItem: _p_item
880 withView: o_parent_view];
884 p_control = [[FloatConfigControl alloc]
885 initWithItem: _p_item
886 withView: o_parent_view];
889 case CONFIG_ITEM_KEY:
890 if( MACOS_VERSION < 10.3 )
892 p_control = [[KeyConfigControlBefore103 alloc]
893 initWithItem: _p_item
894 withView: o_parent_view];
898 p_control = [[KeyConfigControlAfter103 alloc]
899 initWithItem: _p_item
900 withView: o_parent_view];
903 case CONFIG_ITEM_MODULE_LIST:
904 case CONFIG_ITEM_MODULE_LIST_CAT:
905 p_control = [[ModuleListConfigControl alloc]
906 initWithItem: _p_item
907 withView: o_parent_view];
915 - (NSString *)getName
917 return [[VLCMain sharedInstance] localizedString: psz_name];
945 - (char *)stringValue
953 switch( p_item->i_type )
955 case CONFIG_ITEM_STRING:
956 case CONFIG_ITEM_FILE:
957 case CONFIG_ITEM_DIRECTORY:
958 case CONFIG_ITEM_MODULE:
959 case CONFIG_ITEM_MODULE_LIST:
960 case CONFIG_ITEM_MODULE_LIST_CAT:
961 fprintf( stderr, "Applying %s to %s\n" , [self stringValue], psz_name );
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 fprintf( stderr, "Applying %d to %s\n" , [self intValue], psz_name );
967 val.i_int = [self intValue];
968 var_Set( VLCIntf->p_vlc, psz_name, val );
969 case CONFIG_ITEM_INTEGER:
970 case CONFIG_ITEM_BOOL:
971 fprintf( stderr, "Applying %d to %s\n" , [self intValue], psz_name );
972 config_PutInt( VLCIntf, psz_name, [self intValue] );
974 case CONFIG_ITEM_FLOAT:
975 fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
976 config_PutFloat( VLCIntf, psz_name, [self floatValue] );
983 return [o_label frame].size.width;
987 @implementation StringConfigControl
988 - (id) initWithItem: (module_config_t *)_p_item
989 withView: (NSView *)o_parent_view
991 NSRect mainFrame = [o_parent_view frame];
992 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
993 mainFrame.size.height = 22;
994 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
995 mainFrame.origin.x = LEFTMARGIN;
996 mainFrame.origin.y = 0;
998 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1000 i_view_type = CONFIG_ITEM_STRING;
1002 if( p_item->psz_text )
1003 o_labelString = [[VLCMain sharedInstance]
1004 localizedString: p_item->psz_text];
1006 o_labelString = [NSString stringWithString:@""];
1007 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1008 [o_label setAutoresizingMask:NSViewNotSizable ];
1009 [self addSubview: o_label];
1011 /* build the textfield */
1012 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1013 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext]
1014 toWidth: PREFS_WRAP];
1015 if( p_item->psz_value )
1016 o_textfieldString = [[VLCMain sharedInstance]
1017 localizedString: p_item->psz_value];
1019 o_textfieldString = [NSString stringWithString: @""];
1020 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1021 0, mainFrame.size.width - [o_label frame].size.width -
1022 2, o_textfieldTooltip, o_textfieldString )
1023 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1024 [self addSubview: o_textfield];
1029 - (void) alignWithXPosition:(int)i_xPos
1032 NSRect superFrame = [self frame];
1033 frame = [o_label frame];
1034 frame.origin.x = i_xPos - frame.size.width - 3;
1035 [o_label setFrame:frame];
1037 frame = [o_textfield frame];
1038 frame.origin.x = i_xPos + 2;
1039 frame.size.width = superFrame.size.width - frame.origin.x - 1;
1040 [o_textfield setFrame:frame];
1045 [o_textfield release];
1049 - (char *)stringValue
1051 return strdup( [[VLCMain sharedInstance] delocalizeString:
1052 [o_textfield stringValue]] );
1056 @implementation StringListConfigControl
1057 - (id) initWithItem: (module_config_t *)_p_item
1058 withView: (NSView *)o_parent_view
1060 NSRect mainFrame = [o_parent_view frame];
1061 NSString *o_labelString, *o_textfieldTooltip;
1062 mainFrame.size.height = 22;
1063 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1064 mainFrame.origin.x = LEFTMARGIN;
1065 mainFrame.origin.y = 0;
1067 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1070 i_view_type = CONFIG_ITEM_STRING_LIST;
1072 if( p_item->psz_text )
1073 o_labelString = [[VLCMain sharedInstance]
1074 localizedString: p_item->psz_text];
1076 o_labelString = [NSString stringWithString:@""];
1077 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1078 [o_label setAutoresizingMask:NSViewNotSizable ];
1079 [self addSubview: o_label];
1081 /* build the textfield */
1082 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1083 [[VLCMain sharedInstance]
1084 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1085 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1086 -2, 0, o_textfieldTooltip )
1087 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1088 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1089 if( p_item->psz_value &&
1090 !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) )
1091 [o_combo selectItemAtIndex: i_index];
1092 [self addSubview: o_combo];
1097 - (void) alignWithXPosition:(int)i_xPos
1100 NSRect superFrame = [self frame];
1101 frame = [o_label frame];
1102 frame.origin.x = i_xPos - frame.size.width - 3;
1103 [o_label setFrame:frame];
1105 frame = [o_combo frame];
1106 frame.origin.x = i_xPos + 2;
1107 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1108 [o_combo setFrame:frame];
1117 - (char *)stringValue
1119 if( [o_combo indexOfSelectedItem] >= 0 )
1120 return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
1122 return strdup( [[VLCMain sharedInstance]
1123 delocalizeString: [o_combo stringValue]] );
1127 @implementation StringListConfigControl (NSComboBoxDataSource)
1128 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1130 return p_item->i_list;
1133 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1135 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1137 return [[VLCMain sharedInstance]
1138 localizedString: p_item->ppsz_list_text[i_index]];
1139 } else return [[VLCMain sharedInstance]
1140 localizedString: p_item->ppsz_list[i_index]];
1144 @implementation FileConfigControl
1145 - (id) initWithItem: (module_config_t *)_p_item
1146 withView: (NSView *)o_parent_view
1148 NSRect mainFrame = [o_parent_view frame];
1149 NSString *o_labelString, *o_buttonTooltip, *o_textfieldString;
1150 NSString *o_textfieldTooltip;
1151 mainFrame.size.height = 46;
1152 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1153 mainFrame.origin.x = LEFTMARGIN;
1154 mainFrame.origin.y = 0;
1156 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1158 i_view_type = CONFIG_ITEM_FILE;
1160 /* is it a directory */
1161 b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
1164 if( p_item->psz_text )
1165 o_labelString = [[VLCMain sharedInstance]
1166 localizedString: p_item->psz_text];
1168 o_labelString = [NSString stringWithString:@""];
1169 ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString )
1170 [o_label setAutoresizingMask:NSViewNotSizable ];
1171 [self addSubview: o_label];
1173 /* build the button */
1174 o_buttonTooltip = [[VLCMain sharedInstance]
1175 wrapString: [[VLCMain sharedInstance]
1176 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1177 ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_buttonTooltip,
1179 [o_button setAutoresizingMask:NSViewMinXMargin ];
1180 [self addSubview: o_button];
1182 /* build the textfield */
1183 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1184 [[VLCMain sharedInstance]
1185 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1186 if( p_item->psz_value )
1187 o_textfieldString = [[VLCMain sharedInstance]
1188 localizedString: p_item->psz_value];
1190 o_textfieldString = [NSString stringWithString: @""];
1191 ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1192 8 - [o_button frame].size.width,
1193 o_textfieldTooltip, o_textfieldString )
1194 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1195 [self addSubview: o_textfield];
1200 - (void) alignWithXPosition:(int)i_xPos
1207 [o_textfield release];
1212 - (IBAction)openFileDialog: (id)sender
1214 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1216 [o_open_panel setTitle: (b_directory)?
1217 _NS("Select a directory"):_NS("Select a file")];
1218 [o_open_panel setPrompt: _NS("Select")];
1219 [o_open_panel setAllowsMultipleSelection: NO];
1220 [o_open_panel setCanChooseFiles: !b_directory];
1221 [o_open_panel setCanChooseDirectories: b_directory];
1222 [o_open_panel beginSheetForDirectory:nil
1225 modalForWindow:[sender window]
1227 didEndSelector: @selector(pathChosenInPanel:
1233 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
1234 withReturn:(int)i_return_code contextInfo:(void *)o_context_info
1236 if( i_return_code == NSOKButton )
1238 NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
1239 [o_textfield setStringValue: o_path];
1243 - (char *)stringValue
1245 if( [[o_textfield stringValue] length] != 0)
1246 return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
1252 @implementation ModuleConfigControl
1253 - (id) initWithItem: (module_config_t *)_p_item
1254 withView: (NSView *)o_parent_view
1256 NSRect mainFrame = [o_parent_view frame];
1257 NSString *o_labelString, *o_popupTooltip;
1258 mainFrame.size.height = 22;
1259 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1260 mainFrame.origin.x = LEFTMARGIN;
1261 mainFrame.origin.y = 0;
1263 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1268 i_view_type = CONFIG_ITEM_MODULE;
1271 if( p_item->psz_text )
1272 o_labelString = [[VLCMain sharedInstance]
1273 localizedString: p_item->psz_text];
1275 o_labelString = [NSString stringWithString:@""];
1276 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
1277 [o_label setAutoresizingMask:NSViewNotSizable ];
1278 [self addSubview: o_label];
1280 /* build the popup */
1281 o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1282 [[VLCMain sharedInstance]
1283 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1284 ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
1285 -2, 0, o_popupTooltip )
1286 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1287 [o_popup addItemWithTitle: _NS("Default")];
1288 [[o_popup lastItem] setTag: -1];
1289 [o_popup selectItem: [o_popup lastItem]];
1291 /* build a list of available modules */
1292 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1293 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1295 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
1296 if( p_item->i_type == CONFIG_ITEM_MODULE )
1298 if( !strcmp( p_parser->psz_capability,
1299 p_item->psz_type ) )
1301 NSString *o_description = [[VLCMain sharedInstance]
1302 localizedString: p_parser->psz_longname];
1303 [o_popup addItemWithTitle: o_description];
1305 if( p_item->psz_value &&
1306 !strcmp( p_item->psz_value, p_parser->psz_object_name ) )
1307 [o_popup selectItem:[o_popup lastItem]];
1312 module_config_t *p_config;
1313 if( !strcmp( p_parser->psz_object_name, "main" ) )
1316 p_config = p_parser->p_config;
1319 /* Hack: required subcategory is stored in i_min */
1320 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1321 p_config->i_value == p_item->i_min )
1323 NSString *o_description = [[VLCMain sharedInstance]
1324 localizedString: p_parser->psz_longname];
1325 [o_popup addItemWithTitle: o_description];
1327 if( p_item->psz_value && !strcmp(p_item->psz_value,
1328 p_parser->psz_object_name) )
1329 [o_popup selectItem:[o_popup lastItem]];
1331 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
1334 vlc_list_release( p_list );
1335 [self addSubview: o_popup];
1340 - (void) alignWithXPosition:(int)i_xPos
1343 NSRect superFrame = [self frame];
1344 frame = [o_label frame];
1345 frame.origin.x = i_xPos - frame.size.width - 3;
1346 [o_label setFrame:frame];
1348 frame = [o_popup frame];
1349 frame.origin.x = i_xPos - 1;
1350 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1351 [o_popup setFrame:frame];
1360 - (char *)stringValue
1362 NSString *newval = [o_popup titleOfSelectedItem];
1363 char *returnval = NULL;
1368 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1369 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1371 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
1372 if( p_item->i_type == CONFIG_ITEM_MODULE )
1374 if( !strcmp( p_parser->psz_capability,
1375 p_item->psz_type ) )
1377 NSString *o_description = [[VLCMain sharedInstance]
1378 localizedString: p_parser->psz_longname];
1379 if( [newval isEqualToString: o_description] )
1381 returnval = strdup(p_parser->psz_object_name);
1388 module_config_t *p_config;
1389 if( !strcmp( p_parser->psz_object_name, "main" ) )
1392 p_config = p_parser->p_config;
1395 /* Hack: required subcategory is stored in i_min */
1396 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1397 p_config->i_value == p_item->i_min )
1399 NSString *o_description = [[VLCMain sharedInstance]
1400 localizedString: p_parser->psz_longname];
1401 if( [newval isEqualToString: o_description] )
1403 returnval = strdup(p_parser->psz_object_name);
1407 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
1410 vlc_list_release( p_list );
1415 @implementation IntegerConfigControl
1416 - (id) initWithItem: (module_config_t *)_p_item
1417 withView: (NSView *)o_parent_view
1419 NSRect mainFrame = [o_parent_view frame];
1420 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1421 mainFrame.size.height = 23;
1422 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1423 mainFrame.origin.x = LEFTMARGIN;
1424 mainFrame.origin.y = 0;
1426 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1428 i_view_type = CONFIG_ITEM_INTEGER;
1430 o_tooltip = [[VLCMain sharedInstance] wrapString:
1431 [[VLCMain sharedInstance]
1432 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1435 if( p_item->psz_text )
1436 o_labelString = [[VLCMain sharedInstance]
1437 localizedString: p_item->psz_text];
1439 o_labelString = [NSString stringWithString:@""];
1440 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1441 [o_label setAutoresizingMask:NSViewNotSizable ];
1442 [self addSubview: o_label];
1444 /* build the stepper */
1445 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1446 0, o_tooltip, -1600, 1600)
1447 [o_stepper setIntValue: p_item->i_value];
1448 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1449 [self addSubview: o_stepper];
1451 /* build the textfield */
1452 if( p_item->psz_value )
1453 o_textfieldString = [[VLCMain sharedInstance]
1454 localizedString: p_item->psz_value];
1456 o_textfieldString = [NSString stringWithString: @""];
1457 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1458 1, 49, o_tooltip, @"" )
1459 [o_textfield setIntValue: p_item->i_value];
1460 [o_textfield setDelegate: self];
1461 [[NSNotificationCenter defaultCenter] addObserver: self
1462 selector: @selector(textfieldChanged:)
1463 name: NSControlTextDidChangeNotification
1464 object: o_textfield];
1465 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1466 [self addSubview: o_textfield];
1471 - (void) alignWithXPosition:(int)i_xPos
1474 frame = [o_label frame];
1475 frame.origin.x = i_xPos - frame.size.width - 3;
1476 [o_label setFrame:frame];
1478 frame = [o_textfield frame];
1479 frame.origin.x = i_xPos + 2;
1480 [o_textfield setFrame:frame];
1482 frame = [o_stepper frame];
1483 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1484 [o_stepper setFrame:frame];
1489 [o_stepper release];
1490 [o_textfield release];
1494 - (IBAction)stepperChanged:(id)sender
1496 [o_textfield setIntValue: [o_stepper intValue]];
1499 - (void)textfieldChanged:(NSNotification *)o_notification
1501 [o_stepper setIntValue: [o_textfield intValue]];
1506 return [o_textfield intValue];
1511 @implementation IntegerListConfigControl
1513 - (id) initWithItem: (module_config_t *)_p_item
1514 withView: (NSView *)o_parent_view
1516 NSRect mainFrame = [o_parent_view frame];
1517 NSString *o_labelString, *o_textfieldTooltip;
1518 mainFrame.size.height = 22;
1519 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1520 mainFrame.origin.x = LEFTMARGIN;
1521 mainFrame.origin.y = 0;
1523 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1526 i_view_type = CONFIG_ITEM_STRING_LIST;
1529 if( p_item->psz_text )
1530 o_labelString = [[VLCMain sharedInstance]
1531 localizedString: p_item->psz_text];
1533 o_labelString = [NSString stringWithString:@""];
1534 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1535 [o_label setAutoresizingMask:NSViewNotSizable ];
1536 [self addSubview: o_label];
1538 /* build the textfield */
1539 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1540 [[VLCMain sharedInstance]
1541 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1542 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1543 -2, 0, o_textfieldTooltip )
1544 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1545 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1547 if( p_item->i_value == p_item->pi_list[i_index] )
1549 [o_combo selectItemAtIndex: i_index];
1552 [self addSubview: o_combo];
1557 - (void) alignWithXPosition:(int)i_xPos
1560 NSRect superFrame = [self frame];
1561 frame = [o_label frame];
1562 frame.origin.x = i_xPos - frame.size.width - 3;
1563 [o_label setFrame:frame];
1565 frame = [o_combo frame];
1566 frame.origin.x = i_xPos + 2;
1567 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1568 [o_combo setFrame:frame];
1579 if( [o_combo indexOfSelectedItem] >= 0 )
1580 return p_item->pi_list[[o_combo indexOfSelectedItem]];
1582 return [o_combo intValue];
1586 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1587 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1589 return p_item->i_list;
1592 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1594 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1595 return [[VLCMain sharedInstance]
1596 localizedString: p_item->ppsz_list_text[i_index]];
1598 return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1602 @implementation RangedIntegerConfigControl
1603 - (id) initWithItem: (module_config_t *)_p_item
1604 withView: (NSView *)o_parent_view
1606 NSRect mainFrame = [o_parent_view frame];
1607 NSString *o_labelString, *o_tooltip;
1608 mainFrame.size.height = 50;
1609 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1610 mainFrame.origin.x = LEFTMARGIN;
1611 mainFrame.origin.y = 0;
1613 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1615 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1618 if( p_item->psz_text )
1619 o_labelString = [[VLCMain sharedInstance]
1620 localizedString: p_item->psz_text];
1622 o_labelString = [NSString stringWithString:@""];
1623 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1624 [o_label setAutoresizingMask:NSViewNotSizable ];
1625 [self addSubview: o_label];
1627 /* build the textfield */
1628 o_tooltip = [[VLCMain sharedInstance] wrapString:
1629 [[VLCMain sharedInstance]
1630 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1631 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1632 28, 49, o_tooltip, @"" )
1633 [o_textfield setIntValue: p_item->i_value];
1634 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1635 [o_textfield setDelegate: self];
1636 [[NSNotificationCenter defaultCenter] addObserver: self
1637 selector: @selector(textfieldChanged:)
1638 name: NSControlTextDidChangeNotification
1639 object: o_textfield];
1640 [self addSubview: o_textfield];
1642 /* build the mintextfield */
1643 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1644 [o_textfield_min setIntValue: p_item->i_min];
1645 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1646 [o_textfield_min setAlignment:NSRightTextAlignment];
1647 [self addSubview: o_textfield_min];
1649 /* build the maxtextfield */
1650 ADD_LABEL( o_textfield_max, mainFrame,
1651 mainFrame.size.width - 31, -30, @"8888" )
1652 [o_textfield_max setIntValue: p_item->i_max];
1653 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1654 [self addSubview: o_textfield_max];
1656 /* build the slider */
1657 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1658 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1659 [o_textfield_max frame].size.width -
1660 [o_textfield_max frame].size.width - 14 -
1661 [o_textfield_min frame].origin.x, o_tooltip,
1662 p_item->i_min, p_item->i_max )
1663 [o_slider setIntValue: p_item->i_value];
1664 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1665 [o_slider setTarget: self];
1666 [o_slider setAction: @selector(sliderChanged:)];
1667 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1668 NSLeftMouseDraggedMask];
1669 [self addSubview: o_slider];
1675 - (void) alignWithXPosition:(int)i_xPos
1678 frame = [o_label frame];
1679 frame.origin.x = i_xPos - frame.size.width - 3;
1680 [o_label setFrame:frame];
1682 frame = [o_textfield frame];
1683 frame.origin.x = i_xPos + 2;
1684 [o_textfield setFrame:frame];
1689 [o_textfield release];
1690 [o_textfield_min release];
1691 [o_textfield_max release];
1696 - (IBAction)sliderChanged:(id)sender
1698 [o_textfield setIntValue: [o_slider intValue]];
1701 - (void)textfieldChanged:(NSNotification *)o_notification
1703 [o_slider setIntValue: [o_textfield intValue]];
1708 return [o_slider intValue];
1712 @implementation FloatConfigControl
1713 - (id) initWithItem: (module_config_t *)_p_item
1714 withView: (NSView *)o_parent_view
1716 NSRect mainFrame = [o_parent_view frame];
1717 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1718 mainFrame.size.height = 23;
1719 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1720 mainFrame.origin.x = LEFTMARGIN;
1721 mainFrame.origin.y = 0;
1723 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1725 i_view_type = CONFIG_ITEM_INTEGER;
1727 o_tooltip = [[VLCMain sharedInstance] wrapString:
1728 [[VLCMain sharedInstance]
1729 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1732 if( p_item->psz_text )
1733 o_labelString = [[VLCMain sharedInstance]
1734 localizedString: p_item->psz_text];
1736 o_labelString = [NSString stringWithString:@""];
1737 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
1738 [o_label setAutoresizingMask:NSViewNotSizable ];
1739 [self addSubview: o_label];
1741 /* build the stepper */
1742 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1743 0, o_tooltip, -1600, 1600)
1744 [o_stepper setFloatValue: p_item->f_value];
1745 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1746 [self addSubview: o_stepper];
1748 /* build the textfield */
1749 if( p_item->psz_value )
1750 o_textfieldString = [[VLCMain sharedInstance]
1751 localizedString: p_item->psz_value];
1753 o_textfieldString = [NSString stringWithString: @""];
1754 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1755 1, 49, o_tooltip, @"" )
1756 [o_textfield setFloatValue: p_item->f_value];
1757 [o_textfield setDelegate: self];
1758 [[NSNotificationCenter defaultCenter] addObserver: self
1759 selector: @selector(textfieldChanged:)
1760 name: NSControlTextDidChangeNotification
1761 object: o_textfield];
1762 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1763 [self addSubview: o_textfield];
1768 - (void) alignWithXPosition:(int)i_xPos
1771 frame = [o_label frame];
1772 frame.origin.x = i_xPos - frame.size.width - 3;
1773 [o_label setFrame:frame];
1775 frame = [o_textfield frame];
1776 frame.origin.x = i_xPos + 2;
1777 [o_textfield setFrame:frame];
1779 frame = [o_stepper frame];
1780 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1781 [o_stepper setFrame:frame];
1786 [o_stepper release];
1787 [o_textfield release];
1791 - (IBAction)stepperChanged:(id)sender
1793 [o_textfield setFloatValue: [o_stepper floatValue]];
1796 - (void)textfieldChanged:(NSNotification *)o_notification
1798 [o_stepper setFloatValue: [o_textfield floatValue]];
1803 return [o_stepper floatValue];
1807 @implementation RangedFloatConfigControl
1808 - (id) initWithItem: (module_config_t *)_p_item
1809 withView: (NSView *)o_parent_view
1811 NSRect mainFrame = [o_parent_view frame];
1812 NSString *o_labelString, *o_tooltip;
1813 mainFrame.size.height = 50;
1814 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1815 mainFrame.origin.x = LEFTMARGIN;
1816 mainFrame.origin.y = 0;
1818 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1820 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1823 if( p_item->psz_text )
1824 o_labelString = [[VLCMain sharedInstance]
1825 localizedString: p_item->psz_text];
1827 o_labelString = [NSString stringWithString:@""];
1828 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1829 [o_label setAutoresizingMask:NSViewNotSizable ];
1830 [self addSubview: o_label];
1832 /* build the textfield */
1833 o_tooltip = [[VLCMain sharedInstance] wrapString:
1834 [[VLCMain sharedInstance]
1835 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1836 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1837 28, 49, o_tooltip, @"" )
1838 [o_textfield setFloatValue: p_item->f_value];
1839 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1840 [o_textfield setDelegate: self];
1841 [[NSNotificationCenter defaultCenter] addObserver: self
1842 selector: @selector(textfieldChanged:)
1843 name: NSControlTextDidChangeNotification
1844 object: o_textfield];
1845 [self addSubview: o_textfield];
1847 /* build the mintextfield */
1848 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1849 [o_textfield_min setFloatValue: p_item->f_min];
1850 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1851 [o_textfield_min setAlignment:NSRightTextAlignment];
1852 [self addSubview: o_textfield_min];
1854 /* build the maxtextfield */
1855 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
1857 [o_textfield_max setFloatValue: p_item->f_max];
1858 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1859 [self addSubview: o_textfield_max];
1861 /* build the slider */
1862 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1863 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1864 [o_textfield_max frame].size.width -
1865 [o_textfield_max frame].size.width - 14 -
1866 [o_textfield_min frame].origin.x, o_tooltip, p_item->f_min,
1868 [o_slider setFloatValue: p_item->f_value];
1869 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1870 [o_slider setTarget: self];
1871 [o_slider setAction: @selector(sliderChanged:)];
1872 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1873 NSLeftMouseDraggedMask];
1874 [self addSubview: o_slider];
1880 - (void) alignWithXPosition:(int)i_xPos
1883 frame = [o_label frame];
1884 frame.origin.x = i_xPos - frame.size.width - 3;
1885 [o_label setFrame:frame];
1887 frame = [o_textfield frame];
1888 frame.origin.x = i_xPos + 2;
1889 [o_textfield setFrame:frame];
1894 [o_textfield release];
1895 [o_textfield_min release];
1896 [o_textfield_max release];
1901 - (IBAction)sliderChanged:(id)sender
1903 [o_textfield setFloatValue: [o_slider floatValue]];
1906 - (void)textfieldChanged:(NSNotification *)o_notification
1908 [o_slider setFloatValue: [o_textfield floatValue]];
1913 return [o_slider floatValue];
1918 @implementation BoolConfigControl
1920 - (id) initWithItem: (module_config_t *)_p_item
1921 withView: (NSView *)o_parent_view
1923 NSRect mainFrame = [o_parent_view frame];
1924 NSString *o_labelString, *o_tooltip;
1925 mainFrame.size.height = 17;
1926 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1927 mainFrame.origin.x = LEFTMARGIN;
1928 mainFrame.origin.y = 0;
1930 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1932 i_view_type = CONFIG_ITEM_BOOL;
1935 if( p_item->psz_text )
1936 o_labelString = [[VLCMain sharedInstance]
1937 localizedString: p_item->psz_text];
1939 o_labelString = [NSString stringWithString:@""];
1940 ADD_LABEL( o_label, mainFrame, 0, 0, o_labelString )
1941 [o_label setAutoresizingMask:NSViewNotSizable ];
1942 [self addSubview: o_label];
1943 /* add the checkbox */
1944 o_tooltip = [[VLCMain sharedInstance]
1945 wrapString: [[VLCMain sharedInstance]
1946 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1947 ADD_CHECKBOX( o_checkbox, mainFrame, [o_label frame].size.width,
1948 0, @"", o_tooltip, p_item->i_value, NSImageLeft)
1949 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1950 [self addSubview: o_checkbox];
1955 - (void) alignWithXPosition:(int)i_xPos
1958 frame = [o_label frame];
1959 frame.origin.x = i_xPos - frame.size.width - 3;
1960 [o_label setFrame:frame];
1962 frame = [o_checkbox frame];
1963 frame.origin.x = i_xPos;
1964 [o_checkbox setFrame:frame];
1969 [o_checkbox release];
1975 return [o_checkbox intValue];
1980 @implementation KeyConfigControlBefore103
1982 - (id) initWithItem: (module_config_t *)_p_item
1983 withView: (NSView *)o_parent_view
1985 NSRect mainFrame = [o_parent_view frame];
1986 NSString *o_labelString, *o_tooltip;
1987 mainFrame.size.height = 37;
1988 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1989 mainFrame.origin.x = LEFTMARGIN;
1990 mainFrame.origin.y = 0;
1992 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1994 i_view_type = CONFIG_ITEM_KEY_BEFORE_10_3;
1997 if( p_item->psz_text )
1998 o_labelString = [[VLCMain sharedInstance]
1999 localizedString: p_item->psz_text];
2001 o_labelString = [NSString stringWithString:@""];
2002 ADD_LABEL( o_label, mainFrame, 0, -10, o_labelString )
2003 [o_label setAutoresizingMask:NSViewNotSizable ];
2004 [self addSubview: o_label];
2006 /* add the checkboxes */
2007 o_tooltip = [[VLCMain sharedInstance] wrapString:
2008 [[VLCMain sharedInstance]
2009 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2010 ADD_CHECKBOX( o_cmd_checkbox, mainFrame,
2011 [o_label frame].size.width + 2, 0,
2012 [NSString stringWithUTF8String:PLACE_OF_INTEREST_SIGN], o_tooltip,
2013 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_COMMAND)?YES:NO),
2015 [o_cmd_checkbox setState: p_item->i_value & KEY_MODIFIER_COMMAND];
2016 ADD_CHECKBOX( o_ctrl_checkbox, mainFrame,
2017 [o_cmd_checkbox frame].size.width +
2018 [o_cmd_checkbox frame].origin.x + 6, 0,
2019 [NSString stringWithUTF8String:UP_ARROWHEAD], o_tooltip,
2020 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_CTRL)?YES:NO),
2022 [o_ctrl_checkbox setState: p_item->i_value & KEY_MODIFIER_CTRL];
2023 ADD_CHECKBOX( o_alt_checkbox, mainFrame, [o_label frame].size.width +
2024 2, -2 - [o_cmd_checkbox frame].size.height,
2025 [NSString stringWithUTF8String:OPTION_KEY], o_tooltip,
2026 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_ALT)?YES:NO),
2028 [o_alt_checkbox setState: p_item->i_value & KEY_MODIFIER_ALT];
2029 ADD_CHECKBOX( o_shift_checkbox, mainFrame,
2030 [o_cmd_checkbox frame].size.width +
2031 [o_cmd_checkbox frame].origin.x + 6, -2 -
2032 [o_cmd_checkbox frame].size.height,
2033 [NSString stringWithUTF8String:UPWARDS_WHITE_ARROW], o_tooltip,
2034 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_SHIFT)?YES:NO),
2036 [o_shift_checkbox setState: p_item->i_value & KEY_MODIFIER_SHIFT];
2037 [self addSubview: o_cmd_checkbox];
2038 [self addSubview: o_ctrl_checkbox];
2039 [self addSubview: o_alt_checkbox];
2040 [self addSubview: o_shift_checkbox];
2042 /* build the popup */
2043 ADD_POPUP( o_popup, mainFrame, [o_shift_checkbox frame].origin.x +
2044 [o_shift_checkbox frame].size.width + 4,
2046 [o_popup setAutoresizingMask:NSViewWidthSizable ];
2048 if( o_keys_menu == nil )
2051 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
2052 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
2053 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
2054 POPULATE_A_KEY( o_keys_menu,
2055 [NSString stringWithCString:vlc_keys[i].psz_key_string]
2056 , vlc_keys[i].i_key_code)
2058 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2059 [o_popup selectItemWithTitle: [[VLCMain sharedInstance]
2060 localizedString:KeyToString(
2061 (((unsigned int)p_item->i_value) & ~KEY_MODIFIER ))]];
2062 [self addSubview: o_popup];
2067 - (void) alignWithXPosition:(int)i_xPos
2070 NSRect superFrame = [self frame];
2071 frame = [o_label frame];
2072 frame.origin.x = i_xPos - frame.size.width - 3;
2073 [o_label setFrame:frame];
2075 frame = [o_cmd_checkbox frame];
2076 frame.origin.x = i_xPos;
2077 [o_cmd_checkbox setFrame:frame];
2079 frame = [o_ctrl_checkbox frame];
2080 frame.origin.x = [o_cmd_checkbox frame].size.width +
2081 [o_cmd_checkbox frame].origin.x + 4;
2082 [o_ctrl_checkbox setFrame:frame];
2084 frame = [o_alt_checkbox frame];
2085 frame.origin.x = i_xPos;
2086 [o_alt_checkbox setFrame:frame];
2088 frame = [o_shift_checkbox frame];
2089 frame.origin.x = [o_cmd_checkbox frame].size.width +
2090 [o_cmd_checkbox frame].origin.x + 4;
2091 [o_shift_checkbox setFrame:frame];
2093 frame = [o_popup frame];
2094 frame.origin.x = [o_shift_checkbox frame].origin.x +
2095 [o_shift_checkbox frame].size.width + 3;
2096 frame.size.width = superFrame.size.width - frame.origin.x + 2;
2097 [o_popup setFrame:frame];
2102 [o_cmd_checkbox release];
2103 [o_ctrl_checkbox release];
2104 [o_alt_checkbox release];
2105 [o_shift_checkbox release];
2112 unsigned int i_new_key = 0;
2114 i_new_key |= ([o_cmd_checkbox state] == NSOnState) ?
2115 KEY_MODIFIER_COMMAND : 0;
2116 i_new_key |= ([o_ctrl_checkbox state] == NSOnState) ?
2117 KEY_MODIFIER_CTRL : 0;
2118 i_new_key |= ([o_alt_checkbox state] == NSOnState) ?
2119 KEY_MODIFIER_ALT : 0;
2120 i_new_key |= ([o_shift_checkbox state] == NSOnState) ?
2121 KEY_MODIFIER_SHIFT : 0;
2123 i_new_key |= StringToKey([[[o_popup selectedItem] title] cString]);
2128 @implementation KeyConfigControlAfter103
2129 - (id) initWithItem: (module_config_t *)_p_item
2130 withView: (NSView *)o_parent_view
2132 NSRect mainFrame = [o_parent_view frame];
2133 NSString *o_labelString, *o_tooltip;
2134 mainFrame.size.height = 22;
2135 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
2136 mainFrame.origin.x = LEFTMARGIN;
2137 mainFrame.origin.y = 0;
2139 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2141 i_view_type = CONFIG_ITEM_KEY_AFTER_10_3;
2144 if( p_item->psz_text )
2145 o_labelString = [[VLCMain sharedInstance]
2146 localizedString: p_item->psz_text];
2148 o_labelString = [NSString stringWithString:@""];
2149 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
2150 [o_label setAutoresizingMask:NSViewNotSizable ];
2151 [self addSubview: o_label];
2153 /* build the popup */
2154 o_tooltip = [[VLCMain sharedInstance] wrapString:
2155 [[VLCMain sharedInstance]
2156 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2157 ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
2158 [o_label frame].size.width + 3,
2160 [o_popup setAutoresizingMask:NSViewWidthSizable ];
2162 if( o_keys_menu == nil )
2165 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
2166 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
2167 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
2168 POPULATE_A_KEY( o_keys_menu,
2169 [NSString stringWithCString:vlc_keys[i].psz_key_string]
2170 , vlc_keys[i].i_key_code)
2172 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2173 [o_popup selectItemWithTag: p_item->i_value];
2174 [self addSubview: o_popup];
2180 - (void) alignWithXPosition:(int)i_xPos
2183 NSRect superFrame = [self frame];
2184 frame = [o_label frame];
2185 frame.origin.x = i_xPos - frame.size.width - 3;
2186 [o_label setFrame:frame];
2188 frame = [o_popup frame];
2189 frame.origin.x = i_xPos - 1;
2190 frame.size.width = superFrame.size.width - frame.origin.x + 2;
2191 [o_popup setFrame:frame];
2202 return [o_popup selectedTag];
2206 @implementation ModuleListConfigControl
2207 - (id) initWithItem: (module_config_t *)_p_item
2208 withView: (NSView *)o_parent_view
2210 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
2214 //Fill our array to know how may items we have...
2218 NSRect mainFrame = [o_parent_view frame];
2219 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2221 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2222 /* build a list of available modules */
2223 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
2224 for( i_index = 0; i_index < p_list->i_count; i_index++ )
2226 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
2228 if( !strcmp( p_parser->psz_object_name, "main" ) )
2231 module_config_t *p_config = p_parser->p_config;
2234 NSString *o_modulelongname, *o_modulename;
2235 NSNumber *o_moduleenabled = nil;
2236 /* Hack: required subcategory is stored in i_min */
2237 if( p_config->i_type == CONFIG_SUBCATEGORY &&
2238 p_config->i_value == _p_item->i_min )
2240 o_modulelongname = [NSString stringWithCString:
2241 p_parser->psz_longname];
2242 o_modulename = [NSString stringWithCString:
2243 p_parser->psz_object_name];
2245 if( _p_item->psz_value &&
2246 strstr( _p_item->psz_value, p_parser->psz_object_name ) )
2247 o_moduleenabled = [NSNumber numberWithBool:YES];
2249 o_moduleenabled = [NSNumber numberWithBool:NO];
2251 [o_modulearray addObject:[NSMutableArray
2252 arrayWithObjects: o_modulename, o_modulelongname,
2253 o_moduleenabled, nil]];
2255 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
2257 vlc_list_release( p_list );
2259 mainFrame.size.height = 30 + 18 * [o_modulearray count];
2260 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2261 mainFrame.origin.x = LEFTMARGIN;
2262 mainFrame.origin.y = 0;
2263 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2265 i_view_type = CONFIG_ITEM_MODULE_LIST;
2268 if( p_item->psz_text )
2269 o_labelString = [[VLCMain sharedInstance]
2270 localizedString: p_item->psz_text];
2272 o_labelString = [NSString stringWithString:@""];
2273 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
2274 [o_label setAutoresizingMask:NSViewNotSizable ];
2275 [self addSubview: o_label];
2277 /* build the textfield */
2278 o_tooltip = [[VLCMain sharedInstance] wrapString:
2279 [[VLCMain sharedInstance]
2280 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2281 if( p_item->psz_value )
2282 o_textfieldString = [[VLCMain sharedInstance]
2283 localizedString: p_item->psz_value];
2285 o_textfieldString = [NSString stringWithString: @""];
2286 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
2287 mainFrame.size.height - 22, mainFrame.size.width -
2288 [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
2289 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2290 [self addSubview: o_textfield];
2294 NSRect s_rc = mainFrame;
2295 s_rc.size.height = mainFrame.size.height - 30;
2296 s_rc.size.width = mainFrame.size.width - 12;
2299 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2300 [o_scrollview setDrawsBackground: NO];
2301 [o_scrollview setBorderType: NSBezelBorder];
2302 [o_scrollview setAutohidesScrollers:YES];
2304 NSTableView *o_tableview;
2305 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2306 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2307 [o_tableview setHeaderView:nil];
2308 /* TODO: find a good way to fix the row height and text size*/
2309 /* FIXME: support for multiple selection... */
2310 // [o_tableview setAllowsMultipleSelection:YES];
2312 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2313 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2314 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2315 [o_dataCell setTitle:@""];
2316 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2317 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2318 initWithIdentifier:[NSString stringWithCString: "Enabled"]];
2319 [o_tableColumn setHeaderCell: o_headerCell];
2320 [o_tableColumn setDataCell: o_dataCell];
2321 [o_tableColumn setWidth:17];
2322 [o_tableview addTableColumn: o_tableColumn];
2324 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2325 o_dataCell = [[NSTextFieldCell alloc] init];
2326 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2327 o_tableColumn = [[NSTableColumn alloc]
2328 initWithIdentifier:[NSString stringWithCString: "Module"]];
2329 [o_tableColumn setHeaderCell: o_headerCell];
2330 [o_tableColumn setDataCell: o_dataCell];
2331 [o_tableColumn setWidth:388 - 17];
2332 [o_tableview addTableColumn: o_tableColumn];
2333 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2334 @"VLC media player module", nil]];
2336 [o_tableview setDataSource:self];
2337 [o_tableview setTarget: self];
2338 [o_tableview setAction: @selector(tableChanged:)];
2339 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2340 NSLeftMouseDraggedMask];
2341 [o_scrollview setDocumentView: o_tableview];
2343 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2344 [self addSubview: o_scrollview];
2351 - (void) alignWithXPosition:(int)i_xPos
2356 - (IBAction)tableChanged:(id)sender
2358 NSString *o_newstring = @"";
2360 for( i = 0 ; i < [o_modulearray count] ; i++ )
2361 if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2364 o_newstring = [o_newstring stringByAppendingString:
2365 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2366 o_newstring = [o_newstring stringByAppendingString:@","];
2369 [o_textfield setStringValue: [o_newstring
2370 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2375 [o_scrollview release];
2380 - (char *)stringValue
2382 return strdup( [[o_textfield stringValue] cString] );
2387 @implementation ModuleListConfigControl (NSTableDataSource)
2389 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2390 toPasteboard:(NSPasteboard*)pb
2392 // We only want to allow dragging of selected rows.
2393 NSEnumerator *iter = [rows objectEnumerator];
2395 while ((row = [iter nextObject]) != nil)
2397 if (![table isRowSelected:[row intValue]])
2401 [pb declareTypes:[NSArray
2402 arrayWithObject:@"VLC media player module"] owner:nil];
2403 [pb setPropertyList:rows forType:@"VLC media player module"];
2407 - (NSDragOperation)tableView:(NSTableView*)table
2408 validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row
2409 proposedDropOperation:(NSTableViewDropOperation)op
2411 // Make drops at the end of the table go to the end.
2414 row = [table numberOfRows];
2415 op = NSTableViewDropAbove;
2416 [table setDropRow:row dropOperation:op];
2419 // We don't ever want to drop onto a row, only between rows.
2420 if (op == NSTableViewDropOn)
2421 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2422 return NSTableViewDropAbove;
2425 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2426 row:(int)dropRow dropOperation:(NSTableViewDropOperation)op;
2428 NSPasteboard *pb = [info draggingPasteboard];
2429 NSDragOperation srcMask = [info draggingSourceOperationMask];
2436 // Intra-table drag - data is the array of rows.
2437 if (!accepted && (array =
2438 [pb propertyListForType:@"VLC media player module"]) != NULL)
2440 NSEnumerator *iter = nil;
2442 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2444 iter = [array objectEnumerator];
2445 while ((val = [iter nextObject]) != NULL)
2447 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2448 [val intValue]] mutableCopyWithZone:nil];
2449 [o_modulearray removeObject:o_tmp];
2450 [o_modulearray insertObject:o_tmp
2451 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2455 // Select the newly-dragged items.
2456 iter = [array objectEnumerator];
2458 [table deselectAll:self];
2460 [self tableChanged:self];
2461 [table setNeedsDisplay:YES];
2462 // Indicate that we finished the drag.
2466 [table setNeedsDisplay:YES];
2470 // An exception occurred. Uh-oh. Update the track table so that
2471 // it stays consistent, and re-raise the exception.
2473 [localException raise];
2474 [table setNeedsDisplay:YES];
2480 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
2482 return [o_modulearray count];
2485 - (id)tableView:(NSTableView *)aTableView
2486 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2488 if( [[aTableColumn identifier] isEqualToString:
2489 [NSString stringWithCString:"Enabled"]] )
2490 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2491 if( [[aTableColumn identifier] isEqualToString:
2492 [NSString stringWithCString:"Module"]] )
2493 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2498 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2499 forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2501 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2502 withObject: anObject];