From f508189682b6fba62e08feeb1596f682bad5fff9 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 24 Feb 2010 18:42:24 +0000 Subject: Added KDE3 version of PikLab git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/devices/mem24/gui/mem24_memory_editor.h | 77 +++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/devices/mem24/gui/mem24_memory_editor.h (limited to 'src/devices/mem24/gui/mem24_memory_editor.h') diff --git a/src/devices/mem24/gui/mem24_memory_editor.h b/src/devices/mem24/gui/mem24_memory_editor.h new file mode 100644 index 0000000..eb99e97 --- /dev/null +++ b/src/devices/mem24/gui/mem24_memory_editor.h @@ -0,0 +1,77 @@ +/*************************************************************************** + * Copyright (C) 2006 Nicolas Hadacek * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#ifndef MEM24_MEMORY_EDITOR_H +#define MEM24_MEMORY_EDITOR_H + +#include "devices/gui/memory_editor.h" +#include "devices/gui/hex_word_editor.h" +#include "devices/mem24/mem24/mem24_memory.h" + +namespace Mem24 +{ +class HexView; + +//----------------------------------------------------------------------------- +class MemoryCaster +{ +public: + MemoryCaster(Memory &memory) : _memory(memory) {} + const Data &device() const { return static_cast(_memory.device()); } + const Memory &memory() const { return static_cast(_memory); } + Memory &memory() { return static_cast(_memory); } + +private: + Memory &_memory; +}; + +//----------------------------------------------------------------------------- +class HexWordEditor : public Device::HexWordEditor, public MemoryCaster +{ +Q_OBJECT +public: + HexWordEditor(Memory &memory, QWidget *parent) + : Device::HexWordEditor(memory, 2, parent), MemoryCaster(memory) {} + +private: + virtual BitValue mask() const { return 0xFF; } + virtual BitValue normalizeWord(BitValue value) const { return value; } + virtual BitValue word() const { return memory().byte(_offset); } + virtual void setWord(BitValue value) { memory().setByte(_offset, value); } +}; + +//----------------------------------------------------------------------------- +class MemoryRangeEditor : public Device::MemoryRangeEditor, public MemoryCaster +{ +Q_OBJECT +public: + MemoryRangeEditor(Memory &memory, QWidget *parent); + +private: + virtual uint nbWords() const { return device().nbBytes(); } + virtual uint addressIncrement() const { return 1; } + virtual Address startAddress() const { return 0x0; } + virtual Device::HexWordEditor *createHexWordEditor(QWidget *parent); + virtual bool isRangeReadOnly() const { return false; } +}; + +//----------------------------------------------------------------------------- +class MemoryTypeEditor : public Device::MemoryTypeEditor, public MemoryCaster +{ +Q_OBJECT +public: + MemoryTypeEditor(const HexView *hexview, Memory &memory, QWidget *parent); + virtual void init(bool first); + +private: + virtual bool internalDoAction(Device::Action action); +}; + +} // namespace + +#endif -- cgit v1.2.1