Code: Select all
#include "MyPaintPanel.h"
#include<wx/dcclient.h>
MyPaintPanel::MyPaintPanel(wxWindow* parent, wxWindowID id , const wxPoint& pos , const wxSize& size, long style , const wxString& name)
:wxPanel(parent,id,pos,size,style,name){
//wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
this->dayx= new wxStaticText(this, -1, wxString("Day X"), wxPoint(0,0));
this->dayx->SetFont(wxFont(20, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));
this->uhrzeit = new wxStaticText(this, -1, wxString(" 14:32:52"), wxPoint(50,30));
this->uhrzeit->SetFont(wxFont(50, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));
this->status = new wxStaticText(this, -1, wxString(" Systemzeit"), wxPoint(200,0));
this->status->SetFont(wxFont(18, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));
//sizer->Add(uhrzeit,1,wxGROW|wxALIGN_CENTRE);
//wxMessageBox(wxString("")<<size.GetWidth()/2);
this->SetBackgroundColour("WHITE");
//SetSizerAndFit(sizer);
}
void MyPaintPanel::update(wxString s,int x,bool temp){
this->uhrzeit->SetLabel(s);
this->sim=temp;
if(x!=this->x){
this->x=x;
this->SetSize(wxSize(this->GetSize()));
}
if(x<0){
this->dayx->SetLabel(wxString("Day X ")<<x);
}else{
if (x>0){
this->dayx->SetLabel(wxString("Day X +")<<x);
}
else{
this->dayx->SetLabel(wxString("Day X"));
}
}
if (temp==true){this->status->SetLabel("Systemzeit");
}else{
this->status->SetLabel("Sim Zeit");}
}
//wxPoint(size.GetWidth()/2,size.GetHeight() /2
void MyPaintPanel::OnSize(wxSizeEvent& event){
if(x!=0){
this->dayx->SetFont(wxFont(((this->GetSize().GetHeight()/100)*15), wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));
this->dayx->SetPosition(wxPoint(((this->GetSize().GetWidth()/100)*30),this->GetSize().GetHeight()/4));
}else{
this->dayx->SetFont(wxFont(((this->GetSize().GetHeight()/100)*15), wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));
this->dayx->SetPosition(wxPoint(((this->GetSize().GetWidth()/100)*36),this->GetSize().GetHeight()/4));
}
if(sim){
this->status->SetFont(wxFont(((this->GetSize().GetHeight()/100)*15), wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));
this->status->SetPosition(wxPoint(((this->GetSize().GetWidth()/100)*27),0));
}else{
this->status->SetFont(wxFont(((this->GetSize().GetHeight()/100)*15), wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));
this->status->SetPosition(wxPoint(((this->GetSize().GetWidth()/100)*31),0));
}
this->uhrzeit->SetFont(wxFont(((this->GetSize().GetHeight()/100)*20), wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));
this->uhrzeit->SetPosition(wxPoint(((this->GetSize().GetWidth()/100)*25),this->GetSize().GetHeight()/2));
}
BEGIN_EVENT_TABLE(MyPaintPanel,wxPanel)
EVT_SIZE ( MyPaintPanel::OnSize)
END_EVENT_TABLE()