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);
|
|
|
|
|
|
|
|
class wxPieCtrl;
|
|
|
|
|
|
|
|
// ========================================================================
|
|
|
|
// wxPieCtrlLegend
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
/// The component draws a rectangle and outputs text information for
|
|
|
|
/// each sector of pie diagram
|
|
|
|
class wxPieCtrlLegend : public wxWindow
|
|
|
|
{
|
|
|
|
wxFont m_TitleFont;
|
|
|
|
wxFont m_LabelFont;
|
|
|
|
bool m_IsTransparent;
|
|
|
|
wxColour m_TitleColour;
|
2007-01-10 01:01:24 +00:00
|
|
|
wxColour m_LabelColour;
|
|
|
|
wxColour m_BackColour;
|
2006-10-09 17:38:59 +00:00
|
|
|
wxBitmap m_Background;
|
|
|
|
wxMemoryDC m_BackgroundDC;
|
|
|
|
unsigned int m_HorBorder;
|
2007-01-10 01:01:24 +00:00
|
|
|
unsigned int m_VerBorder;
|
|
|
|
wxString m_szTitle;
|
|
|
|
|
2006-10-09 17:38:59 +00:00
|
|
|
protected:
|
|
|
|
void RecreateBackground(wxMemoryDC & parentdc);
|
|
|
|
public:
|
|
|
|
/// Constructor
|
|
|
|
/*!
|
|
|
|
\param parent Pointer to a parent window
|
|
|
|
\param title Legend window title
|
|
|
|
\param pos Legend window position
|
|
|
|
\param sz Legend window size
|
|
|
|
\param style Window style
|
|
|
|
*/
|
2007-01-10 01:01:24 +00:00
|
|
|
wxPieCtrlLegend(wxPieCtrl * parent, wxString title = wxEmptyString,
|
2006-10-09 17:38:59 +00:00
|
|
|
wxPoint pos = wxPoint(10,10), wxSize sz = wxDefaultSize,
|
|
|
|
long style = 0);
|
|
|
|
/// Returns transparency flag of legend window
|
|
|
|
bool IsTransparent() {return m_IsTransparent;}
|
|
|
|
/// Sets transparency flag of legend window
|
2007-01-10 01:01:24 +00:00
|
|
|
void SetTransparent(bool value);
|
2006-10-09 17:38:59 +00:00
|
|
|
/// 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 window
|
|
|
|
unsigned int GetHorBorder() {return m_HorBorder;}
|
|
|
|
/// Returns the size of vertical border of legend window
|
|
|
|
unsigned int GetVerBorder() {return m_VerBorder;}
|
|
|
|
/// Sets the size of horizontal border of legend window
|
|
|
|
void SetHorBorder(unsigned int value);
|
|
|
|
/// Sets the size of vertical border of legend window
|
|
|
|
void SetVerBorder(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 window background
|
|
|
|
wxColour GetBackColour() {return m_BackColour;}
|
|
|
|
/// Sets the colour used for displaying legend window background
|
|
|
|
void SetBackColour(wxColour colour);
|
|
|
|
|
2007-01-10 01:01:24 +00:00
|
|
|
void SetLabel(const wxString& label);
|
|
|
|
|
2006-10-09 17:38:59 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
void OnPaint(wxPaintEvent & event);
|
|
|
|
void OnEraseBackground(wxEraseEvent & event);
|
|
|
|
friend class wxPieCtrl;
|
|
|
|
};
|
|
|
|
// ========================================================================
|
|
|
|
// wxPieCtrl
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
/// The component for drawing pie diagrams
|
|
|
|
class wxPieCtrl : public wxWindow
|
|
|
|
{
|
|
|
|
double m_Angle;
|
|
|
|
double m_RotationAngle;
|
|
|
|
int m_Height;
|
2007-01-10 01:01:24 +00:00
|
|
|
wxArrayDouble m_Values;
|
2006-10-09 17:38:59 +00:00
|
|
|
wxBitmap m_Background;
|
|
|
|
wxBitmap m_CanvasBitmap;
|
|
|
|
wxMemoryDC m_CanvasDC;
|
|
|
|
wxColour m_BackColour;
|
|
|
|
wxPieCtrlLegend * m_Legend;
|
2007-01-10 01:01:24 +00:00
|
|
|
bool m_ShowEdges;
|
2007-01-19 00:59:31 +00:00
|
|
|
int m_lastCoveredPart;
|
2007-01-10 01:01:24 +00:00
|
|
|
void GetPartAngles(wxArrayDouble & angles);
|
2006-10-12 12:52:19 +00:00
|
|
|
#if defined(__WXMSW__) || defined(__WXMAC__)
|
2006-10-09 17:38:59 +00:00
|
|
|
void DrawParts(wxMemoryDC & dc, int cx, int cy, int w, int h);
|
|
|
|
#endif
|
|
|
|
void RecreateCanvas();
|
|
|
|
protected:
|
|
|
|
bool m_CanRepaint;
|
2006-10-12 12:52:19 +00:00
|
|
|
bool m_bPaint3D;
|
|
|
|
bool m_bDrawCircle;
|
2006-10-09 17:38:59 +00:00
|
|
|
void Draw(wxPaintDC & pdc);
|
|
|
|
public:
|
|
|
|
/// An array of wxPiePart objects for storing information about sectors
|
|
|
|
wxPieSeries m_Series;
|
|
|
|
/// Constructor
|
|
|
|
/*!
|
|
|
|
\param parent Pointer to a parent window
|
|
|
|
\param id Window ID
|
|
|
|
\param pos Window position
|
|
|
|
\param sz Window size
|
|
|
|
\param style Window style
|
|
|
|
\param name Window name
|
|
|
|
*/
|
|
|
|
wxPieCtrl(wxWindow * parent, wxWindowID id = wxID_ANY, wxPoint pos = wxDefaultPosition,
|
|
|
|
wxSize sz = wxDefaultSize, long style = 0, wxString name = wxT("wxPieCtrl"));
|
|
|
|
/// Sets the angle of vertical rotation
|
|
|
|
void SetAngle(double angle);
|
|
|
|
/// Sets the angle of horizontal rotation
|
|
|
|
void SetRotationAngle(double angle);
|
|
|
|
/// Sets the height of pie diagram
|
|
|
|
void SetHeight(int value) {m_Height = abs(value);}
|
|
|
|
/// Sets the background bitmap of the control
|
|
|
|
void SetBackground(wxBitmap bmp);
|
|
|
|
/// Returns the background colour of the control
|
|
|
|
wxColour GetBackColour() {return m_BackColour;}
|
|
|
|
/// Sets the background colour of the control
|
|
|
|
void SetBackColour(wxColour colour);
|
|
|
|
//set 3D mode
|
|
|
|
void SetPaint3D(bool b3D);
|
|
|
|
//get 3D mode
|
|
|
|
bool GetPaint3D();
|
|
|
|
//set circle mode
|
|
|
|
void SetDrawCircle(bool bCircle);
|
|
|
|
//get circle mode
|
|
|
|
bool GetDrawCircle();
|
|
|
|
|
|
|
|
/// Returns true if the edges of diagram are shown, otherwise returns false
|
|
|
|
bool GetShowEdges() {return m_ShowEdges;}
|
|
|
|
/// Shows or hides edges of diagram
|
|
|
|
/*!
|
|
|
|
\param value Specifies the visibility of diagram edges
|
|
|
|
*/
|
|
|
|
void SetShowEdges(bool value);
|
|
|
|
/// Returns the pointer of diagram legend
|
|
|
|
wxPieCtrlLegend * GetLegend() {return m_Legend;}
|
|
|
|
virtual void Refresh(bool eraseBackground = true, const wxRect* rect = NULL);
|
2007-01-19 00:59:31 +00:00
|
|
|
int GetCoveredPiePart(int x,int y);
|
2006-10-09 17:38:59 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
void OnPaint(wxPaintEvent & event);
|
|
|
|
void OnEraseBackground(wxEraseEvent & 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);
|
2006-10-09 17:38:59 +00:00
|
|
|
};
|
|
|
|
// ========================================================================
|
|
|
|
// wxProgressPie
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
/// A ProgressPie is a pie digram control which shows a quantity (often time).
|
|
|
|
class wxProgressPie : public wxPieCtrl
|
|
|
|
{
|
|
|
|
double m_MaxValue;
|
|
|
|
double m_Value;
|
|
|
|
wxColour m_FilledColour;
|
|
|
|
wxColour m_UnfilledColour;
|
|
|
|
public:
|
|
|
|
/// Constructor
|
|
|
|
/*!
|
|
|
|
\param parent Pointer to a parent window
|
|
|
|
\param id Window ID
|
|
|
|
\param maxvalue Maximal value of progress pie
|
|
|
|
\param value Initial value of progress pie
|
|
|
|
\param pos Window position
|
|
|
|
\param sz Window size
|
2007-01-10 01:01:24 +00:00
|
|
|
\param style Window style
|
2006-10-09 17:38:59 +00:00
|
|
|
*/
|
|
|
|
wxProgressPie(wxWindow * parent, wxWindowID id = wxID_ANY, double maxvalue = 100, double value = 50,
|
|
|
|
wxPoint pos = wxDefaultPosition, wxSize sz = wxDefaultSize, long style = 0);
|
|
|
|
/// Sets the value of progress pie
|
|
|
|
void SetValue(double value);
|
|
|
|
/// Returns the value of progress pie
|
|
|
|
double GetValue() {return m_Value;}
|
|
|
|
/// Sets maximal value of progress pie
|
|
|
|
void SetMaxValue(double value);
|
|
|
|
/// Returns maximal value of progress pie
|
|
|
|
double GetMaxValue() {return m_MaxValue;}
|
|
|
|
/// Sets the colour of sector that indicates the progress (filled)
|
|
|
|
void SetFilledColour(wxColour colour);
|
|
|
|
/// Sets the colour of sector that indicates the rest (unfilled)
|
|
|
|
void SetUnfilledColour(wxColour colour);
|
|
|
|
/// Returns the colour of sector that indicates the progress (filled)
|
|
|
|
wxColour GetFilledColour();
|
|
|
|
/// Returns the colour of sector that indicates the rest (unfilled)
|
2007-01-10 01:01:24 +00:00
|
|
|
wxColour GetUnfilledColour();
|
2006-10-09 17:38:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|