/////////////////////////////////////////////////////////////////////////////
// Name:        myframe.cpp	(generated and maintained by wxWorkshop's RAD)
// Purpose:     
// Author:      
// Modified by:
// Created:     02/17/01
// RCS-ID:      $ Id$
// Copyright:   (c) 
// Licence:   	
/////////////////////////////////////////////////////////////////////////////


// %%INFO-{
// { TEMPL = "wxFrame for C++" WND_RES = "MyFrameRes" MENU_RES = "" DECL_FILE = "myframe.h" CLASS = "MyFrame" RES_FILE = "demo.xrc" }
// %%INFO-}

#ifdef __GNUG__
    #pragma implementation "myframe.cpp"
    #pragma interface "myframe.h"
#endif

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif

#include "myframe.h"
#include "wx/xml/xmlres.h"
#include "wx/wspp/init.h"



/***** Implementation for class MyFrame *****/

IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )

BEGIN_EVENT_TABLE( MyFrame, wxFrame )

// %%EVT_TBL-{
	EVT_BUTTON( XMLID("hello"), MyFrame::OnButtonHello )
	EVT_BUTTON( XMLID("goodbye"), MyFrame::OnButtonGoodbye )
	EVT_TEXT_ENTER( XMLID("yourname"), MyFrame::OnTextEnterYourname )
	EVT_INIT_DIALOG( MyFrame::OnInitDialog )
	EVT_BUTTON( XMLID("quit"), MyFrame::OnButtonQuit )
// %%EVT_TBL-}

END_EVENT_TABLE()

MyFrame::MyFrame()

	: wxFrame()
{   
	int o = 0;
	++o;
}

MyFrame::~MyFrame()
{      
}

// %%EVT_IMPS-{

void MyFrame::OnButtonHello( wxCommandEvent& event )
{                         
	ExchangeValues( FALSE ); // receive control-values back to class-members
	wxMessageBox( "Hello " + m_Myname );
}

void MyFrame::OnButtonGoodbye( wxCommandEvent& event )
{                           
	m_Myname = "cleared";
	m_Yourname = "cleared too";
	ExchangeValues( TRUE ); // put class-member values back to controls
	
	wxMessageBox( "Cleared!" );
}

void MyFrame::OnTextEnterYourname( wxCommandEvent& event )
{                               
	wxMessageBox( "Text chagned!" );
}

void MyFrame::OnInitDialog( wxInitDialogEvent& event )
{            
	SetBackgroundColour( 
		wxSystemSettings::GetSystemColour( wxSYS_COLOUR_3DFACE ) );
		
	DoInit();
}

void MyFrame::OnButtonQuit( wxCommandEvent& event )
{
	Close();
}
// %%EVT_IMPS-}

// %%GETTER_IMPLS-{
const wxString& MyFrame::GetMyname() const
{ return m_Myname; }

const wxString& MyFrame::GetYourname() const
{ return m_Yourname; }

// %%GETTER_IMPLS-}

// %%SETTER_IMPLS-{
void MyFrame::SetMyname( const wxString& value )
{ m_Myname = value; }

void MyFrame::SetYourname( const wxString& value )
{ m_Yourname = value; }

// %%SETTER_IMPLS-}

/*** protected members ***/

void MyFrame::DoInit()
{
	// %%MEMBER_INITS-{
	m_Myname = _("");
	m_Yourname = _("Mark");
	// %%MEMBER_INITS-}

	// %%CTL_MEMBER_INITS-{
	m_pHello = (wxButton*)wxXmlFindWindow( "hello", this );
	m_pGoodbye = (wxButton*)wxXmlFindWindow( "goodbye", this );
	m_pMyname = (wxTextCtrl*)wxXmlFindWindow( "myname", this );
	m_pYourname = (wxTextCtrl*)wxXmlFindWindow( "yourname", this );
	m_pNotebook1 = (wxNotebook*)wxXmlFindWindow( "notebook1", this );
	m_pPanel2 = (wxPanel*)wxXmlFindWindow( "panel2", this );
	m_pButton1 = (wxButton*)wxXmlFindWindow( "button1", this );
	// %%CTL_MEMBER_INITS-}
	
	ExchangeValues( TRUE );	
}

void MyFrame::ExchangeValues( bool toControls )
{
	if ( toControls )
	{
	// %%MEMBER_VALUES_TO_CTL-{
	m_pMyname->SetValue( m_Myname );
	m_pYourname->SetValue( m_Yourname );
	// %%MEMBER_VALUES_TO_CTL-}
	}
	else
	{
	// %%CTL_VALUES_TO_MEMBER-{
	m_Myname = m_pMyname->GetValue();
	m_Yourname = m_pYourname->GetValue();
	// %%CTL_VALUES_TO_MEMBER-}
	}
}