diff src/mask.cpp @ 1:7b6dab24f4b8

Gui parts complete.
author pyon@macmini
date Sun, 04 Aug 2013 21:42:49 +0900
parents 0c0701a935f8
children c066fde99517
line wrap: on
line diff
--- a/src/mask.cpp	Sun Jul 21 16:07:19 2013 +0900
+++ b/src/mask.cpp	Sun Aug 04 21:42:49 2013 +0900
@@ -1,5 +1,5 @@
 // Filename   : mask.cpp
-// Last Change: 21-Jul-2013.
+// Last Change: 04-Aug-2013.
 //
 
 #include "mask.h"
@@ -93,67 +93,63 @@
 	this->Layout();
 	
 	this->Centre( wxBOTH );
-
-    conf_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("app.conf");
-    config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
-
-    GetParams();
 }
 
 MaskDialog::~MaskDialog()
 {
-    delete config;
 }
 
 // Event Table
 BEGIN_EVENT_TABLE( MaskDialog, wxDialog )
-    EVT_BUTTON( ID_SETPARAM, MaskDialog::SetParams )
+    EVT_BUTTON( ID_SETPARAM, MaskDialog::OnSet )
 END_EVENT_TABLE()
 
-void MaskDialog::GetParams( void )
+// Event Handlers & Functions
+void MaskDialog::OnSet( wxCommandEvent& WXUNUSED(event) )
 {
-    wxString x, y, w, h;
-
-    config->SetPath( wxT("/Mask") );
-
-    config->Read( wxT("x1"), &x );
-    config->Read( wxT("y1"), &y );
-    config->Read( wxT("w1"), &w );
-    config->Read( wxT("h1"), &h );
-
-	m_textCtrlM1x->SetValue( x );
-	m_textCtrlM1y->SetValue( y );
-	m_textCtrlM1w->SetValue( w );
-	m_textCtrlM1h->SetValue( h );
+    wxString buf;
+    buf = m_textCtrlM1x->GetValue(); buf.ToLong( &x, 10 );
+    buf = m_textCtrlM1y->GetValue(); buf.ToLong( &y, 10 );
+    buf = m_textCtrlM1w->GetValue(); buf.ToLong( &w, 10 );
+    buf = m_textCtrlM1h->GetValue(); buf.ToLong( &h, 10 );
+    m_mask1.SetPosition( wxPoint( x, y ) ); 
+    m_mask1.SetSize( wxSize( w, h ) ); 
 
-    config->Read( wxT("x2"), &x );
-    config->Read( wxT("y2"), &y );
-    config->Read( wxT("w2"), &w );
-    config->Read( wxT("h2"), &h );
-
-	m_textCtrlM2x->SetValue( x );
-	m_textCtrlM2y->SetValue( y );
-	m_textCtrlM2w->SetValue( w );
-	m_textCtrlM2h->SetValue( h );
+    buf = m_textCtrlM2x->GetValue(); buf.ToLong( &x, 10 );
+    buf = m_textCtrlM2y->GetValue(); buf.ToLong( &y, 10 );
+    buf = m_textCtrlM2w->GetValue(); buf.ToLong( &w, 10 );
+    buf = m_textCtrlM2h->GetValue(); buf.ToLong( &h, 10 );
+    m_mask2.SetPosition( wxPoint( x, y ) ); 
+    m_mask2.SetSize( wxSize( w, h ) ); 
 
-    config->Read( wxT("x3"), &x );
-    config->Read( wxT("y3"), &y );
-    config->Read( wxT("w3"), &w );
-    config->Read( wxT("h3"), &h );
+    buf = m_textCtrlM3x->GetValue(); buf.ToLong( &x, 10 );
+    buf = m_textCtrlM3y->GetValue(); buf.ToLong( &y, 10 );
+    buf = m_textCtrlM3w->GetValue(); buf.ToLong( &w, 10 );
+    buf = m_textCtrlM3h->GetValue(); buf.ToLong( &h, 10 );
+    m_mask3.SetPosition( wxPoint( x, y ) ); 
+    m_mask3.SetSize( wxSize( w, h ) ); 
 
-	m_textCtrlM3x->SetValue( x );
-	m_textCtrlM3y->SetValue( y );
-	m_textCtrlM3w->SetValue( w );
-	m_textCtrlM3h->SetValue( h );
+    if ( IsModal() ) 
+        EndModal( wxID_OK );
+    else {
+        SetReturnCode( wxID_OK );
+        Show( false );
+    }
 }
 
-void MaskDialog::SetParams( wxCommandEvent& WXUNUSED(event) )
+void MaskDialog::LoadParams( void )
 {
-    config->SetPath( wxT("/Mask") );
-
-    config->Write( wxT("h3"), m_textCtrlM3h->GetValue() );
-    config->Flush();
-
-    Close();
+    m_textCtrlM1x->SetValue( wxString::Format( wxT("%d"), m_mask1.GetX() ) );
+    m_textCtrlM1y->SetValue( wxString::Format( wxT("%d"), m_mask1.GetY() ) );
+    m_textCtrlM1w->SetValue( wxString::Format( wxT("%d"), m_mask1.GetWidth() ) );
+    m_textCtrlM1h->SetValue( wxString::Format( wxT("%d"), m_mask1.GetHeight() ) );
+    m_textCtrlM2x->SetValue( wxString::Format( wxT("%d"), m_mask2.GetX() ) );
+    m_textCtrlM2y->SetValue( wxString::Format( wxT("%d"), m_mask2.GetY() ) );
+    m_textCtrlM2w->SetValue( wxString::Format( wxT("%d"), m_mask2.GetWidth() ) );
+    m_textCtrlM2h->SetValue( wxString::Format( wxT("%d"), m_mask2.GetHeight() ) );
+    m_textCtrlM3x->SetValue( wxString::Format( wxT("%d"), m_mask3.GetX() ) );
+    m_textCtrlM3y->SetValue( wxString::Format( wxT("%d"), m_mask3.GetY() ) );
+    m_textCtrlM3w->SetValue( wxString::Format( wxT("%d"), m_mask3.GetWidth() ) );
+    m_textCtrlM3h->SetValue( wxString::Format( wxT("%d"), m_mask3.GetHeight() ) );
 }