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

Last change on this file since 47 was 47, checked in by sven, 10 years ago

Continued implementation:

  • removed bugs
  • improved features

Programming continues, but quite slow since I've got few time... unfortunately

File size: 1.8 KB
Line 
1#ifndef DECKTEXTEDITOR_H
2#define DECKTEXTEDITOR_H
3
4#include <QPlainTextEdit>
5#include <QDockWidget>
6
7class TextEditorDock;
8class DeckTextEditor;
9
10#include "cardeditor.h"
11#include "qpunchcard/card.h"
12#include "qpunchcard/codec.h"
13
14class TextEditorDock : public QDockWidget {
15        Q_OBJECT
16
17        EditorWindow* main;
18        QPunchCard::Codec* codec;
19        DeckTextEditor* editor;
20public:
21        TextEditorDock(EditorWindow* parent);
22
23public slots:
24        void setCard(DeckIndex i);
25
26signals:
27        void cardSelected(DeckIndex i);
28};
29
30/// The QPlainTextEditor extension
31class DeckTextEditor : public QPlainTextEdit {
32        Q_OBJECT
33
34        EditorWindow* main;
35
36public:
37        // nested inner class
38        class NumberArea : public QWidget {
39                DeckTextEditor* editor;
40        public:
41                NumberArea(DeckTextEditor* e) : QWidget(e), editor(e) { }
42                QSize sizeHint() const {
43                        return editor->numberAreaSize(this);
44                }
45        protected:
46                void paintEvent(QPaintEvent* event) {
47                        editor->numberAreaPaintEvent(this, event);
48                }
49        };
50
51        DeckTextEditor(EditorWindow* main);
52
53        void numberAreaPaintEvent(NumberArea* area, QPaintEvent* event);
54        QSize numberAreaSize(const NumberArea* area) const;
55
56public slots:
57        // wird Markierung entfernen, wenn ausser gueltigem Blockbereich
58        void highlightRow(DeckIndex i);
59        void contentsChanged(DeckIndex lower_card_index, DeckIndex upper_card_index);
60
61signals:
62        // die aktive Karte des Benutzers
63        void cursorRowChanged(DeckIndex row);
64
65private:
66        NumberArea* row_area;
67        NumberArea* col_area;
68        int highlighted_row;
69
70protected:
71        void resizeEvent(QResizeEvent* event);
72
73private slots:
74        void updateLineNumberAreaWidth(int newBlockCount);
75        void highlightCurrentCursorPos();
76        void paintHighlights();
77        void updateLineNumberArea(const QRect&, int);
78        void translateChanges(int position, int charsRemoved, int charsAdded);
79
80}; // class
81
82
83#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