(self, painter)
paint main control
paint main control
paint main control
def paint_control(self, painter):
        """ paint main control
        """
        qtext_align = QTextOption(Qt.AlignVCenter | Qt.AlignHCenter)
        painter.setPen(self._ctrl_colors['foreground'])

        # header
        painter.fillRect(0, 0, self.width(), self._header_height,
                         self._ctrl_colors['header_bg'])

        # header texts
        if self._hex_style == 'upper':
            hex_style = 'X'
        else:
            hex_style = 'x'

        bounds = QRectF(self._offset_start, 0, self._offset_width,
                        self._header_height)
        painter.drawText(bounds, "OFFSET(%s)" % hex_style, option=qtext_align)

        drawing_pos_x = self._hex_start

        painter.setPen(self._ctrl_colors['foreground'])
        for i in range(self.bytes_per_line):
            if self._dual_color_bytes and not i % 2:
                painter.setPen(self._ctrl_colors['byte_col_1'])
            elif self._dual_color_bytes and i % 2:
                painter.setPen(self._ctrl_colors['byte_col_2'])
            else:
                painter.setPen(self._ctrl_colors['foreground'])

            bounds = QRectF(drawing_pos_x, 0, (2 * self._char_width),
                            self._header_height)
            if self._hex_style == 'upper':
                painter.drawText(
                    bounds, '{0:02X}'.format(i), option=qtext_align)
            else:
                painter.drawText(
                    bounds, '{0:02x}'.format(i), option=qtext_align)

            drawing_pos_x += (3 * self._char_width)

        # draw separator lines
        if self._draw_sep_lines:
            line_pos_x = self._hex_start - self._line_width - self._hor_spacing
            painter.fillRect(line_pos_x, 0, self._line_width, self.height(),
                             self._ctrl_colors['divider'])
            line_pos_x = self._ascii_start - self._line_width - self._hor_spacing
            painter.fillRect(line_pos_x, 0, self._line_width, self.height(),
                             self._ctrl_colors['divider'])

        painter.setPen(self._ctrl_colors['foreground'])
        bounds = QRectF(self._ascii_start, 0, self._ascii_width,
                        self._header_height)
        painter.drawText(
            bounds,
            "ASCII",
            option=QTextOption(Qt.AlignVCenter | Qt.AlignHCenter))
def paint_control ( self , painter ) : qtext_align = QTextOption ( Qt . AlignVCenter | Qt . AlignHCenter ) painter . setPen ( self . _ctrl_colors [ 'foreground' ] ) # header painter . fillRect ( 0 , 0 , self . width ( ) , self . _header_height , self . _ctrl_colors [ 'header_bg' ] ) # header texts if self . _hex_style == 'upper' : hex_style = 'X' else : hex_style = 'x' bounds = QRectF ( self . _offset_start , 0 , self . _offset_width , self . _header_height ) painter . drawText ( bounds , "OFFSET(%s)" % hex_style , option = qtext_align ) drawing_pos_x = self . _hex_start painter . setPen ( self . _ctrl_colors [ 'foreground' ] ) for i in range ( self . bytes_per_line ) : if self . _dual_color_bytes and not i % 2 : painter . setPen ( self . _ctrl_colors [ 'byte_col_1' ] ) elif self . _dual_color_bytes and i % 2 : painter . setPen ( self . _ctrl_colors [ 'byte_col_2' ] ) else : painter . setPen ( self . _ctrl_colors [ 'foreground' ] ) bounds = QRectF ( drawing_pos_x , 0 , ( 2 * self . _char_width ) , self . _header_height ) if self . _hex_style == 'upper' : painter . drawText ( bounds , '{0:02X}' . format ( i ) , option = qtext_align ) else : painter . drawText ( bounds , '{0:02x}' . format ( i ) , option = qtext_align ) drawing_pos_x += ( 3 * self . _char_width ) # draw separator lines if self . _draw_sep_lines : line_pos_x = self . _hex_start - self . _line_width - self . _hor_spacing painter . fillRect ( line_pos_x , 0 , self . _line_width , self . height ( ) , self . _ctrl_colors [ 'divider' ] ) line_pos_x = self . _ascii_start - self . _line_width - self . _hor_spacing painter . fillRect ( line_pos_x , 0 , self . _line_width , self . height ( ) , self . _ctrl_colors [ 'divider' ] ) painter . setPen ( self . _ctrl_colors [ 'foreground' ] ) bounds = QRectF ( self . _ascii_start , 0 , self . _ascii_width , self . _header_height ) painter . drawText ( bounds , "ASCII" , option = QTextOption ( Qt . AlignVCenter | Qt . AlignHCenter ) )