Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <wx/wx.h>
- using namespace std;
- class Window : public wxFrame
- {
- private:
- double zmienna1,zmienna2;
- double wynik;
- public:
- Window(const wxString&);
- Window *okno;
- wxPanel *panel;
- wxButton *odczyt_button;
- wxTextCtrl * tekst1;
- wxTextCtrl * tekst2;
- wxStaticText * etykieta;
- DECLARE_EVENT_TABLE();
- void dodaj(wxCommandEvent& event);
- void odczytaj(wxCommandEvent& event);
- };
- BEGIN_EVENT_TABLE(Window,wxFrame)
- EVT_BUTTON(10,Window::odczytaj)
- END_EVENT_TABLE()
- void Window::dodaj(wxCommandEvent& event)
- {
- }
- void Window::odczytaj(wxCommandEvent& event)
- {
- wxString str = tekst1->GetValue();
- str.ToDouble(&zmienna1);
- str = tekst2->GetValue();
- str.ToDouble(&zmienna2);
- wynik = zmienna1 + zmienna2;
- str.Printf("WYNIK: %.2f", wynik);
- etykieta->SetLabel(str);
- }
- Window::Window(const wxString & title): wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800,600))
- {
- panel=new wxPanel(this,wxID_ANY,wxDefaultPosition,wxDefaultSize);
- odczyt_button = new wxButton(panel,10,wxT("WYKONAJ"),wxDefaultPosition,wxDefaultSize);
- tekst1 = new wxTextCtrl(panel,100,wxEmptyString,wxDefaultPosition,wxDefaultSize);
- tekst2 = new wxTextCtrl(panel,200,wxEmptyString,wxDefaultPosition,wxDefaultSize);
- etykieta = new wxStaticText(panel,1000,"WYNIK: ",wxDefaultPosition,wxDefaultSize);
- tekst2->Move(0,25);
- etykieta->Move(0,50);
- odczyt_button->Move(0,70);
- }
- class ZAD2 : public wxApp
- {
- public:
- bool OnInit();
- };
- bool ZAD2::OnInit()
- {
- Window *okno = new Window(wxT("ZAD2"));
- okno->Center();
- okno->Show(true);
- return true;
- }
- wxIMPLEMENT_APP(ZAD2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement