def draw(self, dc, xoffset=0): self.x0 = self.x0 + xoffset pen = wx.Pen(colours.pathBoxBorder) pen.SetWidth(1) dc.SetPen(pen) w = self.getWidth(dc) - 5 h = self.parent.GetClientSize()[1] - 16 dc.DrawRectangle(self.x0 + 5, self.y0 + 8, w, h) dc.GradientFillLinear(wx.Rect(self.x0 + 6, self.y0 + 8, w - 1, h - 1), colours.horPanelGradient1, colours.horPanelGradient2, wx.SOUTH) if self.status == STATUS_SELECTED: dc.SetTextForeground(colours.text_sel_tap) xlen = dc.GetTextExtent(self.text)[0] self.tx = self.x0 + 5 + (0.5 * w) - 0.5 * xlen dc.DrawText(self.text, self.tx, self.ty) dc.SetTextForeground('black') yinc = dc.GetTextExtent(self.text)[1] elif self.status == STATUS_SCROLL: pts, weight = fonts.setTableEntrySelectedFont(dc) xlen = dc.GetTextExtent(self.text)[0] self.tx = self.x0 + 5 + (0.5 * w) - 0.5 * xlen dc.DrawText(self.text, self.tx, self.ty) yinc = dc.GetTextExtent(self.text)[1] fonts.resetFont(dc, pts, weight) elif self.status == STATUS_SELECTED + STATUS_SCROLL: pts, weight = fonts.setTableEntrySelectedFont(dc) dc.SetTextForeground(colours.text_sel_tap) xlen = dc.GetTextExtent(self.text)[0] self.tx = self.x0 + 5 + (0.5 * w) - 0.5 * xlen dc.DrawText(self.text, self.tx, self.ty) dc.SetTextForeground('black') yinc = dc.GetTextExtent(self.text)[1] fonts.resetFont(dc, pts, weight) elif self.status == STATUS_ORDINARY: xlen = dc.GetTextExtent(self.text)[0] self.tx = self.x0 + 5 + (0.5 * w) - 0.5 * xlen dc.DrawText(self.text, self.tx, self.ty) yinc = dc.GetTextExtent(self.text)[1] dc.DrawBitmap(self.parent.getStatusIcon(self.status), self.tx + (xlen * 0.5) - 10, self.ty + yinc - 2) self.x1 = self.x0 + xlen + 10 if self.drawlink: pen = wx.Pen(colours.pathBoxBorder) pen.SetWidth(2) dc.SetPen(pen) dc.DrawLine(self.x0 + 5 + w, 0.5 * self.parent.GetClientSize()[1], self.x0 + 5 + w + 5, 0.5 * self.parent.GetClientSize()[1])
def __drawNote(self,note,xpos,dc,colour): penColour=colour brushColour=colour ypos = self.origin[1]+(8-(int(note)-1))*self.noteRadius if int(note)>4: self.circles.append(stavecircle(xpos,ypos,self.noteRadius,colour=brushColour)) self.lines.append(staveline((xpos-self.noteRadius),ypos,(xpos-self.noteRadius),ypos+self.tailLength,colour=penColour,penWidth=self.lineWidth)) else: self.circles.append(stavecircle(xpos,ypos,self.noteRadius,colour=brushColour)) self.lines.append(staveline((xpos+self.noteRadius)-1,ypos,(xpos+self.noteRadius)-1,ypos-self.tailLength,colour=penColour,penWidth=self.lineWidth)) if self.showNumbers: pts,weight=fonts.setStaffNumbersFont(dc) y=self.origin[1]-dc.GetTextExtent(note)[1] x=self.xpos-1.3*self.noteRadius self.numbers.append(stavenumber(note,x,y,colour=colour)) fonts.resetFont(dc,pts,weight)
def scrolldraw(self,dc,xOffset=0,yOffset=0,xRange=(-10000,10000),yRange=(-10000,10000)): drawutils.setPenColour(dc,self.lineColour) drawutils.setPenWidth(dc,1) for stave in self.staves: for item in stave.lines: item.setXOffset(xOffset) item.setYOffset(yOffset) if xRange: item.setXRange(xRange) item.m_draw(dc) drawutils.setBrushColour(dc,self.noteColour) drawutils.setPenColour(dc,self.noteColour) for stave in self.staves: for item in stave.circles: item.setXOffset(xOffset) item.setYOffset(yOffset) if xRange: item.setXRange(xRange) item.m_draw(dc) for stave in self.staves: for item in stave.text: item.setXOffset(xOffset) item.setYOffset(yOffset) if xRange: item.setXRange(xRange) item.m_draw(dc) pts,weight=fonts.setStaffNumbersFont(dc) for stave in self.staves: for item in stave.numbers: item.setXOffset(xOffset) item.setYOffset(yOffset) if xRange: item.setXRange(xRange) item.m_draw(dc) fonts.resetFont(dc,pts,weight)
def doPaint(self,dc): self.__backgroundDrawing(dc) y=2 x=2 print 'belcanto_panel:doPaint',self.model.words pts,weight=fonts.setFont(dc,ptfactor=0.75) displayText=[] maxWidth=0.95*self.GetClientSize()[0] widthTolerance=0.1*maxWidth #utils.chopString(self.model.get_text(),dc,maxWidth,displayText,widthTolerance,True) utils.chopString2(self.model.get_text(),dc,maxWidth,displayText,0,True) yInc=1.1*dc.GetTextExtent('A')[1] for choppedLine in displayText: dc.DrawText(choppedLine,x,y) print 'BelcantoPanel',choppedLine y=y+yInc self.__borderDrawing(dc) fonts.resetFont(dc,pts,weight)
def draw(self,dc): print 'StaffPanel draw' self.__backgroundDrawing(dc) pts,weight=fonts.setStaffFont(dc) self.height=min([self.GetSize()[1],4*dc.GetFont().GetPointSize()]) self.setOrigin() myStave=stavedrawing.stave(self.origin,self.height,width=self.GetSize()[0],words=self.model.words,notes=self.model.notes,parent=self,fitInWindow=True,interactive=True,matchesNotes=self.model.matchesWord(self.model.notes)) staveLength=myStave.getOverallLength(dc) if staveLength>0.9*self.GetSize()[0]: myStave.setOrigin((0.9*self.GetSize()[0]-staveLength,self.origin[1])) myStave.setColour(colours.staff,colours.staffLines) myStave.draw(dc) # if staveLength>0.9*self.GetSize()[0]: # width=self.GetSize()[0]*(float(self.GetSize()[0])/float(staveLength)) # start=self.GetSize()[0]-width # scrollbar=drawutils.HScrollMeter(start,width,(self.GetSize()[0],10),(0,self.GetSize()[1]-12)) # scrollbar.draw(dc) fonts.resetFont(dc,pts,weight) self.__borderDrawing(dc)
def drawHeader(size,title,dc,position=(0,0),blank=False): print 'drawHeader',title if blank: viewBackground=colours.defaultViewBackground dc.SetPen(wx.Pen(viewBackground)) dc.SetBrush(wx.Brush(viewBackground)) dc.DrawRectangle(position[0],position[1],size[0],20) else: #position=(size[0]*position[0],size[1]*position[1]) titleBarBackground=wx.SystemSettings_GetColour(wx.SYS_COLOUR_ACTIVECAPTION) dc.SetPen(wx.Pen(titleBarBackground)) dc.SetBrush(wx.Brush(titleBarBackground)) dc.DrawRectangle(position[0],position[1],size[0],20) dc.GradientFillLinear(wx.Rect(position[0],position[1],size[0],20),colours.titleBarGradient1,colours.titleBarGradient2,wx.SOUTH) dc.SetPen(wx.Pen(colours.titleBarEdge)) dc.DrawLine(position[0],position[1],size[0],position[1]) dc.DrawLine(position[0],position[1]+20,position[0]+size[0],position[1]+20) dc.SetBrush(wx.Brush('WHITE')) dc.SetPen(wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_CAPTIONTEXT))) pts,weight=fonts.setTitleBarFont(dc) xpos=0.5*(size[0]-dc.GetTextExtent(title)[0]) dc.DrawText(title,xpos,position[1]+3) fonts.resetFont(dc,pts,weight)
def getWidth(self, dc): pts, weight = fonts.setTableEntrySelectedFont(dc) width = 10 + dc.GetTextExtent(self.text)[0] fonts.resetFont(dc, pts, weight) return width
def draw(self,dc): dc.SetTextForeground(colours.dictionaryLabelText) pts,weight=fonts.setDictionaryLabelFont(dc) dc.DrawText(self.label,self.x+10,self.y-10) dc.SetTextForeground('black') fonts.resetFont(dc,pts,weight)
def draw(self,dc): pts,weight=fonts.setTableTitleFont(dc) dc.DrawText(self.text,self.x,self.y) fonts.resetFont(dc,pts,weight)
def draw(self,dc): pts,weight=fonts.setStaffNumbersFont(dc) dc.SetTextForeground(self.colour) if self.__inXRange() and self.__inYRange(): dc.DrawText(self.text,self.x,self.y) fonts.resetFont(dc,pts,weight)
def draw(self, dc): # drawutils.setPenColour(dc,colours.borderGradient1) # drawutils.setBrushColour(dc,colours.borderGradient1) # dc.DrawRectangle(0,0,self.width,self.height) self.gridlines = [] self.parent.truncatedValues = [] self.__setupDimensions(dc) xpos = self.xpos + self.xMargin ypos = self.ypos + self.yMargin drawutils.setPenColour(dc, 'black') if self.maxOffset > 0: for i in range(self.numItems): self.count = self.count + 1 if self.count > self.maxOffset: break rectHeight = min((self.lineSpacing - 1), (self.height - (ypos - 1))) rectHeight = rectHeight + 1 if self.itemList: if i < len(self.itemList): item = self.itemList[i] desc = self.processDescription(item) name = self.processName(item) highlight, scroll_selection, tap_selection, amber_selection = self.__getStatus( i, item) drawutils.setPenColour(dc, wx.Colour(0, 0, 0)) drawutils.setBrushColour(dc, wx.Colour(0, 0, 0)) rect = wx.Rect(1, ypos - 1, self.width, rectHeight) if tap_selection: if scroll_selection: dc.GradientFillLinear(rect, colours.bg_sel_tap, colours.bg_sel_tap, wx.SOUTH) pts, weight = fonts.setTableEntrySelectedFont( dc) self.drawEntry( dc, item, self.__getHighlightLed(highlight), xpos, ypos, desc, name, current=True, tapped=True) fonts.resetFont(dc, pts, weight) else: dc.GradientFillLinear(rect, colours.bg_sel_tap, colours.bg_sel_tap, wx.SOUTH) pts, weight = fonts.setTableEntrySelectedFont( dc) self.drawEntry( dc, item, self.__getHighlightLed(highlight), xpos, ypos, desc, name, tapped=True) fonts.resetFont(dc, pts, weight) elif highlight: if scroll_selection: dc.GradientFillLinear(rect, colours.bg_selGradient1, colours.bg_selGradient2, wx.SOUTH) pts, weight = fonts.setTableEntrySelectedFont( dc) self.drawEntry(dc, item, self.green, xpos, ypos, desc, name, current=True, highlight=True) fonts.resetFont(dc, pts, weight) else: dc.GradientFillLinear(rect, colours.borderGradient1, colours.borderGradient2, wx.SOUTH) self.drawEntry(dc, item, self.green, xpos, ypos, desc, name, highlight=True) elif scroll_selection: dc.GradientFillLinear(rect, colours.bg_selGradient1, colours.bg_selGradient2, wx.SOUTH) pts, weight = fonts.setTableEntrySelectedFont(dc) self.drawEntry(dc, item, self.__getAmberLed(amber_selection), xpos, ypos, desc, name, current=True) fonts.resetFont(dc, pts, weight) else: dc.GradientFillLinear(rect, colours.borderGradient1, colours.borderGradient2, wx.SOUTH) self.drawEntry(dc, item, self.__getAmberLed(amber_selection), xpos, ypos, desc, name) ypos = ypos + self.lineSpacing drawutils.setPenColour(dc, colours.browser_gridlines) for l in self.gridlines: l.draw(dc) drawutils.setPenColour(dc, 'black')