summaryrefslogtreecommitdiffstats
path: root/src/devices/mem24/gui/mem24_hex_view.cpp
blob: 7c30e9f9bcd46fe4af2bb252fbb2c9c3a7564cfa (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
/***************************************************************************
 *   Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org>                  *
 *                                                                         *
 *   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.                                   *
 ***************************************************************************/
#include "mem24_hex_view.h"

#include <tqlayout.h>
#include <tqlabel.h>
#include <klocale.h>

#include "mem24_memory_editor.h"

Mem24::HexView::HexView(const HexEditor &editor, TQWidget *tqparent)
  : Device::HexView(editor, tqparent, "mem24_hex_view")
{}

void Mem24::HexView::display()
{
  Memory *pmemory = static_cast<Memory *>(_memory);
  MemoryTypeEditor *e = new MemoryTypeEditor(this, *pmemory, this);
  e->init(true);
  e->show();
  _top->addWidget(e);
  addEditor(e);
}

BitValue Mem24::HexView::checksum() const
{
  if ( _memory==0 ) return 0x0000;
  BitValue cs = 0x0000;
  for (uint i=0; i<static_cast<const Data &>(_memory->device()).nbBytes(); i++)
    cs += static_cast<const Memory *>(_memory)->byte(i);
  return cs.maskWith(0xFFFF);
}