• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

okteta

  • sources
  • kde-4.12
  • kdesdk
  • okteta
  • kasten
  • gui
  • io
  • streamencoder
  • viewtext
abstractbytearraycolumntextrenderer.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Kasten module, made within the KDE community.
3 
4  Copyright 2003,2008 Friedrich W. H. Kossebau <kossebau@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) version 3, or any
10  later version accepted by the membership of KDE e.V. (or its
11  successor approved by the membership of KDE e.V.), which shall
12  act as a proxy defined in Section 6 of version 3 of the license.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #include "abstractbytearraycolumntextrenderer.h"
24 
25 // Qt
26 #include <QtCore/QTextStream>
27 
28 
29 namespace Kasten2
30 {
31 
32 AbstractByteArrayColumnTextRenderer::AbstractByteArrayColumnTextRenderer( const Okteta::AbstractByteArrayModel *byteArrayModel, Okteta::Address offset, const Okteta::CoordRange& coordRange,
33  int noOfBytesPerLine )
34  : mByteArrayModel( byteArrayModel ),
35  mCoordRange( coordRange ),
36  mNoOfBytesPerLine( noOfBytesPerLine ),
37  mOffset( offset ),
38  mNoOfCharsPerLine( 0 ),
39  mLinePositions( new int[mNoOfBytesPerLine] )
40 {
41 }
42 
43 void AbstractByteArrayColumnTextRenderer::setWidths( int byteWidth, int byteSpacingWidth, int noOfGroupedBytes )
44 {
45  // TODO: remove this hack and make it more general
46  if( byteSpacingWidth > 0 )
47  byteSpacingWidth = DefaultTRByteSpacingWidth;
48 
49  int spacingTrigger = noOfGroupedBytes-1;
50  if( spacingTrigger < 0 )
51  spacingTrigger = mNoOfBytesPerLine; // ensures to never trigger the group spacing
52 
53  int N = 0;
54  int p = 0;
55  int gs = 0;
56  int *P = mLinePositions;
57  for( ; P<&mLinePositions[mNoOfBytesPerLine]; ++P, ++p, ++gs )
58  {
59  *P = N;
60  N += byteWidth;
61 
62  // is there a space behind the actual byte (if it is not the last)?
63  if( gs == spacingTrigger )
64  {
65  N += TRGroupSpacingWidth;
66  gs = -1;
67  }
68  else
69  N += byteSpacingWidth;
70  }
71  N -= (gs==0)?TRGroupSpacingWidth:byteSpacingWidth;
72 
73  mNoOfCharsPerLine = N;
74 }
75 
76 
77 void AbstractByteArrayColumnTextRenderer::renderFirstLine( QTextStream *stream, int lineIndex ) const
78 {
79  mRenderLine = lineIndex;
80  renderLine( stream, false );
81 }
82 
83 
84 void AbstractByteArrayColumnTextRenderer::renderNextLine( QTextStream* stream, bool isSubline ) const
85 {
86  renderLine( stream, isSubline );
87 }
88 
89 AbstractByteArrayColumnTextRenderer::~AbstractByteArrayColumnTextRenderer()
90 {
91  delete [] mLinePositions;
92 }
93 
94 }
Okteta::CoordRange
describes a range in the buffercoord
Definition: coordrange.h:51
Okteta::Address
qint32 Address
Definition: address.h:34
Okteta::AbstractByteArrayModel
could it be useful to hide the data access behind an iterator? * class KDataBufferIterator { public: ...
Definition: abstractbytearraymodel.h:79
Kasten2::AbstractByteArrayColumnTextRenderer::renderNextLine
virtual void renderNextLine(QTextStream *stream, bool isSubline) const
Definition: abstractbytearraycolumntextrenderer.cpp:84
Kasten2::AbstractByteArrayColumnTextRenderer::mNoOfBytesPerLine
const int mNoOfBytesPerLine
Definition: abstractbytearraycolumntextrenderer.h:69
Kasten2::AbstractByteArrayColumnTextRenderer::setWidths
void setWidths(int byteWidth, int byteSpacingWidth, int noOfGroupedBytes)
Definition: abstractbytearraycolumntextrenderer.cpp:43
Kasten2::AbstractByteArrayColumnTextRenderer::renderLine
virtual void renderLine(QTextStream *stream, bool isSubline) const =0
abstractbytearraycolumntextrenderer.h
Kasten2::AbstractByteArrayColumnTextRenderer::mLinePositions
int *const mLinePositions
Definition: abstractbytearraycolumntextrenderer.h:79
Kasten2::AbstractByteArrayColumnTextRenderer::mNoOfCharsPerLine
int mNoOfCharsPerLine
buffered value of how many chars a line needs
Definition: abstractbytearraycolumntextrenderer.h:77
N
Kasten2::AbstractByteArrayColumnTextRenderer::AbstractByteArrayColumnTextRenderer
AbstractByteArrayColumnTextRenderer(const Okteta::AbstractByteArrayModel *byteArrayModel, Okteta::Address offset, const Okteta::CoordRange &coordRange, int noOfBytesPerLine)
Definition: abstractbytearraycolumntextrenderer.cpp:32
Kasten2::AbstractByteArrayColumnTextRenderer::mRenderLine
int mRenderLine
Line to print.
Definition: abstractbytearraycolumntextrenderer.h:72
Kasten2::AbstractByteArrayColumnTextRenderer::~AbstractByteArrayColumnTextRenderer
virtual ~AbstractByteArrayColumnTextRenderer()
Definition: abstractbytearraycolumntextrenderer.cpp:89
Kasten2::AbstractByteArrayColumnTextRenderer::renderFirstLine
virtual void renderFirstLine(QTextStream *stream, int lineIndex) const
Definition: abstractbytearraycolumntextrenderer.cpp:77
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okteta

Skip menu "okteta"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal