all repos — mgba @ 6d40031d99b701c9e8febf3552a82a316e12e914

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	bool isEditing(uint32_t address);
54	void drawEditingText(QPainter& painter, const QPointF& origin);
55
56	void adjustCursor(int adjust, bool shift);
57
58	ARMCore* m_cpu;
59	QFont m_font;
60	int m_cellHeight;
61	int m_letterWidth;
62	uint32_t m_base;
63	uint32_t m_size;
64	int m_top;
65	int m_align;
66	QMargins m_margins;
67	QVector<QStaticText> m_staticNumbers;
68	QVector<QStaticText> m_staticAscii;
69	QStaticText m_regionName;
70	QSizeF m_cellSize;
71	QPair<uint32_t, uint32_t> m_selection;
72	uint32_t m_selectionAnchor;
73	uint32_t m_buffer;
74	int m_bufferedNybbles;
75};
76
77}
78
79#endif