| 1 | // File: memorycellgraphicsitem.cppcxx . . $ `<file>/memorycellgraphicsitem.cpp`/ |
| 2 | /* |
| 3 | Pep8-1 is a virtual machine for writing machine language and assembly |
| 4 | language programs. |
| 5 | |
| 6 | Copyright (C) 2009 J. Stanley Warford, Pepperdine University |
| 7 | |
| 8 | This program is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 3 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | */ |
| 21 | |
| 22 | #include "memorycellgraphicsitem.h"cxx . . $ `<file>/memorycellgraphicsitem.h`/ |
| 23 | #include "pep.h"cxx . . $ `<file>/pep.h`/ |
| 24 | #include "sim.h"cxx . . $ `<file>/sim.h`/ |
| 25 | #include <QPainter> |
| 26 | |
| 27 | // #include <QDebug> |
| 28 | |
| 29 | const int MemoryCellGraphicsItemcxx . . $ MemoryCellGraphicsItem#::boxHeightcxx . . $ MemoryCellGraphicsItem#boxHeight. = 22; |
| 30 | const int MemoryCellGraphicsItemcxx . . $ MemoryCellGraphicsItem#::boxWidthcxx . . $ MemoryCellGraphicsItem#boxWidth. = 50; |
| 31 | const int MemoryCellGraphicsItemcxx . . $ MemoryCellGraphicsItem#::addressWidthcxx . . $ MemoryCellGraphicsItem#addressWidth. = 48; |
| 32 | const int MemoryCellGraphicsItemcxx . . $ MemoryCellGraphicsItem#::symbolWidthcxx . . $ MemoryCellGraphicsItem#symbolWidth. = 96; |
| 33 | const int MemoryCellGraphicsItemcxx . . $ MemoryCellGraphicsItem#::bufferWidthcxx . . $ MemoryCellGraphicsItem#bufferWidth. = 14; |
| 34 | |
| 35 | MemoryCellGraphicsItemcxx . . $ MemoryCellGraphicsItem#::MemoryCellGraphicsItemcxx . . $ MemoryCellGraphicsItem#MemoryCellGraphicsItem(fdb9435aa122334d).(int addr, QStringcxx . . $ QString# sym, Enucxx . . $ Enu/::ESymbolFormatcxx . . $ Enu/ESymbolFormat# eSymFrmt, int xLoc, int yLoc) |
| 36 | { |
| 37 | xcxx . . $ MemoryCellGraphicsItem#x. = xLoc; |
| 38 | ycxx . . $ MemoryCellGraphicsItem#y. = yLoc; |
| 39 | addresscxx . . $ MemoryCellGraphicsItem#address. = addr; |
| 40 | symbolcxx . . $ MemoryCellGraphicsItem#symbol. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). sym; |
| 41 | eSymbolFormatcxx . . $ MemoryCellGraphicsItem#eSymbolFormat. = eSymFrmt; |
| 42 | boxColorcxx . . $ MemoryCellGraphicsItem#boxColor. =cxx . . $ QColor#`operator=`(7dc25a5504d99c29). Qtcxx . . $ Qt/::blackcxx . . $ Qt/black.; |
| 43 | boxBgColorcxx . . $ MemoryCellGraphicsItem#boxBgColor. =cxx . . $ QColor#`operator=`(7dc25a5504d99c29). Qtcxx . . $ Qt/::whitecxx . . $ Qt/white.; |
| 44 | textColorcxx . . $ MemoryCellGraphicsItem#textColor. =cxx . . $ QColor#`operator=`(7dc25a5504d99c29). Qtcxx . . $ Qt/::blackcxx . . $ Qt/black.; |
| 45 | boxTextColorcxx . . $ MemoryCellGraphicsItem#boxTextColor. =cxx . . $ QColor#`operator=`(7dc25a5504d99c29). Qtcxx . . $ Qt/::blackcxx . . $ Qt/black.; |
| 46 | } |
| 47 | |
| 48 | QRectFcxx . . $ QRectF# MemoryCellGraphicsItemcxx . . $ MemoryCellGraphicsItem#::boundingRectcxx . . $ MemoryCellGraphicsItem#boundingRect(19f9350443f914b1).() const |
| 49 | { |
| 50 | const int Margin = 4; |
| 51 | return QRectFcxx . . $ QRectF#QRectF(b1aba82a5bc266ba).(QPointFcxx . . $ QPointF#QPointF(bc12c9ec15586e6a).(xcxx . . $ MemoryCellGraphicsItem#x. - addressWidthcxx . . $ MemoryCellGraphicsItem#addressWidth. - Margin, ycxx . . $ MemoryCellGraphicsItem#y. - Margin), |
| 52 | QSizeFcxx . . $ QSizeF#QSizeF(acbf2dbd75fdf3c4).(addressWidthcxx . . $ MemoryCellGraphicsItem#addressWidth. + bufferWidthcxx . . $ MemoryCellGraphicsItem#bufferWidth. * 2 + boxWidthcxx . . $ MemoryCellGraphicsItem#boxWidth. + symbolWidthcxx . . $ MemoryCellGraphicsItem#symbolWidth. + Margin * 2, boxHeightcxx . . $ MemoryCellGraphicsItem#boxHeight. + Margin * 2)); |
| 53 | } |
| 54 | |
| 55 | void MemoryCellGraphicsItemcxx . . $ MemoryCellGraphicsItem#::paintcxx . . $ MemoryCellGraphicsItem#paint(75fb761ce905ae5).(QPaintercxx . . $ QPainter# *painter, const QStyleOptionGraphicsItemcxx . . $ QStyleOptionGraphicsItem# *, QWidgetcxx . . $ QWidget# *) |
| 56 | { |
| 57 | QPencxx . . $ QPen# pencxx . . $ QPen#QPen(129a55e114526ad3).(boxColorcxx . . $ MemoryCellGraphicsItem#boxColor.); |
| 58 | pen.setWidthcxx . . $ QPen#setWidth(d4f767463ce0a6b3).(2); |
| 59 | painter->setPencxx . . $ QPainter#setPen(af0a25dfda3214db).(pen); |
| 60 | painter->setBrushcxx . . $ QPainter#setBrush(ffc9f5d0bda78261).(boxBgColorcxx . . $ QBrush#QBrush(b50947b0752ea6ac).); |
| 61 | painter->setRenderHintcxx . . $ QPainter#setRenderHint(df747a77a7bbbce1).(QPaintercxx . . $ QPainter#::Antialiasingcxx . . $ QPainter#Antialiasing.); |
| 62 | painter->drawRoundedRectcxx . . $ QPainter#drawRoundedRect(4097802b0bac5cc0).(QRectFcxx . . $ QRectF#QRectF(ba0360b8cbb82f7c).(xcxx . . $ MemoryCellGraphicsItem#x., ycxx . . $ MemoryCellGraphicsItem#y., boxWidthcxx . . $ MemoryCellGraphicsItem#boxWidth., boxHeightcxx . . $ MemoryCellGraphicsItem#boxHeight.), 2, 2, Qtcxx . . $ Qt/::RelativeSizecxx . . $ Qt/RelativeSize.); |
| 63 | |
| 64 | painter->setPencxx . . $ QPainter#setPen(129a55e114526ad3).(textColorcxx . . $ MemoryCellGraphicsItem#textColor.); |
| 65 | painter->setRenderHintcxx . . $ QPainter#setRenderHint(df747a77a7bbbce1).(QPaintercxx . . $ QPainter#::TextAntialiasingcxx . . $ QPainter#TextAntialiasing.); |
| 66 | painter->setFontcxx . . $ QPainter#setFont(d0a4bd0c8524b912).(QFontcxx . . $ QFont#QFont(7ae16150a604556).(Pepcxx . . $ Pep#::codeFontcxx . . $ Pep#codeFont., Pepcxx . . $ Pep#::codeFontSizecxx . . $ Pep#codeFontSize.)); |
| 67 | |
| 68 | painter->drawTextcxx . . $ QPainter#drawText(37db8d97befc6512).(QRectFcxx . . $ QRectF#QRectF(ba0360b8cbb82f7c).(xcxx . . $ MemoryCellGraphicsItem#x. - addressWidthcxx . . $ MemoryCellGraphicsItem#addressWidth. - bufferWidthcxx . . $ MemoryCellGraphicsItem#bufferWidth., ycxx . . $ MemoryCellGraphicsItem#y., addressWidthcxx . . $ MemoryCellGraphicsItem#addressWidth., boxHeightcxx . . $ MemoryCellGraphicsItem#boxHeight.), Qtcxx . . $ Qt/::AlignVCentercxx . . $ Qt/AlignVCenter. |cxx . . $ Qt/`operator|`(6ff00bf3a2570bcb). Qtcxx . . $ Qt/::AlignRightcxx . . $ Qt/AlignRight., QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1").argcxx . . $ QString#arg(64ab2ed17cc11715).(addresscxx . . $ MemoryCellGraphicsItem#address., 4, 16, QLatin1Charcxx . . $ QChar#QChar(a50889c09eec06d9).('0')).toUppercxx . . $ QString#toUpper(30b3b70527b1c61a).()); |
| 69 | painter->drawTextcxx . . $ QPainter#drawText(37db8d97befc6512).(QRectFcxx . . $ QRectF#QRectF(ba0360b8cbb82f7c).(xcxx . . $ MemoryCellGraphicsItem#x. + bufferWidthcxx . . $ MemoryCellGraphicsItem#bufferWidth. + boxWidthcxx . . $ MemoryCellGraphicsItem#boxWidth., ycxx . . $ MemoryCellGraphicsItem#y., symbolWidthcxx . . $ MemoryCellGraphicsItem#symbolWidth., boxHeightcxx . . $ MemoryCellGraphicsItem#boxHeight.), Qtcxx . . $ Qt/::AlignVCentercxx . . $ Qt/AlignVCenter. |cxx . . $ Qt/`operator|`(6ff00bf3a2570bcb). Qtcxx . . $ Qt/::AlignLeftcxx . . $ Qt/AlignLeft., QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1").argcxx . . $ QString#arg(bc823072288cbbb5).(symbolcxx . . $ MemoryCellGraphicsItem#symbol.)); |
| 70 | |
| 71 | painter->setPencxx . . $ QPainter#setPen(129a55e114526ad3).(boxTextColorcxx . . $ MemoryCellGraphicsItem#boxTextColor.); |
| 72 | painter->drawTextcxx . . $ QPainter#drawText(37db8d97befc6512).(QRectFcxx . . $ QRectF#QRectF(ba0360b8cbb82f7c).(xcxx . . $ MemoryCellGraphicsItem#x., ycxx . . $ MemoryCellGraphicsItem#y., boxWidthcxx . . $ MemoryCellGraphicsItem#boxWidth., boxHeightcxx . . $ MemoryCellGraphicsItem#boxHeight.), Qtcxx . . $ Qt/::AlignCentercxx . . $ Qt/AlignCenter., valuecxx . . $ MemoryCellGraphicsItem#value.); |
| 73 | } |
| 74 | |
| 75 | void MemoryCellGraphicsItemcxx . . $ MemoryCellGraphicsItem#::updateValuecxx . . $ MemoryCellGraphicsItem#updateValue(49f6e7a06ebc5aa8).() |
| 76 | { |
| 77 | switch (eSymbolFormatcxx . . $ MemoryCellGraphicsItem#eSymbolFormat.) { |
| 78 | case Enucxx . . $ Enu/::F_1Ccxx . . $ Enu/F_1C.: |
| 79 | valuecxx . . $ MemoryCellGraphicsItem#value. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(f2c90172ce699d92).(QCharcxx . . $ QChar#(Simcxx . . $ Sim#::Memcxx . . $ Sim#Mem.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).addresscxx . . $ MemoryCellGraphicsItem#address.])); |
| 80 | break; |
| 81 | case Enucxx . . $ Enu/::F_1Dcxx . . $ Enu/F_1D.: |
| 82 | valuecxx . . $ MemoryCellGraphicsItem#value. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1").argcxx . . $ QString#arg(64ab2ed17cc11715).(Simcxx . . $ Sim#::Memcxx . . $ Sim#Mem.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).addresscxx . . $ MemoryCellGraphicsItem#address.]); |
| 83 | break; |
| 84 | case Enucxx . . $ Enu/::F_2Dcxx . . $ Enu/F_2D.: |
| 85 | valuecxx . . $ MemoryCellGraphicsItem#value. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1").argcxx . . $ QString#arg(64ab2ed17cc11715).(Simcxx . . $ Sim#::toSignedDecimalcxx . . $ Sim#toSignedDecimal(7864480464b09eea).(Simcxx . . $ Sim#::Memcxx . . $ Sim#Mem.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).addresscxx . . $ MemoryCellGraphicsItem#address.] * 256 + Simcxx . . $ Sim#::Memcxx . . $ Sim#Mem.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).addresscxx . . $ MemoryCellGraphicsItem#address. +1])); |
| 86 | break; |
| 87 | case Enucxx . . $ Enu/::F_1Hcxx . . $ Enu/F_1H.: |
| 88 | valuecxx . . $ MemoryCellGraphicsItem#value. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1").argcxx . . $ QString#arg(64ab2ed17cc11715).(Simcxx . . $ Sim#::Memcxx . . $ Sim#Mem.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).addresscxx . . $ MemoryCellGraphicsItem#address.], 2, 16, QLatin1Charcxx . . $ QChar#QChar(a50889c09eec06d9).('0')).toUppercxx . . $ QString#toUpper(30b3b70527b1c61a).(); |
| 89 | break; |
| 90 | case Enucxx . . $ Enu/::F_2Hcxx . . $ Enu/F_2H.: |
| 91 | valuecxx . . $ MemoryCellGraphicsItem#value. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1").argcxx . . $ QString#arg(64ab2ed17cc11715).(Simcxx . . $ Sim#::Memcxx . . $ Sim#Mem.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).addresscxx . . $ MemoryCellGraphicsItem#address.] * 256 + Simcxx . . $ Sim#::Memcxx . . $ Sim#Mem.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).addresscxx . . $ MemoryCellGraphicsItem#address. + 1], 4, 16, QLatin1Charcxx . . $ QChar#QChar(a50889c09eec06d9).('0')).toUppercxx . . $ QString#toUpper(30b3b70527b1c61a).(); |
| 92 | break; |
| 93 | default: |
| 94 | valuecxx . . $ MemoryCellGraphicsItem#value. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; // Should not occur |
| 95 | break; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | int MemoryCellGraphicsItemcxx . . $ MemoryCellGraphicsItem#::getAddresscxx . . $ MemoryCellGraphicsItem#getAddress(b126dc7c1de90089).() |
| 100 | { |
| 101 | return addresscxx . . $ MemoryCellGraphicsItem#address.; |
| 102 | } |
| 103 | |
| 104 | int MemoryCellGraphicsItemcxx . . $ MemoryCellGraphicsItem#::getNumBytescxx . . $ MemoryCellGraphicsItem#getNumBytes(b126dc7c1de90089).() |
| 105 | { |
| 106 | return Simcxx . . $ Sim#::cellSizecxx . . $ Sim#cellSize(10342dda07a560ad).(eSymbolFormatcxx . . $ MemoryCellGraphicsItem#eSymbolFormat.); |
| 107 | } |