all repos — mgba @ ec529a86c795b46f08d92f20cffed3920ce7b3c8

mGBA Game Boy Advance Emulator

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
31	void setAlignment(int);
32	int alignment() const { return m_align; }
33
34public slots:
35	void jumpToAddress(const QString& hex);
36	void jumpToAddress(uint32_t);
37
38signals:
39	void selectionChanged(uint32_t start, uint32_t end);
40
41protected:
42	void resizeEvent(QResizeEvent*) override;
43	void paintEvent(QPaintEvent*) override;
44	void wheelEvent(QWheelEvent*) override;
45	void mousePressEvent(QMouseEvent*) override;
46	void mouseMoveEvent(QMouseEvent*) override;
47	void keyPressEvent(QKeyEvent*) override;
48
49private:
50	void boundsCheck();
51
52	bool isInSelection(uint32_t address);
53
54	ARMCore* m_cpu;
55	QFont m_font;
56	int m_cellHeight;
57	int m_letterWidth;
58	uint32_t m_base;
59	uint32_t m_size;
60	int m_top;
61	int m_align;
62	QMargins m_margins;
63	QVector<QStaticText> m_staticNumbers;
64	QVector<QStaticText> m_staticAscii;
65	QStaticText m_regionName;
66	QSizeF m_cellSize;
67	QPair<uint32_t, uint32_t> m_selection;
68	uint32_t m_selectionAnchor;
69	uint32_t m_buffer;
70	int m_bufferedNybbles;
71};
72
73}
74
75#endif