More patches from FM to clean up after moving contribs. Also removes

use of wxUSE_RESOURCES


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45280 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2007-04-06 21:08:30 +00:00
parent 79f45cf784
commit cf63f3d3ae
19 changed files with 35 additions and 1379 deletions

View File

@@ -38,113 +38,6 @@
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// functions to work with .INI files
// ----------------------------------------------------------------------------
// Reading and writing resources (eg WIN.INI, .Xdefaults)
#if wxUSE_RESOURCES
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
{
if (file != wxEmptyString)
// Don't know what the correct cast should be, but it doesn't
// compile in BC++/16-bit without this cast.
#if !defined(__WIN32__)
return (WritePrivateProfileString((const char*) section, (const char*) entry, (const char*) value, (const char*) file) != 0);
#else
return (WritePrivateProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)value, (LPCTSTR)WXSTRINGCAST file) != 0);
#endif
else
return (WriteProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)WXSTRINGCAST value) != 0);
}
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
{
wxString buf;
buf.Printf(wxT("%.4f"), value);
return wxWriteResource(section, entry, buf, file);
}
bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file)
{
wxString buf;
buf.Printf(wxT("%ld"), value);
return wxWriteResource(section, entry, buf, file);
}
bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file)
{
wxString buf;
buf.Printf(wxT("%d"), value);
return wxWriteResource(section, entry, buf, file);
}
bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file)
{
static const wxChar defunkt[] = wxT("$$default");
wxChar buf[1024];
if (file != wxEmptyString)
{
int n = GetPrivateProfileString(section, entry, defunkt,
buf, WXSIZEOF(buf), file);
if (n == 0 || wxStrcmp(buf, defunkt) == 0)
return false;
}
else
{
int n = GetProfileString(section, entry, defunkt, buf, WXSIZEOF(buf));
if (n == 0 || wxStrcmp(buf, defunkt) == 0)
return false;
}
if (*value) delete[] (*value);
*value = wxStrcpy(new wxChar[wxStrlen(buf) + 1], buf);
return true;
}
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
{
wxChar *s = NULL;
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
if (succ)
{
*value = (float)wxStrtod(s, NULL);
delete[] s;
return true;
}
else return false;
}
bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
{
wxChar *s = NULL;
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
if (succ)
{
*value = wxStrtol(s, NULL, 10);
delete[] s;
return true;
}
else return false;
}
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
{
wxChar *s = NULL;
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
if (succ)
{
*value = (int)wxStrtol(s, NULL, 10);
delete[] s;
return true;
}
else return false;
}
#endif // wxUSE_RESOURCES
// ---------------------------------------------------------------------------
// helper functions for showing a "busy" cursor
// ---------------------------------------------------------------------------