prefs_widgets.m 91.1 KB
Newer Older
1
2
3
4
/*****************************************************************************
 * prefs_widgets.m: Preferences controls
 *****************************************************************************
 * Copyright (C) 2002-2003 VideoLAN
5
 * $Id$
6
 *
Jérome Decoodt's avatar
Jérome Decoodt committed
7
8
 * Authors: Derk-Jan Hartman <hartman at videolan.org>
 *          Jrme Decoodt <djc at videolan.org>
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <stdlib.h>                                      /* malloc(), free() */
#include <string.h>

#include <vlc/vlc.h>
#include "vlc_keys.h"

#include "intf.h"
#include "prefs_widgets.h"

#define PREFS_WRAP 300
#define OFFSET_RIGHT 20
39
#define OFFSET_BETWEEN 2
40

Jérome Decoodt's avatar
Jérome Decoodt committed
41
42
43
44
45
46
47
48
49
#define UPWARDS_WHITE_ARROW                 "\xE2\x87\xA7" 
#define OPTION_KEY                          "\xE2\x8C\xA5"
#define UP_ARROWHEAD                        "\xE2\x8C\x83"
#define PLACE_OF_INTEREST_SIGN              "\xE2\x8C\x98"

#define POPULATE_A_KEY( o_menu, string, value )                             \
{                                                                           \
    NSMenuItem *o_mi;                                                       \
/*  Normal */                                                               \
50
51
    o_mi = [[NSMenuItem alloc] initWithTitle:string                         \
        action:nil keyEquivalent:@""];                                      \
Jérome Decoodt's avatar
Jérome Decoodt committed
52
53
    [o_mi setKeyEquivalentModifierMask:                                     \
        0];                                                                 \
54
if( MACOS_VERSION >= 10.3 )                                                 \
Jérome Decoodt's avatar
Jérome Decoodt committed
55
56
57
58
    [o_mi setAlternate: NO];                                                \
    [o_mi setTag:                                                           \
        ( value )];                                                         \
    [o_menu addItem: o_mi];                                                 \
59
if( MACOS_VERSION >= 10.3 )                                                 \
Jérome Decoodt's avatar
Jérome Decoodt committed
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{                                                                           \
/*  Ctrl */                                                                 \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
            UP_ARROWHEAD                                                    \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
        NSControlKeyMask];                                                  \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
        KEY_MODIFIER_CTRL | ( value )];                                     \
    [o_menu addItem: o_mi];                                                 \
/* Ctrl+Alt */                                                              \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
            UP_ARROWHEAD OPTION_KEY                                         \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
        NSControlKeyMask | NSAlternateKeyMask];                             \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
        (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | ( value )];                \
    [o_menu addItem: o_mi];                                                 \
/* Ctrl+Shift */                                                            \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
            UP_ARROWHEAD UPWARDS_WHITE_ARROW                                \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
       NSControlKeyMask | NSShiftKeyMask];                                  \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
        (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | ( value )];              \
    [o_menu addItem: o_mi];                                                 \
/* Ctrl+Apple */                                                            \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
            UP_ARROWHEAD PLACE_OF_INTEREST_SIGN                             \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
        NSControlKeyMask | NSCommandKeyMask];                               \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
        (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | ( value )];            \
    [o_menu addItem: o_mi];                                                 \
/* Ctrl+Alt+Shift */                                                        \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
            UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW                     \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
        NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask];            \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
119
120
        (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) |       \
             ( value )];                                                    \
Jérome Decoodt's avatar
Jérome Decoodt committed
121
122
123
124
125
126
127
128
129
130
131
    [o_menu addItem: o_mi];                                                 \
/* Ctrl+Alt+Apple */                                                        \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
            UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN                  \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
        NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask];          \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
132
133
        (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) |     \
            ( value )];                                                     \
Jérome Decoodt's avatar
Jérome Decoodt committed
134
135
136
137
138
139
140
141
142
143
144
    [o_menu addItem: o_mi];                                                 \
/* Ctrl+Shift+Apple */                                                      \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
            UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN         \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
        NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask];              \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
145
146
        (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) |   \
            ( value )];                                                     \
Jérome Decoodt's avatar
Jérome Decoodt committed
147
148
149
150
    [o_menu addItem: o_mi];                                                 \
/* Ctrl+Alt+Shift+Apple */                                                  \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
151
152
            UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW                     \
                PLACE_OF_INTEREST_SIGN                                      \
Jérome Decoodt's avatar
Jérome Decoodt committed
153
154
155
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
156
157
        NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask |            \
            NSCommandKeyMask];                                              \
Jérome Decoodt's avatar
Jérome Decoodt committed
158
159
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
160
161
        (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT |        \
            KEY_MODIFIER_COMMAND) | ( value )];                             \
Jérome Decoodt's avatar
Jérome Decoodt committed
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
    [o_menu addItem: o_mi];                                                 \
/* Alt */                                                                   \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
            OPTION_KEY                                                      \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
        NSAlternateKeyMask];                                                \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
        KEY_MODIFIER_ALT | ( value )];                                      \
    [o_menu addItem: o_mi];                                                 \
/* Alt+Shift */                                                             \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
            OPTION_KEY UPWARDS_WHITE_ARROW                                  \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
        NSAlternateKeyMask | NSShiftKeyMask];                               \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
        (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )];               \
    [o_menu addItem: o_mi];                                                 \
/* Alt+Apple */                                                             \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
            OPTION_KEY PLACE_OF_INTEREST_SIGN                               \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
        NSAlternateKeyMask | NSCommandKeyMask];                             \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
        (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )];             \
    [o_menu addItem: o_mi];                                                 \
/* Alt+Shift+Apple */                                                       \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
            OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN           \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
        NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask];            \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
209
210
        (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) |    \
            ( value )];                                                     \
Jérome Decoodt's avatar
Jérome Decoodt committed
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
    [o_menu addItem: o_mi];                                                 \
/* Shift */                                                                 \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
            UPWARDS_WHITE_ARROW                                             \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
        NSShiftKeyMask];                                                    \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
        KEY_MODIFIER_SHIFT | ( value )];                                    \
    [o_menu addItem: o_mi];                                                 \
/* Shift+Apple */                                                           \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
            UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN                      \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
        NSShiftKeyMask | NSCommandKeyMask];                                 \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
        (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )];           \
    [o_menu addItem: o_mi];                                                 \
/* Apple */                                                                 \
    o_mi = [[NSMenuItem alloc] initWithTitle:                               \
        [[NSString stringWithUTF8String:                                    \
        PLACE_OF_INTEREST_SIGN                                              \
        ] stringByAppendingString: string]                                  \
        action:nil keyEquivalent:@""];                                      \
    [o_mi setKeyEquivalentModifierMask:                                     \
        NSCommandKeyMask];                                                  \
    [o_mi setAlternate: YES];                                               \
    [o_mi setTag:                                                           \
        KEY_MODIFIER_COMMAND | ( value )];                                  \
    [o_menu addItem: o_mi];                                                 \
}                                                                           \
}

251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#define ADD_LABEL( o_label, superFrame, x_offset, my_y_offset, label )      \
{                                                                           \
    NSRect s_rc = superFrame;                                               \
    s_rc.size.height = 17;                                                  \
    s_rc.origin.x = x_offset - 3;                                           \
    s_rc.origin.y = superFrame.size.height - 17 + my_y_offset;              \
    o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain];           \
    [o_label setDrawsBackground: NO];                                       \
    [o_label setBordered: NO];                                              \
    [o_label setEditable: NO];                                              \
    [o_label setSelectable: NO];                                            \
    [o_label setStringValue: label];                                        \
    [o_label setFont:[NSFont systemFontOfSize:0]];                          \
    [o_label sizeToFit];                                                    \
}

#define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset,      \
    my_width, tooltip, init_value )                                         \
{                                                                           \
    NSRect s_rc = superFrame;                                               \
    s_rc.origin.x = x_offset;                                               \
    s_rc.origin.y = my_y_offset;                                            \
    s_rc.size.height = 22;                                                  \
    s_rc.size.width = my_width;                                             \
    o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain];       \
    [o_textfield setFont:[NSFont systemFontOfSize:0]];                      \
    [o_textfield setToolTip: tooltip];                                      \
    [o_textfield setStringValue: init_value];                               \
}

#define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset,   \
    tooltip )                                                               \
{                                                                           \
    NSRect s_rc = superFrame;                                               \
    s_rc.origin.x = x_offset + 2;                                           \
    s_rc.origin.y = my_y_offset;                                            \
    s_rc.size.height = 26;                                                  \
    s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x -           \
        (x2_offset);                                                        \
    o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain];            \
    [o_combo setFont:[NSFont systemFontOfSize:0]];                          \
    [o_combo setToolTip: tooltip];                                          \
    [o_combo setUsesDataSource:TRUE];                                       \
    [o_combo setDataSource:self];                                           \
    [o_combo setNumberOfVisibleItems:10];                                   \
    [o_combo setCompletes:YES];                                             \
}

#define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset,      \
    tooltip, title )                                                        \
{                                                                           \
    NSRect s_rc = superFrame;                                               \
    o_button = [[[NSButton alloc] initWithFrame: s_rc] retain];             \
    [o_button setButtonType: NSMomentaryPushInButton];                      \
    [o_button setBezelStyle: NSRoundedBezelStyle];                          \
    [o_button setTitle: title];                                             \
    [o_button setFont:[NSFont systemFontOfSize:0]];                         \
    [o_button sizeToFit];                                                   \
    s_rc = [o_button frame];                                                \
    s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
    s_rc.origin.y = my_y_offset - 6;                                        \
    s_rc.size.width += 12;                                                  \
    [o_button setFrame: s_rc];                                              \
    [o_button setToolTip: tooltip];                                         \
    [o_button setTarget: self];                                             \
    [o_button setAction: @selector(openFileDialog:)];                       \
}

#define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset,   \
    tooltip )                                                               \
{                                                                           \
    NSRect s_rc = superFrame;                                               \
    s_rc.origin.x = x_offset - 1;                                           \
    s_rc.origin.y = my_y_offset;                                            \
    s_rc.size.height = 26;                                                  \
    s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x -           \
        (x2_offset);                                                        \
    o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain];         \
    [o_popup setFont:[NSFont systemFontOfSize:0]];                          \
    [o_popup setToolTip: tooltip];                                          \
}

#define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
    lower, higher )                                                         \
{                                                                           \
    NSRect s_rc = superFrame;                                               \
    s_rc.origin.x = x_offset;                                               \
    s_rc.origin.y = my_y_offset;                                            \
    s_rc.size.height = 23;                                                  \
    s_rc.size.width = 23;                                                   \
    o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain];           \
    [o_stepper setFont:[NSFont systemFontOfSize:0]];                        \
    [o_stepper setToolTip: tooltip];                                        \
    [o_stepper setMaxValue: higher];                                        \
    [o_stepper setMinValue: lower];                                         \
    [o_stepper setTarget: self];                                            \
    [o_stepper setAction: @selector(stepperChanged:)];                      \
    [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |       \
        NSLeftMouseDraggedMask];                                            \
}

#define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width,  \
    tooltip, lower, higher )                                                \
{                                                                           \
    NSRect s_rc = superFrame;                                               \
    s_rc.origin.x = x_offset;                                               \
    s_rc.origin.y = my_y_offset;                                            \
    s_rc.size.height = 21;                                                  \
    s_rc.size.width = my_width;                                             \
    o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain];             \
    [o_slider setFont:[NSFont systemFontOfSize:0]];                         \
    [o_slider setToolTip: tooltip];                                         \
    [o_slider setMaxValue: higher];                                         \
    [o_slider setMinValue: lower];                                          \
}

#define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
    tooltip, init_value, position )                                         \
{                                                                           \
    NSRect s_rc = superFrame;                                               \
    s_rc.size.height = 18;                                                  \
    s_rc.origin.x = x_offset - 2;                                           \
    s_rc.origin.y = superFrame.size.height - 18 + my_y_offset;              \
    o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain];           \
    [o_checkbox setFont:[NSFont systemFontOfSize:0]];                       \
    [o_checkbox setButtonType: NSSwitchButton];                             \
    [o_checkbox setImagePosition: position];                                \
    [o_checkbox setIntValue: init_value];                                   \
    [o_checkbox setTitle: label];                                           \
    [o_checkbox setToolTip: tooltip];                                       \
    [o_checkbox sizeToFit];                                                 \
}

384
385
386
387
@implementation VLCConfigControl
- (id)initWithFrame: (NSRect)frame
{
    return [self initWithFrame: frame
Jérome Decoodt's avatar
Jérome Decoodt committed
388
                    item: nil];
389
390
391
}

- (id)initWithFrame: (NSRect)frame
392
        item: (module_config_t *)_p_item
393
394
395
396
397
{
    self = [super initWithFrame: frame];

    if( self != nil )
    {
398
        p_item = _p_item;
399
        psz_name = strdup( p_item->psz_name );
Jérome Decoodt's avatar
Jérome Decoodt committed
400
        o_label = NULL;
401
        i_type = p_item->i_type;
402
        i_view_type = 0;
403
404
405
406
407
408
        b_advanced = p_item->b_advanced;
        [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
    }
    return (self);
}

409
410
411
412
413
414
415
- (void)setYPos:(int)i_yPos
{
    NSRect frame = [self frame];
    frame.origin.y = i_yPos;
    [self setFrame:frame];
}

416
417
418
419
420
421
422
- (void)dealloc
{
    if( o_label ) [o_label release];
    if( psz_name ) free( psz_name );
    [super dealloc];
}

Jérome Decoodt's avatar
Jérome Decoodt committed
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
+ (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
{
    int i_margin;
    switch( i_curItem )
    {
    case CONFIG_ITEM_STRING:
        switch( i_lastItem )
        {
        case CONFIG_ITEM_STRING:
            i_margin = 8;
            break;
        case CONFIG_ITEM_STRING_LIST:
            i_margin = 7;
            break;
        case CONFIG_ITEM_FILE:
            i_margin = 8;
            break;
        case CONFIG_ITEM_MODULE:
            i_margin = 4;
            break;
        case CONFIG_ITEM_INTEGER:
            i_margin = 7;
            break;
        case CONFIG_ITEM_RANGED_INTEGER:
            i_margin = 5;
            break;
        case CONFIG_ITEM_BOOL:
            i_margin = 7;
            break;
        case CONFIG_ITEM_KEY_BEFORE_10_3:
            i_margin = 7;
            break;
        case CONFIG_ITEM_KEY_AFTER_10_3:
            i_margin = 6;
            break;
        case CONFIG_ITEM_MODULE_LIST:
            i_margin = 8;
            break;
        default:
            i_margin = 20;
            break;
        }
        break;
    case CONFIG_ITEM_STRING_LIST:
        switch( i_lastItem )
        {
        case CONFIG_ITEM_STRING:
            i_margin = 8;
            break;
        case CONFIG_ITEM_STRING_LIST:
            i_margin = 7;
            break;
        case CONFIG_ITEM_FILE:
            i_margin = 6;
            break;
        case CONFIG_ITEM_MODULE:
            i_margin = 4;
            break;
        case CONFIG_ITEM_INTEGER:
            i_margin = 7;
            break;
        case CONFIG_ITEM_RANGED_INTEGER:
            i_margin = 5;
            break;
        case CONFIG_ITEM_BOOL:
            i_margin = 7;
            break;
        case CONFIG_ITEM_KEY_BEFORE_10_3:
            i_margin = 7;
            break;
        case CONFIG_ITEM_KEY_AFTER_10_3:
            i_margin = 6;
            break;
        case CONFIG_ITEM_MODULE_LIST:
            i_margin = 8;
            break;
        default:
            i_margin = 20;
            break;
        }
        break;
    case CONFIG_ITEM_FILE:
        switch( i_lastItem )
        {
        case CONFIG_ITEM_STRING:
            i_margin = 13;
            break;
        case CONFIG_ITEM_STRING_LIST:
            i_margin = 10;
            break;
        case CONFIG_ITEM_FILE:
            i_margin = 9;
            break;
        case CONFIG_ITEM_MODULE:
            i_margin = 9;
            break;
        case CONFIG_ITEM_INTEGER:
            i_margin = 10;
            break;
        case CONFIG_ITEM_RANGED_INTEGER:
            i_margin = 8;
            break;
        case CONFIG_ITEM_BOOL:
            i_margin = 10;
            break;
        case CONFIG_ITEM_KEY_BEFORE_10_3:
            i_margin = 10;
            break;
        case CONFIG_ITEM_KEY_AFTER_10_3:
            i_margin = 9;
            break;
        case CONFIG_ITEM_MODULE_LIST:
            i_margin = 11;
            break;
        default:
            i_margin = 23;
            break;
        }
        break;
    case CONFIG_ITEM_MODULE:
        switch( i_lastItem )
        {
        case CONFIG_ITEM_STRING:
            i_margin = 8;
            break;
        case CONFIG_ITEM_STRING_LIST:
            i_margin = 7;
            break;
        case CONFIG_ITEM_FILE:
            i_margin = 6;
            break;
        case CONFIG_ITEM_MODULE:
            i_margin = 5;
            break;
        case CONFIG_ITEM_INTEGER:
            i_margin = 7;
            break;
        case CONFIG_ITEM_RANGED_INTEGER:
            i_margin = 6;
            break;
        case CONFIG_ITEM_BOOL:
            i_margin = 8;
            break;
        case CONFIG_ITEM_KEY_BEFORE_10_3:
            i_margin = 8;
            break;
        case CONFIG_ITEM_KEY_AFTER_10_3:
            i_margin = 7;
            break;
        case CONFIG_ITEM_MODULE_LIST:
            i_margin = 9;
            break;
        default:
            i_margin = 20;
            break;
        }
        break;
    case CONFIG_ITEM_INTEGER:
        switch( i_lastItem )
        {
        case CONFIG_ITEM_STRING:
            i_margin = 8;
            break;
        case CONFIG_ITEM_STRING_LIST:
            i_margin = 7;
            break;
        case CONFIG_ITEM_FILE:
            i_margin = 6;
            break;
        case CONFIG_ITEM_MODULE:
            i_margin = 4;
            break;
        case CONFIG_ITEM_INTEGER:
            i_margin = 7;
            break;
        case CONFIG_ITEM_RANGED_INTEGER:
            i_margin = 5;
            break;
        case CONFIG_ITEM_BOOL:
            i_margin = 7;
            break;
        case CONFIG_ITEM_KEY_BEFORE_10_3:
            i_margin = 7;
            break;
        case CONFIG_ITEM_KEY_AFTER_10_3:
            i_margin = 6;
            break;
        case CONFIG_ITEM_MODULE_LIST:
            i_margin = 8;
            break;
        default:
            i_margin = 20;
            break;
        }
        break;
    case CONFIG_ITEM_RANGED_INTEGER:
        switch( i_lastItem )
        {
        case CONFIG_ITEM_STRING:
            i_margin = 8;
            break;
        case CONFIG_ITEM_STRING_LIST:
            i_margin = 7;
            break;
        case CONFIG_ITEM_FILE:
            i_margin = 8;
            break;
        case CONFIG_ITEM_MODULE:
            i_margin = 4;
            break;
        case CONFIG_ITEM_INTEGER:
            i_margin = 7;
            break;
        case CONFIG_ITEM_RANGED_INTEGER:
            i_margin = 5;
            break;
        case CONFIG_ITEM_BOOL:
            i_margin = 7;
            break;
        case CONFIG_ITEM_KEY_BEFORE_10_3:
            i_margin = 7;
            break;
        case CONFIG_ITEM_KEY_AFTER_10_3:
            i_margin = 6;
            break;
        case CONFIG_ITEM_MODULE_LIST:
            i_margin = 8;
            break;
        default:
            i_margin = 20;
            break;
        }
        break;
    case CONFIG_ITEM_BOOL:
        switch( i_lastItem )
        {
        case CONFIG_ITEM_STRING:
Jérome Decoodt's avatar
Jérome Decoodt committed
660
            i_margin = 10;
Jérome Decoodt's avatar
Jérome Decoodt committed
661
662
            break;
        case CONFIG_ITEM_STRING_LIST:
Jérome Decoodt's avatar
Jérome Decoodt committed
663
            i_margin = 9;
Jérome Decoodt's avatar
Jérome Decoodt committed
664
665
            break;
        case CONFIG_ITEM_FILE:
Jérome Decoodt's avatar
Jérome Decoodt committed
666
            i_margin = 8;
Jérome Decoodt's avatar
Jérome Decoodt committed
667
668
            break;
        case CONFIG_ITEM_MODULE:
Jérome Decoodt's avatar
Jérome Decoodt committed
669
            i_margin = 6;
Jérome Decoodt's avatar
Jérome Decoodt committed
670
671
            break;
        case CONFIG_ITEM_INTEGER:
Jérome Decoodt's avatar
Jérome Decoodt committed
672
            i_margin = 9;
Jérome Decoodt's avatar
Jérome Decoodt committed
673
674
            break;
        case CONFIG_ITEM_RANGED_INTEGER:
Jérome Decoodt's avatar
Jérome Decoodt committed
675
            i_margin = 7;
Jérome Decoodt's avatar
Jérome Decoodt committed
676
677
            break;
        case CONFIG_ITEM_BOOL:
Jérome Decoodt's avatar
Jérome Decoodt committed
678
            i_margin = 7;
Jérome Decoodt's avatar
Jérome Decoodt committed
679
680
            break;
        case CONFIG_ITEM_KEY_BEFORE_10_3:
Jérome Decoodt's avatar
Jérome Decoodt committed
681
            i_margin = 7;
Jérome Decoodt's avatar
Jérome Decoodt committed
682
683
            break;
        case CONFIG_ITEM_KEY_AFTER_10_3:
Jérome Decoodt's avatar
Jérome Decoodt committed
684
            i_margin = 5;
Jérome Decoodt's avatar
Jérome Decoodt committed
685
686
            break;
        case CONFIG_ITEM_MODULE_LIST:
Jérome Decoodt's avatar
Jérome Decoodt committed
687
            i_margin = 10;
Jérome Decoodt's avatar
Jérome Decoodt committed
688
689
            break;
        default:
Jérome Decoodt's avatar
Jérome Decoodt committed
690
            i_margin = 20;
Jérome Decoodt's avatar
Jérome Decoodt committed
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
            break;
        }
        break;
    case CONFIG_ITEM_KEY_BEFORE_10_3:
        switch( i_lastItem )
        {
        case CONFIG_ITEM_STRING:
            i_margin = 6;
            break;
        case CONFIG_ITEM_STRING_LIST:
            i_margin = 5;
            break;
        case CONFIG_ITEM_FILE:
            i_margin = 4;
            break;
        case CONFIG_ITEM_MODULE:
            i_margin = 2;
            break;
        case CONFIG_ITEM_INTEGER:
            i_margin = 5;
            break;
        case CONFIG_ITEM_RANGED_INTEGER:
            i_margin = 3;
            break;
        case CONFIG_ITEM_BOOL:
            i_margin = 3;
            break;
        case CONFIG_ITEM_KEY_BEFORE_10_3:
            i_margin = 10;
            break;
        case CONFIG_ITEM_KEY_AFTER_10_3:
            i_margin = 6;
            break;
        case CONFIG_ITEM_MODULE_LIST:
            i_margin = 6;
            break;
        default:
            i_margin = 18;
            break;
        }
        break;
    case CONFIG_ITEM_KEY_AFTER_10_3:
        switch( i_lastItem )
        {
        case CONFIG_ITEM_STRING:
            i_margin = 8;
            break;
        case CONFIG_ITEM_STRING_LIST:
            i_margin = 7;
            break;
        case CONFIG_ITEM_FILE:
            i_margin = 6;
            break;
        case CONFIG_ITEM_MODULE:
            i_margin = 6;
            break;
        case CONFIG_ITEM_INTEGER:
            i_margin = 7;
            break;
        case CONFIG_ITEM_RANGED_INTEGER:
            i_margin = 5;
            break;
        case CONFIG_ITEM_BOOL:
            i_margin = 7;
            break;
        case CONFIG_ITEM_KEY_BEFORE_10_3:
            i_margin = 7;
            break;
        case CONFIG_ITEM_KEY_AFTER_10_3:
            i_margin = 8;
            break;
        case CONFIG_ITEM_MODULE_LIST:
            i_margin = 10;
            break;
        default:
            i_margin = 20;
            break;
        }
        break;
    case CONFIG_ITEM_MODULE_LIST:
        switch( i_lastItem )
        {
        case CONFIG_ITEM_STRING:
            i_margin = 10;
            break;
        case CONFIG_ITEM_STRING_LIST:
            i_margin = 7;
            break;
        case CONFIG_ITEM_FILE:
            i_margin = 6;
            break;
        case CONFIG_ITEM_MODULE:
            i_margin = 6;
            break;
        case CONFIG_ITEM_INTEGER:
            i_margin = 9;
            break;
        case CONFIG_ITEM_RANGED_INTEGER:
            i_margin = 5;
            break;
        case CONFIG_ITEM_BOOL:
            i_margin = 7;
            break;
        case CONFIG_ITEM_KEY_BEFORE_10_3:
            i_margin = 7;
            break;
        case CONFIG_ITEM_KEY_AFTER_10_3:
            i_margin = 5;
            break;
        case CONFIG_ITEM_MODULE_LIST:
            i_margin = 8;
            break;
        default:
            i_margin = 20;
            break;
        }
        break;
    default:
        i_margin = 20;
        break;
    }
    return i_margin;
}
814

Jérome Decoodt's avatar
Jérome Decoodt committed
815
816
+ (VLCConfigControl *)newControl: (module_config_t *)_p_item
                      withView: (NSView *)o_parent_view
817
818
{
    VLCConfigControl *p_control = NULL;
819
    switch( _p_item->i_type )
820
821
    {
    case CONFIG_ITEM_STRING:
822
        if( !_p_item->i_list )
823
        {
824
825
            p_control = [[StringConfigControl alloc]
                    initWithItem: _p_item
Jérome Decoodt's avatar
Jérome Decoodt committed
826
                    withView: o_parent_view];
827
828
829
        }
        else
        {
830
831
            p_control = [[StringListConfigControl alloc]
                    initWithItem: _p_item
Jérome Decoodt's avatar
Jérome Decoodt committed
832
                    withView: o_parent_view];
833
834
835
836
        }
        break;
    case CONFIG_ITEM_FILE:
    case CONFIG_ITEM_DIRECTORY:
837
838
        p_control = [[FileConfigControl alloc]
                    initWithItem: _p_item
Jérome Decoodt's avatar
Jérome Decoodt committed
839
                    withView: o_parent_view];
Jérome Decoodt's avatar
Jérome Decoodt committed
840
841
842
        break;
    case CONFIG_ITEM_MODULE:
    case CONFIG_ITEM_MODULE_CAT:
843
844
        p_control = [[ModuleConfigControl alloc]
                    initWithItem: _p_item
Jérome Decoodt's avatar
Jérome Decoodt committed
845
                    withView: o_parent_view];
846
847
        break;
    case CONFIG_ITEM_INTEGER:
848
        if( _p_item->i_list )
849
        {
850
851
            p_control = [[IntegerListConfigControl alloc]
                        initWithItem: _p_item
Jérome Decoodt's avatar
Jérome Decoodt committed
852
                        withView: o_parent_view];
853
        }
854
        else if( _p_item->i_min != 0 || _p_item->i_max != 0 )
855
        {
856
857
            p_control = [[RangedIntegerConfigControl alloc]
                        initWithItem: _p_item
Jérome Decoodt's avatar
Jérome Decoodt committed
858
                        withView: o_parent_view];
859
860
861
        }
        else
        {
862
863
            p_control = [[IntegerConfigControl alloc]
                        initWithItem: _p_item
Jérome Decoodt's avatar
Jérome Decoodt committed
864
                        withView: o_parent_view];
865
866
        }
        break;
Jérome Decoodt's avatar
Jérome Decoodt committed
867
    case CONFIG_ITEM_BOOL:
868
869
        p_control = [[BoolConfigControl alloc]
                    initWithItem: _p_item
Jérome Decoodt's avatar
Jérome Decoodt committed
870
                    withView: o_parent_view];
871
872
        break;
    case CONFIG_ITEM_FLOAT:
873
        if( _p_item->f_min != 0 || _p_item->f_max != 0 )
874
        {
875
876
            p_control = [[RangedFloatConfigControl alloc]
                        initWithItem: _p_item
Jérome Decoodt's avatar
Jérome Decoodt committed
877
                        withView: o_parent_view];
878
879
880
        }
        else
        {
881
882
            p_control = [[FloatConfigControl alloc]
                        initWithItem: _p_item
Jérome Decoodt's avatar
Jérome Decoodt committed
883
                        withView: o_parent_view];
884
885
        }
        break;
Jérome Decoodt's avatar
Jérome Decoodt committed
886
    case CONFIG_ITEM_KEY:
887
        if( MACOS_VERSION < 10.3 )
Jérome Decoodt's avatar
Jérome Decoodt committed
888
        {
889
890
            p_control = [[KeyConfigControlBefore103 alloc]
                        initWithItem: _p_item
Jérome Decoodt's avatar
Jérome Decoodt committed
891
                        withView: o_parent_view];
Jérome Decoodt's avatar
Jérome Decoodt committed
892
893
894
        }
        else
        {
895
896
            p_control = [[KeyConfigControlAfter103 alloc]
                        initWithItem: _p_item
Jérome Decoodt's avatar
Jérome Decoodt committed
897
                        withView: o_parent_view];
Jérome Decoodt's avatar
Jérome Decoodt committed
898
899
900
901
        }
        break;
    case CONFIG_ITEM_MODULE_LIST:
    case CONFIG_ITEM_MODULE_LIST_CAT:
902
903
        p_control = [[ModuleListConfigControl alloc]
                    initWithItem: _p_item
Jérome Decoodt's avatar
Jérome Decoodt committed
904
                    withView: o_parent_view];
905
906
907
908
909
910
911
912
913
        break;
    default:
        break;
    }
    return p_control;
}

- (NSString *)getName
{
914
    return [[VLCMain sharedInstance] localizedString: psz_name];
915
916
917
918
919
920
921
}

- (int)getType
{
    return i_type;
}

922
923
924
925
926
- (int)getViewType
{
    return i_view_type;
}

927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
- (BOOL)isAdvanced
{
    return b_advanced;
}

- (int)intValue
{
    return 0;
}

- (float)floatValue
{
    return 0;
}

- (char *)stringValue
{
    return NULL;
}

Jérome Decoodt's avatar
Jérome Decoodt committed
947
- (void)applyChanges
948
{
Jérome Decoodt's avatar
Jérome Decoodt committed
949
950
    vlc_value_t val;
    switch( p_item->i_type )
951
    {
Jérome Decoodt's avatar
Jérome Decoodt committed
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
    case CONFIG_ITEM_STRING:
    case CONFIG_ITEM_FILE:
    case CONFIG_ITEM_DIRECTORY:
    case CONFIG_ITEM_MODULE:
    case CONFIG_ITEM_MODULE_LIST:
    case CONFIG_ITEM_MODULE_LIST_CAT:
        config_PutPsz( VLCIntf, psz_name, [self stringValue] );
        break;
    case CONFIG_ITEM_KEY:
        /* So you don't need to restart to have the changes take effect */
        val.i_int = [self intValue];
        var_Set( VLCIntf->p_vlc, psz_name, val );
    case CONFIG_ITEM_INTEGER:
    case CONFIG_ITEM_BOOL:
        config_PutInt( VLCIntf, psz_name, [self intValue] );
        break;
    case CONFIG_ITEM_FLOAT:
        config_PutFloat( VLCIntf, psz_name, [self floatValue] );
        break;
971
972
    }
}
Jérome Decoodt's avatar
Jérome Decoodt committed
973
974
975
976
977

- (int)getLabelSize
{
    return [o_label frame].size.width;
}
978
979
980
@end

@implementation StringConfigControl
Jérome Decoodt's avatar
Jérome Decoodt committed
981
982
- (id) initWithItem: (module_config_t *)_p_item
           withView: (NSView *)o_parent_view
983
{
Jérome Decoodt's avatar
Jérome Decoodt committed
984
985
986
987
988
    NSRect mainFrame = [o_parent_view frame];
    NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
    mainFrame.size.height = 22;
    mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
    mainFrame.origin.x = LEFTMARGIN;
Jérome Decoodt's avatar
Jérome Decoodt committed
989
    mainFrame.origin.y = 0;
Jérome Decoodt's avatar
Jérome Decoodt committed
990
991

    if( [super initWithFrame: mainFrame item: _p_item] != nil )
992
    {
993
        i_view_type = CONFIG_ITEM_STRING;
994
995
        /* add the label */
        if( p_item->psz_text )
996
997
            o_labelString = [[VLCMain sharedInstance]
                                localizedString: p_item->psz_text];
Jérome Decoodt's avatar
Jérome Decoodt committed
998
999
1000
1001
        else
            o_labelString = [NSString stringWithString:@""];
        ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
        [o_label setAutoresizingMask:NSViewNotSizable ];
1002
        [self addSubview: o_label];
1003

Jérome Decoodt's avatar
Jérome Decoodt committed
1004
1005
        /* build the textfield */
        o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1006
1007
            [[VLCMain sharedInstance] localizedString: p_item->psz_longtext]
                                         toWidth: PREFS_WRAP];
1008
        if( p_item->psz_value )
1009
1010
            o_textfieldString = [[VLCMain sharedInstance]
                                    localizedString: p_item->psz_value];
Jérome Decoodt's avatar
Jérome Decoodt committed
1011
1012
1013
        else
            o_textfieldString = [NSString stringWithString: @""];
        ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1014
1015
                        0, mainFrame.size.width - [o_label frame].size.width -
                        2, o_textfieldTooltip, o_textfieldString )
Jérome Decoodt's avatar
Jérome Decoodt committed
1016
        [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1017
        [self addSubview: o_textfield];
1018
1019
1020
1021
    }
    return self;
}

Jérome Decoodt's avatar
Jérome Decoodt committed
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
- (void) alignWithXPosition:(int)i_xPos
{
    NSRect frame;
    NSRect superFrame = [self frame];
    frame = [o_label frame];
    frame.origin.x = i_xPos - frame.size.width - 3;
    [o_label setFrame:frame];

    frame = [o_textfield frame];
    frame.origin.x = i_xPos + 2;
    frame.size.width = superFrame.size.width - frame.origin.x - 1;
    [o_textfield setFrame:frame];
}

1036
1037
1038
1039
1040
1041
1042
1043
- (void)dealloc
{
    [o_textfield release];
    [super dealloc];
}

- (char *)stringValue
{
1044
1045
    return strdup( [[VLCMain sharedInstance] delocalizeString:
                        [o_textfield stringValue]] );
1046
1047
1048
1049
}
@end

@implementation StringListConfigControl
Jérome Decoodt's avatar
Jérome Decoodt committed
1050
1051
- (id) initWithItem: (module_config_t *)_p_item
           withView: (NSView *)o_parent_view
1052
{
Jérome Decoodt's avatar
Jérome Decoodt committed
1053
1054
1055
1056
1057
    NSRect mainFrame = [o_parent_view frame];
    NSString *o_labelString, *o_textfieldTooltip;
    mainFrame.size.height = 22;
    mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
    mainFrame.origin.x = LEFTMARGIN;
Jérome Decoodt's avatar
Jérome Decoodt committed
1058
    mainFrame.origin.y = 0;
Jérome Decoodt's avatar
Jérome Decoodt committed
1059
1060

    if( [super initWithFrame: mainFrame item: _p_item] != nil )
1061
1062
    {
        int i_index;
1063
        i_view_type = CONFIG_ITEM_STRING_LIST;
1064
1065
        /* add the label */
        if( p_item->psz_text )
1066
1067
            o_labelString = [[VLCMain sharedInstance]
                                localizedString: p_item->psz_text];
Jérome Decoodt's avatar
Jérome Decoodt committed
1068
1069
1070
1071
        else
            o_labelString = [NSString stringWithString:@""];
        ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
        [o_label setAutoresizingMask:NSViewNotSizable ];
1072
        [self addSubview: o_label];
1073

Jérome Decoodt's avatar
Jérome Decoodt committed
1074
1075
        /* build the textfield */
        o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1076
1077
            [[VLCMain sharedInstance]
                localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
Jérome Decoodt's avatar
Jérome Decoodt committed
1078
1079
1080
        ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
            -2, 0, o_textfieldTooltip )
        [o_combo setAutoresizingMask:NSViewWidthSizable ];
1081
        for( i_index = 0; i_index < p_item->i_list; i_index++ )
1082
1083
            if( p_item->psz_value &&
                !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) )
1084
                [o_combo selectItemAtIndex: i_index];
1085
        [self addSubview: o_combo];
1086
1087
1088
1089
    }
    return self;
}

