Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. #include <wx/wx.h>
  2.  
  3. using namespace std;
  4.  
  5. class Window : public wxFrame
  6. {
  7. private:
  8. double zmienna1,zmienna2;
  9. double wynik;
  10. public:
  11. Window(const wxString&);
  12.  
  13. Window *okno;
  14. wxPanel *panel;
  15. wxButton *odczyt_button;
  16. wxTextCtrl * tekst1;
  17. wxTextCtrl * tekst2;
  18. wxStaticText * etykieta;
  19.  
  20. DECLARE_EVENT_TABLE();
  21.  
  22. void dodaj(wxCommandEvent& event);
  23. void odczytaj(wxCommandEvent& event);
  24. };
  25.  
  26. BEGIN_EVENT_TABLE(Window,wxFrame)
  27. EVT_BUTTON(10,Window::odczytaj)
  28. END_EVENT_TABLE()
  29.  
  30. void Window::dodaj(wxCommandEvent& event)
  31. {
  32.  
  33. }
  34.  
  35. void Window::odczytaj(wxCommandEvent& event)
  36. {
  37. wxString str = tekst1->GetValue();
  38. str.ToDouble(&zmienna1);
  39.  
  40. str = tekst2->GetValue();
  41. str.ToDouble(&zmienna2);
  42.  
  43. wynik = zmienna1 + zmienna2;
  44.  
  45. str.Printf("WYNIK: %.2f", wynik);
  46.  
  47. etykieta->SetLabel(str);
  48.  
  49. }
  50.  
  51. Window::Window(const wxString & title): wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800,600))
  52. {
  53. panel=new wxPanel(this,wxID_ANY,wxDefaultPosition,wxDefaultSize);
  54.  
  55. odczyt_button = new wxButton(panel,10,wxT("WYKONAJ"),wxDefaultPosition,wxDefaultSize);
  56.  
  57. tekst1 = new wxTextCtrl(panel,100,wxEmptyString,wxDefaultPosition,wxDefaultSize);
  58. tekst2 = new wxTextCtrl(panel,200,wxEmptyString,wxDefaultPosition,wxDefaultSize);
  59.  
  60. etykieta = new wxStaticText(panel,1000,"WYNIK: ",wxDefaultPosition,wxDefaultSize);
  61.  
  62. tekst2->Move(0,25);
  63.  
  64. etykieta->Move(0,50);
  65.  
  66. odczyt_button->Move(0,70);
  67. }
  68.  
  69. class ZAD2 : public wxApp
  70. {
  71. public:
  72. bool OnInit();
  73. };
  74.  
  75. bool ZAD2::OnInit()
  76. {
  77. Window *okno = new Window(wxT("ZAD2"));
  78.  
  79. okno->Center();
  80. okno->Show(true);
  81. return true;
  82. }
  83.  
  84. wxIMPLEMENT_APP(ZAD2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement