home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / khexedit / valuecolumninterface.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  5.3 KB  |  171 lines

  1. /***************************************************************************
  2.                           valuecolumninterface.h  -  description
  3.                              -------------------
  4.     begin                : Fri Sep 12 2003
  5.     copyright            : (C) 2003 by Friedrich W. H. Kossebau
  6.     email                : Friedrich.W.H@Kossebau.de
  7.  ***************************************************************************/
  8.  
  9. /***************************************************************************
  10.  *                                                                         *
  11.  *   This library is free software; you can redistribute it and/or         *
  12.  *   modify it under the terms of the GNU Library General Public           *
  13.  *   License version 2 as published by the Free Software Foundation.       *
  14.  *                                                                         *
  15.  ***************************************************************************/
  16.  
  17.  
  18. #ifndef VALUECOLUMNINTERFACE_H
  19. #define VALUECOLUMNINTERFACE_H
  20.  
  21. namespace KHE
  22. {
  23.  
  24. /**
  25.  *  Interface for the value displaying column of a hexedit widget
  26.  *
  27.  * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de>
  28.  * @see createBytesEditWidget(), valueColumnInterface()
  29.  * @since 3.2
  30.  */
  31.  
  32. class ValueColumnInterface
  33. {
  34.   public:
  35.     /** collection of ids for the different numeric codings of a byte */
  36.     enum KCoding
  37.     {
  38.       /** hexadecimal encoding */
  39.       HexadecimalCoding=0,
  40.       /** decimal encoding */
  41.       DecimalCoding=1,
  42.       /** octal encoding */
  43.       OctalCoding=2,
  44.       /** bit by bit coding */
  45.       BinaryCoding=3,
  46.       /** @internal enables extension without breaking binary compatibility */
  47.       MaxCodingId=0xFFFF
  48.     };
  49.  
  50.     /** collection of ids for the fitting of the layout into the available widget's width */
  51.     enum KResizeStyle
  52.     {
  53.       /** we don't care about the actual sizing of the widget
  54.         * but stick to the given NoOfBytesPerLine
  55.         */
  56.       NoResize=0,
  57.       /** we try to fit the layout to the available width
  58.         * but only with full groups like set in NoOfGroupedBytes
  59.         * with minimum of one full group
  60.         */
  61.       LockGrouping=1,
  62.       /** we try to fit as many bytes into the width as possible, with minimum of 1 byte
  63.         */
  64.       FullSizeUsage=2,
  65.       /** @internal enables extension without breaking binary compatibility */
  66.       MaxResizeStyleId=0xFF
  67.     };
  68.  
  69.  
  70.   public: // get methods
  71.     /** @return the current resize style
  72.       * @see setResizeStyle()
  73.       */
  74.     virtual KResizeStyle resizeStyle() const = 0;
  75.     /** @return the current number of bytes per line
  76.       * @see setNoOfBytesPerLine()
  77.       */
  78.     virtual int noOfBytesPerLine()     const = 0;
  79.  
  80.     /** @return the current coding
  81.       * @see setCoding()
  82.       */
  83.     virtual KCoding coding()        const = 0;
  84.     /** @return the spacing between bytes (in pixels)
  85.       * @see setByteSpacingWidth()
  86.       */
  87.     virtual int byteSpacingWidth()  const = 0;
  88.  
  89.     /** @return the current number of bytes per group
  90.       * @see setNoOfGroupedBytes()
  91.       */
  92.     virtual int noOfGroupedBytes()  const = 0;
  93.     /** @return the spacing between groups of bytes (in pixels)
  94.       * @see setGroupSpacingWidth()
  95.       */
  96.     virtual int groupSpacingWidth() const = 0;
  97.  
  98.     /** @return the gap in the middle of a binary (in pixels) 
  99.       * @see setBinaryGapWidth()
  100.     */
  101.     virtual int binaryGapWidth()    const = 0;
  102.  
  103.  
  104.   public: // set methods
  105.     /** sets the resize style for the hex column.
  106.       * Default is @c FullSizeUsage
  107.       * @param Style new style
  108.       * @see resizeStyle()
  109.       */
  110.     virtual void setResizeStyle( KResizeStyle Style ) = 0;
  111.     /** sets the number of bytes per line, switching the resize style to @c NoResize
  112.       * Default is 16.
  113.       * @param NoCpL new number of bytes per line
  114.       * @see noOfBytesPerLine()
  115.       */
  116.     virtual void setNoOfBytesPerLine( int NoCpL ) = 0;
  117.  
  118.     /** sets the format of the hex column.
  119.       * If the coding is not available the format will not be changed.
  120.       * Default is @c HexadecimalCoding.
  121.       * @param C
  122.       * @see coding()
  123.       */
  124.     virtual void setCoding( KCoding C ) = 0;
  125.     /** sets the spacing between the bytes.
  126.       * Default is 3.
  127.       * @param BSW new spacing between bytes (in pixels)
  128.       * @see byteSpacingWidth()
  129.       */
  130.     virtual void setByteSpacingWidth( int BSW ) = 0;
  131.  
  132.     /** sets the numbers of grouped bytes, 0 means no grouping.
  133.       * Default is 4.
  134.       * @param NoGB new number of bytes per group
  135.       * @see noOfGroupedBytes()
  136.       */
  137.     virtual void setNoOfGroupedBytes( int NoGB ) = 0;
  138.     /** sets the spacing between the groups.
  139.       * Default is 9.
  140.       * @param GSW new spacing width (in pixels)
  141.       * @see groupSpacingWidth()
  142.       */
  143.     virtual void setGroupSpacingWidth( int GSW ) = 0;
  144.  
  145.     /** sets the spacing in the middle of a binary encoded byte.
  146.       * Default is 1.
  147.       * @param BGW spacing in the middle of a binary (in pixels)
  148.       * @see binaryGapWidth()
  149.       */
  150.     virtual void setBinaryGapWidth( int BGW ) = 0;
  151. };
  152.  
  153.  
  154. /** tries to get the valuecolumn interface of t 
  155.   * @return a pointer to the interface, otherwise 0
  156.   * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de>
  157.   * @since 3.2
  158. */
  159. template<class T>
  160. ValueColumnInterface *valueColumnInterface( T *t )
  161. {
  162.   if( !t )
  163.     return 0;
  164.  
  165.   return static_cast<ValueColumnInterface*>( t->qt_cast("KHE::ValueColumnInterface") );
  166. }
  167.  
  168. }
  169.  
  170. #endif
  171.