~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to kmidi/config/tkpanel.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/local/bin/wishx -f
 
2
#
 
3
# TkMidity -- Tcl/Tk Interface for TiMidity
 
4
#       written by Takashi IWAI
 
5
#
 
6
# Tk control panel routine
 
7
#
 
8
 
 
9
#----------------
 
10
# initialize global variables
 
11
#
 
12
proc InitGlobal {} {
 
13
 
 
14
    global Stat tk_patchLevel
 
15
 
 
16
    if [catch {expr $Stat(new_tcltk) == 0 || $Stat(new_tcltk) == 1}] {
 
17
        set Stat(new_tcltk) 0
 
18
        if [regexp "(\[0-9\]+\.\[0-9\]+)" $tk_patchLevel cur] {
 
19
            if {$cur >= 4.0} {
 
20
                set Stat(new_tcltk) 1
 
21
            }
 
22
        }
 
23
    }
 
24
 
 
25
    # time table and volume
 
26
    set Stat(MaxSecs) 0
 
27
    set Stat(LastSec) 0
 
28
    set Stat(TotalTimeStr) "/ 0:00"
 
29
 
 
30
    # message lines
 
31
    set Stat(CurMsgs) 0
 
32
    set Stat(MaxMsgs) 500
 
33
 
 
34
    # current status
 
35
    set Stat(Playing) 0
 
36
    set Stat(Paused) 0
 
37
    set Stat(Blinking) 0
 
38
 
 
39
    # MIDI file list
 
40
    set Stat(CurIdx) -1
 
41
    set Stat(MaxFiles) 0
 
42
    set Stat(FileList) {}
 
43
    set Stat(ShuffleList) {}
 
44
    set Stat(CurFile) "--------"
 
45
    set Stat(NextFile) "--------"
 
46
 
 
47
    global Config
 
48
    # playing mode
 
49
    set Config(Tracing) 0
 
50
    set Config(RepeatPlay) 0
 
51
    set Config(ShufflePlay) 0
 
52
    set Config(AutoStart) 0
 
53
    set Config(AutoExit) 0
 
54
    set Config(ConfirmExit) 1
 
55
 
 
56
    # display configuration
 
57
    set Config(Disp:file) 1
 
58
    set Config(Disp:time) 1
 
59
    set Config(Disp:text) 1
 
60
    set Config(Disp:volume) 1
 
61
    set Config(Disp:button) 1
 
62
    set Config(Disp:trace) 1
 
63
 
 
64
    set Config(CurFileMode) 0
 
65
 
 
66
    # current volume
 
67
    set Config(CurVol) 100
 
68
 
 
69
    wm title . "TkAWEMidi"
 
70
    wm iconname . "TkAWEMidi"
 
71
    global bitmap_path
 
72
    wm iconbitmap . @$bitmap_path/timidity.xbm
 
73
}
 
74
 
 
75
 
 
76
#----------------
 
77
# read a message from stdin
 
78
#
 
79
proc HandleInput {} {
 
80
    global Stat Config
 
81
 
 
82
    set mlist [gets stdin]
 
83
    set msg [lindex $mlist 0]
 
84
 
 
85
    if {$msg == "RSET"} {
 
86
        if {$Config(Tracing)} {
 
87
            TraceReset
 
88
        }
 
89
    } elseif {$msg == "TIME"} {
 
90
        # set total time
 
91
        set csecs [expr [lindex $mlist 1] / 100]
 
92
        set mins [expr $csecs / 60]
 
93
        set secs [expr $csecs % 60]
 
94
        set Stat(TotalTimeStr) [format "/ %d:%02d" $mins $secs]
 
95
        set Stat(MaxSecs) $csecs
 
96
        set tics [expr $csecs / 8]
 
97
        set tics [expr (($tics + 4) / 5) * 5]
 
98
        .body.time.scale configure -tickinterval $tics -to $csecs
 
99
        SetTime 0
 
100
 
 
101
    } elseif {$msg == "MVOL"} {
 
102
        # set master volume
 
103
        SetVolume [lindex $mlist 1]
 
104
 
 
105
    } elseif {$msg == "FILE"} {
 
106
        # set playing file
 
107
        set Stat(CurFile) [retrieve-filename [lindex $mlist 1]]
 
108
        wm title . "TkAWEMidi: $Stat(CurFile)"
 
109
        wm iconname . "TkAWEMidi: $Stat(CurFile)"
 
110
        if {$Config(CurFileMode) == 0} {
 
111
            .body.curfile configure -text "$Stat(CurFile) / 00:00"
 
112
        } else {
 
113
            .body.curfile configure -text "$Stat(CurFile) / -$Stat(TotalTimeStr)"
 
114
        }
 
115
        AppendMsg "------"
 
116
 
 
117
    } elseif {$msg == "LIST"} {
 
118
        # set file list
 
119
        .body.file.list delete 0 end
 
120
        set Stat(MaxFiles) [lindex $mlist 1]
 
121
        set Stat(FileList) {}
 
122
        for {set i 0} {$i < $Stat(MaxFiles)} {incr i} {
 
123
            set file [gets stdin]
 
124
            .body.file.list insert end $file
 
125
            lappend Stat(FileList) $file
 
126
        }
 
127
        # MakeShuffleList
 
128
 
 
129
        set Stat(CurIdx) -1
 
130
        SelectNumber 
 
131
 
 
132
    } elseif {$msg == "PREV"} {
 
133
        # previous file
 
134
        set Stat(CurIdx) [expr $Stat(CurIdx) - 1]
 
135
        if {$Stat(CurIdx) < 0} {set Stat(CurIdx) 0}
 
136
        SelectNumber 
 
137
 
 
138
    } elseif {$msg == "NEXT" || $msg == "TEND"} {
 
139
        # next file
 
140
        incr Stat(CurIdx)
 
141
        if {$Stat(CurIdx) >= $Stat(MaxFiles)} {
 
142
            if {$Config(RepeatPlay)} {
 
143
                set Stat(CurIdx) 0
 
144
            } elseif {$Config(AutoExit)} {
 
145
                QuitCmd
 
146
            } else {
 
147
                StopCmd
 
148
            }
 
149
        }
 
150
        SelectNumber
 
151
 
 
152
    } elseif {$msg == "CMSG"} {
 
153
        # put message
 
154
        set type [lindex $mlist 1]
 
155
        set str [gets stdin]
 
156
        AppendMsg $str
 
157
 
 
158
    } elseif {$msg == "CERR"} {
 
159
        error [format "%s: %s" $Stat(NextFile) [gets stdin]]
 
160
        WriteMsg "NEXT"
 
161
 
 
162
    } elseif {$msg == "QUIT"} {
 
163
        # quit
 
164
        exit
 
165
    } elseif {$msg == "RSTA"} {
 
166
        # restart file
 
167
        SelectNumber
 
168
    }
 
169
}
 
170
 
 
171
 
 
172
#----------------
 
173
# make shuffled list
 
174
#
 
175
proc MakeShuffleList {} {
 
176
    global Stat
 
177
    set tmplist {}
 
178
    for {set i 0} {$i < $Stat(MaxFiles)} {incr i} {
 
179
        lappend tmplist $i
 
180
    }
 
181
    set Stat(ShuffleList) {}
 
182
    set len $Stat(MaxFiles)
 
183
    while {$len > 0} {
 
184
        set pos [my-random $len]
 
185
        lappend Stat(ShuffleList) [lindex $tmplist $pos]
 
186
        set tmplist [lreplace $tmplist $pos $pos]
 
187
        set len [expr $len - 1]
 
188
    }
 
189
}
 
190
 
 
191
#
 
192
# append a string to message buffer
 
193
#
 
