blob: a9732914529698b5717354e4240aedaed23c5083 (
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
|
/***************************************************************************
* Copyright (C) 2006-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 HEXWORD_GUI_H
#define HEXWORD_GUI_H
#include <tqvalidator.h>
#include <klineedit.h>
#include "common/common/bitvalue.h"
//-----------------------------------------------------------------------------
class HexValueValidator : public TQValidator
{
Q_OBJECT
TQ_OBJECT
public:
HexValueValidator(uint nbChars, TQObject *parent);
virtual State validate(TQString &input, int &pos) const;
private:
uint _nbChars;
};
//-----------------------------------------------------------------------------
class GenericHexWordEditor : public KLineEdit
{
Q_OBJECT
TQ_OBJECT
public:
GenericHexWordEditor(uint nbChars, bool hasBlankValue, TQWidget *parent);
virtual TQSize tqsizeHint() const;
virtual TQSize tqminimumSizeHint() const;
signals:
void modified();
void moveNext();
void movePrev();
void moveUp();
void moveDown();
void moveFirst();
void moveLast();
void moveNextPage();
void movePrevPage();
private slots:
bool changeValue();
void slotTextChanged();
protected:
uint _nbChars;
bool _hasBlankValue;
virtual bool isValid() const = 0;
virtual BitValue mask() const = 0;
virtual BitValue normalizeWord(BitValue value) const = 0;
virtual bool event(TQEvent *e);
virtual void set();
virtual BitValue word() const = 0;
virtual void setWord(BitValue value) = 0;
virtual BitValue blankValue() const = 0;
};
//-----------------------------------------------------------------------------
class HexWordEditor : public GenericHexWordEditor
{
Q_OBJECT
TQ_OBJECT
public:
HexWordEditor(uint nbChars, TQWidget *parent) : GenericHexWordEditor(nbChars, false, parent) {}
void setValue(BitValue word) { _word = word; set(); }
BitValue value() const { return _word; }
protected:
BitValue _word;
virtual bool isValid() const { return true; }
virtual BitValue mask() const { return maxValue(NumberBase::Hex, _nbChars); }
virtual BitValue normalizeWord(BitValue value) const { return value.maskWith(mask()); }
virtual BitValue word() const { return _word; }
virtual void setWord(BitValue value) { _word = value; }
virtual BitValue blankValue() const { return 0; }
};
#endif
|