DlgMessageBox.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /******************************************************************************
  19. *
  20. * NAME
  21. * $Archive: /Commando/Code/Commando/DlgMessageBox.h $
  22. *
  23. * DESCRIPTION
  24. * Popup message dialog.
  25. *
  26. * PROGRAMMER
  27. * Denzil E. Long, Jr.
  28. * $Author: Denzil_l $
  29. *
  30. * VERSION INFO
  31. * $Revision: 8 $
  32. * $Modtime: 10/13/01 4:50p $
  33. *
  34. ******************************************************************************/
  35. #ifndef __DLGMESSAGEBOX_H__
  36. #define __DLGMESSAGEBOX_H__
  37. #include <WWUI\PopupDialog.h>
  38. #include <WWLib\Notify.h>
  39. class DlgMsgBox;
  40. class DlgMsgBoxEvent :
  41. public TypedEventPtr<DlgMsgBoxEvent, DlgMsgBox>
  42. {
  43. public:
  44. typedef enum
  45. {
  46. None = 0, // NULL event
  47. Okay, // Okay button pressed
  48. Yes, // Yes button pressed
  49. No, // No button pressed
  50. Quitting, // Dialog quitting.
  51. } EventID;
  52. //! Retrieve event
  53. inline EventID Event(void) const
  54. {return mEvent;}
  55. //! User data access
  56. inline unsigned long Get_User_Data(void) const
  57. {return mUserData;}
  58. inline void Set_User_Data(unsigned long data)
  59. {mUserData = data;}
  60. DlgMsgBoxEvent(EventID event, DlgMsgBox* object, unsigned long user_data) :
  61. TypedEventPtr<DlgMsgBoxEvent, DlgMsgBox>(object),
  62. mEvent(event), mUserData (user_data)
  63. {}
  64. protected:
  65. // Prevent copy and assignment
  66. DlgMsgBoxEvent(const DlgMsgBoxEvent&);
  67. const DlgMsgBoxEvent& operator=(const DlgMsgBoxEvent&);
  68. private:
  69. EventID mEvent;
  70. unsigned long mUserData;
  71. };
  72. class DlgMsgBox :
  73. public PopupDialogClass,
  74. public Notifier<DlgMsgBoxEvent>
  75. {
  76. public:
  77. typedef enum
  78. {
  79. Okay = 0, // Message box with okay button (Default)
  80. YesNo, // Yes/No message box
  81. } Type;
  82. static bool DoDialog(const WCHAR* title, const WCHAR* text,
  83. DlgMsgBox::Type type = DlgMsgBox::Okay, Observer<DlgMsgBoxEvent>* observer = NULL,
  84. unsigned long user_data = 0);
  85. static bool DoDialog(int titleID, int textID, DlgMsgBox::Type type = DlgMsgBox::Okay,
  86. Observer<DlgMsgBoxEvent>* observer = NULL, unsigned long user_data = 0);
  87. void Set_User_Data(unsigned long user_data)
  88. {mUserData = user_data;}
  89. unsigned long Get_User_Data(void) const
  90. {return mUserData;}
  91. static int Get_Current_Count(void)
  92. {return CurrentCount;}
  93. protected:
  94. DlgMsgBox();
  95. virtual ~DlgMsgBox();
  96. void SetResourceType(DlgMsgBox::Type type);
  97. void End_Dialog(void);
  98. void On_Command(int ctrl, int message, DWORD param);
  99. DECLARE_NOTIFIER(DlgMsgBoxEvent)
  100. private:
  101. // Prevent copy and assignment
  102. DlgMsgBox(const DlgMsgBox&);
  103. const DlgMsgBox& operator=(const DlgMsgBox&);
  104. static int CurrentCount;
  105. unsigned long mUserData;
  106. };
  107. #endif // __DLGMESSAGEBOX_H__