Hugin trunk 0.1
Loading...
Searching...
No Matches
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_shared.h"
27#include "panoinc_WX.h"
28#include "hugin_utils/utils.h"
29
30// use trace function under windows, because usually there is
31// no stdout under windows
32#ifdef __WXMSW__
33 #include <wx/string.h>
34 #include <wx/log.h>
35
36 #ifdef DEBUG
37 #undef DEBUG_TRACE
38 #undef DEBUG_DEBUG
39 #undef DEBUG_INFO
40 #undef DEBUG_NOTICE
41
42 // debug trace
43// #define DEBUG_TRACE(msg) { std::stringstream o; o << "TRACE " << DEBUG_HEADER << msg; wxLogDebug(o.str().c_str());}
44 #define DEBUG_TRACE(msg) { std::cerr << "TRACE " << DEBUG_HEADER << msg << std::endl; }
45 // low level debug info
46// #define DEBUG_DEBUG(msg) { std::stringstream o; o << "DEBUG " << DEBUG_HEADER << msg; wxLogDebug(o.str().c_str()); }
47 #define DEBUG_DEBUG(msg) { std::cerr << "DEBUG " << DEBUG_HEADER << msg << std::endl; }
48 // informational debug message,
49// #define DEBUG_INFO(msg) { std::stringstream o; o << "INFO " << DEBUG_HEADER << msg; wxLogDebug(o.str().c_str()); }
50 #define DEBUG_INFO(msg) { std::cerr << "INFO " << DEBUG_HEADER << msg << std::endl; }
51 // major change/operation should use this
52// #define DEBUG_NOTICE(msg) { std::stringstream o; o << "NOTICE " << DEBUG_HEADER << msg; wxLogMessage(o.str().c_str()); }
53 #define DEBUG_NOTICE(msg) { std::cerr << "NOTICE " << DEBUG_HEADER << msg << std::endl; }
54 #endif
55
56 #undef DEBUG_WARN
57 #undef DEBUG_ERROR
58 #undef DEBUG_FATAL
59 #undef DEBUG_ASSERT
60
61 // when an error occurred, but can be handled by the same function
62 #define DEBUG_WARN(msg) { std::stringstream o; o << "WARN: " << DEBUG_HEADER << msg; wxLogWarning(wxString(o.str().c_str(), wxConvISO8859_1));}
63 // an error occurred, might be handled by a calling function
64 #define DEBUG_ERROR(msg) { std::stringstream o; o << "ERROR: " << DEBUG_HEADER << msg; wxLogError(wxString(o.str().c_str(),wxConvISO8859_1));}
65 // a fatal error occurred. further program execution is unlikely
66 #define DEBUG_FATAL(msg) { std::stringstream o; o << "FATAL: " << DEBUG_HEADER << "(): " << msg; wxLogError(wxString(o.str().c_str(),wxConvISO8859_1)); }
67 // assertion
68 #define DEBUG_ASSERT(cond) \
69 do { \
70 if (!(cond)) { \
71 std::stringstream o; o << "ASSERTATION: " << DEBUG_HEADER << "(): " << #cond; \
72 wxLogFatalError(wxString(o.str().c_str(),wxConvISO8859_1)); \
73 } \
74 } while(0)
75#endif
76
77namespace hugin_utils
78{
80
81 // functions to store/restore frame/dialog position and size
82 WXIMPEX void RestoreFramePosition(wxTopLevelWindow* frame, const wxString& basename, const bool ignoreMaximize = false);
83 WXIMPEX void StoreFramePosition(wxTopLevelWindow* frame, const wxString& basename, const bool ignoreMaximize = false);
84 // functions to store/restore frame/dialog position only
85 WXIMPEX void RestoreFramePositionOnly(wxTopLevelWindow* frame, const wxString& basename);
86 WXIMPEX void StoreFramePositionOnly(wxTopLevelWindow* frame, const wxString& basename);
87 // wrapper around wxMessageBox, don't show caption on Linux/MacOS
88 // use wxMessageDialog on Windows for dark mode support
89 WXIMPEX int HuginMessageBox(const wxString& message, const wxString& caption, int style, wxWindow* parent);
90 typedef std::unique_ptr<wxMessageDialogBase> MessageDialog;
93 WXIMPEX bool AskUserOverwrite(const wxString& filename, const wxString& caption, wxWindow* parent);
98 {
99 public:
100 DisableWindow(wxWindow* window);
102 private:
103 wxWindow* m_window;
104 };
105}
106#endif // _BASE_WX_WXUTILS_H
helper class, it disables the control/window in the constructor and automatically enables it back in ...
Definition wxutils.h:98
#define WXIMPEX
namespace for various utils
void StoreFramePositionOnly(wxTopLevelWindow *frame, const wxString &basename)
Definition wxutils.cpp:163
WXIMPEX wxString GetFormattedTimeSpan(const wxTimeSpan &timeSpan)
Definition wxutils.cpp:29
bool AskUserOverwrite(const wxString &filename, const wxString &caption, wxWindow *parent)
ask user if the given file should be overwritten, return true if the user confirmed the overwritting
Definition wxutils.cpp:233
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
Definition wxutils.cpp:176
void RestoreFramePositionOnly(wxTopLevelWindow *frame, const wxString &basename)
Definition wxutils.cpp:143
std::unique_ptr< wxMessageDialogBase > MessageDialog
Definition wxutils.h:90
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
Definition wxutils.cpp:106
MessageDialog GetMessageDialog(const wxString &message, const wxString &caption, int style, wxWindow *parent)
Definition wxutils.cpp:212
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
Definition wxutils.cpp:67
include file for the hugin project
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41