-
Notifications
You must be signed in to change notification settings - Fork 3
/
mainwidget.h
146 lines (120 loc) · 4.33 KB
/
mainwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* Copyright (C) 2020-2024 Gavin MacGregor
*
* This file is part of QTeletextMaker.
*
* QTeletextMaker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QTeletextMaker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MAINWIDGET_H
#define MAINWIDGET_H
#include <QBasicTimer>
#include <QFrame>
#include <QGraphicsItemGroup>
#include <QGraphicsProxyWidget>
#include <QGraphicsScene>
#include <QPair>
#include <QTextStream>
#include <vector>
#include "decode.h"
#include "document.h"
#include "levelonepage.h"
#include "render.h"
class QPaintEvent;
class TeletextWidget : public QFrame
{
Q_OBJECT
public:
TeletextWidget(QFrame *parent = 0);
~TeletextWidget();
void setCharacter(unsigned char newCharacter);
void toggleCharacterBit(unsigned char bitToToggle);
bool insertMode() const { return m_insertMode; };
void setInsertMode(bool insertMode);
bool showControlCodes() const { return m_pageRender.showControlCodes(); };
QSize sizeHint() { return QSize(480+(pageDecode()->leftSidePanelColumns()+pageDecode()->rightSidePanelColumns())*12, 250); }
void inputMethodEvent(QInputMethodEvent *event);
TeletextDocument* document() const { return m_teletextDocument; }
TeletextPageDecode *pageDecode() { return &m_pageDecode; }
TeletextPageRender *pageRender() { return &m_pageRender; }
signals:
void sizeChanged();
void insertKeyPressed();
public slots:
void subPageSelected();
void refreshPage();
void setReveal(bool reveal);
void setMix(bool mix);
void setShowControlCodes(bool showControlCodes);
void updateFlashTimer(int newFlashTimer);
void pauseFlash(bool pauseNow);
void setControlBit(int bitNumber, bool active);
void setDefaultCharSet(int newDefaultCharSet);
void setDefaultNOS(int newDefaultNOS);
void setSidePanelWidths(int newLeftSidePanelColumns, int newRightSidePanelColumns);
void setSidePanelAtL35Only(bool newSidePanelAtL35Only);
void cut();
void copy();
void paste();
void changeSize();
protected:
void paintEvent(QPaintEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
TeletextPageDecode m_pageDecode;
TeletextPageRender m_pageRender;
private:
TeletextDocument* m_teletextDocument;
LevelOnePage* m_levelOnePage;
bool m_insertMode, m_selectionInProgress;
QBasicTimer m_flashTimer;
int m_flashTiming, m_flashPhase;
void timerEvent(QTimerEvent *event) override;
void selectionToClipboard();
QPair<int, int> mouseToRowAndColumn(const QPoint &mousePosition);
};
class LevelOneScene : public QGraphicsScene
{
Q_OBJECT
public:
LevelOneScene(QWidget *levelOneWidget, QObject *parent = nullptr);
void setBorderDimensions(int sceneWidth, int sceneHeight, int widgetWidth, int leftSidePanelColumns, int rightSidePanelColumns);
QGraphicsRectItem *cursorRectItem() const { return m_cursorRectItem; }
public slots:
void updateCursor();
void updateSelection();
void setMix(bool mix);
void toggleGrid(bool gridOn);
void hideGUIElements(bool hidden);
void setFullScreenColour(const QColor &newColor);
void setFullRowColour(int row, const QColor &newColor);
signals:
void mouseZoomIn();
void mouseZoomOut();
protected:
bool eventFilter(QObject *object, QEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *keyEvent);
private:
QGraphicsRectItem *m_fullScreenTopRectItem, *m_fullScreenBottomRectItem;
QGraphicsRectItem *m_fullRowLeftRectItem[25], *m_fullRowRightRectItem[25];
QGraphicsProxyWidget *m_levelOneProxyWidget;
QGraphicsRectItem *m_cursorRectItem, *m_selectionRectItem;
QGraphicsItemGroup *m_mainGridItemGroup, *m_sidePanelGridItemGroup[32];
bool m_grid, m_sidePanelGridNeeded[32];
};
#endif