git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15270 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
		
			
				
	
	
		
			144 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			144 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/////////////////////////////////////////////////////////////////////////////
 | 
						|
// Name:        test.cpp
 | 
						|
// Author:      XX
 | 
						|
// Created:     XX/XX/XX
 | 
						|
// Copyright:   
 | 
						|
/////////////////////////////////////////////////////////////////////////////
 | 
						|
 | 
						|
#ifdef __GNUG__
 | 
						|
    #pragma implementation "test.cpp"
 | 
						|
#endif
 | 
						|
 | 
						|
// For compilers that support precompilation
 | 
						|
#include "wx/wxprec.h"
 | 
						|
 | 
						|
#ifdef __BORLANDC__
 | 
						|
    #pragma hdrstop
 | 
						|
#endif
 | 
						|
 | 
						|
// Include private headers
 | 
						|
#include "test.h"
 | 
						|
 | 
						|
// WDR: class implementations
 | 
						|
 | 
						|
//----------------------------------------------------------------------------
 | 
						|
// MyDialog
 | 
						|
//----------------------------------------------------------------------------
 | 
						|
 | 
						|
// WDR: event table for MyDialog
 | 
						|
 | 
						|
BEGIN_EVENT_TABLE(MyDialog,wxDialog)
 | 
						|
END_EVENT_TABLE()
 | 
						|
 | 
						|
MyDialog::MyDialog( wxWindow *parent, wxWindowID id, const wxString &title,
 | 
						|
    const wxPoint &position, const wxSize& size, long style ) :
 | 
						|
    wxDialog( parent, id, title, position, size, style|wxRESIZE_BORDER )
 | 
						|
{
 | 
						|
    MyDialogFunc( this, TRUE ); 
 | 
						|
    
 | 
						|
    CentreOnParent();
 | 
						|
}
 | 
						|
 | 
						|
bool MyDialog::Validate()
 | 
						|
{
 | 
						|
    return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool MyDialog::TransferDataToWindow()
 | 
						|
{
 | 
						|
    return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool MyDialog::TransferDataFromWindow()
 | 
						|
{
 | 
						|
    return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
// WDR: handler implementations for MyDialog
 | 
						|
 | 
						|
 | 
						|
//------------------------------------------------------------------------------
 | 
						|
// MyFrame
 | 
						|
//------------------------------------------------------------------------------
 | 
						|
 | 
						|
// WDR: event table for MyFrame
 | 
						|
 | 
						|
BEGIN_EVENT_TABLE(MyFrame,wxFrame)
 | 
						|
    EVT_MENU(ID_ABOUT, MyFrame::OnAbout)
 | 
						|
    EVT_MENU(ID_QUIT, MyFrame::OnQuit)
 | 
						|
    EVT_CLOSE(MyFrame::OnCloseWindow)
 | 
						|
    EVT_MENU( ID_TEST, MyFrame::OnTest )
 | 
						|
END_EVENT_TABLE()
 | 
						|
 | 
						|
MyFrame::MyFrame( wxWindow *parent, wxWindowID id, const wxString &title,
 | 
						|
    const wxPoint &position, const wxSize& size, long style ) :
 | 
						|
    wxFrame( parent, id, title, position, size, style )
 | 
						|
{
 | 
						|
    CreateMyMenuBar();
 | 
						|
    
 | 
						|
    CreateStatusBar(1);
 | 
						|
    SetStatusText( "Welcome!" );
 | 
						|
    
 | 
						|
     // insert main window here
 | 
						|
}
 | 
						|
 | 
						|
void MyFrame::CreateMyMenuBar()
 | 
						|
{
 | 
						|
#ifdef __WXMAC__
 | 
						|
    wxApp::s_macAboutMenuItemId = ID_ABOUT;
 | 
						|
#endif
 | 
						|
 | 
						|
    SetMenuBar( MyMenuBarFunc() );
 | 
						|
}
 | 
						|
 | 
						|
// WDR: handler implementations for MyFrame
 | 
						|
 | 
						|
void MyFrame::OnTest( wxCommandEvent &event )
 | 
						|
{
 | 
						|
    MyDialog dialog( this, -1, "Test" );
 | 
						|
    dialog.ShowModal();
 | 
						|
}
 | 
						|
 | 
						|
void MyFrame::OnAbout( wxCommandEvent &event )
 | 
						|
{
 | 
						|
    wxMessageDialog dialog( this, "Welcome to SuperApp 1.0\n(C)opyright Joe Hacker",
 | 
						|
        "About SuperApp", wxOK|wxICON_INFORMATION );
 | 
						|
    dialog.ShowModal();
 | 
						|
}
 | 
						|
 | 
						|
void MyFrame::OnQuit( wxCommandEvent &event )
 | 
						|
{
 | 
						|
     Close( TRUE );
 | 
						|
}
 | 
						|
 | 
						|
void MyFrame::OnCloseWindow( wxCloseEvent &event )
 | 
						|
{
 | 
						|
    // if ! saved changes -> return
 | 
						|
    
 | 
						|
    Destroy();
 | 
						|
}
 | 
						|
 | 
						|
//------------------------------------------------------------------------------
 | 
						|
// MyApp
 | 
						|
//------------------------------------------------------------------------------
 | 
						|
 | 
						|
IMPLEMENT_APP(MyApp)
 | 
						|
 | 
						|
MyApp::MyApp()
 | 
						|
{
 | 
						|
}
 | 
						|
 | 
						|
bool MyApp::OnInit()
 | 
						|
{
 | 
						|
    MyFrame *frame = new MyFrame( NULL, -1, "SuperApp", wxPoint(20,20), wxSize(500,340) );
 | 
						|
    frame->Show( TRUE );
 | 
						|
    
 | 
						|
    return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
int MyApp::OnExit()
 | 
						|
{
 | 
						|
    return 0;
 | 
						|
}
 | 
						|
 |