]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/utilsres.cpp
Shell version of dllar, needed for building DLLs while generating
[wxWidgets.git] / src / gtk1 / 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
14f355c2 10//#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
c801d85f
KB
11//#pragma implementation "utils.h"
12//#endif
13
14f355c2
VS
14// For compilers that support precompilation, includes "wx.h".
15#include "wx/wxprec.h"
16
c801d85f
KB
17#include "wx/utils.h"
18#include "wx/string.h"
19#include "wx/list.h"
c693edf3 20#include "wx/log.h"
bd046d42
RR
21#include "wx/config.h"
22#include "wx/app.h"
c801d85f
KB
23
24//-----------------------------------------------------------------------------
25// resource functions
26//-----------------------------------------------------------------------------
27
28bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file )
29{
bd046d42
RR
30 wxString filename( file );
31 if (filename.IsEmpty()) 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}
c801d85f
KB
39
40bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file )
41{
bd046d42
RR
42 wxString buf;
43 buf.Printf(wxT("%.4f"), value);
44
c801d85f 45 return wxWriteResource(section, entry, buf, file);
bd046d42 46}
c801d85f
KB
47
48bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file )
49{
bd046d42
RR
50 wxString buf;
51 buf.Printf(wxT("%ld"), value);
52
c801d85f 53 return wxWriteResource(section, entry, buf, file);
bd046d42 54}
c801d85f
KB
55
56bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file )
57{
bd046d42
RR
58 wxString buf;
59 buf.Printf(wxT("%d"), value);
60
c801d85f 61 return wxWriteResource(section, entry, buf, file);
bd046d42 62}
c801d85f 63
cbf97a6c 64bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file )
c801d85f 65{
bd046d42
RR
66 wxString filename( file );
67 if (filename.IsEmpty()) filename = wxT(".wxWindows");
9c2882d9 68
bd046d42 69 wxFileConfig conf( wxTheApp->GetAppName(), wxTheApp->GetVendorName(), filename );
9c2882d9 70
bd046d42 71 conf.SetPath( section );
9c2882d9 72
bd046d42 73 wxString result;
9c2882d9 74 if (conf.Read( entry, &result ))
3e61c765 75 {
bd046d42 76 if (!result.IsEmpty())
9c2882d9 77 {
cbf97a6c 78 wxChar *s = new wxChar[result.Len()+1];
9c2882d9
VZ
79 wxStrcpy( s, result.c_str() );
80 *value = s;
81 return TRUE;
82 }
c801d85f 83 }
9c2882d9 84
c801d85f 85 return FALSE;
bd046d42 86}
c801d85f
KB
87
88bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file )
89{
bd046d42
RR
90 wxChar *s = NULL;
91 bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
92 if (succ)
3e61c765 93 {
bd046d42
RR
94 *value = (float)wxStrtod(s, NULL);
95 delete[] s;
a3622daa 96 return TRUE;
bd046d42
RR
97 }
98 else return FALSE;
99}
c801d85f
KB
100
101bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file )
102{
bd046d42
RR
103 wxChar *s = NULL;
104 bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
105 if (succ)
3e61c765 106 {
bd046d42
RR
107 *value = wxStrtol(s, NULL, 10);
108 delete[] s;
a3622daa 109 return TRUE;
bd046d42
RR
110 }
111 else return FALSE;
112}
c801d85f
KB
113
114bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file )
115{
bd046d42
RR
116 wxChar *s = NULL;
117 bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
118 if (succ)
3e61c765 119 {
bd046d42
RR
120 *value = (int)wxStrtol(s, NULL, 10);
121 delete[] s;
a3622daa 122 return TRUE;
bd046d42
RR
123 }
124 else return FALSE;
125}
c801d85f 126