2006-10-09 17:38:59 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wxPieCtrl.h
|
|
|
|
// Purpose: wxPieCtrl (v0.1.2)
|
|
|
|
// Author: Volodymir (T-Rex) Tryapichko
|
|
|
|
// Modified by: Frank Weiler, 10.10.2006
|
|
|
|
// Created: June-07-2005
|
|
|
|
// RCS-ID: $Id:
|
|
|
|
// Copyright: (c) Volodymir (T-Rex) Tryapichko
|
|
|
|
// Licence: wxWidgets license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _WX_PIE_CTRL
|
|
|
|
#define _WX_PIE_CTRL
|
|
|
|
|
2007-01-19 00:59:31 +00:00
|
|
|
|
2006-10-09 17:38:59 +00:00
|
|
|
#include <wx/wx.h>
|
|
|
|
#include <wx/image.h>
|
|
|
|
#include <wx/dynarray.h>
|
|
|
|
|
|
|
|
#ifndef M_PI
|
|
|
|
#define M_PI 3.14159265358979
|
|
|
|
#endif
|
|
|
|
|
2007-01-19 14:30:18 +00:00
|
|
|
#if ! wxCHECK_VERSION(2,8,0)
|
2006-10-09 17:38:59 +00:00
|
|
|
WX_DECLARE_OBJARRAY(double, wxArrayDouble);
|
2007-01-19 14:30:18 +00:00
|
|
|
#endif
|
2006-10-09 17:38:59 +00:00
|
|
|
|
|
|
|
// ========================================================================
|
|
|
|
// wxPiePart
|
|
|
|
// ------------------------------------------------------------------------
|
2007-01-10 01:01:24 +00:00
|
|
|
/// This class is used for storing data in wxPieCtrl.
|
2006-10-09 17:38:59 +00:00
|
|
|
class wxPiePart
|
|
|
|
{
|
|
|
|
double m_Value;
|
|
|
|
wxColour m_Colour;
|
|
|
|
wxString m_Label;
|
|
|
|
public:
|
|
|
|
/// Default constructor
|
|
|
|
wxPiePart();
|
|
|
|
/// Parametrized constructor
|
|
|
|
/*!
|
|
|
|
\param value used for drawing the pie. Specifies the size of the sector.
|
|
|
|
\param colour specifies the colour of the sector
|
|
|
|
\param label specifies the text to be shown in diagram legend
|
|
|
|
*/
|
|
|
|
wxPiePart(double value, wxColour colour, wxString label = wxEmptyString);
|
|
|
|
/// Copy constructor
|
2007-01-10 01:01:24 +00:00
|
|
|
wxPiePart(const wxPiePart & part);
|
2006-10-09 17:38:59 +00:00
|
|
|
/// Returns the colour of sector
|
|
|
|
wxColour GetColour() {return m_Colour;}
|
|
|
|
/// Sets the colour of sector
|
|
|
|
void SetColour(wxColour colour) {m_Colour = colour;}
|
|
|
|
/// Returns the size of sector
|
|
|
|
double GetValue() {return m_Value;}
|
|
|
|
/// Sets the size of sector
|
|
|
|
void SetValue(double value) {m_Value = fabs(value);}
|
|
|
|
/// Returns the label of sector
|
|
|
|
wxString GetLabel() {return m_Label;}
|
|
|
|
/// Sets the label of sector
|
|
|
|
void SetLabel(wxString value) {m_Label = value;}
|
2007-01-19 00:59:31 +00:00
|
|
|
//
|
2006-10-09 17:38:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
WX_DECLARE_OBJARRAY(wxPiePart, wxPieSeries);
|
|
|
|
|
|
|
|
// ========================================================================
|
|
|
|
// wxPieCtrl
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
/// The component for drawing pie diagrams
|
|
|
|
class wxPieCtrl : public wxWindow
|
|
|
|
{
|
2007-01-24 16:58:11 +00:00
|
|
|
protected:
|
|
|
|
int m_padding;
|
2006-10-09 17:38:59 +00:00
|
|
|
wxBitmap m_CanvasBitmap;
|
|
|
|
wxMemoryDC m_CanvasDC;
|
|
|
|
wxColour m_BackColour;
|
2007-01-24 16:58:11 +00:00
|
|
|
bool m_CanRepaint;
|
2007-01-10 01:01:24 +00:00
|
|
|
bool m_ShowEdges;
|
2007-01-19 00:59:31 +00:00
|
|
|
int m_lastCoveredPart;
|
2007-05-11 06:04:21 +00:00
|
|
|
// parameters affecting legend
|
|
|
|
wxFont m_TitleFont;
|
|
|
|
wxFont m_LabelFont;
|
|
|
|
bool m_LegendIsTransparent;
|
|
|
|
wxColour m_TitleColour;
|
|
|
|
wxColour m_LabelColour;
|
|
|
|
wxColour m_LegendBackColour;
|
|
|
|
unsigned int m_legendHorBorder;
|
|
|
|
unsigned int m_LegendVerBorder;
|
|
|
|
wxString m_szTitle;
|
|
|
|
|
2007-01-24 16:58:11 +00:00
|
|
|
//internal methods
|
|
|
|
void GetPartAngles(wxArrayDouble & angles);
|
2006-10-09 17:38:59 +00:00
|
|
|
void RecreateCanvas();
|
2007-01-24 16:58:11 +00:00
|
|
|
int GetCoveredPiePart(int x,int y);
|
|
|
|
void DrawParts(wxRect& pieRect);
|
2007-05-11 06:04:21 +00:00
|
|
|
void DrawLegend(int left, int top);
|
2006-10-09 17:38:59 +00:00
|
|
|
void Draw(wxPaintDC & pdc);
|
2007-08-15 10:50:59 +00:00
|
|
|
#if (defined(__WXMAC__) && wxCHECK_VERSION(2,8,2))
|
|
|
|
void DrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
|
|
|
double sa, double ea );
|
|
|
|
#endif
|
2006-10-09 17:38:59 +00:00
|
|
|
public:
|
|
|
|
/// An array of wxPiePart objects for storing information about sectors
|
|
|
|
wxPieSeries m_Series;
|
2007-01-24 16:58:11 +00:00
|
|
|
|
2006-10-09 17:38:59 +00:00
|
|
|
wxPieCtrl(wxWindow * parent, wxWindowID id = wxID_ANY, wxPoint pos = wxDefaultPosition,
|
|
|
|
wxSize sz = wxDefaultSize, long style = 0, wxString name = wxT("wxPieCtrl"));
|
2007-01-24 16:58:11 +00:00
|
|
|
|
|
|
|
wxColour GetBackColour();
|
2006-10-09 17:38:59 +00:00
|
|
|
void SetBackColour(wxColour colour);
|
2007-01-24 16:58:11 +00:00
|
|
|
|
|
|
|
bool GetShowEdges();
|
2006-10-09 17:38:59 +00:00
|
|
|
void SetShowEdges(bool value);
|
2007-01-24 16:58:11 +00:00
|
|
|
|
|
|
|
void SetPadding(int pad);
|
|
|
|
int GetPadding();
|
2006-10-09 17:38:59 +00:00
|
|
|
virtual void Refresh(bool eraseBackground = true, const wxRect* rect = NULL);
|
2007-05-11 06:04:21 +00:00
|
|
|
|
|
|
|
/// Returns transparency flag of legend box
|
|
|
|
bool IsTransparent() {return m_LegendIsTransparent;}
|
|
|
|
/// Sets transparency flag of legend box
|
|
|
|
void SetTransparent(bool value);
|
|
|
|
/// Returns the font used for displaying the labels of sectors
|
|
|
|
wxFont GetLabelFont() {return m_LabelFont;}
|
|
|
|
/// Sets the font used for displaying the labels of sectors
|
|
|
|
void SetLabelFont(wxFont font);
|
|
|
|
/// Returns the size of horizontal border of legend box
|
|
|
|
unsigned int GeHorLegendBorder() {return m_legendHorBorder;}
|
|
|
|
/// Returns the size of vertical border of legend box
|
|
|
|
unsigned int GetVerLegendBorder() {return m_LegendVerBorder;}
|
|
|
|
/// Sets the size of horizontal border of legend box
|
|
|
|
void SetHorLegendBorder(unsigned int value);
|
|
|
|
/// Sets the size of vertical border of legend box
|
|
|
|
void SetVerLegendBorder(unsigned int value);
|
|
|
|
/// Returns the colour used for displaying the labels of sectors
|
|
|
|
wxColour GetLabelColour() {return m_LabelColour;}
|
|
|
|
/// Sets the colour used for displaying the labels of sectors
|
|
|
|
void SetLabelColour(wxColour colour);
|
|
|
|
/// Returns the colour used for displaying lagend box background
|
|
|
|
wxColour GetLegendBackColour() {return m_LegendBackColour;}
|
|
|
|
/// Sets the colour used for displaying legend box background
|
|
|
|
void SetLegendBackColour(wxColour colour);
|
|
|
|
|
|
|
|
void SetLabel(const wxString& label);
|
2007-01-24 16:58:11 +00:00
|
|
|
|
2006-10-09 17:38:59 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
void OnPaint(wxPaintEvent & event);
|
2007-01-10 01:01:24 +00:00
|
|
|
void OnSize(wxSizeEvent & event);
|
2007-01-19 00:59:31 +00:00
|
|
|
void OnMouseMove(wxMouseEvent& ev);
|
2007-01-24 16:58:11 +00:00
|
|
|
void OnEraseBackground(wxEraseEvent & /*event*/);
|
2006-10-09 17:38:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|