194
proc AppendMsg {str} {
 
195
    global Stat
 
196
 
 
197
    incr Stat(CurMsgs)
 
198
    if {$Stat(CurMsgs) >= $Stat(MaxMsgs)} { ClearMsg }
 
199
 
 
200
    if [regexp "^(~)(.*)" $str foo til rem] {
 
201
        set flagnl 0
 
202
    } else {
 
203
        set flagnl 1
 
204
        set rem $str
 
205
    }
 
206
 
 
207
    if $flagnl {
 
208
        .body.text.buf insert end $rem\n
 
209
    } else {
 
210
        .body.text.buf insert end $rem
 
211
    }
 
212
    .body.text.buf yview -pickplace end
 
213
}
 
214
 
 
215
#
 
216
# clear message buffer
 
217
#
 
218
proc ClearMsg {} {
 
219
    global Stat
 
220
    .body.text.buf delete 0.0 end
 
221
    .body.text.buf yview 0
 
222
    set Stat(CurMsgs) 0
 
223
}
 
224
 
 
225
 
 
226
#----------------
 
227
# select the file in listbox and load it
 
228
#
 
229
proc SelectNumber {} {
 
230
    global Stat Config
 
231
    if {$Stat(new_tcltk)} {
 
232
        .body.file.list select clear 0 end
 
233
    } else {
 
234
        .body.file.list select clear
 
235
    }
 
236
    set idx -1
 
237
    if {$Stat(CurIdx) >= 0 && $Stat(CurIdx) < [llength $Stat(FileList)]} {
 
238
        if {$Config(ShufflePlay)} {
 
239
            if {$Stat(ShuffleList) == {}} {
 
240
                MakeShuffleList
 
241
            }
 
242
            set idx [lindex $Stat(ShuffleList) $Stat(CurIdx)]
 
243
        } else {
 
244
            set idx $Stat(CurIdx)
 
245
        }
 
246
        set thefile [lindex $Stat(FileList) $idx]
 
247
        set Stat(NextFile) $thefile
 
248
    }
 
249
    if {$idx >= 0 && ![file exists $thefile]} {
 
250
        warning "Can't open file \"$thefile\"."
 
251
        set idx -1
 
252
    }
 
253
 
 
254
    if {$idx >= 0} {
 
255
        if {$Stat(new_tcltk)} {
 
256
            .body.file.list select set $idx
 
257
        } else {
 
258
            .body.file.list select from $idx
 
259
            .body.file.list select to $idx
 
260
        }
 
261
        .body.curfile configure -text\
 
262
                "Playing: [lindex $Stat(FileList) $idx]"
 
263
        LoadCmd $idx
 
264
        set Stat(Playing) 1
 
265
    } else {
 
266
        SetTime 0
 
267
        .body.curfile configure -text "-------- / 00:00"
 
268
        set Stat(Playing) 0
 
269
        set Stat(Paused) 0
 
270
    }
 
271
    DispButtonPlay
 
272
}
 
273
 
 
274
 
 
275
#
 
276
# update current time
 
277
#
 
278
proc SetTime {val} {
 
279
    global Stat Config
 
280
    if {$Stat(CurIdx) == -1} {
 
281
        return
 
282
    }
 
283
    set Stat(LastSec) $val
 
284
    if {$Config(CurFileMode) == 0} {
 
285
        set curt [sec2time $val]
 
286
        .body.curfile configure\
 
287
                -text "$Stat(CurFile) / $curt"
 
288
    } else {
 
289
        set curt [sec2time [expr $val - $Stat(MaxSecs)]]
 
290
        .body.curfile configure\
 
291
                -text "$Stat(CurFile) / $curt"
 
292
    }
 
293
    set curt [sec2time $val]
 
294
    .body.time.label configure\
 
295
            -text "$curt / $Stat(TotalTimeStr)"
 
296
    .body.time.scale set $val
 
297
    DispButtonPlay
 
298
}
 
299
 
 
300
 
 
301
#
 
302
# colorize buttons with each state
 
303
#
 
