/////////////////////////////////////////////////////////////////////////////
-// Name: xmlres.h
+// Name: wx/xrc/xmlres.h
// Purpose: XML resources
// Author: Vaclav Slavik
// Created: 2000/03/05
#ifndef _WX_XMLRES_H_
#define _WX_XMLRES_H_
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma interface "xmlres.h"
-#endif
-
#include "wx/defs.h"
#if wxUSE_XRC
#include "wx/bitmap.h"
#include "wx/icon.h"
#include "wx/artprov.h"
+#include "wx/colour.h"
#include "wx/xml/xml.h"
class WXDLLIMPEXP_XRC wxXmlResourceDataRecord
{
public:
- wxXmlResourceDataRecord() : Doc(NULL), Time(wxDateTime::Now()) {}
+ wxXmlResourceDataRecord() : Doc(NULL) {
+#if wxUSE_DATETIME
+ Time = wxDateTime::Now();
+#endif
+ }
~wxXmlResourceDataRecord() {delete Doc;}
wxString File;
wxXmlDocument *Doc;
+#if wxUSE_DATETIME
wxDateTime Time;
+#endif
};
// wxXRC_NO_SUBCLASSING
// subclass property of object nodes will be ignored
// (useful for previews in XRC editors)
+ // wxXRC_NO_RELOADING
+ // don't check the modification time of the XRC files and
+ // reload them if they have changed on disk
wxXmlResource(int flags = wxXRC_USE_LOCALE);
// Constructor.
// This method understands VFS (see filesys.h).
bool Load(const wxString& filemask);
+ // Unload resource from the given XML file (wildcards not allowed)
+ bool Unload(const wxString& filename);
+
// Initialize handlers for all supported controls/windows. This will
// make the executable quite big because it forces linking against
// most of the wxWidgets library.
bool AttachUnknownControl(const wxString& name, wxWindow *control,
wxWindow *parent = NULL);
- // Returns a numeric ID that is equivalent to the string id used in an XML
- // resource. To be used in event tables.
- // Macro XRCID is provided for convenience
- static int GetXRCID(const wxChar *str_id);
+ // Returns a numeric ID that is equivalent to the string ID used in an XML
+ // resource. If an unknown str_id is requested (i.e. other than wxID_XXX
+ // or integer), a new record is created which associates the given string
+ // with a number. If value_if_not_found == wxID_NONE, the number is obtained via
+ // wxNewId(). Otherwise value_if_not_found is used.
+ // Macro XRCID(name) is provided for convenient use in event tables.
+ static int GetXRCID(const wxChar *str_id, int value_if_not_found = wxID_NONE);
// Returns version information (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a).
long GetVersion() const { return m_version; }
wxObject *instance = NULL,
wxXmlResourceHandler *handlerToUse = NULL);
+ // Helper of Load() and Unload(): returns the URL corresponding to the
+ // given file if it's indeed a file, otherwise returns the original string
+ // unmodified
+ static wxString ConvertFileNameToURL(const wxString& filename);
+
+ // loading resources from archives is impossible without wxFileSystem
+#if wxUSE_FILESYSTEM
+ // Another helper: detect if the filename is a ZIP or XRS file
+ static bool IsArchive(const wxString& filename);
+#endif // wxUSE_FILESYSTEM
+
private:
long m_version;
// Returns true if the node has a property class equal to classname,
// e.g. <object class="wxDialog">.
- bool IsOfClass(wxXmlNode *node, const wxString& classname)
- { return node->GetPropVal(wxT("class"), wxEmptyString) == classname; }
+ bool IsOfClass(wxXmlNode *node, const wxString& classname);
// Gets node content from wxXML_ENTITY_NODE
// The problem is, <tag>content<tag> is represented as
float GetFloat(const wxString& param, float defaultv = 0);
// Gets colour in HTML syntax (#RRGGBB).
- wxColour GetColour(const wxString& param);
+ wxColour GetColour(const wxString& param, const wxColour& defaultv = wxNullColour);
// Gets the size (may be in dialog units).
wxSize GetSize(const wxString& param = wxT("size"),