INT32 InformError(UINT32 ErrorMsg, UINT32 Butt1, UINT32 Butt2, UINT32 Butt3, UINT32 Butt4, UINT32 OK, UINT32 Cancel) { return InformGeneral(ERRORTYPE_ERROR, 0, ErrorMsg, Butt1, Butt2, Butt3, Butt4, OK, Cancel); }
INT32 InformGeneral(UINT32 Error, ErrorInfo* pInfo, UINT32 ModID) { if (!pInfo) return _R(IDS_OK); // Catch this early INT32 num = InformGeneral(Error,ModID, pInfo->ErrorMsg, pInfo->Button[0],pInfo->Button[1],pInfo->Button[2],pInfo->Button[3], pInfo->OK,pInfo->Cancel); return num?pInfo->Button[num-1]:_R(IDS_OK); }
UINT32 ToolAskQuestion(UINT32 ToolID, UINT32 ErrorMsg, UINT32 Butt1, UINT32 Butt2, UINT32 Butt3, UINT32 Butt4, UINT32 OK, UINT32 Cancel) { return InformGeneral(ERRORTYPE_QUESTION, Tool::GetModuleID(ToolID), ErrorMsg, Butt1, Butt2, Butt3, Butt4, OK, Cancel); }
INT32 ModuleInformWarning(UINT32 ModID, ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_WARNING, pInfo, ModID); }
INT32 ModuleInformMessage(UINT32 ModID, ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_NORMAL, pInfo, ModID); }
INT32 InformMessage(ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_NORMAL, pInfo); }
INT32 ToolInformMessage(UINT32 ToolID, UINT32 ErrorMsg, UINT32 Butt1, UINT32 Butt2, UINT32 Butt3, UINT32 Butt4, UINT32 OK, UINT32 Cancel) { return InformGeneral(ERRORTYPE_NORMAL, Tool::GetModuleID(ToolID), ErrorMsg, Butt1, Butt2, Butt3, Butt4, OK, Cancel); }
INT32 ToolAskQuestion(UINT32 ToolID, ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_QUESTION, pInfo, Tool::GetModuleID(ToolID)); }
INT32 ToolInformSeriousError(UINT32 ToolID, ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_SERIOUS, pInfo, Tool::GetModuleID(ToolID)); }
INT32 InformSeriousError(ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_SERIOUS, pInfo); }
INT32 ModuleInformSeriousError(UINT32 ModID, UINT32 ErrorMsg, UINT32 Butt1, UINT32 Butt2, UINT32 Butt3, UINT32 Butt4, UINT32 OK, UINT32 Cancel) { return InformGeneral(ERRORTYPE_SERIOUS, ModID, ErrorMsg, Butt1, Butt2, Butt3, Butt4, OK, Cancel); }
INT32 ToolInformSeriousError(UINT32 ToolID, UINT32 ErrorMsg, UINT32 Butt1, UINT32 Butt2, UINT32 Butt3, UINT32 Butt4, UINT32 OK, UINT32 Cancel) { return InformGeneral(ERRORTYPE_SERIOUS, Tool::GetModuleID(ToolID), ErrorMsg, Butt1, Butt2, Butt3, Butt4, OK, Cancel); }
INT32 ModuleInformError(UINT32 ModID, ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_ERROR, pInfo, ModID); }
INT32 ToolInformError(UINT32 ToolID, ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_ERROR, pInfo, Tool::GetModuleID(ToolID)); }
INT32 InformError(ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_ERROR, pInfo); }
INT32 ModuleAskQuestion(UINT32 ModID, UINT32 ErrorMsg, UINT32 Butt1, UINT32 Butt2, UINT32 Butt3, UINT32 Butt4, UINT32 OK, UINT32 Cancel) { return InformGeneral(ERRORTYPE_QUESTION, ModID, ErrorMsg, Butt1, Butt2, Butt3, Butt4, OK, Cancel); }
INT32 AskQuestion(ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_QUESTION, pInfo); }
INT32 ModuleInformSeriousError(UINT32 ModID, ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_SERIOUS, pInfo, ModID); }
INT32 ModuleAskQuestion(UINT32 ModID, ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_QUESTION, pInfo, ModID); }
INT32 ToolInformWarning(UINT32 ToolID, UINT32 ErrorMsg, UINT32 Butt1, UINT32 Butt2, UINT32 Butt3, UINT32 Butt4, UINT32 OK, UINT32 Cancel) { return InformGeneral(ERRORTYPE_WARNING, Tool::GetModuleID(ToolID), ErrorMsg, Butt1, Butt2, Butt3, Butt4, OK, Cancel); }
INT32 ModuleInformMessage(UINT32 ModID, UINT32 ErrorMsg, UINT32 Butt1, UINT32 Butt2, UINT32 Butt3, UINT32 Butt4, UINT32 OK, UINT32 Cancel) { return InformGeneral(ERRORTYPE_NORMAL, ModID, ErrorMsg, Butt1, Butt2, Butt3, Butt4, OK, Cancel); }
INT32 ModuleInformWarning(UINT32 ModID, UINT32 ErrorMsg, UINT32 Butt1, UINT32 Butt2, UINT32 Butt3, UINT32 Butt4, UINT32 OK, UINT32 Cancel) { return InformGeneral(ERRORTYPE_WARNING, ModID, ErrorMsg, Butt1, Butt2, Butt3, Butt4, OK, Cancel); }
INT32 ToolInformMessage(UINT32 ToolID, ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_NORMAL, pInfo, Tool::GetModuleID(ToolID)); }
INT32 InformWarning(ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_WARNING, pInfo); }
INT32 ToolInformWarning(UINT32 ToolID, ErrorInfo *pInfo) { return InformGeneral(ERRORTYPE_WARNING, pInfo, Tool::GetModuleID(ToolID)); }
static void InternalAssert(const TCHAR * AssertDescription, const char * lpszFileName, INT32 nLine, BOOL UseMFC) { if (!UseMFC) #if defined(__WXMSW__) MessageBeep(MB_ICONASTERISK); #else ::wxBell(); #endif #ifdef _ENSURES TCHAR sz[256]; static TCHAR BASED_CODE szTitle[] = wxT("Ensure Failed!"); // In Unicode we need to convert the filename to TCHAR #if 0 != wxUSE_UNICODE TCHAR szRealFile[256]; size_t count = camMbstowcs(szRealFile, lpszFileName, 255); if (count == (size_t)-1) count = 0; szRealFile[count] = (TCHAR)0; const TCHAR* lpszRealFile = szRealFile; #else const TCHAR* lpszRealFile = lpszFileName; #endif static TCHAR BASED_CODE szMessage[] = wxT("%s, File %s, Line %d"); static TCHAR BASED_CODE szMessageNoReason[] = wxT("Error %d@%s"); // note number first // get app name or NULL if unknown (don't call assert) // const TCHAR *pszAppName = wxGetApp().GetAppName(); if (AssertDescription != NULL) { camSnprintf(sz, 255, szMessage, AssertDescription, lpszRealFile, nLine); } else { camSnprintf(sz, 255, szMessageNoReason, nLine, lpszRealFile); } #ifdef _DEBUG //PORTNOTE("other","Remove afxTraceEnabled") //#ifndef EXCLUDE_FROM_XARALX // if (afxTraceEnabled) #if defined(__WXMSW__) { // assume the debugger or auxiliary port #ifndef _MAC ::OutputDebugString(sz); ::OutputDebugString(_T(", ")); ::OutputDebugString(szTitle); ::OutputDebugString(_T("\n\r")); #else // Mac version needs them all together camStrcat(sz, _T(", ")); camStrcat(sz,szTitle); camStrcat(sz,_T("\n\r")); ::OutputDebugString(sz); #endif } #endif #endif if (AssertBusy > 0) { // getting assertion while inside an assertion // - it has already been traced, but // break into the debugger (or Dr Watson log) DEBUGBREAK; // else Win32s might die (just beeps) return; } AssertBusy++; if ( Error::IsInRenderThread() ) { TRACE( wxT("In RenderThread so clearing up system") ); Error::RenderThreadReset(); // Commented out - no problem using wx for render errors // UseMFC = FALSE; // mustn't use MFC for render errors } INT32 result; TCHAR RealErrorMsg[256]; if (UseMFC) { // use our error handler to report ensures as it is more robust instead of MessageBox // The arrangement of buttons is the same as the exception handler dialog, not the same // as the original Ensure dialog (which was Abort/Retry/Ignore) ErrorInfo Info; // try to preserve original error message camStrcpy( RealErrorMsg, Error::GetErrorString() ); Error::SetErrorSerious( sz ); // set error msg (vaping any previous one) Info.ErrorMsg = 0; Info.Button[0] = _R(IDS_CONTINUE); Info.Button[1] = _R(IDS_QUIT); #ifndef EXCLUDE_FROM_XARALX if (IsWin32NT()) { #endif // only NT can cope with an Abort button Info.Button[2] = _R(IDS_ABORT); Info.Button[3] = _R(IDS_DEBUG); #ifndef EXCLUDE_FROM_XARALX } else { Info.Button[2] = _R(IDS_DEBUG); } #endif // no default button (or Help) Info.Cancel = 1; // Esc = Continue result = InformGeneral( ERRORTYPE_ENSURE, &Info ); } else { CamResource::DoneInit(); CCamApp::DisableSystem(); // e.g. if this an MFC assert, don't use our lovely error handler becuase that itself // uses MFC. Instead we use good old MessageBox #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) wxWindow *pParent = AfxGetApp().GetTopWindow(); PORTNOTE("other","Use CInformErrorDialog::GetSafeParent() when implemented") #ifndef EXCLUDE_FROM_XARALX CInformErrorDialog::GetSafeParent(); #endif #else wxWindow *pParent = NULL; #endif wxMessageDialog Dialog( pParent, sz, szTitle, wxICON_HAND | wxYES_NO | wxCANCEL ); INT32 nCode = Dialog.ShowModal(); CCamApp::EnableSystem(); // convert MessageBox return value into a sane button ID switch (nCode) { case wxID_NO: result = _R(IDS_ABORT); break; case wxID_YES: result = _R(IDS_DEBUG); break; case wxID_CANCEL: default: result = _R(IDS_CONTINUE); break; } } AssertBusy--; if ((ResourceID)result == _R(IDS_DEBUG)) { DEBUGBREAK; } // no action on _R(IDS_CONTINUE)) else if ((ResourceID)result == _R(IDS_QUIT)) { // quit in a slightly nice way wxWindow *MainWnd = AfxGetApp().GetTopWindow(); if( MainWnd && MainWnd->IsShown() ) { MainWnd->Destroy(); } } // drop through if (((ResourceID)result == _R(IDS_ABORT)) || ((ResourceID)result == _R(IDS_QUIT))) { // if no window, try nasty exit AfxAbort(); return; // how did we get here? } // if we ever get here we just carry on as if nothing happened PORTNOTE("other","We can never use MFC again") #ifndef EXCLUDE_FROM_XARALX if (UseMFC) { if (RealErrorMsg[0]) Error::SetErrorSerious( RealErrorMsg ); // restore previous error msg else Error::ClearError(); } #endif #else // parameters not used if non-debug (void)lpszFileName; (void)nLine; #endif // _ENSURES }