Esempio n. 1
0
    def draw(self, dc, ypos, parent):
        xIndent = 25
        xpos = self.getXPos(dc, parent)
        if self.staves:
            staveHeight = self.staves[0].getStaveHeight(dc)
            height = self.staves[0].getOverallHeight(dc)
            height = height + 0.3 * dc.GetTextExtent('A')[1]
            origin = (xpos, ypos)

            for stave in self.staves:
                if self.status == 'message':
                    stave.setColour(colours.talkerText,
                                    colours.talkerStaffLines)
                elif self.status == 'failed' or self.status == 'err_msg':
                    stave.setColour(colours.error, colours.errorStaffLines)
                stave.setOrigin(origin)
                origin = (xpos + xIndent, origin[1] + height)

            self.overallStaveLength = self.staves[0].getOverallLength(dc)

            if self.music:
                for stave in self.staves:
                    stave.draw(dc)
                if not self.status == '':
                    x = xpos + 10 + self.staves[self.__getNumStaves() -
                                                1].getOverallLength(dc)
                    if self.__getNumStaves() > 1:
                        x = x + xIndent
                    y = self.staves[self.__getNumStaves() - 1].origin[
                        1] + 0.5 * staveHeight - 0.5 * dc.GetTextExtent(
                            self.status)[1]

                    if self.status != 'err_msg':
                        if self.status == 'failed':
                            self.drawingItems.append(
                                drawutils.textItem(self.status,
                                                   x,
                                                   y,
                                                   colour=colours.errorText))
                        else:
                            self.drawingItems.append(
                                drawutils.textItem(self.status,
                                                   x,
                                                   y,
                                                   colour=colours.normalText))

                if self.feedback:
                    y = self.staves[
                        self.__getNumStaves() -
                        1].origin[1] + self.staves[0].getOverallHeight(
                            dc) + 0.3 * dc.GetTextExtent('A')[1]
                    self.feedback.set_origin(xpos, y)
                    self.feedback.set_width(parent.GetSize()[0])
                    self.feedback.draw(dc)

                for di in self.drawingItems:
                    di.draw(dc)
Esempio n. 2
0
    def draw(self, dc, ypos, parent):
        self.drawingItems = []
        xpos = self.getXPos(dc, parent)

        colour = colours.normalText
        if self.status == 'failed' or self.status == 'err_msg':
            colour = colours.errorText
        for row in self.displayText:
            self.drawingItems.append(
                drawutils.textItem(row,
                                   xpos + (self.xspacing / 2),
                                   ypos - dc.GetTextExtent(row)[1],
                                   colour=colour))
            ypos = ypos + dc.GetTextExtent(row)[1]

        for di in self.drawingItems:
            di.draw(dc)
Esempio n. 3
0
    def doDrawing(self, dc):
        self.__backgroundDrawing(dc)
        print 'dictionary: doDrawing'
        self.drawingItems = []
        self.oldXOffset = 0
        self.staveManager.clear()
        size = self.GetClientSize()
        if self.model:
            self.xMargin = 3
            self.yMargin = 10

            xpos = self.xMargin
            ypos = self.yMargin

            dict = self.model.getDict()
            numItems = len(dict)

            space = dc.GetTextExtent('00')[0]
            stavelen = space * 3

            keys = self.model.getKeys()

            if keys:
                labeling = False
                label = ''
                cols = 1
                largestWidth = 0
                widthSum = 0

                for i in range(len(keys)):
                    key = keys[i]
                    if self.model.byWord:
                        music = dict[key]

                        if key[0] == 'a':
                            labeling = True
                        if labeling and label != key[0]:
                            label = key[0]
                            self.drawingItems.append(
                                drawutils.dictionaryLabel(label, xpos, ypos))
                            inc = self.getLineHeight(dc)
                            ypos = ypos + inc
                            lastInc = 0.7 * self.getLineHeight(dc)

                            if ypos + lastInc > self.GetClientSize()[1]:
                                ypos = self.yMargin
                                cols = cols + 1
                                widthSum = widthSum + largestWidth

                                xpos = (self.xMargin) * cols + widthSum
                                largestWidth = 0

                                self.drawingItems.append(
                                    drawutils.divider(xpos, 0, xpos, size[1]))

                    else:
                        music = key

                    origin = (xpos, ypos)
                    staveHeight = 1.6 * dc.GetTextExtent('0')[1]

                    stave = stavedrawing.stave(origin,
                                               staveHeight,
                                               width=stavelen,
                                               words=[(music, '')],
                                               margins=(0.1, 0.1),
                                               translation=False,
                                               numbers=True,
                                               matchesNotes=True)
                    stave.setColour(colours.staff, colours.staffLines)
                    self.staveManager.addStave(stave)

                    textPos = xpos + stavelen + (0.3 * space)
                    if self.model.byWord:
                        self.drawingItems.append(
                            drawutils.textItem(key, textPos, ypos))
                        width = stavelen + (0.3 *
                                            space) + dc.GetTextExtent(key)[0]
                    else:
                        self.drawingItems.append(
                            drawutils.textItem(dict[key], textPos, ypos))
                        width = stavelen + (0.3 * space) + dc.GetTextExtent(
                            dict[key])[0]

                    if width > largestWidth:
                        largestWidth = width

                    inc = self.getLineHeight(dc)
                    ypos = ypos + inc
                    lastInc = 0.7 * self.getLineHeight(dc)

                    if ypos + lastInc > self.GetClientSize()[1]:
                        ypos = self.yMargin
                        cols = cols + 1
                        widthSum = widthSum + largestWidth

                        xpos = (self.xMargin) * cols + widthSum
                        largestWidth = 0

                        self.drawingItems.append(
                            drawutils.divider(xpos, 0, xpos, size[1]))

                cols = cols + 1
                widthSum = widthSum + largestWidth
                xpos = ((self.xMargin) * cols + widthSum)

                self.drawingItems.append(
                    drawutils.divider(xpos, 0, xpos, size[1]))
        self.__drawImpl(dc)
        self.minX = 0
        self.maxX = xpos + 50 - self.GetClientSize()[0]