• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeutils
  • Sitemap
  • Contact Us
 

okteta

abstractbytearraycolumnrenderer.h

Go to the documentation of this file.
00001 /*
00002     This file is part of the Okteta Gui library, part of the KDE project.
00003 
00004     Copyright 2003,2007,2008 Friedrich W. H. Kossebau <kossebau@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Lesser General Public
00008     License as published by the Free Software Foundation; either
00009     version 2.1 of the License, or (at your option) version 3, or any
00010     later version accepted by the membership of KDE e.V. (or its
00011     successor approved by the membership of KDE e.V.), which shall
00012     act as a proxy defined in Section 6 of version 3 of the license.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public
00020     License along with this library. If not, see <http://www.gnu.org/licenses/>.
00021 */
00022 
00023 #ifndef KHE_UI_ABSTRACTBYTEARRAYCOLUMNRENDERER_H
00024 #define KHE_UI_ABSTRACTBYTEARRAYCOLUMNRENDERER_H
00025 
00026 // ColumnsView
00027 #include <columnrenderer.h>
00028 // Okteta core
00029 #include <khe.h>
00030 #include <kabstractbytearraymodel.h>
00031 #include <khechar.h>
00032 // commonlib
00033 #include <ksection.h>
00034 
00035 
00036 class QPainter;
00037 class QColor;
00038 class QBrush;
00039 
00040 namespace KHECore {
00041 class Bookmarkable;
00042 class KCharCodec;
00043 }
00044 
00045 namespace KHEUI
00046 {
00047 
00048 // class KByteArrayView;
00049 class KDataRanges;
00050 class ByteArrayTableLayout;
00051 
00052 const int NoByteFound = -1;
00053 
00061 class AbstractByteArrayColumnRenderer : public ColumnRenderer
00062 {
00063   public:
00064     enum FrameStyle { Frame, Left, Right };
00065   public:
00066     AbstractByteArrayColumnRenderer( ColumnsView/*KByteArrayView*/ *columnsView,
00067         KHECore::KAbstractByteArrayModel *byteArrayModel, ByteArrayTableLayout *layout, KDataRanges *ranges );
00068     virtual ~AbstractByteArrayColumnRenderer();
00069 
00070 
00071   public: // ColumnRenderer API
00072     virtual void renderFirstLine( QPainter *painter, const KPixelXs &Xs, int firstLineIndex );
00073     virtual void renderNextLine( QPainter *painter );
00074 
00075   public:
00076     void prepareRendering( const KPixelXs &Xs );
00077 
00078   public:
00079     //void renderLine( QPainter *painter, int lineIndex );
00080     void renderLinePositions( QPainter *painter, int lineIndex, const KHE::KSection &linePositions );
00084     void renderCursor( QPainter *painter, int byteIndex );
00088     void renderByte( QPainter *painter, int byteIndex );
00093     void renderFramedByte( QPainter *painter, int byteIndex, FrameStyle style );
00094 
00095 
00096   public: // modification access
00103     bool setSpacing( KPixelX byteSpacingWidth, int noOfGroupedBytes = 0, KPixelX groupSpacingWidth = 0 );
00108     bool setByteSpacingWidth( KPixelX byteSpacingWidth );
00113     bool setNoOfGroupedBytes( int noOfGroupedBytes );
00118     bool setGroupSpacingWidth( KPixelX groupSpacingWidth );
00122     bool setDigitWidth( KPixelX digitWidth );
00127     void setMetrics( KPixelX digitWidth, KPixelY digitBaseLine );
00129     void set( KHECore::KAbstractByteArrayModel *byteArrayModel );
00131     void resetXBuffer();
00133     void setCharCodec( KHECore::KCharCodec *charCodec );
00134 
00135     void setByteTypeColored( bool byteTypeColored );
00136 
00137 
00138   public: // functional logic
00140     KHE::KSection linePositionsOfX( KPixelX x, KPixelX width ) const;
00142     int linePositionOfX( KPixelX x ) const;
00144     int magneticLinePositionOfX( KPixelX x ) const;
00146     KPixelX xOfLinePosition( int posInLine ) const;
00148     KPixelX rightXOfLinePosition( int posInLine ) const;
00150     int linePositionOfColumnX( KPixelX x ) const;
00152     KHE::KSection linePositionsOfColumnXs( KPixelX x, KPixelX width ) const;
00154     KPixelX columnXOfLinePosition( int posInLine ) const;
00156     KPixelX columnRightXOfLinePosition( int posInLine ) const;
00158     KHE::KSection visibleLinePositions( KPixelX x, KPixelX width ) const;
00160     KPixelXs xsOfLinePositionsInclSpaces( const KHE::KSection &linePositions ) const;
00162     KPixelXs columnXsOfLinePositionsInclSpaces( const KHE::KSection &linePositions ) const;
00163 
00164   public: // value access
00165     KPixelX byteWidth() const;
00166     KPixelX digitWidth() const;
00167     KPixelX groupSpacingWidth() const;
00168     KPixelX byteSpacingWidth() const;
00169     int noOfGroupedBytes() const;
00170 
00171     int firstLinePos() const;
00172     int lastLinePos()  const;
00173     KHE::KSection visibleLinePositions() const;
00174     const ByteArrayTableLayout *layout() const;
00175     KHECore::KCharCodec *charCodec() const;
00176     bool isByteTypeColored() const;
00177 
00178 
00179   protected: // API to be redefined
00180     virtual void renderByteText( QPainter *painter, char byte, KHECore::KChar charByte, const QColor &color ) const = 0;
00182     virtual void recalcByteWidth();
00183 
00184 
00185   protected:
00186     void renderPlain( QPainter *painter, const KHE::KSection &linePositions, int byteIndex );
00187     void renderSelection( QPainter *painter, const KHE::KSection &linePositions, int byteIndex, int flag );
00188     void renderMarking( QPainter *painter, const KHE::KSection &linePositions, int byteIndex, int flag );
00189     void renderRange( QPainter *painter, const QBrush &brush, const KHE::KSection &linePositions, int flag );
00190     void renderBookmark( QPainter *painter, const QBrush &brush );
00191 
00192     void recalcX();
00193 
00194     bool isSelected( const KHE::KSection &range, KHE::KSection *selection, unsigned int *flag ) const;
00195     bool isMarked( const KHE::KSection &range, KHE::KSection *marking, unsigned int *flag ) const;
00196 
00197     void setByteWidth( int byteWidth );
00198 
00199 
00200   protected:
00202     KHECore::KAbstractByteArrayModel *mByteArrayModel;
00204     const ByteArrayTableLayout *mLayout;
00206     KDataRanges *mRanges;
00208     KHECore::Bookmarkable *mBookmarks;
00210     KHECore::KCharCodec *mCharCodec;
00211 
00213     KPixelX mDigitWidth;
00215     KPixelY mDigitBaseLine;
00216 
00217 
00218   protected:  // individual data
00220     KPixelX mByteWidth;
00222 //     KPixelX mCursorWidth;
00224     KPixelX mByteSpacingWidth;
00226     KPixelX mGroupSpacingWidth;
00227 
00229     int mNoOfGroupedBytes;
00230 
00234     KPixelX *mLinePosLeftPixelX;
00235     KPixelX *mLinePosRightPixelX;
00237     int mLastLinePos;
00238 
00240     bool mByteTypeColored;
00241 
00242 
00243   protected: // buffering rendering data
00244     KHE::KSection mRenderLinePositions;
00245     int mRenderLine;
00246     KPixelX mRenderX;
00247     KPixelX mRenderWidth;
00248     int mSpacingTrigger;
00249 };
00250 
00251 
00252 inline KPixelX AbstractByteArrayColumnRenderer::byteWidth()         const { return mByteWidth; }
00253 inline KPixelX AbstractByteArrayColumnRenderer::digitWidth()        const { return mDigitWidth; }
00254 inline KPixelX AbstractByteArrayColumnRenderer::byteSpacingWidth()  const { return mByteSpacingWidth; }
00255 inline KPixelX AbstractByteArrayColumnRenderer::groupSpacingWidth() const { return mGroupSpacingWidth; }
00256 
00257 inline int AbstractByteArrayColumnRenderer::noOfGroupedBytes()      const { return mNoOfGroupedBytes; }
00258 
00259 inline int AbstractByteArrayColumnRenderer::firstLinePos() const { return mRenderLinePositions.start(); }
00260 inline int AbstractByteArrayColumnRenderer::lastLinePos()  const { return mRenderLinePositions.end(); }
00261 inline KHE::KSection AbstractByteArrayColumnRenderer::visibleLinePositions() const { return mRenderLinePositions; }
00262 
00263 inline const ByteArrayTableLayout *AbstractByteArrayColumnRenderer::layout() const { return mLayout; }
00264 
00265 inline void AbstractByteArrayColumnRenderer::setCharCodec( KHECore::KCharCodec *charCodec ) { mCharCodec = charCodec; }
00266 inline KHECore::KCharCodec* AbstractByteArrayColumnRenderer::charCodec() const { return mCharCodec; }
00267 
00268 inline void AbstractByteArrayColumnRenderer::setByteTypeColored( bool byteTypeColored )
00269 {
00270     mByteTypeColored = byteTypeColored;
00271 }
00272 inline bool AbstractByteArrayColumnRenderer::isByteTypeColored() const { return mByteTypeColored; }
00273 
00274 inline void AbstractByteArrayColumnRenderer::setByteWidth( int byteWidth ) { mByteWidth = byteWidth; }
00275 
00276 }
00277 
00278 #endif

okteta

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

kdeutils

Skip menu "kdeutils"
  • ark
  • kcalc
  • kcharselect
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • okteta
  • printer-applet
  • superkaramba
  • sweeper
Generated for kdeutils by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal