def __init__(self): # Fonts and pens we use when drawing self.header_font = drawing.get_default_font(12, True) self.small_text_font = drawing.get_default_font(8) self.red_solid_pen = wx.Pen(wx.Colour(255,0, 0), 1, wx.SOLID) self.black_solid_pen = wx.Pen(wx.Colour(0, 0, 0), 1, wx.SOLID) self.darkred_solid_pen = wx.Pen(wx.Colour(200, 0, 0), 1, wx.SOLID) self.black_dashed_pen = wx.Pen(wx.Colour(200, 200, 200), 1, wx.USER_DASH) self.black_dashed_pen.SetDashes([2, 2]) self.black_dashed_pen.SetCap(wx.CAP_BUTT) self.grey_solid_pen = wx.Pen(wx.Colour(200, 200, 200), 1, wx.SOLID) self.white_solid_brush = wx.Brush(wx.Colour(255, 255, 255), wx.SOLID) self.black_solid_brush = wx.Brush(wx.Colour(0, 0, 0), wx.SOLID) self.lightgrey_solid_brush = wx.Brush(wx.Colour(230, 230, 230), wx.SOLID) self.DATA_ICON_WIDTH = 5
def _draw_ballon(self, event, event_rect): """Draw one ballon on a selected event that has 'description' data.""" # Constants MAX_TEXT_WIDTH = 200 MIN_WIDTH = 100 inner_rect_w = 0 inner_rect_h = 0 # Icon (iw, ih) = (0, 0) icon = event.get_data("icon") if icon != None: (iw, ih) = icon.Size inner_rect_w = iw inner_rect_h = ih # Text self.dc.SetFont(drawing.get_default_font(8)) font_h = self.dc.GetCharHeight() (tw, th) = (0, 0) description = event.get_data("description") lines = None if description != None: lines = break_text(description, self.dc, MAX_TEXT_WIDTH) th = len(lines) * self.dc.GetCharHeight() for line in lines: (lw, lh) = self.dc.GetTextExtent(line) tw = max(lw, tw) if icon != None: inner_rect_w += BALLOON_RADIUS inner_rect_w += min(tw, MAX_TEXT_WIDTH) inner_rect_h = max(inner_rect_h, th) inner_rect_w = max(MIN_WIDTH, inner_rect_w) # Calcule la position X du balloon x_balloon = event_rect.X + 20 if event_rect.X < 40 : x_balloon = 40 x, y = self._draw_balloon_bg(self.dc, (inner_rect_w, inner_rect_h), #(event_rect.X + event_rect.Width / 2, event_rect.Y), (x_balloon, event_rect.Y), True) if icon != None: self.dc.DrawBitmap(icon, x, y, False) x += iw + BALLOON_RADIUS if lines != None: ty = y for line in lines: self.dc.DrawText(line, x, ty) ty += font_h x += tw
def _draw_ballon(self, event, event_rect): """Draw one ballon on a selected event that has 'description' data.""" # Constants MAX_TEXT_WIDTH = 200 MIN_WIDTH = 100 inner_rect_w = 0 inner_rect_h = 0 # Icon (iw, ih) = (0, 0) icon = event.get_data("icon") if icon != None: (iw, ih) = icon.Size inner_rect_w = iw inner_rect_h = ih # Text self.dc.SetFont(drawing.get_default_font(8)) font_h = self.dc.GetCharHeight() (tw, th) = (0, 0) description = event.get_data("description") lines = None if description != None: lines = break_text(description, self.dc, MAX_TEXT_WIDTH) th = len(lines) * self.dc.GetCharHeight() for line in lines: (lw, lh) = self.dc.GetTextExtent(line) tw = max(lw, tw) if icon != None: inner_rect_w += BALLOON_RADIUS inner_rect_w += min(tw, MAX_TEXT_WIDTH) inner_rect_h = max(inner_rect_h, th) inner_rect_w = max(MIN_WIDTH, inner_rect_w) x, y = self._draw_balloon_bg(self.dc, (inner_rect_w, inner_rect_h), (event_rect.X + event_rect.Width / 2, event_rect.Y), True) if icon != None: self.dc.DrawBitmap(icon, x, y, False) x += iw + BALLOON_RADIUS if lines != None: ty = y for line in lines: self.dc.DrawText(line, x, ty) ty += font_h x += tw