[829492]: src / hugin1 / base_wx / PTWXDlg.cpp  Maximize  Restore  History

Download this file

195 lines (170 with data), 5.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// -*- c-basic-offset: 4 -*-
/** @file OptimizePanel.cpp
*
* @brief implementation of OptimizePanel
*
* @author Pablo d'Angelo <pablo.dangelo@web.de>
*
* $Id$
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <config.h>
#include "panoinc.h"
#include "panoinc_WX.h"
#include "PTWXDlg.h"
#include <wx/app.h>
extern "C" {
#include <pano13/filter.h>
#include <pano13/queryfeature.h>
}
// Error reporting
static void PTPrintErrorWX(char* fmt, va_list ap)
{
char message[257];
vsprintf(message, fmt, ap);
// MessageBox(GetFocus(), (LPSTR)message, (LPSTR)"", MB_OK | MB_ICONHAND) ;
wxMessageBox(wxString(message,wxConvLocal), _("Panorama Tools"), wxOK | wxICON_HAND);
}
// Progress report; return false if canceled
static int PTProgressWX( int command, char* argument ){
static wxProgressDialog * dlg = 0;
// MSG msg;
long percent;
switch( command ){
case _initProgress:
if (dlg) {
dlg->Destroy();
wxTheApp->Yield();
dlg = 0;
} else {
dlg = new wxProgressDialog(_("Panorama Tools"),
wxT("\n\n\n"), 100, NULL,
wxPD_APP_MODAL | wxPD_CAN_ABORT);
if (dlg == 0) {
return FALSE;
}
dlg->Update(0, wxString(argument, wxConvLocal));
}
return TRUE;
case _setProgress:
if (dlg) {
sscanf(argument,"%ld", &percent);
if(percent>100) percent = 100;
if(percent<0 ) percent = 0;
if (! dlg->Update(percent)) {
return FALSE;
}
}
return TRUE;
break;
case _disposeProgress:
if( dlg != 0 )
{
dlg->Destroy();
wxTheApp->Yield();
dlg=0;
}
return TRUE;
case _idleProgress:
return TRUE;
}
return TRUE;
}
static int PTInfoDlgWX ( int command, char* argument ) // Display info: same argumenmts as progress
{
char text[256];
static char mainMessage[256];
static wxProgressDialog * dlg = 0;
// MSG msg;
switch( command ){
case _initProgress:
if (dlg) {
dlg->Destroy();
wxTheApp->Yield();
dlg = 0;
} else {
// we need to ensure that there is are enough lines in the dialog..
// create progress dialog
dlg = new wxProgressDialog(_("Panorama Tools"),
#ifdef __WXMAC__
wxT("0123456789012345678901234567890123456789012345\n\n\n\n\n"),
#else
wxT("0123456789012345678901234567890123456789012345\n\n\n"),
#endif
100, NULL,
wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_ELAPSED_TIME);
if (dlg == 0) {
return FALSE;
}
#if wxCHECK_VERSION(2,8,0)
dlg->Pulse(wxString(argument, wxConvLocal));
#else
dlg->Update(0, wxString(argument, wxConvLocal));
#endif
}
return TRUE;
case _setProgress:
if (dlg) {
if( *argument != 0 )
{
bool cont;
if( *argument != '+' )
{
strcpy( mainMessage, argument );
strcpy( text, argument );
}
else
{
sprintf( text,"%s%s", mainMessage, &(argument[1]) );
}
#if wxCHECK_VERSION(2,8,0)
cont = dlg->Pulse(wxString(argument, wxConvLocal));
#else
cont = dlg->Update(1, wxString(argument, wxConvLocal));
#endif
if (! cont) {
return FALSE;
}
}
}
return TRUE;
break;
case _disposeProgress:
if( dlg != 0 )
{
dlg->Destroy();
wxTheApp->Yield();
dlg=0;
}
return TRUE;
case _idleProgress:
return TRUE;
}
return TRUE;
}
void registerPTWXDlgFcn()
{
PT_setProgressFcn(&PTProgressWX);
PT_setErrorFcn(&PTPrintErrorWX);
PT_setInfoDlgFcn(&PTInfoDlgWX);
};
void deregisterPTWXDlgFcn()
{
PT_setProgressFcn(NULL);
PT_setErrorFcn(NULL);
PT_setInfoDlgFcn(NULL);
}