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 #ifndef __WXMSW__
49 #include <wx/confbase.h>
50 #include <wx/gdicmn.h>
51 // check if the help window has correct position/size inside current display
52 // this is not done by wxWidgets
54 {
55  wxConfigBase* config = wxConfigBase::Get();
56  int dw, dh;
57  wxDisplaySize(&dw, &dh);
58 
59  int x, y, w, h;
60  config->Read("/wxWindows/wxHtmlHelpController/hcX", &x, wxDefaultCoord);
61  config->Read("/wxWindows/wxHtmlHelpController/hcY", &y, wxDefaultCoord);
62  config->Read("/wxWindows/wxHtmlHelpController/hcW", &w, 700);
63  config->Read("/wxWindows/wxHtmlHelpController/hcH", &h, 480);
64  if (w > dw)
65  {
66  w = 700;
67  config->Write("/wxWindows/wxHtmlHelpController/hcW", w);
68  };
69  if (h > dh)
70  {
71  h = 480;
72  config->Write("/wxWindows/wxHtmlHelpController/hcH", h);
73  };
74  if (x<-1 || x>dw-100)
75  {
76  x = wxDefaultCoord;
77  config->Write("/wxWindows/wxHtmlHelpController/hcX", x);
78  };
79  if (y<-1 || y>dh - 100)
80  {
81  y = wxDefaultCoord;
82  config->Write("/wxWindows/wxHtmlHelpController/hcY", y);
83  };
84 }
85 #endif
86 
87 #if defined __WXGTK__
88 #include <wx/stdpaths.h>
89 #include <wx/app.h>
90 #include <wx/filename.h>
91 void CheckConfigFilename()
92 {
93  wxStandardPaths& paths = wxStandardPaths::Get();
94  // get config file name for old config filename
95  const wxFileName oldConfigFile (paths.GetUserConfigDir(), paths.MakeConfigFileName(wxTheApp->GetAppName(), wxStandardPaths::ConfigFileConv_Dot));
96  // now switch to XDG layout
97  paths.SetFileLayout(wxStandardPaths::FileLayout_XDG);
98  if (oldConfigFile.FileExists())
99  {
100  // get the new filename
101  const wxFileName newConfigFile(paths.GetUserConfigDir(), paths.MakeConfigFileName(wxTheApp->GetAppName(), wxStandardPaths::ConfigFileConv_Dot));
102  // if old file exists but not new file, move old config to new place
103  if (!newConfigFile.FileExists())
104  {
105  wxRenameFile(oldConfigFile.GetFullPath(), newConfigFile.GetFullPath());
106  };
107  };
108 };
109 #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:53
#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.