Exemplo n.º 1
0
def _scaled_size(r: QRect, scale: int) -> QSize:
    """
    Get the scaled size of a QRect.

    :param r: the QRect to scale
    :param scale: the scaling factor to use
    :retval: the resulting QSize of the operation
    """

    s = QRect(r)

    s.setWidth(int(r.width() * scale))
    s.setHeight(int(r.height() * scale))

    return s.size()
Exemplo n.º 2
0
 def paintlines(self, surface, first, count, l0):
     "draws the data out of the model onto the qpainter surface"
     self.model.cur = first
     N = self.model.linesize
     h = self.line.height
     ww = surface.window().width()
     y = (first - l0) * h
     c0, c1 = brushes.xv_bg, brushes.xv_bg_alt
     pen = surface.pen()
     for address, data, txt in self.model.iterlines(count):
         # background rect (alternate)
         r = QRect(0, y, ww, h)
         surface.fillRect(r, c0)
         # address column:
         r.setWidth(self.line.x_hex)
         surface.drawText(r, Qt.AlignHCenter | Qt.AlignVCenter,
                          "%08x" % address)
         # hex column:
         w = self.line.xb.width
         r.setWidth(w)
         r.translate(self.line.x_hex + self.line.pxpad, 0)
         C = self.highlight.get(address, [None] * N)
         for i, c in enumerate(C):
             try:
                 s = "%02x" % (data[i])
             except IndexError:
                 break
             flg = Qt.AlignHCenter | Qt.AlignVCenter
             if c:
                 surface.fillRect(r, c)
                 surface.setPen(QPen(Qt.white))
             surface.drawText(r, flg, s)
             surface.setPen(pen)
             r.translate(w, 0)
         # ascii column:
         w = self.line.xb.cw
         r.setX(self.line.x_txt + self.line.pxpad)
         r.setWidth(w)
         for i, c in enumerate(C):
             try:
                 s = txt[i]
             except IndexError:
                 break
             flg = Qt.AlignHCenter | Qt.AlignVCenter
             if c:
                 surface.fillRect(r, c)
                 surface.setPen(QPen(Qt.white))
             surface.drawText(r, flg, s)
             surface.setPen(pen)
             r.translate(w, 0)
         # clear background endline:
         r.setX(self.line.x_end)
         r.setWidth(ww - self.line.x_end)
         surface.fillRect(r, brushes.xv_bg_alt)
         y += h
         c0, c1 = c1, c0