all repos — mgba @ 1326626777dacd7a7882e39c0f6dccc752549a1e

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 mCore;
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
38	void copy();
39	void save();
40
41signals:
42	void selectionChanged(uint32_t start, uint32_t end);
43
44protected:
45	void resizeEvent(QResizeEvent*) override;
46	void paintEvent(QPaintEvent*) override;
47	void wheelEvent(QWheelEvent*) override;
48	void mousePressEvent(QMouseEvent*) override;
49	void mouseMoveEvent(QMouseEvent*) override;
50	void keyPressEvent(QKeyEvent*) override;
51
52private:
53	void boundsCheck();
54
55	bool isInSelection(uint32_t address);
56	bool isEditing(uint32_t address);
57	void drawEditingText(QPainter& painter, const QPointF& origin);
58
59	void adjustCursor(int adjust, bool shift);
60
61	void serialize(QDataStream* stream);
62
63	mCore* m_core;
64	QFont m_font;
65	int m_cellHeight;
66	int m_letterWidth;
67	uint32_t m_base;
68	uint32_t m_size;
69	int m_top;
70	int m_align;
71	QMargins m_margins;
72	QVector<QStaticText> m_staticNumbers;
73	QVector<QStaticText> m_staticAscii;
74	QStaticText m_regionName;
75	QSizeF m_cellSize;
76	QPair<uint32_t, uint32_t> m_selection;
77	uint32_t m_selectionAnchor;
78	uint32_t m_buffer;
79	int m_bufferedNybbles;
80};
81
82}
83
84#endif