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

Last change on this file since 48 was 48, checked in by sven, 10 years ago
  • Fixed more bugs
  • Cardeditor is now capable of writing text live using Codecs
  • Toolbars for Cardeditor, Codec changing menu
  • etc...
File size: 2.0 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        friend class TextEditorDock;
45
46public:
47        // nested inner class
48        class NumberArea : public QWidget {
49                DeckTextEditor* editor;
50        public:
51                NumberArea(DeckTextEditor* e) : QWidget(e), editor(e) { }
52                QSize sizeHint() const {
53                        return editor->numberAreaSize(this);
54                }
55        protected:
56                void paintEvent(QPaintEvent* event) {
57                        editor->numberAreaPaintEvent(this, event);
58                }
59        };
60
61        DeckTextEditor(EditorWindow* main);
62
63        void numberAreaPaintEvent(NumberArea* area, QPaintEvent* event);
64        QSize numberAreaSize(const NumberArea* area) const;
65        bool translateBlock(const QTextBlock& block);
66
67public slots:
68        // wird Markierung entfernen, wenn ausser gueltigem Blockbereich
69        void highlightRow(DeckIndex i);
70        void contentsChanged(DeckIndex lower_card_index, DeckIndex upper_card_index);
71
72signals:
73        // die aktive Karte des Benutzers
74        void cursorRowChanged(DeckIndex row);
75
76private:
77        NumberArea* row_area;
78        NumberArea* col_area;
79        int highlighted_row;
80
81protected:
82        void resizeEvent(QResizeEvent* event);
83
84private slots:
85        void updateLineNumberAreaWidth(int newBlockCount);
86        void highlightCurrentCursorPos();
87        void paintHighlights();
88        void updateLineNumberArea(const QRect&, int);
89        void translateChanges(int position, int charsRemoved, int charsAdded);
90
91}; // class
92
93
94#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