Advertisement
asqapro

RobotCgen - gui

Jul 10th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.63 KB | None | 0 0
  1. /***************************************************************
  2.  * Name:      RobotCGenMain.cpp
  3.  * Purpose:   Code for Application Frame
  4.  * Author:    Jeff Goldman
  5.  * Created:   2013-07-08
  6.  * Copyright: Jeff Goldman
  7.  * License:
  8.  **************************************************************/
  9.  
  10. #include <vector>
  11. #include <string>
  12.  
  13. #include "RobotCGenMain.h"
  14. #include "RobotCGenApp.h"
  15. #include <wx/msgdlg.h>
  16. #include <wx/app.h>
  17.  
  18. //(*InternalHeaders(RobotCGenFrame)
  19. #include <wx/intl.h>
  20. #include <wx/string.h>
  21. //*)
  22.  
  23. RobotCGenApp app2;
  24.  
  25. //helper functions
  26. enum wxbuildinfoformat {
  27.     short_f, long_f };
  28.  
  29. wxString wxbuildinfo(wxbuildinfoformat format)
  30. {
  31.     wxString wxbuild(wxVERSION_STRING);
  32.  
  33.     if (format == long_f )
  34.     {
  35. #if defined(__WXMSW__)
  36.         wxbuild << _T("-Windows");
  37. #elif defined(__UNIX__)
  38.         wxbuild << _T("-Linux");
  39. #endif
  40.  
  41. #if wxUSE_UNICODE
  42.         wxbuild << _T("-Unicode build");
  43. #else
  44.         wxbuild << _T("-ANSI build");
  45. #endif // wxUSE_UNICODE
  46.     }
  47.  
  48.     return wxbuild;
  49. }
  50.  
  51. //(*IdInit(RobotCGenFrame)
  52. const long RobotCGenFrame::ID_TEXTCTRL1 = wxNewId();
  53. const long RobotCGenFrame::ID_TEXTCTRL2 = wxNewId();
  54. const long RobotCGenFrame::ID_TEXTCTRL3 = wxNewId();
  55. const long RobotCGenFrame::ID_TEXTCTRL4 = wxNewId();
  56. const long RobotCGenFrame::ID_BUTTON1 = wxNewId();
  57. const long RobotCGenFrame::ID_BUTTON2 = wxNewId();
  58. const long RobotCGenFrame::ID_PANEL1 = wxNewId();
  59. //*)
  60.  
  61. BEGIN_EVENT_TABLE(RobotCGenFrame,wxFrame)
  62.     //(*EventTable(RobotCGenFrame)
  63.     //*)
  64. END_EVENT_TABLE()
  65.  
  66. RobotCGenFrame::RobotCGenFrame(wxWindow* parent,wxWindowID id)
  67. {
  68.     //(*Initialize(RobotCGenFrame)
  69.     wxBoxSizer* BoxSizer2;
  70.     wxBoxSizer* BoxSizer1;
  71.     wxBoxSizer* BoxSizer3;
  72.  
  73.     Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
  74.     SetClientSize(wxSize(952,135));
  75.     BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
  76.     Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxSize(241,203), wxTAB_TRAVERSAL, _T("ID_PANEL1"));
  77.     BoxSizer2 = new wxBoxSizer(wxVERTICAL);
  78.     TextCtrl1 = new wxTextCtrl(Panel1, ID_TEXTCTRL1, _("Button/ Joystick"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
  79.     BoxSizer2->Add(TextCtrl1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  80.     TextCtrl2 = new wxTextCtrl(Panel1, ID_TEXTCTRL2, _("Motor Name"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
  81.     BoxSizer2->Add(TextCtrl2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  82.     TextCtrl3 = new wxTextCtrl(Panel1, ID_TEXTCTRL3, _("Special"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL3"));
  83.     BoxSizer2->Add(TextCtrl3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  84.     TextCtrl4 = new wxTextCtrl(Panel1, ID_TEXTCTRL4, _("Power"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL4"));
  85.     BoxSizer2->Add(TextCtrl4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  86.     BoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
  87.     Button1 = new wxButton(Panel1, ID_BUTTON1, _("Ok"), wxDefaultPosition, wxSize(116,52), 0, wxDefaultValidator, _T("ID_BUTTON1"));
  88.     BoxSizer3->Add(Button1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  89.     Button2 = new wxButton(Panel1, ID_BUTTON2, _("Cancel"), wxDefaultPosition, wxSize(116,49), 0, wxDefaultValidator, _T("ID_BUTTON2"));
  90.     BoxSizer3->Add(Button2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  91.     BoxSizer2->Add(BoxSizer3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  92.     Panel1->SetSizer(BoxSizer2);
  93.     BoxSizer2->SetSizeHints(Panel1);
  94.     BoxSizer1->Add(Panel1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
  95.     SetSizer(BoxSizer1);
  96.     BoxSizer1->SetSizeHints(this);
  97.  
  98.     Connect(ID_TEXTCTRL1,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&RobotCGenFrame::OnTextCtrl1Text);
  99.     Connect(ID_TEXTCTRL2,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&RobotCGenFrame::OnTextCtrl2Text);
  100.     Connect(ID_TEXTCTRL3,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&RobotCGenFrame::OnTextCtrl3Text);
  101.     Connect(ID_TEXTCTRL4,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&RobotCGenFrame::OnTextCtrl4Text);
  102.     Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&RobotCGenFrame::OnButton1Click);
  103.     Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&RobotCGenFrame::OnButton2Click);
  104.     //*)
  105. }
  106.  
  107. RobotCGenFrame::~RobotCGenFrame()
  108. {
  109.     //(*Destroy(RobotCGenFrame)
  110.     //*)
  111. }
  112.  
  113. void RobotCGenFrame::OnQuit(wxCommandEvent& event)
  114. {
  115.     Close();
  116. }
  117.  
  118. void RobotCGenFrame::OnAbout(wxCommandEvent& event)
  119. {
  120.     wxString msg = wxbuildinfo(long_f);
  121.     wxMessageBox(msg, _("Welcome to..."));
  122. }
  123.  
  124. wxString input;
  125. wxString motor;
  126. wxString special;
  127. wxString power;
  128.  
  129. void RobotCGenFrame::OnButton1Click(wxCommandEvent& event)
  130. {
  131.     Close();
  132.     if(process(input, motor, special, power) == false){
  133.         app2.create();
  134.     }
  135. }
  136.  
  137. void RobotCGenFrame::OnTextCtrl1Text(wxCommandEvent& event)
  138. {
  139.     input = TextCtrl1->GetValue();
  140. }
  141.  
  142. void RobotCGenFrame::OnTextCtrl2Text(wxCommandEvent& event)
  143. {
  144.     motor = TextCtrl2->GetValue();
  145. }
  146.  
  147. void RobotCGenFrame::OnTextCtrl3Text(wxCommandEvent& event)
  148. {
  149.     special = TextCtrl3->GetValue();
  150. }
  151.  
  152. void RobotCGenFrame::OnTextCtrl4Text(wxCommandEvent& event)
  153. {
  154.     power = TextCtrl4->GetValue();
  155. }
  156.  
  157. void RobotCGenFrame::OnButton2Click(wxCommandEvent& event)
  158. {
  159.     Close();
  160.     std::string items = "";
  161.     wxString wxItems(items.c_str(), wxConvUTF8);
  162.     process(wxItems, wxItems, wxItems, wxItems);
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement