PTWXDlg.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
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 // Error reporting
00039 
00040 static void PTPrintErrorWX(char* fmt, va_list ap)
00041 {
00042     char message[257];
00043 
00044     vsprintf(message, fmt, ap);
00045         
00046 //              MessageBox(GetFocus(), (LPSTR)message, (LPSTR)"", MB_OK | MB_ICONHAND) ;
00047     wxMessageBox(wxString(message,wxConvLocal), _("Panorama Tools"), wxOK | wxICON_HAND);
00048 }       
00049 
00050 
00051 // Progress report; return false if canceled
00052 
00053 
00054 static int PTProgressWX( int command, char* argument ){
00055 
00056     static wxProgressDialog * dlg = 0;
00057 //    MSG       msg;
00058     long percent;       
00059     switch( command ){
00060         case _initProgress:
00061             if (dlg) {
00062                 dlg->Destroy();
00063                 wxTheApp->Yield();
00064                 dlg = 0;
00065             } else {
00066                 dlg = new wxProgressDialog(_("Panorama Tools"),
00067                                            wxT("\n\n\n"), 100, NULL,
00068                                            wxPD_APP_MODAL | wxPD_CAN_ABORT);
00069                 if (dlg == 0) {
00070                     return FALSE;
00071                 }
00072                 dlg->Update(0, wxString(argument, wxConvLocal));
00073             }
00074             return TRUE;
00075         case _setProgress:
00076             if (dlg) {
00077                 sscanf(argument,"%ld", &percent);
00078                 if(percent>100) percent = 100;
00079                 if(percent<0  ) percent = 0;
00080                 if (! dlg->Update(percent)) {
00081                     return FALSE;
00082                 }
00083             }
00084             return TRUE;
00085             break;
00086         case _disposeProgress:
00087             if( dlg != 0 )
00088             {
00089                 dlg->Destroy();
00090                 wxTheApp->Yield();
00091                 dlg=0;
00092             }
00093 
00094             return TRUE;
00095 
00096         case _idleProgress:
00097             return TRUE;
00098 
00099     }
00100     return TRUE;
00101 }
00102 
00103 
00104 static int PTInfoDlgWX ( int command, char* argument )  // Display info: same argumenmts as progress
00105 {
00106     char                                text[256];
00107     static char                 mainMessage[256];                                               
00108 
00109     static wxProgressDialog * dlg = 0;
00110 //    MSG       msg;
00111     switch( command ){
00112         case _initProgress:
00113             if (dlg) {
00114                 dlg->Destroy();
00115                 wxTheApp->Yield();
00116                 dlg = 0;
00117             } else {
00118                 // we need to ensure that there is are enough lines in the dialog..
00119                 // create progress dialog
00120                 dlg = new wxProgressDialog(_("Panorama Tools"),
00121 #ifdef __WXMAC__
00122                                            wxT("0123456789012345678901234567890123456789012345\n\n\n\n\n"),
00123 #else
00124                                            wxT("0123456789012345678901234567890123456789012345\n\n\n"),
00125 #endif
00126                                            100, NULL,
00127                                            wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_ELAPSED_TIME);
00128                 if (dlg == 0) {
00129                     return FALSE;
00130                 }
00131                 dlg->Pulse(wxString(argument, wxConvLocal));
00132             }
00133             return TRUE;
00134         case _setProgress:
00135             if (dlg) {
00136                 if( *argument != 0 )
00137                 {
00138                     bool cont;
00139 
00140                     if( *argument != '+' )
00141                     {
00142                         strcpy( mainMessage, argument );
00143                         strcpy( text, argument );
00144                     }
00145                     else
00146                     {
00147                         sprintf( text,"%s%s", mainMessage, &(argument[1]) );
00148                     }
00149                     cont = dlg->Pulse(wxString(argument, wxConvLocal));
00150                     if (! cont) {
00151                         return FALSE;
00152                     }
00153                 }
00154             }
00155             return TRUE;
00156             break;
00157         case _disposeProgress:
00158             if( dlg != 0 )
00159             {
00160                 dlg->Destroy();
00161                 wxTheApp->Yield();
00162                 dlg=0;
00163             }
00164 
00165             return TRUE;
00166 
00167         case _idleProgress:
00168             return TRUE;
00169     }
00170     return TRUE;
00171 }
00172 
00173 void registerPTWXDlgFcn()
00174 {
00175     PT_setProgressFcn(&PTProgressWX);
00176     PT_setErrorFcn(&PTPrintErrorWX);
00177     PT_setInfoDlgFcn(&PTInfoDlgWX);
00178 };
00179 
00180 void deregisterPTWXDlgFcn()
00181 {
00182     PT_setProgressFcn(NULL);
00183     PT_setErrorFcn(NULL);
00184     PT_setInfoDlgFcn(NULL);
00185 }
00186 

Generated on 29 Jul 2015 for Hugintrunk by  doxygen 1.4.7