]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/utilsres.cpp
minimize overlay area to avoid eg scrolling artifacts when using a caret
[wxWidgets.git] / src / gtk / utilsres.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/gtk/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
28bool 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
40bool 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
48bool 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
56bool 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
64bool 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
88bool 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, NULL);
95 delete[] s;
96 return true;
97 }
98 else return false;
99}
100
101bool 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, NULL, 10);
108 delete[] s;
109 return true;
110 }
111 else return false;
112}
113
114bool 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, NULL, 10);
121 delete[] s;
122 return true;
123 }
124 else return false;
125}