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
42 #define RIGHTMARGIN 18
44 #define UPWARDS_WHITE_ARROW "\xE2\x87\xA7"
45 #define OPTION_KEY "\xE2\x8C\xA5"
46 #define UP_ARROWHEAD "\xE2\x8C\x83"
47 #define PLACE_OF_INTEREST_SIGN "\xE2\x8C\x98"
49 #define POPULATE_A_KEY( o_menu, string, value ) \
53 o_mi = [[NSMenuItem alloc] initWithTitle:string \
54 action:nil keyEquivalent:@""]; \
55 [o_mi setKeyEquivalentModifierMask: \
57 [o_mi setAlternate: NO]; \
60 [o_menu addItem: o_mi]; \
61 if( MACOS_VERSION >= 10.3 ) \
64 o_mi = [[NSMenuItem alloc] initWithTitle: \
65 [[NSString stringWithUTF8String: \
67 ] stringByAppendingString: string] \
68 action:nil keyEquivalent:@""]; \
69 [o_mi setKeyEquivalentModifierMask: \
71 [o_mi setAlternate: YES]; \
73 KEY_MODIFIER_CTRL | ( value )]; \
74 [o_menu addItem: o_mi]; \
76 o_mi = [[NSMenuItem alloc] initWithTitle: \
77 [[NSString stringWithUTF8String: \
78 UP_ARROWHEAD OPTION_KEY \
79 ] stringByAppendingString: string] \
80 action:nil keyEquivalent:@""]; \
81 [o_mi setKeyEquivalentModifierMask: \
82 NSControlKeyMask | NSAlternateKeyMask]; \
83 [o_mi setAlternate: YES]; \
85 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | ( value )]; \
86 [o_menu addItem: o_mi]; \
88 o_mi = [[NSMenuItem alloc] initWithTitle: \
89 [[NSString stringWithUTF8String: \
90 UP_ARROWHEAD UPWARDS_WHITE_ARROW \
91 ] stringByAppendingString: string] \
92 action:nil keyEquivalent:@""]; \
93 [o_mi setKeyEquivalentModifierMask: \
94 NSControlKeyMask | NSShiftKeyMask]; \
95 [o_mi setAlternate: YES]; \
97 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | ( value )]; \
98 [o_menu addItem: o_mi]; \
100 o_mi = [[NSMenuItem alloc] initWithTitle: \
101 [[NSString stringWithUTF8String: \
102 UP_ARROWHEAD PLACE_OF_INTEREST_SIGN \
103 ] stringByAppendingString: string] \
104 action:nil keyEquivalent:@""]; \
105 [o_mi setKeyEquivalentModifierMask: \
106 NSControlKeyMask | NSCommandKeyMask]; \
107 [o_mi setAlternate: YES]; \
109 (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | ( value )]; \
110 [o_menu addItem: o_mi]; \
111 /* Ctrl+Alt+Shift */ \
112 o_mi = [[NSMenuItem alloc] initWithTitle: \
113 [[NSString stringWithUTF8String: \
114 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
115 ] stringByAppendingString: string] \
116 action:nil keyEquivalent:@""]; \
117 [o_mi setKeyEquivalentModifierMask: \
118 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
119 [o_mi setAlternate: YES]; \
121 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | \
123 [o_menu addItem: o_mi]; \
124 /* Ctrl+Alt+Apple */ \
125 o_mi = [[NSMenuItem alloc] initWithTitle: \
126 [[NSString stringWithUTF8String: \
127 UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN \
128 ] stringByAppendingString: string] \
129 action:nil keyEquivalent:@""]; \
130 [o_mi setKeyEquivalentModifierMask: \
131 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
132 [o_mi setAlternate: YES]; \
134 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
136 [o_menu addItem: o_mi]; \
137 /* Ctrl+Shift+Apple */ \
138 o_mi = [[NSMenuItem alloc] initWithTitle: \
139 [[NSString stringWithUTF8String: \
140 UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
141 ] stringByAppendingString: string] \
142 action:nil keyEquivalent:@""]; \
143 [o_mi setKeyEquivalentModifierMask: \
144 NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
145 [o_mi setAlternate: YES]; \
147 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
149 [o_menu addItem: o_mi]; \
150 /* Ctrl+Alt+Shift+Apple */ \
151 o_mi = [[NSMenuItem alloc] initWithTitle: \
152 [[NSString stringWithUTF8String: \
153 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
154 PLACE_OF_INTEREST_SIGN \
155 ] stringByAppendingString: string] \
156 action:nil keyEquivalent:@""]; \
157 [o_mi setKeyEquivalentModifierMask: \
158 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
160 [o_mi setAlternate: YES]; \
162 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
163 KEY_MODIFIER_COMMAND) | ( value )]; \
164 [o_menu addItem: o_mi]; \
166 o_mi = [[NSMenuItem alloc] initWithTitle: \
167 [[NSString stringWithUTF8String: \
169 ] stringByAppendingString: string] \
170 action:nil keyEquivalent:@""]; \
171 [o_mi setKeyEquivalentModifierMask: \
172 NSAlternateKeyMask]; \
173 [o_mi setAlternate: YES]; \
175 KEY_MODIFIER_ALT | ( value )]; \
176 [o_menu addItem: o_mi]; \
178 o_mi = [[NSMenuItem alloc] initWithTitle: \
179 [[NSString stringWithUTF8String: \
180 OPTION_KEY UPWARDS_WHITE_ARROW \
181 ] stringByAppendingString: string] \
182 action:nil keyEquivalent:@""]; \
183 [o_mi setKeyEquivalentModifierMask: \
184 NSAlternateKeyMask | NSShiftKeyMask]; \
185 [o_mi setAlternate: YES]; \
187 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )]; \
188 [o_menu addItem: o_mi]; \
190 o_mi = [[NSMenuItem alloc] initWithTitle: \
191 [[NSString stringWithUTF8String: \
192 OPTION_KEY PLACE_OF_INTEREST_SIGN \
193 ] stringByAppendingString: string] \
194 action:nil keyEquivalent:@""]; \
195 [o_mi setKeyEquivalentModifierMask: \
196 NSAlternateKeyMask | NSCommandKeyMask]; \
197 [o_mi setAlternate: YES]; \
199 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )]; \
200 [o_menu addItem: o_mi]; \
201 /* Alt+Shift+Apple */ \
202 o_mi = [[NSMenuItem alloc] initWithTitle: \
203 [[NSString stringWithUTF8String: \
204 OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
205 ] stringByAppendingString: string] \
206 action:nil keyEquivalent:@""]; \
207 [o_mi setKeyEquivalentModifierMask: \
208 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
209 [o_mi setAlternate: YES]; \
211 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
213 [o_menu addItem: o_mi]; \
215 o_mi = [[NSMenuItem alloc] initWithTitle: \
216 [[NSString stringWithUTF8String: \
217 UPWARDS_WHITE_ARROW \
218 ] stringByAppendingString: string] \
219 action:nil keyEquivalent:@""]; \
220 [o_mi setKeyEquivalentModifierMask: \
222 [o_mi setAlternate: YES]; \
224 KEY_MODIFIER_SHIFT | ( value )]; \
225 [o_menu addItem: o_mi]; \
227 o_mi = [[NSMenuItem alloc] initWithTitle: \
228 [[NSString stringWithUTF8String: \
229 UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
230 ] stringByAppendingString: string] \
231 action:nil keyEquivalent:@""]; \
232 [o_mi setKeyEquivalentModifierMask: \
233 NSShiftKeyMask | NSCommandKeyMask]; \
234 [o_mi setAlternate: YES]; \
236 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \
237 [o_menu addItem: o_mi]; \
239 o_mi = [[NSMenuItem alloc] initWithTitle: \
240 [[NSString stringWithUTF8String: \
241 PLACE_OF_INTEREST_SIGN \
242 ] stringByAppendingString: string] \
243 action:nil keyEquivalent:@""]; \
244 [o_mi setKeyEquivalentModifierMask: \
246 [o_mi setAlternate: YES]; \
248 KEY_MODIFIER_COMMAND | ( value )]; \
249 [o_menu addItem: o_mi]; \
253 #define ADD_LABEL( o_label, superFrame, x_offset, my_y_offset, label ) \
255 NSRect s_rc = superFrame; \
256 s_rc.size.height = 17; \
257 s_rc.origin.x = x_offset - 3; \
258 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
259 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
260 [o_label setDrawsBackground: NO]; \
261 [o_label setBordered: NO]; \
262 [o_label setEditable: NO]; \
263 [o_label setSelectable: NO]; \
264 [o_label setStringValue: label]; \
265 [o_label setFont:[NSFont systemFontOfSize:0]]; \
266 [o_label sizeToFit]; \
269 #define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \
270 my_width, tooltip, init_value ) \
272 NSRect s_rc = superFrame; \
273 s_rc.origin.x = x_offset; \
274 s_rc.origin.y = my_y_offset; \
275 s_rc.size.height = 22; \
276 s_rc.size.width = my_width; \
277 o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
278 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
279 [o_textfield setToolTip: tooltip]; \
280 [o_textfield setStringValue: init_value]; \
283 #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
286 NSRect s_rc = superFrame; \
287 s_rc.origin.x = x_offset + 2; \
288 s_rc.origin.y = my_y_offset; \
289 s_rc.size.height = 26; \
290 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
292 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
293 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
294 [o_combo setToolTip: tooltip]; \
295 [o_combo setUsesDataSource:TRUE]; \
296 [o_combo setDataSource:self]; \
297 [o_combo setNumberOfVisibleItems:10]; \
298 [o_combo setCompletes:YES]; \
301 #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, \
304 NSRect s_rc = superFrame; \
305 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
306 [o_button setButtonType: NSMomentaryPushInButton]; \
307 [o_button setBezelStyle: NSRoundedBezelStyle]; \
308 [o_button setTitle: title]; \
309 [o_button setFont:[NSFont systemFontOfSize:0]]; \
310 [o_button sizeToFit]; \
311 s_rc = [o_button frame]; \
312 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
313 s_rc.origin.y = my_y_offset - 6; \
314 s_rc.size.width += 12; \
315 [o_button setFrame: s_rc]; \
316 [o_button setToolTip: tooltip]; \
317 [o_button setTarget: self]; \
318 [o_button setAction: @selector(openFileDialog:)]; \
321 #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
324 NSRect s_rc = superFrame; \
325 s_rc.origin.x = x_offset - 1; \
326 s_rc.origin.y = my_y_offset; \
327 s_rc.size.height = 26; \
328 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
330 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
331 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
332 [o_popup setToolTip: tooltip]; \
335 #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
338 NSRect s_rc = superFrame; \
339 s_rc.origin.x = x_offset; \
340 s_rc.origin.y = my_y_offset; \
341 s_rc.size.height = 23; \
342 s_rc.size.width = 23; \
343 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
344 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
345 [o_stepper setToolTip: tooltip]; \
346 [o_stepper setMaxValue: higher]; \
347 [o_stepper setMinValue: lower]; \
348 [o_stepper setTarget: self]; \
349 [o_stepper setAction: @selector(stepperChanged:)]; \
350 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
351 NSLeftMouseDraggedMask]; \
354 #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, \
355 tooltip, lower, higher ) \
357 NSRect s_rc = superFrame; \
358 s_rc.origin.x = x_offset; \
359 s_rc.origin.y = my_y_offset; \
360 s_rc.size.height = 21; \
361 s_rc.size.width = my_width; \
362 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
363 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
364 [o_slider setToolTip: tooltip]; \
365 [o_slider setMaxValue: higher]; \
366 [o_slider setMinValue: lower]; \
369 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
370 tooltip, init_value, position ) \
372 NSRect s_rc = superFrame; \
373 s_rc.size.height = 18; \
374 s_rc.origin.x = x_offset - 2; \
375 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
376 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
377 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
378 [o_checkbox setButtonType: NSSwitchButton]; \
379 [o_checkbox setImagePosition: position]; \
380 [o_checkbox setIntValue: init_value]; \
381 [o_checkbox setTitle: label]; \
382 [o_checkbox setToolTip: tooltip]; \
383 [o_checkbox sizeToFit]; \
386 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
387 tooltip, init_value, position ) \
389 NSRect s_rc = superFrame; \
390 s_rc.size.height = 18; \
391 s_rc.origin.x = x_offset - 2; \
392 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
393 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
394 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
395 [o_checkbox setButtonType: NSSwitchButton]; \
396 [o_checkbox setImagePosition: position]; \
397 [o_checkbox setIntValue: init_value]; \
398 [o_checkbox setTitle: label]; \
399 [o_checkbox setToolTip: tooltip]; \
400 [o_checkbox sizeToFit]; \
403 @implementation VLCConfigControl
404 - (id)initWithFrame: (NSRect)frame
406 return [self initWithFrame: frame
410 - (id)initWithFrame: (NSRect)frame
411 item: (module_config_t *)_p_item
413 self = [super initWithFrame: frame];
418 psz_name = strdup( p_item->psz_name );
420 i_type = p_item->i_type;
422 b_advanced = p_item->b_advanced;
423 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
428 - (void)setYPos:(int)i_yPos
430 NSRect frame = [self frame];
431 frame.origin.y = i_yPos;
432 [self setFrame:frame];
437 if( o_label ) [o_label release];
438 if( psz_name ) free( psz_name );
442 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
447 case CONFIG_ITEM_STRING:
450 case CONFIG_ITEM_STRING:
453 case CONFIG_ITEM_STRING_LIST:
456 case CONFIG_ITEM_FILE:
459 case CONFIG_ITEM_MODULE:
462 case CONFIG_ITEM_INTEGER:
465 case CONFIG_ITEM_RANGED_INTEGER:
468 case CONFIG_ITEM_BOOL:
471 case CONFIG_ITEM_KEY_BEFORE_10_3:
474 case CONFIG_ITEM_KEY_AFTER_10_3:
477 case CONFIG_ITEM_MODULE_LIST:
485 case CONFIG_ITEM_STRING_LIST:
488 case CONFIG_ITEM_STRING:
491 case CONFIG_ITEM_STRING_LIST:
494 case CONFIG_ITEM_FILE:
497 case CONFIG_ITEM_MODULE:
500 case CONFIG_ITEM_INTEGER:
503 case CONFIG_ITEM_RANGED_INTEGER:
506 case CONFIG_ITEM_BOOL:
509 case CONFIG_ITEM_KEY_BEFORE_10_3:
512 case CONFIG_ITEM_KEY_AFTER_10_3:
515 case CONFIG_ITEM_MODULE_LIST:
523 case CONFIG_ITEM_FILE:
526 case CONFIG_ITEM_STRING:
529 case CONFIG_ITEM_STRING_LIST:
532 case CONFIG_ITEM_FILE:
535 case CONFIG_ITEM_MODULE:
538 case CONFIG_ITEM_INTEGER:
541 case CONFIG_ITEM_RANGED_INTEGER:
544 case CONFIG_ITEM_BOOL:
547 case CONFIG_ITEM_KEY_BEFORE_10_3:
550 case CONFIG_ITEM_KEY_AFTER_10_3:
553 case CONFIG_ITEM_MODULE_LIST:
561 case CONFIG_ITEM_MODULE:
564 case CONFIG_ITEM_STRING:
567 case CONFIG_ITEM_STRING_LIST:
570 case CONFIG_ITEM_FILE:
573 case CONFIG_ITEM_MODULE:
576 case CONFIG_ITEM_INTEGER:
579 case CONFIG_ITEM_RANGED_INTEGER:
582 case CONFIG_ITEM_BOOL:
585 case CONFIG_ITEM_KEY_BEFORE_10_3:
588 case CONFIG_ITEM_KEY_AFTER_10_3:
591 case CONFIG_ITEM_MODULE_LIST:
599 case CONFIG_ITEM_INTEGER:
602 case CONFIG_ITEM_STRING:
605 case CONFIG_ITEM_STRING_LIST:
608 case CONFIG_ITEM_FILE:
611 case CONFIG_ITEM_MODULE:
614 case CONFIG_ITEM_INTEGER:
617 case CONFIG_ITEM_RANGED_INTEGER:
620 case CONFIG_ITEM_BOOL:
623 case CONFIG_ITEM_KEY_BEFORE_10_3:
626 case CONFIG_ITEM_KEY_AFTER_10_3:
629 case CONFIG_ITEM_MODULE_LIST:
637 case CONFIG_ITEM_RANGED_INTEGER:
640 case CONFIG_ITEM_STRING:
643 case CONFIG_ITEM_STRING_LIST:
646 case CONFIG_ITEM_FILE:
649 case CONFIG_ITEM_MODULE:
652 case CONFIG_ITEM_INTEGER:
655 case CONFIG_ITEM_RANGED_INTEGER:
658 case CONFIG_ITEM_BOOL:
661 case CONFIG_ITEM_KEY_BEFORE_10_3:
664 case CONFIG_ITEM_KEY_AFTER_10_3:
667 case CONFIG_ITEM_MODULE_LIST:
675 case CONFIG_ITEM_BOOL:
678 case CONFIG_ITEM_STRING:
681 case CONFIG_ITEM_STRING_LIST:
684 case CONFIG_ITEM_FILE:
687 case CONFIG_ITEM_MODULE:
690 case CONFIG_ITEM_INTEGER:
693 case CONFIG_ITEM_RANGED_INTEGER:
696 case CONFIG_ITEM_BOOL:
699 case CONFIG_ITEM_KEY_BEFORE_10_3:
702 case CONFIG_ITEM_KEY_AFTER_10_3:
705 case CONFIG_ITEM_MODULE_LIST:
713 case CONFIG_ITEM_KEY_BEFORE_10_3:
716 case CONFIG_ITEM_STRING:
719 case CONFIG_ITEM_STRING_LIST:
722 case CONFIG_ITEM_FILE:
725 case CONFIG_ITEM_MODULE:
728 case CONFIG_ITEM_INTEGER:
731 case CONFIG_ITEM_RANGED_INTEGER:
734 case CONFIG_ITEM_BOOL:
737 case CONFIG_ITEM_KEY_BEFORE_10_3:
740 case CONFIG_ITEM_KEY_AFTER_10_3:
743 case CONFIG_ITEM_MODULE_LIST:
751 case CONFIG_ITEM_KEY_AFTER_10_3:
754 case CONFIG_ITEM_STRING:
757 case CONFIG_ITEM_STRING_LIST:
760 case CONFIG_ITEM_FILE:
763 case CONFIG_ITEM_MODULE:
766 case CONFIG_ITEM_INTEGER:
769 case CONFIG_ITEM_RANGED_INTEGER:
772 case CONFIG_ITEM_BOOL:
775 case CONFIG_ITEM_KEY_BEFORE_10_3:
778 case CONFIG_ITEM_KEY_AFTER_10_3:
781 case CONFIG_ITEM_MODULE_LIST:
789 case CONFIG_ITEM_MODULE_LIST:
792 case CONFIG_ITEM_STRING:
795 case CONFIG_ITEM_STRING_LIST:
798 case CONFIG_ITEM_FILE:
801 case CONFIG_ITEM_MODULE:
804 case CONFIG_ITEM_INTEGER:
807 case CONFIG_ITEM_RANGED_INTEGER:
810 case CONFIG_ITEM_BOOL:
813 case CONFIG_ITEM_KEY_BEFORE_10_3:
816 case CONFIG_ITEM_KEY_AFTER_10_3:
819 case CONFIG_ITEM_MODULE_LIST:
834 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
835 withView: (NSView *)o_parent_view
838 VLCConfigControl *p_control = NULL;
839 switch( _p_item->i_type )
841 case CONFIG_ITEM_STRING:
842 if( !_p_item->i_list )
844 p_control = [[StringConfigControl alloc]
845 initWithItem: _p_item
846 withView: o_parent_view
847 withVerticalOffset: i_yPos];
851 p_control = [[StringListConfigControl alloc]
852 initWithItem: _p_item
853 withView: o_parent_view
854 withVerticalOffset: i_yPos];
857 case CONFIG_ITEM_FILE:
858 case CONFIG_ITEM_DIRECTORY:
859 p_control = [[FileConfigControl alloc]
860 initWithItem: _p_item
861 withView: o_parent_view
862 withVerticalOffset: i_yPos];
864 case CONFIG_ITEM_MODULE:
865 case CONFIG_ITEM_MODULE_CAT:
866 p_control = [[ModuleConfigControl alloc]
867 initWithItem: _p_item
868 withView: o_parent_view
869 withVerticalOffset: i_yPos];
871 case CONFIG_ITEM_INTEGER:
872 if( _p_item->i_list )
874 p_control = [[IntegerListConfigControl alloc]
875 initWithItem: _p_item
876 withView: o_parent_view
877 withVerticalOffset: i_yPos];
879 else if( _p_item->i_min != 0 || _p_item->i_max != 0 )
881 p_control = [[RangedIntegerConfigControl alloc]
882 initWithItem: _p_item
883 withView: o_parent_view
884 withVerticalOffset: i_yPos];
888 p_control = [[IntegerConfigControl alloc]
889 initWithItem: _p_item
890 withView: o_parent_view
891 withVerticalOffset: i_yPos];
894 case CONFIG_ITEM_BOOL:
895 p_control = [[BoolConfigControl alloc]
896 initWithItem: _p_item
897 withView: o_parent_view
898 withVerticalOffset: i_yPos];
900 case CONFIG_ITEM_FLOAT:
901 if( _p_item->f_min != 0 || _p_item->f_max != 0 )
903 p_control = [[RangedFloatConfigControl alloc]
904 initWithItem: _p_item
905 withView: o_parent_view
906 withVerticalOffset: i_yPos];
910 p_control = [[FloatConfigControl alloc]
911 initWithItem: _p_item
912 withView: o_parent_view
913 withVerticalOffset: i_yPos];
916 case CONFIG_ITEM_KEY:
917 if( MACOS_VERSION < 10.3 )
919 p_control = [[KeyConfigControlBefore103 alloc]
920 initWithItem: _p_item
921 withView: o_parent_view
922 withVerticalOffset: i_yPos];
926 p_control = [[KeyConfigControlAfter103 alloc]
927 initWithItem: _p_item
928 withView: o_parent_view
929 withVerticalOffset: i_yPos];
932 case CONFIG_ITEM_MODULE_LIST:
933 case CONFIG_ITEM_MODULE_LIST_CAT:
934 p_control = [[ModuleListConfigControl alloc]
935 initWithItem: _p_item
936 withView: o_parent_view
937 withVerticalOffset: i_yPos];
945 - (NSString *)getName
947 return [[VLCMain sharedInstance] localizedString: psz_name];
975 - (char *)stringValue
983 switch( p_item->i_type )
985 case CONFIG_ITEM_STRING:
986 case CONFIG_ITEM_FILE:
987 case CONFIG_ITEM_DIRECTORY:
988 case CONFIG_ITEM_MODULE:
989 case CONFIG_ITEM_MODULE_LIST:
990 case CONFIG_ITEM_MODULE_LIST_CAT:
991 fprintf( stderr, "Applying %s to %s\n" , [self stringValue], psz_name );
992 config_PutPsz( VLCIntf, psz_name, [self stringValue] );
994 case CONFIG_ITEM_KEY:
995 /* So you don't need to restart to have the changes take effect */
996 fprintf( stderr, "Applying %d to %s\n" , [self intValue], psz_name );
997 val.i_int = [self intValue];
998 var_Set( VLCIntf->p_vlc, psz_name, val );
999 case CONFIG_ITEM_INTEGER:
1000 case CONFIG_ITEM_BOOL:
1001 fprintf( stderr, "Applying %d to %s\n" , [self intValue], psz_name );
1002 config_PutInt( VLCIntf, psz_name, [self intValue] );
1004 case CONFIG_ITEM_FLOAT:
1005 fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
1006 config_PutFloat( VLCIntf, psz_name, [self floatValue] );
1012 @implementation StringConfigControl
1013 - (id) initWithItem: (module_config_t *)_p_item
1014 withView: (NSView *)o_parent_view
1015 withVerticalOffset: (int)i_yPos
1017 NSRect mainFrame = [o_parent_view frame];
1018 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
1019 mainFrame.size.height = 22;
1020 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1021 mainFrame.origin.x = LEFTMARGIN;
1022 mainFrame.origin.y = i_yPos;
1024 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1026 i_view_type = CONFIG_ITEM_STRING;
1028 if( p_item->psz_text )
1029 o_labelString = [[VLCMain sharedInstance]
1030 localizedString: p_item->psz_text];
1032 o_labelString = [NSString stringWithString:@""];
1033 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1034 [o_label setAutoresizingMask:NSViewNotSizable ];
1035 [self addSubview: o_label];
1037 /* build the textfield */
1038 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1039 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext]
1040 toWidth: PREFS_WRAP];
1041 if( p_item->psz_value )
1042 o_textfieldString = [[VLCMain sharedInstance]
1043 localizedString: p_item->psz_value];
1045 o_textfieldString = [NSString stringWithString: @""];
1046 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1047 0, mainFrame.size.width - [o_label frame].size.width -
1048 2, o_textfieldTooltip, o_textfieldString )
1049 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1050 [self addSubview: o_textfield];
1058 [o_textfield release];
1062 - (char *)stringValue
1064 return strdup( [[VLCMain sharedInstance] delocalizeString:
1065 [o_textfield stringValue]] );
1069 @implementation StringListConfigControl
1070 - (id) initWithItem: (module_config_t *)_p_item
1071 withView: (NSView *)o_parent_view
1072 withVerticalOffset: (int)i_yPos
1074 NSRect mainFrame = [o_parent_view frame];
1075 NSString *o_labelString, *o_textfieldTooltip;
1076 mainFrame.size.height = 22;
1077 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1078 mainFrame.origin.x = LEFTMARGIN;
1079 mainFrame.origin.y = i_yPos;
1081 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1084 i_view_type = CONFIG_ITEM_STRING_LIST;
1086 if( p_item->psz_text )
1087 o_labelString = [[VLCMain sharedInstance]
1088 localizedString: p_item->psz_text];
1090 o_labelString = [NSString stringWithString:@""];
1091 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1092 [o_label setAutoresizingMask:NSViewNotSizable ];
1093 [self addSubview: o_label];
1095 /* build the textfield */
1096 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1097 [[VLCMain sharedInstance]
1098 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1099 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1100 -2, 0, o_textfieldTooltip )
1101 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1102 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1103 if( p_item->psz_value &&
1104 !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) )
1105 [o_combo selectItemAtIndex: i_index];
1106 [self addSubview: o_combo];
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
1147 withVerticalOffset: (int)i_yPos
1149 NSRect mainFrame = [o_parent_view frame];
1150 NSString *o_labelString, *o_buttonTooltip, *o_textfieldString;
1151 NSString *o_textfieldTooltip;
1152 mainFrame.size.height = 46;
1153 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1154 mainFrame.origin.x = LEFTMARGIN;
1155 mainFrame.origin.y = i_yPos;
1157 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1159 i_view_type = CONFIG_ITEM_FILE;
1161 /* is it a directory */
1162 b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
1165 if( p_item->psz_text )
1166 o_labelString = [[VLCMain sharedInstance]
1167 localizedString: p_item->psz_text];
1169 o_labelString = [NSString stringWithString:@""];
1170 ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString )
1171 [o_label setAutoresizingMask:NSViewNotSizable ];
1172 [self addSubview: o_label];
1174 /* build the button */
1175 o_buttonTooltip = [[VLCMain sharedInstance]
1176 wrapString: [[VLCMain sharedInstance]
1177 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1178 ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_buttonTooltip,
1180 [o_button setAutoresizingMask:NSViewMinXMargin ];
1181 [self addSubview: o_button];
1183 /* build the textfield */
1184 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1185 [[VLCMain sharedInstance]
1186 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1187 if( p_item->psz_value )
1188 o_textfieldString = [[VLCMain sharedInstance]
1189 localizedString: p_item->psz_value];
1191 o_textfieldString = [NSString stringWithString: @""];
1192 ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1193 8 - [o_button frame].size.width,
1194 o_textfieldTooltip, o_textfieldString )
1195 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1196 [self addSubview: o_textfield];
1203 [o_textfield release];
1208 - (IBAction)openFileDialog: (id)sender
1210 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1212 [o_open_panel setTitle: (b_directory)?
1213 _NS("Select a directory"):_NS("Select a file")];
1214 [o_open_panel setPrompt: _NS("Select")];
1215 [o_open_panel setAllowsMultipleSelection: NO];
1216 [o_open_panel setCanChooseFiles: !b_directory];
1217 [o_open_panel setCanChooseDirectories: b_directory];
1218 [o_open_panel beginSheetForDirectory:nil
1221 modalForWindow:[sender window]
1223 didEndSelector: @selector(pathChosenInPanel:
1229 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
1230 withReturn:(int)i_return_code contextInfo:(void *)o_context_info
1232 if( i_return_code == NSOKButton )
1234 NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
1235 [o_textfield setStringValue: o_path];
1239 - (char *)stringValue
1241 if( [[o_textfield stringValue] length] != 0)
1242 return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
1248 @implementation ModuleConfigControl
1249 - (id) initWithItem: (module_config_t *)_p_item
1250 withView: (NSView *)o_parent_view
1251 withVerticalOffset: (int)i_yPos
1253 NSRect mainFrame = [o_parent_view frame];
1254 NSString *o_labelString, *o_popupTooltip;
1255 mainFrame.size.height = 22;
1256 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1257 mainFrame.origin.x = LEFTMARGIN;
1258 mainFrame.origin.y = i_yPos;
1260 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1265 i_view_type = CONFIG_ITEM_MODULE;
1268 if( p_item->psz_text )
1269 o_labelString = [[VLCMain sharedInstance]
1270 localizedString: p_item->psz_text];
1272 o_labelString = [NSString stringWithString:@""];
1273 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
1274 [o_label setAutoresizingMask:NSViewNotSizable ];
1275 [self addSubview: o_label];
1277 /* build the popup */
1278 o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1279 [[VLCMain sharedInstance]
1280 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1281 ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
1282 -2, 0, o_popupTooltip )
1283 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1284 [o_popup addItemWithTitle: _NS("Default")];
1285 [[o_popup lastItem] setTag: -1];
1286 [o_popup selectItem: [o_popup lastItem]];
1288 /* build a list of available modules */
1289 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1290 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1292 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
1293 if( p_item->i_type == CONFIG_ITEM_MODULE )
1295 if( !strcmp( p_parser->psz_capability,
1296 p_item->psz_type ) )
1298 NSString *o_description = [[VLCMain sharedInstance]
1299 localizedString: p_parser->psz_longname];
1300 [o_popup addItemWithTitle: o_description];
1302 if( p_item->psz_value &&
1303 !strcmp( p_item->psz_value, p_parser->psz_object_name ) )
1304 [o_popup selectItem:[o_popup lastItem]];
1309 module_config_t *p_config;
1310 if( !strcmp( p_parser->psz_object_name, "main" ) )
1313 p_config = p_parser->p_config;
1316 /* Hack: required subcategory is stored in i_min */
1317 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1318 p_config->i_value == p_item->i_min )
1320 NSString *o_description = [[VLCMain sharedInstance]
1321 localizedString: p_parser->psz_longname];
1322 [o_popup addItemWithTitle: o_description];
1324 if( p_item->psz_value && !strcmp(p_item->psz_value,
1325 p_parser->psz_object_name) )
1326 [o_popup selectItem:[o_popup lastItem]];
1328 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
1331 vlc_list_release( p_list );
1332 [self addSubview: o_popup];
1343 - (char *)stringValue
1345 NSString *newval = [o_popup titleOfSelectedItem];
1346 char *returnval = NULL;
1351 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1352 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1354 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
1355 if( p_item->i_type == CONFIG_ITEM_MODULE )
1357 if( !strcmp( p_parser->psz_capability,
1358 p_item->psz_type ) )
1360 NSString *o_description = [[VLCMain sharedInstance]
1361 localizedString: p_parser->psz_longname];
1362 if( [newval isEqualToString: o_description] )
1364 returnval = strdup(p_parser->psz_object_name);
1371 module_config_t *p_config;
1372 if( !strcmp( p_parser->psz_object_name, "main" ) )
1375 p_config = p_parser->p_config;
1378 /* Hack: required subcategory is stored in i_min */
1379 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1380 p_config->i_value == p_item->i_min )
1382 NSString *o_description = [[VLCMain sharedInstance]
1383 localizedString: p_parser->psz_longname];
1384 if( [newval isEqualToString: o_description] )
1386 returnval = strdup(p_parser->psz_object_name);
1390 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
1393 vlc_list_release( p_list );
1398 @implementation IntegerConfigControl
1399 - (id) initWithItem: (module_config_t *)_p_item
1400 withView: (NSView *)o_parent_view
1401 withVerticalOffset: (int)i_yPos
1403 NSRect mainFrame = [o_parent_view frame];
1404 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1405 mainFrame.size.height = 23;
1406 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1407 mainFrame.origin.x = LEFTMARGIN;
1408 mainFrame.origin.y = i_yPos;
1410 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1412 i_view_type = CONFIG_ITEM_INTEGER;
1414 o_tooltip = [[VLCMain sharedInstance] wrapString:
1415 [[VLCMain sharedInstance]
1416 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1419 if( p_item->psz_text )
1420 o_labelString = [[VLCMain sharedInstance]
1421 localizedString: p_item->psz_text];
1423 o_labelString = [NSString stringWithString:@""];
1424 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
1425 [o_label setAutoresizingMask:NSViewNotSizable ];
1426 [self addSubview: o_label];
1428 /* build the stepper */
1429 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1430 0, o_tooltip, -1600, 1600)
1431 [o_stepper setIntValue: p_item->i_value];
1432 [o_stepper setAutoresizingMask:NSViewMinXMargin ];
1433 [self addSubview: o_stepper];
1435 /* build the textfield */
1436 if( p_item->psz_value )
1437 o_textfieldString = [[VLCMain sharedInstance]
1438 localizedString: p_item->psz_value];
1440 o_textfieldString = [NSString stringWithString: @""];
1441 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1442 1, 49, o_tooltip, @"" )
1443 [o_textfield setIntValue: p_item->i_value];
1444 [o_textfield setDelegate: self];
1445 [[NSNotificationCenter defaultCenter] addObserver: self
1446 selector: @selector(textfieldChanged:)
1447 name: NSControlTextDidChangeNotification
1448 object: o_textfield];
1449 [o_textfield setAutoresizingMask:NSViewMinXMargin ];
1450 [self addSubview: o_textfield];
1457 [o_stepper release];
1458 [o_textfield release];
1462 - (IBAction)stepperChanged:(id)sender
1464 [o_textfield setIntValue: [o_stepper intValue]];
1467 - (void)textfieldChanged:(NSNotification *)o_notification
1469 [o_stepper setIntValue: [o_textfield intValue]];
1474 return [o_textfield intValue];
1479 @implementation IntegerListConfigControl
1481 - (id) initWithItem: (module_config_t *)_p_item
1482 withView: (NSView *)o_parent_view
1483 withVerticalOffset: (int)i_yPos
1485 NSRect mainFrame = [o_parent_view frame];
1486 NSString *o_labelString, *o_textfieldTooltip;
1487 mainFrame.size.height = 22;
1488 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1489 mainFrame.origin.x = LEFTMARGIN;
1490 mainFrame.origin.y = i_yPos;
1492 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1495 i_view_type = CONFIG_ITEM_STRING_LIST;
1498 if( p_item->psz_text )
1499 o_labelString = [[VLCMain sharedInstance]
1500 localizedString: p_item->psz_text];
1502 o_labelString = [NSString stringWithString:@""];
1503 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1504 [o_label setAutoresizingMask:NSViewNotSizable ];
1505 [self addSubview: o_label];
1507 /* build the textfield */
1508 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1509 [[VLCMain sharedInstance]
1510 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1511 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1512 -2, 0, o_textfieldTooltip )
1513 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1514 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1516 if( p_item->i_value == p_item->pi_list[i_index] )
1518 [o_combo selectItemAtIndex: i_index];
1521 [self addSubview: o_combo];
1534 if( [o_combo indexOfSelectedItem] >= 0 )
1535 return p_item->pi_list[[o_combo indexOfSelectedItem]];
1537 return [o_combo intValue];
1541 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1542 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1544 return p_item->i_list;
1547 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1549 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1550 return [[VLCMain sharedInstance]
1551 localizedString: p_item->ppsz_list_text[i_index]];
1553 return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1557 @implementation RangedIntegerConfigControl
1558 - (id) initWithItem: (module_config_t *)_p_item
1559 withView: (NSView *)o_parent_view
1560 withVerticalOffset: (int)i_yPos
1562 NSRect mainFrame = [o_parent_view frame];
1563 NSString *o_labelString, *o_tooltip;
1564 mainFrame.size.height = 50;
1565 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1566 mainFrame.origin.x = LEFTMARGIN;
1567 mainFrame.origin.y = i_yPos;
1569 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1571 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1574 if( p_item->psz_text )
1575 o_labelString = [[VLCMain sharedInstance]
1576 localizedString: p_item->psz_text];
1578 o_labelString = [NSString stringWithString:@""];
1579 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1580 [o_label setAutoresizingMask:NSViewNotSizable ];
1581 [self addSubview: o_label];
1583 /* build the textfield */
1584 o_tooltip = [[VLCMain sharedInstance] wrapString:
1585 [[VLCMain sharedInstance]
1586 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1587 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1588 28, 49, o_tooltip, @"" )
1589 [o_textfield setIntValue: p_item->i_value];
1590 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1591 [o_textfield setDelegate: self];
1592 [[NSNotificationCenter defaultCenter] addObserver: self
1593 selector: @selector(textfieldChanged:)
1594 name: NSControlTextDidChangeNotification
1595 object: o_textfield];
1596 [self addSubview: o_textfield];
1598 /* build the mintextfield */
1599 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1600 [o_textfield_min setIntValue: p_item->i_min];
1601 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1602 [self addSubview: o_textfield_min];
1604 /* build the maxtextfield */
1605 ADD_LABEL( o_textfield_max, mainFrame,
1606 mainFrame.size.width - 31, -30, @"8888" )
1607 [o_textfield_max setIntValue: p_item->i_max];
1608 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1609 [self addSubview: o_textfield_max];
1611 /* build the slider */
1612 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1613 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1614 [o_textfield_max frame].size.width -
1615 [o_textfield_max frame].size.width - 14 -
1616 [o_textfield_min frame].origin.x, o_tooltip,
1617 p_item->i_min, p_item->i_max )
1618 [o_slider setIntValue: p_item->i_value];
1619 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1620 [o_slider setTarget: self];
1621 [o_slider setAction: @selector(sliderChanged:)];
1622 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1623 NSLeftMouseDraggedMask];
1624 [self addSubview: o_slider];
1632 [o_textfield release];
1633 [o_textfield_min release];
1634 [o_textfield_max release];
1639 - (IBAction)sliderChanged:(id)sender
1641 [o_textfield setIntValue: [o_slider intValue]];
1644 - (void)textfieldChanged:(NSNotification *)o_notification
1646 [o_slider setIntValue: [o_textfield intValue]];
1651 return [o_slider intValue];
1655 @implementation FloatConfigControl
1656 - (id) initWithItem: (module_config_t *)_p_item
1657 withView: (NSView *)o_parent_view
1658 withVerticalOffset: (int)i_yPos
1660 NSRect mainFrame = [o_parent_view frame];
1661 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1662 mainFrame.size.height = 23;
1663 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1664 mainFrame.origin.x = LEFTMARGIN;
1665 mainFrame.origin.y = i_yPos;
1667 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1669 i_view_type = CONFIG_ITEM_INTEGER;
1671 o_tooltip = [[VLCMain sharedInstance] wrapString:
1672 [[VLCMain sharedInstance]
1673 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1676 if( p_item->psz_text )
1677 o_labelString = [[VLCMain sharedInstance]
1678 localizedString: p_item->psz_text];
1680 o_labelString = [NSString stringWithString:@""];
1681 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
1682 [o_label setAutoresizingMask:NSViewNotSizable ];
1683 [self addSubview: o_label];
1685 /* build the stepper */
1686 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1687 0, o_tooltip, -1600, 1600)
1688 [o_stepper setFloatValue: p_item->f_value];
1689 [o_stepper setAutoresizingMask:NSViewMinXMargin ];
1690 [self addSubview: o_stepper];
1692 /* build the textfield */
1693 if( p_item->psz_value )
1694 o_textfieldString = [[VLCMain sharedInstance]
1695 localizedString: p_item->psz_value];
1697 o_textfieldString = [NSString stringWithString: @""];
1698 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1699 1, 49, o_tooltip, @"" )
1700 [o_textfield setFloatValue: p_item->f_value];
1701 [o_textfield setDelegate: self];
1702 [[NSNotificationCenter defaultCenter] addObserver: self
1703 selector: @selector(textfieldChanged:)
1704 name: NSControlTextDidChangeNotification
1705 object: o_textfield];
1706 [o_textfield setAutoresizingMask:NSViewMinXMargin ];
1707 [self addSubview: o_textfield];
1714 [o_stepper release];
1715 [o_textfield release];
1719 - (IBAction)stepperChanged:(id)sender
1721 [o_textfield setFloatValue: [o_stepper floatValue]];
1724 - (void)textfieldChanged:(NSNotification *)o_notification
1726 [o_stepper setFloatValue: [o_textfield floatValue]];
1731 return [o_stepper floatValue];
1735 @implementation RangedFloatConfigControl
1736 - (id) initWithItem: (module_config_t *)_p_item
1737 withView: (NSView *)o_parent_view
1738 withVerticalOffset: (int)i_yPos
1740 NSRect mainFrame = [o_parent_view frame];
1741 NSString *o_labelString, *o_tooltip;
1742 mainFrame.size.height = 50;
1743 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1744 mainFrame.origin.x = LEFTMARGIN;
1745 mainFrame.origin.y = i_yPos;
1747 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1749 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1752 if( p_item->psz_text )
1753 o_labelString = [[VLCMain sharedInstance]
1754 localizedString: p_item->psz_text];
1756 o_labelString = [NSString stringWithString:@""];
1757 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1758 [o_label setAutoresizingMask:NSViewNotSizable ];
1759 [self addSubview: o_label];
1761 /* build the textfield */
1762 o_tooltip = [[VLCMain sharedInstance] wrapString:
1763 [[VLCMain sharedInstance]
1764 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1765 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1766 28, 49, o_tooltip, @"" )
1767 [o_textfield setFloatValue: p_item->f_value];
1768 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1769 [o_textfield setDelegate: self];
1770 [[NSNotificationCenter defaultCenter] addObserver: self
1771 selector: @selector(textfieldChanged:)
1772 name: NSControlTextDidChangeNotification
1773 object: o_textfield];
1774 [self addSubview: o_textfield];
1776 /* build the mintextfield */
1777 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1778 [o_textfield_min setFloatValue: p_item->f_min];
1779 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1780 [self addSubview: o_textfield_min];
1782 /* build the maxtextfield */
1783 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
1785 [o_textfield_max setFloatValue: p_item->f_max];
1786 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1787 [self addSubview: o_textfield_max];
1789 /* build the slider */
1790 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1791 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1792 [o_textfield_max frame].size.width -
1793 [o_textfield_max frame].size.width - 14 -
1794 [o_textfield_min frame].origin.x, o_tooltip, p_item->f_min,
1796 [o_slider setFloatValue: p_item->f_value];
1797 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1798 [o_slider setTarget: self];
1799 [o_slider setAction: @selector(sliderChanged:)];
1800 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1801 NSLeftMouseDraggedMask];
1802 [self addSubview: o_slider];
1810 [o_textfield release];
1811 [o_textfield_min release];
1812 [o_textfield_max release];
1817 - (IBAction)sliderChanged:(id)sender
1819 [o_textfield setFloatValue: [o_slider floatValue]];
1822 - (void)textfieldChanged:(NSNotification *)o_notification
1824 [o_slider setFloatValue: [o_textfield floatValue]];
1829 return [o_slider floatValue];
1834 @implementation BoolConfigControl
1836 - (id) initWithItem: (module_config_t *)_p_item
1837 withView: (NSView *)o_parent_view
1838 withVerticalOffset: (int)i_yPos
1840 NSRect mainFrame = [o_parent_view frame];
1841 NSString *o_labelString, *o_tooltip;
1842 mainFrame.size.height = 17;
1843 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1844 mainFrame.origin.x = LEFTMARGIN;
1845 mainFrame.origin.y = i_yPos;
1847 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1849 i_view_type = CONFIG_ITEM_BOOL;
1851 /* add the checkbox */
1852 if( p_item->psz_text )
1853 o_labelString = [[VLCMain sharedInstance]
1854 localizedString: p_item->psz_text];
1856 o_labelString = [NSString stringWithString:@""];
1857 o_tooltip = [[VLCMain sharedInstance]
1858 wrapString: [[VLCMain sharedInstance]
1859 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1860 ADD_CHECKBOX( o_checkbox, mainFrame, 0, 0, o_labelString,
1861 o_tooltip, p_item->i_value, NSImageRight)
1862 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1863 [self addSubview: o_checkbox];
1870 [o_checkbox release];
1876 return [o_checkbox intValue];
1881 @implementation KeyConfigControlBefore103
1883 - (id) initWithItem: (module_config_t *)_p_item
1884 withView: (NSView *)o_parent_view
1885 withVerticalOffset: (int)i_yPos
1887 NSRect mainFrame = [o_parent_view frame];
1888 NSString *o_labelString, *o_tooltip;
1889 mainFrame.size.height = 37;
1890 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1891 mainFrame.origin.x = LEFTMARGIN;
1892 mainFrame.origin.y = i_yPos;
1894 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1896 i_view_type = CONFIG_ITEM_KEY_BEFORE_10_3;
1899 if( p_item->psz_text )
1900 o_labelString = [[VLCMain sharedInstance]
1901 localizedString: p_item->psz_text];
1903 o_labelString = [NSString stringWithString:@""];
1904 ADD_LABEL( o_label, mainFrame, 0, -10, o_labelString )
1905 [o_label setAutoresizingMask:NSViewNotSizable ];
1906 [self addSubview: o_label];
1908 /* add the checkboxes */
1909 o_tooltip = [[VLCMain sharedInstance] wrapString:
1910 [[VLCMain sharedInstance]
1911 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1912 ADD_CHECKBOX( o_cmd_checkbox, mainFrame,
1913 [o_label frame].size.width + 2, 0,
1914 [NSString stringWithUTF8String:PLACE_OF_INTEREST_SIGN], o_tooltip,
1915 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_COMMAND)?YES:NO),
1917 [o_cmd_checkbox setState: p_item->i_value & KEY_MODIFIER_COMMAND];
1918 ADD_CHECKBOX( o_ctrl_checkbox, mainFrame,
1919 [o_cmd_checkbox frame].size.width +
1920 [o_cmd_checkbox frame].origin.x + 6, 0,
1921 [NSString stringWithUTF8String:UP_ARROWHEAD], o_tooltip,
1922 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_CTRL)?YES:NO),
1924 [o_ctrl_checkbox setState: p_item->i_value & KEY_MODIFIER_CTRL];
1925 ADD_CHECKBOX( o_alt_checkbox, mainFrame, [o_label frame].size.width +
1926 2, -2 - [o_cmd_checkbox frame].size.height,
1927 [NSString stringWithUTF8String:OPTION_KEY], o_tooltip,
1928 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_ALT)?YES:NO),
1930 [o_alt_checkbox setState: p_item->i_value & KEY_MODIFIER_ALT];
1931 ADD_CHECKBOX( o_shift_checkbox, mainFrame,
1932 [o_cmd_checkbox frame].size.width +
1933 [o_cmd_checkbox frame].origin.x + 6, -2 -
1934 [o_cmd_checkbox frame].size.height,
1935 [NSString stringWithUTF8String:UPWARDS_WHITE_ARROW], o_tooltip,
1936 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_SHIFT)?YES:NO),
1938 [o_shift_checkbox setState: p_item->i_value & KEY_MODIFIER_SHIFT];
1939 [self addSubview: o_cmd_checkbox];
1940 [self addSubview: o_ctrl_checkbox];
1941 [self addSubview: o_alt_checkbox];
1942 [self addSubview: o_shift_checkbox];
1944 /* build the popup */
1945 ADD_POPUP( o_popup, mainFrame, [o_shift_checkbox frame].origin.x +
1946 [o_shift_checkbox frame].size.width + 4,
1948 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1950 if( o_keys_menu == nil )
1953 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
1954 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
1955 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
1956 POPULATE_A_KEY( o_keys_menu,
1957 [NSString stringWithCString:vlc_keys[i].psz_key_string]
1958 , vlc_keys[i].i_key_code)
1960 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
1961 [o_popup selectItemWithTitle: [[VLCMain sharedInstance]
1962 localizedString:KeyToString(
1963 (((unsigned int)p_item->i_value) & ~KEY_MODIFIER ))]];
1964 [self addSubview: o_popup];
1971 [o_cmd_checkbox release];
1972 [o_ctrl_checkbox release];
1973 [o_alt_checkbox release];
1974 [o_shift_checkbox release];
1981 unsigned int i_new_key = 0;
1983 i_new_key |= ([o_cmd_checkbox state] == NSOnState) ?
1984 KEY_MODIFIER_COMMAND : 0;
1985 i_new_key |= ([o_ctrl_checkbox state] == NSOnState) ?
1986 KEY_MODIFIER_CTRL : 0;
1987 i_new_key |= ([o_alt_checkbox state] == NSOnState) ?
1988 KEY_MODIFIER_ALT : 0;
1989 i_new_key |= ([o_shift_checkbox state] == NSOnState) ?
1990 KEY_MODIFIER_SHIFT : 0;
1992 i_new_key |= StringToKey([[[o_popup selectedItem] title] cString]);
1997 @implementation KeyConfigControlAfter103
1998 - (id) initWithItem: (module_config_t *)_p_item
1999 withView: (NSView *)o_parent_view
2000 withVerticalOffset: (int)i_yPos
2002 NSRect mainFrame = [o_parent_view frame];
2003 NSString *o_labelString, *o_tooltip;
2004 mainFrame.size.height = 22;
2005 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
2006 mainFrame.origin.x = LEFTMARGIN;
2007 mainFrame.origin.y = i_yPos;
2009 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2011 i_view_type = CONFIG_ITEM_KEY_AFTER_10_3;
2014 if( p_item->psz_text )
2015 o_labelString = [[VLCMain sharedInstance]
2016 localizedString: p_item->psz_text];
2018 o_labelString = [NSString stringWithString:@""];
2019 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
2020 [o_label setAutoresizingMask:NSViewNotSizable ];
2021 [self addSubview: o_label];
2023 /* build the popup */
2024 o_tooltip = [[VLCMain sharedInstance] wrapString:
2025 [[VLCMain sharedInstance]
2026 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2027 ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
2028 [o_label frame].size.width + 3,
2030 [o_popup setAutoresizingMask:NSViewWidthSizable ];
2032 if( o_keys_menu == nil )
2035 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
2036 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
2037 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
2038 POPULATE_A_KEY( o_keys_menu,
2039 [NSString stringWithCString:vlc_keys[i].psz_key_string]
2040 , vlc_keys[i].i_key_code)
2042 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2043 [o_popup selectItemWithTag: p_item->i_value];
2044 [self addSubview: o_popup];
2058 return [o_popup selectedTag];
2062 @implementation ModuleListConfigControl
2063 - (id) initWithItem: (module_config_t *)_p_item
2064 withView: (NSView *)o_parent_view
2065 withVerticalOffset: (int)i_yPos
2067 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
2071 //Fill our array to know how may items we have...
2075 NSRect mainFrame = [o_parent_view frame];
2076 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2078 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2079 /* build a list of available modules */
2080 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
2081 for( i_index = 0; i_index < p_list->i_count; i_index++ )
2083 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
2085 if( !strcmp( p_parser->psz_object_name, "main" ) )
2088 module_config_t *p_config = p_parser->p_config;
2091 NSString *o_modulelongname, *o_modulename;
2092 NSNumber *o_moduleenabled = nil;
2093 /* Hack: required subcategory is stored in i_min */
2094 if( p_config->i_type == CONFIG_SUBCATEGORY &&
2095 p_config->i_value == _p_item->i_min )
2097 o_modulelongname = [NSString stringWithCString:
2098 p_parser->psz_longname];
2099 o_modulename = [NSString stringWithCString:
2100 p_parser->psz_object_name];
2102 if( _p_item->psz_value &&
2103 strstr( _p_item->psz_value, p_parser->psz_object_name ) )
2104 o_moduleenabled = [NSNumber numberWithBool:YES];
2106 o_moduleenabled = [NSNumber numberWithBool:NO];
2108 [o_modulearray addObject:[NSMutableArray
2109 arrayWithObjects: o_modulename, o_modulelongname,
2110 o_moduleenabled, nil]];
2112 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
2114 vlc_list_release( p_list );
2116 mainFrame.size.height = 30 + 18 * [o_modulearray count];
2117 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2118 mainFrame.origin.x = LEFTMARGIN;
2119 mainFrame.origin.y = i_yPos;
2120 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2122 i_view_type = CONFIG_ITEM_MODULE_LIST;
2125 if( p_item->psz_text )
2126 o_labelString = [[VLCMain sharedInstance]
2127 localizedString: p_item->psz_text];
2129 o_labelString = [NSString stringWithString:@""];
2130 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
2131 [o_label setAutoresizingMask:NSViewNotSizable ];
2132 [self addSubview: o_label];
2134 /* build the textfield */
2135 o_tooltip = [[VLCMain sharedInstance] wrapString:
2136 [[VLCMain sharedInstance]
2137 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2138 if( p_item->psz_value )
2139 o_textfieldString = [[VLCMain sharedInstance]
2140 localizedString: p_item->psz_value];
2142 o_textfieldString = [NSString stringWithString: @""];
2143 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
2144 mainFrame.size.height - 22, mainFrame.size.width -
2145 [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
2146 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2147 [self addSubview: o_textfield];
2151 NSRect s_rc = mainFrame;
2152 s_rc.size.height = mainFrame.size.height - 30;
2153 s_rc.size.width = mainFrame.size.width - 12;
2156 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2157 [o_scrollview setDrawsBackground: NO];
2158 [o_scrollview setBorderType: NSBezelBorder];
2159 [o_scrollview setAutohidesScrollers:YES];
2161 NSTableView *o_tableview;
2162 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2163 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2164 [o_tableview setHeaderView:nil];
2165 /* TODO: find a good way to fix the row height and text size*/
2166 /* FIXME: support for multiple selection... */
2167 // [o_tableview setAllowsMultipleSelection:YES];
2169 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2170 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2171 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2172 [o_dataCell setTitle:@""];
2173 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2174 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2175 initWithIdentifier:[NSString stringWithCString: "Enabled"]];
2176 [o_tableColumn setHeaderCell: o_headerCell];
2177 [o_tableColumn setDataCell: o_dataCell];
2178 [o_tableColumn setWidth:17];
2179 [o_tableview addTableColumn: o_tableColumn];
2181 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2182 o_dataCell = [[NSTextFieldCell alloc] init];
2183 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2184 o_tableColumn = [[NSTableColumn alloc]
2185 initWithIdentifier:[NSString stringWithCString: "Module"]];
2186 [o_tableColumn setHeaderCell: o_headerCell];
2187 [o_tableColumn setDataCell: o_dataCell];
2188 [o_tableColumn setWidth:388 - 17];
2189 [o_tableview addTableColumn: o_tableColumn];
2190 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2191 @"VLC media player module", nil]];
2193 [o_tableview setDataSource:self];
2194 [o_tableview setTarget: self];
2195 [o_tableview setAction: @selector(tableChanged:)];
2196 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2197 NSLeftMouseDraggedMask];
2198 [o_scrollview setDocumentView: o_tableview];
2200 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2201 [self addSubview: o_scrollview];
2208 - (IBAction)tableChanged:(id)sender
2210 NSString *o_newstring = @"";
2212 for( i = 0 ; i < [o_modulearray count] ; i++ )
2213 if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2216 o_newstring = [o_newstring stringByAppendingString:
2217 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2218 o_newstring = [o_newstring stringByAppendingString:@","];
2221 [o_textfield setStringValue: [o_newstring
2222 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2227 [o_scrollview release];
2232 - (char *)stringValue
2234 return strdup( [[o_textfield stringValue] cString] );
2239 @implementation ModuleListConfigControl (NSTableDataSource)
2241 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2242 toPasteboard:(NSPasteboard*)pb
2244 // We only want to allow dragging of selected rows.
2245 NSEnumerator *iter = [rows objectEnumerator];
2247 while ((row = [iter nextObject]) != nil)
2249 if (![table isRowSelected:[row intValue]])
2253 [pb declareTypes:[NSArray
2254 arrayWithObject:@"VLC media player module"] owner:nil];
2255 [pb setPropertyList:rows forType:@"VLC media player module"];
2259 - (NSDragOperation)tableView:(NSTableView*)table
2260 validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row
2261 proposedDropOperation:(NSTableViewDropOperation)op
2263 // Make drops at the end of the table go to the end.
2266 row = [table numberOfRows];
2267 op = NSTableViewDropAbove;
2268 [table setDropRow:row dropOperation:op];
2271 // We don't ever want to drop onto a row, only between rows.
2272 if (op == NSTableViewDropOn)
2273 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2274 return NSTableViewDropAbove;
2277 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2278 row:(int)dropRow dropOperation:(NSTableViewDropOperation)op;
2280 NSPasteboard *pb = [info draggingPasteboard];
2281 NSDragOperation srcMask = [info draggingSourceOperationMask];
2288 // Intra-table drag - data is the array of rows.
2289 if (!accepted && (array =
2290 [pb propertyListForType:@"VLC media player module"]) != NULL)
2292 NSEnumerator *iter = nil;
2294 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2296 iter = [array objectEnumerator];
2297 while ((val = [iter nextObject]) != NULL)
2299 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2300 [val intValue]] mutableCopyWithZone:nil];
2301 [o_modulearray removeObject:o_tmp];
2302 [o_modulearray insertObject:o_tmp
2303 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2307 // Select the newly-dragged items.
2308 iter = [array objectEnumerator];
2310 [table deselectAll:self];
2312 [self tableChanged:self];
2313 [table setNeedsDisplay:YES];
2314 // Indicate that we finished the drag.
2318 [table setNeedsDisplay:YES];
2322 // An exception occurred. Uh-oh. Update the track table so that
2323 // it stays consistent, and re-raise the exception.
2325 [localException raise];
2326 [table setNeedsDisplay:YES];
2332 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
2334 return [o_modulearray count];
2337 - (id)tableView:(NSTableView *)aTableView
2338 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2340 if( [[aTableColumn identifier] isEqualToString:
2341 [NSString stringWithCString:"Enabled"]] )
2342 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2343 if( [[aTableColumn identifier] isEqualToString:
2344 [NSString stringWithCString:"Module"]] )
2345 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2350 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2351 forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2353 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2354 withObject: anObject];