862
/////////////////////////////////////////////GinkgoBoxPanel/////////////////////////////////////
863
GinkgoBoxPanel::GinkgoBoxPanel(wxWindow *parent,
867
long style):wxPanel(parent, winid, pos, size, style)
869
m_backgroudColor = wxColour(248,247,243);
870
m_borderColor = wxColour(216, 215, 209, 255);
871
SetBackgroundColour(m_backgroudColor);
873
this->Connect( wxEVT_PAINT, wxPaintEventHandler( GinkgoBoxPanel::OnPaint ), NULL, this );
876
GinkgoBoxPanel::~GinkgoBoxPanel()
878
this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( GinkgoBoxPanel::OnPaint ), NULL, this );
881
void GinkgoBoxPanel::OnPaint(wxPaintEvent &event)
885
dc.SetBrush(wxBrush(m_borderColor,wxTRANSPARENT));
886
dc.SetPen(wxPen(m_borderColor, 1, wxSOLID));
888
dc.DrawRectangle(wxRect(wxPoint(0,0), wxPoint(dc.GetSize().x-1, dc.GetSize().y-1)));
892
/////////////////////////////////////////////GinkgoGauge/////////////////////////////////////
893
GinkgoGauge::GinkgoGauge(wxWindow *parent,
897
long style): wxPanel(parent, winid, pos, size, style)
899
SetMinSize(wxSize(150, 15));
901
wxFont font(8, GetFont().GetFamily(), GetFont().GetStyle(), GetFont().GetWeight());
903
wxWindow::SetBackgroundStyle(wxBG_STYLE_CUSTOM);
908
dc.GetTextExtent(wxT("000% "), &width, &height, NULL, NULL, NULL);
909
m_maxSizeOfText = GetSize().x - (width +15);
911
RecreateBuffer(size);
914
this->Connect( wxEVT_PAINT, wxPaintEventHandler( GinkgoGauge::OnPaint ), NULL, this );
915
this->Connect( wxEVT_ERASE_BACKGROUND, wxEraseEventHandler( GinkgoGauge::OnEraseBackground ), NULL, this);
916
this->Connect( wxEVT_SIZE, wxSizeEventHandler( GinkgoGauge::OnSize ), NULL, this );
919
GinkgoGauge::~GinkgoGauge()
921
this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( GinkgoGauge::OnPaint ), NULL, this );
922
this->Disconnect( wxEVT_ERASE_BACKGROUND, wxEraseEventHandler( GinkgoGauge::OnEraseBackground ), NULL, this);
923
this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( GinkgoGauge::OnSize ), NULL, this );
926
void GinkgoGauge::SetStatus(const wxString& status)
930
dc.SetFont(GetFont());
932
dc.GetTextExtent(m_status, &width, &height, NULL, NULL, NULL);
933
while (width > m_maxSizeOfText && m_status.size() > 2) {
934
m_status = m_status.substr(0, m_status.size() - 2);
935
dc.GetTextExtent(m_status, &width, &height, NULL, NULL, NULL);
941
void GinkgoGauge::SetProgress(float progress)
943
if (progress >= 0.0f && progress <= 1.0f) {
944
m_progress = progress;
949
void GinkgoGauge::OnPaint(wxPaintEvent &event)
951
wxBufferedPaintDC dc(this, m_bufferBitmap);
954
dc.SetFont(GetFont());
955
dc.SetPen( wxPen( m_borderColour, 1, wxSOLID ) );
956
dc.SetBrush(wxColour(255,255,255));
958
int width = dc.GetSize().x;
959
int height = dc.GetSize().y;
960
wxRect cr(0,0, width, height);
962
dc.DrawRectangle(cr);
964
cr.width = (int) ( (float)width * m_progress );
966
dc.GradientFillLinear(cr, m_startColour, m_endColour, wxEAST);
968
int func = dc.GetLogicalFunction();
969
dc.SetLogicalFunction(wxXOR);
971
wxCoord tx = 0, ty = 0;
972
wxString str = wxString::Format(wxT("%.00f%% "), 100.0f * m_progress) + m_status;
973
dc.GetTextExtent(str, &tx, &ty, NULL, NULL, NULL);
976
dc.DrawText(str, (width >> 1) - (tx >> 1), (height >> 1) - (ty >> 1) );
977
dc.SetLogicalFunction(func);
981
void GinkgoGauge::OnEraseBackground( wxEraseEvent& )
986
void GinkgoGauge::OnSize(wxSizeEvent& )
991
void GinkgoGauge::SetMinSize(const wxSize &minSize)
993
wxPanel::SetMinSize(minSize);
997
void GinkgoGauge::SetSize(const wxSize &minSize)
999
wxPanel::SetSize(minSize);
1003
void GinkgoGauge::SetColorSchema(TColorSchema schema)
1007
m_fontColour = wxColour(0,0,0);
1008
m_startColour = wxColour(224, 237, 255);
1009
m_endColour = wxColour(119, 169, 255);
1010
m_borderColour = wxColour(58, 143, 255);
1013
m_fontColour = wxColour(0,0,0);
1014
m_startColour = wxColour(255, 224, 237);
1015
m_endColour = wxColour(255, 169, 119);
1016
m_borderColour = wxColour(255, 0, 0);
1019
m_fontColour = wxColour(0,0,0);
1020
m_startColour = wxColour(237, 237, 237);
1021
m_endColour = wxColour(100, 100, 100);
1022
m_borderColour = wxColour(143, 143, 143);
1025
m_fontColour = wxColour(0,0,0);
1026
m_startColour = wxColour(237, 255, 224);
1027
m_endColour = wxColour(120, 198, 83);
1028
m_borderColour = wxColour(143, 255, 58);
1031
SetForegroundColour(m_fontColour);
1034
bool GinkgoGauge::RecreateBuffer(const wxSize& size)
1037
if (sz == wxDefaultSize)
1038
sz = GetClientSize();
1040
if (sz.x < 1 || sz.y < 1)
1043
wxClientDC dc(this);
1044
dc.SetFont(GetFont());
1046
dc.GetTextExtent(wxT("000% "), &width, &height, NULL, NULL, NULL);
1047
m_maxSizeOfText = sz.x - (width +15);
1049
if (!m_bufferBitmap.Ok() || m_bufferBitmap.GetWidth() < sz.x || m_bufferBitmap.GetHeight() < sz.y)
1050
m_bufferBitmap = wxBitmap(sz.x, sz.y);
1052
return m_bufferBitmap.Ok();