예제 #1
0
 def sizeHint(self):
     """ Returns the widget size hint (based on the editor font size) """
     fm = QtGui.QFontMetricsF(self.editor.font())
     size_hint = QtCore.QSize(fm.height(), fm.height())
     if size_hint.width() > 16:
         size_hint.setWidth(16)
     return size_hint
예제 #2
0
 def sizeHint(self):
     """
     Returns the panel size hint. (fixed with of 16px)
     """
     metrics = QtGui.QFontMetricsF(self.editor.font())
     size_hint = QtCore.QSize(metrics.height(), metrics.height())
     if size_hint.width() > 16:
         size_hint.setWidth(16)
     return size_hint
예제 #3
0
 def _paint_margin(self, event):
     """ Paints the right margin after editor paint event. """
     font = QtGui.QFont(self.editor.font_name,
                        self.editor.font_size + self.editor.zoom_level)
     metrics = QtGui.QFontMetricsF(font)
     pos = self._margin_pos
     offset = self.editor.contentOffset().x() + \
         self.editor.document().documentMargin()
     x80 = round(metrics.width(' ') * pos) + offset
     painter = QtGui.QPainter(self.editor.viewport())
     painter.setPen(self._pen)
     painter.drawLine(x80, 0, x80, 2**16)
예제 #4
0
 def _paint_margins(self, event):
     """ Paints the right margin after editor paint event. """
     font = QtGui.QFont(self.editor.font_name,
                        self.editor.font_size + self.editor.zoom_level)
     metrics = QtGui.QFontMetricsF(font)
     painter = QtGui.QPainter(self.editor.viewport())
     for pos, pen in zip(self._positions, self._pens):
         if pos < 0:
             # margin not visible
             continue
         offset = self.editor.contentOffset().x() + \
             self.editor.document().documentMargin()
         x_pos = round(metrics.width(' ') * pos) + offset
         painter.setPen(pen)
         painter.drawLine(x_pos, 0, x_pos, 2**16)