Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre/Tools/3dsmaxExport/LEXIExporter/LexiExport/Sources/LexiDialogProgress.cpp @ 45

Last change on this file since 45 was 6, checked in by anonymous, 18 years ago

=…

File size: 3.9 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of LEXIExporter
4
5Copyright 2006 NDS Limited
6
7Author(s):
8Mark Folkenberg,
9Bo Krohn
10
11This program is free software; you can redistribute it and/or modify it under
12the terms of the GNU Lesser General Public License as published by the Free Software
13Foundation; either version 2 of the License, or (at your option) any later
14version.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
19
20You should have received a copy of the GNU Lesser General Public License along with
21this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22Place - Suite 330, Boston, MA 02111-1307, USA, or go to
23http://www.gnu.org/copyleft/lesser.txt.
24-----------------------------------------------------------------------------
25*/
26
27#include "LexiStdAfx.h"
28#include "LexiMaxExport.h"
29#include "LexiDialogProgress.h"
30#include "LexiExportObject.h"
31
32#include "..\Res\resource.h"
33
34//
35CExportProgressDlg::CExportProgressDlg(Window* pParent) : Dialog(IDD_DIALOG_PROGRESS, DlgProc, pParent)
36{
37        m_iTotalGlobal=0;
38        m_iGlobalProgress=0;
39        m_bAbortRequest=false;
40        m_bAbortFlag=false;
41}
42
43CExportProgressDlg::~CExportProgressDlg()
44{
45}
46
47// Initialize global stepping
48void CExportProgressDlg::InitGlobal(int iObjectCount)
49{
50        m_pGlobalProgress->SendMessage(PBM_SETRANGE, 0, MAKELPARAM(0, iObjectCount+1));
51        m_iGlobalProgress=0;
52        m_iTotalGlobal=iObjectCount;
53}
54
55// Do a global step (once per ExportObject)
56void CExportProgressDlg::GlobalStep()
57{
58        ++m_iGlobalProgress;
59        _snprintf_s(m_InfoBuffer, 1024, "Exporting %d of %d", m_iGlobalProgress, m_iTotalGlobal);
60        m_pGlobalInfo->SetWindowText(m_InfoBuffer);
61        m_pGlobalProgress->SendMessage(PBM_SETPOS, m_iGlobalProgress, 0);
62
63        // Pump messages
64        MSG winmsg;
65        while(PeekMessage(&winmsg, NULL, 0, 0, PM_REMOVE))
66        {
67                TranslateMessage(&winmsg);
68                DispatchMessage(&winmsg);
69        }
70}
71
72// Initialize local progress
73void CExportProgressDlg::InitLocal(int iStepCount)
74{
75        m_pLocalProgress->SendMessage(PBM_SETRANGE, 0, MAKELPARAM(0, iStepCount+1));
76        m_iLocalProgress=0;
77}
78
79// Do a local step
80void CExportProgressDlg::LocalStep(const char *pszDesc)
81{
82        ++m_iLocalProgress;     
83        if(pszDesc!=NULL) m_pLocalInfo->SetWindowText(pszDesc);
84        m_pLocalProgress->SendMessage(PBM_SETPOS, m_iLocalProgress, 0);
85
86        // Pump messages
87        MSG winmsg;
88        while(PeekMessage(&winmsg, NULL, 0, 0, PM_REMOVE))
89        {
90                TranslateMessage(&winmsg);
91                DispatchMessage(&winmsg);
92        }
93}
94
95// Signal export done
96void CExportProgressDlg::ExportDone(void)
97{
98        DestroyWindow();
99}
100
101// Check if we want to abort current export
102bool CExportProgressDlg::CheckAbort()
103{
104        if(m_bAbortFlag) return true;
105
106        if(m_bAbortRequest)
107        {
108                int rs = MessageBox("Do you want to abort current export?", NDS_EXPORTER_TITLE, MB_YESNO | MB_ICONWARNING);
109                if(rs != IDYES) 
110                {
111                        m_bAbortRequest=false;
112                        return false;   
113                }
114                m_bAbortFlag=true;
115                return true;
116        }
117        return false;
118}
119
120//
121INT_PTR CALLBACK CExportProgressDlg::DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
122{
123        CExportProgressDlg* pThis = (CExportProgressDlg*)Window::GetMapping(hWnd);
124
125        switch(message)
126        {
127                case WM_INITDIALOG:
128                {
129                        pThis = (CExportProgressDlg*)lParam;
130                        Window::AddMapping(pThis, hWnd);
131
132                        pThis->OnInitDialog();
133
134                }       return 0;
135
136                case WM_COMMAND:
137                {
138                        switch(LOWORD(wParam))
139                        {
140                                case IDC_ABORT:
141                                        pThis->OnAbort();
142                                        break;
143                        }
144                }       break;
145        }
146
147        return 0;
148}
149
150//
151
152void CExportProgressDlg::OnInitDialog()
153{               
154        m_pGlobalInfo=GetDlgItem(IDC_EXPORTINFO);
155        m_pGlobalProgress=GetDlgItem(IDC_GLOBALPROGRESS);
156        m_pLocalInfo=GetDlgItem(IDC_LOCALINFO);
157        m_pLocalProgress=GetDlgItem(IDC_LOCALPROGRESS);
158        m_pGlobalInfo->SetWindowText("Counting...");
159        m_pLocalInfo->SetWindowText("");
160        CenterWindow();
161}
162
163
164void CExportProgressDlg::OnAbort()
165{
166        m_bAbortRequest=true;
167}
Note: See TracBrowser for help on using the repository browser.