From 2bda8f7717adf28da4af0d34fb82f63d2868c31d Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- khexedit/lib/koffsetcolumn.cpp | 110 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 khexedit/lib/koffsetcolumn.cpp (limited to 'khexedit/lib/koffsetcolumn.cpp') diff --git a/khexedit/lib/koffsetcolumn.cpp b/khexedit/lib/koffsetcolumn.cpp new file mode 100644 index 0000000..6bd6d09 --- /dev/null +++ b/khexedit/lib/koffsetcolumn.cpp @@ -0,0 +1,110 @@ +/*************************************************************************** + 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 ) +{ + const QColor &ButtonColor = View->colorGroup().button(); + P->fillRect( 0,0,width(),LineHeight, QBrush(ButtonColor,Qt::SolidPattern) ); + + printFunction()( CodedOffset,FirstLineOffset+Delta*Line ); + P->drawText( 0, DigitBaseLine, QString().append(CodedOffset) ); +} + + +void KOffsetColumn::paintFirstLine( QPainter *P, KPixelXs, int FirstLine ) +{ + PaintLine = FirstLine; + paintLine( P, PaintLine++ ); +} + + +void KOffsetColumn::paintNextLine( QPainter *P ) +{ + paintLine( P, PaintLine++ ); +} + + + +void KOffsetColumn::paintEmptyColumn( QPainter *P, KPixelXs Xs, KPixelYs Ys ) +{ + Xs.restrictTo( XSpan ); + + const QColor &ButtonColor = View->colorGroup().button(); + P->fillRect( Xs.start(), Ys.start(), Xs.width(), Ys.width(), QBrush(ButtonColor,Qt::SolidPattern) ); +} + +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 ); +} -- cgit v1.2.1