]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/utilsres.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/utilsres.cpp
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
17 #include "wx/string.h"
22 #include "wx/config.h"
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, const wxString
& value
, const wxString
& file
)
30 wxString
filename( file
);
31 if (filename
.empty()) filename
= wxT(".wxWindows");
33 wxFileConfig
conf( wxTheApp
->GetAppName(), wxTheApp
->GetVendorName(), filename
);
35 conf
.SetPath( section
);
37 return conf
.Write( entry
, value
);
40 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, float value
, const wxString
& file
)
43 buf
.Printf(wxT("%.4f"), value
);
45 return wxWriteResource(section
, entry
, buf
, file
);
48 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, long value
, const wxString
& file
)
51 buf
.Printf(wxT("%ld"), value
);
53 return wxWriteResource(section
, entry
, buf
, file
);
56 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, int value
, const wxString
& file
)
59 buf
.Printf(wxT("%d"), value
);
61 return wxWriteResource(section
, entry
, buf
, file
);
64 bool wxGetResource(const wxString
& section
, const wxString
& entry
, wxChar
**value
, const wxString
& file
)
66 wxString
filename( file
);
67 if (filename
.empty()) filename
= wxT(".wxWindows");
69 wxFileConfig
conf( wxTheApp
->GetAppName(), wxTheApp
->GetVendorName(), filename
);
71 conf
.SetPath( section
);
74 if (conf
.Read( entry
, &result
))
78 wxChar
*s
= new wxChar
[result
.Len()+1];
79 wxStrcpy( s
, result
.c_str() );
88 bool wxGetResource(const wxString
& section
, const wxString
& entry
, float *value
, const wxString
& file
)
91 bool succ
= wxGetResource(section
, entry
, (wxChar
**)&s
, file
);
94 *value
= (float)wxStrtod(s
, NULL
);
101 bool wxGetResource(const wxString
& section
, const wxString
& entry
, long *value
, const wxString
& file
)
104 bool succ
= wxGetResource(section
, entry
, (wxChar
**)&s
, file
);
107 *value
= wxStrtol(s
, NULL
, 10);
114 bool wxGetResource(const wxString
& section
, const wxString
& entry
, int *value
, const wxString
& file
)
117 bool succ
= wxGetResource(section
, entry
, (wxChar
**)&s
, file
);
120 *value
= (int)wxStrtol(s
, NULL
, 10);