File indexing completed on 2024-04-28 05:50:52
0001 /* 0002 SPDX-FileCopyrightText: 2020-2020 Gustavo Carneiro <gcarneiroa@hotmail.com> 0003 SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com> 0004 SPDX-FileCopyrightText: 1997, 1998 Lars Doelle <lars.doelle@on-line.de> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef TERMINALSCROLLBAR_HPP 0010 #define TERMINALSCROLLBAR_HPP 0011 0012 // Qt 0013 #include <QScrollBar> 0014 0015 // Konsole 0016 #include "Enumeration.h" 0017 #include "ScreenWindow.h" 0018 #include "ScrollState.h" 0019 #include "extras/HighlightScrolledLines.h" 0020 #include "konsoleprivate_export.h" 0021 0022 namespace Konsole 0023 { 0024 class TerminalDisplay; 0025 0026 class KONSOLEPRIVATE_EXPORT TerminalScrollBar : public QScrollBar 0027 { 0028 Q_OBJECT 0029 public: 0030 explicit TerminalScrollBar(QWidget *parent); 0031 0032 /** 0033 * Specifies whether the terminal display has a vertical scroll bar, and if so whether it 0034 * is shown on the left or right side of the display. 0035 */ 0036 void setScrollBarPosition(Enum::ScrollBarPositionEnum position); 0037 0038 /** 0039 * Sets the current position and range of the display's scroll bar. 0040 * 0041 * @param cursor The position of the scroll bar's thumb. 0042 * @param slines The maximum value of the scroll bar. 0043 */ 0044 void setScroll(int cursor, int slines); 0045 0046 void setScrollFullPage(bool fullPage); 0047 bool scrollFullPage() const; 0048 void setHighlightScrolledLines(bool highlight); 0049 0050 /** See setAlternateScrolling() */ 0051 bool alternateScrolling() const; 0052 0053 /** 0054 * Sets the AlternateScrolling profile property which controls whether 0055 * to emulate up/down key presses for mouse scroll wheel events. 0056 * For more details, check the documentation of that property in the 0057 * Profile header. 0058 * Enabled by default. 0059 */ 0060 void setAlternateScrolling(bool enable); 0061 0062 // applies changes to scrollbarLocation to the scroll bar and 0063 // if @propagate is true, propagates size information 0064 void applyScrollBarPosition(bool propagate = true); 0065 0066 // scrolls the image by a number of lines. 0067 // 'lines' may be positive ( to scroll the image down ) 0068 // or negative ( to scroll the image up ) 0069 // 'region' is the part of the image to scroll - currently only 0070 // the top, bottom and height of 'region' are taken into account, 0071 // the left and right are ignored. 0072 void scrollImage(int lines, const QRect &screenWindowRegion, Character *image, int imageSize); 0073 0074 Enum::ScrollBarPositionEnum scrollBarPosition() const 0075 { 0076 return _scrollbarLocation; 0077 } 0078 0079 /** 0080 * Return the highlight line control 0081 */ 0082 HighlightScrolledLines &highlightScrolledLines() 0083 { 0084 return _highlightScrolledLines; 0085 } 0086 0087 void changeEvent(QEvent *e) override; 0088 0089 void updatePalette(const QPalette &pal); 0090 0091 public Q_SLOTS: 0092 0093 void scrollBarPositionChanged(int value); 0094 void highlightScrolledLinesEvent(); 0095 0096 private: 0097 bool _scrollFullPage = false; 0098 bool _alternateScrolling = false; 0099 Enum::ScrollBarPositionEnum _scrollbarLocation = Enum::ScrollBarRight; 0100 HighlightScrolledLines _highlightScrolledLines; 0101 QPalette _backgroundMatchingPalette; 0102 }; 0103 } // namespace Konsole 0104 0105 #endif