edbee - Qt Editor Library v0.11.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
texteditorwidget.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 <QAbstractScrollArea>
10
11#include <QStringList>
12#include <QWidget>
13
14class QResizeEvent;
15class QScrollBar;
16
17namespace edbee {
18
19class TextDocument;
28class TextRenderer;
29class TextSelection;
30
31
35class EDBEE_EXPORT TextEditorWidget : public QWidget
36{
37 Q_OBJECT
38public:
39
40 explicit TextEditorWidget(TextEditorController *controller, QWidget *parent = 0);
41 explicit TextEditorWidget(TextDocument *document, QWidget *parent = 0);
42 explicit TextEditorWidget(TextEditorConfig *config, QWidget *parent = 0);
43 explicit TextEditorWidget(QWidget *parent = 0);
44 virtual ~TextEditorWidget();
45
46 void scrollPositionVisible( int xPosIn, int yPosIn );
47
48 // a whole bunch of getters
50 TextEditorConfig* config() const;
52 TextEditorKeyMap* keyMap() const;
59
60 void resetCaretTime();
61 void fullUpdate();
62
63 QScrollBar* horizontalScrollBar() const;
64 QScrollBar* verticalScrollBar() const;
65 void setVerticalScrollBar( QScrollBar* scrollBar );
66 void setHorizontalScrollBar( QScrollBar* scrollBar );
67 int autoScrollMargin() const;
68 void setAutoScrollMargin(int amount=50);
69 void setPlaceholderText(const QString& text);
70
71 virtual bool readonly() const;
72 void setReadonly(bool readonly);
73
74
75protected:
76
77 virtual void resizeEvent(QResizeEvent* event);
78 bool eventFilter(QObject *obj, QEvent *event );
79
80signals:
81 void focusIn(QWidget* event);
82 void focusOut(QWidget* event);
83
84 void verticalScrollBarChanged( QScrollBar* newScrollBar );
85 void horizontalScrollBarChanged( QScrollBar* newScrollBar );
86
87protected slots:
88
91
92public slots:
93
94 void scrollTopToLine( int line );
95 virtual void updateLineAtOffset(int offset);
96 virtual void updateAreaAroundOffset(int offset, int width=8);
97 virtual void updateLine( int line, int length=1 );
98 virtual void updateComponents();
99
100 virtual void updateGeometryComponents();
101
102 virtual void updateRendererViewport();
103
104private:
105
106 TextEditorController* controller_;
107
108 TextEditorScrollArea* scrollAreaRef_;
109 TextEditorComponent* editCompRef_;
110 TextMarginComponent* marginCompRef_;
111 TextEditorAutoCompleteComponent* autoCompleteCompRef_;
112
113 int autoScrollMargin_;
114 bool readonly_;
115};
116
117} // edbee
This is the base and abstract class of a text document A TextDocument is the model part of the editor...
Definition textdocument.h:42
An autocomplete list Which receives it's autocomplete list from the document.
Definition texteditorautocompletecomponent.h:55
This is a texteditor map. This is used to map Command-Names to commands This class is the owner of th...
Definition texteditorcommandmap.h:20
This is the main texteditor-component (which is the true editor) This is the QWidget that recieves th...
Definition texteditorcomponent.h:29
General configuration settings of the text editor.
Definition texteditorconfig.h:18
The texteditor works via the controller. The controller is the central point/mediator which maps/cont...
Definition texteditorcontroller.h:39
A text editor key map This key map, maps key-sequences to action-names.
Definition texteditorkeymap.h:39
A special scrollarea that makes it possible to add components to the margins of it.
Definition texteditorscrollarea.h:19
TextEditorCommandMap * commandMap() const
Return the associated commandmap.
Definition texteditorwidget.cpp:165
TextEditorWidget(TextEditorController *controller, QWidget *parent=0)
The default TextEditor widget constructor.
Definition texteditorwidget.cpp:50
QScrollBar * horizontalScrollBar() const
Return the horizontal scrollbar.
Definition texteditorwidget.cpp:237
QScrollBar * verticalScrollBar() const
returns the vertical scrollbar
Definition texteditorwidget.cpp:244
TextEditorConfig * config() const
Returns the configuration object for this widget.
Definition texteditorwidget.cpp:158
virtual void updateAreaAroundOffset(int offset, int width=8)
updates the character before and at the given offset
Definition texteditorwidget.cpp:360
void verticalScrollBarChanged(QScrollBar *newScrollBar)
Definition moc_texteditorwidget.cpp:376
void horizontalScrollBarChanged(QScrollBar *newScrollBar)
Definition moc_texteditorwidget.cpp:383
void setPlaceholderText(const QString &text)
Definition texteditorwidget.cpp:281
TextEditorKeyMap * keyMap() const
return the associated keymap
Definition texteditorwidget.cpp:172
void focusIn(QWidget *event)
Definition moc_texteditorwidget.cpp:362
virtual void updateLine(int line, int length=1)
This method repaints the given lines.
Definition texteditorwidget.cpp:370
TextSelection * textSelection() const
Return the textselection.
Definition texteditorwidget.cpp:193
int autoScrollMargin() const
Returns the auto scroll margin.
Definition texteditorwidget.cpp:270
TextDocument * textDocument() const
Returns the textdocument for this widget.
Definition texteditorwidget.cpp:179
void connectVerticalScrollBar()
Connects the vertical scrollbar so it updates the rendering viewport.
Definition texteditorwidget.cpp:330
void setVerticalScrollBar(QScrollBar *scrollBar)
Use this method to change a scrollbar. By using this method listeners of the scrollbar well be inform...
Definition texteditorwidget.cpp:253
virtual void updateGeometryComponents()
Updates the geometry for all components.
Definition texteditorwidget.cpp:387
virtual void updateLineAtOffset(int offset)
updates the given line so it will be repainted @Param offset the offset of the line that needs repain...
Definition texteditorwidget.cpp:350
virtual bool readonly() const
Return the readonly status.
Definition texteditorwidget.cpp:288
virtual void resizeEvent(QResizeEvent *event)
This method is called when a resize happens.
Definition texteditorwidget.cpp:302
TextEditorController * controller() const
returns the controller for this editor
Definition texteditorwidget.cpp:141
virtual void updateComponents()
Calls update on all components.
Definition texteditorwidget.cpp:379
void connectHorizontalScrollBar()
Connects the horizontal scrollbar so it updates the rendering viewport.
Definition texteditorwidget.cpp:337
TextRenderer * textRenderer() const
Returns the text-renderer.
Definition texteditorwidget.cpp:186
void scrollPositionVisible(int xPosIn, int yPosIn)
This method makes sure the given position is visible.
Definition texteditorwidget.cpp:133
TextMarginComponent * textMarginComponent() const
Returns the active margin component.
Definition texteditorwidget.cpp:207
void resetCaretTime()
This method resets the caret time.
Definition texteditorwidget.cpp:221
void setHorizontalScrollBar(QScrollBar *scrollBar)
Use this method to change the horizontal scrollbar. By using this method listeners of the scrollbar w...
Definition texteditorwidget.cpp:263
TextEditorScrollArea * textScrollArea() const
Returns the active scroll area.
Definition texteditorwidget.cpp:214
TextEditorComponent * textEditorComponent() const
Returns the editor component-part of the editor.
Definition texteditorwidget.cpp:200
bool eventFilter(QObject *obj, QEvent *event)
a basic event-filter for receiving focus-events of the editor
Definition texteditorwidget.cpp:311
void setAutoScrollMargin(int amount=50)
Sets the auto scrollmargin.
Definition texteditorwidget.cpp:276
virtual void updateRendererViewport()
Updates the renderer viewport.
Definition texteditorwidget.cpp:400
void fullUpdate()
This method performs a full update. Which means it calibrates the scrollbars invalidates all caches,...
Definition texteditorwidget.cpp:229
void setReadonly(bool readonly)
Set the readonly status.
Definition texteditorwidget.cpp:294
void scrollTopToLine(int line)
this method scrolls the top position to the given line
Definition texteditorwidget.cpp:149
void focusOut(QWidget *event)
Definition moc_texteditorwidget.cpp:369
The margin/line-number component This class is used for rendering line-numbers etc.
Definition textmargincomponent.h:53
A class for rendering the text.
Definition textrenderer.h:35
The class textselection is a RangeSet that is used by the view of the document.
Definition textselection.h:25
#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