summaryrefslogtreecommitdiffstats
path: root/src/devices/gui/register_view.h
blob: f3cb11d7192d6ac7d472791fd924fb5810acc6ff (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/***************************************************************************
 *   Copyright (C) 2006 Nicolas Hadacek <[email protected]>                  *
 *                                                                         *
 *   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 REGISTER_VIEW_H
#define REGISTER_VIEW_H

#include <tqframe.h>

#include "devices/base/register.h"
#include "common/gui/number_gui.h"
#include "common/gui/list_view.h"

namespace Register
{
enum { PortBitRtti = 1000, RegisterRtti = 1001 };

//-----------------------------------------------------------------------------
class PortBitListViewItem : public TDEListViewItem
{
public:
  PortBitListViewItem(uint address, uint bit, TDEListViewItem *parent);
  virtual int rtti() const { return PortBitRtti; }
  void updateView();
  TQString tooltip(int column) const;

private:
  uint _index, _bit;

  virtual void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int align);
};

//-----------------------------------------------------------------------------
class ListViewItem : public EditListViewItem
{
public:
  ListViewItem(const TypeData &data, TDEListViewItem *item);
  virtual int rtti() const { return RegisterRtti; }
  virtual void updateView();
  const TypeData &data() const { return _data; }
  TQString tooltip(int column) const;
  NumberBase base() const { return _base; }
  void setBase(NumberBase base);
  virtual TQString label() const = 0;
  virtual int compare(TQListViewItem *item, int, bool) const;

protected:
  TypeData _data;
  TQValueList<PortBitListViewItem *> _items;
  NumberBase _base;

  virtual void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int align);
  virtual TQWidget *editWidgetFactory(int col) const;
  virtual bool alwaysAcceptEdit(int) const { return false; }
  virtual void editDone(int col, const TQWidget *editWidget);
  virtual uint nbCharsAddress() const = 0;
  virtual TQString text() const;
  virtual void activate() {}
};

//-----------------------------------------------------------------------------
class LineEdit : public NumberLineEdit
{
Q_OBJECT
  
public:
  LineEdit(TQWidget *parent, const char *name = 0);
  void setValue(NumberBase base, BitValue value, uint nbChars);
  BitValue value() const { return _value; }

signals:
  void modified();

protected:
  virtual void keyPressEvent(TQKeyEvent *e);

private slots:
  void updateText();
  void returnPressedSlot();

private:
  NumberBase _base;
  BitValue   _value;
  uint       _nbChars;
};

//-----------------------------------------------------------------------------
class View : public TQFrame, public GenericView
{
Q_OBJECT
  
public:
  View(TQWidget *parent, const char *name);

signals:
  void readSignal(uint address);
  void writeSignal(uint address, uint value);
  void setWatchedSignal(uint address, bool watched);
};

} // namespace

#endif