home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WGAUGE.HPP < prev    next >
C/C++ Source or Header  |  1996-11-29  |  4KB  |  148 lines

  1. #ifndef _WGAUGE_HPP_INCLUDED
  2. #define _WGAUGE_HPP_INCLUDED
  3.  
  4. #ifndef _WCONTROL_HPP_INCLUDED
  5. #  include "wcontrol.hpp"
  6. #endif
  7.  
  8. /*************************************************************************
  9.  *
  10.  * WGauge -- Wrapper for the Gauge control.
  11.  *
  12.  *   Events:
  13.  *
  14.  *       Change --
  15.  *
  16.  ************************************************************************/
  17.  
  18. #include <math.h>
  19.  
  20. #define X_OFFSET_DEFAULT                5
  21. #define Y_OFFSET_DEFAULT                5
  22. #define PI                              3.141592653589793
  23.  
  24. enum WGaugeType {
  25.     WGT_HorizontalBar,
  26.     WGT_VerticalBar,
  27.     WGT_SemiCircle,
  28.     WGT_SemiPie,
  29.     WGT_Pie,
  30.     WGT_Text
  31. };
  32.  
  33. enum WGBorderType {
  34.     WGBT_None,
  35.     WGBT_Single
  36. };
  37.  
  38. struct WGaugeChangeEventData : public WEventData {
  39.     WUShort        oldPosition;      
  40.     WUShort        newPosition;
  41. };
  42.  
  43. class WCMCLASS WGauge :public WControl
  44. {
  45.         /**************************************************************
  46.          * Constructors and destructors
  47.          **************************************************************/
  48.     public:
  49.         WGauge();
  50.         ~WGauge();
  51.  
  52.         /**************************************************************
  53.          * Properties
  54.          **************************************************************/
  55.  
  56.         // BorderType
  57.  
  58.         WGBorderType GetBorderType() const;
  59.         WBool SetBorderType( WGBorderType borderType, WBool repaint=TRUE );
  60.  
  61.         // FillColor
  62.  
  63.         WColor GetFillColor() const;
  64.         WBool SetFillColor( const WColor & fillColor, WBool repaint=TRUE );
  65.  
  66.         // HorizontalMargin
  67.  
  68.         WUShort GetHorizontalMargin() const;
  69.         WBool SetHorizontalMargin( WUShort val );
  70.  
  71.         // Maximum
  72.  
  73.         WUShort GetMaximum() const;
  74.         WBool SetMaximum( WUShort max );
  75.  
  76.         // Minimum
  77.  
  78.         WUShort GetMinimum() const;
  79.         WBool SetMinimum( WUShort min );
  80.  
  81.         // Position
  82.  
  83.         WUShort GetPosition() const;
  84.         WBool SetPosition( WUShort position );
  85.  
  86.         // ShowPercent
  87.  
  88.         WBool GetShowPercent() const;
  89.         WBool SetShowPercent( WBool showPercent, WBool repaint=TRUE );
  90.  
  91.         // Type
  92.  
  93.         WGaugeType GetType() const;
  94.         WBool SetType( WGaugeType type );
  95.  
  96.         // VerticalMargin
  97.  
  98.         WUShort GetVerticalMargin() const;
  99.         WBool SetVerticalMargin( WUShort val );
  100.  
  101.         /**************************************************************
  102.          * Methods
  103.          **************************************************************/
  104.  
  105.         /**************************************************************
  106.          * Overrides
  107.          **************************************************************/
  108.  
  109.         virtual WStyle GetDefaultStyle() const;
  110.  
  111.         /**************************************************************
  112.          * Event Handlers
  113.          **************************************************************/
  114.  
  115.         WBool ResizeEventHandler( WWindow *window, WResizeEventData *event );
  116.  
  117.     protected:
  118.         WBool PaintEventHandler( WWindow *window, WPaintEventData *event );
  119.  
  120.         /**************************************************************
  121.          * Others
  122.          **************************************************************/
  123.  
  124.     private:
  125.         void DrawSemiCircle( WDouble pct, WCanvas *canvas, WRect rect,
  126.                              WFont font );
  127.  
  128.         void DrawFullCircle( WDouble pct, WCanvas *canvas, WRect rect,
  129.                              WFont font );
  130.  
  131.         /**************************************************************
  132.          * Data Members
  133.          **************************************************************/
  134.  
  135.     private:
  136.         WUShort             _min;
  137.         WUShort             _max;
  138.         WUShort             _pos;
  139.         WUShort             _horizMargin;
  140.         WUShort             _vertMargin;
  141.         WGaugeType          _type;
  142.         WGBorderType        _border;
  143.         WBool               _showText;
  144.         WColor              _fillColor;
  145. };
  146.  
  147. #endif
  148.