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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
/***************************************************************************
kbyteseditwidget.h - description
-------------------
begin : Fri Aug 29 2003
copyright : (C) 2003 by Friedrich W. H. Kossebau
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License version 2 as published by the Free Software Foundation. *
* *
***************************************************************************/
#ifndef KBYTESEDITWIDGET_H
#define KBYTESEDITWIDGET_H
// qt specific
#include <tqwidget.h>
// kde specific
#include <khexedit/byteseditinterface.h>
#include <khexedit/valuecolumninterface.h>
#include <khexedit/charcolumninterface.h>
#include <khexedit/zoominterface.h>
#include <khexedit/clipboardinterface.h>
namespace KHE {
class KBytesEdit;
}
/**
hex editor/viewer.
@author Friedrich W. H. Kossebau <[email protected]>
@version 0.1
**/
class KBytesEditWidget : public TQWidget, public KHE::BytesEditInterface,
public KHE::ValueColumnInterface, public KHE::CharColumnInterface,
public KHE::ZoomInterface, public KHE::ClipboardInterface
{
Q_OBJECT
TQ_OBJECT
public:
/** constructor API as demanded by KGenericFactory */
KBytesEditWidget( TQWidget *parent, const char *name, const TQStringList & = TQStringList() );
public: // bytesedit interface
/** hands over to the editor a new byte array.
* If there exists an old one and autodelete is set the old one gets deleted.
* @param D pointer to memory
* @param DS_ size of used memory
* @param RS_ real size of the memory
* @param KM keep the memory on resize (RS_ is the maximum size)
*/
virtual void setData( char *D, int DS_, int RS_ = -1, bool KM = true );
/** sets the maximal size of the actual byte array. If the actual array is already larger
* it will not be modified but there can be only done non-inserting actions
* until the array's is below the limit
*/
virtual void setMaxDataSize( int MS );
/** sets whether the array should be deleted on the widget's end or if a new array is set.
* Default is false
*/
virtual void setAutoDelete( bool AD = true );
/** sets whether the memory given by setData or in the constructor should be kept on resize
*/
virtual void setKeepsMemory( bool KM = true );
/** */
virtual char *data() const;
/** returns the size of the actual byte array */
virtual int dataSize() const;
/** returns the maximal allowed size for the byte array */
virtual int maxDataSize () const;
/** returns whether autodelete is set for the byte array */
virtual bool isAutoDelete() const;
/** returns whether the memory of the byte array is kept */
virtual bool keepsMemory() const;
/** */
virtual bool isOverwriteMode() const;
virtual bool isOverwriteOnly() const;
virtual bool isReadOnly() const;
virtual bool isModified() const;
/** repaint the indizes from i1 to i2 */
virtual void repaintRange( int i1, int i2 );
public: // cursor interface
/** */
virtual void setCursorPosition( int Index );
// virtual bool tabChangesFocus() const;
public: // tqlayout interface ??
/** sets the resizestyle for the value column. Default is KHE::FullSizeUsage */
virtual void setResizeStyle( KResizeStyle Style );
/** sets the number of bytes per line, switching the resize style to KHE::NoResize */
virtual void setNoOfBytesPerLine( int NoCpL );
virtual int noOfBytesPerLine() const;
virtual KResizeStyle resizeStyle() const;
public: // value column
/** sets the format of the value column. Default is KHE::HexadecimalCoding */
virtual void setCoding( KCoding C );
/** sets the spacing between the bytes in pixels */
virtual void setByteSpacingWidth( int BSW );
/** sets the numbers of grouped bytes, 0 means no grouping, Default is 4 */
virtual void setNoOfGroupedBytes( int NoGB );
/** sets the spacing between the groups in pixels */
virtual void setGroupSpacingWidth( int GSW );
/** sets the spacing in the middle of a binary byte in the value column
* @param BGW spacing in the middle of a binary in pixels
*/
virtual void setBinaryGapWidth( int BGW );
virtual KCoding coding() const;
virtual int byteSpacingWidth() const;
virtual int noOfGroupedBytes() const;
virtual int groupSpacingWidth() const;
virtual int binaryGapWidth() const;
public: // char column
/** sets whether "unprintable" chars (>32) should be displayed in the char column
* with their corresponding character.
* @param SU
* returns true if there was a change
*/
virtual void setShowUnprintable( bool SU = true );
/** sets the substitute character for "unprintable" chars
* returns true if there was a change
*/
virtual void setSubstituteChar( TQChar SC );
/** sets the encoding of the char column. Default is KHE::LocalEncoding.
* If the encoding is not available the format will not be changed. */
virtual void setEncoding( KEncoding C );
/** returns true if "unprintable" chars (>32) are displayed in the char column
* with their corresponding character, default is false
*/
virtual bool showUnprintable() const;
/** returns the actually used substitute character for "unprintable" chars, default is '.' */
virtual TQChar substituteChar() const;
/** */
virtual KEncoding encoding() const;
public: // edit interface
/** */
virtual void insert( const TQByteArray &D );
/** de-/selects all data */
virtual void selectAll( bool select );
/** returns true if there is a selected range in the array */
virtual bool hasSelectedData() const;
public slots:
// bytesedit interface
virtual void setReadOnly( bool RO = true );
virtual void setOverwriteOnly( bool b );
virtual void setOverwriteMode( bool b );
virtual void setModified( bool b );
// clipboard interface
virtual void copy();
virtual void cut();
virtual void paste();
// zooming interface
virtual void zoomIn( int PointInc );
virtual void zoomIn();
virtual void zoomOut( int PointDec );
virtual void zoomOut();
virtual void zoomTo( int PointSize );
virtual void unZoom();
signals:
// clipboard interface
virtual void copyAvailable( bool Really );
protected:
KHE::KBytesEdit* BytesEdit;
};
#endif
|