// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "xmlres.h"
#endif
#if wxUSE_XRC
+#ifndef __WXWINCE__
#include <locale.h>
+#endif
#include "wx/dialog.h"
#include "wx/panel.h"
#include "wx/image.h"
#include "wx/fontmap.h"
#include "wx/artprov.h"
+#include "wx/settings.h"
#include "wx/xml/xml.h"
#include "wx/xrc/xmlres.h"
fnd = wxXmlFindFirst;
else
fnd = filemask;
- while (!!fnd)
+ while (!fnd.empty())
{
// NB: Load() accepts both filenames and URLs (should probably be
// changed to filenames only, but embedded resources currently
XRC_ADD_STYLE(wxNO_BORDER);
XRC_ADD_STYLE(wxTRANSPARENT_WINDOW);
XRC_ADD_STYLE(wxWANTS_CHARS);
+ XRC_ADD_STYLE(wxTAB_TRAVERSAL);
XRC_ADD_STYLE(wxNO_FULL_REPAINT_ON_RESIZE);
XRC_ADD_STYLE(wxFULL_REPAINT_ON_RESIZE);
XRC_ADD_STYLE(wxWS_EX_BLOCK_EVENTS);
+ XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
}
case wxT('n'):
str2 << wxT('\n');
break;
-
+
case wxT('t'):
str2 << wxT('\t');
break;
-
+
case wxT('r'):
str2 << wxT('\r');
break;
break;
}
// else fall-through to default: branch below
-
+
default:
str2 << wxT('\\') << *dt;
break;
#endif
}
}
- else
- {
- // If wxXRC_USE_LOCALE is not set, then the string is already in
- // system's default encoding in ANSI build, so we don't have to
- // do anything special here.
- return str2;
- }
+
+ // If wxXRC_USE_LOCALE is not set, then the string is already in
+ // system's default encoding in ANSI build, so we don't have to
+ // do anything special here.
+ return str2;
}
return value;
}
-
+
float wxXmlResourceHandler::GetFloat(const wxString& param, float defaultv)
{
double value;
wxString str1 = GetParamValue(param);
+#ifndef __WXWINCE__
const char *prevlocale = setlocale(LC_NUMERIC, "C");
-
+#endif
+
if (!str1.ToDouble(&value))
value = defaultv;
+#ifndef __WXWINCE__
setlocale(LC_NUMERIC, prevlocale);
+#endif
return value;
}
wxString v = GetParamValue(param);
v.MakeLower();
if (!v) return defaultv;
- else return (v == wxT("1"));
+
+ return (v == wxT("1"));
}
wxColour clr = GetSystemColour(v);
if (clr.Ok())
return clr;
-
+
wxLogError(_("XRC resource: Incorrect colour specification '%s' for property '%s'."),
v.c_str(), param.c_str());
return wxNullColour;
scl = defaultArtClient;
else
scl = wxART_MAKE_CLIENT_ID_FROM_STR(scl);
-
+
wxBitmap stockArt =
wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(sid),
scl, size);
/* ...or load the bitmap from file: */
wxString name = GetParamValue(param);
- if (name.IsEmpty()) return wxNullBitmap;
+ if (name.empty()) return wxNullBitmap;
#if wxUSE_FILESYSTEM
wxFSFile *fsfile = GetCurFileSystem().OpenFile(name);
if (fsfile == NULL)
wxString wxXmlResourceHandler::GetParamValue(const wxString& param)
{
- if (param.IsEmpty())
+ if (param.empty())
return GetNodeContent(m_node);
else
return GetNodeContent(GetParamNode(param));
-wxSize wxXmlResourceHandler::GetSize(const wxString& param)
+wxSize wxXmlResourceHandler::GetSize(const wxString& param,
+ wxWindow *windowToUse)
{
wxString s = GetParamValue(param);
- if (s.IsEmpty()) s = wxT("-1,-1");
+ if (s.empty()) s = wxT("-1,-1");
bool is_dlg;
long sx, sy = 0;
if (is_dlg)
{
- if (m_parentAsWindow)
+ if (windowToUse)
+ {
+ return wxDLG_UNIT(windowToUse, wxSize(sx, sy));
+ }
+ else if (m_parentAsWindow)
+ {
return wxDLG_UNIT(m_parentAsWindow, wxSize(sx, sy));
+ }
else
{
wxLogError(_("Cannot convert dialog units: dialog unknown."));
return wxDefaultSize;
}
}
- else return wxSize(sx, sy);
+
+ return wxSize(sx, sy);
}
-wxCoord wxXmlResourceHandler::GetDimension(const wxString& param, wxCoord defaultv)
+wxCoord wxXmlResourceHandler::GetDimension(const wxString& param,
+ wxCoord defaultv,
+ wxWindow *windowToUse)
{
wxString s = GetParamValue(param);
- if (s.IsEmpty()) return defaultv;
+ if (s.empty()) return defaultv;
bool is_dlg;
long sx;
if (is_dlg)
{
- if (m_parentAsWindow)
+ if (windowToUse)
+ {
+ return wxDLG_UNIT(windowToUse, wxSize(sx, 0)).x;
+ }
+ else if (m_parentAsWindow)
+ {
return wxDLG_UNIT(m_parentAsWindow, wxSize(sx, 0)).x;
+ }
else
{
wxLogError(_("Cannot convert dialog units: dialog unknown."));
return defaultv;
}
}
- else return sx;
+
+ return sx;
}
// size
int isize = wxDEFAULT;
bool hasSize = HasParam(wxT("size"));
- if (hasSize)
+ if (hasSize)
isize = GetLong(wxT("size"), wxDEFAULT);
// style
if (hasStyle)
{
wxString style = GetParamValue(wxT("style"));
- if (style == wxT("italic"))
+ if (style == wxT("italic"))
istyle = wxITALIC;
- else if (style == wxT("slant"))
+ else if (style == wxT("slant"))
istyle = wxSLANT;
}
if (hasWeight)
{
wxString weight = GetParamValue(wxT("weight"));
- if (weight == wxT("bold"))
+ if (weight == wxT("bold"))
iweight = wxBOLD;
- else if (weight == wxT("light"))
+ else if (weight == wxT("light"))
iweight = wxLIGHT;
}
-
+
// underline
bool hasUnderlined = HasParam(wxT("underlined"));
bool underlined = hasUnderlined ? GetBool(wxT("underlined"), false) : false;
else if (family == wxT("modern")) ifamily = wxMODERN;
else if (family == wxT("teletype")) ifamily = wxTELETYPE;
}
-
-
+
+
wxString facename;
bool hasFacename = HasParam(wxT("face"));
if (hasFacename)
{
wxString encoding = GetParamValue(wxT("encoding"));
wxFontMapper mapper;
- if (!encoding.IsEmpty())
+ if (!encoding.empty())
enc = mapper.CharsetToEncoding(encoding);
if (enc == wxFONTENCODING_SYSTEM)
enc = wxFONTENCODING_DEFAULT;
// is this font based on a system font?
wxFont sysfont = GetSystemFont(GetParamValue(wxT("sysfont")));
-
+
if (sysfont.Ok())
{
if (hasSize)
else if (HasParam(wxT("relativesize")))
sysfont.SetPointSize(int(sysfont.GetPointSize() *
GetFloat(wxT("relativesize"))));
-
+
if (hasStyle)
sysfont.SetStyle(istyle);
if (hasWeight)
m_node = oldnode;
return sysfont;
}
- else
- {
- m_node = oldnode;
- return wxFont(isize, ifamily, istyle, iweight,
- underlined, facename, enc);
- }
+
+ m_node = oldnode;
+ return wxFont(isize, ifamily, istyle, iweight,
+ underlined, facename, enc);
}
stdID(wxID_ANY);
stdID(wxID_SEPARATOR);
-
+
stdID(wxID_OPEN);
stdID(wxID_CLOSE);
stdID(wxID_NEW);