| 270 | self._post_draw(self, ctx) |
| 271 | |
| 272 | def _post_draw(self, widget, ctx): |
| 273 | if self._rubberband_rect is None: |
| 274 | return |
| 275 | |
| 276 | lw = 1 |
| 277 | dash = 3 |
| 278 | x0, y0, w, h = (dim / self.device_pixel_ratio |
| 279 | for dim in self._rubberband_rect) |
| 280 | x1 = x0 + w |
| 281 | y1 = y0 + h |
| 282 | |
| 283 | # Draw the lines from x0, y0 towards x1, y1 so that the |
| 284 | # dashes don't "jump" when moving the zoom box. |
| 285 | ctx.move_to(x0, y0) |
| 286 | ctx.line_to(x0, y1) |
| 287 | ctx.move_to(x0, y0) |
| 288 | ctx.line_to(x1, y0) |
| 289 | ctx.move_to(x0, y1) |
| 290 | ctx.line_to(x1, y1) |
| 291 | ctx.move_to(x1, y0) |
| 292 | ctx.line_to(x1, y1) |
| 293 | |
| 294 | ctx.set_antialias(1) |
| 295 | ctx.set_line_width(lw) |
| 296 | ctx.set_dash((dash, dash), 0) |
| 297 | ctx.set_source_rgb(0, 0, 0) |
| 298 | ctx.stroke_preserve() |
| 299 | |
| 300 | ctx.set_dash((dash, dash), dash) |
| 301 | ctx.set_source_rgb(1, 1, 1) |
| 302 | ctx.stroke() |
| 303 | |
| 304 | def on_draw_event(self, widget, ctx): |
| 305 | # to be overwritten by GTK4Agg or GTK4Cairo |