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
|
/***************************************************************************
koffsetcolumn.cpp - description
-------------------
begin : Mit Mai 14 2003
copyright : (C) 2003 by Friedrich W. H. Kossebau
email : Friedrich.W.H@Kossebau.de
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// qt specific
#include "qpainter.h"
// lib specific
#include "kcolumnsview.h"
#include "koffsetcolumn.h"
using namespace KHE;
KOffsetColumn::KOffsetColumn( KColumnsView *V, int FLO, int D, KOffsetFormat::KFormat F )
: KColumn( V ),
FirstLineOffset( FLO ),
Delta( D ),
Margin( 0 ),
DigitWidth( 0 ),
DigitBaseLine( 0 ),
Format( KOffsetFormat::None )
{
setFormat( F );
}
KOffsetColumn::~KOffsetColumn()
{
}
void KOffsetColumn::paintLine( QPainter *P, int Line )
{
KColumn::paintBlankLine( P );
printFunction()( CodedOffset,FirstLineOffset+Delta*Line );
P->drawText( 0, DigitBaseLine, QString().append(CodedOffset) );
}
void KOffsetColumn::paintFirstLine( QPainter *P, KPixelX, KPixelX, int FirstLine )
{
PaintLine = FirstLine;
paintLine( P, PaintLine++ );
}
void KOffsetColumn::paintNextLine( QPainter *P )
{
paintLine( P, PaintLine++ );
}
void KOffsetColumn::setFormat( KOffsetFormat::KFormat F )
{
// no changes?
if( Format == F )
return;
Format = F;
CodingWidth = KOffsetFormat::codingWidth( Format );
PrintFunction = KOffsetFormat::printFunction( Format );
recalcX();
}
void KOffsetColumn::setMetrics( KPixelX DW, KPixelY DBL )
{
DigitBaseLine = DBL;
setDigitWidth( DW );
}
void KOffsetColumn::setDigitWidth( KPixelX DW )
{
// no changes?
if( DigitWidth == DW )
return;
DigitWidth = DW;
recalcX();
}
void KOffsetColumn::recalcX()
{
// recalculate depend sizes
setWidth( CodingWidth * DigitWidth );
}
|