controls/CustomToolTip.py
branchwxPython4
changeset 3303 0ffb41625592
parent 2229 3c94bac4526e
child 3750 f62625418bff
equal deleted inserted replaced
3302:c89fc366bebd 3303:0ffb41625592
   135         @return: wx.Size(tool_tip_width, tool_tip_height)
   135         @return: wx.Size(tool_tip_width, tool_tip_height)
   136         """
   136         """
   137         max_width = max_height = 0
   137         max_width = max_height = 0
   138 
   138 
   139         # Create a memory DC for calculating text extent
   139         # Create a memory DC for calculating text extent
   140         dc = wx.MemoryDC(wx.EmptyBitmap(1, 1))
   140         dc = wx.MemoryDC(wx.Bitmap(1, 1))
   141         dc.SetFont(self.Font)
   141         dc.SetFont(self.Font)
   142 
   142 
   143         # Compute max tip text size
   143         # Compute max tip text size
   144         for line in self.Tip:
   144         for line in self.Tip:
   145             w, h = dc.GetTextExtent(line)
   145             w, h = dc.GetTextExtent(line)
   173         dc.SetPen(wx.BLACK_PEN)
   173         dc.SetPen(wx.BLACK_PEN)
   174         dc.SetBrush(wx.Brush(wx.Colour(255, 238, 170)))
   174         dc.SetBrush(wx.Brush(wx.Colour(255, 238, 170)))
   175         dc.SetFont(self.Font)
   175         dc.SetFont(self.Font)
   176 
   176 
   177         # Draw Tool tip
   177         # Draw Tool tip
   178         dc.BeginDrawing()
       
   179         tip_width, tip_height = self.GetToolTipSize()
   178         tip_width, tip_height = self.GetToolTipSize()
   180 
   179 
   181         # Draw background rectangle
   180         # Draw background rectangle
   182         dc.DrawRectangle(0, 0, tip_width, tip_height)
   181         dc.DrawRectangle(0, 0, tip_width, tip_height)
   183 
   182 
   186         for line in self.Tip:
   185         for line in self.Tip:
   187             dc.DrawText(line, 2, line_offset + 2)
   186             dc.DrawText(line, 2, line_offset + 2)
   188             _line_width, line_height = dc.GetTextExtent(line)
   187             _line_width, line_height = dc.GetTextExtent(line)
   189             line_offset += line_height
   188             line_offset += line_height
   190 
   189 
   191         dc.EndDrawing()
       
   192 
   190 
   193         event.Skip()
   191         event.Skip()