src/platform/qt/MemoryModel.h (view raw)
1/* Copyright (c) 2013-2015 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef QGBA_MEMORY_MODEL
7#define QGBA_MEMORY_MODEL
8
9#include <QAbstractScrollArea>
10#include <QFont>
11#include <QSize>
12#include <QStaticText>
13#include <QVector>
14
15struct ARMCore;
16
17namespace QGBA {
18
19class GameController;
20
21class MemoryModel : public QAbstractScrollArea {
22Q_OBJECT
23
24public:
25 MemoryModel(QWidget* parent = nullptr);
26
27 void setController(GameController* controller);
28
29 void setRegion(uint32_t base, uint32_t size, const QString& name = QString());
30 void setAlignment(int);
31
32public slots:
33 void jumpToAddress(const QString& hex);
34 void jumpToAddress(uint32_t);
35
36protected:
37 void resizeEvent(QResizeEvent*) override;
38 void paintEvent(QPaintEvent*) override;
39 void wheelEvent(QWheelEvent*) override;
40 void mousePressEvent(QMouseEvent*) override;
41 void mouseMoveEvent(QMouseEvent*) override;
42
43private:
44 void boundsCheck();
45
46 bool isInSelection(uint32_t address);
47
48 ARMCore* m_cpu;
49 QFont m_font;
50 int m_cellHeight;
51 int m_letterWidth;
52 uint32_t m_base;
53 uint32_t m_size;
54 int m_top;
55 int m_align;
56 QMargins m_margins;
57 QVector<QStaticText> m_staticNumbers;
58 QVector<QStaticText> m_staticAscii;
59 QStaticText m_regionName;
60 QSizeF m_cellSize;
61 QPair<uint32_t, uint32_t> m_selection;
62 uint32_t m_selectionAnchor;
63};
64
65}
66
67#endif