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 / KDChartEnums.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-30  |  12.3 KB  |  306 lines

  1. /* -*- Mode: C++ -*-
  2.    KDChart - a multi-platform charting engine
  3.    */
  4.  
  5. /****************************************************************************
  6.  ** Copyright (C) 2001-2003 Klar├ñlvdalens Datakonsult AB.  All rights reserved.
  7.  **
  8.  ** This file is part of the KDChart library.
  9.  **
  10.  ** This file may be distributed and/or modified under the terms of the
  11.  ** GNU General Public License version 2 as published by the Free Software
  12.  ** Foundation and appearing in the file LICENSE.GPL included in the
  13.  ** packaging of this file.
  14.  **
  15.  ** Licensees holding valid commercial KDChart licenses may use this file in
  16.  ** accordance with the KDChart Commercial License Agreement provided with
  17.  ** the Software.
  18.  **
  19.  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20.  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21.  **
  22.  ** See http://www.klaralvdalens-datakonsult.se/?page=products for
  23.  **   information about KDChart Commercial License Agreements.
  24.  **
  25.  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
  26.  ** licensing are not clear to you.
  27.  **
  28.  **********************************************************************/
  29. #ifndef __KDCHARTENUMS_H__
  30. #define __KDCHARTENUMS_H__
  31.  
  32. #include <qrect.h>
  33. #include <qpointarray.h>
  34.  
  35. #include "KDChartGlobal.h"
  36. #include <qobject.h>
  37.  
  38. /** \file KDChartEnums.h
  39.   \brief Definition of global enums.
  40.   */
  41.  
  42. /**
  43.   Project global class providing some enums needed both by KDChartParams
  44.   and by KDChartCustomBox.
  45.   */
  46. class KDCHART_EXPORT KDChartEnums :public QObject
  47. {
  48.     Q_OBJECT
  49.     Q_ENUMS( TextLayoutPolicy )
  50.     Q_ENUMS( AreaName )
  51.     Q_ENUMS( PositionFlag )
  52.  
  53. public:
  54.     /**
  55.       Text layout policy: what to do if text that is to be drawn would
  56.       cover neighboring text or neighboring areas.
  57.  
  58.       \li \c LayoutJustOverwrite Just ignore the layout collision and write the text nevertheless.
  59.       \li \c LayoutPolicyRotate Try counter-clockwise rotation to make the text fit into the space.
  60.       \li \c LayoutPolicyShiftVertically Shift the text baseline upwards (or downwards, resp.) and draw a connector line between the text and its anchor.
  61.       \li \c LayoutPolicyShiftHorizontally Shift the text baseline to the left (or to the right, resp.) and draw a connector line between the text and its anchor.
  62.       \li \c LayoutPolicyShrinkFontSize Reduce the text font size.
  63.  
  64.       \sa KDChartParams::setPrintDataValues
  65.       */
  66.     enum TextLayoutPolicy { LayoutJustOverwrite,
  67.         LayoutPolicyRotate,
  68.         LayoutPolicyShiftVertically,
  69.         LayoutPolicyShiftHorizontally,
  70.         LayoutPolicyShrinkFontSize };
  71.  
  72.     /**
  73.       Converts the specified text layout policy enum to a
  74.       string representation.
  75.  
  76.       \param type the text layout policy to convert
  77.       \return the string representation of the text layout policy enum
  78.       */
  79.     static QString layoutPolicyToString( TextLayoutPolicy type ) {
  80.         switch( type ) {
  81.             case LayoutJustOverwrite:
  82.                 return "JustOverwrite";
  83.             case LayoutPolicyRotate:
  84.                 return "Rotate";
  85.             case LayoutPolicyShiftVertically:
  86.                 return "ShiftVertically";
  87.             case LayoutPolicyShiftHorizontally:
  88.                 return "ShiftHorizontally";
  89.             case LayoutPolicyShrinkFontSize:
  90.                 return "ShrinkFontSize";
  91.             default: // should not happen
  92.                 qDebug( "Unknown text layout policy" );
  93.                 return "JustOverwrite";
  94.         }
  95.     }
  96.  
  97.  
  98.     /**
  99.       Number notation specifies the general way, how a number is to be shown.
  100.  
  101.       \li \c NumberNotationDecimal Traditional way of writing a decimal number.
  102.       \li \c NumberNotationScientific Exponential notation, with exactly one non-zero digit to the left of the decimal.
  103.       \li \c NumberNotationScientificBig Same as \c NumberNotationScientific, but using 'E' instead of 'e'.
  104.  
  105.       \sa KDChartAxisParams::setAxisLabelsNotation
  106.       */
  107.     enum NumberNotation { NumberNotationDecimal,
  108.                           NumberNotationScientific,
  109.                           NumberNotationScientificBig };
  110.  
  111.     /**
  112.       Converts the specified number notation enum to a
  113.       string representation.
  114.  
  115.       \param notation the number notation to convert
  116.       \return the string representation of the number notation enum
  117.       */
  118.     static QString numberNotationToString( NumberNotation notation ) {
  119.         switch( notation ) {
  120.             case NumberNotationDecimal:
  121.                 return "NumberNotationDecimal";
  122.             case NumberNotationScientific:
  123.                 return "NumberNotationScientific";
  124.             case NumberNotationScientificBig:
  125.                 return "NumberNotationScientificBig";
  126.             default: // should not happen
  127.                 qDebug( "Unknown text number notation" );
  128.                 return "NumberNotationDecimal";
  129.         }
  130.     }
  131.  
  132.  
  133.     /**
  134.       Converts the specified string to a number notation enum value.
  135.  
  136.       \param string the string to convert
  137.       \return the number notation enum value
  138.       */
  139.     static NumberNotation stringToNumberNotation( const QString& notation ) {
  140.         if( notation ==      "NumberNotationDecimal" )
  141.             return NumberNotationDecimal;
  142.         else if( notation == "NumberNotationScientific" )
  143.             return NumberNotationScientific;
  144.         else if( notation == "NumberNotationScientificBig" )
  145.             return NumberNotationScientificBig;
  146.         else // default, should not happen
  147.             return NumberNotationDecimal;
  148.     }
  149.  
  150.  
  151.     /**
  152.       Converts the specified string to a text layout policy enum value.
  153.  
  154.       \param string the string to convert
  155.       \return the text layout policy enum value
  156.       */
  157.     static TextLayoutPolicy stringToLayoutPolicy( const QString& string ) {
  158.         if( string ==      "JustOverwrite" )
  159.             return LayoutJustOverwrite;
  160.         else if( string == "Rotate" )
  161.             return LayoutPolicyRotate;
  162.         else if( string == "ShiftVertically" )
  163.             return LayoutPolicyShiftVertically;
  164.         else if( string == "ShiftHorizontally" )
  165.             return LayoutPolicyShiftHorizontally;
  166.         else if( string == "ShrinkFontSize" )
  167.             return LayoutPolicyShrinkFontSize;
  168.         else // default, should not happen
  169.             return LayoutJustOverwrite;
  170.     }
  171.  
  172.     /**
  173.       Areas of the chart that may have their own backgrounds
  174.       and/or may be surrounded by a simple or complex border.
  175.  
  176.       \li \c AreaData surrounding the data area
  177.       \li \c AreaAxes surrounding the axes but leaving out the data area
  178.       \li \c AreaDataAxes surrounding the data+axes area
  179.       \li \c AreaLegend surrounding the legend area
  180.       \li \c AreaDataAxesLegend surrounding the data+axes+legend area
  181.       \li \c AreaHeaders surrounding the headers area
  182.       \li \c AreaFooters surrounding the footers area
  183.       \li \c AreaDataAxesLegendHeadersFooters surrounding the data+axes+legend+headers+footers area
  184.       \li \c AreaInnermost covering the complete drawing area but <b>not</b> covering the global left/top/right/bottom leading
  185.       \li \c AreaOutermost covering the complete drawing area including the global left/top/right/bottom leading
  186.  
  187.       \li \c AreaChartDataRegion covering the area used to display one data entry (i.e. one point, bar, line, pie slice,...).
  188.       The respective data coordinates are specified by additional parameters, this is used by
  189.       KDChartCustomBox where you have the parameters \c dataRow, \c dataCol, \c data3rd.
  190.  
  191.       In addition there is a special value specifying a <b>list</b> of regions:
  192.  
  193.       \li \c AreasCustomBoxes specifies many small areas surrounding all the custom boxes that you might have added to the chart,
  194.       this is useful in case you want to specify some default frame settings to be used for all custom boxes
  195.       not having frame settings of their own.
  196.  
  197.       Finally there are three special values that you may use to specify
  198.       a single axis area (or a header/footer area, or a custom box area resp.).
  199.       Just add the number of the axis (or header/footer, or custom box resp.)
  200.       to the respective base value:
  201.  
  202.       \li \c AreaAxisBASE value to be added to the axis number in case you want to specify a single axis area,
  203.       e.g. for specifying the area of the left ordinate axis just type <b>AreaAxisBASE + AxisPosLeft</b>.
  204.       \li \c AreaHdFtBASE value to be added to the header/footer number in case you want to specify a single header (or footer, resp.) area,
  205.       e.g. for specifying the area of the main header just type <b>AreaHdFtBASE + HdFtPosHeader</b>.
  206.       \li \c AreaCustomBoxBASE value to be added to the number of a custom box that you might have added to your chart,
  207.       e.g. for specifying the area a custom box you have added to the chart
  208.       (let us assume the index of that box is in \c boxIdx1) just type <b>AreaCustBoxBASE + boxIdx1</b>.
  209.  
  210.       \sa KDChartParams::setSimpleFrame, KDChartParams::setFrame
  211.       \sa KDChartParams::insertCustomBox, KDChartCustomBox
  212.       */
  213.     enum AreaName { AreaUNKNOWN                      = 0x0000,
  214.         AreaData                         = 0x0001,
  215.         AreaAxes                         = 0x0002,
  216.         AreaDataAxes                     = 0x0003,
  217.         AreaLegend                       = 0x0004,
  218.         AreaDataAxesLegend               = 0x0005,
  219.         AreaHeaders                      = 0x0006,
  220.         AreaFooters                      = 0x0007,
  221.         AreaDataAxesLegendHeadersFooters = 0x0008,
  222.         AreaInnermost                    = 0x0009,
  223.         AreaOutermost                    = 0x000a,
  224.         AreaChartDataRegion              = 0x000b,
  225.         AreasCustomBoxes                 = 0x000d,
  226.         AreaAxisBASE                     = 0x1000,
  227.         AreaHdFtBASE                     = 0x2000,
  228.         AreaCustomBoxesBASE              = 0x4000,
  229.         AreaBASEMask                     = 0xF000 };
  230.  
  231.  
  232.     /**
  233.       The general position flag to specify a point of
  234.       an area, for example this could be the anchor point
  235.       which an annotation box should be aligned to.
  236.  
  237.       The following picture shows the different positions:
  238.  
  239.       \image html "../refman_images/positions.png"
  240.       \image latex "../refman_images/positions.png" "the PositionFlag enum" width=4in
  241.  
  242.       \note The position and alignment of content to be printed at (or
  243.       inside of, resp.) an area or a point -- like for printing data value texts next
  244.       to their graphical representations (which might be a bar, line, pie slice,...) --
  245.       is specified by two parameters: a \c PositionFlag and a uint holding a combination of \c Qt::AlignmentFlags.
  246.       Remember that Qt::AlignmentFlags are used to specify <b>with which edge</b> something
  247.       is to be aligned to its anchor, e.g. \c AlignLeft means align with the left edge.
  248.  
  249.       The position of content and the way it is aligned to this
  250.       position is shown in the following drawing, note that annotation #2 and annotation #3
  251.       share the same PositionFlag but have different alignment flags set:
  252.  
  253.       \image html "../refman_images/alignment.png"
  254.       \image latex "../refman_images/alignment.png" "positioning and aligning" width=4in
  255.  
  256.       \sa KDChartParams::setPrintDataValues
  257.     */
  258.     enum PositionFlag { PosTopLeft   =0, PosTopCenter   =1, PosTopRight   =2,
  259.         PosCenterLeft=3, PosCenter      =4, PosCenterRight=5,
  260.         PosBottomLeft=6, PosBottomCenter=7, PosBottomRight=8 };
  261.  
  262.  
  263.     /**
  264.       Returns the point representing a position of a rectangle.
  265.       */
  266.     static QPoint positionFlagToPoint( const QRect& rect,
  267.                                       PositionFlag pos );
  268.  
  269.     /**
  270.       Returns the point representing a position of a corresponding
  271.       QPointArray.
  272.  
  273.       \note The array \c points <b>must</b> have at least nine elements.
  274.       */
  275.     static QPoint positionFlagToPoint( const QPointArray& points,
  276.             PositionFlag pos )
  277.     {
  278.         QPoint pt;
  279.         if( 9 <= points.size() )
  280.             pt = points[ pos ];
  281.         return pt;
  282.     }
  283.  
  284.  
  285.     /**
  286.       Converts the specified content position enum to a
  287.       string representation.
  288.  
  289.       \param type the content position to convert
  290.       \return the string representation of the type enum
  291.       */
  292.     static QString positionFlagToString( PositionFlag type );
  293.  
  294.  
  295.     /**
  296.       Converts the specified string to a content position enum value.
  297.  
  298.       \param string the string to convert
  299.       \return the content position enum value
  300.       */
  301.     static PositionFlag stringToPositionFlag( const QString& string );
  302. };
  303.  
  304.  
  305. #endif
  306.