1 # Window interface to (some of) the CD player's vital audio functions
5 from stdwinevents
import *
10 stdwin
.setdefscrollbars(0, 0)
11 win
= stdwin
.open('CD')
13 win
.dispatch
= cddispatch
14 mainloop
.register(win
)
18 def cddispatch(type, win
, detail
):
21 elif type == WE_CLOSE
:
22 mainloop
.unregister(win
)
26 elif type == WE_TIMER
:
28 elif type == WE_MOUSE_UP
:
29 left
, top
, right
, bottom
, v1
, v2
= getgeo(win
)
45 state
= win
.player
.getstatus()[0]
48 elif state
in (cd
.playing
, cd
.paused
):
49 win
.player
.togglepause()
59 d
= win
.begindrawing()
64 statedict
= ['ERROR', 'NODISK', 'READY', 'PLAYING', 'PAUSED', 'STILL']
67 left
, top
, right
, bottom
, v1
, v2
= getgeo(win
)
68 d
= win
.begindrawing()
70 box(d
, left
, v1
, right
, v2
, 'Play/Pause')
71 box(d
, left
, v2
, right
, bottom
, 'Stop')
74 def drawstatus(win
, d
):
75 left
, top
, right
, bottom
, v1
, v2
= getgeo(win
)
76 state
, track
, curtime
, abstime
, totaltime
, first
, last
, \
77 scsi_audio
, cur_block
, dummy
= win
.player
.getstatus()
78 if 0 <= state
< len(statedict
):
79 message
= statedict
[state
]
82 message
= message
+ ' track ' + `track`
+ ' of ' + `last`
83 d
.erase((left
, top
), (right
, v1
))
84 box(d
, left
, top
, right
, v1
, message
)
86 def box(d
, left
, top
, right
, bottom
, label
):
87 R
= (left
+1, top
+1), (right
-1, bottom
-1)
88 width
= d
.textwidth(label
)
89 height
= d
.lineheight()
90 h
= (left
+ right
- width
) / 2
91 v
= (top
+ bottom
- height
) / 2
98 (left
, top
), (right
, bottom
) = (0, 0), win
.getwinsize()
99 v1
= top
+ (bottom
- top
) / 3
100 v2
= top
+ (bottom
- top
) * 2 / 3
101 return left
, top
, right
, bottom
, v1
, v2