summaryrefslogtreecommitdiffstats
path: root/src/devices/gui/hex_word_editor.h
blob: db9374c388a539cab99b2aa04a2d1d11106bfe53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/***************************************************************************
 *   Copyright (C) 2005-2007 Nicolas Hadacek <hadacek@kde.org>             *
 *   Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr>           *
 *                                                                         *
 *   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