Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************************************
- * Name: RobotCGenMain.cpp
- * Purpose: Code for Application Frame
- * Author: Jeff Goldman
- * Created: 2013-07-08
- * Copyright: Jeff Goldman
- * License:
- **************************************************************/
- #include <vector>
- #include <string>
- #include "RobotCGenMain.h"
- #include "RobotCGenApp.h"
- #include <wx/msgdlg.h>
- #include <wx/app.h>
- //(*InternalHeaders(RobotCGenFrame)
- #include <wx/intl.h>
- #include <wx/string.h>
- //*)
- RobotCGenApp app2;
- //helper functions
- enum wxbuildinfoformat {
- short_f, long_f };
- wxString wxbuildinfo(wxbuildinfoformat format)
- {
- wxString wxbuild(wxVERSION_STRING);
- if (format == long_f )
- {
- #if defined(__WXMSW__)
- wxbuild << _T("-Windows");
- #elif defined(__UNIX__)
- wxbuild << _T("-Linux");
- #endif
- #if wxUSE_UNICODE
- wxbuild << _T("-Unicode build");
- #else
- wxbuild << _T("-ANSI build");
- #endif // wxUSE_UNICODE
- }
- return wxbuild;
- }
- //(*IdInit(RobotCGenFrame)
- const long RobotCGenFrame::ID_TEXTCTRL1 = wxNewId();
- const long RobotCGenFrame::ID_TEXTCTRL2 = wxNewId();
- const long RobotCGenFrame::ID_TEXTCTRL3 = wxNewId();
- const long RobotCGenFrame::ID_TEXTCTRL4 = wxNewId();
- const long RobotCGenFrame::ID_BUTTON1 = wxNewId();
- const long RobotCGenFrame::ID_BUTTON2 = wxNewId();
- const long RobotCGenFrame::ID_PANEL1 = wxNewId();
- //*)
- BEGIN_EVENT_TABLE(RobotCGenFrame,wxFrame)
- //(*EventTable(RobotCGenFrame)
- //*)
- END_EVENT_TABLE()
- RobotCGenFrame::RobotCGenFrame(wxWindow* parent,wxWindowID id)
- {
- //(*Initialize(RobotCGenFrame)
- wxBoxSizer* BoxSizer2;
- wxBoxSizer* BoxSizer1;
- wxBoxSizer* BoxSizer3;
- Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
- SetClientSize(wxSize(952,135));
- BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
- Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxSize(241,203), wxTAB_TRAVERSAL, _T("ID_PANEL1"));
- BoxSizer2 = new wxBoxSizer(wxVERTICAL);
- TextCtrl1 = new wxTextCtrl(Panel1, ID_TEXTCTRL1, _("Button/ Joystick"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
- BoxSizer2->Add(TextCtrl1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- TextCtrl2 = new wxTextCtrl(Panel1, ID_TEXTCTRL2, _("Motor Name"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
- BoxSizer2->Add(TextCtrl2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- TextCtrl3 = new wxTextCtrl(Panel1, ID_TEXTCTRL3, _("Special"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL3"));
- BoxSizer2->Add(TextCtrl3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- TextCtrl4 = new wxTextCtrl(Panel1, ID_TEXTCTRL4, _("Power"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL4"));
- BoxSizer2->Add(TextCtrl4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- BoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
- Button1 = new wxButton(Panel1, ID_BUTTON1, _("Ok"), wxDefaultPosition, wxSize(116,52), 0, wxDefaultValidator, _T("ID_BUTTON1"));
- BoxSizer3->Add(Button1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- Button2 = new wxButton(Panel1, ID_BUTTON2, _("Cancel"), wxDefaultPosition, wxSize(116,49), 0, wxDefaultValidator, _T("ID_BUTTON2"));
- BoxSizer3->Add(Button2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- BoxSizer2->Add(BoxSizer3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- Panel1->SetSizer(BoxSizer2);
- BoxSizer2->SetSizeHints(Panel1);
- BoxSizer1->Add(Panel1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
- SetSizer(BoxSizer1);
- BoxSizer1->SetSizeHints(this);
- Connect(ID_TEXTCTRL1,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&RobotCGenFrame::OnTextCtrl1Text);
- Connect(ID_TEXTCTRL2,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&RobotCGenFrame::OnTextCtrl2Text);
- Connect(ID_TEXTCTRL3,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&RobotCGenFrame::OnTextCtrl3Text);
- Connect(ID_TEXTCTRL4,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&RobotCGenFrame::OnTextCtrl4Text);
- Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&RobotCGenFrame::OnButton1Click);
- Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&RobotCGenFrame::OnButton2Click);
- //*)
- }
- RobotCGenFrame::~RobotCGenFrame()
- {
- //(*Destroy(RobotCGenFrame)
- //*)
- }
- void RobotCGenFrame::OnQuit(wxCommandEvent& event)
- {
- Close();
- }
- void RobotCGenFrame::OnAbout(wxCommandEvent& event)
- {
- wxString msg = wxbuildinfo(long_f);
- wxMessageBox(msg, _("Welcome to..."));
- }
- wxString input;
- wxString motor;
- wxString special;
- wxString power;
- void RobotCGenFrame::OnButton1Click(wxCommandEvent& event)
- {
- Close();
- if(process(input, motor, special, power) == false){
- app2.create();
- }
- }
- void RobotCGenFrame::OnTextCtrl1Text(wxCommandEvent& event)
- {
- input = TextCtrl1->GetValue();
- }
- void RobotCGenFrame::OnTextCtrl2Text(wxCommandEvent& event)
- {
- motor = TextCtrl2->GetValue();
- }
- void RobotCGenFrame::OnTextCtrl3Text(wxCommandEvent& event)
- {
- special = TextCtrl3->GetValue();
- }
- void RobotCGenFrame::OnTextCtrl4Text(wxCommandEvent& event)
- {
- power = TextCtrl4->GetValue();
- }
- void RobotCGenFrame::OnButton2Click(wxCommandEvent& event)
- {
- Close();
- std::string items = "";
- wxString wxItems(items.c_str(), wxConvUTF8);
- process(wxItems, wxItems, wxItems, wxItems);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement