WaitDlg.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code 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. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #include "../../idlib/precompiled.h"
  21. #pragma hdrstop
  22. #include "qe3.h"
  23. #include "WaitDlg.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CWaitDlg dialog
  31. CWaitDlg::CWaitDlg(CWnd* pParent, const char *msg)
  32. : CDialog(CWaitDlg::IDD, pParent)
  33. {
  34. //{{AFX_DATA_INIT(CWaitDlg)
  35. waitStr = msg;
  36. //}}AFX_DATA_INIT
  37. cancelPressed = false;
  38. Create(CWaitDlg::IDD);
  39. //g_pParentWnd->SetBusy(true);
  40. }
  41. CWaitDlg::~CWaitDlg() {
  42. g_pParentWnd->SetBusy(false);
  43. }
  44. void CWaitDlg::DoDataExchange(CDataExchange* pDX)
  45. {
  46. CDialog::DoDataExchange(pDX);
  47. //{{AFX_DATA_MAP(CWaitDlg)
  48. DDX_Text(pDX, IDC_WAITSTR, waitStr);
  49. //}}AFX_DATA_MAP
  50. }
  51. BEGIN_MESSAGE_MAP(CWaitDlg, CDialog)
  52. //{{AFX_MSG_MAP(CWaitDlg)
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CWaitDlg message handlers
  57. BOOL CWaitDlg::OnInitDialog()
  58. {
  59. CDialog::OnInitDialog();
  60. //GetDlgItem(IDC_WAITSTR)->SetWindowText(waitStr);
  61. GetDlgItem(IDC_WAITSTR)->SetFocus();
  62. UpdateData(FALSE);
  63. ShowWindow(SW_SHOW);
  64. // cancel disabled by default
  65. AllowCancel( false );
  66. // TODO: Add extra initialization here
  67. return TRUE; // return TRUE unless you set the focus to a control
  68. // EXCEPTION: OCX Property Pages should return FALSE
  69. }
  70. void CWaitDlg::SetText(const char *msg, bool append) {
  71. if (append) {
  72. waitStr = text;
  73. waitStr += "\r\n";
  74. waitStr += msg;
  75. } else {
  76. waitStr = msg;
  77. text = msg;
  78. }
  79. UpdateData(FALSE);
  80. Invalidate();
  81. UpdateWindow();
  82. ShowWindow (SW_SHOWNORMAL);
  83. }
  84. void CWaitDlg::AllowCancel( bool enable ) {
  85. // this shows or hides the Cancel button
  86. CWnd* pCancelButton = GetDlgItem (IDCANCEL);
  87. ASSERT (pCancelButton);
  88. if ( enable ) {
  89. pCancelButton->ShowWindow (SW_NORMAL);
  90. } else {
  91. pCancelButton->ShowWindow (SW_HIDE);
  92. }
  93. }
  94. bool CWaitDlg::CancelPressed( void ) {
  95. #if _MSC_VER >= 1300
  96. MSG *msg = AfxGetCurrentMessage(); // TODO Robert fix me!!
  97. #else
  98. MSG *msg = &m_msgCur;
  99. #endif
  100. while( ::PeekMessage(msg, NULL, NULL, NULL, PM_NOREMOVE) ) {
  101. // pump message
  102. if ( !AfxGetApp()->PumpMessage() ) {
  103. }
  104. }
  105. return cancelPressed;
  106. }
  107. void CWaitDlg::OnCancel() {
  108. cancelPressed = true;
  109. }