home *** CD-ROM | disk | FTP | other *** search
- //========================================================================
- //
- // Error.cc
- //
- // Copyright 1996 Derek B. Noonburg
- //
- //========================================================================
- //
- // Ported to EPOC by Sander van der Wal
- //
- // $Log: Error.cpp $
- // Revision 1.2 2000-09-17 13:38:24+02 svdwal
- // Ported
- //
-
- #ifdef __GNUC__
- #pragma implementation
- #endif
-
- #ifdef __SYMBIAN32__
- # include <e32def.h>
- #else
- # include <stddef.h>
- # include <stdio.h>
- #endif
-
- #include <stdarg.h>
-
- #include "gtypes.h"
- #include "Error.h"
-
- #include <eikdialg.h>
- #include "pdf.hrh"
- #include "Pdf.rsg"
-
- // report errors in C code
- extern "C" void C_error(TInt msg);
-
- void C_error(TInt msg)
- {
- error(-1, msg);
- }
-
-
- class CErrorDialog : public CEikDialog
- {
- public:
- CErrorDialog(TInt aPos, TInt aResourceId, VA_LIST args);
-
- // -- CEikDialog
- private:
- void PreLayoutDynInitL();
- TBool OkToExitL(TInt aKeycode);
-
- private:
- TBuf<32> iTitle;
- TPtrC iTitlePtr;
- TBuf<256> iMsg;
- TPtrC iMsgPtr;
- };
-
-
- CErrorDialog::CErrorDialog(TInt aPos, TInt aResourceId, VA_LIST args)
- {
- if (aPos >= 0)
- iCoeEnv->Format128(iTitle, R_ERROR_AT, aPos);
- else
- iCoeEnv->Format128(iTitle, R_ERROR);
- iTitlePtr.Set(iTitle);
-
- HBufC* fmt = 0;
- TRAPD(error, fmt = iCoeEnv->AllocReadResourceL(aResourceId));
- if (!error) {
- iMsg.FormatList(*fmt, args);
- delete fmt;
- }
- iMsgPtr.Set(iMsg);
- }
-
-
- void CErrorDialog::PreLayoutDynInitL()
- {
- SetTitleL(iTitlePtr);
- SetEdwinTextL(EErrorDialogMessage, &iMsgPtr);
- }
-
-
- TBool CErrorDialog::OkToExitL(TInt /*aKeycode*/)
- {
- return ETrue;
- }
-
- void CDECL error(int aPos, int aResourceId, ...)
- {
- VA_LIST args;
- VA_START(args, aResourceId);
- error(aPos, aResourceId, args);
- VA_END(args);
- }
-
- void CDECL error(int aPos, int aResourceId, VA_LIST args)
- {
- #ifndef OOM // bad interactions
- CErrorDialog* dialog = new(ELeave) CErrorDialog(aPos, aResourceId, args);
- dialog->ExecuteLD(R_ERROR_DIALOG);
- #endif
- }
-