• 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
  • gui
bytearrayrowcolumnrenderer.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Gui library, made within the KDE community.
3 
4  Copyright 2008-2009 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 "bytearrayrowcolumnrenderer.h"
24 
25 // lib
26 #include "oktetagui.h"
27 #include "bytearraytableranges.h"
28 #include "bytearraytablecursor.h"
29 #include "bytearraytablelayout.h"
30 #include "helper.h"
31 // lib
32 #include <abstractcolumnstylist.h>
33 // Okteta core
34 #include <bookmarkable.h>
35 #include <bookmarksconstiterator.h>
36 #include <bookmark.h>
37 #include <charcodec.h>
38 #include <valuecodec.h>
39 // KDE
40 #include <KColorScheme>
41 // Qt
42 #include <QtGui/QPainter>
43 #include <QtGui/QFontMetrics>
44 
45 
46 namespace Okteta
47 {
48 
49 static const AbstractByteArrayView::CodingTypes DefaultVisibleCodings =
50  (AbstractByteArrayView::CodingTypes)( AbstractByteArrayView::ValueCodingId | AbstractByteArrayView::CharCodingId );
51 
52 ByteArrayRowColumnRenderer::ByteArrayRowColumnRenderer( AbstractColumnStylist* stylist,
53  AbstractByteArrayModel* byteArrayModel, ByteArrayTableLayout* layout, ByteArrayTableRanges* ranges )
54  : AbstractColumnRenderer( stylist ),
55  mByteArrayModel( byteArrayModel ),
56  mLayout( layout ),
57  mRanges( ranges ),
58  mBookmarks( qobject_cast<Bookmarkable*>(byteArrayModel) ),
59  mVisibleCodings( DefaultVisibleCodings ),
60  mDigitWidth( 0 ),
61  mDigitBaseLine( 0 ),
62  mDigitHeight( 0 ),
63  mFontMetrics( QFont() ),
64  mByteWidth( 0 ),
65  mByteSpacingWidth( DefaultByteSpacingWidth ),
66  mGroupSpacingWidth( DefaultGroupSpacingWidth ),
67  mNoOfGroupedBytes( DefaultNoOfGroupedBytes ),
68  mLinePosLeftPixelX( 0 ),
69  mLinePosRightPixelX( 0 ),
70  mLastLinePos( 0 ),
71  mByteTypeColored( true ),
72  mValueCodec( 0 ),
73  mBinaryGapWidth( DefaultBinaryGapWidth ),
74  mShowingNonprinting( DefaultShowingNonprinting ),
75  mSubstituteChar( DefaultSubstituteChar ),
76  mUndefinedChar( DefaultUndefinedChar )
77 {
78 }
79 
80 AbstractByteArrayView::CodingTypeId ByteArrayRowColumnRenderer::codingIdofY( PixelY y ) const
81 {
82  return
83  ( mVisibleCodings != AbstractByteArrayView::ValueAndCharCodings ) ?
84  (AbstractByteArrayView::CodingTypeId)mVisibleCodings :
85  ( y < mDigitHeight ) ?
86  AbstractByteArrayView::ValueCodingId :
87  AbstractByteArrayView::CharCodingId;
88 }
89 
90 PixelY ByteArrayRowColumnRenderer::rowHeight() const
91 {
92  const int noOfCodings = ( mVisibleCodings > 2 ) ? 2 : 1;
93  return noOfCodings * mDigitHeight + DefaultRowSpacingHeight;
94 }
95 
96 PixelY ByteArrayRowColumnRenderer::yOfCodingId( AbstractByteArrayView::CodingTypeId codingId ) const
97 {
98  PixelY result = ( mVisibleCodings <= 2 ) ? 0 :
99  ( codingId == AbstractByteArrayView::ValueCodingId ) ? 0 :
100  mDigitHeight;
101 
102  return result;
103 }
104 
105 
106 void ByteArrayRowColumnRenderer::set( AbstractByteArrayModel* byteArrayModel )
107 {
108  mByteArrayModel = byteArrayModel;
109  mBookmarks = qobject_cast<Bookmarkable*>(byteArrayModel );
110 }
111 
112 
113 void ByteArrayRowColumnRenderer::resetXBuffer()
114 {
115  delete [] mLinePosLeftPixelX;
116  delete [] mLinePosRightPixelX;
117 
118  mLastLinePos = mLayout->noOfBytesPerLine()-1;
119  mLinePosLeftPixelX = new PixelX[mLastLinePos+1];
120  mLinePosRightPixelX = new PixelX[mLastLinePos+1];
121 
122  if( mLinePosLeftPixelX )
123  recalcX();
124 }
125 
126 void ByteArrayRowColumnRenderer::setVisibleCodings( int visibleCodings )
127 {
128  mVisibleCodings = (AbstractByteArrayView::CodingTypes)( visibleCodings );
129 }
130 
131 
132 void ByteArrayRowColumnRenderer::setFontMetrics( const QFontMetrics& fontMetrics )
133 {
134  mFontMetrics = fontMetrics;
135 
136  mDigitBaseLine = fontMetrics.ascent();
137  mDigitHeight = fontMetrics.height();
138  mDigitWidth = fontMetrics.maxWidth();
139 
140  // recalculate depend sizes
141  recalcByteWidth();
142 
143  if( mLinePosLeftPixelX )
144  recalcX();
145 }
146 
147 
148 bool ByteArrayRowColumnRenderer::setSpacing( PixelX byteSpacingWidth, Size NoGB, PixelX groupSpacingWidth )
149 {
150  // no changes?
151  if( mByteSpacingWidth == byteSpacingWidth && mNoOfGroupedBytes == NoGB && mGroupSpacingWidth == groupSpacingWidth )
152  return false;
153 
154  mByteSpacingWidth = byteSpacingWidth;
155  mNoOfGroupedBytes = NoGB;
156  mGroupSpacingWidth = groupSpacingWidth;
157 
158  // recalculate depend sizes
159  if( mLinePosLeftPixelX )
160  recalcX();
161 
162  return true;
163 }
164 
165 
166 bool ByteArrayRowColumnRenderer::setByteSpacingWidth( PixelX byteSpacingWidth )
167 {
168  // no changes?
169  if( mByteSpacingWidth == byteSpacingWidth )
170  return false;
171 
172  mByteSpacingWidth = byteSpacingWidth;
173 
174  // recalculate depend sizes
175  if( mLinePosLeftPixelX )
176  recalcX();
177 
178  return true;
179 }
180 
181 
182 bool ByteArrayRowColumnRenderer::setNoOfGroupedBytes( Size NoGB )
183 {
184  // no changes?
185  if( mNoOfGroupedBytes == NoGB )
186  return false;
187 
188  mNoOfGroupedBytes = NoGB;
189 
190  if( mLinePosLeftPixelX )
191  recalcX();
192  return true;
193 }
194 
195 
196 bool ByteArrayRowColumnRenderer::setGroupSpacingWidth( PixelX groupSpacingWidth )
197 {
198  // no changes?
199  if( mGroupSpacingWidth == groupSpacingWidth )
200  return false;
201 
202  mGroupSpacingWidth = groupSpacingWidth;
203 
204  // recalculate depend sizes
205  if( mLinePosLeftPixelX )
206  recalcX();
207 
208  return true;
209 }
210 
211 
212 void ByteArrayRowColumnRenderer::setValueCodec( ValueCoding valueCoding, const ValueCodec* valueCodec )
213 {
214  mValueCoding = valueCoding;
215  mValueCodec = valueCodec;
216  mDecodedByteText.resize( mValueCodec->encodingWidth() );
217 
218  // recalculate depend sizes
219  recalcByteWidth();
220 
221  if( mLinePosLeftPixelX )
222  recalcX();
223 }
224 
225 
226 bool ByteArrayRowColumnRenderer::setBinaryGapWidth( PixelX binaryGapWidth )
227 {
228  // no changes?
229  if( mBinaryGapWidth == binaryGapWidth )
230  return false;
231 
232  mBinaryGapWidth = binaryGapWidth;
233 
234  // recalculate depend sizes
235  recalcByteWidth();
236 
237  if( mLinePosLeftPixelX )
238  recalcX();
239  return true;
240 }
241 
242 
243 void ByteArrayRowColumnRenderer::recalcByteWidth()
244 {
245  // use 0 as reference, using a fixed font should always yield same width
246  mValueCodec->encode( mDecodedByteText, 0, Byte(0) );
247  if( mValueCoding == BinaryCoding )
248  {
249  const int binaryHalfWidth = mFontMetrics.width( mDecodedByteText.left(4) );
250  mBinaryHalfOffset = binaryHalfWidth + mBinaryGapWidth;
251  mByteWidth = mBinaryHalfOffset + binaryHalfWidth;
252  }
253  else
254  mByteWidth = mFontMetrics.width( mDecodedByteText );
255 }
256 
257 // perhaps sometimes there will be a grammar
258 void ByteArrayRowColumnRenderer::renderEditedByte( QPainter* painter, Byte byte, const QString& editBuffer )
259 {
260  const Character byteChar = mCharCodec->decode( byte );
261 
262  const QPalette& palette = stylist()->palette();
263  KColorScheme colorScheme( palette.currentColorGroup(), KColorScheme::View );
264  const KColorScheme::ForegroundRole foregroundRole =
265  mByteTypeColored ? foregroundRoleForChar(byteChar): KColorScheme::NormalText;
266  const QBrush brush = colorScheme.foreground( foregroundRole );
267  painter->fillRect( 0,0, byteWidth(),mDigitHeight, brush );
268 
269  const QBrush backgroundBrush = colorScheme.background();
270  const QColor& charColor = backgroundBrush.color();
271  renderCode( painter, editBuffer, charColor );
272 }
273 
274 
275 void ByteArrayRowColumnRenderer::renderByteText( QPainter* painter,
276  Byte byte, Character byteChar, int codings,
277  const QColor& color ) const
278 {
279  PixelY charBaseLine = mDigitBaseLine;
280  if( codings & AbstractByteArrayView::ValueCodingId )
281  {
282  mValueCodec->encode( mDecodedByteText, 0, byte );
283  renderCode( painter, mDecodedByteText, color );
284 
285  charBaseLine += mDigitHeight;
286  }
287 
288  if( codings & AbstractByteArrayView::CharCodingId )
289  {
290  // turn into a drawable String
291  const QString text( byteChar.isUndefined() ? Character(mUndefinedChar) :
292  !(mShowingNonprinting || byteChar.isPrint()) ? Character(mSubstituteChar) :
293  byteChar );
294 
295  painter->setPen( color );
296  painter->drawText( 0, charBaseLine, text );
297  }
298 }
299 
300 
301 void ByteArrayRowColumnRenderer::renderCode( QPainter* painter, const QString& code, const QColor& color ) const
302 {
303  painter->setPen( color );
304  if( mValueCoding == BinaryCoding )
305  {
306  // leave a gap in the middle
307  painter->drawText( 0, mDigitBaseLine, code.left(4) );
308  painter->drawText( mBinaryHalfOffset, mDigitBaseLine, code.right(4) );
309  }
310  else
311  painter->drawText( 0, mDigitBaseLine, code );
312 }
313 
314 
315 void ByteArrayRowColumnRenderer::recalcX()
316 {
317  mSpacingTrigger = noOfGroupedBytes() > 0 ? noOfGroupedBytes()-1 : mLastLinePos+1; // last ensures to never trigger the spacing
318 
319  PixelX newWidth = 0;
320  Size groupedBytes = 0;
321  PixelX* PX = mLinePosLeftPixelX;
322  PixelX* PRX = mLinePosRightPixelX;
323  LinePosition p = 0;
324  for( ; p<=mLastLinePos; ++PX, ++PRX, ++p, ++groupedBytes )
325  {
326  *PX = newWidth;
327  newWidth += mByteWidth;
328  *PRX = newWidth-1;
329 
330  // is there a space behind the actual byte (if it is not the last)?
331  if( groupedBytes == mSpacingTrigger )
332  {
333  newWidth += mGroupSpacingWidth;
334  groupedBytes = -1;
335  }
336  else
337  newWidth += mByteSpacingWidth;
338  }
339  setWidth( mLinePosRightPixelX[mLastLinePos]+1 );
340 }
341 
342 
343 // TODO: why are inlined functions not available as symbols when defined before their use
344 //TODO: works not precisly for the byte rects but includes spacing and left and right
345 /*inline*/ LinePosition ByteArrayRowColumnRenderer::linePositionOfX( PixelX PX ) const
346 {
347  if( !mLinePosLeftPixelX )
348  return NoByteFound;
349 
350  // translate
351  PX -= x();
352  // search backwards for the first byte that is equalleft to x
353  for( LinePosition p=mLastLinePos; p>=0; --p )
354  if( mLinePosLeftPixelX[p] <= PX )
355  return p;
356 
357  return 0; //NoByteFound;
358 }
359 
360 
361 LinePosition ByteArrayRowColumnRenderer::magneticLinePositionOfX( PixelX PX ) const
362 {
363  if( !mLinePosLeftPixelX )
364  return NoByteFound;
365 
366  // translate
367  PX -= x();
368  // search backwards for the first byte that is equalleft to x
369  for( LinePosition p = mLastLinePos; p>=0; --p )
370  if( mLinePosLeftPixelX[p] <= PX )
371  {
372  // are we close to the right?
373  if( mLinePosRightPixelX[p]-PX < mDigitWidth/2 ) // TODO: perhaps cache also the middle xpos's
374  ++p;
375  return p;
376  }
377 
378  return 0; //NoByteFound;
379 }
380 
381 
382 LinePositionRange ByteArrayRowColumnRenderer::linePositionsOfX( PixelX PX, PixelX PW ) const
383 {
384  if( !mLinePosLeftPixelX )
385  return LinePositionRange();
386 
387  // translate
388  PX -= x();
389  const PixelX PRX = PX + PW - 1;
390 
391  LinePositionRange positions;
392  // search backwards for the first byte that is equalleft to x
393  for( LinePosition p=mLastLinePos; p>=0; --p )
394  if( mLinePosLeftPixelX[p] <= PRX )
395  {
396  positions.setEnd( p );
397  for( ; p>=0; --p )
398  if( mLinePosLeftPixelX[p] <= PX )
399  {
400  positions.setStart( p );
401  break;
402  }
403  break;
404  }
405 
406  return positions;
407 }
408 
409 
410 PixelX ByteArrayRowColumnRenderer::xOfLinePosition( LinePosition linePosition ) const
411 {
412  return x() + ( mLinePosLeftPixelX ? mLinePosLeftPixelX[linePosition] : 0 );
413 }
414 
415 PixelX ByteArrayRowColumnRenderer::rightXOfLinePosition( LinePosition linePosition ) const
416 {
417  return x() + ( mLinePosRightPixelX ? mLinePosRightPixelX[linePosition] : 0 );
418 }
419 
420 
421 LinePosition ByteArrayRowColumnRenderer::linePositionOfColumnX( PixelX PX ) const
422 {
423  if( !mLinePosLeftPixelX )
424  return NoByteFound;
425 
426  // search backwards for the first byte that is equalleft to x
427  for( LinePosition p=mLastLinePos; p>=0; --p )
428  if( mLinePosLeftPixelX[p] <= PX )
429  return p;
430 
431  return 0; //NoByteFound;
432 }
433 
434 
435 LinePositionRange ByteArrayRowColumnRenderer::linePositionsOfColumnXs( PixelX pixelX, PixelX pixelWidth ) const
436 {
437  if( ! mLinePosLeftPixelX )
438  return LinePositionRange();
439 
440  const PixelX rightPixelX = pixelX + pixelWidth - 1;
441 
442  LinePositionRange positions;
443  // search backwards for the first byte that is equalleft to x
444  for( LinePosition p=mLastLinePos; p>=0; --p )
445  if( mLinePosLeftPixelX[p] <= rightPixelX )
446  {
447  const LinePosition endPos = p;
448  positions.setEnd( p );
449  for( p=0; p<=endPos; ++p )
450  if( mLinePosRightPixelX[p] >= pixelX )
451  {
452  positions.setStart( p );
453  break;
454  }
455  break;
456  }
457 
458  return positions;
459 }
460 
461 
462 PixelX ByteArrayRowColumnRenderer::columnXOfLinePosition( LinePosition linePosition ) const
463 {
464  return mLinePosLeftPixelX ? mLinePosLeftPixelX[linePosition] : 0;
465 }
466 
467 PixelX ByteArrayRowColumnRenderer::columnRightXOfLinePosition( LinePosition linePosition ) const
468 {
469  return mLinePosRightPixelX ? mLinePosRightPixelX[linePosition] : 0;
470 }
471 
472 
473 PixelXRange ByteArrayRowColumnRenderer::xsOfLinePositionsInclSpaces( const LinePositionRange& linePositions ) const
474 {
475  const PixelX x = (linePositions.start()>0) ? rightXOfLinePosition( linePositions.nextBeforeStart() ) + 1 :
476  xOfLinePosition( linePositions.start() );
477  const PixelX rightX = (linePositions.end()<mLastLinePos) ? xOfLinePosition( linePositions.nextBehindEnd() ) - 1 :
478  rightXOfLinePosition( linePositions.end() );
479  return PixelXRange( x, rightX );
480 }
481 
482 
483 PixelXRange ByteArrayRowColumnRenderer::columnXsOfLinePositionsInclSpaces( const LinePositionRange& linePositions ) const
484 {
485  const PixelX x = (linePositions.start()>0) ? columnRightXOfLinePosition( linePositions.nextBeforeStart() ) + 1 :
486  columnXOfLinePosition( linePositions.start() );
487  const PixelX rightX = (linePositions.end()<mLastLinePos) ? columnXOfLinePosition( linePositions.nextBehindEnd() ) - 1 :
488  columnRightXOfLinePosition( linePositions.end() );
489  return PixelXRange( x, rightX );
490 }
491 
492 
493 QRect ByteArrayRowColumnRenderer::byteRect( const Coord& coord ) const
494 {
495  const int x = xOfLinePosition( coord.pos() );
496  const int y = lineHeight() * coord.line();
497  const int w = mByteWidth;
498  const int h = lineHeight();
499  const QPoint point( x, y );
500  const QSize size( w, h );
501 
502  const QRect result( point, size );
503  return result;
504 }
505 
506 
507 QRect ByteArrayRowColumnRenderer::byteRect( const Coord& coord, AbstractByteArrayView::CodingTypeId codingId ) const
508 {
509  const int x = xOfLinePosition( coord.pos() );
510  const int y = lineHeight() * coord.line() + yOfCodingId( codingId );
511  const int w = mByteWidth;
512  const int h = mDigitHeight;
513  const QPoint point( x, y );
514  const QSize size( w, h );
515 
516  const QRect result( point, size );
517  return result;
518 }
519 
520 
521 void ByteArrayRowColumnRenderer::prepareRendering( const PixelXRange& _Xs )
522 {
523  PixelXRange Xs( _Xs );
524  restrictToXSpan( &Xs );
525  // translate
526  Xs.moveBy( -x() );
527 
528  // store the values
529  mRenderX = Xs.start();
530  mRenderWidth = Xs.width();
531 
532  // get line linePositions to paint
533  mRenderLinePositions = linePositionsOfColumnXs( mRenderX, mRenderWidth );
534 }
535 
536 
537 void ByteArrayRowColumnRenderer::renderFirstLine( QPainter* painter, const PixelXRange& Xs, Line firstLineIndex )
538 {
539  prepareRendering( Xs );
540 
541  mRenderLine = firstLineIndex;
542 
543  renderLinePositions( painter, mRenderLine++, mRenderLinePositions );
544 }
545 
546 
547 void ByteArrayRowColumnRenderer::renderNextLine( QPainter* painter )
548 {
549  renderLinePositions( painter, mRenderLine++, mRenderLinePositions );
550 }
551 
552 
553 void ByteArrayRowColumnRenderer::renderLinePositions( QPainter* painter, Line lineIndex, const LinePositionRange& _linePositions )
554 {
555  // clear background
556  const unsigned int blankFlag =
557  (_linePositions.start()!=0?StartsBefore:0) | (_linePositions.end()!=mLastLinePos?EndsLater:0);
558  const QBrush& backgroundBrush = stylist()->palette().brush( QPalette::Base );
559 
560  renderRange( painter, backgroundBrush, _linePositions, blankFlag );
561 
562  // no bytes to paint?
563  if( !mLayout->hasContent(lineIndex) )
564  return;
565 
566  // Go through the lines TODO: handle first and last line more effeciently
567  // check for leading and trailing spaces
568  const LinePositionRange existingLinePositions = mLayout->linePositions( lineIndex );
569 
570  LinePositionRange linePositions = _linePositions;
571  linePositions.restrictTo( existingLinePositions );
572  const int firstLinePosition = linePositions.start();
573 
574  // check for leading and trailing spaces
575  AddressRange byteIndizes =
576  AddressRange::fromWidth( mLayout->indexAtCoord(Coord( linePositions.start(), lineIndex )), linePositions.width() );
577 
578  unsigned int selectionFlag = 0;
579  unsigned int markingFlag = 0;
580  AddressRange selectedRange;
581  AddressRange markedRange;
582  bool hasMarking = mRanges->hasMarking();
583  bool hasSelection = mRanges->hasSelection();
584 
585 //kDebug() << QString("painting linePositions (painter%1-%2L%3): ").arg(linePositions.start()).arg(linePositions.end()).arg(lineIndex)
586 // <<linePositions.start()<<"-"<<linePositions.start()
587 // <<" for byteIndizes "<<byteIndizes.start()<<"-"<<byteIndizes.start()<<endl;
588  while( linePositions.isValid() )
589  {
590  LinePositionRange positionsPart = linePositions; // set of linePositions to paint next
591  AddressRange byteIndizesPart = byteIndizes; // set of indizes to paint next
592 
593  if( hasMarking && markedRange.endsBefore(byteIndizesPart) )
594  hasMarking = getNextMarkedAddressRange( &markedRange, &markingFlag, byteIndizesPart );
595 
596  if( hasSelection && selectedRange.endsBefore(byteIndizesPart) )
597  hasSelection = getNextSelectedAddressRange( &selectedRange, &selectionFlag, byteIndizesPart );
598 
599  if( byteIndizesPart.start() == markedRange.start() )
600  {
601  byteIndizesPart.setEnd( markedRange.end() );
602  positionsPart.setEndByWidth( markedRange.width() );
603 
604  if( positionsPart.start() == existingLinePositions.start() ) markingFlag &= ~StartsBefore;
605  // TODO: hack: needed because otherwise the spacing will be plain
606  else if( positionsPart.start() == firstLinePosition && selectedRange.includes(byteIndizesPart.start()) )
607  renderSelectionSpaceBehind( painter, firstLinePosition-1 );
608 
609  if( positionsPart.end() == existingLinePositions.end() ) markingFlag &= ~EndsLater;
610  // TODO: hack: needed because otherwise the spacing will be plain
611  else if( positionsPart.end() == linePositions.end() && selectedRange.includes(byteIndizesPart.end()) )
612  renderSelectionSpaceBehind( painter, positionsPart.end() );
613 
614  renderMarking( painter, positionsPart, byteIndizesPart.start(), markingFlag );
615  }
616  else if( selectedRange.includes(byteIndizesPart.start()) )
617  {
618  if( selectedRange.startsBefore(byteIndizesPart) )
619  selectionFlag |= StartsBefore;
620 
621  const bool hasMarkingBeforeSelectionEnd = ( hasMarking && markedRange.start() <= selectedRange.end() );
622 
623  byteIndizesPart.setEnd( hasMarkingBeforeSelectionEnd ? markedRange.nextBeforeStart() : selectedRange.end() );
624  positionsPart.setEndByWidth( byteIndizesPart.width() );
625 
626  if( hasMarkingBeforeSelectionEnd )
627  selectionFlag |= EndsLater;
628  if( positionsPart.start() == existingLinePositions.start() ) selectionFlag &= ~StartsBefore;
629  if( positionsPart.end() == existingLinePositions.end() ) selectionFlag &= ~EndsLater;
630 
631  renderSelection( painter, positionsPart, byteIndizesPart.start(), selectionFlag );
632  }
633  else
634  {
635  // calc end of plain text
636  if( hasMarking )
637  byteIndizesPart.setEnd( markedRange.nextBeforeStart() );
638  if( hasSelection )
639  byteIndizesPart.restrictEndTo( selectedRange.nextBeforeStart() );
640 
641  positionsPart.setEndByWidth( byteIndizesPart.width() );
642 
643  renderPlain( painter, positionsPart, byteIndizesPart.start() );
644  }
645 
646  byteIndizes.setStartNextBehind( byteIndizesPart );
647  linePositions.setStartNextBehind( positionsPart );
648  }
649 }
650 
651 
652 void ByteArrayRowColumnRenderer::renderPlain( QPainter* painter, const LinePositionRange& linePositions, Address byteIndex )
653 {
654  BookmarksConstIterator bit;
655  Address nextBookmarkOffset = -1;
656 
657  const bool hasBookmarks = ( mBookmarks != 0 );
658  if( hasBookmarks )
659  {
660  bit = mBookmarks->createBookmarksConstIterator();
661  if( bit.findNextFrom(byteIndex) )
662  nextBookmarkOffset = bit.next().offset();
663  }
664 
665  const QPalette& palette = stylist()->palette();
666  KColorScheme colorScheme( palette.currentColorGroup(), KColorScheme::View );
667 
668  // paint all the bytes affected
669  for( LinePosition linePosition=linePositions.start(); linePosition<=linePositions.end(); ++linePosition,++byteIndex )
670  {
671  const PixelX x = columnXOfLinePosition( linePosition );
672 
673  // draw the byte
674  painter->translate( x, 0 );
675 
676  if( byteIndex == nextBookmarkOffset )
677  {
678  renderBookmark( painter, colorScheme.background(KColorScheme::NeutralBackground) );
679 
680  nextBookmarkOffset = bit.hasNext() ? bit.next().offset() : -1;//TODO )&& ( bit->offset() <= LastIndex );
681  }
682 
683  const Byte byte = mByteArrayModel->byte( byteIndex );
684  const Character byteChar = mCharCodec->decode( byte );
685 
686  const KColorScheme::ForegroundRole foregroundRole =
687  mByteTypeColored ? foregroundRoleForChar(byteChar): KColorScheme::NormalText;
688  const QBrush brush = colorScheme.foreground( foregroundRole );
689  const QColor& charColor = brush.color();// palette.text().color();//colorForChar(byteChar)
690  renderByteText( painter, byte, byteChar, mVisibleCodings, charColor );
691 
692  painter->translate( -x, 0 );
693  }
694 }
695 
696 
697 void ByteArrayRowColumnRenderer::renderSelection( QPainter* painter, const LinePositionRange& linePositions, Address byteIndex, int flag )
698 {
699  BookmarksConstIterator bit;
700  Address nextBookmarkOffset = -1;
701 
702  const bool hasBookmarks = ( mBookmarks != 0 );
703  if( hasBookmarks )
704  {
705  bit = mBookmarks->createBookmarksConstIterator();
706  if( bit.findNextFrom( byteIndex) )
707  nextBookmarkOffset = bit.next().offset();
708  }
709 
710  const QPalette& palette = stylist()->palette();
711  KColorScheme colorScheme( palette.currentColorGroup(), KColorScheme::Selection );
712 
713  renderRange( painter, colorScheme.background(), linePositions, flag );
714 
715  // paint all the bytes affected
716  for( LinePosition linePosition=linePositions.start(); linePosition<=linePositions.end(); ++linePosition,++byteIndex )
717  {
718  const PixelX x = columnXOfLinePosition( linePosition );
719 
720  // draw the byte
721  painter->translate( x, 0 );
722 
723  if( byteIndex == nextBookmarkOffset )
724  {
725  renderBookmark( painter, colorScheme.background(KColorScheme::NeutralBackground) );
726 
727  nextBookmarkOffset = bit.hasNext() ? bit.next().offset() : -1;//TODO )&& ( bit->offset() <= LastIndex );
728  }
729 
730  const Byte byte = mByteArrayModel->byte( byteIndex );
731  const Character byteChar = mCharCodec->decode( byte );
732 
733  const KColorScheme::ForegroundRole foregroundRole =
734  mByteTypeColored ? foregroundRoleForChar(byteChar): KColorScheme::NormalText;
735  const QBrush brush = colorScheme.foreground( foregroundRole );
736  const QColor& charColor = brush.color();
737  renderByteText( painter, byte, byteChar, mVisibleCodings, charColor );
738 
739  painter->translate( -x, 0 );
740  }
741 }
742 
743 void ByteArrayRowColumnRenderer::renderSelectionSpaceBehind( QPainter* painter, LinePosition linePosition )
744 {
745  const QPalette& palette = stylist()->palette();
746  KColorScheme colorScheme( palette.currentColorGroup(), KColorScheme::Selection );
747 
748  renderSpaceBehind( painter, colorScheme.background(), linePosition );
749 }
750 
751 
752 void ByteArrayRowColumnRenderer::renderMarking( QPainter* painter, const LinePositionRange& linePositions, Address byteIndex, int flag )
753 {
754  const QPalette& palette = stylist()->palette();
755 
756  renderRange( painter, palette.text(), linePositions, flag );
757 
758  const QColor& baseColor = palette.base().color();
759  // paint all the bytes affected
760  for( LinePosition p=linePositions.start(); p<=linePositions.end(); ++p,++byteIndex )
761  {
762  const PixelX x = columnXOfLinePosition( p );
763 
764  // draw the byte
765  painter->translate( x, 0 );
766  const Byte byte = mByteArrayModel->byte( byteIndex );
767  const Character byteChar = mCharCodec->decode( byte );
768  renderByteText( painter, byte, byteChar, mVisibleCodings, baseColor );
769 
770  painter->translate( -x, 0 );
771  }
772 }
773 
774 
775 void ByteArrayRowColumnRenderer::renderBookmark( QPainter* painter, const QBrush& brush )
776 {
777  // TODO: think about how bookmarks should really be rendered
778  painter->fillRect( 1,1, mByteWidth-2,lineHeight()-2, brush );
779 }
780 
781 
782 void ByteArrayRowColumnRenderer::renderRange( QPainter* painter, const QBrush& brush, const LinePositionRange& linePositions, int flag )
783 {
784  const PixelX rangeX =
785  ( flag & StartsBefore ) ? columnRightXOfLinePosition( linePositions.nextBeforeStart() ) + 1 :
786  columnXOfLinePosition( linePositions.start() );
787  const PixelX rangeW =
788  ( (flag & EndsLater) ? columnXOfLinePosition( linePositions.nextBehindEnd() ) :
789  columnRightXOfLinePosition( linePositions.end() ) + 1 )
790  - rangeX;
791 
792  painter->fillRect( rangeX,0, rangeW,lineHeight(), brush );
793 }
794 
795 void ByteArrayRowColumnRenderer::renderSpaceBehind( QPainter* painter, const QBrush& brush, LinePosition linePosition )
796 {
797  const PixelX rangeX = columnRightXOfLinePosition( linePosition ) + 1;
798  const PixelX rangeW = columnXOfLinePosition( linePosition+1 ) - rangeX;
799 
800  painter->fillRect( rangeX,0, rangeW,lineHeight(), brush );
801 }
802 
803 
804 void ByteArrayRowColumnRenderer::renderByte( QPainter* painter,
805  Address byteIndex, AbstractByteArrayView::CodingTypeId codingId )
806 {
807  const Byte byte = ( byteIndex > -1 ) ? mByteArrayModel->byte( byteIndex ) : EmptyByte;
808  const Character byteChar = mCharCodec->decode( byte );
809 
810  const QPalette& palette = stylist()->palette();
811 
812  KColorScheme::ColorSet colorSet = KColorScheme::View;
813  if( byteIndex > -1 )
814  {
815  if( mRanges->selectionIncludes(byteIndex) )
816  colorSet = KColorScheme::Selection;
817 // else if( mRanges->markingIncludes(byteIndex) )
818 // {
819 // charColor = palette.base().color();
820 // brush = palette.text();
821 // }
822  }
823  KColorScheme colorScheme( palette.currentColorGroup(), colorSet );
824 
825  const QBrush backgroundBrush = colorScheme.background();
826  painter->fillRect( 0,0, mByteWidth,mDigitHeight, backgroundBrush );
827 
828  if( mBookmarks && mBookmarks->containsBookmarkFor(byteIndex) )
829  {
830  const QBrush bookmarkBackgroundBrush = colorScheme.background( KColorScheme::NeutralBackground );
831  painter->fillRect( 1,1, mByteWidth-2,mDigitHeight-2, bookmarkBackgroundBrush );
832  }
833 
834  if( byteIndex > -1 )
835  {
836  const KColorScheme::ForegroundRole foregroundRole =
837  mByteTypeColored ? foregroundRoleForChar(byteChar): KColorScheme::NormalText;
838  const QBrush brush = colorScheme.foreground( foregroundRole );
839  const QColor& charColor = brush.color();
840 
841  renderByteText( painter, byte, byteChar, codingId, charColor );
842  }
843 }
844 
845 // TODO: think about making framestyle a enum of a class ByteArrayColumnCursor
846 void ByteArrayRowColumnRenderer::renderFramedByte( QPainter* painter,
847  Address byteIndex, AbstractByteArrayView::CodingTypeId codingId,
848  FrameStyle frameStyle )
849 {
850  renderByte( painter, byteIndex, codingId );
851 
852  const Byte byte = ( byteIndex > -1 ) ? mByteArrayModel->byte( byteIndex ) : EmptyByte;
853  const Character byteChar = mCharCodec->decode( byte );
854 
855  const bool isInSelection = ( byteIndex > -1 && mRanges->selectionIncludes(byteIndex) );
856  const KColorScheme::ColorSet colorSet = isInSelection ? KColorScheme::Selection : KColorScheme::View;
857 
858  const QPalette& palette = stylist()->palette();
859  KColorScheme colorScheme( palette.currentColorGroup(), colorSet );
860  const KColorScheme::ForegroundRole foregroundRole =
861  mByteTypeColored ? foregroundRoleForChar(byteChar): KColorScheme::NormalText;
862  const QBrush brush = colorScheme.foreground( foregroundRole );
863  const QColor& charColor = brush.color();
864  painter->setPen( charColor );
865  if( frameStyle == Frame )
866  painter->drawRect( 0,0, mByteWidth-1,mDigitHeight-1 );
867  else if( frameStyle == Left )
868  painter->drawLine( 0,0, 0,mDigitHeight-1 );
869  else
870  painter->drawLine( mByteWidth-1,0, mByteWidth-1,mDigitHeight-1 );
871 }
872 
873 
874 void ByteArrayRowColumnRenderer::renderCursor( QPainter* painter, Address byteIndex, AbstractByteArrayView::CodingTypeId codingId )
875 {
876 Q_UNUSED( codingId )
877  const Byte byte = ( byteIndex > -1 ) ? mByteArrayModel->byte( byteIndex ) : EmptyByte;
878  const Character byteChar = mCharCodec->decode( byte );
879 
880  const bool isInSelection = ( byteIndex > -1 && mRanges->selectionIncludes(byteIndex) );
881  const KColorScheme::ColorSet colorSet = isInSelection ? KColorScheme::Selection : KColorScheme::View;
882 
883  const QPalette& palette = stylist()->palette();
884  KColorScheme colorScheme( palette.currentColorGroup(), colorSet );
885  const KColorScheme::ForegroundRole foregroundRole =
886  mByteTypeColored ? foregroundRoleForChar(byteChar): KColorScheme::NormalText;
887  const QBrush brush = colorScheme.foreground( foregroundRole );
888  painter->fillRect( 0,0, mByteWidth,mDigitHeight, brush );
889 }
890 
891 
892 bool ByteArrayRowColumnRenderer::getNextSelectedAddressRange( AddressRange* _selection, unsigned int* _flag,
893  const AddressRange& range ) const
894 {
895  const AddressRange* overlappingSelectedSection = mRanges->firstOverlappingSelection( range );
896  if( !overlappingSelectedSection )
897  return false;
898 
899  AddressRange selectedRange = *overlappingSelectedSection;
900  unsigned int flag = 0;
901 
902  // does selectedRange start before asked range?
903  if( selectedRange.startsBefore(range) )
904  {
905  selectedRange.setStart( range.start() );
906  flag |= StartsBefore;
907  }
908 
909  // does selectedRange go on behind asked range?
910  if( selectedRange.endsBehind(range) )
911  {
912  selectedRange.setEnd( range.end() );
913  flag |= EndsLater;
914  }
915 
916  *_selection = selectedRange;
917  *_flag = flag;
918  return true;
919 }
920 
921 
922 bool ByteArrayRowColumnRenderer::getNextMarkedAddressRange( AddressRange* _markedSection, unsigned int* _flag,
923  const AddressRange& range ) const
924 {
925  const AddressRange* overlappingMarkedSection = mRanges->overlappingMarking( range );
926  if( !overlappingMarkedSection )
927  return false;
928 
929  unsigned int flag = 0;
930  AddressRange markedRange = *overlappingMarkedSection;
931 
932  if( markedRange.startsBefore(range) )
933  {
934  markedRange.setStart( range.start() );
935  flag |= StartsBefore;
936  }
937 
938  if( markedRange.endsBehind(range) )
939  {
940  markedRange.setEnd( range.end() );
941  flag |= EndsLater;
942  }
943 
944  *_markedSection = markedRange;
945  *_flag = flag;
946  return true;
947 }
948 
949 
950 ByteArrayRowColumnRenderer::~ByteArrayRowColumnRenderer()
951 {
952  delete [] mLinePosLeftPixelX;
953  delete [] mLinePosRightPixelX;
954 }
955 
956 }
Okteta::ByteArrayRowColumnRenderer::renderFirstLine
virtual void renderFirstLine(QPainter *painter, const PixelXRange &Xs, Line firstLineIndex)
Definition: bytearrayrowcolumnrenderer.cpp:537
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
Okteta::ByteArrayRowColumnRenderer::setBinaryGapWidth
bool setBinaryGapWidth(PixelX binaryGapWidth)
sets the spacing in the middle of a binary byte in the value column
Definition: bytearrayrowcolumnrenderer.cpp:226
Okteta::ByteArrayRowColumnRenderer::prepareRendering
void prepareRendering(const PixelXRange &Xs)
Definition: bytearrayrowcolumnrenderer.cpp:521
Okteta::ByteArrayRowColumnRenderer::~ByteArrayRowColumnRenderer
virtual ~ByteArrayRowColumnRenderer()
Definition: bytearrayrowcolumnrenderer.cpp:950
Okteta::AbstractColumnRenderer::restrictToXSpan
void restrictToXSpan(PixelXRange *xSpan) const
Definition: abstractcolumnrenderer.cpp:54
Okteta::DefaultRowSpacingHeight
static const PixelX DefaultRowSpacingHeight
Definition: oktetagui.h:48
Okteta::LinePositionRange
KDE::NumberRange< LinePosition, LinePositionSize > LinePositionRange
Definition: linepositionrange.h:34
Okteta::ByteArrayRowColumnRenderer::renderEditedByte
void renderEditedByte(QPainter *painter, Byte byte, const QString &editBuffer)
Definition: bytearrayrowcolumnrenderer.cpp:258
Okteta::ByteArrayRowColumnRenderer::recalcByteWidth
void recalcByteWidth()
default implementation sets byte width to one digit width
Definition: bytearrayrowcolumnrenderer.cpp:243
Okteta::ByteArrayRowColumnRenderer::getNextSelectedAddressRange
bool getNextSelectedAddressRange(AddressRange *selectedRange, unsigned int *flag, const AddressRange &range) const
Definition: bytearrayrowcolumnrenderer.cpp:892
Okteta::ByteArrayRowColumnRenderer::renderByteText
void renderByteText(QPainter *painter, Byte byte, Character charByte, int codings, const QColor &color) const
Definition: bytearrayrowcolumnrenderer.cpp:275
bookmark.h
Okteta::ByteArrayTableRanges::overlappingMarking
const AddressRange * overlappingMarking(const AddressRange &range) const
Definition: bytearraytableranges.cpp:203
Okteta::ByteArrayRowColumnRenderer::renderSelectionSpaceBehind
void renderSelectionSpaceBehind(QPainter *painter, LinePosition linePosition)
Definition: bytearrayrowcolumnrenderer.cpp:743
Okteta::ByteArrayTableRanges
a class to control all the ranges like marking and selections holds also all modified ranges and merg...
Definition: bytearraytableranges.h:45
Okteta::ByteArrayTableLayout::noOfBytesPerLine
Size noOfBytesPerLine() const
returns number of bytes per line
Definition: bytearraytablelayout.h:209
Okteta::ByteArrayRowColumnRenderer::mByteTypeColored
bool mByteTypeColored
Definition: bytearrayrowcolumnrenderer.h:288
Okteta::ByteArrayRowColumnRenderer::mByteSpacingWidth
PixelX mByteSpacingWidth
width of inserting cursor in pixel
Definition: bytearrayrowcolumnrenderer.h:272
Okteta::ByteArrayRowColumnRenderer::rowHeight
PixelY rowHeight() const
Definition: bytearrayrowcolumnrenderer.cpp:90
Okteta::ByteArrayRowColumnRenderer::setSpacing
bool setSpacing(PixelX byteSpacingWidth, Size noOfGroupedBytes=0, PixelX groupSpacingWidth=0)
sets the spacing in the hex column
Definition: bytearrayrowcolumnrenderer.cpp:148
Okteta::ByteArrayRowColumnRenderer::mByteArrayModel
AbstractByteArrayModel * mByteArrayModel
pointer to the buffer
Definition: bytearrayrowcolumnrenderer.h:245
abstractcolumnstylist.h
Okteta::ByteArrayRowColumnRenderer::columnRightXOfLinePosition
PixelX columnRightXOfLinePosition(LinePosition posInLine) const
returns right relative x-coord of byte at position posInLine
Definition: bytearrayrowcolumnrenderer.cpp:467
KDE::Range::moveBy
void moveBy(T D)
moves the range by D.
Definition: range.h:82
Okteta::Bookmark::offset
Address offset() const
Definition: bookmark.h:66
Okteta::DefaultBinaryGapWidth
static const int DefaultBinaryGapWidth
Definition: oktetagui.h:52
Okteta::DefaultByteSpacingWidth
static const PixelX DefaultByteSpacingWidth
Definition: oktetagui.h:46
Okteta::ByteArrayRowColumnRenderer::mBinaryGapWidth
PixelX mBinaryGapWidth
Definition: bytearrayrowcolumnrenderer.h:296
KDE::NumberRange::nextBehindEnd
N nextBehindEnd() const
Definition: numberrange.h:145
Okteta::ByteArrayRowColumnRenderer::mDigitWidth
PixelX mDigitWidth
Definition: bytearrayrowcolumnrenderer.h:257
Okteta::ByteArrayRowColumnRenderer::mRenderLinePositions
LinePositionRange mRenderLinePositions
Definition: bytearrayrowcolumnrenderer.h:313
KDE::NumberRange< LinePosition, LinePositionSize >
oktetagui.h
KDE::Range::start
T start() const
Definition: range.h:86
KDE::Range::setEnd
void setEnd(T E)
sets the last index of the range
Definition: range.h:60
Okteta::Character::isUndefined
bool isUndefined() const
Definition: character.h:52
Okteta::ByteArrayRowColumnRenderer::mByteWidth
PixelX mByteWidth
total width of byte display in pixel
Definition: bytearrayrowcolumnrenderer.h:268
Okteta::Byte
unsigned char Byte
Definition: byte.h:29
Okteta::ByteArrayRowColumnRenderer::xOfLinePosition
PixelX xOfLinePosition(LinePosition posInLine) const
returns absolute x-coord of byte at position posInLine
Definition: bytearrayrowcolumnrenderer.cpp:410
Okteta::ByteArrayRowColumnRenderer::Frame
Definition: bytearrayrowcolumnrenderer.h:65
Okteta::CharCodec::decode
virtual Character decode(Byte byte) const =0
Okteta::ByteArrayRowColumnRenderer::mRenderX
PixelX mRenderX
Definition: bytearrayrowcolumnrenderer.h:315
Okteta::ByteArrayTableRanges::selectionIncludes
bool selectionIncludes(Address index) const
Definition: bytearraytableranges.h:141
Okteta::ByteArrayTableLayout::linePositions
LinePositionRange linePositions(Line line) const
returns the used positions in line
Definition: bytearraytablelayout.cpp:267
KDE::Range::restrictTo
void restrictTo(const Range &Limit)
restricts the range to Limit.
Definition: range.h:64
Okteta::ByteArrayRowColumnRenderer::yOfCodingId
PixelY yOfCodingId(AbstractByteArrayView::CodingTypeId codingId) const
Definition: bytearrayrowcolumnrenderer.cpp:96
Okteta::AbstractByteArrayView::CodingTypeId
CodingTypeId
Definition: abstractbytearrayview.h:103
Okteta::Coord
a class which represents a coord in a 2-dim.
Definition: coord.h:47
Okteta::ByteArrayRowColumnRenderer::setVisibleCodings
void setVisibleCodings(int visibleCodings)
Definition: bytearrayrowcolumnrenderer.cpp:126
Okteta::ByteArrayRowColumnRenderer::recalcX
void recalcX()
Definition: bytearrayrowcolumnrenderer.cpp:315
Okteta::ByteArrayRowColumnRenderer::renderLinePositions
void renderLinePositions(QPainter *painter, Line lineIndex, const LinePositionRange &linePositions)
Definition: bytearrayrowcolumnrenderer.cpp:553
Okteta::ByteArrayTableRanges::firstOverlappingSelection
const AddressRange * firstOverlappingSelection(const AddressRange &range) const
Definition: bytearraytableranges.cpp:197
Okteta::ByteArrayRowColumnRenderer::mLastLinePos
LinePosition mLastLinePos
index of right position
Definition: bytearrayrowcolumnrenderer.h:285
Okteta::DefaultGroupSpacingWidth
static const PixelX DefaultGroupSpacingWidth
Definition: oktetagui.h:47
Okteta::ByteArrayRowColumnRenderer::renderCode
void renderCode(QPainter *painter, const QString &code, const QColor &color) const
Definition: bytearrayrowcolumnrenderer.cpp:301
Okteta::ByteArrayRowColumnRenderer::mUndefinedChar
QChar mUndefinedChar
Definition: bytearrayrowcolumnrenderer.h:310
Okteta::Bookmarkable
Definition: bookmarkable.h:39
Okteta::ByteArrayRowColumnRenderer::mRenderLine
Line mRenderLine
Definition: bytearrayrowcolumnrenderer.h:314
Okteta::AbstractByteArrayView::ValueCodingId
Definition: abstractbytearrayview.h:103
Okteta::Line
qint32 Line
Definition: line.h:33
Okteta::Bookmarkable::createBookmarksConstIterator
virtual Okteta::BookmarksConstIterator createBookmarksConstIterator() const =0
KDE::NumberRange::width
S width() const
Definition: numberrange.h:141
Okteta::AbstractColumnStylist
Definition: abstractcolumnstylist.h:38
Okteta::ByteArrayRowColumnRenderer::mVisibleCodings
AbstractByteArrayView::CodingTypes mVisibleCodings
Definition: bytearrayrowcolumnrenderer.h:255
Okteta::BookmarksConstIterator
Definition: bookmarksconstiterator.h:36
bytearraytablelayout.h
Okteta::ByteArrayRowColumnRenderer::set
void set(AbstractByteArrayModel *byteArrayModel)
Definition: bytearrayrowcolumnrenderer.cpp:106
Okteta::ByteArrayRowColumnRenderer::setGroupSpacingWidth
bool setGroupSpacingWidth(PixelX groupSpacingWidth)
sets the spacing between the groups of bytes in the hex column
Definition: bytearrayrowcolumnrenderer.cpp:196
Okteta::ByteArrayTableLayout
the logical layout of a byte array table for a view
Definition: bytearraytablelayout.h:61
Okteta::ByteArrayRowColumnRenderer::linePositionOfColumnX
LinePosition linePositionOfColumnX(PixelX x) const
returns byte pos at pixel with relative x-coord x
Definition: bytearrayrowcolumnrenderer.cpp:421
Okteta::ByteArrayRowColumnRenderer::resetXBuffer
void resetXBuffer()
creates new buffer for x-values; to be called on any change of NoOfBytesPerLine or metrics ...
Definition: bytearrayrowcolumnrenderer.cpp:113
Okteta::PixelX
int PixelX
Definition: kadds.h:34
Okteta::ByteArrayRowColumnRenderer::mBinaryHalfOffset
PixelX mBinaryHalfOffset
calculated: Offset in pixels of the second half of the binary
Definition: bytearrayrowcolumnrenderer.h:302
Okteta::ByteArrayTableLayout::hasContent
bool hasContent(Line line) const
returns true if the line has content
Definition: bytearraytablelayout.cpp:293
Okteta::DefaultUndefinedChar
static const QChar DefaultUndefinedChar
Definition: oktetagui.h:58
Okteta::ByteArrayRowColumnRenderer::mRenderWidth
PixelX mRenderWidth
Definition: bytearrayrowcolumnrenderer.h:316
bytearrayrowcolumnrenderer.h
Okteta::ByteArrayTableRanges::hasSelection
bool hasSelection() const
Definition: bytearraytableranges.h:136
KDE::Range::restrictEndTo
void restrictEndTo(T Limit)
restricts the end to Limit.
Definition: range.h:69
Okteta::ByteArrayRowColumnRenderer::setFontMetrics
void setFontMetrics(const QFontMetrics &fontMetrics)
sets the metrics of the used font
Definition: bytearrayrowcolumnrenderer.cpp:132
Okteta::ByteArrayRowColumnRenderer::linePositionsOfColumnXs
LinePositionRange linePositionsOfColumnXs(PixelX x, PixelX width) const
returns byte linePositions covered by pixels with relative x-coord x
Definition: bytearrayrowcolumnrenderer.cpp:435
bookmarksconstiterator.h
Okteta::ByteArrayRowColumnRenderer::byteSpacingWidth
PixelX byteSpacingWidth() const
Definition: bytearrayrowcolumnrenderer.h:325
Okteta::ByteArrayRowColumnRenderer::mBookmarks
Bookmarkable * mBookmarks
Definition: bytearrayrowcolumnrenderer.h:251
Okteta::ByteArrayRowColumnRenderer::mValueCoding
ValueCoding mValueCoding
Definition: bytearrayrowcolumnrenderer.h:292
KDE::Range::end
T end() const
Definition: range.h:88
Okteta::ValueCodec
Class that is able to convert codings to and from hexadecimal, decimal, octal, and binary...
Definition: valuecodec.h:45
KDE::NumberRange< Address, Size >::fromWidth
static NumberRange fromWidth(AddressstartIndex, Sizewidth)
constructs a range by width
Okteta::ByteArrayRowColumnRenderer::mSpacingTrigger
int mSpacingTrigger
Definition: bytearrayrowcolumnrenderer.h:317
KDE::Range::endsBehind
bool endsBehind(T Value) const
returns true if the range ends later than index.
Definition: range.h:101
Okteta::ByteArrayRowColumnRenderer::xsOfLinePositionsInclSpaces
PixelXRange xsOfLinePositionsInclSpaces(const LinePositionRange &linePositions) const
returns the
Definition: bytearrayrowcolumnrenderer.cpp:473
Okteta::Coord::pos
LinePosition pos() const
Definition: coord.h:213
Okteta::ByteArrayRowColumnRenderer::renderPlain
void renderPlain(QPainter *painter, const LinePositionRange &linePositions, Address byteIndex)
Definition: bytearrayrowcolumnrenderer.cpp:652
Okteta::ByteArrayRowColumnRenderer::renderSpaceBehind
void renderSpaceBehind(QPainter *painter, const QBrush &brush, LinePosition linePosition)
Definition: bytearrayrowcolumnrenderer.cpp:795
Okteta::ByteArrayRowColumnRenderer::setValueCodec
void setValueCodec(ValueCoding valueCoding, const ValueCodec *valueCodec)
Definition: bytearrayrowcolumnrenderer.cpp:212
Okteta::ByteArrayRowColumnRenderer::mGroupSpacingWidth
PixelX mGroupSpacingWidth
width of spacing in pixel
Definition: bytearrayrowcolumnrenderer.h:274
Okteta::AbstractColumnRenderer::setWidth
void setWidth(PixelX width)
sets width of the column
Definition: abstractcolumnrenderer.cpp:50
Okteta::ByteArrayRowColumnRenderer::mDigitBaseLine
PixelY mDigitBaseLine
Definition: bytearrayrowcolumnrenderer.h:259
Okteta::ByteArrayRowColumnRenderer::noOfGroupedBytes
Size noOfGroupedBytes() const
Definition: bytearrayrowcolumnrenderer.h:328
valuecodec.h
Okteta::ByteArrayRowColumnRenderer::renderNextLine
virtual void renderNextLine(QPainter *painter)
the actual painting call for a column's line.
Definition: bytearrayrowcolumnrenderer.cpp:547
Okteta::ByteArrayRowColumnRenderer::ByteArrayRowColumnRenderer
ByteArrayRowColumnRenderer(AbstractColumnStylist *stylist, AbstractByteArrayModel *byteArrayModel, ByteArrayTableLayout *layout, ByteArrayTableRanges *ranges)
Definition: bytearrayrowcolumnrenderer.cpp:52
Okteta::ByteArrayRowColumnRenderer::binaryGapWidth
PixelX binaryGapWidth() const
Definition: bytearrayrowcolumnrenderer.h:347
Okteta::ByteArrayRowColumnRenderer::renderMarking
void renderMarking(QPainter *painter, const LinePositionRange &linePositions, Address byteIndex, int flag)
Definition: bytearrayrowcolumnrenderer.cpp:752
Okteta::AbstractByteArrayModel::byte
virtual Byte byte(Address offset) const =0
locates working range The idea behind is to tell buffer which range will be requested in the followin...
Okteta::BinaryCoding
Definition: oktetacore.h:34
Okteta::ByteArrayRowColumnRenderer::mNoOfGroupedBytes
Size mNoOfGroupedBytes
number of grouped bytes
Definition: bytearrayrowcolumnrenderer.h:277
KDE::NumberRange::setEndByWidth
void setEndByWidth(S width)
sets the last index of the range's range to be width-1 behind the start If the range is invalid the b...
Definition: numberrange.h:152
KDE::NumberRange::setStartNextBehind
void setStartNextBehind(const NumberRange &other)
sets the first index of the range's range one behind the other's end If one of both is invalid the be...
Definition: numberrange.h:154
Okteta::DefaultShowingNonprinting
static const bool DefaultShowingNonprinting
Definition: oktetagui.h:56
Okteta::EmptyByte
static const Byte EmptyByte
Definition: oktetagui.h:43
Okteta::ByteArrayRowColumnRenderer::renderByte
void renderByte(QPainter *painter, Address byteIndex, AbstractByteArrayView::CodingTypeId codingId)
paints the byte with background.
Definition: bytearrayrowcolumnrenderer.cpp:804
Okteta::ByteArrayRowColumnRenderer::mFontMetrics
QFontMetrics mFontMetrics
Definition: bytearrayrowcolumnrenderer.h:263
Okteta::ByteArrayRowColumnRenderer::renderSelection
void renderSelection(QPainter *painter, const LinePositionRange &linePositions, Address byteIndex, int flag)
Definition: bytearrayrowcolumnrenderer.cpp:697
Okteta::ByteArrayRowColumnRenderer::mValueCodec
const ValueCodec * mValueCodec
Definition: bytearrayrowcolumnrenderer.h:294
Okteta::BookmarksConstIterator::next
const Okteta::Bookmark & next()
Definition: bookmarksconstiterator.h:78
Okteta::ByteArrayRowColumnRenderer::mDecodedByteText
QString mDecodedByteText
buffer to hold the formatted valueCoding
Definition: bytearrayrowcolumnrenderer.h:300
Okteta::ByteArrayTableRanges::hasMarking
bool hasMarking() const
Definition: bytearraytableranges.h:140
KDE::Range::includes
bool includes(T Value) const
returns true if Value is covered
Definition: range.h:93
Okteta::ByteArrayRowColumnRenderer::columnXsOfLinePositionsInclSpaces
PixelXRange columnXsOfLinePositionsInclSpaces(const LinePositionRange &linePositions) const
Definition: bytearrayrowcolumnrenderer.cpp:483
Okteta::AbstractByteArrayView::ValueAndCharCodings
Definition: abstractbytearrayview.h:104
charcodec.h
Okteta::LinePosition
qint32 LinePosition
Definition: lineposition.h:33
Okteta::ByteArrayRowColumnRenderer::mShowingNonprinting
bool mShowingNonprinting
Definition: bytearrayrowcolumnrenderer.h:306
Okteta::BookmarksConstIterator::hasNext
bool hasNext() const
Definition: bookmarksconstiterator.h:69
Okteta::AbstractByteArrayView::CharCodingId
Definition: abstractbytearrayview.h:103
foregroundRoleForChar
static KColorScheme::ForegroundRole foregroundRoleForChar(const Okteta::Character byteChar)
Definition: helper.h:46
Okteta::ByteArrayRowColumnRenderer::setNoOfGroupedBytes
bool setNoOfGroupedBytes(Size noOfGroupedBytes)
sets the number of grouped bytes in the hex column
Definition: bytearrayrowcolumnrenderer.cpp:182
Okteta::ByteArrayRowColumnRenderer::setByteSpacingWidth
bool setByteSpacingWidth(PixelX byteSpacingWidth)
sets the spacing between the bytes in the hex column
Definition: bytearrayrowcolumnrenderer.cpp:166
Okteta::ByteArrayRowColumnRenderer::linePositionsOfX
LinePositionRange linePositionsOfX(PixelX x, PixelX width) const
returns byte linePositions covered by pixels with absolute x-coord x
Definition: bytearrayrowcolumnrenderer.cpp:382
Okteta::ByteArrayRowColumnRenderer::linePositionOfX
LinePosition linePositionOfX(PixelX x) const
returns byte pos at pixel with absolute x-coord x
Definition: bytearrayrowcolumnrenderer.cpp:345
Okteta::AbstractColumnRenderer::stylist
AbstractColumnStylist * stylist() const
Definition: abstractcolumnrenderer.cpp:40
Okteta::ByteArrayRowColumnRenderer::columnXOfLinePosition
PixelX columnXOfLinePosition(LinePosition posInLine) const
returns relative x-coord of byte at position posInLine
Definition: bytearrayrowcolumnrenderer.cpp:462
Okteta::ByteArrayRowColumnRenderer::mRanges
ByteArrayTableRanges * mRanges
pointer to the ranges
Definition: bytearrayrowcolumnrenderer.h:249
Okteta::ByteArrayTableLayout::indexAtCoord
Address indexAtCoord(const Coord &coord) const
calculates the index of coord.
Definition: bytearraytablelayout.cpp:213
Okteta::ByteArrayRowColumnRenderer::mLayout
const ByteArrayTableLayout * mLayout
pointer to the layout
Definition: bytearrayrowcolumnrenderer.h:247
Okteta::ValueCoding
ValueCoding
Definition: oktetacore.h:34
Okteta::ByteArrayRowColumnRenderer::byteRect
QRect byteRect(const Coord &coord) const
Definition: bytearrayrowcolumnrenderer.cpp:493
Okteta::ByteArrayRowColumnRenderer::byteWidth
PixelX byteWidth() const
Definition: bytearrayrowcolumnrenderer.h:323
Okteta::StartsBefore
static const unsigned int StartsBefore
Definition: oktetagui.h:41
Okteta::Coord::line
Line line() const
Definition: coord.h:214
Okteta::ByteArrayRowColumnRenderer::rightXOfLinePosition
PixelX rightXOfLinePosition(LinePosition posInLine) const
returns right absolute x-coord of byte at position posInLine
Definition: bytearrayrowcolumnrenderer.cpp:415
Okteta::ByteArrayRowColumnRenderer::Left
Definition: bytearrayrowcolumnrenderer.h:65
bytearraytableranges.h
Okteta::AbstractColumnRenderer::rightX
PixelX rightX() const
right offset x in pixel
Definition: abstractcolumnrenderer.cpp:43
Okteta::ByteArrayRowColumnRenderer::renderFramedByte
void renderFramedByte(QPainter *painter, Address byteIndex, AbstractByteArrayView::CodingTypeId codingId, FrameStyle style)
paints the byte with background and a frame around.
Definition: bytearrayrowcolumnrenderer.cpp:846
Okteta::ByteArrayRowColumnRenderer::getNextMarkedAddressRange
bool getNextMarkedAddressRange(AddressRange *markedRange, unsigned int *flag, const AddressRange &range) const
Definition: bytearrayrowcolumnrenderer.cpp:922
KDE::Range::startsBefore
bool startsBefore(T Value) const
returns true is the range starts before index.
Definition: range.h:99
Okteta::AbstractColumnRenderer::x
PixelX x() const
left offset x in pixel
Definition: abstractcolumnrenderer.cpp:42
KDE::Range::endsBefore
bool endsBefore(T Value) const
returns true if range is before index.
Definition: range.h:103
Okteta::DefaultVisibleCodings
static const AbstractByteArrayView::CodingTypes DefaultVisibleCodings
Definition: bytearrayrowcolumnrenderer.cpp:49
Okteta::ByteArrayRowColumnRenderer::mCharCodec
const CharCodec * mCharCodec
Definition: bytearrayrowcolumnrenderer.h:253
Okteta::Size
qint32 Size
Definition: size.h:33
Okteta::AbstractColumnRenderer::lineHeight
PixelY lineHeight() const
Definition: abstractcolumnrenderer.cpp:47
Okteta::AbstractColumnRenderer
base class for columns of the ColumnsView
Definition: abstractcolumnrenderer.h:46
Okteta::ByteArrayRowColumnRenderer::renderBookmark
void renderBookmark(QPainter *painter, const QBrush &brush)
Definition: bytearrayrowcolumnrenderer.cpp:775
Okteta::AbstractColumnStylist::palette
virtual const QPalette & palette() const =0
Okteta::ByteArrayRowColumnRenderer::codingIdofY
AbstractByteArrayView::CodingTypeId codingIdofY(PixelY y) const
Definition: bytearrayrowcolumnrenderer.cpp:80
Okteta::BookmarksConstIterator::findNextFrom
bool findNextFrom(unsigned int offset)
Definition: bookmarksconstiterator.h:76
Okteta::DefaultNoOfGroupedBytes
static const int DefaultNoOfGroupedBytes
Definition: oktetagui.h:49
Okteta::ValueCodec::encodingWidth
virtual unsigned int encodingWidth() const =0
Okteta::ByteArrayRowColumnRenderer::groupSpacingWidth
PixelX groupSpacingWidth() const
Definition: bytearrayrowcolumnrenderer.h:326
KDE::Range::setStart
void setStart(T S)
sets the first index of the range
Definition: range.h:58
Okteta::DefaultSubstituteChar
static const QChar DefaultSubstituteChar
Definition: oktetagui.h:57
bytearraytablecursor.h
Okteta::ByteArrayRowColumnRenderer::renderRange
void renderRange(QPainter *painter, const QBrush &brush, const LinePositionRange &linePositions, int flag)
Definition: bytearrayrowcolumnrenderer.cpp:782
KDE::Range::isValid
bool isValid() const
returns true if the range covers at least one index
Definition: range.h:122
Okteta::ByteArrayRowColumnRenderer::renderCursor
void renderCursor(QPainter *painter, Address byteIndex, AbstractByteArrayView::CodingTypeId codingId)
paints a cursor based on the type of the byte.
Definition: bytearrayrowcolumnrenderer.cpp:874
Okteta::ByteArrayRowColumnRenderer::FrameStyle
FrameStyle
Definition: bytearrayrowcolumnrenderer.h:65
Okteta::Bookmarkable::containsBookmarkFor
virtual bool containsBookmarkFor(int offset) const =0
Okteta::Character
Definition: character.h:35
Okteta::PixelXRange
KDE::NumberRange< PixelX > PixelXRange
Definition: kadds.h:37
Okteta::ByteArrayRowColumnRenderer::mLinePosLeftPixelX
PixelX * mLinePosLeftPixelX
pointer to array with buffered linePositions (relative to column position) any spacing gets assigned ...
Definition: bytearrayrowcolumnrenderer.h:282
Okteta::ByteArrayRowColumnRenderer::mLinePosRightPixelX
PixelX * mLinePosRightPixelX
Definition: bytearrayrowcolumnrenderer.h:283
Okteta::PixelY
int PixelY
Definition: kadds.h:35
bookmarkable.h
KDE::NumberRange::nextBeforeStart
N nextBeforeStart() const
Definition: numberrange.h:143
Okteta::AbstractByteArrayView::CodingTypes
CodingTypes
Definition: abstractbytearrayview.h:104
Okteta::EndsLater
static const unsigned int EndsLater
Definition: oktetagui.h:42
helper.h
Okteta::ByteArrayRowColumnRenderer::magneticLinePositionOfX
LinePosition magneticLinePositionOfX(PixelX x) const
returns byte pos at pixel with absolute x-coord x, and sets the flag to true if we are closer to the ...
Definition: bytearrayrowcolumnrenderer.cpp:361
Okteta::NoByteFound
static const LinePosition NoByteFound
Definition: oktetagui.h:39
Okteta::ValueCodec::encode
virtual void encode(QString &digits, unsigned int pos, Byte byte) const =0
Encodes the byte using full coding width, prefixing with 0s if needed, and writes the result to digit...
Okteta::ByteArrayRowColumnRenderer::mSubstituteChar
QChar mSubstituteChar
Definition: bytearrayrowcolumnrenderer.h:308
Okteta::ByteArrayRowColumnRenderer::mDigitHeight
PixelY mDigitHeight
Definition: bytearrayrowcolumnrenderer.h:261
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:07 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