]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/utilsres.cpp
Fix assorted typos in comments and other non-code.
[wxWidgets.git] / src / gtk1 / utilsres.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/utilsres.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
11
12 #include "wx/utils.h"
13
14 #ifndef WX_PRECOMP
15 #include "wx/list.h"
16 #include "wx/string.h"
17 #include "wx/log.h"
18 #include "wx/app.h"
19 #endif
20
21 #include "wx/config.h"
22
23 //-----------------------------------------------------------------------------
24 // resource functions
25 //-----------------------------------------------------------------------------
26
27 bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file )
28 {
29 wxString filename( file );
30 if (filename.empty()) filename = wxT(".wxWindows");
31
32 wxFileConfig conf( wxTheApp->GetAppName(), wxTheApp->GetVendorName(), filename );
33
34 conf.SetPath( section );
35
36 return conf.Write( entry, value );
37 }
38
39 bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file )
40 {
41 wxString buf;
42 buf.Printf(wxT("%.4f"), value);
43
44 return wxWriteResource(section, entry, buf, file);
45 }
46
47 bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file )
48 {
49 wxString buf;
50 buf.Printf(wxT("%ld"), value);
51
52 return wxWriteResource(section, entry, buf, file);
53 }
54
55 bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file )
56 {
57 wxString buf;
58 buf.Printf(wxT("%d"), value);
59
60 return wxWriteResource(section, entry, buf, file);
61 }
62
63 bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file )
64 {
65 wxString filename( file );
66 if (filename.empty()) filename = wxT(".wxWindows");
67
68 wxFileConfig conf( wxTheApp->GetAppName(), wxTheApp->GetVendorName(), filename );
69
70 conf.SetPath( section );
71
72 wxString result;
73 if (conf.Read( entry, &result ))
74 {
75 if (!result.empty())
76 {
77 wxChar *s = new wxChar[result.Len()+1];
78 wxStrcpy( s, result.c_str() );
79 *value = s;
80 return true;
81 }
82 }
83
84 return false;
85 }
86
87 bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file )
88 {
89 wxChar *s = NULL;
90 bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
91 if (succ)
92 {
93 *value = (float)wxStrtod(s, (wchar_t **) NULL);
94 delete[] s;
95 return true;
96 }
97 else return false;
98 }
99
100 bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file )
101 {
102 wxChar *s = NULL;
103 bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
104 if (succ)
105 {
106 *value = wxStrtol(s, (wchar_t **) NULL, 10);
107 delete[] s;
108 return true;
109 }
110 else return false;
111 }
112
113 bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file )
114 {
115 wxChar *s = NULL;
116 bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
117 if (succ)
118 {
119 *value = (int)wxStrtol(s, (wchar_t **) NULL, 10);
120 delete[] s;
121 return true;
122 }
123 else return false;
124 }