Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PTWXDlg.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
27 #include "hugin_config.h"
28 #include "panoinc_WX.h"
29 #include "panoinc.h"
30 #include "PTWXDlg.h"
31 #include <wx/app.h>
32 
33 extern "C" {
34 #include <pano13/filter.h>
35 #include <pano13/queryfeature.h>
36 }
37 
38 // Error reporting
39 
40 static void PTPrintErrorWX(char* fmt, va_list ap)
41 {
42  char message[257];
43 
44  vsprintf(message, fmt, ap);
45 
46 // MessageBox(GetFocus(), (LPSTR)message, (LPSTR)"", MB_OK | MB_ICONHAND) ;
47  wxMessageBox(wxString(message,wxConvLocal), _("Panorama Tools"), wxOK | wxICON_HAND);
48 }
49 
50 
51 // Progress report; return false if canceled
52 
53 
54 static int PTProgressWX( int command, char* argument ){
55 
56  static wxProgressDialog * dlg = 0;
57 // MSG msg;
58  long percent;
59  switch( command ){
60  case _initProgress:
61  if (dlg) {
62  dlg->Destroy();
63  wxTheApp->Yield();
64  dlg = 0;
65  } else {
66  dlg = new wxProgressDialog(_("Panorama Tools"),
67  wxT("\n\n\n"), 100, wxGetActiveWindow(),
68  wxPD_APP_MODAL | wxPD_CAN_ABORT);
69  if (dlg == 0) {
70  return FALSE;
71  }
72  dlg->Update(0, wxString(argument, wxConvLocal));
73  }
74  return TRUE;
75  case _setProgress:
76  if (dlg) {
77  sscanf(argument,"%ld", &percent);
78  if(percent>100) percent = 100;
79  if(percent<0 ) percent = 0;
80  if (! dlg->Update(percent)) {
81  return FALSE;
82  }
83  }
84  return TRUE;
85  break;
86  case _disposeProgress:
87  if( dlg != 0 )
88  {
89  dlg->Destroy();
90  wxTheApp->Yield();
91  dlg=0;
92  }
93 
94  return TRUE;
95 
96  case _idleProgress:
97  return TRUE;
98 
99  }
100  return TRUE;
101 }
102 
103 
104 static int PTInfoDlgWX ( int command, char* argument ) // Display info: same argumenmts as progress
105 {
106  char text[256];
107  static char mainMessage[256];
108 
109  static wxProgressDialog * dlg = 0;
110 // MSG msg;
111  switch( command ){
112  case _initProgress:
113  if (dlg) {
114  dlg->Destroy();
115  wxTheApp->Yield();
116  dlg = 0;
117  } else {
118  // we need to ensure that there is are enough lines in the dialog..
119  // create progress dialog
120  dlg = new wxProgressDialog(_("Panorama Tools"),
121 #ifdef __WXMAC__
122  wxT("0123456789012345678901234567890123456789012345\n\n\n\n\n"),
123 #else
124  wxT("0123456789012345678901234567890123456789012345\n\n\n"),
125 #endif
126  100, wxGetActiveWindow(),
127  wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_ELAPSED_TIME);
128  if (dlg == 0) {
129  return FALSE;
130  }
131  dlg->Pulse(wxString(argument, wxConvLocal));
132  }
133  return TRUE;
134  case _setProgress:
135  if (dlg) {
136  if( *argument != 0 )
137  {
138  bool cont;
139 
140  if( *argument != '+' )
141  {
142  strcpy( mainMessage, argument );
143  strcpy( text, argument );
144  }
145  else
146  {
147  sprintf( text,"%s%s", mainMessage, &(argument[1]) );
148  }
149  cont = dlg->Pulse(wxString(argument, wxConvLocal));
150  if (! cont) {
151  return FALSE;
152  }
153  }
154  }
155  return TRUE;
156  break;
157  case _disposeProgress:
158  if( dlg != 0 )
159  {
160  dlg->Destroy();
161  wxTheApp->Yield();
162  dlg=0;
163  }
164 
165  return TRUE;
166 
167  case _idleProgress:
168  return TRUE;
169  }
170  return TRUE;
171 }
172 
174 {
175  PT_setProgressFcn(&PTProgressWX);
176  PT_setErrorFcn(&PTPrintErrorWX);
177  PT_setInfoDlgFcn(&PTInfoDlgWX);
178 };
179 
181 {
182  PT_setProgressFcn(NULL);
183  PT_setErrorFcn(NULL);
184  PT_setInfoDlgFcn(NULL);
185 }
186 
void registerPTWXDlgFcn()
Definition: PTWXDlg.cpp:173
void deregisterPTWXDlgFcn()
Definition: PTWXDlg.cpp:180
include file for the hugin project
static int PTProgressWX(int command, char *argument)
Definition: PTWXDlg.cpp:54
static void PTPrintErrorWX(char *fmt, va_list ap)
Definition: PTWXDlg.cpp:40
include file for the hugin project
static int PTInfoDlgWX(int command, char *argument)
Definition: PTWXDlg.cpp:104