def sizeHint(self): """ Returns the widget size hint (based on the editor font size) """ fm = QFontMetricsF(self.editor.codeEdit.font()) self.size_hint = QSize(fm.height(), fm.height()) if self.size_hint.width() > 16: self.size_hint.setWidth(16) return self.size_hint
def init_font_config(self): self.disasm_font = QFont("DejaVu Sans Mono", 10) font_metrics = QFontMetricsF(self.disasm_font) self.disasm_font_height = font_metrics.height() self.disasm_font_width = font_metrics.width('A') self.disasm_font_ascent = font_metrics.ascent() self.symexec_font = QFont("DejaVu Sans Mono", 10) font_metrics = QFontMetricsF(self.symexec_font) self.symexec_font_height = font_metrics.height() self.symexec_font_width = font_metrics.width('A') self.symexec_font_ascent = font_metrics.ascent()
def _onStyleChanged(self): """ Updates stylesheet and brushes. """ fm = QFontMetricsF(self.editor.codeEdit.font()) self.size_hint = QSize(fm.height(), fm.height()) style = self.currentStyle self.back_brush = QBrush(QColor(style.panelsBackgroundColor)) self.active_line_brush = QBrush(QColor(style.activeLineColor)) self.separator_pen = QPen(QColor(style.panelSeparatorColor)) # qss = self.QSS % {"back": style.activeLineColor, # "color": style.tokenColor(Text)} # self.setStyleSheet(qss) self.updateGeometry()
def paintEvent(self, event): """ Paints the widget """ if self.enabled is False: return Panel.paintEvent(self, event) painter = QPainter(self) painter.fillRect(event.rect(), self.back_brush) for vb in self.editor.codeEdit.visible_blocks: line = vb.row # paint marker for line marker = self.getIndicatorForLine(line) if marker is None: continue # use the normal pen to draw the fold indicator drawLines = False pen = self.normal_pen if marker.hover is True: pen = self.highlight_pen drawLines = True painter.setPen(pen) # get the text to draw txt = '-' if marker.folded is True: drawLines = False txt = '+' offset = 4 h = self.size_hint.height() fm = QFontMetricsF(self.editor.codeEdit.font()) hoffset = (fm.height() - h) / 2.0 r = QRect(vb.rect.x(), vb.rect.y() + hoffset, self.size_hint.width(), self.size_hint.height()) painter.setFont(self.font) painter.drawText(r, Qt.AlignVCenter | Qt.AlignHCenter, txt) w = self.size_hint.width() - 2 * offset h = self.size_hint.width() - 2 * offset hoffset = (fm.height() - h) / 2.0 r.setX(vb.rect.x() + offset) r.setY(vb.rect.y() + hoffset) r.setWidth(w) r.setHeight(h) painter.drawRect(r) if drawLines is True: top = (vb.rect.x() + self.size_hint.width() / 2.0, vb.rect.y() + hoffset + offset * 2) delta = ((marker.end - marker.start) * vb.height) # - (vb.rect.height() / 2.0) bottom = (top[0], top[1] + delta) painter.drawLine(top[0], top[1], bottom[0], bottom[1]) painter.drawLine(bottom[0], bottom[1], bottom[0] + self.size_hint.width() / 2.0, bottom[1]) return
def __init__(self, main_window): self._main_window = main_window self._instance = None self.views_by_category = defaultdict(list) self.views = [] self.dockable_views = [] self.view_to_dockable = {} # # Some generic configurations. move to "configurations" module later # #self.disasm_font = QFont("courier new", 20) self.disasm_font = QFont("DejaVu Sans Mono", 10) font_metrics = QFontMetricsF(self.disasm_font) self.disasm_font_height = font_metrics.height() self.disasm_font_width = font_metrics.width('A') self.disasm_font_ascent = font_metrics.ascent() default_tabs = [ FunctionsView(self, 'left'), DisassemblyView(self, 'right'), SymexecView(self, 'right'), StatesView(self, 'right'), StringsView(self, 'right'), ConsoleView(self, 'bottom'), ] for tab in default_tabs: self.add_view(tab, tab.caption, tab.category)