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