/*************************************************************************** * Copyright (C) 2005-2007 Nicolas Hadacek * * Copyright (C) 2003-2004 Alain Gibaud * * * * 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 HEX_WORD_EDITOR_H #define HEX_WORD_EDITOR_H #include "common/gui/hexword_gui.h" #include "devices/base/generic_memory.h" namespace Device { //----------------------------------------------------------------------------- class HexWordEditor : public GenericHexWordEditor { Q_OBJECT TQ_OBJECT public: HexWordEditor(Memory &memory, uint nbChars, TQWidget *tqparent); void setOffset(int offset); int offset() const { return _offset; } protected: Device::Memory &_memory; int _offset; virtual bool isValid() const { return _offset!=-1; } virtual BitValue tqmask() const = 0; virtual BitValue normalizeWord(BitValue value) const = 0; virtual BitValue word() const = 0; virtual void setWord(BitValue value) = 0; virtual BitValue blankValue() const { return BitValue(); } }; //----------------------------------------------------------------------------- class RegisterHexWordEditor : public GenericHexWordEditor { Q_OBJECT TQ_OBJECT public: RegisterHexWordEditor(TQWidget *tqparent, uint nbChars, BitValue tqmask); void clear() { setValue(BitValue()); } void setValue(BitValue word); BitValue value() const { return _word; } void setColor(TQColor color) { setPaletteForegroundColor(color); } void unsetColor() { unsetPalette(); } private: BitValue _tqmask, _word; virtual bool isValid() const { return true; } virtual BitValue tqmask() const { return _tqmask; } virtual BitValue normalizeWord(BitValue value) const { return value.tqmaskWith(_tqmask); } virtual BitValue word() const { return _word; } virtual void setWord(BitValue value) { _word = value; } virtual BitValue blankValue() const { return BitValue(); } }; } // namespace #endif