/Rainman2/exception_dialog.h

http://modstudio2.googlecode.com/ · C Header · 71 lines · 38 code · 9 blank · 24 comment · 0 complexity · 3b3880bb12d60ed5930cb8f8dc60991b MD5 · raw file

  1. /*
  2. Copyright (c) 2008 Peter "Corsix" Cawley
  3. Permission is hereby granted, free of charge, to any person
  4. obtaining a copy of this software and associated documentation
  5. files (the "Software"), to deal in the Software without
  6. restriction, including without limitation the rights to use,
  7. copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the
  9. Software is furnished to do so, subject to the following
  10. conditions:
  11. The above copyright notice and this permission notice shall be
  12. included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  15. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  17. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  18. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #pragma once
  23. #include "exception.h"
  24. #ifdef RAINMAN2_USE_WX
  25. #include <wx/wx.h>
  26. #include <wx/dialog.h>
  27. #include <wx/button.h>
  28. #include <wx/listctrl.h>
  29. #include <wx/statline.h>
  30. #include "exception.h"
  31. #pragma warning(push)
  32. #pragma warning(disable: 4275) // non dll-interface class used as base
  33. class RAINMAN2_API RainExceptionDialog : public wxDialog
  34. {
  35. public:
  36. RainExceptionDialog(wxWindow *parent, RainException *pException);
  37. static void show(RainException* pE, bool bDeleteException = true);
  38. void onOK(wxCommandEvent& e);
  39. void onDetails(wxCommandEvent& e);
  40. void onSave(wxCommandEvent& e);
  41. void onListSelect(wxListEvent& e);
  42. private:
  43. void _addExtraControls();
  44. wxArrayString m_aMessages;
  45. wxArrayString m_aFiles;
  46. wxArrayLong m_aLines;
  47. wxButton *m_pDetailsBtn;
  48. bool m_bShowingDetails;
  49. wxListCtrl *m_pDetailList;
  50. wxStaticLine *m_pStaticLine;
  51. wxButton *m_pSaveBtn;
  52. DECLARE_EVENT_TABLE()
  53. };
  54. #define EXCEPTION_MESSAGE_BOX(message, e) RainExceptionDialog::show(new RainException(__WFILE__, __LINE__, message, e));
  55. #define EXCEPTION_MESSAGE_BOX_1(message, a1, e) RainExceptionDialog::show(new RainException(__WFILE__, __LINE__, e, message, a1));
  56. #define CATCH_MESSAGE_BOX(message, cleanup) catch (RainException *pRainError) { EXCEPTION_MESSAGE_BOX(message, pRainError); cleanup; }
  57. #define CATCH_MESSAGE_BOX_1(message, a1, cleanup) catch (RainException *pRainError) { EXCEPTION_MESSAGE_BOX_1(message, a1, pRainError); cleanup; }
  58. #pragma warning(pop)
  59. #endif