home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / IOC / LANCELOT / LTIMEPIE.HPP < prev    next >
C/C++ Source or Header  |  1995-04-01  |  8KB  |  183 lines

  1. /******************************************************************************
  2. * FILE NAME: ltimepie.hpp                                                     *
  3. *                                                                             *
  4. * DESCRIPTION: Timecard pie chart                                             *
  5. *                                                                             *
  6. * Classes:                                                                    *
  7. *   LTimeCardPieChart                                                         *
  8. *   LPieChartResizeHandler                                                    *
  9. *   TaskElement                                                               *
  10. *                                                                             *
  11. * COPYRIGHT:                                                                  *
  12. *   Licensed Materials - Property of IBM                                      *
  13. *   (C) Copyright IBM Corporation 1992, 1995                                  *
  14. *   All Rights Reserved                                                       *
  15. *   US Government Users Restricted Rights - Use, duplication, or disclosure   *
  16. *   restricted by GSA ADP Schedule Contract with IBM Corp.                    *
  17. *                                                                             *
  18. ******************************************************************************/
  19. #include "ltimec.hpp"
  20. #ifndef _LTIMEPIE_
  21. #define _LTIMEPIE_
  22.  
  23. #include <igpie.hpp>
  24. #include <igrect.hpp>
  25. #include <igstring.hpp>
  26. #include <imcelcv.hpp>
  27. #include <iglist.hpp>
  28. #include <idrawcv.hpp>
  29. #include <isizehdr.hpp>
  30. #include <ikeyset.h>
  31. #include <istring.hpp>
  32. #include <ifont.hpp>
  33. #include "lancelot.h"
  34.  
  35. class LTimeCardPieChart;
  36.  
  37. /******************************************************************************
  38. * Class TaskElement - Collection element with task name and hours.            *
  39. ******************************************************************************/
  40. class TaskElement : public IBase
  41. {
  42.    public:
  43. /*------------------------ Constructors/Destructor ----------------------------
  44. | Construct the object in only one way:                                       |
  45. | 1) Task name and hours worked for the task.                                 |
  46. -----------------------------------------------------------------------------*/
  47.       TaskElement( IString theTask, unsigned short theHours ) 
  48.            :aTask( theTask ), aHours( theHours ) {};
  49.  
  50. /*------------------------------- Accessors -----------------------------------
  51. | These functions provide a means of getting and setting the accessible       |
  52. | attributes of instances of this class:                                      |
  53. |   task                - Returns the task name                               |
  54. |   hours               - Returns the task hours                              |
  55. -----------------------------------------------------------------------------*/
  56.       IString const 
  57.          &task() const { return aTask; };
  58.  
  59.       unsigned short const 
  60.          &hours() const { return aHours; };
  61.  
  62. /*------------------------------- Operators -----------------------------------
  63. | Arithmetic and comparative operations for instances of this class:          |
  64. |   ==                  - Compares two TaskElements for equality              |
  65. -----------------------------------------------------------------------------*/
  66.       Boolean 
  67.          operator == (TaskElement const& k) const { return aTask == k.aTask; };
  68.  
  69.    private:
  70.       IString 
  71.          aTask;
  72.  
  73.       unsigned short 
  74.          aHours;
  75. };
  76. /*------------------------------- Accessors -----------------------------------
  77. | These functions provide a means of getting and setting the accessible       |
  78. | attributes of instances of this class:                                      |
  79. |   key                 - Defines and returns the key for a TaskElement       |
  80. -----------------------------------------------------------------------------*/
  81. inline IString const
  82.    &key( TaskElement const& k ) { return k.task(); };
  83.  
  84. typedef 
  85.    IKeySet< TaskElement, IString > TaskSet;
  86.  
  87.  
  88. /******************************************************************************
  89. * Class LPieChartResizeHandler - Handle resize events for the pie chart.      *
  90. ******************************************************************************/
  91. class LPieChartResizeHandler : public IResizeHandler
  92. {
  93.    public:
  94. /*------------------------ Constructors/Destructor ----------------------------
  95. | Construct the object in only one way:                                       |
  96. | 1) LTimeCardPieChart                                                        |
  97. -----------------------------------------------------------------------------*/
  98.       LPieChartResizeHandler( LTimeCardPieChart* pie );
  99.  
  100.       virtual ~LPieChartResizeHandler();
  101.  
  102. /*----------------------------- Event Processing ------------------------------
  103. | Handle and process events:                                                  |
  104. |   windowResize        - Process resize events.                              |
  105. -----------------------------------------------------------------------------*/
  106.    protected:
  107.       virtual Boolean
  108.          windowResize( IResizeEvent& event );
  109.  
  110.    private:
  111.       LTimeCardPieChart
  112.         *ppieChart;
  113. };
  114.  
  115.  
  116. /******************************************************************************
  117. * Class LTimeCardPieChart - Timecard pie chart class.                         *
  118. ******************************************************************************/
  119. class LTimeCardPieChart : public IDrawingCanvas
  120. {
  121.    public:
  122. /*------------------------ Constructors/Destructor ----------------------------
  123. | Construct the object in only one way:                                       |
  124. | 1) ResourceId, parent, owner, location, and LTimeCardData.                  |
  125. -----------------------------------------------------------------------------*/
  126.       LTimeCardPieChart( unsigned long windoId,
  127.                          IWindow* parent, IWindow* owner,
  128.                          const IRectangle& location = IRectangle(),
  129.                          LTimeCardData* pTimeData = NULL );
  130.  
  131.      ~LTimeCardPieChart();
  132.  
  133. /*------------------------------- Actions -------------------------------------
  134. | Actions for instances of this class:                                        |
  135. |   resizePieChart      - Resize the pie chart and legend.                    |
  136. |   refreshData         - Refresh the timecard data.                          |
  137. |   drawPie             - Draw the pie chart and legend.                      |
  138. |   calculatePieData    - Pie chart and legend calculations.                  |
  139. -----------------------------------------------------------------------------*/
  140.       LTimeCardPieChart
  141.         &resizePieChart( const ISize& size );
  142.  
  143.       LTimeCardPieChart
  144.         &refreshData( LTimeCardData * tcp ) { pTimeCardData = tcp; return *this; };
  145.  
  146.       LTimeCardPieChart
  147.         &drawPie(),
  148.         &calculatePieData();
  149.  
  150.    private:
  151.       LTimeCardData
  152.         *pTimeCardData;
  153.  
  154.       IGList
  155.          graphList;
  156.  
  157.       LPieChartResizeHandler
  158.          pieChartResizeHandler;
  159.  
  160.       IFont
  161.          legendFont;
  162.  
  163.       IGPie
  164.         *ppieSlice[ ID_TIMECARD_ENTRIES ];
  165.  
  166.       IGRectangle
  167.         *ppieLegendKey[ ID_TIMECARD_ENTRIES ];
  168.  
  169.       IGString
  170.         *ppieLegendKeyText[ ID_TIMECARD_ENTRIES ];
  171.  
  172.       unsigned short
  173.          numberSlices,
  174.          totalHours;
  175.  
  176.       TaskSet
  177.          tasks;
  178.  
  179.       TaskSet::Cursor
  180.          tasksCursor;
  181. };
  182. #endif
  183.