Alexander Alexeev avatar Alexander Alexeev committed 0e58169

onSolveButtonClick()

Comments (0)

Files changed (4)

 	m_staticText2->Wrap( -1 );
 	bSizer3->Add( m_staticText2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
 	
-	m_targetText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_TAB|wxTAB_TRAVERSAL );
-	bSizer3->Add( m_targetText, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+	m_goalText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_TAB|wxTAB_TRAVERSAL );
+	bSizer3->Add( m_goalText, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
 	
 	bSizer2->Add( bSizer3, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
 	
 	this->Layout();
 	
 	this->Centre( wxBOTH );
+	
+	// Connect Events
+	m_solveButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( SolverFrame::onSolveButtonClick ), NULL, this );
 }
 
 SolverFrame::~SolverFrame()
 {
+	// Disconnect Events
+	m_solveButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( SolverFrame::onSolveButtonClick ), NULL, this );
 }
                                         <property name="maximum_size"></property>
                                         <property name="maxlength">0</property>
                                         <property name="minimum_size"></property>
-                                        <property name="name">m_targetText</property>
+                                        <property name="name">m_goalText</property>
                                         <property name="permission">protected</property>
                                         <property name="pos"></property>
                                         <property name="size"></property>
                                 <property name="window_extra_style"></property>
                                 <property name="window_name"></property>
                                 <property name="window_style">wxTAB_TRAVERSAL</property>
-                                <event name="OnButtonClick"></event>
+                                <event name="OnButtonClick">onSolveButtonClick</event>
                                 <event name="OnChar"></event>
                                 <event name="OnEnterWindow"></event>
                                 <event name="OnEraseBackground"></event>
 		wxStaticText* m_staticText1;
 		wxTextCtrl* m_startText;
 		wxStaticText* m_staticText2;
-		wxTextCtrl* m_targetText;
+		wxTextCtrl* m_goalText;
 		wxButton* m_solveButton;
 		wxTextCtrl* m_solutionText;
+		
+		// Virtual event handlers, overide them in your derived class
+		virtual void onSolveButtonClick( wxCommandEvent& event ) { event.Skip(); }
+		
 	
 	public:
 		
 
 IMPLEMENT_APP(SolverApp) 
 
+class AppFrame: public SolverFrame {
+  public:
+    AppFrame( wxWindow* parent ) : SolverFrame(parent) { }
+
+    void onSolveButtonClick( wxCommandEvent& event ) {
+      wxString start = this->m_startText->GetValue();
+      wxString goal = this->m_goalText->GetValue();
+      // this->m_solutionText->SetValue(...)
+      wxMessageBox(start + wxT(" ") + goal);
+    }
+};
+
 bool SolverApp::OnInit() {
   int argc = 1;
   const char* prog_name = "main";
   char** argv = const_cast<char**>(&prog_name);
   hs_init(&argc, &argv); // does support unicode?
 
-  SolverFrame *frame = new SolverFrame(NULL); 
+  AppFrame *frame = new AppFrame(NULL); 
   frame->Show(TRUE); 
   this->SetTopWindow(frame); 
   return TRUE; 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.