304
proc DispButtonPlay {} {
 
305
    global Stat
 
306
    if {$Stat(Playing)} {
 
307
        if {$Stat(Blinking)} {
 
308
            set color green
 
309
            set Stat(Blinking) 0
 
310
        } else {
 
311
            set color red
 
312
            set Stat(Blinking) 1
 
313
        }
 
314
        .body.button.play configure -fg $color -activeforeground $color
 
315
    } else {
 
316
        .body.button.play configure -fg black -activeforeground black
 
317
    }
 
318
 
 
319
    if {$Stat(Playing) && $Stat(Paused)} {
 
320
        .body.button.pause configure -fg red -activeforeground red
 
321
    } else {
 
322
        .body.button.pause configure -fg black -activeforeground black
 
323
    }
 
324
}    
 
325
 
 
326
 
 
327
#
 
328
# update current volume
 
329
#
 
330
proc SetVolume {val} {
 
331
    global Config
 
332
    set Config(CurVol) $val
 
333
    .body.volume.scale set $val
 
334
}
 
335
 
 
336
 
 
337
#----------------
 
338
# write message
 
339
# messages are: PREV, NEXT, QUIT, FWRD, BACK, RSET, STOP
 
340
#       LOAD\n<filename>, JUMP <time>, VOLM <volume>
 
341
#
 
342
 
 
343
proc WriteMsg {str} {
 
344
    puts stdout $str
 
345
    flush stdout
 
346
}
 
347
 
 
348
 
 
349
#----------------
 
350
# callback commands
 
351
#
 
352
 
 
353
#
 
354
# jump to specified time
 
355
#
 
356
proc JumpCmd {val} {
 
357
    global Stat
 
358
    if {$val != $Stat(LastSec)} {
 
359
        WriteMsg [format "JUMP %d" [expr $val * 100]]
 
360
    }
 
361
}
 
362
 
 
363
#
 
364
# change volume amplitude
 
365
#
 
366
proc VolumeCmd {val {force 0}} {
 
367
    global Config
 
368
    if {$val < 0} {set val 0}
 
369
    if {$val > 200} {set val 200}
 
370
    if {$force != 0 || $val != $Config(CurVol)} {
 
371
        WriteMsg [format "VOLM %d" $val]
 
372
    }
 
373
}
 
374
 
 
375
#
 
376
# load the specified file
 
377
#
 
378
proc LoadCmd {idx} {
 
379
    global Stat Config
 
380
    WriteMsg "LOAD"
 
381
    WriteMsg [lindex $Stat(FileList) $idx]
 
382
    AppendMsg ""
 
383
    VolumeCmd $Config(CurVol) 1
 
384
}
 
385
 
 
386
#
 
387
# play the first file
 
388
#
 
389
proc PlayCmd {} {
 
390
    global Stat
 
391
    if {$Stat(Playing) == 0} {
 
392
        WriteMsg "NEXT"
 
393
    }
 
394
}
 
395
 
 
396
#
 
397
# pause music
 
398
#
 
399
proc PauseCmd {} {
 
400
    global Stat
 
401
    if {$Stat(Playing)} {
 
402
        if {$Stat(Paused)} {
 
403
            set Stat(Paused) 0
 
404
        } else {
 
405
            set Stat(Paused) 1
 
406
        }
 
407
        DispButtonPlay
 
408
        WriteMsg "STOP"
 
409
    }
 
410
}
 
411
 
 
412
#
 
413
# stop playing
 
414
#
 
415
proc StopCmd {} {
 
416
    global Stat Config
 
417
    if {$Stat(Playing)} {
 
418
        WriteMsg "QUIT"
 
419
        WriteMsg "XTND"
 
420
        set Stat(CurIdx) -1
 
421
        SelectNumber
 
422
        if {$Config(Tracing)} {
 
423
            TraceReset
 
424
        }
 
425
        wm title . "TkAWEMidi"
 
426
        wm iconname . "TkAWEMidi"
 
427
    }
 
428
}
 
429
 
 
430
#
 
431
# quit TkMidity
 
432
#
 
433
proc QuitCmd {} {
 
434
    global Config Stat
 
435
    if {$Config(AutoExit) || !$Config(ConfirmExit)} {
 
436
        WriteMsg "QUIT"
 
437
        WriteMsg "ZAPP"
 
438
        return
 
439
    }
 
440
    set oldpause $Stat(Paused)
 
441
    if {!$oldpause} {PauseCmd}
 
442
    if {[question "Really Quit TkMidity?" 0]} {
 
443
        WriteMsg "QUIT"
 
444
        WriteMsg "ZAPP"
 
445
        return
 
446
    }
 
447
    if {!$oldpause} {PauseCmd}
 
448
}
 
449
 
 
450
#
 
451
# play previous file
 
452
#
 
453
proc PrevCmd {} {
 
454
    global Stat
 
455
    if {$Stat(Playing)} {
 
456
        WriteMsg "PREV"
 
457
    }
 
458
}
 
459
 
 
460
#
 
461
# play next file
 
462
#
 
463
proc NextCmd {} {
 
464
    global Stat
 
465
    if {$Stat(Playing)} {
 
466
        WriteMsg "NEXT"
 
467
    }
 
468
}
 
469
 
 
470
#
 
471
# forward/backward 2 secs
 
472
#
 
473
proc ForwardCmd {} {
 
474
    global Stat
 
475
    if {$Stat(Playing)} {
 
476
        WriteMsg "FWRD"
 
477
    }
 
478
}
 
479
    
 
480
proc BackwardCmd {} {
 
481
    global Stat
 
482
    if {$Stat(Playing)} {
 
483
        WriteMsg "BACK"
 
484
    }
 
485
}
 
486
 
 
487
 
 
488
#
 
489
# volume up/down
 
490
#
 
491
proc VolUpCmd {} {
 
492
    global Stat Config
 
493
    if {$Stat(Playing)} {
 
494
        VolumeCmd [expr $Config(CurVol) + 5]
 
495
    }
 
496
}
 
497
 
 
498
proc VolDownCmd {} {
 
499
    global Stat Config
 
500
    if {$Stat(Playing)} {
 
501
        VolumeCmd [expr $Config(CurVol) - 5]
 
502
    }
 
503
}
 
504
 
 
505
#----------------
 
506
# display configured tables
 
507
#
 
508
proc DispTables {} {
 
509
    global Config
 
510
    set allitems {file time text volume button trace}
 
511
 
 
512
    foreach i $allitems {
 
513
        pack forget .body.$i
 
514
        if {$Config(Disp:$i)} {
 
515
            pack .body.$i -side top -fill x
 
516
        } 
 
517
    }
 
518
}
 
519
 
 
520
#
 
521
# save configuration and playing mode
 
522
#
 
523
proc SaveConfig {} {
 
524
    global Config ConfigFile
 
525
    set fd [open $ConfigFile w]
 
526
    if {$fd != ""} {
 
527
        puts $fd "global Config"
 
528
        foreach i [array names Config] {
 
529
            puts $fd "set Config($i) $Config($i)"
 
530
        }
 
531
        close $fd
 
532
    }
 
533
}
 
534
 
 
535
#
 
536
# load configuration file
 
537
#
 
538
proc LoadConfig {} {
 
539
    global ConfigFile Stat
 
540
    catch {source $ConfigFile}
 
541
}
 
542
 
 
543
#
 
544
# from command line
 
545
#
 
