Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CalFrame::CalFrame ( const wxString& title, const wxPoint& pos, const wxSize& size ) : wxFrame ( nullptr , wxID _ ANY, title, pos, size ) {
CalFrame::CalFrameconst wxString& title, const wxPoint& pos, const wxSize& size
: wxFramenullptr wxIDANY, title, pos, size
textControl new wxTextCtrlthis wxIDANY, wxPoint wxSize wxTEREADONLY;
new wxButtonthis IDBUTTON wxPoint wxSize;
new wxButtonthis IDBUTTON wxPoint wxSize;
new wxButtonthis IDBUTTON wxPoint wxSize;
new wxButtonthis IDBUTTON wxPoint wxSize;
new wxButtonthis IDBUTTON wxPoint wxSize;
new wxButtonthis IDBUTTON wxPoint wxSize;
new wxButtonthis IDBUTTON wxPoint wxSize;
new wxButtonthis IDBUTTON wxPoint wxSize;
new wxButtonthis IDBUTTON wxPoint wxSize;
new wxButtonthis IDBUTTONDECIMAL, wxPoint wxSize;
new wxButtonthis IDBUTTON wxPoint wxSize;
new wxButtonthis IDBUTTONNEGATIVE, wxPoint wxSize;
new wxButtonthis IDBUTTONPLUS, wxPoint wxSize;
new wxButtonthis IDBUTTONMINUS, wxPoint wxSize;
new wxButtonthis IDBUTTONMULTIPLY, wxPoint wxSize;
new wxButtonthis IDBUTTONDIVIDE, wxPoint wxSize;
new wxButtonthis IDBUTTONMOD, wxPoint wxSize;
new wxButtonthis IDBUTTONSIN, "SIN", wxPoint wxSize;
new wxButtonthis IDBUTTONCON, "CON", wxPoint wxSize;
new wxButtonthis IDBUTTONTAN, "TAN", wxPoint wxSize;
new wxButtonthis IDBUTTONBACKSPACE, wxPoint wxSize;
new wxButtonthis IDBUTTONEQUAL, wxPoint wxSize;
new wxButtonthis IDBUTTONCLEAR, "CLEAR", wxPoint wxSize;
BindwxEVTBUTTON, &CalFrame::OnButtonClicked, this, IDBUTTON IDBUTTONTAN;
BindwxEVTBUTTON, &CalFrame::OnClearButtonClick, this, IDBUTTONCLEAR;
BindwxEVTBUTTON, &CalFrame::OnBackspace, this, IDBUTTONBACKSPACE;
BindwxEVTBUTTON, &CalFrame::OnCalculate, this, IDBUTTONEQUAL;
void CalFrame::OnButtonClickedwxCommandEvent& event
int buttonId event.GetId;
wxString buttonText;
if buttonId IDBUTTON && buttonId IDBUTTON
buttonText wxString::Formatc buttonId IDBUTTON;
else
switch buttonId
case IDBUTTONPLUS:
buttonText ;
break;
case IDBUTTONMINUS:
buttonText ;
break;
case IDBUTTONMULTIPLY:
buttonText ;
break;
case IDBUTTONDIVIDE:
buttonText ;
break;
case IDBUTTONMOD:
buttonText ;
break;
case IDBUTTONDECIMAL:
buttonText ;
break;
case IDBUTTONCLEAR:
OnClearButtonClickevent;
return;
break;
case IDBUTTONEQUAL:
OnCalculateevent;
break;
case IDBUTTONTAN:
buttonText "TAN";
break;
case IDBUTTONSIN:
buttonText "SIN";
break;
case IDBUTTONCON:
buttonText "CON";
break;
case IDBUTTONNEGATIVE:
buttonText ;
break;
case IDBUTTONBACKSPACE:
OnBackspaceevent;
return;
break;
textControlAppendTextbuttonText;
void CalFrame::OnClearButtonClickwxCommandEvent& event
textControlClear;
void CalFrame::OnCalculatewxCommandEvent& event
wxString expression textControlGetValue;
double result;
if wxStringexpressionToCDouble&result
textControlSetValuewxString::Formatg result;
else
wxMessageBoxInvalid expression", "Error", wxICONERROR wxOK;
void CalFrame::OnBackspacewxCommandEvent& event
wxString currentValue textControlGetValue;
if currentValue.empty
currentValue.RemoveLast;
textControlSetValuecurrentValue;
the onCalculation fuction does not work and i cant sema to fix it i dont know what i am doing wrong.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started