Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Avoid displaying an unnecessary horizontal scrollbar in SQL editor wi…
…dgets The following scroll width functionalities are added to QScintilla: setScrollWidth, getScrollWidth, setScrollWidthTracking and getScrollWidthTracking. This allows setting a lower value for the initial scroll width (default is 2000 pixels). Consequently, the horizontal scroll is only visible if the SQL lines become bigger than window width. The scroll width, though, is never reduced by Scintilla for performance reasons. See this for explanation: jacobslusser/ScintillaNET#216 And see this for a possible implementation of a fully adjusted scroll width with fixed-width fonts: https://groups.google.com/forum/#!topic/scintilla-interest/ly8u7mVDgyQ
- Loading branch information
Showing
4 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
diff --git a/libs/qscintilla/Qt4Qt5/Qsci/qsciscintilla.h b/libs/qscintilla/Qt4Qt5/Qsci/qsciscintilla.h | ||
index 3b5f185..49ca5cc 100644 | ||
--- a/libs/qscintilla/Qt4Qt5/Qsci/qsciscintilla.h | ||
+++ b/libs/qscintilla/Qt4Qt5/Qsci/qsciscintilla.h | ||
@@ -2009,6 +2009,34 @@ public slots: | ||
//! \sa zoomIn(), zoomOut() | ||
virtual void zoomTo(int size); | ||
|
||
+ //! For performance, Scintilla does not measure the display width | ||
+ //! of the document to determine the properties of the horizontal | ||
+ //! scroll bar. Instead, an assumed width is used. This sets the | ||
+ //! document width in pixels assumed by Scintilla to \a | ||
+ //! pixelWidth. The default value is 2000. | ||
+ //! | ||
+ //! \sa getScrollWidth(), setScrollWidthTracking() | ||
+ virtual void setScrollWidth(int pixelWidth); | ||
+ | ||
+ //! Gets the document width in pixels assumed by Scintilla. | ||
+ //! | ||
+ //! \sa setScrollWidth(), setScrollWidthTracking() | ||
+ virtual int getScrollWidth() const; | ||
+ | ||
+ //! If scroll width tracking is enabled then the scroll width is | ||
+ //! adjusted to ensure that all of the lines currently displayed | ||
+ //! can be completely scrolled. This mode never adjusts the scroll | ||
+ //! width to be narrower. | ||
+ //! Sets the scroll width tracking to \a enabled. | ||
+ //! | ||
+ //! \sa setScrollWidth(), getScrollWidthTracking() | ||
+ virtual void setScrollWidthTracking(bool enabled); | ||
+ | ||
+ //! Gets the current scroll width tracking mode. | ||
+ //! | ||
+ //! \sa getScrollWidth(), setScrollWidthTracking() | ||
+ virtual bool getScrollWidthTracking() const; | ||
+ | ||
signals: | ||
//! This signal is emitted whenever the cursor position changes. \a line | ||
//! contains the line number and \a index contains the character index | ||
diff --git a/libs/qscintilla/Qt4Qt5/qsciscintilla.cpp b/libs/qscintilla/Qt4Qt5/qsciscintilla.cpp | ||
index 4c9fe75..31dc579 100644 | ||
--- a/libs/qscintilla/Qt4Qt5/qsciscintilla.cpp | ||
+++ b/libs/qscintilla/Qt4Qt5/qsciscintilla.cpp | ||
@@ -4481,3 +4481,26 @@ static QColor asQColor(long sci_colour) | ||
((int)(sci_colour >> 8)) & 0x00ff, | ||
((int)(sci_colour >> 16)) & 0x00ff); | ||
} | ||
+ | ||
+void QsciScintilla::setScrollWidth(int pixelWidth) | ||
+{ | ||
+ SendScintilla(SCI_SETSCROLLWIDTH, pixelWidth); | ||
+} | ||
+ | ||
+int QsciScintilla::getScrollWidth() const | ||
+{ | ||
+ return SendScintilla(SCI_GETSCROLLWIDTH); | ||
+} | ||
+ | ||
+void QsciScintilla::setScrollWidthTracking(bool enabled) | ||
+{ | ||
+ SendScintilla(SCI_SETSCROLLWIDTHTRACKING, enabled); | ||
+} | ||
+ | ||
+bool QsciScintilla::getScrollWidthTracking() const | ||
+{ | ||
+ return SendScintilla(SCI_GETSCROLLWIDTHTRACKING); | ||
+} | ||
+ | ||
+ | ||
+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters