edbee - Qt Editor Library
texteditorcomponent.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <QSize>
9 #include <QWidget>
10 
11 namespace edbee {
12 
13 class TextDocument;
14 class TextEditorCommandMap;
15 class TextEditorConfig;
16 class TextEditorController;
17 class TextEditorRenderer;
18 class TextEditorKeyMap;
19 class TextRenderer;
20 class TextSelection;
21 
22 
25 class TextEditorComponent : public QWidget
26 {
27  Q_OBJECT
28 public:
29  explicit TextEditorComponent( TextEditorController* controller, QWidget *parent = 0);
30  virtual ~TextEditorComponent();
31 
33  TextEditorConfig* config() const;
34  TextDocument* textDocument() const;
38 
39  TextEditorRenderer* textEditorRenderer() { return textEditorRenderer_; }
41 
42  void resetCaretTime();
43  void fullUpdate();
44 
45  virtual QSize sizeHint() const;
46 
47 protected:
48  virtual void paintEvent( QPaintEvent* paintEvent );
49  virtual bool event( QEvent* event );
50  virtual void keyPressEvent( QKeyEvent* event );
51  virtual void keyReleaseEvent ( QKeyEvent* event );
52  void inputMethodEvent( QInputMethodEvent* m );
53  QVariant inputMethodQuery( Qt::InputMethodQuery p ) const;
54  virtual void mousePressEvent( QMouseEvent* event );
55  virtual void mouseDoubleClickEvent( QMouseEvent* event );
56  virtual void mouseMoveEvent( QMouseEvent* event );
57  virtual void focusInEvent( QFocusEvent* event );
58  virtual void focusOutEvent( QFocusEvent* event );
59  virtual void contextMenuEvent(QContextMenuEvent* event);
60 
61 public slots:
62 
63  void repaintCarets();
64  virtual void updateLineAtOffset(int offset);
65  virtual void updateAreaAroundOffset(int offset, int width=8);
66  virtual void updateLine( int line, int length );
67 
68 private:
69 
70  TextRenderer* textRenderer() const;
71 
72  QTimer* caretTimer_;
73 
74  QKeySequence lastKeySequence_;
75  QString lastCharacter_;
76 
77  TextEditorController* controllerRef_;
78  TextEditorRenderer* textEditorRenderer_;
79 };
80 
81 } // edbee
void fullUpdate()
A slow and full update of the control.
Definition: texteditorcomponent.cpp:162
This is the base and abstract class of a text document A TextDocument is the model part of the editor...
Definition: textdocument.h:40
TextEditorComponent(TextEditorController *controller, QWidget *parent=0)
The default texteditor compenent constructor.
Definition: texteditorcomponent.cpp:34
void repaintCarets()
This method repaints &#39;all&#39; carets.
Definition: texteditorcomponent.cpp:477
virtual QSize sizeHint() const
returns the size hint. This is the total size of the editor-area
Definition: texteditorcomponent.cpp:130
A class for rendering the text.
Definition: textrenderer.h:34
virtual void mouseMoveEvent(QMouseEvent *event)
A mouse move event.
Definition: texteditorcomponent.cpp:419
virtual void focusInEvent(QFocusEvent *event)
A focus in event occured.
Definition: texteditorcomponent.cpp:441
The class textselection is a RangeSet that is used by the view of the document.
Definition: textselection.h:24
virtual void updateLine(int line, int length)
This method invalidates the given lines.
Definition: texteditorcomponent.cpp:537
virtual ~TextEditorComponent()
The destructor of the the component.
Definition: texteditorcomponent.cpp:74
This is the main texteditor-component (which is the true editor) This is the QWidget that recieves th...
Definition: texteditorcomponent.h:25
General configuration settings of the text editor.
Definition: texteditorconfig.h:17
Copyright 2011-2013 - Reliable Bits Software by Blommers IT.
Definition: commentcommand.cpp:22
TextSelection * textSelection()
Returns the texselection range.
Definition: texteditorcomponent.cpp:117
TextEditorKeyMap * keyMap()
Returns the current keymap.
Definition: texteditorcomponent.cpp:103
TextDocument * textDocument() const
Returns the active textdocument.
Definition: texteditorcomponent.cpp:96
QVariant inputMethodQuery(Qt::InputMethodQuery p) const
currently unused ?!
Definition: texteditorcomponent.cpp:351
virtual void updateLineAtOffset(int offset)
updates the given line so it will be repainted
Definition: texteditorcomponent.cpp:507
This is a texteditor map. This is used to map Command-Names to commands This class is the owner of th...
Definition: texteditorcommandmap.h:19
TextEditorRenderer * textEditorRenderer()
Definition: texteditorcomponent.h:39
virtual void keyPressEvent(QKeyEvent *event)
handle keypresses
Definition: texteditorcomponent.cpp:234
virtual void updateAreaAroundOffset(int offset, int width=8)
updates the character before and at the given offest
Definition: texteditorcomponent.cpp:522
A text editor key map This key map, maps key-sequences to action-names.
Definition: texteditorkeymap.h:39
void giveTextEditorRenderer(TextEditorRenderer *renderer)
Definition: texteditorcomponent.cpp:122
virtual void mousePressEvent(QMouseEvent *event)
A mouse press happens.
Definition: texteditorcomponent.cpp:366
The texteditor works via the controller. The controller is the central point/mediater which maps/cont...
Definition: texteditorcontroller.h:37
virtual bool event(QEvent *event)
This method is used to FORCE the interception of tab events.
Definition: texteditorcomponent.cpp:214
void resetCaretTime()
This method resets the caret timer The caret time is used for blinking carets When resetting the time...
Definition: texteditorcomponent.cpp:150
void inputMethodEvent(QInputMethodEvent *m)
input method event
Definition: texteditorcomponent.cpp:325
virtual void focusOutEvent(QFocusEvent *event)
The focus is lost, we must STOP coalescing of undo-events!
Definition: texteditorcomponent.cpp:448
virtual void contextMenuEvent(QContextMenuEvent *event)
The default context menu is requested Add the default menu actions.
Definition: texteditorcomponent.cpp:458
virtual void mouseDoubleClickEvent(QMouseEvent *event)
A mouse double click happens.
Definition: texteditorcomponent.cpp:391
virtual void keyReleaseEvent(QKeyEvent *event)
the key release event
Definition: texteditorcomponent.cpp:303
Definition: texteditorrenderer.h:17
TextEditorConfig * config() const
Returns the active configuration.
Definition: texteditorcomponent.cpp:89
TextEditorCommandMap * commandMap()
Returns the active commandmap.
Definition: texteditorcomponent.cpp:82
TextEditorController * controller()
Returns the active texteditor controller.
Definition: texteditorcomponent.cpp:110
virtual void paintEvent(QPaintEvent *paintEvent)
paint the editor
Definition: texteditorcomponent.cpp:173