mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2024-10-13 16:23:46 +00:00
Updates to CharacterSetExplorer in CharSetViewer
This commit is contained in:
parent
581ac6fa5e
commit
2f8c2cfd59
@ -7,6 +7,7 @@
|
||||
CharSetViewer::CharSetViewer(QWidget *parent) : FileViewerInterface(parent)
|
||||
{
|
||||
m_file = Q_NULLPTR;
|
||||
m_cse = Q_NULLPTR;
|
||||
|
||||
QGridLayout *qgl = new QGridLayout(this);
|
||||
setLayout(qgl);
|
||||
@ -14,6 +15,10 @@ CharSetViewer::CharSetViewer(QWidget *parent) : FileViewerInterface(parent)
|
||||
setWindowTitle(title);
|
||||
}
|
||||
|
||||
CharSetViewer::~CharSetViewer()
|
||||
{
|
||||
}
|
||||
|
||||
void CharSetViewer::setFile(GenericFile *file)
|
||||
{
|
||||
if (dynamic_cast<BinaryFile*>(file))
|
||||
@ -73,9 +78,30 @@ bool CharSetViewer::optionsMenuItems(QMenu *menu)
|
||||
connect(action, SIGNAL(toggled(bool)),SLOT(enableBitShift(bool)));
|
||||
menu->addAction(action);
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
action = new QAction("&Character Set Explorer...");
|
||||
connect(action, SIGNAL(triggered(bool)), SLOT(showExplorer()));
|
||||
menu->addAction(action);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CharSetViewer::showExplorer()
|
||||
{
|
||||
if (!m_cse) {
|
||||
m_cse = new CharacterSetExplorer(this);
|
||||
connect(m_cse, SIGNAL(destroyed(QObject*)), SLOT(cleanupExplorer()));
|
||||
m_cse->setCharSet(m_charset);
|
||||
}
|
||||
m_cse->show();
|
||||
m_cse->raise();
|
||||
}
|
||||
|
||||
void CharSetViewer::cleanupExplorer()
|
||||
{
|
||||
m_cse = Q_NULLPTR;
|
||||
}
|
||||
|
||||
QList<CharacterWidget *> CharSetViewer::getChildren()
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "binaryfile.h"
|
||||
#include "characterwidget.h"
|
||||
#include "fileviewerinterface.h"
|
||||
#include "CharacterSetExplorer.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
@ -12,6 +13,7 @@ class CharSetViewer : public FileViewerInterface
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CharSetViewer(QWidget *parent = 0);
|
||||
virtual ~CharSetViewer();
|
||||
|
||||
void setFile(GenericFile *file);
|
||||
void setFile(BinaryFile *file);
|
||||
@ -26,12 +28,16 @@ public slots:
|
||||
void showGrid(bool show);
|
||||
void enableBitShift(bool enable);
|
||||
|
||||
void showExplorer();
|
||||
|
||||
signals:
|
||||
|
||||
protected:
|
||||
QList<CharacterWidget*> getChildren();
|
||||
|
||||
protected slots:
|
||||
void cleanupExplorer();
|
||||
|
||||
private:
|
||||
BinaryFile *m_file;
|
||||
|
||||
@ -39,6 +45,7 @@ private:
|
||||
|
||||
CharacterSet m_charset;
|
||||
|
||||
CharacterSetExplorer *m_cse;
|
||||
};
|
||||
|
||||
#endif // CHARSETVIEWER_H
|
||||
|
@ -5,10 +5,82 @@ CharacterSetExplorer::CharacterSetExplorer(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CharacterSetExplorer)
|
||||
{
|
||||
m_unpackedScreen.fill(0,8192);
|
||||
ui->setupUi(this);
|
||||
connect(ui->drawButton, SIGNAL(clicked(bool)), SLOT(handleDrawButton()));
|
||||
connect(ui->insertChar, SIGNAL(clicked(bool)), SLOT(handleInsertCharButton()));
|
||||
connect(ui->inputText, SIGNAL(textChanged(QString)), SLOT(handleTextChanged(QString)));
|
||||
}
|
||||
|
||||
void CharacterSetExplorer::setCharSet(CharacterSet &charset)
|
||||
{
|
||||
m_charset = charset;
|
||||
}
|
||||
|
||||
CharacterSetExplorer::~CharacterSetExplorer()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CharacterSetExplorer::handleDrawButton()
|
||||
{
|
||||
handleTextChanged(ui->inputText->text());
|
||||
}
|
||||
|
||||
void CharacterSetExplorer::handleInsertCharButton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CharacterSetExplorer::handleTextChanged(QString string)
|
||||
{
|
||||
int currCursorX = 0;
|
||||
int currCursorY = 0;
|
||||
m_unpackedScreen.fill(0x00,8192);
|
||||
|
||||
foreach (QChar character, string)
|
||||
{
|
||||
if (character.unicode() < 128)
|
||||
{
|
||||
if (character.unicode() < 32)
|
||||
{
|
||||
// Handle control character
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle ASCII value
|
||||
if (m_charset.contains(character.unicode()))
|
||||
{
|
||||
QByteArray chardata = m_charset[character.unicode()].data();
|
||||
|
||||
for (int idx = 0; idx < 8; idx++)
|
||||
{
|
||||
int baseY = (currCursorY * 8 + idx) * 40;
|
||||
quint8 chr = chardata[idx];
|
||||
m_unpackedScreen[baseY + currCursorX] = chr;
|
||||
}
|
||||
currCursorX++;
|
||||
|
||||
if (currCursorX >= 40) {
|
||||
currCursorY++;
|
||||
currCursorX = 0;
|
||||
}
|
||||
if (currCursorY >= 24)
|
||||
{
|
||||
currCursorX = 0;
|
||||
currCursorY = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Character" << character.unicode() << "not defined in char set";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Unhandled character: " << character.unicode();
|
||||
}
|
||||
}
|
||||
ui->drawWidget->setUnpackedData(m_unpackedScreen);
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "charset.h"
|
||||
|
||||
namespace Ui {
|
||||
class CharacterSetExplorer;
|
||||
}
|
||||
@ -15,8 +17,19 @@ public:
|
||||
explicit CharacterSetExplorer(QWidget *parent = 0);
|
||||
~CharacterSetExplorer();
|
||||
|
||||
void setCharSet(CharacterSet &charset);
|
||||
|
||||
public slots:
|
||||
void handleDrawButton();
|
||||
void handleInsertCharButton();
|
||||
void handleTextChanged(QString string);
|
||||
|
||||
private:
|
||||
Ui::CharacterSetExplorer *ui;
|
||||
|
||||
QByteArray m_unpackedScreen;
|
||||
|
||||
CharacterSet m_charset;
|
||||
};
|
||||
|
||||
#endif // CHARACTERSETEXPLORER_H
|
||||
|
@ -10,12 +10,31 @@
|
||||
<height>352</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" rowstretch="1,999999">
|
||||
<item row="1" column="0">
|
||||
<widget class="QWidget" name="drawWidget" native="true"/>
|
||||
<widget class="HiresScreenWidget" name="drawWidget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>561</width>
|
||||
<height>384</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
@ -29,6 +48,13 @@
|
||||
<item>
|
||||
<widget class="QLineEdit" name="inputText"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="insertChar">
|
||||
<property name="text">
|
||||
<string>Insert Char...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="drawButton">
|
||||
<property name="text">
|
||||
@ -40,6 +66,14 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>HiresScreenWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>HiresScreenWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -120,8 +120,8 @@ void HiresScreenWidget::resizeEvent(QResizeEvent *)
|
||||
|
||||
}
|
||||
|
||||
void HiresScreenWidget::drawPixmap() {
|
||||
|
||||
void HiresScreenWidget::drawPixmap()
|
||||
{
|
||||
QPainter pmpainter(&m_pixmap);
|
||||
|
||||
pmpainter.setBrush(Qt::black);
|
||||
@ -207,7 +207,7 @@ void HiresScreenWidget::drawPixmap() {
|
||||
int xoff = cr.col() * 7;
|
||||
int yoff = cr.row() * 2;
|
||||
|
||||
quint8 cOffset = 0;// highBit?1:0;
|
||||
quint8 cOffset = highBit?1:0;
|
||||
|
||||
quint8 doubleScan = 0;
|
||||
if (!m_showScanLines)
|
||||
@ -276,7 +276,11 @@ QByteArray HiresScreenWidget::packData(QByteArray unpackedData)
|
||||
for (int idx = 0; idx < qMin(unpackedData.count(),8192); idx++)
|
||||
{
|
||||
ColRow cr = getColRowFromRawAddress(idx);
|
||||
packedData[cr.appleAddress()] = unpackedData[idx];
|
||||
|
||||
if (cr.isDefined())
|
||||
{
|
||||
packedData[cr.appleAddress()] = unpackedData[idx];
|
||||
}
|
||||
}
|
||||
|
||||
return packedData;
|
||||
@ -303,20 +307,17 @@ int HiresScreenWidget::getLineAddressOffset(int line)
|
||||
void HiresScreenWidget::setData(QByteArray data) {
|
||||
m_data = data;
|
||||
|
||||
drawPixmap();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void HiresScreenWidget::drawMonoLine(QPainter &painter, int lineNum, QBitArray data) {
|
||||
painter.setPen(Qt::black);
|
||||
painter.drawLine(0,lineNum,data.count(),lineNum);
|
||||
painter.setPen(Qt::white);
|
||||
for (int idx = 0; idx < data.count(); idx++) {
|
||||
|
||||
if (data.at(idx))
|
||||
{
|
||||
painter.setPen(Qt::white);
|
||||
} else {
|
||||
painter.setPen(Qt::black);
|
||||
}
|
||||
|
||||
painter.drawPoint(idx,lineNum);
|
||||
painter.drawPoint(idx,lineNum);
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,7 +403,6 @@ QColor HiresScreenWidget::getColorFromBits(QBitArray bits, quint8 phase)
|
||||
if (bitval == 7 && phase == 3) return lightBlueColor;
|
||||
|
||||
return whiteColor;
|
||||
|
||||
}
|
||||
|
||||
void HiresScreenWidget::drawNtscLine(QPainter &painter, int lineNum, QBitArray data) {
|
||||
@ -479,7 +479,6 @@ HiresScreenWidget::ColRow HiresScreenWidget::getColRowFromRawAddress(quint16 add
|
||||
|
||||
void HiresScreenWidget::makeAddressTables()
|
||||
{
|
||||
qDebug() << " ****** makeAddressTables()";
|
||||
m_rawAddressToColRowList.resize(8192);
|
||||
m_appleAddressToColRowList.resize(8192);
|
||||
|
||||
@ -488,7 +487,6 @@ void HiresScreenWidget::makeAddressTables()
|
||||
for (int col = 0; col < 40; col++)
|
||||
{
|
||||
ColRow cr(col,row);
|
||||
// qDebug() << "Col: " << col << "Row: " << row << "Raw: " << cr.rawAddress() << " Apple: " << cr.appleAddress();
|
||||
|
||||
m_rawAddressToColRowList[cr.rawAddress()] = cr;
|
||||
m_appleAddressToColRowList[cr.appleAddress()] = cr;
|
||||
|
@ -24,14 +24,13 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class CharacterSet
|
||||
{
|
||||
public:
|
||||
void buildSetFromSetBlob(QByteArray data);
|
||||
CharSetCharacter operator[](int asciival) const { return m_charmap[asciival]; }
|
||||
QList<CharSetCharacter> allCharacters() const;
|
||||
bool contains(int asciival) { return m_charmap.keys().contains(asciival); }
|
||||
|
||||
private:
|
||||
QMap<int, CharSetCharacter> m_charmap;
|
||||
|
Loading…
Reference in New Issue
Block a user