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