home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Learn 3D Graphics Programming on the PC
/
Learn_3D_Graphics_Programming_on_the_PC_Ferraro.iso
/
rwwin
/
rwmfc.cp_
/
rwmfc.bin
Wrap
Text File
|
1995-11-14
|
8KB
|
301 lines
// rwmfc.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "rwmfc.h"
#include "mainfrm.h"
#include "rwmfcdoc.h"
#include "rwmfcvw.h"
#include <rwlib.h>
#include <rwwin31.h>
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRwApp
BEGIN_MESSAGE_MAP(CRwApp, CWinApp)
//{{AFX_MSG_MAP(CRwApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_UPDATE_COMMAND_UI(ID_DEBUGGING_APIS, OnUpdateDebuggingApis)
ON_UPDATE_COMMAND_UI(ID_DEBUGGING_ASSERTIONS, OnUpdateDebuggingAssertions)
ON_UPDATE_COMMAND_UI(ID_DEBUGGING_MESSAGES, OnUpdateDebuggingMessages)
ON_UPDATE_COMMAND_UI(ID_DEBUGGING_SCRIPTS, OnUpdateDebuggingScripts)
ON_COMMAND(ID_DEBUGGING_APIS, OnDebuggingApis)
ON_COMMAND(ID_DEBUGGING_ASSERTIONS, OnDebuggingAssertions)
ON_COMMAND(ID_DEBUGGING_MESSAGES, OnDebuggingMessages)
ON_COMMAND(ID_DEBUGGING_SCRIPTS, OnDebuggingScripts)
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRwApp construction
CRwApp::CRwApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CRwApp object
CRwApp NEAR theApp;
/////////////////////////////////////////////////////////////////////////////
// CRwApp initialization
BOOL CRwApp::InitInstance()
{
// Open RenderWare first as there is little point doint anything else if
// RenderWare is not available.
if (!::RwOpen("MSWindows", NULL))
{
// Should really do some error handling here to discover why, but for
// now we will just flag the error and quit.
AfxMessageBox("RenderWare could not be opened", MB_OK | MB_APPLMODAL | MB_ICONSTOP);
return FALSE;
}
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
SetDialogBkColor(); // Set dialog background color to gray
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_RWXTYPE,
RUNTIME_CLASS(CRwDoc),
RUNTIME_CLASS(CMDIChildWnd), // standard MDI child frame
RUNTIME_CLASS(CRwView));
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// enable file manager drag/drop and DDE Execute open
EnableShellOpen();
RegisterShellFileTypes();
// simple command line parsing
if (m_lpCmdLine[0] == '\0')
{
// create a new (empty) document
OnFileNew();
}
else
{
// open an existing document
OpenDocumentFile(m_lpCmdLine);
}
m_pMainWnd->DragAcceptFiles();
// The main window has been initialized, so show and update it.
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
int CRwApp::ExitInstance()
{
// Close RenderWare down.
::RwClose();
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// Implementation
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CRwApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CRwApp commands
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
return TRUE;
}
void CRwApp::OnUpdateDebuggingApis(CCmdUI* pCmdUI)
{
RwBool isDebugging;
::RwGetSystemInfo(rwDEBUGGINGLIB, &isDebugging, sizeof(isDebugging));
if (isDebugging)
{
pCmdUI->Enable();
if (::RwGetDebugTraceState() == rwENABLE)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
else
{
pCmdUI->Enable(FALSE);
pCmdUI->SetCheck(0);
}
}
void CRwApp::OnUpdateDebuggingAssertions(CCmdUI* pCmdUI)
{
RwBool isDebugging;
::RwGetSystemInfo(rwDEBUGGINGLIB, &isDebugging, sizeof(isDebugging));
if (isDebugging)
{
pCmdUI->Enable();
if (::RwGetDebugAssertionState() == rwENABLE)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
else
{
pCmdUI->Enable(FALSE);
pCmdUI->SetCheck(0);
}
}
void CRwApp::OnUpdateDebuggingMessages(CCmdUI* pCmdUI)
{
RwBool isDebugging;
::RwGetSystemInfo(rwDEBUGGINGLIB, &isDebugging, sizeof(isDebugging));
if (isDebugging)
{
pCmdUI->Enable();
if (::RwGetDebugMessageState() == rwENABLE)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
else
{
pCmdUI->Enable(FALSE);
pCmdUI->SetCheck(0);
}
}
void CRwApp::OnUpdateDebuggingScripts(CCmdUI* pCmdUI)
{
RwBool isDebugging;
::RwGetSystemInfo(rwDEBUGGINGLIB, &isDebugging, sizeof(isDebugging));
if (isDebugging)
{
pCmdUI->Enable();
if (::RwGetDebugScriptState() == rwENABLE)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
else
{
pCmdUI->Enable(FALSE);
pCmdUI->SetCheck(0);
}
}
void CRwApp::OnDebuggingApis()
{
// Toggle API level function tracing.
if (::RwGetDebugTraceState() == rwENABLE)
::RwSetDebugTraceState(rwDISABLE);
else
::RwSetDebugTraceState(rwENABLE);
}
void CRwApp::OnDebuggingAssertions()
{
// Toggle assertion failure messages.
if (::RwGetDebugAssertionState() == rwENABLE)
::RwSetDebugAssertionState(rwDISABLE);
else
::RwSetDebugAssertionState(rwENABLE);
}
void CRwApp::OnDebuggingMessages()
{
// Toggle informational messages.
if (::RwGetDebugMessageState() == rwENABLE)
::RwSetDebugMessageState(rwDISABLE);
else
::RwSetDebugMessageState(rwENABLE);
}
void CRwApp::OnDebuggingScripts()
{
// Toggle script trace messages.
if (::RwGetDebugScriptState() == rwENABLE)
::RwSetDebugScriptState(rwDISABLE);
else
::RwSetDebugScriptState(rwENABLE);
}