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