QScintilla/QsciScintillaCompat.py

changeset 6309
acaae2a2f1cb
parent 6305
7652b925c25e
child 6312
5d3c401188c6
equal deleted inserted replaced
6308:f49ce4c244b1 6309:acaae2a2f1cb
1536 1536
1537 width += 4 # Borders 1537 width += 4 # Borders
1538 1538
1539 itemHeight = ch.visualItemRect(all_items[0]).height() 1539 itemHeight = ch.visualItemRect(all_items[0]).height()
1540 height = min(self.maxLines, len(all_items)) * itemHeight 1540 height = min(self.maxLines, len(all_items)) * itemHeight
1541 # Just a fiddling factor: 4 for the borders, 2 for better readability, 1541 # Just a fiddling factor: 2 for better readability,
1542 # e.g. underscores at the end of the list. 1542 # e.g. underscores at the end of the list.
1543 height += 6 1543 height += 2
1544 1544
1545 sbSize = self.verticalScrollBar().sizeHint().width()
1546 font = ch.font() 1545 font = ch.font()
1547 fm = QFontMetrics(font) 1546 fm = QFontMetrics(font)
1548 averageCharWidth = fm.averageCharWidth() 1547 averageCharWidth = fm.averageCharWidth()
1549 maxWidth = averageCharWidth * self.maxChars 1548 maxWidth = averageCharWidth * self.maxChars
1550 if width > (maxWidth): 1549 if width > maxWidth:
1551 width = maxWidth 1550 width = maxWidth
1552 height += sbSize
1553 # List box doesn't honor limited size to show scroll bars, e.g. 1551 # List box doesn't honor limited size to show scroll bars, e.g.
1554 # Python 2 on Win 10. So just force it. 1552 # Python 2 on Win 10. So just force it.
1555 ch.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) 1553 ch.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
1556 1554
1557 if len(all_items) > self.maxLines: 1555 hsb = self.horizontalScrollBar()
1558 width += sbSize 1556 if hsb.isVisible():
1557 hsbHeight = hsb.sizeHint().height()
1558 height += hsbHeight
1559
1560 vsb = self.verticalScrollBar()
1561 if vsb.isVisible():
1562 vsbWidth = vsb.sizeHint().width()
1563 width += vsbWidth
1559 1564
1560 # Special case, where the space below current line where to less 1565 # Special case, where the space below current line where to less
1561 yPos = geom.y() 1566 yPos = geom.y()
1562 charPos = self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS) 1567 charPos = self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS)
1563 currentYPos = self.SendScintilla( 1568 currentYPos = self.SendScintilla(

eric ide

mercurial