1 /*****************************************************************************
2 * prefs_widgets.m: Preferences controls
3 *****************************************************************************
4 * Copyright (C) 2002-2003 the VideoLAN team
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 UPWARDS_WHITE_ARROW "\xE2\x87\xA7"
42 #define OPTION_KEY "\xE2\x8C\xA5"
43 #define UP_ARROWHEAD "\xE2\x8C\x83"
44 #define PLACE_OF_INTEREST_SIGN "\xE2\x8C\x98"
46 #define POPULATE_A_KEY( o_menu, string, value ) \
50 o_mi = [[NSMenuItem alloc] initWithTitle:string \
51 action:nil keyEquivalent:@""]; \
52 [o_mi setKeyEquivalentModifierMask: \
54 if( MACOS_VERSION >= 10.3 ) \
55 [o_mi setAlternate: NO]; \
58 [o_menu addItem: o_mi]; \
59 if( MACOS_VERSION >= 10.3 ) \
62 o_mi = [[NSMenuItem alloc] initWithTitle: \
63 [[NSString stringWithUTF8String: \
65 ] stringByAppendingString: string] \
66 action:nil keyEquivalent:@""]; \
67 [o_mi setKeyEquivalentModifierMask: \
69 [o_mi setAlternate: YES]; \
71 KEY_MODIFIER_CTRL | ( value )]; \
72 [o_menu addItem: o_mi]; \
74 o_mi = [[NSMenuItem alloc] initWithTitle: \
75 [[NSString stringWithUTF8String: \
76 UP_ARROWHEAD OPTION_KEY \
77 ] stringByAppendingString: string] \
78 action:nil keyEquivalent:@""]; \
79 [o_mi setKeyEquivalentModifierMask: \
80 NSControlKeyMask | NSAlternateKeyMask]; \
81 [o_mi setAlternate: YES]; \
83 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | ( value )]; \
84 [o_menu addItem: o_mi]; \
86 o_mi = [[NSMenuItem alloc] initWithTitle: \
87 [[NSString stringWithUTF8String: \
88 UP_ARROWHEAD UPWARDS_WHITE_ARROW \
89 ] stringByAppendingString: string] \
90 action:nil keyEquivalent:@""]; \
91 [o_mi setKeyEquivalentModifierMask: \
92 NSControlKeyMask | NSShiftKeyMask]; \
93 [o_mi setAlternate: YES]; \
95 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | ( value )]; \
96 [o_menu addItem: o_mi]; \
98 o_mi = [[NSMenuItem alloc] initWithTitle: \
99 [[NSString stringWithUTF8String: \
100 UP_ARROWHEAD PLACE_OF_INTEREST_SIGN \
101 ] stringByAppendingString: string] \
102 action:nil keyEquivalent:@""]; \
103 [o_mi setKeyEquivalentModifierMask: \
104 NSControlKeyMask | NSCommandKeyMask]; \
105 [o_mi setAlternate: YES]; \
107 (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | ( value )]; \
108 [o_menu addItem: o_mi]; \
109 /* Ctrl+Alt+Shift */ \
110 o_mi = [[NSMenuItem alloc] initWithTitle: \
111 [[NSString stringWithUTF8String: \
112 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
113 ] stringByAppendingString: string] \
114 action:nil keyEquivalent:@""]; \
115 [o_mi setKeyEquivalentModifierMask: \
116 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
117 [o_mi setAlternate: YES]; \
119 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | \
121 [o_menu addItem: o_mi]; \
122 /* Ctrl+Alt+Apple */ \
123 o_mi = [[NSMenuItem alloc] initWithTitle: \
124 [[NSString stringWithUTF8String: \
125 UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN \
126 ] stringByAppendingString: string] \
127 action:nil keyEquivalent:@""]; \
128 [o_mi setKeyEquivalentModifierMask: \
129 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
130 [o_mi setAlternate: YES]; \
132 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
134 [o_menu addItem: o_mi]; \
135 /* Ctrl+Shift+Apple */ \
136 o_mi = [[NSMenuItem alloc] initWithTitle: \
137 [[NSString stringWithUTF8String: \
138 UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
139 ] stringByAppendingString: string] \
140 action:nil keyEquivalent:@""]; \
141 [o_mi setKeyEquivalentModifierMask: \
142 NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
143 [o_mi setAlternate: YES]; \
145 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
147 [o_menu addItem: o_mi]; \
148 /* Ctrl+Alt+Shift+Apple */ \
149 o_mi = [[NSMenuItem alloc] initWithTitle: \
150 [[NSString stringWithUTF8String: \
151 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
152 PLACE_OF_INTEREST_SIGN \
153 ] stringByAppendingString: string] \
154 action:nil keyEquivalent:@""]; \
155 [o_mi setKeyEquivalentModifierMask: \
156 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
158 [o_mi setAlternate: YES]; \
160 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
161 KEY_MODIFIER_COMMAND) | ( value )]; \
162 [o_menu addItem: o_mi]; \
164 o_mi = [[NSMenuItem alloc] initWithTitle: \
165 [[NSString stringWithUTF8String: \
167 ] stringByAppendingString: string] \
168 action:nil keyEquivalent:@""]; \
169 [o_mi setKeyEquivalentModifierMask: \
170 NSAlternateKeyMask]; \
171 [o_mi setAlternate: YES]; \
173 KEY_MODIFIER_ALT | ( value )]; \
174 [o_menu addItem: o_mi]; \
176 o_mi = [[NSMenuItem alloc] initWithTitle: \
177 [[NSString stringWithUTF8String: \
178 OPTION_KEY UPWARDS_WHITE_ARROW \
179 ] stringByAppendingString: string] \
180 action:nil keyEquivalent:@""]; \
181 [o_mi setKeyEquivalentModifierMask: \
182 NSAlternateKeyMask | NSShiftKeyMask]; \
183 [o_mi setAlternate: YES]; \
185 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )]; \
186 [o_menu addItem: o_mi]; \
188 o_mi = [[NSMenuItem alloc] initWithTitle: \
189 [[NSString stringWithUTF8String: \
190 OPTION_KEY PLACE_OF_INTEREST_SIGN \
191 ] stringByAppendingString: string] \
192 action:nil keyEquivalent:@""]; \
193 [o_mi setKeyEquivalentModifierMask: \
194 NSAlternateKeyMask | NSCommandKeyMask]; \
195 [o_mi setAlternate: YES]; \
197 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )]; \
198 [o_menu addItem: o_mi]; \
199 /* Alt+Shift+Apple */ \
200 o_mi = [[NSMenuItem alloc] initWithTitle: \
201 [[NSString stringWithUTF8String: \
202 OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
203 ] stringByAppendingString: string] \
204 action:nil keyEquivalent:@""]; \
205 [o_mi setKeyEquivalentModifierMask: \
206 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
207 [o_mi setAlternate: YES]; \
209 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
211 [o_menu addItem: o_mi]; \
213 o_mi = [[NSMenuItem alloc] initWithTitle: \
214 [[NSString stringWithUTF8String: \
215 UPWARDS_WHITE_ARROW \
216 ] stringByAppendingString: string] \
217 action:nil keyEquivalent:@""]; \
218 [o_mi setKeyEquivalentModifierMask: \
220 [o_mi setAlternate: YES]; \
222 KEY_MODIFIER_SHIFT | ( value )]; \
223 [o_menu addItem: o_mi]; \
225 o_mi = [[NSMenuItem alloc] initWithTitle: \
226 [[NSString stringWithUTF8String: \
227 UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
228 ] stringByAppendingString: string] \
229 action:nil keyEquivalent:@""]; \
230 [o_mi setKeyEquivalentModifierMask: \
231 NSShiftKeyMask | NSCommandKeyMask]; \
232 [o_mi setAlternate: YES]; \
234 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \
235 [o_menu addItem: o_mi]; \
237 o_mi = [[NSMenuItem alloc] initWithTitle: \
238 [[NSString stringWithUTF8String: \
239 PLACE_OF_INTEREST_SIGN \
240 ] stringByAppendingString: string] \
241 action:nil keyEquivalent:@""]; \
242 [o_mi setKeyEquivalentModifierMask: \
244 [o_mi setAlternate: YES]; \
246 KEY_MODIFIER_COMMAND | ( value )]; \
247 [o_menu addItem: o_mi]; \
251 #define ADD_LABEL( o_label, superFrame, x_offset, my_y_offset, label ) \
253 NSRect s_rc = superFrame; \
254 s_rc.size.height = 17; \
255 s_rc.origin.x = x_offset - 3; \
256 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
257 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
258 [o_label setDrawsBackground: NO]; \
259 [o_label setBordered: NO]; \
260 [o_label setEditable: NO]; \
261 [o_label setSelectable: NO]; \
262 [o_label setStringValue: label]; \
263 [o_label setFont:[NSFont systemFontOfSize:0]]; \
264 [o_label sizeToFit]; \
267 #define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \
268 my_width, tooltip, init_value ) \
270 NSRect s_rc = superFrame; \
271 s_rc.origin.x = x_offset; \
272 s_rc.origin.y = my_y_offset; \
273 s_rc.size.height = 22; \
274 s_rc.size.width = my_width; \
275 o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
276 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
277 [o_textfield setToolTip: tooltip]; \
278 [o_textfield setStringValue: init_value]; \
281 #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
284 NSRect s_rc = superFrame; \
285 s_rc.origin.x = x_offset + 2; \
286 s_rc.origin.y = my_y_offset; \
287 s_rc.size.height = 26; \
288 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
290 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
291 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
292 [o_combo setToolTip: tooltip]; \
293 [o_combo setUsesDataSource:TRUE]; \
294 [o_combo setDataSource:self]; \
295 [o_combo setNumberOfVisibleItems:10]; \
296 [o_combo setCompletes:YES]; \
299 #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, \
302 NSRect s_rc = superFrame; \
303 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
304 [o_button setButtonType: NSMomentaryPushInButton]; \
305 [o_button setBezelStyle: NSRoundedBezelStyle]; \
306 [o_button setTitle: title]; \
307 [o_button setFont:[NSFont systemFontOfSize:0]]; \
308 [o_button sizeToFit]; \
309 s_rc = [o_button frame]; \
310 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
311 s_rc.origin.y = my_y_offset - 6; \
312 s_rc.size.width += 12; \
313 [o_button setFrame: s_rc]; \
314 [o_button setToolTip: tooltip]; \
315 [o_button setTarget: self]; \
316 [o_button setAction: @selector(openFileDialog:)]; \
319 #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
322 NSRect s_rc = superFrame; \
323 s_rc.origin.x = x_offset - 1; \
324 s_rc.origin.y = my_y_offset; \
325 s_rc.size.height = 26; \
326 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
328 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
329 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
330 [o_popup setToolTip: tooltip]; \
333 #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
336 NSRect s_rc = superFrame; \
337 s_rc.origin.x = x_offset; \
338 s_rc.origin.y = my_y_offset; \
339 s_rc.size.height = 23; \
340 s_rc.size.width = 23; \
341 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
342 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
343 [o_stepper setToolTip: tooltip]; \
344 [o_stepper setMaxValue: higher]; \
345 [o_stepper setMinValue: lower]; \
346 [o_stepper setTarget: self]; \
347 [o_stepper setAction: @selector(stepperChanged:)]; \
348 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
349 NSLeftMouseDraggedMask]; \
352 #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, \
353 tooltip, lower, higher ) \
355 NSRect s_rc = superFrame; \
356 s_rc.origin.x = x_offset; \
357 s_rc.origin.y = my_y_offset; \
358 s_rc.size.height = 21; \
359 s_rc.size.width = my_width; \
360 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
361 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
362 [o_slider setToolTip: tooltip]; \
363 [o_slider setMaxValue: higher]; \
364 [o_slider setMinValue: lower]; \
367 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
368 tooltip, init_value, position ) \
370 NSRect s_rc = superFrame; \
371 s_rc.size.height = 18; \
372 s_rc.origin.x = x_offset - 2; \
373 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
374 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
375 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
376 [o_checkbox setButtonType: NSSwitchButton]; \
377 [o_checkbox setImagePosition: position]; \
378 [o_checkbox setIntValue: init_value]; \
379 [o_checkbox setTitle: label]; \
380 [o_checkbox setToolTip: tooltip]; \
381 [o_checkbox sizeToFit]; \
384 @implementation VLCConfigControl
385 - (id)initWithFrame: (NSRect)frame
387 return [self initWithFrame: frame
391 - (id)initWithFrame: (NSRect)frame
392 item: (module_config_t *)_p_item
394 self = [super initWithFrame: frame];
399 psz_name = strdup( p_item->psz_name );
401 i_type = p_item->i_type;
403 b_advanced = p_item->b_advanced;
404 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
409 - (void)setYPos:(int)i_yPos
411 NSRect frame = [self frame];
412 frame.origin.y = i_yPos;
413 [self setFrame:frame];
418 if( o_label ) [o_label release];
419 if( psz_name ) free( psz_name );
423 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
428 case CONFIG_ITEM_STRING:
431 case CONFIG_ITEM_STRING:
434 case CONFIG_ITEM_STRING_LIST:
437 case CONFIG_ITEM_FILE:
440 case CONFIG_ITEM_MODULE:
443 case CONFIG_ITEM_INTEGER:
446 case CONFIG_ITEM_RANGED_INTEGER:
449 case CONFIG_ITEM_BOOL:
452 case CONFIG_ITEM_KEY_BEFORE_10_3:
455 case CONFIG_ITEM_KEY_AFTER_10_3:
458 case CONFIG_ITEM_MODULE_LIST:
466 case CONFIG_ITEM_STRING_LIST:
469 case CONFIG_ITEM_STRING:
472 case CONFIG_ITEM_STRING_LIST:
475 case CONFIG_ITEM_FILE:
478 case CONFIG_ITEM_MODULE:
481 case CONFIG_ITEM_INTEGER:
484 case CONFIG_ITEM_RANGED_INTEGER:
487 case CONFIG_ITEM_BOOL:
490 case CONFIG_ITEM_KEY_BEFORE_10_3:
493 case CONFIG_ITEM_KEY_AFTER_10_3:
496 case CONFIG_ITEM_MODULE_LIST:
504 case CONFIG_ITEM_FILE:
507 case CONFIG_ITEM_STRING:
510 case CONFIG_ITEM_STRING_LIST:
513 case CONFIG_ITEM_FILE:
516 case CONFIG_ITEM_MODULE:
519 case CONFIG_ITEM_INTEGER:
522 case CONFIG_ITEM_RANGED_INTEGER:
525 case CONFIG_ITEM_BOOL:
528 case CONFIG_ITEM_KEY_BEFORE_10_3:
531 case CONFIG_ITEM_KEY_AFTER_10_3:
534 case CONFIG_ITEM_MODULE_LIST:
542 case CONFIG_ITEM_MODULE:
545 case CONFIG_ITEM_STRING:
548 case CONFIG_ITEM_STRING_LIST:
551 case CONFIG_ITEM_FILE:
554 case CONFIG_ITEM_MODULE:
557 case CONFIG_ITEM_INTEGER:
560 case CONFIG_ITEM_RANGED_INTEGER:
563 case CONFIG_ITEM_BOOL:
566 case CONFIG_ITEM_KEY_BEFORE_10_3:
569 case CONFIG_ITEM_KEY_AFTER_10_3:
572 case CONFIG_ITEM_MODULE_LIST:
580 case CONFIG_ITEM_INTEGER:
583 case CONFIG_ITEM_STRING:
586 case CONFIG_ITEM_STRING_LIST:
589 case CONFIG_ITEM_FILE:
592 case CONFIG_ITEM_MODULE:
595 case CONFIG_ITEM_INTEGER:
598 case CONFIG_ITEM_RANGED_INTEGER:
601 case CONFIG_ITEM_BOOL:
604 case CONFIG_ITEM_KEY_BEFORE_10_3:
607 case CONFIG_ITEM_KEY_AFTER_10_3:
610 case CONFIG_ITEM_MODULE_LIST:
618 case CONFIG_ITEM_RANGED_INTEGER:
621 case CONFIG_ITEM_STRING:
624 case CONFIG_ITEM_STRING_LIST:
627 case CONFIG_ITEM_FILE:
630 case CONFIG_ITEM_MODULE:
633 case CONFIG_ITEM_INTEGER:
636 case CONFIG_ITEM_RANGED_INTEGER:
639 case CONFIG_ITEM_BOOL:
642 case CONFIG_ITEM_KEY_BEFORE_10_3:
645 case CONFIG_ITEM_KEY_AFTER_10_3:
648 case CONFIG_ITEM_MODULE_LIST:
656 case CONFIG_ITEM_BOOL:
659 case CONFIG_ITEM_STRING:
662 case CONFIG_ITEM_STRING_LIST:
665 case CONFIG_ITEM_FILE:
668 case CONFIG_ITEM_MODULE:
671 case CONFIG_ITEM_INTEGER:
674 case CONFIG_ITEM_RANGED_INTEGER:
677 case CONFIG_ITEM_BOOL:
680 case CONFIG_ITEM_KEY_BEFORE_10_3:
683 case CONFIG_ITEM_KEY_AFTER_10_3:
686 case CONFIG_ITEM_MODULE_LIST:
694 case CONFIG_ITEM_KEY_BEFORE_10_3:
697 case CONFIG_ITEM_STRING:
700 case CONFIG_ITEM_STRING_LIST:
703 case CONFIG_ITEM_FILE:
706 case CONFIG_ITEM_MODULE:
709 case CONFIG_ITEM_INTEGER:
712 case CONFIG_ITEM_RANGED_INTEGER:
715 case CONFIG_ITEM_BOOL:
718 case CONFIG_ITEM_KEY_BEFORE_10_3:
721 case CONFIG_ITEM_KEY_AFTER_10_3:
724 case CONFIG_ITEM_MODULE_LIST:
732 case CONFIG_ITEM_KEY_AFTER_10_3:
735 case CONFIG_ITEM_STRING:
738 case CONFIG_ITEM_STRING_LIST:
741 case CONFIG_ITEM_FILE:
744 case CONFIG_ITEM_MODULE:
747 case CONFIG_ITEM_INTEGER:
750 case CONFIG_ITEM_RANGED_INTEGER:
753 case CONFIG_ITEM_BOOL:
756 case CONFIG_ITEM_KEY_BEFORE_10_3:
759 case CONFIG_ITEM_KEY_AFTER_10_3:
762 case CONFIG_ITEM_MODULE_LIST:
770 case CONFIG_ITEM_MODULE_LIST:
773 case CONFIG_ITEM_STRING:
776 case CONFIG_ITEM_STRING_LIST:
779 case CONFIG_ITEM_FILE:
782 case CONFIG_ITEM_MODULE:
785 case CONFIG_ITEM_INTEGER:
788 case CONFIG_ITEM_RANGED_INTEGER:
791 case CONFIG_ITEM_BOOL:
794 case CONFIG_ITEM_KEY_BEFORE_10_3:
797 case CONFIG_ITEM_KEY_AFTER_10_3:
800 case CONFIG_ITEM_MODULE_LIST:
815 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
816 withView: (NSView *)o_parent_view
818 VLCConfigControl *p_control = NULL;
819 /* Skip depracated options */
820 if( _p_item->psz_current )
825 switch( _p_item->i_type )
827 case CONFIG_ITEM_STRING:
828 if( !_p_item->i_list )
830 p_control = [[StringConfigControl alloc]
831 initWithItem: _p_item
832 withView: o_parent_view];
836 p_control = [[StringListConfigControl alloc]
837 initWithItem: _p_item
838 withView: o_parent_view];
841 case CONFIG_ITEM_FILE:
842 case CONFIG_ITEM_DIRECTORY:
843 p_control = [[FileConfigControl alloc]
844 initWithItem: _p_item
845 withView: o_parent_view];
847 case CONFIG_ITEM_MODULE:
848 case CONFIG_ITEM_MODULE_CAT:
849 p_control = [[ModuleConfigControl alloc]
850 initWithItem: _p_item
851 withView: o_parent_view];
853 case CONFIG_ITEM_INTEGER:
854 if( _p_item->i_list )
856 p_control = [[IntegerListConfigControl alloc]
857 initWithItem: _p_item
858 withView: o_parent_view];
860 else if( _p_item->i_min != 0 || _p_item->i_max != 0 )
862 p_control = [[RangedIntegerConfigControl alloc]
863 initWithItem: _p_item
864 withView: o_parent_view];
868 p_control = [[IntegerConfigControl alloc]
869 initWithItem: _p_item
870 withView: o_parent_view];
873 case CONFIG_ITEM_BOOL:
874 p_control = [[BoolConfigControl alloc]
875 initWithItem: _p_item
876 withView: o_parent_view];
878 case CONFIG_ITEM_FLOAT:
879 if( _p_item->f_min != 0 || _p_item->f_max != 0 )
881 p_control = [[RangedFloatConfigControl alloc]
882 initWithItem: _p_item
883 withView: o_parent_view];
887 p_control = [[FloatConfigControl alloc]
888 initWithItem: _p_item
889 withView: o_parent_view];
892 case CONFIG_ITEM_KEY:
893 if( MACOS_VERSION < 10.3 )
895 p_control = [[KeyConfigControlBefore103 alloc]
896 initWithItem: _p_item
897 withView: o_parent_view];
901 p_control = [[KeyConfigControlAfter103 alloc]
902 initWithItem: _p_item
903 withView: o_parent_view];
906 case CONFIG_ITEM_MODULE_LIST:
907 case CONFIG_ITEM_MODULE_LIST_CAT:
908 p_control = [[ModuleListConfigControl alloc]
909 initWithItem: _p_item
910 withView: o_parent_view];
918 - (NSString *)getName
920 return [[VLCMain sharedInstance] localizedString: psz_name];
948 - (char *)stringValue
956 switch( p_item->i_type )
958 case CONFIG_ITEM_STRING:
959 case CONFIG_ITEM_FILE:
960 case CONFIG_ITEM_DIRECTORY:
961 case CONFIG_ITEM_MODULE:
962 case CONFIG_ITEM_MODULE_LIST:
963 case CONFIG_ITEM_MODULE_LIST_CAT:
964 config_PutPsz( VLCIntf, psz_name, [self stringValue] );
966 case CONFIG_ITEM_KEY:
967 /* So you don't need to restart to have the changes take effect */
968 val.i_int = [self intValue];
969 var_Set( VLCIntf->p_vlc, psz_name, val );
970 case CONFIG_ITEM_INTEGER:
971 case CONFIG_ITEM_BOOL:
972 config_PutInt( VLCIntf, psz_name, [self intValue] );
974 case CONFIG_ITEM_FLOAT:
975 config_PutFloat( VLCIntf, psz_name, [self floatValue] );
982 return [o_label frame].size.width;
986 @implementation StringConfigControl
987 - (id) initWithItem: (module_config_t *)_p_item
988 withView: (NSView *)o_parent_view
990 NSRect mainFrame = [o_parent_view frame];
991 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
992 mainFrame.size.height = 22;
993 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
994 mainFrame.origin.x = LEFTMARGIN;
995 mainFrame.origin.y = 0;
997 if( [super initWithFrame: mainFrame item: _p_item] != nil )
999 i_view_type = CONFIG_ITEM_STRING;
1001 if( p_item->psz_text )
1002 o_labelString = [[VLCMain sharedInstance]
1003 localizedString: p_item->psz_text];
1005 o_labelString = [NSString stringWithString:@""];
1006 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1007 [o_label setAutoresizingMask:NSViewNotSizable ];
1008 [self addSubview: o_label];
1010 /* build the textfield */
1011 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1012 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext]
1013 toWidth: PREFS_WRAP];
1014 if( p_item->psz_value )
1015 o_textfieldString = [[VLCMain sharedInstance]
1016 localizedString: p_item->psz_value];
1018 o_textfieldString = [NSString stringWithString: @""];
1019 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1020 0, mainFrame.size.width - [o_label frame].size.width -
1021 2, o_textfieldTooltip, o_textfieldString )
1022 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1023 [self addSubview: o_textfield];
1028 - (void) alignWithXPosition:(int)i_xPos
1031 NSRect superFrame = [self frame];
1032 frame = [o_label frame];
1033 frame.origin.x = i_xPos - frame.size.width - 3;
1034 [o_label setFrame:frame];
1036 frame = [o_textfield frame];
1037 frame.origin.x = i_xPos + 2;
1038 frame.size.width = superFrame.size.width - frame.origin.x - 1;
1039 [o_textfield setFrame:frame];
1044 [o_textfield release];
1048 - (char *)stringValue
1050 return strdup( [[VLCMain sharedInstance] delocalizeString:
1051 [o_textfield stringValue]] );
1055 @implementation StringListConfigControl
1056 - (id) initWithItem: (module_config_t *)_p_item
1057 withView: (NSView *)o_parent_view
1059 NSRect mainFrame = [o_parent_view frame];
1060 NSString *o_labelString, *o_textfieldTooltip;
1061 mainFrame.size.height = 22;
1062 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1063 mainFrame.origin.x = LEFTMARGIN;
1064 mainFrame.origin.y = 0;
1066 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1069 i_view_type = CONFIG_ITEM_STRING_LIST;
1071 if( p_item->psz_text )
1072 o_labelString = [[VLCMain sharedInstance]
1073 localizedString: p_item->psz_text];
1075 o_labelString = [NSString stringWithString:@""];
1076 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1077 [o_label setAutoresizingMask:NSViewNotSizable ];
1078 [self addSubview: o_label];
1080 /* build the textfield */
1081 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1082 [[VLCMain sharedInstance]
1083 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1084 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1085 -2, 0, o_textfieldTooltip )
1086 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1087 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1088 if( p_item->psz_value &&
1089 !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) )
1090 [o_combo selectItemAtIndex: i_index];
1091 [self addSubview: o_combo];
1096 - (void) alignWithXPosition:(int)i_xPos
1099 NSRect superFrame = [self frame];
1100 frame = [o_label frame];
1101 frame.origin.x = i_xPos - frame.size.width - 3;
1102 [o_label setFrame:frame];
1104 frame = [o_combo frame];
1105 frame.origin.x = i_xPos + 2;
1106 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1107 [o_combo setFrame:frame];
1116 - (char *)stringValue
1118 if( [o_combo indexOfSelectedItem] >= 0 )
1119 return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
1121 return strdup( [[VLCMain sharedInstance]
1122 delocalizeString: [o_combo stringValue]] );
1126 @implementation StringListConfigControl (NSComboBoxDataSource)
1127 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1129 return p_item->i_list;
1132 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1134 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1136 return [[VLCMain sharedInstance]
1137 localizedString: p_item->ppsz_list_text[i_index]];
1138 } else return [[VLCMain sharedInstance]
1139 localizedString: p_item->ppsz_list[i_index]];
1143 @implementation FileConfigControl
1144 - (id) initWithItem: (module_config_t *)_p_item
1145 withView: (NSView *)o_parent_view
1147 NSRect mainFrame = [o_parent_view frame];
1148 NSString *o_labelString, *o_buttonTooltip, *o_textfieldString;
1149 NSString *o_textfieldTooltip;
1150 mainFrame.size.height = 46;
1151 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1152 mainFrame.origin.x = LEFTMARGIN;
1153 mainFrame.origin.y = 0;
1155 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1157 i_view_type = CONFIG_ITEM_FILE;
1159 /* is it a directory */
1160 b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
1163 if( p_item->psz_text )
1164 o_labelString = [[VLCMain sharedInstance]
1165 localizedString: p_item->psz_text];
1167 o_labelString = [NSString stringWithString:@""];
1168 ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString )
1169 [o_label setAutoresizingMask:NSViewNotSizable ];
1170 [self addSubview: o_label];
1172 /* build the button */
1173 o_buttonTooltip = [[VLCMain sharedInstance]
1174 wrapString: [[VLCMain sharedInstance]
1175 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1176 ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_buttonTooltip,
1178 [o_button setAutoresizingMask:NSViewMinXMargin ];
1179 [self addSubview: o_button];
1181 /* build the textfield */
1182 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1183 [[VLCMain sharedInstance]
1184 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1185 if( p_item->psz_value )
1186 o_textfieldString = [[VLCMain sharedInstance]
1187 localizedString: p_item->psz_value];
1189 o_textfieldString = [NSString stringWithString: @""];
1190 ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1191 8 - [o_button frame].size.width,
1192 o_textfieldTooltip, o_textfieldString )
1193 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1194 [self addSubview: o_textfield];
1199 - (void) alignWithXPosition:(int)i_xPos
1206 [o_textfield release];
1211 - (IBAction)openFileDialog: (id)sender
1213 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1215 [o_open_panel setTitle: (b_directory)?
1216 _NS("Select a directory"):_NS("Select a file")];
1217 [o_open_panel setPrompt: _NS("Select")];
1218 [o_open_panel setAllowsMultipleSelection: NO];
1219 [o_open_panel setCanChooseFiles: !b_directory];
1220 [o_open_panel setCanChooseDirectories: b_directory];
1221 [o_open_panel beginSheetForDirectory:nil
1224 modalForWindow:[sender window]
1226 didEndSelector: @selector(pathChosenInPanel:
1232 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
1233 withReturn:(int)i_return_code contextInfo:(void *)o_context_info
1235 if( i_return_code == NSOKButton )
1237 NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
1238 [o_textfield setStringValue: o_path];
1242 - (char *)stringValue
1244 if( [[o_textfield stringValue] length] != 0)
1245 return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
1251 @implementation ModuleConfigControl
1252 - (id) initWithItem: (module_config_t *)_p_item
1253 withView: (NSView *)o_parent_view
1255 NSRect mainFrame = [o_parent_view frame];
1256 NSString *o_labelString, *o_popupTooltip;
1257 mainFrame.size.height = 22;
1258 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1259 mainFrame.origin.x = LEFTMARGIN;
1260 mainFrame.origin.y = 0;
1262 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1267 i_view_type = CONFIG_ITEM_MODULE;
1270 if( p_item->psz_text )
1271 o_labelString = [[VLCMain sharedInstance]
1272 localizedString: p_item->psz_text];
1274 o_labelString = [NSString stringWithString:@""];
1275 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
1276 [o_label setAutoresizingMask:NSViewNotSizable ];
1277 [self addSubview: o_label];
1279 /* build the popup */
1280 o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1281 [[VLCMain sharedInstance]
1282 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1283 ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
1284 -2, 0, o_popupTooltip )
1285 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1286 [o_popup addItemWithTitle: _NS("Default")];
1287 [[o_popup lastItem] setTag: -1];
1288 [o_popup selectItem: [o_popup lastItem]];
1290 /* build a list of available modules */
1291 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1292 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1294 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
1295 if( p_item->i_type == CONFIG_ITEM_MODULE )
1297 if( !strcmp( p_parser->psz_capability,
1298 p_item->psz_type ) )
1300 NSString *o_description = [[VLCMain sharedInstance]
1301 localizedString: p_parser->psz_longname];
1302 [o_popup addItemWithTitle: o_description];
1304 if( p_item->psz_value &&
1305 !strcmp( p_item->psz_value, p_parser->psz_object_name ) )
1306 [o_popup selectItem:[o_popup lastItem]];
1311 module_config_t *p_config;
1312 if( !strcmp( p_parser->psz_object_name, "main" ) )
1315 p_config = p_parser->p_config;
1318 /* Hack: required subcategory is stored in i_min */
1319 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1320 p_config->i_value == p_item->i_min )
1322 NSString *o_description = [[VLCMain sharedInstance]
1323 localizedString: p_parser->psz_longname];
1324 [o_popup addItemWithTitle: o_description];
1326 if( p_item->psz_value && !strcmp(p_item->psz_value,
1327 p_parser->psz_object_name) )
1328 [o_popup selectItem:[o_popup lastItem]];
1330 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
1333 vlc_list_release( p_list );
1334 [self addSubview: o_popup];
1339 - (void) alignWithXPosition:(int)i_xPos
1342 NSRect superFrame = [self frame];
1343 frame = [o_label frame];
1344 frame.origin.x = i_xPos - frame.size.width - 3;
1345 [o_label setFrame:frame];
1347 frame = [o_popup frame];
1348 frame.origin.x = i_xPos - 1;
1349 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1350 [o_popup setFrame:frame];
1359 - (char *)stringValue
1361 NSString *newval = [o_popup titleOfSelectedItem];
1362 char *returnval = NULL;
1367 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1368 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1370 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
1371 if( p_item->i_type == CONFIG_ITEM_MODULE )
1373 if( !strcmp( p_parser->psz_capability,
1374 p_item->psz_type ) )
1376 NSString *o_description = [[VLCMain sharedInstance]
1377 localizedString: p_parser->psz_longname];
1378 if( [newval isEqualToString: o_description] )
1380 returnval = strdup(p_parser->psz_object_name);
1387 module_config_t *p_config;
1388 if( !strcmp( p_parser->psz_object_name, "main" ) )
1391 p_config = p_parser->p_config;
1394 /* Hack: required subcategory is stored in i_min */
1395 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1396 p_config->i_value == p_item->i_min )
1398 NSString *o_description = [[VLCMain sharedInstance]
1399 localizedString: p_parser->psz_longname];
1400 if( [newval isEqualToString: o_description] )
1402 returnval = strdup(p_parser->psz_object_name);
1406 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
1409 vlc_list_release( p_list );
1414 @implementation IntegerConfigControl
1415 - (id) initWithItem: (module_config_t *)_p_item
1416 withView: (NSView *)o_parent_view
1418 NSRect mainFrame = [o_parent_view frame];
1419 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1420 mainFrame.size.height = 23;
1421 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1422 mainFrame.origin.x = LEFTMARGIN;
1423 mainFrame.origin.y = 0;
1425 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1427 i_view_type = CONFIG_ITEM_INTEGER;
1429 o_tooltip = [[VLCMain sharedInstance] wrapString:
1430 [[VLCMain sharedInstance]
1431 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1434 if( p_item->psz_text )
1435 o_labelString = [[VLCMain sharedInstance]
1436 localizedString: p_item->psz_text];
1438 o_labelString = [NSString stringWithString:@""];
1439 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1440 [o_label setAutoresizingMask:NSViewNotSizable ];
1441 [self addSubview: o_label];
1443 /* build the stepper */
1444 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1445 0, o_tooltip, -1600, 1600)
1446 [o_stepper setIntValue: p_item->i_value];
1447 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1448 [self addSubview: o_stepper];
1450 /* build the textfield */
1451 if( p_item->psz_value )
1452 o_textfieldString = [[VLCMain sharedInstance]
1453 localizedString: p_item->psz_value];
1455 o_textfieldString = [NSString stringWithString: @""];
1456 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1457 1, 49, o_tooltip, @"" )
1458 [o_textfield setIntValue: p_item->i_value];
1459 [o_textfield setDelegate: self];
1460 [[NSNotificationCenter defaultCenter] addObserver: self
1461 selector: @selector(textfieldChanged:)
1462 name: NSControlTextDidChangeNotification
1463 object: o_textfield];
1464 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1465 [self addSubview: o_textfield];
1470 - (void) alignWithXPosition:(int)i_xPos
1473 frame = [o_label frame];
1474 frame.origin.x = i_xPos - frame.size.width - 3;
1475 [o_label setFrame:frame];
1477 frame = [o_textfield frame];
1478 frame.origin.x = i_xPos + 2;
1479 [o_textfield setFrame:frame];
1481 frame = [o_stepper frame];
1482 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1483 [o_stepper setFrame:frame];
1488 [o_stepper release];
1489 [o_textfield release];
1493 - (IBAction)stepperChanged:(id)sender
1495 [o_textfield setIntValue: [o_stepper intValue]];
1498 - (void)textfieldChanged:(NSNotification *)o_notification
1500 [o_stepper setIntValue: [o_textfield intValue]];
1505 return [o_textfield intValue];
1510 @implementation IntegerListConfigControl
1512 - (id) initWithItem: (module_config_t *)_p_item
1513 withView: (NSView *)o_parent_view
1515 NSRect mainFrame = [o_parent_view frame];
1516 NSString *o_labelString, *o_textfieldTooltip;
1517 mainFrame.size.height = 22;
1518 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1519 mainFrame.origin.x = LEFTMARGIN;
1520 mainFrame.origin.y = 0;
1522 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1525 i_view_type = CONFIG_ITEM_STRING_LIST;
1528 if( p_item->psz_text )
1529 o_labelString = [[VLCMain sharedInstance]
1530 localizedString: p_item->psz_text];
1532 o_labelString = [NSString stringWithString:@""];
1533 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1534 [o_label setAutoresizingMask:NSViewNotSizable ];
1535 [self addSubview: o_label];
1537 /* build the textfield */
1538 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1539 [[VLCMain sharedInstance]
1540 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1541 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1542 -2, 0, o_textfieldTooltip )
1543 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1544 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1546 if( p_item->i_value == p_item->pi_list[i_index] )
1548 [o_combo selectItemAtIndex: i_index];
1551 [self addSubview: o_combo];
1556 - (void) alignWithXPosition:(int)i_xPos
1559 NSRect superFrame = [self frame];
1560 frame = [o_label frame];
1561 frame.origin.x = i_xPos - frame.size.width - 3;
1562 [o_label setFrame:frame];
1564 frame = [o_combo frame];
1565 frame.origin.x = i_xPos + 2;
1566 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1567 [o_combo setFrame:frame];
1578 if( [o_combo indexOfSelectedItem] >= 0 )
1579 return p_item->pi_list[[o_combo indexOfSelectedItem]];
1581 return [o_combo intValue];
1585 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1586 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1588 return p_item->i_list;
1591 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1593 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1594 return [[VLCMain sharedInstance]
1595 localizedString: p_item->ppsz_list_text[i_index]];
1597 return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1601 @implementation RangedIntegerConfigControl
1602 - (id) initWithItem: (module_config_t *)_p_item
1603 withView: (NSView *)o_parent_view
1605 NSRect mainFrame = [o_parent_view frame];
1606 NSString *o_labelString, *o_tooltip;
1607 mainFrame.size.height = 50;
1608 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1609 mainFrame.origin.x = LEFTMARGIN;
1610 mainFrame.origin.y = 0;
1612 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1614 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1617 if( p_item->psz_text )
1618 o_labelString = [[VLCMain sharedInstance]
1619 localizedString: p_item->psz_text];
1621 o_labelString = [NSString stringWithString:@""];
1622 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1623 [o_label setAutoresizingMask:NSViewNotSizable ];
1624 [self addSubview: o_label];
1626 /* build the textfield */
1627 o_tooltip = [[VLCMain sharedInstance] wrapString:
1628 [[VLCMain sharedInstance]
1629 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1630 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1631 28, 49, o_tooltip, @"" )
1632 [o_textfield setIntValue: p_item->i_value];
1633 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1634 [o_textfield setDelegate: self];
1635 [[NSNotificationCenter defaultCenter] addObserver: self
1636 selector: @selector(textfieldChanged:)
1637 name: NSControlTextDidChangeNotification
1638 object: o_textfield];
1639 [self addSubview: o_textfield];
1641 /* build the mintextfield */
1642 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1643 [o_textfield_min setIntValue: p_item->i_min];
1644 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1645 [o_textfield_min setAlignment:NSRightTextAlignment];
1646 [self addSubview: o_textfield_min];
1648 /* build the maxtextfield */
1649 ADD_LABEL( o_textfield_max, mainFrame,
1650 mainFrame.size.width - 31, -30, @"8888" )
1651 [o_textfield_max setIntValue: p_item->i_max];
1652 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1653 [self addSubview: o_textfield_max];
1655 /* build the slider */
1656 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1657 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1658 [o_textfield_max frame].size.width -
1659 [o_textfield_max frame].size.width - 14 -
1660 [o_textfield_min frame].origin.x, o_tooltip,
1661 p_item->i_min, p_item->i_max )
1662 [o_slider setIntValue: p_item->i_value];
1663 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1664 [o_slider setTarget: self];
1665 [o_slider setAction: @selector(sliderChanged:)];
1666 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1667 NSLeftMouseDraggedMask];
1668 [self addSubview: o_slider];
1674 - (void) alignWithXPosition:(int)i_xPos
1677 frame = [o_label frame];
1678 frame.origin.x = i_xPos - frame.size.width - 3;
1679 [o_label setFrame:frame];
1681 frame = [o_textfield frame];
1682 frame.origin.x = i_xPos + 2;
1683 [o_textfield setFrame:frame];
1688 [o_textfield release];
1689 [o_textfield_min release];
1690 [o_textfield_max release];
1695 - (IBAction)sliderChanged:(id)sender
1697 [o_textfield setIntValue: [o_slider intValue]];
1700 - (void)textfieldChanged:(NSNotification *)o_notification
1702 [o_slider setIntValue: [o_textfield intValue]];
1707 return [o_slider intValue];
1711 @implementation FloatConfigControl
1712 - (id) initWithItem: (module_config_t *)_p_item
1713 withView: (NSView *)o_parent_view
1715 NSRect mainFrame = [o_parent_view frame];
1716 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1717 mainFrame.size.height = 23;
1718 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1719 mainFrame.origin.x = LEFTMARGIN;
1720 mainFrame.origin.y = 0;
1722 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1724 i_view_type = CONFIG_ITEM_INTEGER;
1726 o_tooltip = [[VLCMain sharedInstance] wrapString:
1727 [[VLCMain sharedInstance]
1728 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1731 if( p_item->psz_text )
1732 o_labelString = [[VLCMain sharedInstance]
1733 localizedString: p_item->psz_text];
1735 o_labelString = [NSString stringWithString:@""];
1736 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
1737 [o_label setAutoresizingMask:NSViewNotSizable ];
1738 [self addSubview: o_label];
1740 /* build the stepper */
1741 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1742 0, o_tooltip, -1600, 1600)
1743 [o_stepper setFloatValue: p_item->f_value];
1744 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1745 [self addSubview: o_stepper];
1747 /* build the textfield */
1748 if( p_item->psz_value )
1749 o_textfieldString = [[VLCMain sharedInstance]
1750 localizedString: p_item->psz_value];
1752 o_textfieldString = [NSString stringWithString: @""];
1753 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1754 1, 49, o_tooltip, @"" )
1755 [o_textfield setFloatValue: p_item->f_value];
1756 [o_textfield setDelegate: self];
1757 [[NSNotificationCenter defaultCenter] addObserver: self
1758 selector: @selector(textfieldChanged:)
1759 name: NSControlTextDidChangeNotification
1760 object: o_textfield];
1761 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1762 [self addSubview: o_textfield];
1767 - (void) alignWithXPosition:(int)i_xPos
1770 frame = [o_label frame];
1771 frame.origin.x = i_xPos - frame.size.width - 3;
1772 [o_label setFrame:frame];
1774 frame = [o_textfield frame];
1775 frame.origin.x = i_xPos + 2;
1776 [o_textfield setFrame:frame];
1778 frame = [o_stepper frame];
1779 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1780 [o_stepper setFrame:frame];
1785 [o_stepper release];
1786 [o_textfield release];
1790 - (IBAction)stepperChanged:(id)sender
1792 [o_textfield setFloatValue: [o_stepper floatValue]];
1795 - (void)textfieldChanged:(NSNotification *)o_notification
1797 [o_stepper setFloatValue: [o_textfield floatValue]];
1802 return [o_stepper floatValue];
1806 @implementation RangedFloatConfigControl
1807 - (id) initWithItem: (module_config_t *)_p_item
1808 withView: (NSView *)o_parent_view
1810 NSRect mainFrame = [o_parent_view frame];
1811 NSString *o_labelString, *o_tooltip;
1812 mainFrame.size.height = 50;
1813 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1814 mainFrame.origin.x = LEFTMARGIN;
1815 mainFrame.origin.y = 0;
1817 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1819 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1822 if( p_item->psz_text )
1823 o_labelString = [[VLCMain sharedInstance]
1824 localizedString: p_item->psz_text];
1826 o_labelString = [NSString stringWithString:@""];
1827 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1828 [o_label setAutoresizingMask:NSViewNotSizable ];
1829 [self addSubview: o_label];
1831 /* build the textfield */
1832 o_tooltip = [[VLCMain sharedInstance] wrapString:
1833 [[VLCMain sharedInstance]
1834 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1835 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1836 28, 49, o_tooltip, @"" )
1837 [o_textfield setFloatValue: p_item->f_value];
1838 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1839 [o_textfield setDelegate: self];
1840 [[NSNotificationCenter defaultCenter] addObserver: self
1841 selector: @selector(textfieldChanged:)
1842 name: NSControlTextDidChangeNotification
1843 object: o_textfield];
1844 [self addSubview: o_textfield];
1846 /* build the mintextfield */
1847 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1848 [o_textfield_min setFloatValue: p_item->f_min];
1849 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1850 [o_textfield_min setAlignment:NSRightTextAlignment];
1851 [self addSubview: o_textfield_min];
1853 /* build the maxtextfield */
1854 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
1856 [o_textfield_max setFloatValue: p_item->f_max];
1857 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1858 [self addSubview: o_textfield_max];
1860 /* build the slider */
1861 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1862 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1863 [o_textfield_max frame].size.width -
1864 [o_textfield_max frame].size.width - 14 -
1865 [o_textfield_min frame].origin.x, o_tooltip, p_item->f_min,
1867 [o_slider setFloatValue: p_item->f_value];
1868 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1869 [o_slider setTarget: self];
1870 [o_slider setAction: @selector(sliderChanged:)];
1871 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1872 NSLeftMouseDraggedMask];
1873 [self addSubview: o_slider];
1879 - (void) alignWithXPosition:(int)i_xPos
1882 frame = [o_label frame];
1883 frame.origin.x = i_xPos - frame.size.width - 3;
1884 [o_label setFrame:frame];
1886 frame = [o_textfield frame];
1887 frame.origin.x = i_xPos + 2;
1888 [o_textfield setFrame:frame];
1893 [o_textfield release];
1894 [o_textfield_min release];
1895 [o_textfield_max release];
1900 - (IBAction)sliderChanged:(id)sender
1902 [o_textfield setFloatValue: [o_slider floatValue]];
1905 - (void)textfieldChanged:(NSNotification *)o_notification
1907 [o_slider setFloatValue: [o_textfield floatValue]];
1912 return [o_slider floatValue];
1917 @implementation BoolConfigControl
1919 - (id) initWithItem: (module_config_t *)_p_item
1920 withView: (NSView *)o_parent_view
1922 NSRect mainFrame = [o_parent_view frame];
1923 NSString *o_labelString, *o_tooltip;
1924 mainFrame.size.height = 17;
1925 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1926 mainFrame.origin.x = LEFTMARGIN;
1927 mainFrame.origin.y = 0;
1929 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1931 i_view_type = CONFIG_ITEM_BOOL;
1934 if( p_item->psz_text )
1935 o_labelString = [[VLCMain sharedInstance]
1936 localizedString: p_item->psz_text];
1938 o_labelString = [NSString stringWithString:@""];
1939 ADD_LABEL( o_label, mainFrame, 0, 0, o_labelString )
1940 [o_label setAutoresizingMask:NSViewNotSizable ];
1941 [self addSubview: o_label];
1942 /* add the checkbox */
1943 o_tooltip = [[VLCMain sharedInstance]
1944 wrapString: [[VLCMain sharedInstance]
1945 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1946 ADD_CHECKBOX( o_checkbox, mainFrame, [o_label frame].size.width,
1947 0, @"", o_tooltip, p_item->i_value, NSImageLeft)
1948 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1949 [self addSubview: o_checkbox];
1954 - (void) alignWithXPosition:(int)i_xPos
1957 frame = [o_label frame];
1958 frame.origin.x = i_xPos - frame.size.width - 3;
1959 [o_label setFrame:frame];
1961 frame = [o_checkbox frame];
1962 frame.origin.x = i_xPos;
1963 [o_checkbox setFrame:frame];
1968 [o_checkbox release];
1974 return [o_checkbox intValue];
1979 @implementation KeyConfigControlBefore103
1981 - (id) initWithItem: (module_config_t *)_p_item
1982 withView: (NSView *)o_parent_view
1984 NSRect mainFrame = [o_parent_view frame];
1985 NSString *o_labelString, *o_tooltip;
1986 mainFrame.size.height = 37;
1987 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1988 mainFrame.origin.x = LEFTMARGIN;
1989 mainFrame.origin.y = 0;
1991 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1993 i_view_type = CONFIG_ITEM_KEY_BEFORE_10_3;
1996 if( p_item->psz_text )
1997 o_labelString = [[VLCMain sharedInstance]
1998 localizedString: p_item->psz_text];
2000 o_labelString = [NSString stringWithString:@""];
2001 ADD_LABEL( o_label, mainFrame, 0, -10, o_labelString )
2002 [o_label setAutoresizingMask:NSViewNotSizable ];
2003 [self addSubview: o_label];
2005 /* add the checkboxes */
2006 o_tooltip = [[VLCMain sharedInstance] wrapString:
2007 [[VLCMain sharedInstance]
2008 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2009 ADD_CHECKBOX( o_cmd_checkbox, mainFrame,
2010 [o_label frame].size.width + 2, 0,
2011 [NSString stringWithUTF8String:PLACE_OF_INTEREST_SIGN], o_tooltip,
2012 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_COMMAND)?YES:NO),
2014 [o_cmd_checkbox setState: p_item->i_value & KEY_MODIFIER_COMMAND];
2015 ADD_CHECKBOX( o_ctrl_checkbox, mainFrame,
2016 [o_cmd_checkbox frame].size.width +
2017 [o_cmd_checkbox frame].origin.x + 6, 0,
2018 [NSString stringWithUTF8String:UP_ARROWHEAD], o_tooltip,
2019 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_CTRL)?YES:NO),
2021 [o_ctrl_checkbox setState: p_item->i_value & KEY_MODIFIER_CTRL];
2022 ADD_CHECKBOX( o_alt_checkbox, mainFrame, [o_label frame].size.width +
2023 2, -2 - [o_cmd_checkbox frame].size.height,
2024 [NSString stringWithUTF8String:OPTION_KEY], o_tooltip,
2025 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_ALT)?YES:NO),
2027 [o_alt_checkbox setState: p_item->i_value & KEY_MODIFIER_ALT];
2028 ADD_CHECKBOX( o_shift_checkbox, mainFrame,
2029 [o_cmd_checkbox frame].size.width +
2030 [o_cmd_checkbox frame].origin.x + 6, -2 -
2031 [o_cmd_checkbox frame].size.height,
2032 [NSString stringWithUTF8String:UPWARDS_WHITE_ARROW], o_tooltip,
2033 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_SHIFT)?YES:NO),
2035 [o_shift_checkbox setState: p_item->i_value & KEY_MODIFIER_SHIFT];
2036 [self addSubview: o_cmd_checkbox];
2037 [self addSubview: o_ctrl_checkbox];
2038 [self addSubview: o_alt_checkbox];
2039 [self addSubview: o_shift_checkbox];
2041 /* build the popup */
2042 ADD_POPUP( o_popup, mainFrame, [o_shift_checkbox frame].origin.x +
2043 [o_shift_checkbox frame].size.width + 4,
2045 [o_popup setAutoresizingMask:NSViewWidthSizable ];
2047 if( o_keys_menu == nil )
2050 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
2051 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
2052 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
2053 POPULATE_A_KEY( o_keys_menu,
2054 [NSString stringWithCString:vlc_keys[i].psz_key_string]
2055 , vlc_keys[i].i_key_code)
2057 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2058 [o_popup selectItemWithTitle: [[VLCMain sharedInstance]
2059 localizedString:KeyToString(
2060 (((unsigned int)p_item->i_value) & ~KEY_MODIFIER ))]];
2061 [self addSubview: o_popup];
2066 - (void) alignWithXPosition:(int)i_xPos
2069 NSRect superFrame = [self frame];
2070 frame = [o_label frame];
2071 frame.origin.x = i_xPos - frame.size.width - 3;
2072 [o_label setFrame:frame];
2074 frame = [o_cmd_checkbox frame];
2075 frame.origin.x = i_xPos;
2076 [o_cmd_checkbox setFrame:frame];
2078 frame = [o_ctrl_checkbox frame];
2079 frame.origin.x = [o_cmd_checkbox frame].size.width +
2080 [o_cmd_checkbox frame].origin.x + 4;
2081 [o_ctrl_checkbox setFrame:frame];
2083 frame = [o_alt_checkbox frame];
2084 frame.origin.x = i_xPos;
2085 [o_alt_checkbox setFrame:frame];
2087 frame = [o_shift_checkbox frame];
2088 frame.origin.x = [o_cmd_checkbox frame].size.width +
2089 [o_cmd_checkbox frame].origin.x + 4;
2090 [o_shift_checkbox setFrame:frame];
2092 frame = [o_popup frame];
2093 frame.origin.x = [o_shift_checkbox frame].origin.x +
2094 [o_shift_checkbox frame].size.width + 3;
2095 frame.size.width = superFrame.size.width - frame.origin.x + 2;
2096 [o_popup setFrame:frame];
2101 [o_cmd_checkbox release];
2102 [o_ctrl_checkbox release];
2103 [o_alt_checkbox release];
2104 [o_shift_checkbox release];
2111 unsigned int i_new_key = 0;
2113 i_new_key |= ([o_cmd_checkbox state] == NSOnState) ?
2114 KEY_MODIFIER_COMMAND : 0;
2115 i_new_key |= ([o_ctrl_checkbox state] == NSOnState) ?
2116 KEY_MODIFIER_CTRL : 0;
2117 i_new_key |= ([o_alt_checkbox state] == NSOnState) ?
2118 KEY_MODIFIER_ALT : 0;
2119 i_new_key |= ([o_shift_checkbox state] == NSOnState) ?
2120 KEY_MODIFIER_SHIFT : 0;
2122 i_new_key |= StringToKey([[[o_popup selectedItem] title] cString]);
2127 @implementation KeyConfigControlAfter103
2128 - (id) initWithItem: (module_config_t *)_p_item
2129 withView: (NSView *)o_parent_view
2131 NSRect mainFrame = [o_parent_view frame];
2132 NSString *o_labelString, *o_tooltip;
2133 mainFrame.size.height = 22;
2134 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
2135 mainFrame.origin.x = LEFTMARGIN;
2136 mainFrame.origin.y = 0;
2138 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2140 i_view_type = CONFIG_ITEM_KEY_AFTER_10_3;
2143 if( p_item->psz_text )
2144 o_labelString = [[VLCMain sharedInstance]
2145 localizedString: p_item->psz_text];
2147 o_labelString = [NSString stringWithString:@""];
2148 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
2149 [o_label setAutoresizingMask:NSViewNotSizable ];
2150 [self addSubview: o_label];
2152 /* build the popup */
2153 o_tooltip = [[VLCMain sharedInstance] wrapString:
2154 [[VLCMain sharedInstance]
2155 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2156 ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
2157 [o_label frame].size.width + 3,
2159 [o_popup setAutoresizingMask:NSViewWidthSizable ];
2161 if( o_keys_menu == nil )
2164 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
2165 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
2166 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
2167 POPULATE_A_KEY( o_keys_menu,
2168 [NSString stringWithCString:vlc_keys[i].psz_key_string]
2169 , vlc_keys[i].i_key_code)
2171 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2172 [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->i_value]];
2173 [self addSubview: o_popup];
2179 - (void) alignWithXPosition:(int)i_xPos
2182 NSRect superFrame = [self frame];
2183 frame = [o_label frame];
2184 frame.origin.x = i_xPos - frame.size.width - 3;
2185 [o_label setFrame:frame];
2187 frame = [o_popup frame];
2188 frame.origin.x = i_xPos - 1;
2189 frame.size.width = superFrame.size.width - frame.origin.x + 2;
2190 [o_popup setFrame:frame];
2201 return [o_popup selectedTag];
2205 @implementation ModuleListConfigControl
2206 - (id) initWithItem: (module_config_t *)_p_item
2207 withView: (NSView *)o_parent_view
2209 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
2213 //Fill our array to know how may items we have...
2217 NSRect mainFrame = [o_parent_view frame];
2218 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2220 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2221 /* build a list of available modules */
2222 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
2223 for( i_index = 0; i_index < p_list->i_count; i_index++ )
2225 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
2227 if( !strcmp( p_parser->psz_object_name, "main" ) )
2230 module_config_t *p_config = p_parser->p_config;
2233 NSString *o_modulelongname, *o_modulename;
2234 NSNumber *o_moduleenabled = nil;
2235 /* Hack: required subcategory is stored in i_min */
2236 if( p_config->i_type == CONFIG_SUBCATEGORY &&
2237 p_config->i_value == _p_item->i_min )
2239 o_modulelongname = [NSString stringWithUTF8String:
2240 p_parser->psz_longname];
2241 o_modulename = [NSString stringWithUTF8String:
2242 p_parser->psz_object_name];
2244 if( _p_item->psz_value &&
2245 strstr( _p_item->psz_value, p_parser->psz_object_name ) )
2246 o_moduleenabled = [NSNumber numberWithBool:YES];
2248 o_moduleenabled = [NSNumber numberWithBool:NO];
2250 [o_modulearray addObject:[NSMutableArray
2251 arrayWithObjects: o_modulename, o_modulelongname,
2252 o_moduleenabled, nil]];
2254 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
2256 vlc_list_release( p_list );
2258 mainFrame.size.height = 30 + 18 * [o_modulearray count];
2259 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2260 mainFrame.origin.x = LEFTMARGIN;
2261 mainFrame.origin.y = 0;
2262 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2264 i_view_type = CONFIG_ITEM_MODULE_LIST;
2267 if( p_item->psz_text )
2268 o_labelString = [[VLCMain sharedInstance]
2269 localizedString: p_item->psz_text];
2271 o_labelString = [NSString stringWithString:@""];
2272 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
2273 [o_label setAutoresizingMask:NSViewNotSizable ];
2274 [self addSubview: o_label];
2276 /* build the textfield */
2277 o_tooltip = [[VLCMain sharedInstance] wrapString:
2278 [[VLCMain sharedInstance]
2279 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2280 if( p_item->psz_value )
2281 o_textfieldString = [[VLCMain sharedInstance]
2282 localizedString: p_item->psz_value];
2284 o_textfieldString = [NSString stringWithString: @""];
2285 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
2286 mainFrame.size.height - 22, mainFrame.size.width -
2287 [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
2288 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2289 [self addSubview: o_textfield];
2293 NSRect s_rc = mainFrame;
2294 s_rc.size.height = mainFrame.size.height - 30;
2295 s_rc.size.width = mainFrame.size.width - 12;
2298 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2299 [o_scrollview setDrawsBackground: NO];
2300 [o_scrollview setBorderType: NSBezelBorder];
2301 if( MACOS_VERSION >= 10.3 )
2302 [o_scrollview setAutohidesScrollers:YES];
2304 NSTableView *o_tableview;
2305 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2306 if( MACOS_VERSION >= 10.3 )
2307 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2308 [o_tableview setHeaderView:nil];
2309 /* TODO: find a good way to fix the row height and text size*/
2310 /* FIXME: support for multiple selection... */
2311 // [o_tableview setAllowsMultipleSelection:YES];
2313 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2314 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2315 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2316 [o_dataCell setTitle:@""];
2317 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2318 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2319 initWithIdentifier:[NSString stringWithCString: "Enabled"]];
2320 [o_tableColumn setHeaderCell: o_headerCell];
2321 [o_tableColumn setDataCell: o_dataCell];
2322 [o_tableColumn setWidth:17];
2323 [o_tableview addTableColumn: o_tableColumn];
2325 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2326 o_dataCell = [[NSTextFieldCell alloc] init];
2327 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2328 o_tableColumn = [[NSTableColumn alloc]
2329 initWithIdentifier:[NSString stringWithCString: "Module"]];
2330 [o_tableColumn setHeaderCell: o_headerCell];
2331 [o_tableColumn setDataCell: o_dataCell];
2332 [o_tableColumn setWidth:388 - 17];
2333 [o_tableview addTableColumn: o_tableColumn];
2334 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2335 @"VLC media player module", nil]];
2337 [o_tableview setDataSource:self];
2338 [o_tableview setTarget: self];
2339 [o_tableview setAction: @selector(tableChanged:)];
2340 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2341 NSLeftMouseDraggedMask];
2342 [o_scrollview setDocumentView: o_tableview];
2344 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2345 [self addSubview: o_scrollview];
2352 - (void) alignWithXPosition:(int)i_xPos
2357 - (IBAction)tableChanged:(id)sender
2359 NSString *o_newstring = @"";
2361 for( i = 0 ; i < [o_modulearray count] ; i++ )
2362 if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2365 o_newstring = [o_newstring stringByAppendingString:
2366 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2367 o_newstring = [o_newstring stringByAppendingString:@":"];
2370 [o_textfield setStringValue: [o_newstring
2371 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2376 [o_scrollview release];
2381 - (char *)stringValue
2383 return strdup( [[o_textfield stringValue] cString] );
2388 @implementation ModuleListConfigControl (NSTableDataSource)
2390 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2391 toPasteboard:(NSPasteboard*)pb
2393 // We only want to allow dragging of selected rows.
2394 NSEnumerator *iter = [rows objectEnumerator];
2396 while ((row = [iter nextObject]) != nil)
2398 if (![table isRowSelected:[row intValue]])
2402 [pb declareTypes:[NSArray
2403 arrayWithObject:@"VLC media player module"] owner:nil];
2404 [pb setPropertyList:rows forType:@"VLC media player module"];
2408 - (NSDragOperation)tableView:(NSTableView*)table
2409 validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row
2410 proposedDropOperation:(NSTableViewDropOperation)op
2412 // Make drops at the end of the table go to the end.
2415 row = [table numberOfRows];
2416 op = NSTableViewDropAbove;
2417 [table setDropRow:row dropOperation:op];
2420 // We don't ever want to drop onto a row, only between rows.
2421 if (op == NSTableViewDropOn)
2422 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2423 return NSTableViewDropAbove;
2426 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2427 row:(int)dropRow dropOperation:(NSTableViewDropOperation)op;
2429 NSPasteboard *pb = [info draggingPasteboard];
2430 NSDragOperation srcMask = [info draggingSourceOperationMask];
2437 // Intra-table drag - data is the array of rows.
2438 if (!accepted && (array =
2439 [pb propertyListForType:@"VLC media player module"]) != NULL)
2441 NSEnumerator *iter = nil;
2443 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2445 iter = [array objectEnumerator];
2446 while ((val = [iter nextObject]) != NULL)
2448 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2449 [val intValue]] mutableCopyWithZone:nil];
2450 [o_modulearray removeObject:o_tmp];
2451 [o_modulearray insertObject:o_tmp
2452 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2456 // Select the newly-dragged items.
2457 iter = [array objectEnumerator];
2459 [table deselectAll:self];
2461 [self tableChanged:self];
2462 [table setNeedsDisplay:YES];
2463 // Indicate that we finished the drag.
2467 [table setNeedsDisplay:YES];
2471 // An exception occurred. Uh-oh. Update the track table so that
2472 // it stays consistent, and re-raise the exception.
2474 [localException raise];
2475 [table setNeedsDisplay:YES];
2481 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
2483 return [o_modulearray count];
2486 - (id)tableView:(NSTableView *)aTableView
2487 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2489 if( [[aTableColumn identifier] isEqualToString:
2490 [NSString stringWithCString:"Enabled"]] )
2491 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2492 if( [[aTableColumn identifier] isEqualToString:
2493 [NSString stringWithCString:"Module"]] )
2494 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2499 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2500 forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2502 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2503 withObject: anObject];