Jérome Decoodt's avatar
Jérome Decoodt committed
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
- (void) alignWithXPosition:(int)i_xPos
{
    NSRect frame;
    NSRect superFrame = [self frame];
    frame = [o_label frame];
    frame.origin.x = i_xPos - frame.size.width - 3;
    [o_label setFrame:frame];

    frame = [o_combo frame];
    frame.origin.x = i_xPos + 2;
    frame.size.width = superFrame.size.width - frame.origin.x + 2;
    [o_combo setFrame:frame];
}

1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
- (void)dealloc
{
    [o_combo release];
    [super dealloc];
}

- (char *)stringValue
{
    if( [o_combo indexOfSelectedItem] >= 0 )
        return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
    else
1115
1116
        return strdup( [[VLCMain sharedInstance]
                            delocalizeString: [o_combo stringValue]] );
1117
1118
1119
1120
1121
1122
}
@end

@implementation StringListConfigControl (NSComboBoxDataSource)
- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
{
1123
        return p_item->i_list;
1124
1125
1126
1127
1128
1129
}

- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
{
    if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
    {
1130
1131
1132
1133
        return [[VLCMain sharedInstance]
                    localizedString: p_item->ppsz_list_text[i_index]];
    } else return [[VLCMain sharedInstance]
                    localizedString: p_item->ppsz_list[i_index]];
1134
1135
}
@end
Jérome Decoodt's avatar
Jérome Decoodt committed
1136

