source: projects/punch-card/punch-card-editor/src/app/decktexteditor.h @ 49

Last change on this file since 49 was 49, checked in by sven, 10 years ago
  • Text editing part:

Improved Column counting
80 column line bar

  • Saving with Jones Format works
File size: 2.3 KB
Line 
1#ifndef DECKTEXTEDITOR_H
2#define DECKTEXTEDITOR_H
3
4#include <QPlainTextEdit>
5#include <QDockWidget>
6#include <QSharedPointer>
7
8class TextEditorDock;
9class DeckTextEditor;
10
11#include "cardeditor.h"
12#include "qpunchcard/card.h"
13#include "qpunchcard/codec.h"
14
15class TextEditorDock : public QDockWidget {
16        Q_OBJECT
17
18        EditorWindow* main;
19        DeckTextEditor* editor;
20        QWidget* code_bar;
21        QWidget* color_bar;
22public:
23        TextEditorDock(EditorWindow* parent);
24
25private:
26        void create_code_bar();
27        void create_color_bar();
28
29public slots:
30        void setCard(DeckIndex i);
31        void setCodec(QString by_name);
32        void showTextConverterDialog();
33
34signals:
35        void cardSelected(DeckIndex i);
36};
37
38/// The QPlainTextEditor extension
39class DeckTextEditor : public QPlainTextEdit {
40        Q_OBJECT
41
42        QPointer<EditorWindow> main;
43        QSharedPointer<const Codec> codec;
44        QList<QTextEdit::ExtraSelection> invalid_characters;
45        friend class TextEditorDock;
46
47public:
48        // nested inner class
49        class NumberArea : public QWidget {
50                DeckTextEditor* editor;
51        public:
52                NumberArea(DeckTextEditor* e) : QWidget(e), editor(e) { }
53                QSize sizeHint() const {
54                        return editor->numberAreaSize(this);
55                }
56        protected:
57                void paintEvent(QPaintEvent* event) {
58                        editor->numberAreaPaintEvent(this, event);
59                }
60        };
61
62        DeckTextEditor(EditorWindow* main);
63
64        void numberAreaPaintEvent(NumberArea* area, QPaintEvent* event);
65        QSize numberAreaSize(const NumberArea* area) const;
66        bool translateBlock(const QTextBlock& block);
67        bool checkValidity(int pos);
68        /// returns # of invalid chars
69        int containsInvalidCharacters() { return invalid_characters.count(); }
70
71public slots:
72        // wird Markierung entfernen, wenn ausser gueltigem Blockbereich
73        void highlightRow(DeckIndex i);
74        void contentsChanged(DeckIndex lower_card_index, DeckIndex upper_card_index);
75
76signals:
77        // die aktive Karte des Benutzers
78        void cursorRowChanged(DeckIndex row);
79        void invalidCharactersCountChanged(int new_number);
80
81private:
82        NumberArea* row_area;
83        NumberArea* col_area;
84        int highlighted_row;
85
86protected:
87        void resizeEvent(QResizeEvent* event);
88        void paintEvent(QPaintEvent* e);
89
90private slots:
91        void updateLineNumberAreaWidth(int newBlockCount);
92        void highlightCurrentCursorPos();
93        void paintHighlights();
94        void updateLineNumberArea(const QRect&, int);
95        void translateChanges(int position, int charsRemoved, int charsAdded);
96
97}; // class
98
99
100#endif // DECKTEXTEDITOR_H
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License