doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WaitDlg.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 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.
23 
24 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.
25 
26 ===========================================================================
27 */
28 
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "qe3.h"
33 #include "WaitDlg.h"
34 
35 #ifdef _DEBUG
36 #define new DEBUG_NEW
37 #undef THIS_FILE
38 static char THIS_FILE[] = __FILE__;
39 #endif
40 
42 // CWaitDlg dialog
43 
44 
45 CWaitDlg::CWaitDlg(CWnd* pParent, const char *msg)
46  : CDialog(CWaitDlg::IDD, pParent)
47 {
48  //{{AFX_DATA_INIT(CWaitDlg)
49  waitStr = msg;
50  //}}AFX_DATA_INIT
51  cancelPressed = false;
52  Create(CWaitDlg::IDD);
53  //g_pParentWnd->SetBusy(true);
54 }
55 
57  g_pParentWnd->SetBusy(false);
58 }
59 
60 void CWaitDlg::DoDataExchange(CDataExchange* pDX)
61 {
62  CDialog::DoDataExchange(pDX);
63  //{{AFX_DATA_MAP(CWaitDlg)
64  DDX_Text(pDX, IDC_WAITSTR, waitStr);
65  //}}AFX_DATA_MAP
66 }
67 
68 
69 BEGIN_MESSAGE_MAP(CWaitDlg, CDialog)
70  //{{AFX_MSG_MAP(CWaitDlg)
71  //}}AFX_MSG_MAP
72 END_MESSAGE_MAP()
73 
75 // CWaitDlg message handlers
76 
77 BOOL CWaitDlg::OnInitDialog()
78 {
79  CDialog::OnInitDialog();
80  //GetDlgItem(IDC_WAITSTR)->SetWindowText(waitStr);
81  GetDlgItem(IDC_WAITSTR)->SetFocus();
82  UpdateData(FALSE);
83  ShowWindow(SW_SHOW);
84 
85  // cancel disabled by default
86  AllowCancel( false );
87 
88  // TODO: Add extra initialization here
89 
90  return TRUE; // return TRUE unless you set the focus to a control
91  // EXCEPTION: OCX Property Pages should return FALSE
92 }
93 
94 void CWaitDlg::SetText(const char *msg, bool append) {
95  if (append) {
96  waitStr = text;
97  waitStr += "\r\n";
98  waitStr += msg;
99  } else {
100  waitStr = msg;
101  text = msg;
102  }
103  UpdateData(FALSE);
104  Invalidate();
105  UpdateWindow();
106  ShowWindow (SW_SHOWNORMAL);
107 }
108 
109 void CWaitDlg::AllowCancel( bool enable ) {
110  // this shows or hides the Cancel button
111  CWnd* pCancelButton = GetDlgItem (IDCANCEL);
112  ASSERT (pCancelButton);
113  if ( enable ) {
114  pCancelButton->ShowWindow (SW_NORMAL);
115  } else {
116  pCancelButton->ShowWindow (SW_HIDE);
117  }
118 }
119 
121 #if _MSC_VER >= 1300
122  MSG *msg = AfxGetCurrentMessage(); // TODO Robert fix me!!
123 #else
124  MSG *msg = &m_msgCur;
125 #endif
126 
127  while( ::PeekMessage(msg, NULL, NULL, NULL, PM_NOREMOVE) ) {
128  // pump message
129  if ( !AfxGetApp()->PumpMessage() ) {
130  }
131  }
132 
133  return cancelPressed;
134 }
135 
137  cancelPressed = true;
138 }
CMainFrame * g_pParentWnd
Definition: MainFrm.cpp:73
void SetBusy(bool b)
Definition: MainFrm.h:171
CWaitDlg(CWnd *pParent=NULL, const char *msg="Wait...")
Definition: WaitDlg.cpp:45
void AllowCancel(bool enable)
Definition: WaitDlg.cpp:109
#define IDC_WAITSTR
virtual void OnCancel()
Definition: WaitDlg.cpp:136
~CWaitDlg()
Definition: WaitDlg.cpp:56
#define BOOL
Definition: mprintf.c:71
bool CancelPressed(void)
Definition: WaitDlg.cpp:120
#define NULL
Definition: Lib.h:88
void SetText(const char *msg, bool append=false)
Definition: WaitDlg.cpp:94
virtual void DoDataExchange(CDataExchange *pDX)
Definition: WaitDlg.cpp:60
#define FALSE
Definition: mprintf.c:70
#define TRUE
Definition: mprintf.c:69
bool cancelPressed
Definition: WaitDlg.h:76
idStr text
Definition: WaitDlg.h:75
CString waitStr
Definition: WaitDlg.h:53