2020-09-06 16:47:38 +01:00
|
|
|
/*
|
2020-12-31 22:08:52 +00:00
|
|
|
* Copyright (C) 2020, 2021 Gavin MacGregor
|
2020-09-06 16:47:38 +01:00
|
|
|
*
|
|
|
|
|
* 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>
|
2021-04-18 16:57:45 +01:00
|
|
|
#include <QGraphicsItemGroup>
|
2020-11-24 13:16:20 +00:00
|
|
|
#include <QGraphicsProxyWidget>
|
|
|
|
|
#include <QGraphicsScene>
|
2020-10-25 11:07:04 +00:00
|
|
|
#include <QPair>
|
2020-09-06 16:47:38 +01:00
|
|
|
#include <QTextStream>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "document.h"
|
2020-09-11 12:06:06 +01:00
|
|
|
#include "levelonepage.h"
|
2020-09-06 16:47:38 +01:00
|
|
|
#include "render.h"
|
|
|
|
|
|
|
|
|
|
class QPaintEvent;
|
|
|
|
|
|
|
|
|
|
class TeletextWidget : public QFrame
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TeletextWidget(QFrame *parent = 0);
|
|
|
|
|
~TeletextWidget();
|
|
|
|
|
void setCharacter(unsigned char);
|
|
|
|
|
void toggleCharacterBit(unsigned char);
|
2021-02-14 17:35:11 +00:00
|
|
|
bool insertMode() const { return m_insertMode; };
|
|
|
|
|
void setInsertMode(bool);
|
2020-09-06 16:47:38 +01:00
|
|
|
|
|
|
|
|
QSize sizeHint() { return QSize(480+(pageRender()->leftSidePanelColumns()+pageRender()->rightSidePanelColumns())*12, 250); }
|
|
|
|
|
|
2021-02-08 21:39:17 +00:00
|
|
|
void inputMethodEvent(QInputMethodEvent *);
|
|
|
|
|
|
2020-09-06 16:47:38 +01:00
|
|
|
TeletextDocument* document() const { return m_teletextDocument; }
|
|
|
|
|
TeletextPageRender *pageRender() { return &m_pageRender; }
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void sizeChanged();
|
2021-04-11 13:03:07 +01:00
|
|
|
void insertKeyPressed();
|
2020-09-06 16:47:38 +01:00
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void subPageSelected();
|
|
|
|
|
void refreshPage();
|
|
|
|
|
void toggleReveal(bool);
|
|
|
|
|
void toggleMix(bool);
|
|
|
|
|
void updateFlashTimer(int);
|
|
|
|
|
void refreshRow(int);
|
|
|
|
|
|
|
|
|
|
void setControlBit(int, bool);
|
|
|
|
|
void setDefaultCharSet(int);
|
|
|
|
|
void setDefaultNOS(int);
|
|
|
|
|
void setDefaultScreenColour(int);
|
|
|
|
|
void setDefaultRowColour(int);
|
|
|
|
|
void setColourTableRemap(int);
|
|
|
|
|
void setBlackBackgroundSubst(bool);
|
|
|
|
|
void setSidePanelWidths(int, int);
|
|
|
|
|
void setSidePanelAtL35Only(bool);
|
2021-05-03 22:17:51 +01:00
|
|
|
|
|
|
|
|
void cut();
|
|
|
|
|
void copy();
|
|
|
|
|
void paste();
|
|
|
|
|
|
2020-09-06 16:47:38 +01:00
|
|
|
void changeSize();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
|
void keyPressEvent(QKeyEvent *event) override;
|
|
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
2020-10-25 11:07:04 +00:00
|
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
2020-09-06 16:47:38 +01:00
|
|
|
void focusInEvent(QFocusEvent *event) override;
|
|
|
|
|
void focusOutEvent(QFocusEvent *event) override;
|
|
|
|
|
|
|
|
|
|
TeletextPageRender m_pageRender;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TeletextDocument* m_teletextDocument;
|
2020-09-16 11:15:46 +01:00
|
|
|
LevelOnePage* m_levelOnePage;
|
2021-04-18 16:57:45 +01:00
|
|
|
bool m_insertMode, m_selectionInProgress;
|
2020-09-06 16:47:38 +01:00
|
|
|
QBasicTimer m_flashTimer;
|
|
|
|
|
int m_flashTiming, m_flashPhase;
|
|
|
|
|
|
|
|
|
|
void timerEvent(QTimerEvent *event) override;
|
2021-05-03 22:17:51 +01:00
|
|
|
void selectionToClipboard();
|
2020-09-06 16:47:38 +01:00
|
|
|
|
2020-10-25 11:07:04 +00:00
|
|
|
QPair<int, int> mouseToRowAndColumn(const QPoint &);
|
2020-09-06 16:47:38 +01:00
|
|
|
};
|
|
|
|
|
|
2020-11-24 13:16:20 +00:00
|
|
|
class LevelOneScene : public QGraphicsScene
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
LevelOneScene(QWidget *, QObject *parent = nullptr);
|
2021-04-18 16:57:45 +01:00
|
|
|
void setBorderDimensions(int, int, int, int, int);
|
2021-05-09 16:34:53 +01:00
|
|
|
QGraphicsRectItem *cursorRectItem() const { return m_cursorRectItem; }
|
2020-11-24 13:16:20 +00:00
|
|
|
|
|
|
|
|
public slots:
|
2021-04-26 21:06:00 +01:00
|
|
|
void updateCursor();
|
2021-04-26 22:08:28 +01:00
|
|
|
void updateSelection();
|
2021-04-18 16:57:45 +01:00
|
|
|
void toggleGrid(bool);
|
2020-11-24 13:16:20 +00:00
|
|
|
void setFullScreenColour(const QColor &);
|
|
|
|
|
void setFullRowColour(int, const QColor &);
|
|
|
|
|
|
2021-05-04 21:52:51 +01:00
|
|
|
signals:
|
|
|
|
|
void mouseZoomIn();
|
|
|
|
|
void mouseZoomOut();
|
|
|
|
|
|
2020-11-24 13:16:20 +00:00
|
|
|
private:
|
2021-05-04 21:52:51 +01:00
|
|
|
bool eventFilter(QObject *, QEvent *);
|
|
|
|
|
|
2020-11-24 13:16:20 +00:00
|
|
|
QGraphicsRectItem *m_fullScreenTopRectItem, *m_fullScreenBottomRectItem;
|
|
|
|
|
QGraphicsRectItem *m_fullRowLeftRectItem[25], *m_fullRowRightRectItem[25];
|
|
|
|
|
QGraphicsProxyWidget *m_levelOneProxyWidget;
|
2021-04-26 22:08:28 +01:00
|
|
|
QGraphicsRectItem *m_cursorRectItem, *m_selectionRectItem;
|
2021-04-18 16:57:45 +01:00
|
|
|
QGraphicsItemGroup *m_mainGridItemGroup, *m_sidePanelGridItemGroup[32];
|
|
|
|
|
bool m_grid, m_sidePanelGridNeeded[32];
|
2020-11-24 13:16:20 +00:00
|
|
|
};
|
|
|
|
|
|
2020-09-06 16:47:38 +01:00
|
|
|
#endif
|