Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
wxutils.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
7 /* This is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public
18  * License along with this software. If not, see
19  * <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef _BASE_WX_WXUTILS_H
24 #define _BASE_WX_WXUTILS_H
25 
26 #include <hugin_utils/utils.h>
27 
28 // use trace function under windows, because usually there is
29 // no stdout under windows
30 #include <wx/platform.h>
31 #ifdef __WXMSW__
32  #include <wx/string.h>
33  #include <wx/log.h>
34 
35  #ifdef DEBUG
36  #undef DEBUG_TRACE
37  #undef DEBUG_DEBUG
38  #undef DEBUG_INFO
39  #undef DEBUG_NOTICE
40 
41  // debug trace
42 // #define DEBUG_TRACE(msg) { std::stringstream o; o << "TRACE " << DEBUG_HEADER << msg; wxLogDebug(o.str().c_str());}
43  #define DEBUG_TRACE(msg) { std::cerr << "TRACE " << DEBUG_HEADER << msg << std::endl; }
44  // low level debug info
45 // #define DEBUG_DEBUG(msg) { std::stringstream o; o << "DEBUG " << DEBUG_HEADER << msg; wxLogDebug(o.str().c_str()); }
46  #define DEBUG_DEBUG(msg) { std::cerr << "DEBUG " << DEBUG_HEADER << msg << std::endl; }
47  // informational debug message,
48 // #define DEBUG_INFO(msg) { std::stringstream o; o << "INFO " << DEBUG_HEADER << msg; wxLogDebug(o.str().c_str()); }
49  #define DEBUG_INFO(msg) { std::cerr << "INFO " << DEBUG_HEADER << msg << std::endl; }
50  // major change/operation should use this
51 // #define DEBUG_NOTICE(msg) { std::stringstream o; o << "NOTICE " << DEBUG_HEADER << msg; wxLogMessage(o.str().c_str()); }
52  #define DEBUG_NOTICE(msg) { std::cerr << "NOTICE " << DEBUG_HEADER << msg << std::endl; }
53  #endif
54 
55  #undef DEBUG_WARN
56  #undef DEBUG_ERROR
57  #undef DEBUG_FATAL
58  #undef DEBUG_ASSERT
59 
60  // when an error occurred, but can be handled by the same function
61  #define DEBUG_WARN(msg) { std::stringstream o; o << "WARN: " << DEBUG_HEADER << msg; wxLogWarning(wxString(o.str().c_str(), wxConvISO8859_1));}
62  // an error occurred, might be handled by a calling function
63  #define DEBUG_ERROR(msg) { std::stringstream o; o << "ERROR: " << DEBUG_HEADER << msg; wxLogError(wxString(o.str().c_str(),wxConvISO8859_1));}
64  // a fatal error occurred. further program execution is unlikely
65  #define DEBUG_FATAL(msg) { std::stringstream o; o << "FATAL: " << DEBUG_HEADER << "(): " << msg; wxLogError(wxString(o.str().c_str(),wxConvISO8859_1)); }
66  // assertion
67  #define DEBUG_ASSERT(cond) \
68  do { \
69  if (!(cond)) { \
70  std::stringstream o; o << "ASSERTATION: " << DEBUG_HEADER << "(): " << #cond; \
71  wxLogFatalError(wxString(o.str().c_str(),wxConvISO8859_1)); \
72  } \
73  } while(0)
74 #endif
75 
76 
77 #endif // _BASE_WX_WXUTILS_H
implementation of huginApp Class