546
proc InitCmdLine {argc argv} {
 
547
    global Config
 
548
    set Config(Disp:trace) 0
 
549
    for {set i 0} {$i < $argc} {incr i} {
 
550
        if {[lindex $argv $i] == "-mode"} {
 
551
            incr i
 
552
            set mode [lindex $argv $i]
 
553
            if {$mode == "trace"} {
 
554
                set Config(Tracing) 1
 
555
                set Config(Disp:trace) 1
 
556
            } elseif {$mode == "shuffle"} {
 
557
                set Config(ShufflePlay) 1
 
558
            } elseif {$mode == "normal"} {
 
559
                set Config(ShufflePlay) 0
 
560
            } elseif {$mode == "autostart"} {
 
561
                set Config(AutoStart) 1
 
562
            } elseif {$mode == "autoexit"} {
 
563
                set Config(AutoExit) 1
 
564
            } elseif {$mode == "repeat"} {
 
565
                set Config(RepeatPlay) 1
 
566
            }
 
567
        }
 
568
    }
 
569
}
 
570
 
 
571
 
 
572
#
 
573
# selection callback of the playing file from listbox
 
574
#
 
575
proc SelectList {lw pos} {
 
576
    global Config Stat
 
577
    set idx [$lw nearest $pos]
 
578
    if {$idx >= 0 && $idx < $Stat(MaxFiles)} {
 
579
        if {$Config(ShufflePlay)} {
 
580
            set found [lsearch -exact $Stat(ShuffleList) $idx]
 
581
            if {$found != -1} {
 
582
                set Stat(CurIdx) $found
 
583
            }
 
584
        } else {
 
585
            set Stat(CurIdx) $idx
 
586
        }
 
587
        set Stat(Playing) 1
 
588
        SelectNumber
 
589
    }
 
590
}
 
591
    
 
592
 
 
593
#
 
594
#
 
595
#
 
596
proc OpenFiles {} {
 
597
    global Stat
 
598
    set files [filebrowser .browser "" "*.mid*"]
 
599
    if {$files != ""} {
 
600
        set Stat(MaxFiles) [expr $Stat(MaxFiles) + [llength $files]]
 
601
        foreach i $files {
 
602
            .body.file.list insert end $i
 
603
            lappend Stat(FileList) $i
 
604
        }
 
605
        # MakeShuffleList
 
606
    }
 
607
}
 
608
 
 
609
#
 
610
#
 
611
#
 
612
proc CloseFiles {} {
 
613
    global Stat
 
614
    if {[question "Really Clear List?" 0]} {
 
615
        StopCmd
 
616
        .body.file.list delete 0 end
 
617
        set Stat(MaxFiles) 0
 
618
        set Stat(FileList) {}
 
619
        set Stat(SuffleList) {}
 
620
    }
 
621
}
 
622
 
 
623
proc ToggleCurFileMode {} {
 
624
    global Config Stat
 
625
    if {$Config(CurFileMode) == 0} {
 
626
        set Config(CurFileMode) 1
 
627
    } else {
 
628
        set Config(CurFileMode) 0
 
629
    }
 
630
    SetTime $Stat(LastSec)
 
631
}
 
632
 
 
633
#----------------
 
634
# create main window
 
635
#
 
636
 
 
637
proc CreateWindow {} {
 
638
    global Config Stat
 
639
 
 
640
    # menu bar
 
641
    frame .menu -relief raised -bd 1
 
642
    pack .menu -side top -expand 1 -fill x
 
643
 
 
644
    # File menu
 
645
    menubutton .menu.file -text "File" -menu .menu.file.m\
 
646
            -underline 0
 
647
    menu .menu.file.m
 
648
    .menu.file.m add command -label "Open Files" -underline 0\
 
649
            -command OpenFiles
 
650
    .menu.file.m add command -label "Clear List" -underline 0\
 
651
            -command CloseFiles
 
652
    .menu.file.m add command -label "Save Config" -underline 0\
 
653
            -command SaveConfig
 
654
    .menu.file.m add command -label "About" -underline 0\
 
655
            -command {
 
656
        information "TkMidity -- TiMidty Tcl/Tk Version\n  written by T.IWAI"
 
657
    }
 
658
    .menu.file.m add command -label "Quit" -underline 0\
 
659
            -command QuitCmd
 
660
 
 
661
    # Mode menu
 
662
    menubutton .menu.mode -text "Mode" -menu .menu.mode.m\
 
663
            -underline 0
 
664
    menu .menu.mode.m
 
665
    .menu.mode.m add check -label "Repeat" -underline 0\
 
666
            -variable Config(RepeatPlay)
 
667
    .menu.mode.m add check -label "Shuffle" -underline 0\
 
668
            -variable Config(ShufflePlay) -command {
 
669
        if {$Config(ShufflePlay)} {MakeShuffleList}
 
670
    }
 
671
    .menu.mode.m add check -label "Auto Start" -underline 5\
 
672
            -variable Config(AutoStart)
 
673
    .menu.mode.m add check -label "Auto Exit" -underline 5\
 
674
            -variable Config(AutoExit)
 
675
    .menu.mode.m add check -label "Confirm Quit" -underline 0\
 
676
            -variable Config(ConfirmExit)
 
677
 
 
678
    # Display menu
 
679
    menubutton .menu.disp -text "Display" -menu .menu.disp.m\
 
680
            -underline 0
 
681
    menu .menu.disp.m
 
682
    .menu.disp.m add check -label "File List" -underline 0\
 
683
            -variable Config(Disp:file) -command "DispTables"
 
684
    .menu.disp.m add check -label "Time" -underline 0\
 
685
            -variable Config(Disp:time) -command "DispTables"
 
686
    .menu.disp.m add check -label "Messages" -underline 0\
 
687
            -variable Config(Disp:text) -command "DispTables"
 
688
    .menu.disp.m add check -label "Volume" -underline 0\
 
689
            -variable Config(Disp:volume) -command "DispTables"
 
690
    .menu.disp.m add check -label "Buttons" -underline 0\
 
691
            -variable Config(Disp:button) -command "DispTables"
 
692
    if {$Config(Tracing)} {
 
693
        .menu.disp.m add check -label "Trace" -underline 1\
 
694
                -variable Config(Disp:trace) -command "DispTables"
 
695
    }
 
696
 
 
697
    pack .menu.file .menu.mode .menu.disp -side left
 
698
 
 
699
    # display body
 
700
    if {$Stat(new_tcltk)} {
 
701
        frame .body -relief flat
 
702
    } else {
 
703
        frame .body -relief raised -bd 1 
 
704
    }
 
705
    pack .body -side top -expand 1 -fill both
 
706
 
 
707
    # current playing file
 
708
    button .body.curfile -text "-------- / 00:00" -relief ridge\
 
709
            -command "ToggleCurFileMode"
 
710
    pack .body.curfile -side top -expand 1 -fill x
 
711
 
 
712
    # playing files list
 
713
    frame .body.file -relief raised -bd 1
 
714
    scrollbar .body.file.bar -relief sunken\
 
715
            -command ".body.file.list yview"
 
716
    pack .body.file.bar -side right -fill y
 
717
    if {$Stat(new_tcltk)} {
 
718
        listbox .body.file.list -width 36 -height 10 -relief sunken -bd 2\
 
719
                -yscroll ".body.file.bar set"
 
720
    } else {
 
721
        listbox .body.file.list -geometry 36x10 -relief sunken -bd 2\
 
722
                -yscroll ".body.file.bar set"
 
723
    }
 
724
    bind .body.file.list <Button-1> {SelectList %W %y}
 
725
 
 
726
    pack .body.file.list -side top -expand 1 -fill both
 
727
 
 
728
    # time label and scale
 
729
    frame .body.time -relief raised -bd 1
 
730
    label .body.time.label -text "0:00 / 0:00"
 
731
    pack .body.time.label -side top
 
732
    scale .body.time.scale -orient horizontal -length 280\
 
733
            -from 0 -to 100 -tickinterval 10
 
734
    bind .body.time.scale <ButtonRelease-1> {JumpCmd [%W get]}
 
735
    pack .body.time.scale -side bottom -expand 1 -fill x
 
736
 
 
737
    # text browser
 
738
    frame .body.text -relief raised -bd 1
 
739
    scrollbar .body.text.bar -relief sunken\
 
740
            -command ".body.text.buf yview"
 
741
    pack .body.text.bar -side right -fill y
 
742
    text .body.text.buf -width 36 -height 12 -relief sunken -bd 2\
 
743
            -wrap word -yscroll ".body.text.bar set"
 
744
    bind .body.text.buf <Button-1> { }
 
745
    bind .body.text.buf <Any-Key> { }
 
746
    pack .body.text.buf -side top -expand 1 -fill both
 
747
    button .body.text.clear -text "Clear"\
 
748
            -command ClearMsg
 
749
    pack .body.text.clear -side bottom
 
750
 
 
751
    # volume label and scale
 
752
    frame .body.volume -relief raised -bd 1
 
753
    label .body.volume.label -text "Volume:"
 
754
    pack .body.volume.label -side top
 
755
    scale .body.volume.scale -orient horizontal -length 280\
 
756
            -from 0 -to 200 -tickinterval 25\
 
757
            -showvalue true -label "Volume"\
 
758
            -command VolumeCmd
 
759
    pack .body.volume.scale -side bottom -expand 1 -fill x
 
760
 
 
761
    # buttons
 
762
    global bitmap_path
 
763
    frame .body.button -relief raised -bd 1
 
764
    button .body.button.play -bitmap @$bitmap_path/play.xbm\
 
765
            -command "PlayCmd"
 
766
    button .body.button.stop -bitmap @$bitmap_path/stop.xbm\
 
767
            -command "StopCmd"
 
768
    button .body.button.prev -bitmap @$bitmap_path/tprev.xbm\
 
769
            -command "PrevCmd"
 
770
    button .body.button.back -bitmap @$bitmap_path/tback.xbm\
 
771
            -command "BackwardCmd"
 
772
    button .body.button.fwrd -bitmap @$bitmap_path/fwrd.xbm\
 
773
            -command "ForwardCmd"
 
774
    button .body.button.next -bitmap @$bitmap_path/tnext.xbm\
 
775
            -command "NextCmd"
 
776
    button .body.button.pause -bitmap @$bitmap_path/tpause.xbm\
 
777
            -command "PauseCmd"
 
778
    button .body.button.quit -bitmap @$bitmap_path/tquit.xbm\
 
779
            -command "QuitCmd"
 
780
    pack .body.button.play .body.button.pause\
 
781
            .body.button.prev .body.button.back\
 
782
            .body.button.stop\
 
783
            .body.button.fwrd .body.button.next\
 
784
            .body.button.quit\
 
785
            -side left -ipadx 4 -pady 2 -fill x
 
786
 
 
787
    if {$Config(Tracing)} {
 
788
        # trace display
 
789
        TraceCreate
 
790
    }
 
791
    TraceUpdate
 
792
 
 
793
    # pack all items
 
794
    DispTables
 
795
 
 
796
    focus .
 
797
    tk_menuBar .menu .menu.file .menu.mode .menu.disp
 
798
    bind . <Key-Right> "ForwardCmd"
 
799
    bind . <Key-n> "NextCmd"
 
800
    bind . <Key-Left> "BackwardCmd"
 
801
    bind . <Key-p> "PrevCmd"
 
802
    bind . <Key-s> "PauseCmd"
 
803
    bind . <Key-Down> "VolDownCmd"
 
804
    bind . <Key-v> "VolDownCmd"
 
805
    bind . <Key-Up> "VolUpCmd"
 
806
    bind . <Key-V> "VolUpCmd"
 
807
    bind . <Key-space> "PauseCmd"
 
808
    bind . <Return> "PlayCmd"
 
809
    bind . <Key-c> "StopCmd"
 
810
    bind . <Key-q> "QuitCmd"
 
811
 
 
812
    VolumeCmd $Config(CurVol) 1
 
813
}