]> git.saurik.com Git - wxWidgets.git/blobdiff - src/xrc/xmlres.cpp
Set C++ global locale too in wxAppTraitsBase::SetLocale().
[wxWidgets.git] / src / xrc / xmlres.cpp
index bd2482b47d6f79bbf0ce339da8d89471c4c749df..06edee5ffc33f8f0d7b654f6893b406475c0c1a4 100644 (file)
@@ -107,7 +107,7 @@ class wxXmlResourceDataRecords : public wxVector<wxXmlResourceDataRecord*>
     // this is a class so that it can be forward-declared
 };
 
-WX_DECLARE_HASH_SET_PTR(int, ::wxIntegerHash, ::wxIntegerEqual, wxHashSetInt);
+WX_DECLARE_HASH_SET_PTR(int, wxIntegerHash, wxIntegerEqual, wxHashSetInt);
 
 class wxIdRange // Holds data for a particular rangename
 {
@@ -1482,15 +1482,23 @@ void wxXmlResourceHandler::AddWindowStyles()
     XRC_ADD_STYLE(wxRAISED_BORDER); XRC_ADD_STYLE(wxBORDER_RAISED);
     XRC_ADD_STYLE(wxSTATIC_BORDER); XRC_ADD_STYLE(wxBORDER_STATIC);
     XRC_ADD_STYLE(wxNO_BORDER);     XRC_ADD_STYLE(wxBORDER_NONE);
+    XRC_ADD_STYLE(wxBORDER_DEFAULT);
 
     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(wxVSCROLL);
+    XRC_ADD_STYLE(wxHSCROLL);
     XRC_ADD_STYLE(wxALWAYS_SHOW_SB);
+
     XRC_ADD_STYLE(wxWS_EX_BLOCK_EVENTS);
     XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
+    XRC_ADD_STYLE(wxWS_EX_TRANSIENT);
+    XRC_ADD_STYLE(wxWS_EX_CONTEXTHELP);
+    XRC_ADD_STYLE(wxWS_EX_PROCESS_IDLE);
+    XRC_ADD_STYLE(wxWS_EX_PROCESS_UI_UPDATES);
 }
 
 
@@ -1625,11 +1633,20 @@ wxString wxXmlResourceHandler::GetText(const wxString& param, bool translate)
 
 long wxXmlResourceHandler::GetLong(const wxString& param, long defaultv)
 {
-    long value;
+    long value = defaultv;
     wxString str1 = GetParamValue(param);
 
-    if (!str1.ToLong(&value))
-        value = defaultv;
+    if (!str1.empty())
+    {
+        if (!str1.ToLong(&value))
+        {
+            ReportParamError
+            (
+                param,
+                wxString::Format("invalid long specification \"%s\"", str1)
+            );
+        }
+    }
 
     return value;
 }
@@ -1641,9 +1658,18 @@ float wxXmlResourceHandler::GetFloat(const wxString& param, float defaultv)
     // strings in XRC always use C locale so make sure to use the
     // locale-independent wxString::ToCDouble() and not ToDouble() which uses
     // the current locale with a potentially different decimal point character
-    double value;
-    if (!str.ToCDouble(&value))
-        value = defaultv;
+    double value = defaultv;
+    if (!str.empty())
+    {
+        if (!str.ToCDouble(&value))
+        {
+            ReportParamError
+            (
+                param,
+                wxString::Format("invalid float specification \"%s\"", str)
+            );
+        }
+    }
 
     return wx_truncate_cast(float, value);
 }
@@ -2201,7 +2227,7 @@ static wxFont GetSystemFont(const wxString& name)
     return wxNullFont;
 }
 
-wxFont wxXmlResourceHandler::GetFont(const wxString& param)
+wxFont wxXmlResourceHandler::GetFont(const wxString& param, wxWindow* parent)
 {
     wxXmlNode *font_node = GetParamNode(param);
     if (font_node == NULL)
@@ -2232,6 +2258,14 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param)
             istyle = wxITALIC;
         else if (style == wxT("slant"))
             istyle = wxSLANT;
+        else if (style != wxT("normal"))
+        {
+            ReportParamError
+            (
+                param,
+                wxString::Format("unknown font style \"%s\"", style)
+            );
+        }
     }
 
     // weight
@@ -2244,6 +2278,14 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param)
             iweight = wxBOLD;
         else if (weight == wxT("light"))
             iweight = wxLIGHT;
+        else if (weight != wxT("normal"))
+        {
+            ReportParamError
+            (
+                param,
+                wxString::Format("unknown font weight \"%s\"", weight)
+            );
+        }
     }
 
     // underline
@@ -2262,6 +2304,14 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param)
         else if (family == wxT("swiss")) ifamily = wxSWISS;
         else if (family == wxT("modern")) ifamily = wxMODERN;
         else if (family == wxT("teletype")) ifamily = wxTELETYPE;
+        else
+        {
+            ReportParamError
+            (
+                param,
+                wxString::Format("unknown font family \"%s\"", family)
+            );
+        }
     }
 
 
@@ -2304,13 +2354,50 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param)
     }
 #endif // wxUSE_FONTMAP
 
+    wxFont font;
+
     // is this font based on a system font?
-    wxFont font = GetSystemFont(GetParamValue(wxT("sysfont")));
+    if (HasParam(wxT("sysfont")))
+    {
+        font = GetSystemFont(GetParamValue(wxT("sysfont")));
+        if (HasParam(wxT("inherit")))
+        {
+            ReportParamError
+            (
+                param,
+                "double specification of \"sysfont\" and \"inherit\""
+            );
+        }
+    }
+    // or should the font of the widget be used?
+    else if (GetBool(wxT("inherit"), false))
+    {
+        if (parent)
+            font = parent->GetFont();
+        else
+        {
+            ReportParamError
+            (
+                param,
+                "no parent window specified to derive the font from"
+            );
+        }
+    }
 
     if (font.IsOk())
     {
         if (hasSize && isize != -1)
+        {
             font.SetPointSize(isize);
+            if (HasParam(wxT("relativesize")))
+            {
+                ReportParamError
+                (
+                    param,
+                    "double specification of \"size\" and \"relativesize\""
+                );
+            }
+        }
         else if (HasParam(wxT("relativesize")))
             font.SetPointSize(int(font.GetPointSize() *
                                      GetFloat(wxT("relativesize"))));
@@ -2368,9 +2455,9 @@ void wxXmlResourceHandler::SetupWindow(wxWindow *wnd)
         wnd->SetToolTip(GetText(wxT("tooltip")));
 #endif
     if (HasParam(wxT("font")))
-        wnd->SetFont(GetFont(wxT("font")));
+        wnd->SetFont(GetFont(wxT("font"), wnd));
     if (HasParam(wxT("ownfont")))
-        wnd->SetOwnFont(GetFont(wxT("ownfont")));
+        wnd->SetOwnFont(GetFont(wxT("ownfont"), wnd));
     if (HasParam(wxT("help")))
         wnd->SetHelpText(GetText(wxT("help")));
 }