1 # Window interface to (some of) the CD player's vital audio functions
6 from stdwinevents
import *
11 stdwin
.setdefscrollbars(0, 0)
12 win
= stdwin
.open('CD')
14 win
.dispatch
= cddispatch
15 mainloop
.register(win
)
19 def cddispatch(type, win
, detail
):
22 elif type == WE_CLOSE
:
23 mainloop
.unregister(win
)
27 elif type == WE_TIMER
:
29 elif type == WE_MOUSE_UP
:
30 left
, top
, right
, bottom
, v1
, v2
= getgeo(win
)
46 state
= win
.player
.getstatus()[0]
49 elif state
in (CD
.PLAYING
, CD
.PAUSED
):
50 win
.player
.togglepause()
60 d
= win
.begindrawing()
65 statedict
= ['ERROR', 'NODISK', 'READY', 'PLAYING', 'PAUSED', 'STILL']
68 left
, top
, right
, bottom
, v1
, v2
= getgeo(win
)
69 d
= win
.begindrawing()
71 box(d
, left
, v1
, right
, v2
, 'Play/Pause')
72 box(d
, left
, v2
, right
, bottom
, 'Stop')
75 def drawstatus(win
, d
):
76 left
, top
, right
, bottom
, v1
, v2
= getgeo(win
)
77 state
, track
, curtime
, abstime
, totaltime
, first
, last
, \
78 scsi_audio
, cur_block
, dummy
= win
.player
.getstatus()
79 if 0 <= state
< len(statedict
):
80 message
= statedict
[state
]
83 message
= message
+ ' track ' + `track`
+ ' of ' + `last`
84 d
.erase((left
, top
), (right
, v1
))
85 box(d
, left
, top
, right
, v1
, message
)
87 def box(d
, left
, top
, right
, bottom
, label
):
88 R
= (left
+1, top
+1), (right
-1, bottom
-1)
89 width
= d
.textwidth(label
)
90 height
= d
.lineheight()
91 h
= (left
+ right
- width
) / 2
92 v
= (top
+ bottom
- height
) / 2
99 (left
, top
), (right
, bottom
) = (0, 0), win
.getwinsize()
100 v1
= top
+ (bottom
- top
) / 3
101 v2
= top
+ (bottom
- top
) * 2 / 3
102 return left
, top
, right
, bottom
, v1
, v2