edbee - Qt Editor Library v0.11.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
textmargincomponent.h
Go to the documentation of this file.
1// edbee - Copyright (c) 2012-2025 by Rick Blommers and contributors
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include "edbee/exports.h"
7
8#include <QWidget>
9
10class QEvent;
11class QFont;
12class QLinearGradient;
13class QMouseEvent;
14class QPainter;
15
16namespace edbee {
17
20class TextRenderer;
21class TextTheme;
22
26public:
29
30 virtual QString lineText( int line );
31
32 virtual int widthBeforeLineNumber();
33 virtual void renderBefore( QPainter* painter, int startLine, int endLine, int width );
34 virtual void renderAfter( QPainter* painter, int startLine, int endLine, int width );
35
36 virtual bool requiresMouseTracking();
37 virtual void mouseMoveEvent( int line, QMouseEvent* event );
38 virtual void mousePressEvent( int line, QMouseEvent* event );
39 virtual void leaveEvent( QEvent* event );
40
41 TextMarginComponent* marginComponent() { return marginComponentRef_; }
42 void setMarginCompenent( TextMarginComponent* comp ) { marginComponentRef_ = comp; }
43
44private:
45 TextMarginComponent* marginComponentRef_;
46 int startLine_;
47};
48
49
52class EDBEE_EXPORT TextMarginComponent : public QWidget
53{
54 Q_OBJECT
55
56public:
58 virtual ~TextMarginComponent();
59
60 void init();
61 void updateMarginFont();
62
63 int widthHint() const;
64 virtual QSize sizeHint() const;
66
67 void fullUpdate();
68 TextEditorWidget* editorWidget() const { return editorRef_;}
69 TextRenderer* renderer() const;
70
71 TextMarginComponentDelegate* delegate() const { return delegateRef_; }
72 void setDelegate( TextMarginComponentDelegate* delegate );
73 void giveDelegate( TextMarginComponentDelegate* delegate );
74
75protected:
76
77 virtual void paintEvent( QPaintEvent* event );
78 virtual void renderCaretMarkers( QPainter* painter, int startLine, int endLine, int width );
79 virtual void renderLineNumber( QPainter* painter, int startLine, int endLine, int width );
80
81 virtual void mouseMoveEvent(QMouseEvent* event);
82 virtual void mousePressEvent(QMouseEvent* event);
83 virtual void mouseDoubleClickEvent(QMouseEvent *);
84 virtual void leaveEvent(QEvent* event);
85 virtual void wheelEvent(QWheelEvent* event);
86
87public:
88 virtual void updateLineAtOffset(int offset);
89 virtual void updateLine(int line, int length);
90
91protected slots:
92
93 virtual void topChanged(int value);
94 virtual void connectScrollBar();
95 virtual void updateFont();
96
97private:
98
99
101 int top_;
102 mutable int width_;
103 mutable int lastLineCount_;
104 QFont* marginFont_;
105 TextEditorWidget* editorRef_;
106 TextMarginComponentDelegate* delegate_;
107 TextMarginComponentDelegate* delegateRef_;
108};
109
110} // edbee
This is the general edbee widget The core functionality of this widget is divided in several separate...
Definition texteditorwidget.h:36
The textmargin component delegate You can override the methods in the class for adding functionality ...
Definition textmargincomponent.h:25
TextMarginComponent * marginComponent()
Definition textmargincomponent.h:41
TextMarginComponentDelegate()
The default constructor.
Definition textmargincomponent.cpp:31
virtual ~TextMarginComponentDelegate()
Definition textmargincomponent.h:28
void setMarginCompenent(TextMarginComponent *comp)
Definition textmargincomponent.h:42
The margin/line-number component This class is used for rendering line-numbers etc.
Definition textmargincomponent.h:53
void updateMarginFont()
Updates the margin font.
Definition textmargincomponent.cpp:153
int widthHint() const
Returns the required width for this control.
Definition textmargincomponent.cpp:168
TextEditorWidget * editorWidget() const
Definition textmargincomponent.h:68
bool isGeometryChangeRequired()
This emthod is called when the text is changed.
Definition textmargincomponent.cpp:204
TextMarginComponentDelegate * delegate() const
Definition textmargincomponent.h:71
virtual QSize sizeHint() const
This method returns the size hint.
Definition textmargincomponent.cpp:195
TextMarginComponent(TextEditorWidget *editorWidget, QWidget *parent)
Constructs the textmarginc compnonent.
Definition textmargincomponent.cpp:117
void fullUpdate()
A slow and full update of the control.
Definition textmargincomponent.cpp:211
void init()
initalizes this component
Definition textmargincomponent.cpp:142
A class for rendering the text.
Definition textrenderer.h:35
This class defines a single theme.
Definition texttheme.h:68
#define EDBEE_EXPORT
Definition exports.h:15
QT Acessibility has an issue with reporting blank lines between elements lines. defining 'WINDOWS_EMP...
Definition commentcommand.cpp:20