Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
wxPlatform.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
10 /* This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
14 *
15 * This software is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public
21 * License along with this software. If not, see
22 * <http://www.gnu.org/licenses/>.
23 *
24 */
25 
26 #include "wxPlatform.h"
27 #include <hugin_utils/utils.h>
28 
29 namespace hugin_utils
30 {
31  wxString doubleTowxString(double d, int digits)
32  {
33  std::string t = hugin_utils::doubleToString(d, digits);
34  return wxString(t.c_str(), wxConvLocal);
35  }
36 
37  bool str2double(const wxString& s, double & d)
38  {
39  if (!hugin_utils::stringToDouble(std::string(s.mb_str(wxConvLocal)), d))
40  {
41  return false;
42  }
43  return true;
44  }
45 
46 } // namespace
47 
48 #if defined __WXMSW__ && !wxCHECK_VERSION(3,1,1)
49  // workaround for wxWidgets bug 14888
50  // see: http://trac.wxwidgets.org/ticket/14888
51  // if this is fixed upstreams this workaround can be removed
52 void HuginCHMHelpController::DisplayHelpPage(const wxString& name)
53 {
54  // instead of passing filename as dwData to HH_DISPLAY_TOPIC
55  // we pass chmFilename::filename to pszfile
56  wxString command(GetValidFilename());
57  command.Append(wxT("::"));
58  command.Append(name);
59  CallHtmlHelp(GetParentWindow(), command.t_str(), 0 /* =HH_DISPLAY_TOPIC */);
60 };
61 #endif
62 
63 #ifndef __WXMSW__
64 #include <wx/confbase.h>
65 #include <wx/gdicmn.h>
66 // check if the help window has correct position/size inside current display
67 // this is not done by wxWidgets
69 {
70  wxConfigBase* config = wxConfigBase::Get();
71  int dw, dh;
72  wxDisplaySize(&dw, &dh);
73 
74  int x, y, w, h;
75  config->Read("/wxWindows/wxHtmlHelpController/hcX", &x, wxDefaultCoord);
76  config->Read("/wxWindows/wxHtmlHelpController/hcY", &y, wxDefaultCoord);
77  config->Read("/wxWindows/wxHtmlHelpController/hcW", &w, 700);
78  config->Read("/wxWindows/wxHtmlHelpController/hcH", &h, 480);
79  if (w > dw)
80  {
81  w = 700;
82  config->Write("/wxWindows/wxHtmlHelpController/hcW", w);
83  };
84  if (h > dh)
85  {
86  h = 480;
87  config->Write("/wxWindows/wxHtmlHelpController/hcH", h);
88  };
89  if (x<-1 || x>dw-100)
90  {
91  x = wxDefaultCoord;
92  config->Write("/wxWindows/wxHtmlHelpController/hcX", x);
93  };
94  if (y<-1 || y>dh - 100)
95  {
96  y = wxDefaultCoord;
97  config->Write("/wxWindows/wxHtmlHelpController/hcY", y);
98  };
99 }
100 #endif
101 
102 #if defined __WXGTK__ && wxCHECK_VERSION(3,1,1)
103 #include <wx/stdpaths.h>
104 #include <wx/app.h>
105 #include <wx/filename.h>
106 void CheckConfigFilename()
107 {
108  wxStandardPaths& paths = wxStandardPaths::Get();
109  // get config file name for old config filename
110  const wxFileName oldConfigFile (paths.GetUserConfigDir(), paths.MakeConfigFileName(wxTheApp->GetAppName(), wxStandardPaths::ConfigFileConv_Dot));
111  // now switch to XDG layout
112  paths.SetFileLayout(wxStandardPaths::FileLayout_XDG);
113  if (oldConfigFile.FileExists())
114  {
115  // get the new filename
116  const wxFileName newConfigFile(paths.GetUserConfigDir(), paths.MakeConfigFileName(wxTheApp->GetAppName(), wxStandardPaths::ConfigFileConv_Dot));
117  // if old file exists but not new file, move old config to new place
118  if (!newConfigFile.FileExists())
119  {
120  wxRenameFile(oldConfigFile.GetFullPath(), newConfigFile.GetFullPath());
121  };
122  };
123 };
124 #endif
bool str2double(const wxString &s, double &d)
Definition: wxPlatform.cpp:37
wxString doubleTowxString(double d, int digits)
Definition: wxPlatform.cpp:31
std::string doubleToString(double d, int digits)
convert a double to a string, suitable for display within a GUI.
Definition: utils.cpp:228
WXIMPEX void FixHelpSettings()
helper function to check window position settings of help window
Definition: wxPlatform.cpp:68
#define WXIMPEX
Definition: hugin_shared.h:40
IMPEX double h[25][1024]
Definition: emor.cpp:169
bool stringToDouble(const STR &str_, double &dest)
convert a string to a double, ignore localisation.
Definition: utils.h:114
platform/compiler specific stuff.