Esempio n. 1
0
 def process_draw(self, gc: wx.GraphicsContext):
     if self.cam.frame_bitmap is None:
         font = wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD)
         gc.SetFont(font, wx.BLACK)
         if self.cam.camera is None:
             gc.DrawText(
                 _("Camera backend failure...\nCannot attempt camera connection."
                   ),
                 0,
                 0,
             )
         else:
             gc.DrawText(_("Fetching Frame..."), 0, 0)
Esempio n. 2
0
    def process_draw(self, gc: wx.GraphicsContext):
        gc.SetBrush(self.background_brush)
        gc.DrawRectangle(self.left, self.top, self.right, self.bottom)

        gc.SetBrush(self.lacking_brush)
        gc.SetPen(self.lacking_pen)
        gc.DrawLines([(self.start_x, self.start_y), (self.end_x, self.end_y)])
        for idx, value in enumerate(self.values):
            amount = self.value_to_position(value)

            tx = amount * (self.end_x - self.start_x) + self.start_x
            ty = amount * (self.end_y - self.start_y) + self.start_y
            gc.SetBrush(self.selected_brush)
            gc.SetPen(self.selected_pen)
            gc.DrawLines([(self.start_x, self.start_y), (tx, ty)])
            gc.DrawEllipse(tx - BLIP_RADIUS / 2, ty - BLIP_RADIUS / 2,
                           BLIP_RADIUS, BLIP_RADIUS)
            if self.moving and self.seeker == idx:
                gc.SetBrush(self.moving_brush)
                gc.DrawEllipse(
                    tx - MOVE_RADIUS / 2,
                    ty - MOVE_RADIUS / 2,
                    MOVE_RADIUS,
                    MOVE_RADIUS,
                )
        if self.seeker != -1:
            try:
                gc.DrawText(
                    f"{self.values[self.seeker]:.2f}",
                    self.start_x,
                    self.start_y,
                )
            except IndexError:
                pass
Esempio n. 3
0
    def process_draw(self, gc: wx.GraphicsContext):
        # Draw Box
        gc.SetBrush(wx.TRANSPARENT_BRUSH)
        gc.SetPen(self.checkline_pen)
        gc.DrawRectangle(self.left, self.top, self.right - self.left,
                         self.bottom - self.top)
        if self.value:
            # Draw Check
            gc.SetPen(self.checkline_pen)
            check = [(0.2, 0.5), (0.4, 0.75), (0.8, 0.2)]
            for i in range(len(check)):
                x, y = check[i]
                check[i] = towards(self.left, self.right,
                                   x), towards(self.top, self.bottom, y)
            gc.DrawLines(check)

        if self.text:
            height = self.bottom - self.top
            width = self.right - self.left
            text_size = height * 3.0 / 4.0  # px to pt conversion
            try:
                self.font.SetFractionalPointSize(text_size)
            except AttributeError:
                self.font.SetPointSize(int(text_size))
            gc.SetFont(self.font, self.font_color)
            gc.DrawText(self.text, self.right + width * self._text_gap,
                        self.top)
Esempio n. 4
0
    def do_paint(self, gc: wx.GraphicsContext):
        if self.gfont is None or self.font_scale != cstate.scale:
            self.font_scale = cstate.scale
            font = wx.Font(wx.FontInfo(10 * cstate.scale))
            self.gfont = gc.CreateFont(font, wx.BLACK)
        gc.SetFont(self.gfont)

        s_aligned_rect = self.node.s_rect.aligned()
        aligned_border_width = max(
            even_round(self.node.border_width * cstate.scale), 2)
        width, height = s_aligned_rect.size
        draw_rect(
            gc,
            s_aligned_rect,
            fill=self.node.fill_color,
            border=self.node.border_color,
            border_width=aligned_border_width,
        )

        # draw text
        tw, th, _, _ = gc.GetFullTextExtent(
            self.node.id_)  # optimize by caching?
        tx = (width - tw) / 2
        ty = (height - th) / 2
        gc.DrawText(self.node.id_, self.node.s_position.x + tx,
                    self.node.s_position.y + ty)
Esempio n. 5
0
    def draw(self, gc: wx.GraphicsContext):
        if not self.message:
            return
        alpha = 255
        if self.countdown <= 20:
            alpha = int(self.countdown * 12.5)
        self.set_alpha(alpha)

        width = self.right - self.left
        height = self.bottom - self.top
        text_size = height

        while self.text_height > height or self.text_width > width:
            # If we do not fit in the box, decrease size
            text_size *= 0.9
            try:
                self.font.SetFractionalPointSize(text_size)
            except AttributeError:
                self.font.SetPointSize(int(text_size))
            gc.SetFont(self.font, self.font_color)
            self.text_width, self.text_height = gc.GetTextExtent(self.message)
        if text_size == height:
            gc.SetFont(self.font, self.font_color)
        gc.SetPen(self.pen)
        gc.SetBrush(self.brush)
        gc.DrawRectangle(self.left, self.top, self.right - self.left,
                         self.bottom - self.top)

        toast_x = self.left + (width - self.text_width) / 2.0
        toast_y = self.top
        gc.DrawText(self.message, toast_x, toast_y)
Esempio n. 6
0
 def process_draw(self, gc: wx.GraphicsContext):
     if self.text is not None:
         gc.SetPen(self.pen)
         gc.SetBrush(wx.TRANSPARENT_BRUSH)
         gc.DrawText(self.text.text, self.x, self.y)