Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 16.24 KB | None | 0 0
  1. /***************************************************************
  2.  * Name:      CalcApp.h
  3.  * Purpose:   Defines Application Class
  4.  * Author:    Victor Mello Floriano (victormellof@gmail.com)
  5.  * Created:   2011-02-14
  6.  * Copyright: Victor Mello Floriano ()
  7.  * License:
  8.  **************************************************************/
  9.  
  10. #ifndef CALCAPP_H
  11. #define CALCAPP_H
  12.  
  13. #include <wx/app.h>
  14.  
  15. class CalcApp : public wxApp
  16. {
  17.     public:
  18.         virtual bool OnInit();
  19. };
  20.  
  21. #endif // CALCAPP_H
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. /***************************************************************
  43.  * Name:      CalcApp.cpp
  44.  * Purpose:   Code for Application Class
  45.  * Author:    Victor Mello Floriano (victormellof@gmail.com)
  46.  * Created:   2011-02-14
  47.  * Copyright: Victor Mello Floriano ()
  48.  * License:
  49.  **************************************************************/
  50.  
  51. #include "CalcApp.h"
  52.  
  53. //(*AppHeaders
  54. #include "CalcMain.h"
  55. #include <wx/image.h>
  56. //*)
  57.  
  58. IMPLEMENT_APP(CalcApp);
  59.  
  60. bool CalcApp::OnInit()
  61. {
  62.     //(*AppInitialize
  63.     bool wxsOK = true;
  64.     wxInitAllImageHandlers();
  65.     if ( wxsOK )
  66.     {
  67.         CalcFrame* Frame = new CalcFrame(0);
  68.         Frame->Show();
  69.         SetTopWindow(Frame);
  70.     }
  71.     //*)
  72.     return wxsOK;
  73.  
  74. }
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84. /***************************************************************
  85.  * Name:      CalcMain.h
  86.  * Purpose:   Defines Application Frame
  87.  * Author:    Victor Mello Floriano (victormellof@gmail.com)
  88.  * Created:   2011-02-14
  89.  * Copyright: Victor Mello Floriano ()
  90.  * License:
  91.  **************************************************************/
  92.  
  93. #ifndef CALCMAIN_H
  94. #define CALCMAIN_H
  95.  
  96. //(*Headers(CalcFrame)
  97. #include <wx/button.h>
  98. #include <wx/menu.h>
  99. #include <wx/panel.h>
  100. #include <wx/statusbr.h>
  101. #include <wx/frame.h>
  102. #include <wx/textctrl.h>
  103. //*)
  104.  
  105. class CalcFrame: public wxFrame
  106. {
  107.     public:
  108.  
  109.         CalcFrame(wxWindow* parent,wxWindowID id = -1);
  110.         virtual ~CalcFrame();
  111.  
  112.         double num1, num2;
  113.         char op;
  114.  
  115.     private:
  116.  
  117.         //(*Handlers(CalcFrame)
  118.         void OnQuit(wxCommandEvent& event);
  119.         void OnAbout(wxCommandEvent& event);
  120.         void OnButton19Click(wxCommandEvent& event);
  121.         void OnButton9Click(wxCommandEvent& event);
  122.         void OnButton4Click(wxCommandEvent& event);
  123.         void OnButton5Click(wxCommandEvent& event);
  124.         void OnButton6Click(wxCommandEvent& event);
  125.         void OnButton13Click(wxCommandEvent& event);
  126.         void OnButton8Click(wxCommandEvent& event);
  127.         void OnButton10Click(wxCommandEvent& event);
  128.         void OnButton16Click(wxCommandEvent& event);
  129.         void OnButton12Click(wxCommandEvent& event);
  130.         void OnButton1Click(wxCommandEvent& event);
  131.         void OnButton17Click(wxCommandEvent& event);
  132.         void OnButton14Click(wxCommandEvent& event);
  133.         void OnButton3Click(wxCommandEvent& event);
  134.         void OnButton7Click(wxCommandEvent& event);
  135.         void OnButton11Click(wxCommandEvent& event);
  136.         void OnButton18Click(wxCommandEvent& event);
  137.         void OnButton2Click(wxCommandEvent& event);
  138.         void OnButton15Click(wxCommandEvent& event);
  139.         void OnTextCtrl1Text(wxCommandEvent& event);
  140.         //*)
  141.  
  142.         //(*Identifiers(CalcFrame)
  143.         static const long ID_BUTTON9;
  144.         static const long ID_BUTTON13;
  145.         static const long ID_BUTTON16;
  146.         static const long ID_BUTTON17;
  147.         static const long ID_BUTTON18;
  148.         static const long ID_BUTTON15;
  149.         static const long ID_BUTTON19;
  150.         static const long ID_BUTTON14;
  151.         static const long ID_BUTTON12;
  152.         static const long ID_BUTTON11;
  153.         static const long ID_BUTTON10;
  154.         static const long ID_BUTTON8;
  155.         static const long ID_BUTTON7;
  156.         static const long ID_BUTTON6;
  157.         static const long ID_BUTTON5;
  158.         static const long ID_BUTTON4;
  159.         static const long ID_BUTTON3;
  160.         static const long ID_BUTTON2;
  161.         static const long ID_BUTTON1;
  162.         static const long ID_TEXTCTRL1;
  163.         static const long ID_PANEL1;
  164.         static const long ID_STATUSBAR1;
  165.         //*)
  166.  
  167.         //(*Declarations(CalcFrame)
  168.         wxPanel* Panel1;
  169.         wxStatusBar* StatusBar1;
  170.         wxButton* Button19;
  171.         wxButton* Button16;
  172.         wxButton* Button4;
  173.         wxButton* Button1;
  174.         wxButton* Button2;
  175.         wxButton* Button3;
  176.         wxButton* Button12;
  177.         wxButton* Button8;
  178.         wxButton* Button5;
  179.         wxButton* Button17;
  180.         wxButton* Button9;
  181.         wxButton* Button15;
  182.         wxButton* Button14;
  183.         wxTextCtrl* TextCtrl1;
  184.         wxButton* Button18;
  185.         wxButton* Button11;
  186.         wxButton* Button7;
  187.         wxButton* Button6;
  188.         wxButton* Button13;
  189.         wxButton* Button10;
  190.         //*)
  191.  
  192.         DECLARE_EVENT_TABLE()
  193. };
  194.  
  195. #endif // CALCMAIN_H
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217. /***************************************************************
  218.  * Name:      CalcMain.cpp
  219.  * Purpose:   Code for Application Frame
  220.  * Author:    Victor Mello Floriano (victormellof@gmail.com)
  221.  * Created:   2011-02-14
  222.  * Copyright: Victor Mello Floriano ()
  223.  * License:
  224.  **************************************************************/
  225.  
  226. #include "CalcMain.h"
  227. #include <wx/msgdlg.h>
  228.  
  229. //(*InternalHeaders(CalcFrame)
  230. #include <wx/string.h>
  231. #include <wx/intl.h>
  232. #include <wx/font.h>
  233. //*)
  234.  
  235. //helper functions
  236. enum wxbuildinfoformat {
  237.     short_f, long_f };
  238.  
  239. wxString wxbuildinfo(wxbuildinfoformat format)
  240. {
  241.     wxString wxbuild(wxVERSION_STRING);
  242.  
  243.     if (format == long_f )
  244.     {
  245. #if defined(__WXMSW__)
  246.         wxbuild << _T("-Windows");
  247. #elif defined(__UNIX__)
  248.         wxbuild << _T("-Linux");
  249. #endif
  250.  
  251. #if wxUSE_UNICODE
  252.         wxbuild << _T("-Unicode build");
  253. #else
  254.         wxbuild << _T("-ANSI build");
  255. #endif // wxUSE_UNICODE
  256.     }
  257.  
  258.     return wxbuild;
  259. }
  260.  
  261. //(*IdInit(CalcFrame)
  262. const long CalcFrame::ID_BUTTON9 = wxNewId();
  263. const long CalcFrame::ID_BUTTON13 = wxNewId();
  264. const long CalcFrame::ID_BUTTON16 = wxNewId();
  265. const long CalcFrame::ID_BUTTON17 = wxNewId();
  266. const long CalcFrame::ID_BUTTON18 = wxNewId();
  267. const long CalcFrame::ID_BUTTON15 = wxNewId();
  268. const long CalcFrame::ID_BUTTON19 = wxNewId();
  269. const long CalcFrame::ID_BUTTON14 = wxNewId();
  270. const long CalcFrame::ID_BUTTON12 = wxNewId();
  271. const long CalcFrame::ID_BUTTON11 = wxNewId();
  272. const long CalcFrame::ID_BUTTON10 = wxNewId();
  273. const long CalcFrame::ID_BUTTON8 = wxNewId();
  274. const long CalcFrame::ID_BUTTON7 = wxNewId();
  275. const long CalcFrame::ID_BUTTON6 = wxNewId();
  276. const long CalcFrame::ID_BUTTON5 = wxNewId();
  277. const long CalcFrame::ID_BUTTON4 = wxNewId();
  278. const long CalcFrame::ID_BUTTON3 = wxNewId();
  279. const long CalcFrame::ID_BUTTON2 = wxNewId();
  280. const long CalcFrame::ID_BUTTON1 = wxNewId();
  281. const long CalcFrame::ID_TEXTCTRL1 = wxNewId();
  282. const long CalcFrame::ID_PANEL1 = wxNewId();
  283. const long CalcFrame::ID_STATUSBAR1 = wxNewId();
  284. //*)
  285.  
  286. BEGIN_EVENT_TABLE(CalcFrame,wxFrame)
  287.     //(*EventTable(CalcFrame)
  288.     //*)
  289. END_EVENT_TABLE()
  290.  
  291. CalcFrame::CalcFrame(wxWindow* parent,wxWindowID id)
  292. {
  293.     //(*Initialize(CalcFrame)
  294.     wxMenuBar* MenuBar1;
  295.  
  296.     Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
  297.     SetClientSize(wxSize(245,375));
  298.     Panel1 = new wxPanel(this, ID_PANEL1, wxPoint(152,184), wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
  299.     Button9 = new wxButton(Panel1, ID_BUTTON9, _("0"), wxPoint(8,280), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON9"));
  300.     Button13 = new wxButton(Panel1, ID_BUTTON13, _("4"), wxPoint(8,168), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON13"));
  301.     Button16 = new wxButton(Panel1, ID_BUTTON16, _("7"), wxPoint(8,112), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON16"));
  302.     Button17 = new wxButton(Panel1, ID_BUTTON17, _("C"), wxPoint(8,56), wxSize(104,50), 0, wxDefaultValidator, _T("ID_BUTTON17"));
  303.     Button18 = new wxButton(Panel1, ID_BUTTON18, _("*"), wxPoint(176,112), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON18"));
  304.     Button15 = new wxButton(Panel1, ID_BUTTON15, _("+ -"), wxPoint(176,56), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON15"));
  305.     Button19 = new wxButton(Panel1, ID_BUTTON19, _("9"), wxPoint(120,112), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON19"));
  306.     Button14 = new wxButton(Panel1, ID_BUTTON14, _("<-"), wxPoint(120,56), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON14"));
  307.     Button12 = new wxButton(Panel1, ID_BUTTON12, _("8"), wxPoint(64,112), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON12"));
  308.     Button11 = new wxButton(Panel1, ID_BUTTON11, _("/"), wxPoint(176,168), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON11"));
  309.     Button10 = new wxButton(Panel1, ID_BUTTON10, _("6"), wxPoint(120,168), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON10"));
  310.     Button8 = new wxButton(Panel1, ID_BUTTON8, _("5"), wxPoint(64,168), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON8"));
  311.     Button7 = new wxButton(Panel1, ID_BUTTON7, _("-"), wxPoint(176,224), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON7"));
  312.     Button6 = new wxButton(Panel1, ID_BUTTON6, _("3"), wxPoint(120,224), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON6"));
  313.     Button5 = new wxButton(Panel1, ID_BUTTON5, _("2"), wxPoint(64,224), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON5"));
  314.     Button4 = new wxButton(Panel1, ID_BUTTON4, _("1"), wxPoint(8,224), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON4"));
  315.     Button3 = new wxButton(Panel1, ID_BUTTON3, _("+"), wxPoint(176,280), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON3"));
  316.     Button2 = new wxButton(Panel1, ID_BUTTON2, _("="), wxPoint(120,280), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON2"));
  317.     Button1 = new wxButton(Panel1, ID_BUTTON1, _(","), wxPoint(64,280), wxSize(50,50), 0, wxDefaultValidator, _T("ID_BUTTON1"));
  318.     TextCtrl1 = new wxTextCtrl(Panel1, ID_TEXTCTRL1, wxEmptyString, wxPoint(8,16), wxSize(216,27), 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
  319.     TextCtrl1->Disable();
  320.     wxFont TextCtrl1Font(12,wxSWISS,wxFONTSTYLE_NORMAL,wxNORMAL,false,_T("Sans"),wxFONTENCODING_DEFAULT);
  321.     TextCtrl1->SetFont(TextCtrl1Font);
  322.     MenuBar1 = new wxMenuBar();
  323.     SetMenuBar(MenuBar1);
  324.     StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
  325.     int __wxStatusBarWidths_1[1] = { -1 };
  326.     int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
  327.     StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
  328.     StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
  329.     SetStatusBar(StatusBar1);
  330.  
  331.     Connect(ID_BUTTON9,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton9Click);
  332.     Connect(ID_BUTTON13,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton13Click);
  333.     Connect(ID_BUTTON16,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton16Click);
  334.     Connect(ID_BUTTON17,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton17Click);
  335.     Connect(ID_BUTTON18,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton18Click);
  336.     Connect(ID_BUTTON15,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton15Click);
  337.     Connect(ID_BUTTON19,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton19Click);
  338.     Connect(ID_BUTTON14,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton14Click);
  339.     Connect(ID_BUTTON12,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton12Click);
  340.     Connect(ID_BUTTON11,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton11Click);
  341.     Connect(ID_BUTTON10,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton10Click);
  342.     Connect(ID_BUTTON8,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton8Click);
  343.     Connect(ID_BUTTON7,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton7Click);
  344.     Connect(ID_BUTTON6,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton6Click);
  345.     Connect(ID_BUTTON5,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton5Click);
  346.     Connect(ID_BUTTON4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton4Click);
  347.     Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton3Click);
  348.     Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton2Click);
  349.     Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CalcFrame::OnButton1Click);
  350.     Connect(ID_TEXTCTRL1,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&CalcFrame::OnTextCtrl1Text);
  351.     //*)
  352. }
  353.  
  354. CalcFrame::~CalcFrame()
  355. {
  356.     //(*Destroy(CalcFrame)
  357.     //*)
  358. }
  359.  
  360. void CalcFrame::OnQuit(wxCommandEvent& event)
  361. {
  362.     Close();
  363. }
  364.  
  365. void CalcFrame::OnAbout(wxCommandEvent& event)
  366. {
  367.     wxString msg = wxbuildinfo(long_f);
  368.     wxMessageBox(msg, _("Welcome to..."));
  369. }
  370.  
  371. void CalcFrame::OnButton19Click(wxCommandEvent& event)
  372. {
  373.  
  374.     wxString s;
  375.     s=TextCtrl1->GetValue();
  376.  
  377.     TextCtrl1->SetValue(s+_("9"));
  378. }
  379.  
  380. void CalcFrame::OnButton9Click(wxCommandEvent& event)
  381. {
  382.  
  383.     wxString s;
  384.     s=TextCtrl1->GetValue();
  385.  
  386.     TextCtrl1->SetValue(s+_("0"));
  387. }
  388.  
  389. void CalcFrame::OnButton4Click(wxCommandEvent& event)
  390. {
  391.     wxString s;
  392.     s=TextCtrl1->GetValue();
  393.  
  394.     TextCtrl1->SetValue(s+_("1"));
  395. }
  396.  
  397. void CalcFrame::OnButton5Click(wxCommandEvent& event)
  398. {
  399.     wxString s;
  400.     s=TextCtrl1->GetValue();
  401.  
  402.     TextCtrl1->SetValue(s+_("2"));
  403. }
  404.  
  405. void CalcFrame::OnButton6Click(wxCommandEvent& event)
  406. {
  407.  
  408.     wxString s;
  409.     s=TextCtrl1->GetValue();
  410.  
  411.     TextCtrl1->SetValue(s+_("3"));
  412. }
  413.  
  414. void CalcFrame::OnButton13Click(wxCommandEvent& event)
  415. {
  416.  
  417.     wxString s;
  418.     s=TextCtrl1->GetValue();
  419.  
  420.     TextCtrl1->SetValue(s+_("4"));
  421. }
  422.  
  423. void CalcFrame::OnButton8Click(wxCommandEvent& event)
  424. {
  425.  
  426.     wxString s;
  427.     s=TextCtrl1->GetValue();
  428.  
  429.     TextCtrl1->SetValue(s+_("5"));
  430. }
  431.  
  432. void CalcFrame::OnButton10Click(wxCommandEvent& event)
  433. {
  434.     wxString s;
  435.     s=TextCtrl1->GetValue();
  436.  
  437.     TextCtrl1->SetValue(s+_("6"));
  438. }
  439.  
  440. void CalcFrame::OnButton16Click(wxCommandEvent& event)
  441. {
  442.     wxString s;
  443.     s=TextCtrl1->GetValue();
  444.  
  445.     TextCtrl1->SetValue(s+_("7"));
  446. }
  447.  
  448. void CalcFrame::OnButton12Click(wxCommandEvent& event)
  449. {
  450.     wxString s;
  451.     s=TextCtrl1->GetValue();
  452.  
  453.     TextCtrl1->SetValue(s+_("8"));
  454. }
  455.  
  456. void CalcFrame::OnButton1Click(wxCommandEvent& event)
  457. {
  458.        wxString s;
  459.     s=TextCtrl1->GetValue();
  460.  
  461.     TextCtrl1->SetValue(s+_(","));
  462. }
  463.  
  464. void CalcFrame::OnButton17Click(wxCommandEvent& event)
  465. {
  466.      wxString s;
  467.     TextCtrl1->SetValue(_(""));
  468. }
  469.  
  470. void CalcFrame::OnButton14Click(wxCommandEvent& event)
  471. {
  472.     wxString s;
  473.     s=TextCtrl1->GetValue();
  474.     s=s.substr(0,s.length()-1);
  475.     TextCtrl1->SetValue(s);
  476. }
  477.  
  478. void CalcFrame::OnButton3Click(wxCommandEvent& event)
  479. {
  480.  
  481. wxString s;
  482.  
  483. s=TextCtrl1->GetValue();
  484.  
  485. if (!s.ToDouble(&num1)){}
  486.  
  487. op='+';
  488.  
  489.     TextCtrl1->SetValue(_(""));
  490.  
  491. }
  492.  
  493. void CalcFrame::OnButton7Click(wxCommandEvent& event)
  494. {
  495.  
  496. wxString s;
  497.  
  498. s=TextCtrl1->GetValue();
  499.  
  500. if (!s.ToDouble(&num1)){}
  501.  
  502. op='-';
  503.  
  504.     TextCtrl1->SetValue(_(""));
  505.  
  506. }
  507.  
  508. void CalcFrame::OnButton11Click(wxCommandEvent& event)
  509. {
  510. wxString s;
  511.  
  512. s=TextCtrl1->GetValue();
  513.  
  514. if (!s.ToDouble(&num1)){}
  515.  
  516. op='/';
  517.  
  518.     TextCtrl1->SetValue(_(""));
  519.  
  520. }
  521.  
  522. void CalcFrame::OnButton18Click(wxCommandEvent& event)
  523. {
  524.  
  525. wxString s;
  526.  
  527. s=TextCtrl1->GetValue();
  528.  
  529. if (!s.ToDouble(&num1)){}
  530.  
  531. op='*';
  532.  
  533.     TextCtrl1->SetValue(_(""));
  534.  
  535. }
  536.  
  537. void CalcFrame::OnButton2Click(wxCommandEvent& event)
  538. {
  539.        wxString s;
  540.  
  541. s=TextCtrl1->GetValue();
  542. if (!s.ToDouble(&num2)){}
  543.  
  544. wxString mystring;
  545. if(op=='+'){mystring = wxString::Format(wxT("%f"), (num1+num2));}
  546.  
  547. if(op=='-'){mystring = wxString::Format(wxT("%f"), (num1-num2));}
  548.  
  549. if(op=='/'){mystring = wxString::Format(wxT("%f"), (num1/num2));}
  550.  
  551. if(op=='*'){mystring = wxString::Format(wxT("%f"), (num1*num2));}
  552.  
  553.  
  554. TextCtrl1->SetValue(mystring);
  555.  
  556. }
  557.  
  558. void CalcFrame::OnButton15Click(wxCommandEvent& event)
  559. {
  560.        wxString s;
  561.     double aux;
  562. s=TextCtrl1->GetValue();
  563. if (!s.ToDouble(&aux)){}
  564. aux=aux*-1;
  565.  
  566.  
  567. wxString mystring;
  568. mystring = wxString::Format(wxT("%f"), (aux));
  569.  
  570. TextCtrl1->SetValue(mystring);
  571. }
  572.  
  573. void CalcFrame::OnTextCtrl1Text(wxCommandEvent& event)
  574. {
  575. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement