def _on_paint(self, _e): scroll = -self.scroll text_offset_x = self.text_offset_x dc = AutoBufferedPaintDC(self) dc.Clear() text_shift = -self.half_step hl, cur = self._hl, self.current for x1, y1, x2, y2 in self.lines: dc.DrawLine(x1, y1 + scroll, x2, y2 + scroll) br = dc.GetBackground() prev_c = br.GetColour() revert_color = False for c in Commit.graph.iter_commits(): while True: if c is cur: br.SetColour((0, 255, 0, 255)) elif c is hl: br.SetColour((255, 0, 0, 255)) else: break dc.SetBrush(br) revert_color = True break x = c._x y = c._y dc.DrawCircle(x, y + scroll, 4) dc.DrawText(c.label, x + text_offset_x, y + scroll + text_shift) if revert_color: br.SetColour(prev_c) dc.SetBrush(br) revert_color = False
def __draw_cross_point(self, dc: wx.AutoBufferedPaintDC, pos: wx.Point): size: wx.Size = self.frame.GetSize() dc.DrawLine(0, 0, pos.x, pos.y) dc.DrawLine(size.x, 0, pos.x, pos.y) dc.DrawLine(0, size.y, pos.x, pos.y) dc.DrawLine(size.x, size.y, pos.x, pos.y)