def getTextFont(self): font = getattr(self, 'font', None) if font is None: fontsize = styles.cfg.get('triagebuttons', 'FontSize.%s' % wx.Platform) or \ styles.cfg.get('triagebuttons', 'FontSize') or "10" fontweight = styles.cfg.get('triagebuttons', 'FontWeight.%s' % wx.Platform) or \ styles.cfg.get('triagebuttons', 'FontWeight') or wx.BOLD font = self.font = Styles.getFont(size=int(fontsize), weight=int(fontweight)) return font
def __init__(self, parent, id, timeCharStyle, eventCharStyle, linkCharStyle, *arguments, **keywords): super(wxPreviewArea, self).__init__(parent, id, *arguments, **keywords) self.visibleEvents = [] self._avoidDrawing = False self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_LEFT_DCLICK, self.OnDClick) self.Bind(wx.EVT_LEFT_DOWN, self.OnClick) if wx.Platform == "__WXMAC__": self.Bind(wx.EVT_SIZE, self.OnSize) self.SetWindowStyle(PLATFORM_BORDER) self.useToday = True self.maximized = False self.titleFont = Styles.getFont(timeCharStyle) self.timeFont = Styles.getFont(timeCharStyle) self.eventFont = Styles.getFont(eventCharStyle) self.linkFont = Styles.getFont(linkCharStyle) self.labelPosition = -1 # Note that we haven't measured things yet.
def __init__(self, parent, id, timeCharStyle, eventCharStyle, linkCharStyle, *arguments, **keywords): super(wxPreviewArea, self).__init__(parent, id, *arguments, **keywords) self.visibleEvents = [] self._avoidDrawing = False self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_LEFT_DCLICK, self.OnDClick) self.Bind(wx.EVT_LEFT_DOWN, self.OnClick) if wx.Platform == '__WXMAC__': self.Bind(wx.EVT_SIZE, self.OnSize) self.SetWindowStyle(PLATFORM_BORDER) self.useToday = True self.maximized = False self.titleFont = Styles.getFont(timeCharStyle) self.timeFont = Styles.getFont(timeCharStyle) self.eventFont = Styles.getFont(eventCharStyle) self.linkFont = Styles.getFont(linkCharStyle) self.labelPosition = -1 # Note that we haven't measured things yet.
def __init__(self, *arguments, **keywords): super(wxPreviewArea, self).__init__(*arguments, **keywords) self.currentDaysItems = [] self.Bind(wx.EVT_PAINT, self.OnPaint) charStyle = Styles.CharacterStyle() #see Bug 3625 charStyle.fontSize = 11 self.font = Styles.getFont(charStyle) self.fontHeight = Styles.getMeasurements(self.font).height self.text = ""
prefix, theText, isSample = self.GetTextToDraw(item, attributeName) # We'll draw the sample or prefix in gray (unless it's part of the # selection, in which case we'll leave it white) if not isInSelection and (isSample or prefix is not None): oldForeground = dc.GetTextForeground() dc.SetTextForeground (wx.SystemSettings.GetColour (wx.SYS_COLOUR_GRAYTEXT)) haveText = len(theText) > 0 if (prefix is not None) or haveText: # Draw inside the lines. dc.SetBackgroundMode (wx.TRANSPARENT) rect.Inflate (-1, -1) dc.SetClippingRect (rect) textFont = Styles.getFont(grid.blockItem.characterStyle) textMeasurements = Styles.getMeasurements(textFont) textHeight = textMeasurements.height textTop = (rect.GetHeight() - textHeight) / 2 if prefix is not None: # Match up baselines prefixFont = Styles.getFont(grid.blockItem.prefixCharacterStyle) prefixMeasurements = Styles.getMeasurements(prefixFont) prefixHeight = prefixMeasurements.height prefixTop = textTop + ((textHeight - textMeasurements.descent) - (prefixHeight - prefixMeasurements.descent)) dc.SetFont(prefixFont) width = DrawingUtilities.DrawClippedTextWithDots(dc, prefix, rect, top=prefixTop)
def __init__(self, *arguments, **keywords): super(wxMultiWeekCanvas, self).__init__(*arguments, **keywords) # default to showing 7 days -- HELPME is there a better idiom for this? self._weeks = [ MultiWeekWeek(), MultiWeekWeek(), MultiWeekWeek(), MultiWeekWeek(), MultiWeekWeek(), MultiWeekWeek() ] # how many days are visible for each week self._visibleDaysPerWeek = 7 # what day is at the left side of a week (0=Sun, 1=Mon, ... 6=Sat) self._firstVisibleDay = 0 # how many weeks to display - will always be < self.visibleWeeks self._visibleWeekCount = 6 self._dayMargin = (3, 2) # turn off editor self.editor = None # track multi-day events self._multiDayEvents = [] # keep track of available "slots" for drawing events self._eventSlots = SparseMatrix() # should we use the multiWeekControl's column positions, or # calculate our own? self._shouldCalculateColumnPositions = False # rendering self.styles = Block.Block.findBlockByName("MultiWeekCalendarView") self._dayPen = self.styles.minorLinePen self._weekPen = self._dayPen self._noonStrokePen = wx.Pen(wx.Colour(100, 100, 100, 255), 1) self._noonStrokePen.SetCap(wx.CAP_BUTT) self._weekBrush = wx.Brush(wx.Colour(255, 255, 255, 128)) # 128 == half transparent self._eraseBrush = wx.Brush(wx.Colour(255, 255, 255)) self._erasePen = wx.Pen("white", 1) self._zeroPen = wx.Pen("white", 0) self._thisMonthColour = wx.Colour(0, 0, 0, 255) self._otherMonthColour = wx.Colour(128, 128, 128, 128) self._otherMonthBrush = wx.Brush(wx.Colour(0, 0, 0, 128)) self._otherMonthAllDayBrush = wx.Brush(wx.Colour(225, 225, 225, 128)) self._textBrush = wx.Brush(wx.Colour(255, 255, 255, 128)) # 128 == half transparent self._textPen = self._dayPen self._font = self.styles.eventLabelFont self._timeFont = self.styles.eventTimeFont self._textFont = self.styles.eventLabelFont # eventTimeFont # set up superscript size = self.styles.eventTimeStyle.fontSize * .7 if IS_MAC: # on the Mac anti-aliasing stops at 8px by default (user can change to be lower) size = max(size, 9) self._superscriptFont = Styles.getFont(size=size) self._todayBrush = self.styles.todayBrush self.multiWeekControl = Block.Block.findBlockByName( "MainMultiWeekControl") # the widget's block isn't fully baked yet, initialize to None self._rangeStart = self._rangeEnd = self._month = None # initialize bitmaps self.weekdayBitmaps = None self.weekNumberBitmaps = {} self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_LEFT_DOWN, self.OnClick) self.Bind(wx.EVT_LEFT_DCLICK, self.OnDClick) self.measure = wx.ClientDC(self) self.measure.SetFont(self._font) self.doDrawingCalculations()
def __init__(self, *arguments, **keywords): super (wxMultiWeekCanvas, self).__init__ (*arguments, **keywords) # default to showing 7 days -- HELPME is there a better idiom for this? self._weeks = [MultiWeekWeek(), MultiWeekWeek(), MultiWeekWeek(), MultiWeekWeek(), MultiWeekWeek(), MultiWeekWeek()] # how many days are visible for each week self._visibleDaysPerWeek = 7 # what day is at the left side of a week (0=Sun, 1=Mon, ... 6=Sat) self._firstVisibleDay = 0 # how many weeks to display - will always be < self.visibleWeeks self._visibleWeekCount = 6 self._dayMargin = (3, 2) # turn off editor self.editor = None # track multi-day events self._multiDayEvents = [] # keep track of available "slots" for drawing events self._eventSlots = SparseMatrix() # should we use the multiWeekControl's column positions, or # calculate our own? self._shouldCalculateColumnPositions = False # rendering self.styles = Block.Block.findBlockByName("MultiWeekCalendarView") self._dayPen = self.styles.minorLinePen self._weekPen = self._dayPen self._noonStrokePen = wx.Pen(wx.Colour(100, 100, 100, 255), 1) self._noonStrokePen.SetCap(wx.CAP_BUTT) self._weekBrush = wx.Brush(wx.Colour(255, 255, 255, 128)) # 128 == half transparent self._eraseBrush = wx.Brush(wx.Colour(255, 255, 255)) self._erasePen = wx.Pen("white", 1) self._zeroPen = wx.Pen("white", 0) self._thisMonthColour = wx.Colour(0, 0, 0, 255) self._otherMonthColour = wx.Colour(128, 128, 128, 128) self._otherMonthBrush = wx.Brush(wx.Colour(0, 0, 0, 128)) self._otherMonthAllDayBrush = wx.Brush(wx.Colour(225, 225, 225, 128)) self._textBrush = wx.Brush(wx.Colour(255, 255, 255, 128)) # 128 == half transparent self._textPen = self._dayPen self._font = self.styles.eventLabelFont self._timeFont = self.styles.eventTimeFont self._textFont = self.styles.eventLabelFont # eventTimeFont # set up superscript size = self.styles.eventTimeStyle.fontSize * .7 if IS_MAC: # on the Mac anti-aliasing stops at 8px by default (user can change to be lower) size = max(size, 9) self._superscriptFont = Styles.getFont(size=size) self._todayBrush = self.styles.todayBrush self.multiWeekControl = Block.Block.findBlockByName("MainMultiWeekControl") # the widget's block isn't fully baked yet, initialize to None self._rangeStart = self._rangeEnd = self._month = None # initialize bitmaps self.weekdayBitmaps = None self.weekNumberBitmaps = {} self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_LEFT_DOWN, self.OnClick) self.Bind(wx.EVT_LEFT_DCLICK, self.OnDClick) self.measure = wx.ClientDC(self) self.measure.SetFont(self._font) self.doDrawingCalculations()
# they're contracted together... so erase a one-pixel-high rectangle at # the bottom of our rect, then make ours a little smaller, dc.SetBrush(wx.WHITE_BRUSH) x, y, w, h = rect.Get() rect.height -= 1 h -= 1 dc.DrawRectangleRect((x, y + h, w, 1)) # Draw the background brush = wx.Brush(sectionBackgroundColor, wx.SOLID) dc.SetBrush(brush) dc.DrawRectangleRect(rect) dc.SetTextBackground(sectionBackgroundColor) # We'll center the 12-point text on the row, not counting descenders. labelFont = Styles.getFont(grid.blockItem.sectionLabelCharacterStyle) dc.SetFont(labelFont) (labelWidth, labelHeight, labelDescent, ignored) = dc.GetFullTextExtent(label) labelTop = y + ((h - labelHeight) / 2) # Draw the expando triangle (triBitmap, triWidth, triHeight) = self._getTriangle(expanded) triTop = y + ((h - triHeight) / 2) dc.DrawBitmap(triBitmap, margin, triTop, True) # Draw the text label, if it overlaps the rect to be updated labelPosition = margin + triWidth dc.SetTextForeground(wx.BLACK) dc.DrawText(label, labelPosition, labelTop) # Draw the item count, if it overlaps the rect to be updated
# they're contracted together... so erase a one-pixel-high rectangle at # the bottom of our rect, then make ours a little smaller, dc.SetBrush(wx.WHITE_BRUSH) x, y, w, h = rect.Get() rect.height -= 1 h -= 1 dc.DrawRectangleRect((x, y + h, w, 1)) # Draw the background brush = wx.Brush(sectionBackgroundColor, wx.SOLID) dc.SetBrush(brush) dc.DrawRectangleRect(rect) dc.SetTextBackground(sectionBackgroundColor) # We'll center the 12-point text on the row, not counting descenders. labelFont = Styles.getFont(grid.blockItem.sectionLabelCharacterStyle) dc.SetFont(labelFont) (labelWidth, labelHeight, labelDescent, ignored) = dc.GetFullTextExtent(label) labelTop = y + ((h - labelHeight) / 2) # Draw the expando triangle (triBitmap, triWidth, triHeight) = self._getTriangle(expanded) triTop = y + ((h - triHeight) / 2) dc.DrawBitmap(triBitmap, margin, triTop, True) # Draw the text label, if it overlaps the rect to be updated labelPosition = margin + triWidth dc.SetTextForeground(wx.BLACK) dc.DrawText(label, labelPosition, labelTop)
# We'll draw the sample or prefix in gray (unless it's part of the # selection, in which case we'll leave it white) if not isInSelection and (isSample or prefix is not None): oldForeground = dc.GetTextForeground() dc.SetTextForeground( wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)) haveText = len(theText) > 0 if (prefix is not None) or haveText: # Draw inside the lines. dc.SetBackgroundMode(wx.TRANSPARENT) rect.Inflate(-1, -1) dc.SetClippingRect(rect) textFont = Styles.getFont(grid.blockItem.characterStyle) textMeasurements = Styles.getMeasurements(textFont) textHeight = textMeasurements.height textTop = (rect.GetHeight() - textHeight) / 2 if prefix is not None: # Match up baselines prefixFont = Styles.getFont( grid.blockItem.prefixCharacterStyle) prefixMeasurements = Styles.getMeasurements(prefixFont) prefixHeight = prefixMeasurements.height prefixTop = textTop + ( (textHeight - textMeasurements.descent) - (prefixHeight - prefixMeasurements.descent)) dc.SetFont(prefixFont) width = DrawingUtilities.DrawClippedTextWithDots(dc,