1 /*****************************************************************************
2 * prefs_widgets.m: Preferences controls
3 *****************************************************************************
4 * Copyright (C) 2002-2007 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 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 [o_mi setAlternate: NO]; \
57 [o_menu addItem: o_mi]; \
59 o_mi = [[NSMenuItem alloc] initWithTitle: \
60 [[NSString stringWithUTF8String: \
62 ] stringByAppendingString: string] \
63 action:nil keyEquivalent:@""]; \
64 [o_mi setKeyEquivalentModifierMask: \
66 [o_mi setAlternate: YES]; \
68 KEY_MODIFIER_CTRL | ( value )]; \
69 [o_menu addItem: o_mi]; \
71 o_mi = [[NSMenuItem alloc] initWithTitle: \
72 [[NSString stringWithUTF8String: \
73 UP_ARROWHEAD OPTION_KEY \
74 ] stringByAppendingString: string] \
75 action:nil keyEquivalent:@""]; \
76 [o_mi setKeyEquivalentModifierMask: \
77 NSControlKeyMask | NSAlternateKeyMask]; \
78 [o_mi setAlternate: YES]; \
80 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | ( value )]; \
81 [o_menu addItem: o_mi]; \
83 o_mi = [[NSMenuItem alloc] initWithTitle: \
84 [[NSString stringWithUTF8String: \
85 UP_ARROWHEAD UPWARDS_WHITE_ARROW \
86 ] stringByAppendingString: string] \
87 action:nil keyEquivalent:@""]; \
88 [o_mi setKeyEquivalentModifierMask: \
89 NSControlKeyMask | NSShiftKeyMask]; \
90 [o_mi setAlternate: YES]; \
92 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | ( value )]; \
93 [o_menu addItem: o_mi]; \
95 o_mi = [[NSMenuItem alloc] initWithTitle: \
96 [[NSString stringWithUTF8String: \
97 UP_ARROWHEAD PLACE_OF_INTEREST_SIGN \
98 ] stringByAppendingString: string] \
99 action:nil keyEquivalent:@""]; \
100 [o_mi setKeyEquivalentModifierMask: \
101 NSControlKeyMask | NSCommandKeyMask]; \
102 [o_mi setAlternate: YES]; \
104 (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | ( value )]; \
105 [o_menu addItem: o_mi]; \
106 /* Ctrl+Alt+Shift */ \
107 o_mi = [[NSMenuItem alloc] initWithTitle: \
108 [[NSString stringWithUTF8String: \
109 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
110 ] stringByAppendingString: string] \
111 action:nil keyEquivalent:@""]; \
112 [o_mi setKeyEquivalentModifierMask: \
113 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
114 [o_mi setAlternate: YES]; \
116 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | \
118 [o_menu addItem: o_mi]; \
119 /* Ctrl+Alt+Apple */ \
120 o_mi = [[NSMenuItem alloc] initWithTitle: \
121 [[NSString stringWithUTF8String: \
122 UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN \
123 ] stringByAppendingString: string] \
124 action:nil keyEquivalent:@""]; \
125 [o_mi setKeyEquivalentModifierMask: \
126 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
127 [o_mi setAlternate: YES]; \
129 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
131 [o_menu addItem: o_mi]; \
132 /* Ctrl+Shift+Apple */ \
133 o_mi = [[NSMenuItem alloc] initWithTitle: \
134 [[NSString stringWithUTF8String: \
135 UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
136 ] stringByAppendingString: string] \
137 action:nil keyEquivalent:@""]; \
138 [o_mi setKeyEquivalentModifierMask: \
139 NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
140 [o_mi setAlternate: YES]; \
142 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
144 [o_menu addItem: o_mi]; \
145 /* Ctrl+Alt+Shift+Apple */ \
146 o_mi = [[NSMenuItem alloc] initWithTitle: \
147 [[NSString stringWithUTF8String: \
148 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
149 PLACE_OF_INTEREST_SIGN \
150 ] stringByAppendingString: string] \
151 action:nil keyEquivalent:@""]; \
152 [o_mi setKeyEquivalentModifierMask: \
153 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
155 [o_mi setAlternate: YES]; \
157 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
158 KEY_MODIFIER_COMMAND) | ( value )]; \
159 [o_menu addItem: o_mi]; \
161 o_mi = [[NSMenuItem alloc] initWithTitle: \
162 [[NSString stringWithUTF8String: \
164 ] stringByAppendingString: string] \
165 action:nil keyEquivalent:@""]; \
166 [o_mi setKeyEquivalentModifierMask: \
167 NSAlternateKeyMask]; \
168 [o_mi setAlternate: YES]; \
170 KEY_MODIFIER_ALT | ( value )]; \
171 [o_menu addItem: o_mi]; \
173 o_mi = [[NSMenuItem alloc] initWithTitle: \
174 [[NSString stringWithUTF8String: \
175 OPTION_KEY UPWARDS_WHITE_ARROW \
176 ] stringByAppendingString: string] \
177 action:nil keyEquivalent:@""]; \
178 [o_mi setKeyEquivalentModifierMask: \
179 NSAlternateKeyMask | NSShiftKeyMask]; \
180 [o_mi setAlternate: YES]; \
182 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )]; \
183 [o_menu addItem: o_mi]; \
185 o_mi = [[NSMenuItem alloc] initWithTitle: \
186 [[NSString stringWithUTF8String: \
187 OPTION_KEY PLACE_OF_INTEREST_SIGN \
188 ] stringByAppendingString: string] \
189 action:nil keyEquivalent:@""]; \
190 [o_mi setKeyEquivalentModifierMask: \
191 NSAlternateKeyMask | NSCommandKeyMask]; \
192 [o_mi setAlternate: YES]; \
194 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )]; \
195 [o_menu addItem: o_mi]; \
196 /* Alt+Shift+Apple */ \
197 o_mi = [[NSMenuItem alloc] initWithTitle: \
198 [[NSString stringWithUTF8String: \
199 OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
200 ] stringByAppendingString: string] \
201 action:nil keyEquivalent:@""]; \
202 [o_mi setKeyEquivalentModifierMask: \
203 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
204 [o_mi setAlternate: YES]; \
206 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
208 [o_menu addItem: o_mi]; \
210 o_mi = [[NSMenuItem alloc] initWithTitle: \
211 [[NSString stringWithUTF8String: \
212 UPWARDS_WHITE_ARROW \
213 ] stringByAppendingString: string] \
214 action:nil keyEquivalent:@""]; \
215 [o_mi setKeyEquivalentModifierMask: \
217 [o_mi setAlternate: YES]; \
219 KEY_MODIFIER_SHIFT | ( value )]; \
220 [o_menu addItem: o_mi]; \
222 o_mi = [[NSMenuItem alloc] initWithTitle: \
223 [[NSString stringWithUTF8String: \
224 UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
225 ] stringByAppendingString: string] \
226 action:nil keyEquivalent:@""]; \
227 [o_mi setKeyEquivalentModifierMask: \
228 NSShiftKeyMask | NSCommandKeyMask]; \
229 [o_mi setAlternate: YES]; \
231 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \
232 [o_menu addItem: o_mi]; \
234 o_mi = [[NSMenuItem alloc] initWithTitle: \
235 [[NSString stringWithUTF8String: \
236 PLACE_OF_INTEREST_SIGN \
237 ] stringByAppendingString: string] \
238 action:nil keyEquivalent:@""]; \
239 [o_mi setKeyEquivalentModifierMask: \
241 [o_mi setAlternate: YES]; \
243 KEY_MODIFIER_COMMAND | ( value )]; \
244 [o_menu addItem: o_mi]; \
247 #define ADD_LABEL( o_label, superFrame, x_offset, my_y_offset, label ) \
249 NSRect s_rc = superFrame; \
250 s_rc.size.height = 17; \
251 s_rc.origin.x = x_offset - 3; \
252 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
253 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
254 [o_label setDrawsBackground: NO]; \
255 [o_label setBordered: NO]; \
256 [o_label setEditable: NO]; \
257 [o_label setSelectable: NO]; \
258 [o_label setStringValue: label]; \
259 [o_label setFont:[NSFont systemFontOfSize:0]]; \
260 [o_label sizeToFit]; \
263 #define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \
264 my_width, tooltip, init_value ) \
266 NSRect s_rc = superFrame; \
267 s_rc.origin.x = x_offset; \
268 s_rc.origin.y = my_y_offset; \
269 s_rc.size.height = 22; \
270 s_rc.size.width = my_width; \
271 o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
272 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
273 [o_textfield setToolTip: tooltip]; \
274 [o_textfield setStringValue: init_value]; \
277 #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
280 NSRect s_rc = superFrame; \
281 s_rc.origin.x = x_offset + 2; \
282 s_rc.origin.y = my_y_offset; \
283 s_rc.size.height = 26; \
284 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
286 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
287 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
288 [o_combo setToolTip: tooltip]; \
289 [o_combo setUsesDataSource:TRUE]; \
290 [o_combo setDataSource:self]; \
291 [o_combo setNumberOfVisibleItems:10]; \
292 [o_combo setCompletes:YES]; \
295 #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, \
298 NSRect s_rc = superFrame; \
299 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
300 [o_button setButtonType: NSMomentaryPushInButton]; \
301 [o_button setBezelStyle: NSRoundedBezelStyle]; \
302 [o_button setTitle: title]; \
303 [o_button setFont:[NSFont systemFontOfSize:0]]; \
304 [o_button sizeToFit]; \
305 s_rc = [o_button frame]; \
306 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
307 s_rc.origin.y = my_y_offset - 6; \
308 s_rc.size.width += 12; \
309 [o_button setFrame: s_rc]; \
310 [o_button setToolTip: tooltip]; \
311 [o_button setTarget: self]; \
312 [o_button setAction: @selector(openFileDialog:)]; \
315 #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
318 NSRect s_rc = superFrame; \
319 s_rc.origin.x = x_offset - 1; \
320 s_rc.origin.y = my_y_offset; \
321 s_rc.size.height = 26; \
322 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
324 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
325 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
326 [o_popup setToolTip: tooltip]; \
329 #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
332 NSRect s_rc = superFrame; \
333 s_rc.origin.x = x_offset; \
334 s_rc.origin.y = my_y_offset; \
335 s_rc.size.height = 23; \
336 s_rc.size.width = 23; \
337 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
338 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
339 [o_stepper setToolTip: tooltip]; \
340 [o_stepper setMaxValue: higher]; \
341 [o_stepper setMinValue: lower]; \
342 [o_stepper setTarget: self]; \
343 [o_stepper setAction: @selector(stepperChanged:)]; \
344 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
345 NSLeftMouseDraggedMask]; \
348 #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, \
349 tooltip, lower, higher ) \
351 NSRect s_rc = superFrame; \
352 s_rc.origin.x = x_offset; \
353 s_rc.origin.y = my_y_offset; \
354 s_rc.size.height = 21; \
355 s_rc.size.width = my_width; \
356 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
357 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
358 [o_slider setToolTip: tooltip]; \
359 [o_slider setMaxValue: higher]; \
360 [o_slider setMinValue: lower]; \
363 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
364 tooltip, init_value, position ) \
366 NSRect s_rc = superFrame; \
367 s_rc.size.height = 18; \
368 s_rc.origin.x = x_offset - 2; \
369 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
370 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
371 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
372 [o_checkbox setButtonType: NSSwitchButton]; \
373 [o_checkbox setImagePosition: position]; \
374 [o_checkbox setIntValue: init_value]; \
375 [o_checkbox setTitle: label]; \
376 [o_checkbox setToolTip: tooltip]; \
377 [o_checkbox sizeToFit]; \
380 @implementation VLCConfigControl
381 - (id)initWithFrame: (NSRect)frame
383 return [self initWithFrame: frame
387 - (id)initWithFrame: (NSRect)frame
388 item: (module_config_t *)_p_item
390 self = [super initWithFrame: frame];
395 psz_name = strdup( p_item->psz_name );
397 i_type = p_item->i_type;
399 b_advanced = p_item->b_advanced;
400 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
405 - (void)setYPos:(int)i_yPos
407 NSRect frame = [self frame];
408 frame.origin.y = i_yPos;
409 [self setFrame:frame];
415 /* since dealloc isn't called on 10.5 if GC is enabled and since GC is
416 * Obj-C only, we need to do this: */
417 if( psz_name ) free( psz_name );
424 if( o_label ) [o_label release];
425 if( psz_name ) free( psz_name );
429 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
434 case CONFIG_ITEM_STRING:
437 case CONFIG_ITEM_STRING:
440 case CONFIG_ITEM_STRING_LIST:
443 case CONFIG_ITEM_FILE:
446 case CONFIG_ITEM_MODULE:
449 case CONFIG_ITEM_INTEGER:
452 case CONFIG_ITEM_RANGED_INTEGER:
455 case CONFIG_ITEM_BOOL:
458 case CONFIG_ITEM_KEY_BEFORE_10_3:
461 case CONFIG_ITEM_KEY_AFTER_10_3:
464 case CONFIG_ITEM_MODULE_LIST:
472 case CONFIG_ITEM_STRING_LIST:
475 case CONFIG_ITEM_STRING:
478 case CONFIG_ITEM_STRING_LIST:
481 case CONFIG_ITEM_FILE:
484 case CONFIG_ITEM_MODULE:
487 case CONFIG_ITEM_INTEGER:
490 case CONFIG_ITEM_RANGED_INTEGER:
493 case CONFIG_ITEM_BOOL:
496 case CONFIG_ITEM_KEY_BEFORE_10_3:
499 case CONFIG_ITEM_KEY_AFTER_10_3:
502 case CONFIG_ITEM_MODULE_LIST:
510 case CONFIG_ITEM_FILE:
513 case CONFIG_ITEM_STRING:
516 case CONFIG_ITEM_STRING_LIST:
519 case CONFIG_ITEM_FILE:
522 case CONFIG_ITEM_MODULE:
525 case CONFIG_ITEM_INTEGER:
528 case CONFIG_ITEM_RANGED_INTEGER:
531 case CONFIG_ITEM_BOOL:
534 case CONFIG_ITEM_KEY_BEFORE_10_3:
537 case CONFIG_ITEM_KEY_AFTER_10_3:
540 case CONFIG_ITEM_MODULE_LIST:
548 case CONFIG_ITEM_MODULE:
551 case CONFIG_ITEM_STRING:
554 case CONFIG_ITEM_STRING_LIST:
557 case CONFIG_ITEM_FILE:
560 case CONFIG_ITEM_MODULE:
563 case CONFIG_ITEM_INTEGER:
566 case CONFIG_ITEM_RANGED_INTEGER:
569 case CONFIG_ITEM_BOOL:
572 case CONFIG_ITEM_KEY_BEFORE_10_3:
575 case CONFIG_ITEM_KEY_AFTER_10_3:
578 case CONFIG_ITEM_MODULE_LIST:
586 case CONFIG_ITEM_INTEGER:
589 case CONFIG_ITEM_STRING:
592 case CONFIG_ITEM_STRING_LIST:
595 case CONFIG_ITEM_FILE:
598 case CONFIG_ITEM_MODULE:
601 case CONFIG_ITEM_INTEGER:
604 case CONFIG_ITEM_RANGED_INTEGER:
607 case CONFIG_ITEM_BOOL:
610 case CONFIG_ITEM_KEY_BEFORE_10_3:
613 case CONFIG_ITEM_KEY_AFTER_10_3:
616 case CONFIG_ITEM_MODULE_LIST:
624 case CONFIG_ITEM_RANGED_INTEGER:
627 case CONFIG_ITEM_STRING:
630 case CONFIG_ITEM_STRING_LIST:
633 case CONFIG_ITEM_FILE:
636 case CONFIG_ITEM_MODULE:
639 case CONFIG_ITEM_INTEGER:
642 case CONFIG_ITEM_RANGED_INTEGER:
645 case CONFIG_ITEM_BOOL:
648 case CONFIG_ITEM_KEY_BEFORE_10_3:
651 case CONFIG_ITEM_KEY_AFTER_10_3:
654 case CONFIG_ITEM_MODULE_LIST:
662 case CONFIG_ITEM_BOOL:
665 case CONFIG_ITEM_STRING:
668 case CONFIG_ITEM_STRING_LIST:
671 case CONFIG_ITEM_FILE:
674 case CONFIG_ITEM_MODULE:
677 case CONFIG_ITEM_INTEGER:
680 case CONFIG_ITEM_RANGED_INTEGER:
683 case CONFIG_ITEM_BOOL:
686 case CONFIG_ITEM_KEY_BEFORE_10_3:
689 case CONFIG_ITEM_KEY_AFTER_10_3:
692 case CONFIG_ITEM_MODULE_LIST:
700 case CONFIG_ITEM_KEY_BEFORE_10_3:
703 case CONFIG_ITEM_STRING:
706 case CONFIG_ITEM_STRING_LIST:
709 case CONFIG_ITEM_FILE:
712 case CONFIG_ITEM_MODULE:
715 case CONFIG_ITEM_INTEGER:
718 case CONFIG_ITEM_RANGED_INTEGER:
721 case CONFIG_ITEM_BOOL:
724 case CONFIG_ITEM_KEY_BEFORE_10_3:
727 case CONFIG_ITEM_KEY_AFTER_10_3:
730 case CONFIG_ITEM_MODULE_LIST:
738 case CONFIG_ITEM_KEY_AFTER_10_3:
741 case CONFIG_ITEM_STRING:
744 case CONFIG_ITEM_STRING_LIST:
747 case CONFIG_ITEM_FILE:
750 case CONFIG_ITEM_MODULE:
753 case CONFIG_ITEM_INTEGER:
756 case CONFIG_ITEM_RANGED_INTEGER:
759 case CONFIG_ITEM_BOOL:
762 case CONFIG_ITEM_KEY_BEFORE_10_3:
765 case CONFIG_ITEM_KEY_AFTER_10_3:
768 case CONFIG_ITEM_MODULE_LIST:
776 case CONFIG_ITEM_MODULE_LIST:
779 case CONFIG_ITEM_STRING:
782 case CONFIG_ITEM_STRING_LIST:
785 case CONFIG_ITEM_FILE:
788 case CONFIG_ITEM_MODULE:
791 case CONFIG_ITEM_INTEGER:
794 case CONFIG_ITEM_RANGED_INTEGER:
797 case CONFIG_ITEM_BOOL:
800 case CONFIG_ITEM_KEY_BEFORE_10_3:
803 case CONFIG_ITEM_KEY_AFTER_10_3:
806 case CONFIG_ITEM_MODULE_LIST:
821 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
822 withView: (NSView *)o_parent_view
824 VLCConfigControl *p_control = NULL;
825 /* Skip depracated options */
826 if( _p_item->psz_current )
831 switch( _p_item->i_type )
833 case CONFIG_ITEM_STRING:
834 if( !_p_item->i_list )
836 p_control = [[StringConfigControl alloc]
837 initWithItem: _p_item
838 withView: o_parent_view];
842 p_control = [[StringListConfigControl alloc]
843 initWithItem: _p_item
844 withView: o_parent_view];
847 case CONFIG_ITEM_FILE:
848 case CONFIG_ITEM_DIRECTORY:
849 p_control = [[FileConfigControl alloc]
850 initWithItem: _p_item
851 withView: o_parent_view];
853 case CONFIG_ITEM_MODULE:
854 case CONFIG_ITEM_MODULE_CAT:
855 p_control = [[ModuleConfigControl alloc]
856 initWithItem: _p_item
857 withView: o_parent_view];
859 case CONFIG_ITEM_INTEGER:
860 if( _p_item->i_list )
862 p_control = [[IntegerListConfigControl alloc]
863 initWithItem: _p_item
864 withView: o_parent_view];
866 else if( _p_item->min.i != 0 || _p_item->max.i != 0 )
868 p_control = [[RangedIntegerConfigControl alloc]
869 initWithItem: _p_item
870 withView: o_parent_view];
874 p_control = [[IntegerConfigControl alloc]
875 initWithItem: _p_item
876 withView: o_parent_view];
879 case CONFIG_ITEM_BOOL:
880 p_control = [[BoolConfigControl alloc]
881 initWithItem: _p_item
882 withView: o_parent_view];
884 case CONFIG_ITEM_FLOAT:
885 if( _p_item->min.f != 0 || _p_item->max.f != 0 )
887 p_control = [[RangedFloatConfigControl alloc]
888 initWithItem: _p_item
889 withView: o_parent_view];
893 p_control = [[FloatConfigControl alloc]
894 initWithItem: _p_item
895 withView: o_parent_view];
898 case CONFIG_ITEM_KEY:
899 p_control = [[KeyConfigControl alloc]
900 initWithItem: _p_item
901 withView: o_parent_view];
903 case CONFIG_ITEM_MODULE_LIST:
904 case CONFIG_ITEM_MODULE_LIST_CAT:
905 p_control = [[ModuleListConfigControl alloc]
906 initWithItem: _p_item
907 withView: o_parent_view];
915 - (NSString *)getName
917 return [[VLCMain sharedInstance] localizedString: psz_name];
945 - (char *)stringValue
953 switch( p_item->i_type )
955 case CONFIG_ITEM_STRING:
956 case CONFIG_ITEM_FILE:
957 case CONFIG_ITEM_DIRECTORY:
958 case CONFIG_ITEM_MODULE:
959 case CONFIG_ITEM_MODULE_LIST:
960 case CONFIG_ITEM_MODULE_LIST_CAT:
961 config_PutPsz( VLCIntf, psz_name, [self stringValue] );
963 case CONFIG_ITEM_KEY:
964 /* So you don't need to restart to have the changes take effect */
965 val.i_int = [self intValue];
966 var_Set( VLCIntf->p_libvlc, psz_name, val );
967 case CONFIG_ITEM_INTEGER:
968 case CONFIG_ITEM_BOOL:
969 config_PutInt( VLCIntf, psz_name, [self intValue] );
971 case CONFIG_ITEM_FLOAT:
972 config_PutFloat( VLCIntf, psz_name, [self floatValue] );
979 return [o_label frame].size.width;
982 - (void) alignWithXPosition:(int)i_xPos;
984 /* FIXME: not implemented atm, but created to shut up the warning
985 * about "method definition not found" -- FK @ 7/24/05 */
989 @implementation StringConfigControl
990 - (id) initWithItem: (module_config_t *)_p_item
991 withView: (NSView *)o_parent_view
993 NSRect mainFrame = [o_parent_view frame];
994 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
995 mainFrame.size.height = 22;
996 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
997 mainFrame.origin.x = LEFTMARGIN;
998 mainFrame.origin.y = 0;
1000 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1002 i_view_type = CONFIG_ITEM_STRING;
1004 if( p_item->psz_text )
1005 o_labelString = [[VLCMain sharedInstance]
1006 localizedString: (char *)p_item->psz_text];
1008 o_labelString = [NSString stringWithString:@""];
1009 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1010 [o_label setAutoresizingMask:NSViewNotSizable ];
1011 [self addSubview: o_label];
1013 /* build the textfield */
1014 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1015 [[VLCMain sharedInstance] localizedString: (char *)p_item->psz_longtext]
1016 toWidth: PREFS_WRAP];
1017 if( p_item->value.psz )
1018 o_textfieldString = [[VLCMain sharedInstance]
1019 localizedString: (char *)p_item->value.psz];
1021 o_textfieldString = [NSString stringWithString: @""];
1022 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1023 0, mainFrame.size.width - [o_label frame].size.width -
1024 2, o_textfieldTooltip, o_textfieldString )
1025 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1026 [self addSubview: o_textfield];
1031 - (void) alignWithXPosition:(int)i_xPos
1034 NSRect superFrame = [self frame];
1035 frame = [o_label frame];
1036 frame.origin.x = i_xPos - frame.size.width - 3;
1037 [o_label setFrame:frame];
1039 frame = [o_textfield frame];
1040 frame.origin.x = i_xPos + 2;
1041 frame.size.width = superFrame.size.width - frame.origin.x - 1;
1042 [o_textfield setFrame:frame];
1047 [o_textfield release];
1051 - (char *)stringValue
1053 return strdup( [[VLCMain sharedInstance] delocalizeString:
1054 [o_textfield stringValue]] );
1058 @implementation StringListConfigControl
1059 - (id) initWithItem: (module_config_t *)_p_item
1060 withView: (NSView *)o_parent_view
1062 NSRect mainFrame = [o_parent_view frame];
1063 NSString *o_labelString, *o_textfieldTooltip;
1064 mainFrame.size.height = 22;
1065 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1066 mainFrame.origin.x = LEFTMARGIN;
1067 mainFrame.origin.y = 0;
1069 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1072 i_view_type = CONFIG_ITEM_STRING_LIST;
1074 if( p_item->psz_text )
1075 o_labelString = [[VLCMain sharedInstance]
1076 localizedString: (char *)p_item->psz_text];
1078 o_labelString = [NSString stringWithString:@""];
1079 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1080 [o_label setAutoresizingMask:NSViewNotSizable ];
1081 [self addSubview: o_label];
1083 /* build the textfield */
1084 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1085 [[VLCMain sharedInstance]
1086 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1087 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1088 -2, 0, o_textfieldTooltip )
1089 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1090 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1091 if( p_item->value.psz &&
1092 !strcmp( p_item->value.psz, p_item->ppsz_list[i_index] ) )
1093 [o_combo selectItemAtIndex: i_index];
1094 [self addSubview: o_combo];
1099 - (void) alignWithXPosition:(int)i_xPos
1102 NSRect superFrame = [self frame];
1103 frame = [o_label frame];
1104 frame.origin.x = i_xPos - frame.size.width - 3;
1105 [o_label setFrame:frame];
1107 frame = [o_combo frame];
1108 frame.origin.x = i_xPos + 2;
1109 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1110 [o_combo setFrame:frame];
1119 - (char *)stringValue
1121 if( [o_combo indexOfSelectedItem] >= 0 )
1122 return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
1124 return strdup( [[VLCMain sharedInstance]
1125 delocalizeString: [o_combo stringValue]] );
1129 @implementation StringListConfigControl (NSComboBoxDataSource)
1130 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1132 return p_item->i_list;
1135 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1137 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1139 return [[VLCMain sharedInstance]
1140 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1141 } else return [[VLCMain sharedInstance]
1142 localizedString: (char *)p_item->ppsz_list[i_index]];
1146 @implementation FileConfigControl
1147 - (id) initWithItem: (module_config_t *)_p_item
1148 withView: (NSView *)o_parent_view
1150 NSRect mainFrame = [o_parent_view frame];
1151 NSString *o_labelString, *o_buttonTooltip, *o_textfieldString;
1152 NSString *o_textfieldTooltip;
1153 mainFrame.size.height = 46;
1154 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1155 mainFrame.origin.x = LEFTMARGIN;
1156 mainFrame.origin.y = 0;
1158 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1160 i_view_type = CONFIG_ITEM_FILE;
1162 /* is it a directory */
1163 b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
1166 if( p_item->psz_text )
1167 o_labelString = [[VLCMain sharedInstance]
1168 localizedString: (char *)p_item->psz_text];
1170 o_labelString = [NSString stringWithString:@""];
1171 ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString )
1172 [o_label setAutoresizingMask:NSViewNotSizable ];
1173 [self addSubview: o_label];
1175 /* build the button */
1176 o_buttonTooltip = [[VLCMain sharedInstance]
1177 wrapString: [[VLCMain sharedInstance]
1178 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1179 ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_buttonTooltip,
1181 [o_button setAutoresizingMask:NSViewMinXMargin ];
1182 [self addSubview: o_button];
1184 /* build the textfield */
1185 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1186 [[VLCMain sharedInstance]
1187 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1188 if( p_item->value.psz )
1189 o_textfieldString = [[VLCMain sharedInstance]
1190 localizedString: (char *)p_item->value.psz];
1192 o_textfieldString = [NSString stringWithString: @""];
1193 ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1194 8 - [o_button frame].size.width,
1195 o_textfieldTooltip, o_textfieldString )
1196 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1197 [self addSubview: o_textfield];
1202 - (void) alignWithXPosition:(int)i_xPos
1209 [o_textfield release];
1214 - (IBAction)openFileDialog: (id)sender
1216 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1218 [o_open_panel setTitle: (b_directory)?
1219 _NS("Select a directory"):_NS("Select a file")];
1220 [o_open_panel setPrompt: _NS("Select")];
1221 [o_open_panel setAllowsMultipleSelection: NO];
1222 [o_open_panel setCanChooseFiles: !b_directory];
1223 [o_open_panel setCanChooseDirectories: b_directory];
1224 [o_open_panel beginSheetForDirectory:nil
1227 modalForWindow:[sender window]
1229 didEndSelector: @selector(pathChosenInPanel:
1235 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
1236 withReturn:(int)i_return_code contextInfo:(void *)o_context_info
1238 if( i_return_code == NSOKButton )
1240 NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
1241 [o_textfield setStringValue: o_path];
1245 - (char *)stringValue
1247 if( [[o_textfield stringValue] length] != 0)
1248 return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
1254 @implementation ModuleConfigControl
1255 - (id) initWithItem: (module_config_t *)_p_item
1256 withView: (NSView *)o_parent_view
1258 NSRect mainFrame = [o_parent_view frame];
1259 NSString *o_labelString, *o_popupTooltip;
1260 mainFrame.size.height = 22;
1261 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1262 mainFrame.origin.x = LEFTMARGIN;
1263 mainFrame.origin.y = 0;
1265 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1270 module_config_t *p_end;
1271 i_view_type = CONFIG_ITEM_MODULE;
1274 if( p_item->psz_text )
1275 o_labelString = [[VLCMain sharedInstance]
1276 localizedString: (char *)p_item->psz_text];
1278 o_labelString = [NSString stringWithString:@""];
1279 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
1280 [o_label setAutoresizingMask:NSViewNotSizable ];
1281 [self addSubview: o_label];
1283 /* build the popup */
1284 o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1285 [[VLCMain sharedInstance]
1286 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1287 ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
1288 -2, 0, o_popupTooltip )
1289 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1290 [o_popup addItemWithTitle: _NS("Default")];
1291 [[o_popup lastItem] setTag: -1];
1292 [o_popup selectItem: [o_popup lastItem]];
1294 /* build a list of available modules */
1295 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1296 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1298 p_parser = (module_t *)p_list->p_values[i_index].p_object;
1299 p_end = p_item + p_parser->confsize;
1300 if( p_item->i_type == CONFIG_ITEM_MODULE )
1302 if( !strcmp( p_parser->psz_capability,
1303 p_item->psz_type ) )
1305 NSString *o_description = [[VLCMain sharedInstance]
1306 localizedString: (char *)p_parser->psz_longname];
1307 [o_popup addItemWithTitle: o_description];
1309 if( p_item->value.psz &&
1310 !strcmp( p_item->value.psz, p_parser->psz_object_name ) )
1311 [o_popup selectItem:[o_popup lastItem]];
1316 module_config_t *p_config;
1317 if( !strcmp( p_parser->psz_object_name, "main" ) )
1320 p_config = p_parser->p_config;
1323 /* Hack: required subcategory is stored in i_min */
1324 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1325 p_config->value.i == p_item->min.i )
1327 NSString *o_description = [[VLCMain sharedInstance]
1328 localizedString: (char *)p_parser->psz_longname];
1329 [o_popup addItemWithTitle: o_description];
1331 if( p_item->value.psz && !strcmp(p_item->value.psz,
1332 p_parser->psz_object_name) )
1333 [o_popup selectItem:[o_popup lastItem]];
1335 } while( p_item < p_end && p_config++ );
1338 vlc_list_release( p_list );
1339 [self addSubview: o_popup];
1344 - (void) alignWithXPosition:(int)i_xPos
1347 NSRect superFrame = [self frame];
1348 frame = [o_label frame];
1349 frame.origin.x = i_xPos - frame.size.width - 3;
1350 [o_label setFrame:frame];
1352 frame = [o_popup frame];
1353 frame.origin.x = i_xPos - 1;
1354 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1355 [o_popup setFrame:frame];
1364 - (char *)stringValue
1366 NSString *newval = [o_popup titleOfSelectedItem];
1367 char *returnval = NULL;
1371 module_config_t *p_end;
1373 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1374 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1376 p_parser = (module_t *)p_list->p_values[i_index].p_object;
1377 p_end = p_item + p_parser->confsize;
1378 if( p_item->i_type == CONFIG_ITEM_MODULE )
1380 if( !strcmp( p_parser->psz_capability,
1381 p_item->psz_type ) )
1383 NSString *o_description = [[VLCMain sharedInstance]
1384 localizedString: (char *)p_parser->psz_longname];
1385 if( [newval isEqualToString: o_description] )
1387 returnval = strdup(p_parser->psz_object_name);
1394 module_config_t *p_config;
1395 if( !strcmp( p_parser->psz_object_name, "main" ) )
1398 p_config = p_parser->p_config;
1401 /* Hack: required subcategory is stored in i_min */
1402 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1403 p_config->value.i == p_item->min.i )
1405 NSString *o_description = [[VLCMain sharedInstance]
1406 localizedString: (char *)p_parser->psz_longname];
1407 if( [newval isEqualToString: o_description] )
1409 returnval = strdup(p_parser->psz_object_name);
1413 } while( p_item < p_end && p_config++ );
1416 vlc_list_release( p_list );
1421 @implementation IntegerConfigControl
1422 - (id) initWithItem: (module_config_t *)_p_item
1423 withView: (NSView *)o_parent_view
1425 NSRect mainFrame = [o_parent_view frame];
1426 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1427 mainFrame.size.height = 23;
1428 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1429 mainFrame.origin.x = LEFTMARGIN;
1430 mainFrame.origin.y = 0;
1432 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1434 i_view_type = CONFIG_ITEM_INTEGER;
1436 o_tooltip = [[VLCMain sharedInstance] wrapString:
1437 [[VLCMain sharedInstance]
1438 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1441 if( p_item->psz_text )
1442 o_labelString = [[VLCMain sharedInstance]
1443 localizedString: (char *)p_item->psz_text];
1445 o_labelString = [NSString stringWithString:@""];
1446 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1447 [o_label setAutoresizingMask:NSViewNotSizable ];
1448 [self addSubview: o_label];
1450 /* build the stepper */
1451 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1452 0, o_tooltip, -1600, 1600)
1453 [o_stepper setIntValue: p_item->value.i];
1454 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1455 [self addSubview: o_stepper];
1457 /* build the textfield */
1458 if( p_item->value.psz )
1459 o_textfieldString = [[VLCMain sharedInstance]
1460 localizedString: (char *)p_item->value.psz];
1462 o_textfieldString = [NSString stringWithString: @""];
1463 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1464 1, 49, o_tooltip, @"" )
1465 [o_textfield setIntValue: p_item->value.i];
1466 [o_textfield setDelegate: self];
1467 [[NSNotificationCenter defaultCenter] addObserver: self
1468 selector: @selector(textfieldChanged:)
1469 name: NSControlTextDidChangeNotification
1470 object: o_textfield];
1471 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1472 [self addSubview: o_textfield];
1477 - (void) alignWithXPosition:(int)i_xPos
1480 frame = [o_label frame];
1481 frame.origin.x = i_xPos - frame.size.width - 3;
1482 [o_label setFrame:frame];
1484 frame = [o_textfield frame];
1485 frame.origin.x = i_xPos + 2;
1486 [o_textfield setFrame:frame];
1488 frame = [o_stepper frame];
1489 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1490 [o_stepper setFrame:frame];
1495 [o_stepper release];
1496 [o_textfield release];
1500 - (IBAction)stepperChanged:(id)sender
1502 [o_textfield setIntValue: [o_stepper intValue]];
1505 - (void)textfieldChanged:(NSNotification *)o_notification
1507 [o_stepper setIntValue: [o_textfield intValue]];
1512 return [o_textfield intValue];
1517 @implementation IntegerListConfigControl
1519 - (id) initWithItem: (module_config_t *)_p_item
1520 withView: (NSView *)o_parent_view
1522 NSRect mainFrame = [o_parent_view frame];
1523 NSString *o_labelString, *o_textfieldTooltip;
1524 mainFrame.size.height = 22;
1525 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1526 mainFrame.origin.x = LEFTMARGIN;
1527 mainFrame.origin.y = 0;
1529 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1532 i_view_type = CONFIG_ITEM_STRING_LIST;
1535 if( p_item->psz_text )
1536 o_labelString = [[VLCMain sharedInstance]
1537 localizedString: (char *)p_item->psz_text];
1539 o_labelString = [NSString stringWithString:@""];
1540 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1541 [o_label setAutoresizingMask:NSViewNotSizable ];
1542 [self addSubview: o_label];
1544 /* build the textfield */
1545 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1546 [[VLCMain sharedInstance]
1547 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1548 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1549 -2, 0, o_textfieldTooltip )
1550 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1551 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1553 if( p_item->value.i == p_item->pi_list[i_index] )
1555 [o_combo selectItemAtIndex: i_index];
1558 [self addSubview: o_combo];
1563 - (void) alignWithXPosition:(int)i_xPos
1566 NSRect superFrame = [self frame];
1567 frame = [o_label frame];
1568 frame.origin.x = i_xPos - frame.size.width - 3;
1569 [o_label setFrame:frame];
1571 frame = [o_combo frame];
1572 frame.origin.x = i_xPos + 2;
1573 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1574 [o_combo setFrame:frame];
1585 if( [o_combo indexOfSelectedItem] >= 0 )
1586 return p_item->pi_list[[o_combo indexOfSelectedItem]];
1588 return [o_combo intValue];
1592 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1593 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1595 return p_item->i_list;
1598 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1600 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1601 return [[VLCMain sharedInstance]
1602 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1604 return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1608 @implementation RangedIntegerConfigControl
1609 - (id) initWithItem: (module_config_t *)_p_item
1610 withView: (NSView *)o_parent_view
1612 NSRect mainFrame = [o_parent_view frame];
1613 NSString *o_labelString, *o_tooltip;
1614 mainFrame.size.height = 50;
1615 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1616 mainFrame.origin.x = LEFTMARGIN;
1617 mainFrame.origin.y = 0;
1619 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1621 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1624 if( p_item->psz_text )
1625 o_labelString = [[VLCMain sharedInstance]
1626 localizedString: (char *)p_item->psz_text];
1628 o_labelString = [NSString stringWithString:@""];
1629 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1630 [o_label setAutoresizingMask:NSViewNotSizable ];
1631 [self addSubview: o_label];
1633 /* build the textfield */
1634 o_tooltip = [[VLCMain sharedInstance] wrapString:
1635 [[VLCMain sharedInstance]
1636 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1637 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1638 28, 49, o_tooltip, @"" )
1639 [o_textfield setIntValue: p_item->value.i];
1640 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1641 [o_textfield setDelegate: self];
1642 [[NSNotificationCenter defaultCenter] addObserver: self
1643 selector: @selector(textfieldChanged:)
1644 name: NSControlTextDidChangeNotification
1645 object: o_textfield];
1646 [self addSubview: o_textfield];
1648 /* build the mintextfield */
1649 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1650 [o_textfield_min setIntValue: p_item->min.i];
1651 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1652 [o_textfield_min setAlignment:NSRightTextAlignment];
1653 [self addSubview: o_textfield_min];
1655 /* build the maxtextfield */
1656 ADD_LABEL( o_textfield_max, mainFrame,
1657 mainFrame.size.width - 31, -30, @"8888" )
1658 [o_textfield_max setIntValue: p_item->max.i];
1659 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1660 [self addSubview: o_textfield_max];
1662 /* build the slider */
1663 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1664 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1665 [o_textfield_max frame].size.width -
1666 [o_textfield_max frame].size.width - 14 -
1667 [o_textfield_min frame].origin.x, o_tooltip,
1668 p_item->min.i, p_item->max.i )
1669 [o_slider setIntValue: p_item->value.i];
1670 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1671 [o_slider setTarget: self];
1672 [o_slider setAction: @selector(sliderChanged:)];
1673 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1674 NSLeftMouseDraggedMask];
1675 [self addSubview: o_slider];
1681 - (void) alignWithXPosition:(int)i_xPos
1684 frame = [o_label frame];
1685 frame.origin.x = i_xPos - frame.size.width - 3;
1686 [o_label setFrame:frame];
1688 frame = [o_textfield frame];
1689 frame.origin.x = i_xPos + 2;
1690 [o_textfield setFrame:frame];
1695 [o_textfield release];
1696 [o_textfield_min release];
1697 [o_textfield_max release];
1702 - (IBAction)sliderChanged:(id)sender
1704 [o_textfield setIntValue: [o_slider intValue]];
1707 - (void)textfieldChanged:(NSNotification *)o_notification
1709 [o_slider setIntValue: [o_textfield intValue]];
1714 return [o_slider intValue];
1718 @implementation FloatConfigControl
1719 - (id) initWithItem: (module_config_t *)_p_item
1720 withView: (NSView *)o_parent_view
1722 NSRect mainFrame = [o_parent_view frame];
1723 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1724 mainFrame.size.height = 23;
1725 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1726 mainFrame.origin.x = LEFTMARGIN;
1727 mainFrame.origin.y = 0;
1729 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1731 i_view_type = CONFIG_ITEM_INTEGER;
1733 o_tooltip = [[VLCMain sharedInstance] wrapString:
1734 [[VLCMain sharedInstance]
1735 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1738 if( p_item->psz_text )
1739 o_labelString = [[VLCMain sharedInstance]
1740 localizedString: (char *)p_item->psz_text];
1742 o_labelString = [NSString stringWithString:@""];
1743 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
1744 [o_label setAutoresizingMask:NSViewNotSizable ];
1745 [self addSubview: o_label];
1747 /* build the stepper */
1748 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1749 0, o_tooltip, -1600, 1600)
1750 [o_stepper setFloatValue: p_item->value.f];
1751 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1752 [self addSubview: o_stepper];
1754 /* build the textfield */
1755 if( p_item->value.psz )
1756 o_textfieldString = [[VLCMain sharedInstance]
1757 localizedString: (char *)p_item->value.psz];
1759 o_textfieldString = [NSString stringWithString: @""];
1760 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1761 1, 49, o_tooltip, @"" )
1762 [o_textfield setFloatValue: p_item->value.f];
1763 [o_textfield setDelegate: self];
1764 [[NSNotificationCenter defaultCenter] addObserver: self
1765 selector: @selector(textfieldChanged:)
1766 name: NSControlTextDidChangeNotification
1767 object: o_textfield];
1768 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1769 [self addSubview: o_textfield];
1774 - (void) alignWithXPosition:(int)i_xPos
1777 frame = [o_label frame];
1778 frame.origin.x = i_xPos - frame.size.width - 3;
1779 [o_label setFrame:frame];
1781 frame = [o_textfield frame];
1782 frame.origin.x = i_xPos + 2;
1783 [o_textfield setFrame:frame];
1785 frame = [o_stepper frame];
1786 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1787 [o_stepper setFrame:frame];
1792 [o_stepper release];
1793 [o_textfield release];
1797 - (IBAction)stepperChanged:(id)sender
1799 [o_textfield setFloatValue: [o_stepper floatValue]];
1802 - (void)textfieldChanged:(NSNotification *)o_notification
1804 [o_stepper setFloatValue: [o_textfield floatValue]];
1809 return [o_stepper floatValue];
1813 @implementation RangedFloatConfigControl
1814 - (id) initWithItem: (module_config_t *)_p_item
1815 withView: (NSView *)o_parent_view
1817 NSRect mainFrame = [o_parent_view frame];
1818 NSString *o_labelString, *o_tooltip;
1819 mainFrame.size.height = 50;
1820 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1821 mainFrame.origin.x = LEFTMARGIN;
1822 mainFrame.origin.y = 0;
1824 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1826 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1829 if( p_item->psz_text )
1830 o_labelString = [[VLCMain sharedInstance]
1831 localizedString: (char *)p_item->psz_text];
1833 o_labelString = [NSString stringWithString:@""];
1834 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1835 [o_label setAutoresizingMask:NSViewNotSizable ];
1836 [self addSubview: o_label];
1838 /* build the textfield */
1839 o_tooltip = [[VLCMain sharedInstance] wrapString:
1840 [[VLCMain sharedInstance]
1841 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1842 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1843 28, 49, o_tooltip, @"" )
1844 [o_textfield setFloatValue: p_item->value.f];
1845 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1846 [o_textfield setDelegate: self];
1847 [[NSNotificationCenter defaultCenter] addObserver: self
1848 selector: @selector(textfieldChanged:)
1849 name: NSControlTextDidChangeNotification
1850 object: o_textfield];
1851 [self addSubview: o_textfield];
1853 /* build the mintextfield */
1854 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1855 [o_textfield_min setFloatValue: p_item->min.f];
1856 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1857 [o_textfield_min setAlignment:NSRightTextAlignment];
1858 [self addSubview: o_textfield_min];
1860 /* build the maxtextfield */
1861 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
1863 [o_textfield_max setFloatValue: p_item->max.f];
1864 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1865 [self addSubview: o_textfield_max];
1867 /* build the slider */
1868 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1869 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1870 [o_textfield_max frame].size.width -
1871 [o_textfield_max frame].size.width - 14 -
1872 [o_textfield_min frame].origin.x, o_tooltip, p_item->min.f,
1874 [o_slider setFloatValue: p_item->value.f];
1875 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1876 [o_slider setTarget: self];
1877 [o_slider setAction: @selector(sliderChanged:)];
1878 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1879 NSLeftMouseDraggedMask];
1880 [self addSubview: o_slider];
1886 - (void) alignWithXPosition:(int)i_xPos
1889 frame = [o_label frame];
1890 frame.origin.x = i_xPos - frame.size.width - 3;
1891 [o_label setFrame:frame];
1893 frame = [o_textfield frame];
1894 frame.origin.x = i_xPos + 2;
1895 [o_textfield setFrame:frame];
1900 [o_textfield release];
1901 [o_textfield_min release];
1902 [o_textfield_max release];
1907 - (IBAction)sliderChanged:(id)sender
1909 [o_textfield setFloatValue: [o_slider floatValue]];
1912 - (void)textfieldChanged:(NSNotification *)o_notification
1914 [o_slider setFloatValue: [o_textfield floatValue]];
1919 return [o_slider floatValue];
1924 @implementation BoolConfigControl
1926 - (id) initWithItem: (module_config_t *)_p_item
1927 withView: (NSView *)o_parent_view
1929 NSRect mainFrame = [o_parent_view frame];
1930 NSString *o_labelString, *o_tooltip;
1931 mainFrame.size.height = 17;
1932 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1933 mainFrame.origin.x = LEFTMARGIN;
1934 mainFrame.origin.y = 0;
1936 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1938 i_view_type = CONFIG_ITEM_BOOL;
1940 /* add the checkbox */
1941 o_tooltip = [[VLCMain sharedInstance]
1942 wrapString: [[VLCMain sharedInstance]
1943 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1944 ADD_CHECKBOX( o_checkbox, mainFrame, 0,
1945 0, @"", o_tooltip, p_item->value.i, NSImageLeft)
1946 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1947 [self addSubview: o_checkbox];
1949 if( p_item->psz_text )
1950 o_labelString = [[VLCMain sharedInstance]
1951 localizedString: (char *)p_item->psz_text];
1953 o_labelString = [NSString stringWithString:@""];
1954 ADD_LABEL( o_label, mainFrame, [o_checkbox frame].size.width, 0, o_labelString )
1955 [o_label setAutoresizingMask:NSViewNotSizable ];
1956 [self addSubview: o_label];
1963 [o_checkbox release];
1969 return [o_checkbox intValue];
1974 @implementation KeyConfigControl
1975 - (id) initWithItem: (module_config_t *)_p_item
1976 withView: (NSView *)o_parent_view
1978 NSRect mainFrame = [o_parent_view frame];
1979 NSString *o_labelString, *o_tooltip;
1980 mainFrame.size.height = 22;
1981 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1982 mainFrame.origin.x = LEFTMARGIN;
1983 mainFrame.origin.y = 0;
1985 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1987 i_view_type = CONFIG_ITEM_KEY_AFTER_10_3;
1990 if( p_item->psz_text )
1991 o_labelString = [[VLCMain sharedInstance]
1992 localizedString: (char *)p_item->psz_text];
1994 o_labelString = [NSString stringWithString:@""];
1995 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
1996 [o_label setAutoresizingMask:NSViewNotSizable ];
1997 [self addSubview: o_label];
1999 /* build the popup */
2000 o_tooltip = [[VLCMain sharedInstance] wrapString:
2001 [[VLCMain sharedInstance]
2002 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2003 ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
2004 [o_label frame].size.width + 3,
2006 [o_popup setAutoresizingMask:NSViewWidthSizable ];
2008 if( o_keys_menu == nil )
2011 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
2012 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
2013 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
2014 POPULATE_A_KEY( o_keys_menu,
2015 [NSString stringWithCString:vlc_keys[i].psz_key_string]
2016 , vlc_keys[i].i_key_code)
2018 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2019 [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->value.i]];
2020 [self addSubview: o_popup];
2026 - (void) alignWithXPosition:(int)i_xPos
2029 NSRect superFrame = [self frame];
2030 frame = [o_label frame];
2031 frame.origin.x = i_xPos - frame.size.width - 3;
2032 [o_label setFrame:frame];
2034 frame = [o_popup frame];
2035 frame.origin.x = i_xPos - 1;
2036 frame.size.width = superFrame.size.width - frame.origin.x + 2;
2037 [o_popup setFrame:frame];
2048 return [o_popup selectedTag];
2052 @implementation ModuleListConfigControl
2053 - (id) initWithItem: (module_config_t *)_p_item
2054 withView: (NSView *)o_parent_view
2056 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
2060 //Fill our array to know how may items we have...
2063 module_config_t *p_end;
2065 NSRect mainFrame = [o_parent_view frame];
2066 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2068 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2069 /* build a list of available modules */
2070 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
2071 for( i_index = 0; i_index < p_list->i_count; i_index++ )
2073 p_parser = (module_t *)p_list->p_values[i_index].p_object;
2074 p_end = p_item + p_parser->confsize;
2076 if( !strcmp( p_parser->psz_object_name, "main" ) )
2079 module_config_t *p_config = p_parser->p_config;
2082 NSString *o_modulelongname, *o_modulename;
2083 NSNumber *o_moduleenabled = nil;
2084 /* Hack: required subcategory is stored in i_min */
2085 if( p_config->i_type == CONFIG_SUBCATEGORY &&
2086 p_config->value.i == _p_item->min.i )
2088 o_modulelongname = [NSString stringWithUTF8String:
2089 p_parser->psz_longname];
2090 o_modulename = [NSString stringWithUTF8String:
2091 p_parser->psz_object_name];
2093 if( _p_item->value.psz &&
2094 strstr( _p_item->value.psz, p_parser->psz_object_name ) )
2095 o_moduleenabled = [NSNumber numberWithBool:YES];
2097 o_moduleenabled = [NSNumber numberWithBool:NO];
2099 [o_modulearray addObject:[NSMutableArray
2100 arrayWithObjects: o_modulename, o_modulelongname,
2101 o_moduleenabled, nil]];
2103 } while( p_item < p_end && p_config++ );
2105 vlc_list_release( p_list );
2107 mainFrame.size.height = 30 + 18 * [o_modulearray count];
2108 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2109 mainFrame.origin.x = LEFTMARGIN;
2110 mainFrame.origin.y = 0;
2111 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2113 i_view_type = CONFIG_ITEM_MODULE_LIST;
2116 if( p_item->psz_text )
2117 o_labelString = [[VLCMain sharedInstance]
2118 localizedString: (char *)p_item->psz_text];
2120 o_labelString = [NSString stringWithString:@""];
2121 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
2122 [o_label setAutoresizingMask:NSViewNotSizable ];
2123 [self addSubview: o_label];
2125 /* build the textfield */
2126 o_tooltip = [[VLCMain sharedInstance] wrapString:
2127 [[VLCMain sharedInstance]
2128 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2129 if( p_item->value.psz )
2130 o_textfieldString = [[VLCMain sharedInstance]
2131 localizedString: (char *)p_item->value.psz];
2133 o_textfieldString = [NSString stringWithString: @""];
2134 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
2135 mainFrame.size.height - 22, mainFrame.size.width -
2136 [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
2137 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2138 [self addSubview: o_textfield];
2142 NSRect s_rc = mainFrame;
2143 s_rc.size.height = mainFrame.size.height - 30;
2144 s_rc.size.width = mainFrame.size.width - 12;
2147 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2148 [o_scrollview setDrawsBackground: NO];
2149 [o_scrollview setBorderType: NSBezelBorder];
2150 [o_scrollview setAutohidesScrollers:YES];
2152 NSTableView *o_tableview;
2153 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2154 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2155 [o_tableview setHeaderView:nil];
2156 /* TODO: find a good way to fix the row height and text size*/
2157 /* FIXME: support for multiple selection... */
2158 // [o_tableview setAllowsMultipleSelection:YES];
2160 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2161 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2162 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2163 [o_dataCell setTitle:@""];
2164 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2165 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2166 initWithIdentifier:[NSString stringWithCString: "Enabled"]];
2167 [o_tableColumn setHeaderCell: o_headerCell];
2168 [o_tableColumn setDataCell: o_dataCell];
2169 [o_tableColumn setWidth:17];
2170 [o_tableview addTableColumn: o_tableColumn];
2172 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2173 o_dataCell = [[NSTextFieldCell alloc] init];
2174 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2175 o_tableColumn = [[NSTableColumn alloc]
2176 initWithIdentifier:[NSString stringWithCString: "Module"]];
2177 [o_tableColumn setHeaderCell: o_headerCell];
2178 [o_tableColumn setDataCell: o_dataCell];
2179 [o_tableColumn setWidth:388 - 17];
2180 [o_tableview addTableColumn: o_tableColumn];
2181 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2182 @"VLC media player module", nil]];
2184 [o_tableview setDataSource:self];
2185 [o_tableview setTarget: self];
2186 [o_tableview setAction: @selector(tableChanged:)];
2187 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2188 NSLeftMouseDraggedMask];
2189 [o_scrollview setDocumentView: o_tableview];
2191 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2192 [self addSubview: o_scrollview];
2199 - (void) alignWithXPosition:(int)i_xPos
2204 - (IBAction)tableChanged:(id)sender
2206 NSString *o_newstring = @"";
2208 for( i = 0 ; i < [o_modulearray count] ; i++ )
2209 if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2212 o_newstring = [o_newstring stringByAppendingString:
2213 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2214 o_newstring = [o_newstring stringByAppendingString:@":"];
2217 [o_textfield setStringValue: [o_newstring
2218 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2223 [o_scrollview release];
2228 - (char *)stringValue
2230 return strdup( [[o_textfield stringValue] cString] );
2235 @implementation ModuleListConfigControl (NSTableDataSource)
2237 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2238 toPasteboard:(NSPasteboard*)pb
2240 // We only want to allow dragging of selected rows.
2241 NSEnumerator *iter = [rows objectEnumerator];
2243 while ((row = [iter nextObject]) != nil)
2245 if (![table isRowSelected:[row intValue]])
2249 [pb declareTypes:[NSArray
2250 arrayWithObject:@"VLC media player module"] owner:nil];
2251 [pb setPropertyList:rows forType:@"VLC media player module"];
2255 - (NSDragOperation)tableView:(NSTableView*)table
2256 validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row
2257 proposedDropOperation:(NSTableViewDropOperation)op
2259 // Make drops at the end of the table go to the end.
2262 row = [table numberOfRows];
2263 op = NSTableViewDropAbove;
2264 [table setDropRow:row dropOperation:op];
2267 // We don't ever want to drop onto a row, only between rows.
2268 if (op == NSTableViewDropOn)
2269 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2270 return NSTableViewDropAbove;
2273 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2274 row:(int)dropRow dropOperation:(NSTableViewDropOperation)op;
2276 NSPasteboard *pb = [info draggingPasteboard];
2277 NSDragOperation srcMask = [info draggingSourceOperationMask];
2284 // Intra-table drag - data is the array of rows.
2285 if (!accepted && (array =
2286 [pb propertyListForType:@"VLC media player module"]) != NULL)
2288 NSEnumerator *iter = nil;
2290 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2292 iter = [array objectEnumerator];
2293 while ((val = [iter nextObject]) != NULL)
2295 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2296 [val intValue]] mutableCopyWithZone:nil];
2297 [o_modulearray removeObject:o_tmp];
2298 [o_modulearray insertObject:o_tmp
2299 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2303 // Select the newly-dragged items.
2304 iter = [array objectEnumerator];
2306 [table deselectAll:self];
2308 [self tableChanged:self];
2309 [table setNeedsDisplay:YES];
2310 // Indicate that we finished the drag.
2314 [table setNeedsDisplay:YES];
2318 // An exception occurred. Uh-oh. Update the track table so that
2319 // it stays consistent, and re-raise the exception.
2321 [localException raise];
2322 [table setNeedsDisplay:YES];
2328 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
2330 return [o_modulearray count];
2333 - (id)tableView:(NSTableView *)aTableView
2334 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2336 if( [[aTableColumn identifier] isEqualToString:
2337 [NSString stringWithCString:"Enabled"]] )
2338 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2339 if( [[aTableColumn identifier] isEqualToString:
2340 [NSString stringWithCString:"Module"]] )
2341 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2346 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2347 forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2349 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2350 withObject: anObject];