00001
00002
00027 #include <config.h>
00028 #include "panoinc.h"
00029 #include "panoinc_WX.h"
00030 #include "PTWXDlg.h"
00031 #include <wx/app.h>
00032
00033 extern "C" {
00034 #include <pano13/filter.h>
00035 #include <pano13/queryfeature.h>
00036 }
00037
00038
00039
00040 wxWindow* appParent = NULL;
00041
00042 static void PTPrintErrorWX(char* fmt, va_list ap)
00043 {
00044 char message[257];
00045
00046 vsprintf(message, fmt, ap);
00047
00048
00049 wxMessageBox(wxString(message,wxConvLocal), _("Panorama Tools"), wxOK | wxICON_HAND,appParent);
00050 }
00051
00052
00053
00054
00055
00056 static int PTProgressWX( int command, char* argument ){
00057
00058 static wxProgressDialog * dlg = 0;
00059
00060 long percent;
00061 switch( command ){
00062 case _initProgress:
00063 if (dlg) {
00064 dlg->Destroy();
00065 wxTheApp->Yield();
00066 dlg = 0;
00067 } else {
00068 dlg = new wxProgressDialog(_("Panorama Tools"),
00069 wxT("\n\n\n"), 100, NULL,
00070 wxPD_APP_MODAL | wxPD_CAN_ABORT);
00071 if (dlg == 0) {
00072 return FALSE;
00073 }
00074 dlg->Update(0, wxString(argument, wxConvLocal));
00075 }
00076 return TRUE;
00077 case _setProgress:
00078 if (dlg) {
00079 sscanf(argument,"%ld", &percent);
00080 if(percent>100) percent = 100;
00081 if(percent<0 ) percent = 0;
00082 if (! dlg->Update(percent)) {
00083 return FALSE;
00084 }
00085 }
00086 return TRUE;
00087 break;
00088 case _disposeProgress:
00089 if( dlg != 0 )
00090 {
00091 dlg->Destroy();
00092 wxTheApp->Yield();
00093 dlg=0;
00094 }
00095
00096 return TRUE;
00097
00098 case _idleProgress:
00099 return TRUE;
00100
00101 }
00102 return TRUE;
00103 }
00104
00105
00106 static int PTInfoDlgWX ( int command, char* argument )
00107 {
00108 char text[256];
00109 static char mainMessage[256];
00110
00111 static wxProgressDialog * dlg = 0;
00112
00113 switch( command ){
00114 case _initProgress:
00115 if (dlg) {
00116 dlg->Destroy();
00117 wxTheApp->Yield();
00118 dlg = 0;
00119 } else {
00120
00121
00122 dlg = new wxProgressDialog(_("Panorama Tools"),
00123 #ifdef __WXMAC__
00124 wxT("0123456789012345678901234567890123456789012345\n\n\n\n\n"),
00125 #else
00126 wxT("0123456789012345678901234567890123456789012345\n\n\n"),
00127 #endif
00128 100, NULL,
00129 wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_ELAPSED_TIME);
00130 if (dlg == 0) {
00131 return FALSE;
00132 }
00133 #if wxCHECK_VERSION(2,8,0)
00134 dlg->Pulse(wxString(argument, wxConvLocal));
00135 #else
00136 dlg->Update(0, wxString(argument, wxConvLocal));
00137 #endif
00138 }
00139 return TRUE;
00140 case _setProgress:
00141 if (dlg) {
00142 if( *argument != 0 )
00143 {
00144 bool cont;
00145
00146 if( *argument != '+' )
00147 {
00148 strcpy( mainMessage, argument );
00149 strcpy( text, argument );
00150 }
00151 else
00152 {
00153 sprintf( text,"%s%s", mainMessage, &(argument[1]) );
00154 }
00155 #if wxCHECK_VERSION(2,8,0)
00156 cont = dlg->Pulse(wxString(argument, wxConvLocal));
00157 #else
00158 cont = dlg->Update(1, wxString(argument, wxConvLocal));
00159 #endif
00160 if (! cont) {
00161 return FALSE;
00162 }
00163 }
00164 }
00165 return TRUE;
00166 break;
00167 case _disposeProgress:
00168 if( dlg != 0 )
00169 {
00170 dlg->Destroy();
00171 wxTheApp->Yield();
00172 dlg=0;
00173 }
00174
00175 return TRUE;
00176
00177 case _idleProgress:
00178 return TRUE;
00179 }
00180 return TRUE;
00181 }
00182
00183 void registerPTWXDlgFcn(wxWindow* parent)
00184 {
00185 appParent = parent;
00186 PT_setProgressFcn(&PTProgressWX);
00187 PT_setErrorFcn(&PTPrintErrorWX);
00188 PT_setInfoDlgFcn(&PTInfoDlgWX);
00189 };
00190
00191 void deregisterPTWXDlgFcn()
00192 {
00193 PT_setProgressFcn(NULL);
00194 PT_setErrorFcn(NULL);
00195 PT_setInfoDlgFcn(NULL);
00196 }
00197