16b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi"""
26b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi File:
36b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi JetSegGraph.py
46b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
56b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi Contents and purpose:
66b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi Draws the event graph and progress bar
76b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
86b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi Copyright (c) 2008 Android Open Source Project
96b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi Licensed under the Apache License, Version 2.0 (the "License");
116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi you may not use this file except in compliance with the License.
126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi You may obtain a copy of the License at
136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi      http://www.apache.org/licenses/LICENSE-2.0
156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi Unless required by applicable law or agreed to in writing, software
176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi distributed under the License is distributed on an "AS IS" BASIS,
186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi See the License for the specific language governing permissions and
206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi limitations under the License.
216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi"""
226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviimport  wx
256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviimport logging
266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivifrom JetUtils import *
286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivifrom JetDefs import *
296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel TriviGRAPH_COLORS = [
316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                '#C0E272',
326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                '#85CF89',
336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                '#CF9683',
346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                '#749EDE',
356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                '#9FB5B1',
366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                '#B095BF',
376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                '#FE546D',
386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                '#B3BB97',
396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                '#FFFFB8',
406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                ]
426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel TriviPROGRESS_BAR = '#0000CC'
446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel TriviEOS_BAR = '#095000'
456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel TriviAPP_BAR = '#B3BB97'
466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviclass Marker():
496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    """ Defines portions of the graph for events """
506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def __init__(self, sEventType, iEventId, sName, sStartMbt, sEndMbt, iStartMeasure, ppqn):
516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.sEventType = sEventType
526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iEventId = iEventId
536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.sName = sName
546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.StartMbt = ConvertStrTimeToTuple(sStartMbt)
556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.EndMbt = ConvertStrTimeToTuple(sEndMbt)
566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iStartMeasure = iStartMeasure
576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iStart = 0
586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iEnd = 0
596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iWidth = 0
606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iHeight = 0
616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iTop = 0
626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iUpdate = False
636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.sColor = '#FFFFB8'
646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.ppqn = ppqn
656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.isDirty = False
666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def CalcCoord(self, step, height, ColorFct):
686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Calculates the coordinates in pixels for graphing the shaded regions """
696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        #measures
706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        iStartM = self.StartMbt[0] - self.iStartMeasure
716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        iEndM = self.EndMbt[0] - self.iStartMeasure
726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iStart = step * iStartM
736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iEnd = step * iEndM
746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        #beats
756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iStart = self.iStart + ((step / 4.0) * (self.StartMbt[1]-1))
766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iEnd = self.iEnd + ((step / 4.0) * (self.EndMbt[1]-1))
776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        #ticks
786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        pctTickOfBeat = (float(self.StartMbt[2]) / float(self.ppqn))
796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iStart = self.iStart + ((pctTickOfBeat * (step / 4.0)))
806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        pctTickOfBeat = (float(self.EndMbt[2]) / float(self.ppqn))
816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iEnd = self.iEnd + ((pctTickOfBeat * (step / 4.0)))
826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iWidth = self.iEnd - self.iStart
846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iHeight = height
866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.sColor = ColorFct()
876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iUpdate = False
886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviclass SegmentGraph(wx.Panel):
906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    """ Draws the player graph bar """
916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def __init__(self, parent, pos=wx.DefaultPosition, size=wx.DefaultSize, ClickCallbackFct=None, showLabels=True, showClips=True, showAppEvts=True):
926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        wx.Panel.__init__(self, parent, -1, pos=pos, size=size, style=wx.BORDER_STATIC)
936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iLocationInMs = 0
946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iLengthInMs = 0
956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iLengthInMeasures = 0
966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iMarkerTop = 15
976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iScaleTop = 0
986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iEdges = 5
996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iStartMeasure = 0
1006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iMidiMode = False
1016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.ClickCallbackFct = ClickCallbackFct
1026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iColor = 0
1036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.showLabels = showLabels
1046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.showClips = showClips
1056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.showAppEvts = showAppEvts
1066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, 'Courier')
1086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Markers = []
1106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
1116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_PAINT, self.OnPaint)
1126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_SIZE, self.OnSize)
1136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
1146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        #initialize buffer
1166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.OnSize(None)
1176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def ClearGraph(self):
1196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Clears the graph values """
1206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iLocationInMs = 0
1216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iLengthInMs = 0
1226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iLengthInMeasures = 0
1236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iMarkerTop = 15
1246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iScaleTop = 0
1256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iEdges = 5
1266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iStartMeasure = 0
1276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iMidiMode = False
1286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iColor = 0
1296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Markers = []
1306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iLocationInMs = 0
1316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.DoDrawing()
1326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def LoadSegment(self, segment, segMarker=None, iMidiMode=False, showLabels=True, showClips=True, showAppEvts=True):
1346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Loads up the segment drawing the graph """
1356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if segment is None:
1366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.ClearGraph()
1376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return None
1386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iMidiMode = iMidiMode
1396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.showLabels = showLabels
1406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.showClips = showClips
1416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.showAppEvts = showAppEvts
1426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Markers = []
1436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iLocationInMs = 0
1446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        info = MidiSegInfo(segment)
1456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        #disable graph for debugging
1466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        #return info
1476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iLengthInMs = info.iLengthInMs
1486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.ppqn = info.ppqn
1496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.StartMbt = mbtFct(ConvertStrTimeToTuple(segment.start), 1)
1506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.EndMbt = mbtFct(ConvertStrTimeToTuple(segment.end), 1)
1516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.LengthMbt = None
1526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iStartMeasure = self.StartMbt[0]
1536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iLengthInMeasures = self.EndMbt[0] - self.StartMbt[0]
1546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for jet_event in segment.jetevents:
1566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.showClips and jet_event.event_type == JetDefs.E_CLIP:
1576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.AddMarker(JetDefs.E_CLIP, jet_event.event_id, jet_event.event_name, mbtFct(jet_event.event_start,1), mbtFct(jet_event.event_end,1), self.iStartMeasure, self.ppqn)
1586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            elif jet_event.event_type == JetDefs.E_EOS:
1596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.AddMarker(JetDefs.E_EOS, jet_event.event_id, jet_event.event_name, mbtFct(jet_event.event_end,1), mbtFct(jet_event.event_end,1), self.iStartMeasure, self.ppqn)
1606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            elif self.showAppEvts and jet_event.event_type == JetDefs.E_APP:
1616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.AddMarker(JetDefs.E_APP, jet_event.event_id, jet_event.event_name, mbtFct(jet_event.event_start,1), mbtFct(jet_event.event_end,1), self.iStartMeasure, self.ppqn)
1626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if segMarker is not None:
1646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.AddMarker(JetDefs.E_CLIP, 0, segMarker[0], mbtFct(segMarker[1],1), mbtFct(segMarker[2],1), self.iStartMeasure, self.ppqn)
1656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.DoDrawing()
1676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        return info
1686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def AddMarker(self, sEventType, iEventId, sName, sStartMbt, sEndMbt, iStartMeasure, ppqn):
1706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Adds a marker to the list """
1716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if not CompareMbt(sStartMbt, sEndMbt):
1726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            sEndMbt = sStartMbt
1736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Markers.append(Marker(sEventType, iEventId, sName, sStartMbt, sEndMbt, iStartMeasure, ppqn))
1746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnLeftDown(self, event):
1766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Calls the function assicated with an event """
1776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        pt = event.GetPosition()
1786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for Marker in self.Markers:
1796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if pt[0] >= Marker.iStart and pt[0] <= Marker.iEnd and pt[1] >= Marker.iTop and pt[1] <= Marker.iTop + Marker.iHeight:
1806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if self.ClickCallbackFct != None:
1816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    self.ClickCallbackFct(Marker.sName, Marker.iEventId)
1826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def GetAColor(self):
1846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Gets a color """
1856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        color = GRAPH_COLORS[self.iColor]
1866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iColor = self.iColor + 1
1876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.iColor >= len(GRAPH_COLORS):
1886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.iColor = 0
1896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        return color
1906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnSize(self, event=None):
1926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Repaints for resizing of screen """
1936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if OsWindows():
1946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            # The Buffer init is done here, to make sure the buffer is always
1956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            # the same size as the Window
1966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            Size  = self.GetClientSizeTuple()
1976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            # Make new offscreen bitmap: this bitmap will always have the
1996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            # current drawing in it, so it can be used to save the image to
2006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            # a file, or whatever.
2016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self._Buffer = wx.EmptyBitmap(*Size)
2026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.DoDrawing(None)
2036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if event is not None:
2046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            event.Skip()
2056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnPaint(self, event=None):
2076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Painting of windows """
2086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if OsWindows():
2096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dc = wx.BufferedPaintDC(self, self._Buffer)
2106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        else:
2116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dc = wx.AutoBufferedPaintDC(self)
2126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dc.Background = wx.Brush(wx.WHITE)
2136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.DoDrawing(dc)
2146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def DoDrawing(self, dc=None):
2166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Does the actual drawing of the control """
2176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if dc is None:
2186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if OsWindows():
2196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer)
2206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
2216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc = wx.AutoBufferedPaintDC(self)
2226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc.Background = wx.Brush(wx.WHITE)
2236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dc.Clear()
2256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iColor = 0
2276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        gWidth, gHeight = self.GetSize()
2286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        gWidth = gWidth - (self.iEdges * 2)
2296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        step = int(gWidth / (self.iLengthInMeasures + .01))
2306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for Marker in self.Markers:
2326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            Marker.CalcCoord(step, gHeight, self.GetAColor)
2336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ eliminate overlaps; establish colors """
2356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        iClips = 0
2366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        iMarkers = 0
2376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for index, Marker in enumerate(self.Markers):
2386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if Marker.sEventType == JetDefs.E_CLIP:
2396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                iClips = iClips + 1
2406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                iOverlaps = 1
2416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                for index1, Marker1 in enumerate(self.Markers):
2426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    if Marker.sEventType == JetDefs.E_CLIP:
2436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        if index != index1 and not Marker1.iUpdate:
2446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            if Marker.iStart <= Marker1.iStart and Marker.iEnd <= Marker1.iEnd and Marker.iEnd >= Marker1.iStart:
2456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                iOverlaps = iOverlaps + 1
2466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                Marker.iUpdate = True
2476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                Marker1.iUpdate = True
2486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            if not Marker.iUpdate and Marker.iStart >= Marker1.iStart and Marker.iEnd >= Marker1.iEnd and Marker.iStart <= Marker1.iEnd:
2496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                iOverlaps = iOverlaps + 1
2506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                Marker.iUpdate = True
2516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                Marker1.iUpdate = True
2526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if iOverlaps > 1:
2536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    iTop = 0
2546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    for index1, Marker1 in enumerate(self.Markers):
2556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        if Marker.sEventType == JetDefs.E_CLIP:
2566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            if Marker1.iUpdate:
2576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                Marker1.iHeight = gHeight / iOverlaps
2586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                Marker1.iTop = iTop * Marker1.iHeight
2596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                iTop = iTop + 1
2606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            elif Marker.sEventType == JetDefs.E_APP:
2616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                iMarkers = iMarkers + 1
2626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for Marker in self.Markers:
2646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if Marker.sEventType == JetDefs.E_CLIP:
2656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc.SetPen(wx.Pen(Marker.sColor))
2666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc.SetBrush(wx.Brush(Marker.sColor))
2676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc.DrawRectangle(Marker.iStart + self.iEdges, Marker.iTop, Marker.iWidth, Marker.iHeight)
2686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                width, height = dc.GetTextExtent(Marker.sName)
2696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                k = ((Marker.iStart + Marker.iEnd) / 2) - (width/2) + self.iEdges
2706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if self.showLabels or self.iMidiMode:
2716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    dc.DrawText(Marker.sName, k, ((Marker.iTop+Marker.iHeight/2) - (height*.5)))
2726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if self.iMidiMode:
2736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    self.iMidiModeStart = Marker.iStart
2746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            elif Marker.sEventType == JetDefs.E_EOS:
2756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc.SetPen(wx.Pen(EOS_BAR))
2766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc.SetBrush(wx.Brush(EOS_BAR))
2776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc.DrawRectangle(Marker.iStart + self.iEdges, Marker.iTop, 1, Marker.iHeight)
2786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                width, height = dc.GetTextExtent(Marker.sName)
2796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                k = Marker.iStart - (width/2) + self.iEdges
2806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc.DrawText(Marker.sName, k, ((Marker.iTop+Marker.iHeight/2) - (height*.5)))
2816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            elif Marker.sEventType == JetDefs.E_APP:
2826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc.SetPen(wx.Pen(APP_BAR))
2836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc.SetBrush(wx.Brush(APP_BAR))
2846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc.DrawRectangle(Marker.iStart + self.iEdges, Marker.iTop, 1, Marker.iHeight)
2856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                width, height = dc.GetTextExtent(Marker.sName)
2866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                k = Marker.iStart - (width/2) + self.iEdges
2876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if self.showLabels or self.iMidiMode:
2886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    dc.DrawText(Marker.sName, k, ((Marker.iTop+Marker.iHeight/2) - (height*.5)))
2896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Draw scale """
2926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if gWidth == 0:
2936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            iDiv = 50
2946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        else:
2956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            iDiv = (gWidth)/18
2966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if iDiv == 0:
2976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            iDiv = 50
2986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        scale = ((self.iLengthInMeasures / iDiv) + 1)
2996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if scale == 0:
3006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            scale = 1
3016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        beatStep = step / 4.0
3026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dc.SetFont(self.font)
3036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        j = 0
3046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        lastEnd = 0
3056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        num = range(self.iStartMeasure, self.iStartMeasure + self.iLengthInMeasures + 1, 1)
3066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dc.SetPen(wx.Pen('#5C5142'))
3076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for i in range(0, (self.iLengthInMeasures+1)*step, step):
3086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            k = i + self.iEdges
3096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dc.DrawLine(k, self.iScaleTop, k, self.iScaleTop+8)
3106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if i != (self.iLengthInMeasures)*step:
3116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                for iBeat in range(1,4):
3126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    k = i+(iBeat * beatStep) + self.iEdges
3136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    dc.DrawLine(k, self.iScaleTop, k, self.iScaleTop+4)
3146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            width, height = dc.GetTextExtent(str(num[j]))
3156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            k = i-(width/2) + self.iEdges
3166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if k > lastEnd:
3176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if j == 0 or (j % scale) == 0:
3186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    dc.DrawText(str(num[j]), k, self.iScaleTop+8)
3196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                lastEnd = k + width
3206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            j = j + 1
3216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Updates the location bar in case screen moved or resized """
3236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.iLocationInMs > 0 and self.iLengthInMs > 0:
3246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            iOffset = 0
3256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.iMidiMode:
3266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                iOffset = self.iMidiModeStart
3276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            till = gWidth * (self.iLocationInMs / self.iLengthInMs)
3296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dc.SetPen(wx.Pen(PROGRESS_BAR))
3306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dc.SetBrush(wx.Brush(PROGRESS_BAR))
3316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dc.DrawRectangle(self.iEdges + iOffset, gHeight-6, till, 3)
3326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def UpdateLocation(self, iLocationInMs):
3346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Updates the location bar """
3356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        #disable graph for debugging
3366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        #return info
3376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.iLocationInMs = iLocationInMs
3396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.iLocationInMs > 0 and self.iLengthInMs > 0:
3406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if OsWindows():
3416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer)
3426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
3436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc = wx.AutoBufferedPaintDC(self)
3446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dc.Background = wx.Brush(wx.WHITE)
3456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            iOffset = 0
3476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.iMidiMode:
3486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                iOffset = self.iMidiModeStart
3496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            gWidth, gHeight = self.GetSize()
3516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            gWidth = gWidth - (self.iEdges * 2)
3526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            till = gWidth * (self.iLocationInMs / self.iLengthInMs)
3546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dc.SetPen(wx.Pen(PROGRESS_BAR))
3556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dc.SetBrush(wx.Brush(PROGRESS_BAR))
3566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dc.DrawRectangle(self.iEdges + iOffset, gHeight-6, till, 3)
3576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.isDirty = True
3586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        else:
3596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.isDirty:
3606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.DoDrawing()
3616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.isDirty = False
362