def evtLeftUp(self, event): """ Handle left mouse button up """ # Get clicked coordinates clickedCoordinates = self._clickedButton self.logger.debug(f'clickedCoordinates: {clickedCoordinates}') (x1, y1, x2, y2, tool) = self._clickedButton # Get dc dc = ClientDC(self) oldPen = dc.GetPen() # Draw normally button dc.SetPen(BLACK_PEN) dc.DrawLine(x2 - 1, y2 - 1, x2 - 1, y1) dc.DrawLine(x2 - 1, y2 - 1, x1, y2 - 1) dc.SetPen(WHITE_PEN) dc.DrawLine(x1, y1, x2 - 1, y1) dc.DrawLine(x1, y1, x1, y2 - 1) # Set old pen dc.SetPen(oldPen) # Remove clicked button self._clickedButton = None # Execute callback if tool is not None: callback = tool.getActionCallback() if callback is not None: callback(EventClone(tool.getWxId()))
def OnRefresh(self, event): """ Refresh dialog box """ (w, h) = self.GetSize() nbButtonsW = (w - MARGIN * 2) / BUTTON_SIZE dc = ClientDC(self) oldPen = dc.GetPen() # Draw i = 0 j = 0 for tool in self._tools: tool: Tool = cast(Tool, tool) # Calculate position x = MARGIN + i * BUTTON_SIZE y = MARGIN + j * BUTTON_SIZE + MARGIN_TOP # Draw dc.SetPen(BLACK_PEN) categoryStr: str = f'[{tool.initialCategory}]' dc.DrawText(categoryStr, MARGIN, MARGIN) dc.SetPen(WHITE_PEN) dc.DrawLine(x, y, x + BUTTON_SIZE - 1, y) dc.DrawLine(x, y, x, y + BUTTON_SIZE - 1) dc.SetPen(BLACK_PEN) dc.DrawLine(x, y + BUTTON_SIZE - 1, x + BUTTON_SIZE - 1, y + BUTTON_SIZE - 1) dc.DrawLine(x + BUTTON_SIZE - 1, y, x + BUTTON_SIZE - 1, y + BUTTON_SIZE - 1) dc.DrawBitmap(tool.img, x + 1, y + 1) i += 1 # Find next position if i > nbButtonsW - 1: i = 0 j += 1 # Set old pen dc.SetPen(oldPen)
def evtLeftDown(self, event): """ Handle left mouse button down """ # Get the clicked tool x, y = event.GetPosition() (x1, y1, x2, y2, tool) = self._getClickedButton(x, y) self._clickedButton = (x1, y1, x2, y2, tool) # Get dc dc = ClientDC(self) oldPen = dc.GetPen() # Clicked illusion dc.SetPen(GREY_PEN) dc.DrawLine(x2 - 1, y2 - 1, x2 - 1, y1) dc.DrawLine(x2 - 1, y2 - 1, x1, y2 - 1) dc.SetPen(BLACK_PEN) dc.DrawLine(x1, y1, x2 - 1, y1) dc.DrawLine(x1, y1, x1, y2 - 1) # Set old pen dc.SetPen(oldPen)