1 /*******************************************************************************
\r
2 TPI - flexible but useless plug-in framework.
\r
3 Copyright (C) 2002-2009 Silky
\r
5 This library is free software; you can redistribute it and/or modify it under
\r
6 the terms of the GNU Lesser General Public License as published by the Free
\r
7 Software Foundation; either version 2.1 of the License, or (at your option)
\r
10 This library is distributed in the hope that it will be useful, but WITHOUT
\r
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
\r
15 You should have received a copy of the GNU Lesser General Public License along
\r
16 with this library; if not, write to the Free Software Foundation, Inc.,
\r
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
\r
19 $Id: dlg_process.cpp,v 1.6 2009/09/01 12:20:49 sirakaba Exp $
\r
20 *******************************************************************************/
\r
22 #include "frontend.h"
\r
23 #include "dlg_process.h"
\r
25 ProcessDialog * g_procDlg = NULL;
\r
27 //******************************************************************************
\r
29 //******************************************************************************
\r
31 ProcessDialog::ProcessDialog(): wxDialog()
\r
35 ProcessDialog::~ProcessDialog()
\r
40 //******************************************************************************
\r
42 //******************************************************************************
\r
44 BEGIN_EVENT_TABLE(ProcessDialog, wxDialog)
\r
45 EVT_INIT_DIALOG(ProcessDialog::OnInit)
\r
46 EVT_CLOSE( ProcessDialog::OnClose)
\r
49 //******************************************************************************
\r
51 //******************************************************************************
\r
53 void ProcessDialog::OnInit(wxInitDialogEvent &)
\r
55 // XRC
\82Æ
\8c\8b\82Ñ
\82Â
\82¯
\81B
\r
56 this->ebSource = XRCCTRL(* this, "ebSource", wxTextCtrl);
\r
57 this->ebTarget = XRCCTRL(* this, "ebTarget", wxTextCtrl);
\r
58 this->gauge = XRCCTRL(* this, "gauge", wxGauge);
\r
59 this->fCancel = false;
\r
62 ::wxXmlResource::Get()->Unload(FE_DIR_S_XRC wxT("dlg_process.xrc"));
\r
65 void ProcessDialog::OnClose(wxCloseEvent & e)
\r
67 if (e.CanVeto() && ::AskDlg(wxT("Really do you want to cancel this operation?"), this) == wxYES)
\r
69 this->fCancel = true;
\r
74 //******************************************************************************
\r
75 //
\83_
\83C
\83A
\83\8d\83O
\83v
\83\8d\83V
\81[
\83W
\83\83\r
76 //******************************************************************************
\r
78 int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure)
\r
80 if (_uMsg != TPI_NOTIFY_COMMON)
\r
82 return TPI_CALLBACK_UNSUPPORTED;
\r
85 TPI_PROCESSINFO * piInfo = (TPI_PROCESSINFO *) _pStructure;
\r
86 if (g_procDlg == NULL || piInfo == NULL || piInfo->uMessage != TPI_MESSAGE_STATUS || ! g_procDlg->IsShown())
\r
88 return TPI_CALLBACK_CONTINUE;
\r
91 static int s_nGaugeCounter = 0;
\r
92 switch (piInfo->uStatus)
\r
94 case TPI_STATUS_OPENARCHIVE:
\r
95 g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
\r
97 case TPI_STATUS_BEGINPROCESS:
\r
98 g_procDlg->ebTarget->ChangeValue((piInfo->fnDestination.IsOk() ? piInfo->fnDestination : piInfo->fiInfo.fnFileName).GetFullPath());
\r
99 if (piInfo->fiInfo.llUnpackedSize > 10000)
\r
101 g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());
\r
102 g_procDlg->gauge->SetValue(0);
\r
104 ::wxSafeYield(g_procDlg, true);
\r
106 case TPI_STATUS_INPROCESS:
\r
107 if (s_nGaugeCounter++ > 100)
\r
109 if (piInfo->fiInfo.llUnpackedSize > 10000)
\r
111 g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong());
\r
113 ::wxSafeYield(g_procDlg, true);
\r
114 s_nGaugeCounter = 0;
\r
117 case TPI_STATUS_ENDPROCESS:
\r
118 // g_procDlg->gauge->SetValue(piInfo->fiInfo.llUnpackedSize.ToULong());
\r
120 //
\8f\91\8cÉ
\83\8d\81[
\83h
\8e\9e\97p
\82Ì
\93Æ
\8e©
\8ed
\97l
\81B
\r
122 g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
\r
123 g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());
\r
124 g_procDlg->gauge->SetValue(0);
\r
127 //
\8dX
\90V
\82µ
\82·
\82¬
\82é
\82Æ
\92á
\91¬
\82È
\82Ì
\82Å100
\83t
\83@
\83C
\83\8b\96\88\82É
\8dX
\90V
\82·
\82é
\81B
\r
128 if (piInfo->llProcessedSize > g_procDlg->gauge->GetValue() + 100)
\r
130 g_procDlg->ebTarget->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
\r
131 g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong());
\r
132 ::wxSafeYield(g_procDlg, true);
\r
137 return g_procDlg->fCancel ? TPI_CALLBACK_CANCEL : TPI_CALLBACK_CONTINUE;
\r