1137
@implementation FileConfigControl
Jérome Decoodt's avatar
Jérome Decoodt committed
1138
1139
- (id) initWithItem: (module_config_t *)_p_item
           withView: (NSView *)o_parent_view
1140
{
Jérome Decoodt's avatar
Jérome Decoodt committed
1141
    NSRect mainFrame = [o_parent_view frame];
1142
1143
    NSString *o_labelString, *o_buttonTooltip, *o_textfieldString;
    NSString *o_textfieldTooltip;
Jérome Decoodt's avatar
Jérome Decoodt committed
1144
1145
1146
    mainFrame.size.height = 46;
    mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
    mainFrame.origin.x = LEFTMARGIN;
Jérome Decoodt's avatar
Jérome Decoodt committed
1147
    mainFrame.origin.y = 0;
Jérome Decoodt's avatar
Jérome Decoodt committed
1148
1149

    if( [super initWithFrame: mainFrame item: _p_item] != nil )
1150
    {
1151
1152
        i_view_type = CONFIG_ITEM_FILE;

1153
1154
1155
1156
1157
        /* is it a directory */
        b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;

        /* add the label */
        if( p_item->psz_text )
1158
1159
            o_labelString = [[VLCMain sharedInstance]
                                localizedString: p_item->psz_text];
Jérome Decoodt's avatar
Jérome Decoodt committed
1160
1161
1162
1163
        else
            o_labelString = [NSString stringWithString:@""];
        ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString )
        [o_label setAutoresizingMask:NSViewNotSizable ];
1164
        [self addSubview: o_label];
Jérome Decoodt's avatar
Jérome Decoodt committed
1165

1166
        /* build the button */
1167
1168
1169
1170
1171
        o_buttonTooltip = [[VLCMain sharedInstance]
                wrapString: [[VLCMain sharedInstance]
                localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
        ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_buttonTooltip,
                            _NS("Browse...") )
Jérome Decoodt's avatar
Jérome Decoodt committed
1172
1173
        [o_button setAutoresizingMask:NSViewMinXMargin ];
        [self addSubview: o_button];
1174

Jérome Decoodt's avatar
Jérome Decoodt committed
1175
1176
        /* build the textfield */
        o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1177
1178
            [[VLCMain sharedInstance]
                localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
Jérome Decoodt's avatar
Jérome Decoodt committed
1179
        if( p_item->psz_value )
1180
1181
            o_textfieldString = [[VLCMain sharedInstance]
                                    localizedString: p_item->psz_value];
Jérome Decoodt's avatar
Jérome Decoodt committed
1182
1183
        else
            o_textfieldString = [NSString stringWithString: @""];
1184
1185
        ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
                        8 - [o_button frame].size.width,
Jérome Decoodt's avatar
Jérome Decoodt committed
1186
1187
                        o_textfieldTooltip, o_textfieldString )
        [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1188
        [self addSubview: o_textfield];
1189
1190
1191
1192
    }
    return self;
}

Jérome Decoodt's avatar
Jérome Decoodt committed
1193
1194
1195
1196
1197
- (void) alignWithXPosition:(int)i_xPos
{
    ;
}

1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
- (void)dealloc
{
    [o_textfield release];
    [o_button release];
    [super dealloc];
}

- (IBAction)openFileDialog: (id)sender
{
    NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1208
1209
1210

    [o_open_panel setTitle: (b_directory)?
        _NS("Select a directory"):_NS("Select a file")];
1211
1212
    [o_open_panel setPrompt: _NS("Select")];
    [o_open_panel setAllowsMultipleSelection: NO];
1213
1214
    [o_open_panel setCanChooseFiles: !b_directory];
    [o_open_panel setCanChooseDirectories: b_directory];
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
    [o_open_panel beginSheetForDirectory:nil
        file:nil
        types:nil
        modalForWindow:[sender window]
        modalDelegate: self
        didEndSelector: @selector(pathChosenInPanel: 
                        withReturn:
                        contextInfo:)
        contextInfo: nil];
}

1226
1227
- (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
    withReturn:(int)i_return_code contextInfo:(void  *)o_context_info
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
{
    if( i_return_code == NSOKButton )
    {
        NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
        [o_textfield setStringValue: o_path];
    }
}

- (char *)stringValue
{
Jérome Decoodt's avatar
Jérome Decoodt committed
1238
1239
1240
1241
    if( [[o_textfield stringValue] length] != 0)
        return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
    else
        return NULL;
1242
1243
1244
}
@end

Jérome Decoodt's avatar
Jérome Decoodt committed
1245
1246
1247
@implementation ModuleConfigControl
- (id) initWithItem: (module_config_t *)_p_item
           withView: (NSView *)o_parent_view
1248
{
Jérome Decoodt's avatar
Jérome Decoodt committed
1249
1250
1251
1252
1253
    NSRect mainFrame = [o_parent_view frame];
    NSString *o_labelString, *o_popupTooltip;
    mainFrame.size.height = 22;
    mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
    mainFrame.origin.x = LEFTMARGIN;
Jérome Decoodt's avatar
Jérome Decoodt committed
1254
    mainFrame.origin.y = 0;
Jérome Decoodt's avatar
Jérome Decoodt committed
1255
1256

    if( [super initWithFrame: mainFrame item: _p_item] != nil )
1257
    {
Jérome Decoodt's avatar
Jérome Decoodt committed
1258
1259
1260
        int i_index;
        vlc_list_t *p_list;
        module_t *p_parser;
1261
1262
        i_view_type = CONFIG_ITEM_MODULE;

1263
1264
        /* add the label */
        if( p_item->psz_text )
1265
1266
            o_labelString = [[VLCMain sharedInstance]
                                localizedString: p_item->psz_text];
Jérome Decoodt's avatar
Jérome Decoodt committed
1267
1268
1269
1270
        else
            o_labelString = [NSString stringWithString:@""];
        ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
        [o_label setAutoresizingMask:NSViewNotSizable ];
1271
        [self addSubview: o_label];
1272

Jérome Decoodt's avatar
Jérome Decoodt committed
1273
1274
        /* build the popup */
        o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1275
1276
            [[VLCMain sharedInstance]
                localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
Jérome Decoodt's avatar
Jérome Decoodt committed
1277
1278
1279
1280
1281
1282
        ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
            -2, 0, o_popupTooltip )
        [o_popup setAutoresizingMask:NSViewWidthSizable ];
        [o_popup addItemWithTitle: _NS("Default")];
        [[o_popup lastItem] setTag: -1];
        [o_popup selectItem: [o_popup lastItem]];
1283

Jérome Decoodt's avatar
Jérome Decoodt committed
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
        /* build a list of available modules */
        p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
        for( i_index = 0; i_index < p_list->i_count; i_index++ )
        {
            p_parser = (module_t *)p_list->p_values[i_index].p_object ;
            if( p_item->i_type == CONFIG_ITEM_MODULE )
            {
                if( !strcmp( p_parser->psz_capability,
                            p_item->psz_type ) )
                {
                    NSString *o_description = [[VLCMain sharedInstance]
                        localizedString: p_parser->psz_longname];
                    [o_popup addItemWithTitle: o_description];

                    if( p_item->psz_value &&
1299
                !strcmp( p_item->psz_value, p_parser->psz_object_name ) )
Jérome Decoodt's avatar
Jérome Decoodt committed
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
                        [o_popup selectItem:[o_popup lastItem]];
                }
            }
            else
            {
                module_config_t *p_config;
                if( !strcmp( p_parser->psz_object_name, "main" ) )
                      continue;

                p_config = p_parser->p_config;
                if( p_config ) do
                {
                    /* Hack: required subcategory is stored in i_min */
                    if( p_config->i_type == CONFIG_SUBCATEGORY &&
                        p_config->i_value == p_item->i_min )
                    {
                        NSString *o_description = [[VLCMain sharedInstance]
                            localizedString: p_parser->psz_longname];
                        [o_popup addItemWithTitle: o_description];
1319

Jérome Decoodt's avatar
Jérome Decoodt committed
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
                        if( p_item->psz_value && !strcmp(p_item->psz_value,
                                                p_parser->psz_object_name) )
                            [o_popup selectItem:[o_popup lastItem]];
                    }
                } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
            }
        }
        vlc_list_release( p_list );
        [self addSubview: o_popup];
    }
    return self;
}

Jérome Decoodt's avatar
Jérome Decoodt committed
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
- (void) alignWithXPosition:(int)i_xPos
{
    NSRect frame;
    NSRect superFrame = [self frame];
    frame = [o_label frame];
    frame.origin.x = i_xPos - frame.size.width - 3;
    [o_label setFrame:frame];

    frame = [o_popup frame];
    frame.origin.x = i_xPos - 1;
    frame.size.width = superFrame.size.width - frame.origin.x + 2;
    [o_popup setFrame:frame];
}

Jérome Decoodt's avatar
Jérome Decoodt committed
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
- (void)dealloc
{
    [o_popup release];
    [super dealloc];
}

- (char *)stringValue
{
    NSString *newval = [o_popup titleOfSelectedItem];
    char *returnval = NULL;
    int i_index;
    vlc_list_t *p_list;
    module_t *p_parser;

    p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
    for( i_index = 0; i_index < p_list->i_count; i_index++ )
    {
        p_parser = (module_t *)p_list->p_values[i_index].p_object ;
        if( p_item->i_type == CONFIG_ITEM_MODULE )
        {
            if( !strcmp( p_parser->psz_capability,
                    p_item->psz_type ) )
            {
                NSString *o_description = [[VLCMain sharedInstance]
                    localizedString: p_parser->psz_longname];
                if( [newval isEqualToString: o_description] )
                {
                    returnval = strdup(p_parser->psz_object_name);
                    break;
                }
            }
        }
        else
        {
            module_config_t *p_config;
            if( !strcmp( p_parser->psz_object_name, "main" ) )
                  continue;

            p_config = p_parser->p_config;
            if( p_config ) do
            {
                /* Hack: required subcategory is stored in i_min */
                if( p_config->i_type == CONFIG_SUBCATEGORY &&
                    p_config->i_value == p_item->i_min )
                {
                    NSString *o_description = [[VLCMain sharedInstance]
                        localizedString: p_parser->psz_longname];
                    if( [newval isEqualToString: o_description] )
                    {
                        returnval = strdup(p_parser->psz_object_name);
                        break;
                    }
                }
            } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
        }
    }
    vlc_list_release( p_list );
    return returnval;
}
@end

@implementation IntegerConfigControl
- (id) initWithItem: (module_config_t *)_p_item
           withView: (NSView *)o_parent_view
{
    NSRect mainFrame = [o_parent_view frame];
    NSString *o_labelString, *o_tooltip, *o_textfieldString;
    mainFrame.size.height = 23;
    mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
    mainFrame.origin.x = LEFTMARGIN;
Jérome Decoodt's avatar
Jérome Decoodt committed
1417
    mainFrame.origin.y = 0;
Jérome Decoodt's avatar
Jérome Decoodt committed
1418
1419
1420

    if( [super initWithFrame: mainFrame item: _p_item] != nil )
    {
1421
1422
        i_view_type = CONFIG_ITEM_INTEGER;

Jérome Decoodt's avatar
Jérome Decoodt committed
1423
        o_tooltip = [[VLCMain sharedInstance] wrapString:
1424
1425
            [[VLCMain sharedInstance]
                localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
Jérome Decoodt's avatar
Jérome Decoodt committed
1426
1427
1428

        /* add the label */
        if( p_item->psz_text )
1429
1430
            o_labelString = [[VLCMain sharedInstance]
                                localizedString: p_item->psz_text];
Jérome Decoodt's avatar
Jérome Decoodt committed
1431
1432
        else
            o_labelString = [NSString stringWithString:@""];
Jérome Decoodt's avatar
Jérome Decoodt committed
1433
        ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
Jérome Decoodt's avatar
Jérome Decoodt committed
1434
1435
1436
1437
1438
1439
1440
        [o_label setAutoresizingMask:NSViewNotSizable ];
        [self addSubview: o_label];

        /* build the stepper */
        ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
            0, o_tooltip, -1600, 1600)
        [o_stepper setIntValue: p_item->i_value];
Jérome Decoodt's avatar
Jérome Decoodt committed
1441
        [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
Jérome Decoodt's avatar
Jérome Decoodt committed
1442
1443
1444
1445
        [self addSubview: o_stepper];

        /* build the textfield */
        if( p_item->psz_value )
1446
1447
            o_textfieldString = [[VLCMain sharedInstance]
                                    localizedString: p_item->psz_value];
Jérome Decoodt's avatar
Jérome Decoodt committed
1448
1449
1450
1451
        else
            o_textfieldString = [NSString stringWithString: @""];
        ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
            1, 49, o_tooltip, @"" )
1452
1453
1454
1455
1456
1457
        [o_textfield setIntValue: p_item->i_value];
        [o_textfield setDelegate: self];
        [[NSNotificationCenter defaultCenter] addObserver: self
            selector: @selector(textfieldChanged:)
            name: NSControlTextDidChangeNotification
            object: o_textfield];
Jérome Decoodt's avatar
Jérome Decoodt committed
1458
        [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1459
        [self addSubview: o_textfield];
1460
1461
1462
1463
    }
    return self;
}

Jérome Decoodt's avatar
Jérome Decoodt committed
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
- (void) alignWithXPosition:(int)i_xPos
{
    NSRect frame;
    frame = [o_label frame];
    frame.origin.x = i_xPos - frame.size.width - 3;
    [o_label setFrame:frame];

    frame = [o_textfield frame];
    frame.origin.x = i_xPos + 2;
    [o_textfield setFrame:frame];

    frame = [o_stepper frame];
    frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
    [o_stepper setFrame:frame];
}

1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
- (void)dealloc
{
    [o_stepper release];
    [o_textfield release];
    [super dealloc];
}

- (IBAction)stepperChanged:(id)sender
{
    [o_textfield setIntValue: [o_stepper intValue]];
}

- (void)textfieldChanged:(NSNotification *)o_notification
{
    [o_stepper setIntValue: [o_textfield intValue]];
}

Jérome Decoodt's avatar
Jérome Decoodt committed
1497
- (int)intValue
1498
{
Jérome Decoodt's avatar
Jérome Decoodt committed
1499
    return [o_textfield intValue];
1500
1501
1502
1503
1504
1505
}

@end

@implementation IntegerListConfigControl

Jérome Decoodt's avatar
Jérome Decoodt committed
1506
1507
- (id) initWithItem: (module_config_t *)_p_item
           withView: (NSView *)o_parent_view
1508
{
Jérome Decoodt's avatar
Jérome Decoodt committed
1509
1510
1511
1512
1513
    NSRect mainFrame = [o_parent_view frame];
    NSString *o_labelString, *o_textfieldTooltip;
    mainFrame.size.height = 22;
    mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
    mainFrame.origin.x = LEFTMARGIN;
Jérome Decoodt's avatar
Jérome Decoodt committed
1514
    mainFrame.origin.y = 0;
Jérome Decoodt's avatar
Jérome Decoodt committed
1515
1516

    if( [super initWithFrame: mainFrame item: _p_item] != nil )
1517
1518
    {
        int i_index;
1519
1520
        i_view_type = CONFIG_ITEM_STRING_LIST;

1521
1522
        /* add the label */
        if( p_item->psz_text )
1523
1524
            o_labelString = [[VLCMain sharedInstance]
                localizedString: p_item->psz_text];
Jérome Decoodt's avatar
Jérome Decoodt committed
1525
1526
1527
1528
        else
            o_labelString = [NSString stringWithString:@""];
        ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
        [o_label setAutoresizingMask:NSViewNotSizable ];
1529
        [self addSubview: o_label];
1530

Jérome Decoodt's avatar
Jérome Decoodt committed
1531
1532
        /* build the textfield */
        o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1533
1534
            [[VLCMain sharedInstance]
                localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
Jérome Decoodt's avatar
Jérome Decoodt committed
1535
1536
1537
        ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
            -2, 0, o_textfieldTooltip )
        [o_combo setAutoresizingMask:NSViewWidthSizable ];
1538
1539
1540
1541
1542
1543
1544
        for( i_index = 0; i_index < p_item->i_list; i_index++ )
        {
            if( p_item->i_value == p_item->pi_list[i_index] )
            {
                [o_combo selectItemAtIndex: i_index];
            }
        }
1545
        [self addSubview: o_combo];
1546
1547
1548
1549
    }
    return self;
}

Jérome Decoodt's avatar
Jérome Decoodt committed
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
- (void) alignWithXPosition:(int)i_xPos
{
    NSRect frame;
    NSRect superFrame = [self frame];
    frame = [o_label frame];
    frame.origin.x = i_xPos - frame.size.width - 3;
    [o_label setFrame:frame];

    frame = [o_combo frame];
    frame.origin.x = i_xPos + 2;
    frame.size.width = superFrame.size.width - frame.origin.x + 2;
    [o_combo setFrame:frame];
}

1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
- (void)dealloc
{
    [o_combo release];
    [super dealloc];
}

- (int)intValue
{
    if( [o_combo indexOfSelectedItem] >= 0 )
        return p_item->pi_list[[o_combo indexOfSelectedItem]];
    else
        return [o_combo intValue];
}
@end

@implementation IntegerListConfigControl (NSComboBoxDataSource)
- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
{
    return p_item->i_list;
}

- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
{
    if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1588
1589
1590
1591
        return [[VLCMain sharedInstance]
                    localizedString: p_item->ppsz_list_text[i_index]];
    else
        return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1592
1593
1594
1595
}
@end

@implementation RangedIntegerConfigControl
Jérome Decoodt's avatar
Jérome Decoodt committed
1596
1597
- (id) initWithItem: (module_config_t *)_p_item
           withView: (NSView *)o_parent_view
1598
{
Jérome Decoodt's avatar
Jérome Decoodt committed
1599
1600
1601
1602
1603
    NSRect mainFrame = [o_parent_view frame];
    NSString *o_labelString, *o_tooltip;
    mainFrame.size.height = 50;
    mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
    mainFrame.origin.x = LEFTMARGIN;
Jérome Decoodt's avatar
Jérome Decoodt committed
1604
    mainFrame.origin.y = 0;
Jérome Decoodt's avatar
Jérome Decoodt committed
1605
1606

    if( [super initWithFrame: mainFrame item: _p_item] != nil )
1607
    {
1608
1609