]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/utilsres.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/utilsres.cpp
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
16 #include "wx/string.h"
21 #include "wx/config.h"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
27 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, const wxString
& value
, const wxString
& file
)
29 wxString
filename( file
);
30 if (filename
.empty()) filename
= wxT(".wxWindows");
32 wxFileConfig
conf( wxTheApp
->GetAppName(), wxTheApp
->GetVendorName(), filename
);
34 conf
.SetPath( section
);
36 return conf
.Write( entry
, value
);
39 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, float value
, const wxString
& file
)
42 buf
.Printf(wxT("%.4f"), value
);
44 return wxWriteResource(section
, entry
, buf
, file
);
47 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, long value
, const wxString
& file
)
50 buf
.Printf(wxT("%ld"), value
);
52 return wxWriteResource(section
, entry
, buf
, file
);
55 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, int value
, const wxString
& file
)
58 buf
.Printf(wxT("%d"), value
);
60 return wxWriteResource(section
, entry
, buf
, file
);
63 bool wxGetResource(const wxString
& section
, const wxString
& entry
, wxChar
**value
, const wxString
& file
)
65 wxString
filename( file
);
66 if (filename
.empty()) filename
= wxT(".wxWindows");
68 wxFileConfig
conf( wxTheApp
->GetAppName(), wxTheApp
->GetVendorName(), filename
);
70 conf
.SetPath( section
);
73 if (conf
.Read( entry
, &result
))
77 wxChar
*s
= new wxChar
[result
.Len()+1];
78 wxStrcpy( s
, result
.c_str() );
87 bool wxGetResource(const wxString
& section
, const wxString
& entry
, float *value
, const wxString
& file
)
90 bool succ
= wxGetResource(section
, entry
, (wxChar
**)&s
, file
);
93 *value
= (float)wxStrtod(s
, (wchar_t **) NULL
);
100 bool wxGetResource(const wxString
& section
, const wxString
& entry
, long *value
, const wxString
& file
)
103 bool succ
= wxGetResource(section
, entry
, (wxChar
**)&s
, file
);
106 *value
= wxStrtol(s
, (wchar_t **) NULL
, 10);
113 bool wxGetResource(const wxString
& section
, const wxString
& entry
, int *value
, const wxString
& file
)
116 bool succ
= wxGetResource(section
, entry
, (wxChar
**)&s
, file
);
119 *value
= (int)wxStrtol(s
, (wchar_t **) NULL
, 10);