summaryrefslogtreecommitdiffstats
path: root/khexedit/lib/kvaluecolumn.h
blob: e0a515df873f660f93d8c68a14ea872f3a37bb16 (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
/***************************************************************************
                          kvaluecolumn.h  -  description
                             -------------------
    begin                : Mit Sep 3 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 KHE_KVALUECOLUMN_H
#define KHE_KVALUECOLUMN_H

// lib specific
#include "kbytecodec.h"
#include "kbuffercolumn.h"


namespace KHE
{

class TDEBufferRanges;


/** buffer column which displays the numerical values of the bytes
  *
  *@author Friedrich W. H. Kossebau
  */
class KValueColumn : public TDEBufferColumn
{
  public:
    KValueColumn( KColumnsView *CV, KDataBuffer *B, TDEBufferLayout *L, TDEBufferRanges *R );
    virtual ~KValueColumn();

  public:
    void paintEditedByte( TQPainter *P, char Byte, const TQString &EditBuffer );

  public: // modification access
    /**
      * returns true if there was a change
      */
    bool setCoding( KCoding C );
    /** sets the spacing in the middle of a binary byte in the value column
      * @param BinaryGapW spacing in the middle of a binary in pixels
      * returns true if there was a change
      */
    bool setBinaryGapWidth( KPixelX BGW );


  public: // value access
    KPixelX binaryGapWidth()      const;
    KCoding coding()              const;
    const KByteCodec *byteCodec() const;


  protected: // TDEBufferColumn API
    virtual void drawByte( TQPainter *P, char Byte, KHEChar B, const TQColor &Color ) const;
    virtual void recalcByteWidth();

  protected:
    void drawCode( TQPainter *P, const TQString &Code, const TQColor &Color ) const;

  protected: // set data
    /** */
    KCoding Coding;
    /** */
    KByteCodec *ByteCodec;
    /** */
    KPixelX BinaryGapWidth;

  protected: // buffered data
    /** buffer to hold the formatted coding */
    mutable TQString CodedByte;
    /** calculated: Offset in pixels of the second half of the binary */
    KPixelX BinaryHalfOffset;
};


inline KPixelX KValueColumn::binaryGapWidth()        const { return BinaryGapWidth; }
inline KCoding KValueColumn::coding()                const { return Coding; }
inline const KByteCodec *KValueColumn::byteCodec()   const { return ByteCodec; }

}

#endif