1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XML resources
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2000 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "xmlres.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
22 #include "wx/dialog.h"
24 #include "wx/wfstream.h"
25 #include "wx/filesys.h"
28 #include "wx/tokenzr.h"
29 #include "wx/fontenum.h"
30 #include "wx/module.h"
31 #include "wx/bitmap.h"
33 #include "wx/fontmap.h"
35 #include "wx/xml/xml.h"
36 #include "wx/xml/xmlres.h"
38 #include "wx/arrimpl.cpp"
39 WX_DEFINE_OBJARRAY(wxXmlResourceDataRecords
);
42 wxXmlResource::wxXmlResource(bool use_locale
)
44 m_Handlers
.DeleteContents(TRUE
);
45 m_UseLocale
= use_locale
;
48 wxXmlResource::wxXmlResource(const wxString
& filemask
, bool use_locale
)
50 m_UseLocale
= use_locale
;
51 m_Handlers
.DeleteContents(TRUE
);
55 wxXmlResource::~wxXmlResource()
61 bool wxXmlResource::Load(const wxString
& filemask
)
64 wxXmlResourceDataRecord
*drec
;
65 bool iswild
= wxIsWild(filemask
);
69 # define wxXmlFindFirst fsys.FindFirst(filemask, wxFILE)
70 # define wxXmlFindNext fsys.FindNext()
72 # define wxXmlFindFirst wxFindFirstFile(filemask, wxFILE)
73 # define wxXmlFindNext wxFindNextFile()
82 if (filemask
.Lower().Matches("*.zip") ||
83 filemask
.Lower().Matches("*.rsc"))
88 fnd2
= fs2
.FindFirst(fnd
+ wxT("#zip:*.xmb"), wxFILE
);
91 drec
= new wxXmlResourceDataRecord
;
94 fnd2
= fs2
.FindNext();
100 drec
= new wxXmlResourceDataRecord
;
110 # undef wxXmlFindFirst
111 # undef wxXmlFindNext
117 void wxXmlResource::AddHandler(wxXmlResourceHandler
*handler
)
119 m_Handlers
.Append(handler
);
120 handler
->SetParentResource(this);
125 void wxXmlResource::ClearHandlers()
132 wxMenu
*wxXmlResource::LoadMenu(const wxString
& name
)
134 return (wxMenu
*)CreateResFromNode(FindResource(name
, wxT("wxMenu")), NULL
, NULL
);
139 wxMenuBar
*wxXmlResource::LoadMenuBar(const wxString
& name
)
141 return (wxMenuBar
*)CreateResFromNode(FindResource(name
, wxT("wxMenuBar")), NULL
, NULL
);
146 wxToolBar
*wxXmlResource::LoadToolBar(wxWindow
*parent
, const wxString
& name
)
148 return (wxToolBar
*)CreateResFromNode(FindResource(name
, wxT("wxToolBar")), parent
, NULL
);
153 wxDialog
*wxXmlResource::LoadDialog(wxWindow
*parent
, const wxString
& name
)
155 wxDialog
*dialog
= new wxDialog
;
156 if (!LoadDialog(dialog
, parent
, name
))
157 { delete dialog
; return NULL
; }
161 bool wxXmlResource::LoadDialog(wxDialog
*dlg
, wxWindow
*parent
, const wxString
& name
)
163 return CreateResFromNode(FindResource(name
, wxT("wxDialog")), parent
, dlg
) != NULL
;
168 wxPanel
*wxXmlResource::LoadPanel(wxWindow
*parent
, const wxString
& name
)
170 return (wxPanel
*)CreateResFromNode(FindResource(name
, wxT("wxPanel")), parent
, NULL
);
173 bool wxXmlResource::LoadPanel(wxPanel
*panel
, wxWindow
*parent
, const wxString
& name
)
175 return CreateResFromNode(FindResource(name
, wxT("wxPanel")), parent
, panel
) != NULL
;
178 bool wxXmlResource::LoadFrame(wxFrame
* frame
, wxWindow
*parent
, const wxString
& name
)
180 return CreateResFromNode(FindResource(name
, wxT("wxFrame")), parent
, frame
) != NULL
;
183 wxBitmap
wxXmlResource::LoadBitmap(const wxString
& name
)
185 wxBitmap
*bmp
= (wxBitmap
*)CreateResFromNode(
186 FindResource(name
, wxT("wxBitmap")), NULL
, NULL
);
189 if (bmp
) { rt
= *bmp
; delete bmp
; }
193 wxIcon
wxXmlResource::LoadIcon(const wxString
& name
)
195 wxIcon
*icon
= (wxIcon
*)CreateResFromNode(
196 FindResource(name
, wxT("wxIcon")), NULL
, NULL
);
199 if (icon
) { rt
= *icon
; delete icon
; }
205 void wxXmlResource::ProcessPlatformProperty(wxXmlNode
*node
)
210 wxXmlNode
*c
= node
->GetChildren();
214 if (!c
->GetPropVal(wxT("platform"), &s
))
218 wxStringTokenizer
tkn(s
, " |");
220 while (tkn
.HasMoreTokens())
222 s
= tkn
.GetNextToken();
225 s
== wxString(wxT("win"))
226 #elif defined(__UNIX__)
227 s
== wxString(wxT("unix"))
228 #elif defined(__MAC__)
229 s
== wxString(wxT("mac"))
230 #elif defined(__OS2__)
231 s
== wxString(wxT("os2"))
240 ProcessPlatformProperty(c
);
243 node
->RemoveChild(c
);
253 void wxXmlResource::UpdateResources()
256 # if wxUSE_FILESYSTEM
261 for (size_t i
= 0; i
< m_Data
.GetCount(); i
++)
263 modif
= (m_Data
[i
].Doc
== NULL
);
267 # if wxUSE_FILESYSTEM
268 file
= fsys
.OpenFile(m_Data
[i
].File
);
269 modif
= file
&& file
->GetModificationTime() > m_Data
[i
].Time
;
271 wxLogError(_("Cannot open file '%s'."), m_Data
[i
].File
.c_str());
274 modif
= wxDateTime(wxFileModificationTime(m_Data
[i
].File
)) > m_Data
[i
].Time
;
280 wxInputStream
*stream
;
282 # if wxUSE_FILESYSTEM
283 file
= fsys
.OpenFile(m_Data
[i
].File
);
284 stream
= file
->GetStream();
286 stream
= new wxFileInputStream(m_Data
[i
].File
);
291 delete m_Data
[i
].Doc
;
292 m_Data
[i
].Doc
= new wxXmlDocument
;
294 if (!stream
|| !m_Data
[i
].Doc
->Load(*stream
))
296 wxLogError(_("Cannot load resources from file '%s'."), m_Data
[i
].File
.c_str());
297 delete m_Data
[i
].Doc
;
298 m_Data
[i
].Doc
= NULL
;
300 else if (m_Data
[i
].Doc
->GetRoot()->GetName() != wxT("resource"))
302 wxLogError(_("Invalid XML resource '%s': doesn't have root node 'resource'."), m_Data
[i
].File
.c_str());
303 delete m_Data
[i
].Doc
;
304 m_Data
[i
].Doc
= NULL
;
307 ProcessPlatformProperty(m_Data
[i
].Doc
->GetRoot());
309 # if wxUSE_FILESYSTEM
320 wxXmlNode
*wxXmlResource::FindResource(const wxString
& name
, const wxString
& classname
)
322 UpdateResources(); //ensure everything is up-to-date
325 for (size_t f
= 0; f
< m_Data
.GetCount(); f
++)
327 if (m_Data
[f
].Doc
== NULL
|| m_Data
[f
].Doc
->GetRoot() == NULL
) continue;
328 for (wxXmlNode
*node
= m_Data
[f
].Doc
->GetRoot()->GetChildren();
329 node
; node
= node
->GetNext())
330 if (node
->GetType() == wxXML_ELEMENT_NODE
&&
332 node
->GetPropVal(wxT("class"), wxEmptyString
) == classname
) &&
333 node
->GetName() == wxT("object") &&
334 node
->GetPropVal(wxT("name"), &dummy
) &&
338 m_CurFileSystem
.ChangePathTo(m_Data
[f
].File
);
344 wxLogError(_("XML resource '%s' (class '%s') not found!"),
345 name
.c_str(), classname
.c_str());
351 wxObject
*wxXmlResource::CreateResFromNode(wxXmlNode
*node
, wxObject
*parent
, wxObject
*instance
)
353 if (node
== NULL
) return NULL
;
355 wxXmlResourceHandler
*handler
;
357 wxNode
* ND
= m_Handlers
.GetFirst();
360 handler
= (wxXmlResourceHandler
*)ND
->GetData();
361 if (node
->GetName() == wxT("object") && handler
->CanHandle(node
))
363 ret
= handler
->CreateResource(node
, parent
, instance
);
369 wxLogError(_("No handler found for XML node '%s', class '%s'!"),
370 node
->GetName().c_str(),
371 node
->GetPropVal(wxT("class"), wxEmptyString
).c_str());
383 wxXmlResourceHandler::wxXmlResourceHandler()
384 : m_Node(NULL
), m_Parent(NULL
), m_Instance(NULL
),
385 m_ParentAsWindow(NULL
), m_InstanceAsWindow(NULL
)
390 wxObject
*wxXmlResourceHandler::CreateResource(wxXmlNode
*node
, wxObject
*parent
, wxObject
*instance
)
392 wxXmlNode
*myNode
= m_Node
;
393 wxString myClass
= m_Class
;
394 wxObject
*myParent
= m_Parent
, *myInstance
= m_Instance
;
395 wxWindow
*myParentAW
= m_ParentAsWindow
, *myInstanceAW
= m_InstanceAsWindow
;
398 m_Class
= node
->GetPropVal(wxT("class"), wxEmptyString
);
400 m_Instance
= instance
;
401 m_ParentAsWindow
= wxDynamicCast(m_Parent
, wxWindow
);
402 m_InstanceAsWindow
= wxDynamicCast(m_Instance
, wxWindow
);
404 wxObject
*returned
= DoCreateResource();
408 m_Parent
= myParent
; m_ParentAsWindow
= myParentAW
;
409 m_Instance
= myInstance
; m_InstanceAsWindow
= myInstanceAW
;
415 void wxXmlResourceHandler::AddStyle(const wxString
& name
, int value
)
417 m_StyleNames
.Add(name
);
418 m_StyleValues
.Add(value
);
423 void wxXmlResourceHandler::AddWindowStyles()
425 ADD_STYLE(wxSIMPLE_BORDER
);
426 ADD_STYLE(wxSUNKEN_BORDER
);
427 ADD_STYLE(wxDOUBLE_BORDER
);
428 ADD_STYLE(wxRAISED_BORDER
);
429 ADD_STYLE(wxSTATIC_BORDER
);
430 ADD_STYLE(wxTRANSPARENT_WINDOW
);
431 ADD_STYLE(wxWANTS_CHARS
);
432 ADD_STYLE(wxNO_FULL_REPAINT_ON_RESIZE
);
437 bool wxXmlResourceHandler::HasParam(const wxString
& param
)
439 return (GetParamNode(param
) != NULL
);
443 int wxXmlResourceHandler::GetStyle(const wxString
& param
, int defaults
)
445 wxString s
= GetParamValue(param
);
447 if (!s
) return defaults
;
449 wxStringTokenizer
tkn(s
, wxT("| "), wxTOKEN_STRTOK
);
453 while (tkn
.HasMoreTokens())
455 fl
= tkn
.GetNextToken();
456 index
= m_StyleNames
.Index(fl
);
457 if (index
!= wxNOT_FOUND
)
458 style
|= m_StyleValues
[index
];
460 wxLogError(_("Unknown style flag ") + fl
);
467 wxString
wxXmlResourceHandler::GetText(const wxString
& param
)
469 wxString str1
= GetParamValue(param
);
473 for (dt
= str1
.c_str(); *dt
; dt
++)
475 // Remap $ to &, map $$ to $ (for things like "&File..." --
476 // this is illegal in XML, so we use "$File..."):
480 case '$' : str2
<< '$'; break;
481 default : str2
<< '&' << *dt
; break;
483 // Remap \n to CR, \r LF, \t to TAB:
484 else if (*dt
== '\\')
487 case 'n' : str2
<< '\n'; break;
488 case 't' : str2
<< '\t'; break;
489 case 'r' : str2
<< '\r'; break;
490 default : str2
<< '\\' << *dt
; break;
495 if (m_Resource
->GetUseLocale())
496 return wxGetTranslation(str2
);
503 long wxXmlResourceHandler::GetLong(const wxString
& param
, long defaultv
)
506 wxString str1
= GetParamValue(param
);
508 if (!str1
.ToLong(&value
))
515 int wxXmlResourceHandler::GetID()
517 wxString sid
= GetName();
520 if (sid
== wxT("-1")) return -1;
521 else if (sid
.IsNumber() && sid
.ToLong(&num
)) return num
;
522 #define stdID(id) else if (sid == wxT(#id)) return id
523 stdID(wxID_OPEN
); stdID(wxID_CLOSE
); stdID(wxID_NEW
);
524 stdID(wxID_SAVE
); stdID(wxID_SAVEAS
); stdID(wxID_REVERT
);
525 stdID(wxID_EXIT
); stdID(wxID_UNDO
); stdID(wxID_REDO
);
526 stdID(wxID_HELP
); stdID(wxID_PRINT
); stdID(wxID_PRINT_SETUP
);
527 stdID(wxID_PREVIEW
); stdID(wxID_ABOUT
); stdID(wxID_HELP_CONTENTS
);
528 stdID(wxID_HELP_COMMANDS
); stdID(wxID_HELP_PROCEDURES
);
529 stdID(wxID_CUT
); stdID(wxID_COPY
); stdID(wxID_PASTE
);
530 stdID(wxID_CLEAR
); stdID(wxID_FIND
); stdID(wxID_DUPLICATE
);
531 stdID(wxID_SELECTALL
); stdID(wxID_OK
); stdID(wxID_CANCEL
);
532 stdID(wxID_APPLY
); stdID(wxID_YES
); stdID(wxID_NO
);
533 stdID(wxID_STATIC
); stdID(wxID_FORWARD
); stdID(wxID_BACKWARD
);
534 stdID(wxID_DEFAULT
); stdID(wxID_MORE
); stdID(wxID_SETUP
);
535 stdID(wxID_RESET
); stdID(wxID_HELP_CONTEXT
);
537 else return XMLID(sid
.c_str());
541 wxString
wxXmlResourceHandler::GetName()
543 return m_Node
->GetPropVal(wxT("name"), wxT("-1"));
548 bool wxXmlResourceHandler::GetBool(const wxString
& param
, bool defaultv
)
550 wxString v
= GetParamValue(param
);
552 if (!v
) return defaultv
;
553 else return (v
== wxT("1"));
558 wxColour
wxXmlResourceHandler::GetColour(const wxString
& param
)
560 wxString v
= GetParamValue(param
);
561 unsigned long tmp
= 0;
563 if (v
.Length() != 7 || v
[0] != wxT('#') ||
564 wxSscanf(v
.c_str(), wxT("#%lX"), &tmp
) != 1)
566 wxLogError(_("XML resource: Incorrect colour specification '%s' for property '%s'."),
567 v
.c_str(), param
.c_str());
571 return wxColour((tmp
& 0xFF0000) >> 16 ,
572 (tmp
& 0x00FF00) >> 8,
578 wxBitmap
wxXmlResourceHandler::GetBitmap(const wxString
& param
, wxSize size
)
580 wxString name
= GetParamValue(param
);
581 if (name
.IsEmpty()) return wxNullBitmap
;
583 wxFSFile
*fsfile
= GetCurFileSystem().OpenFile(name
);
586 wxLogError(_("XML resource: Cannot create bitmap from '%s'."), param
.mb_str());
589 wxImage
img(*(fsfile
->GetStream()));
592 wxImage
img(GetParamValue(wxT("bitmap")));
596 wxLogError(_("XML resource: Cannot create bitmap from '%s'."), param
.mb_str());
599 if (!(size
== wxDefaultSize
)) img
.Rescale(size
.x
, size
.y
);
600 return img
.ConvertToBitmap();
605 wxIcon
wxXmlResourceHandler::GetIcon(const wxString
& param
, wxSize size
)
607 #if wxCHECK_VERSION(2,3,0) || defined(__WXMSW__)
609 icon
.CopyFromBitmap(GetBitmap(param
, size
));
612 wxBitmap bmppt
= GetBitmap(param
, size
);
613 iconpt
= (wxIcon
*)(&bmppt
);
614 wxIcon
icon(*iconpt
);
621 wxXmlNode
*wxXmlResourceHandler::GetParamNode(const wxString
& param
)
623 wxXmlNode
*n
= m_Node
->GetChildren();
627 if (n
->GetType() == wxXML_ELEMENT_NODE
&& n
->GetName() == param
)
635 wxString
wxXmlResourceHandler::GetNodeContent(wxXmlNode
*node
)
638 if (n
== NULL
) return wxEmptyString
;
639 n
= n
->GetChildren();
643 if (n
->GetType() == wxXML_TEXT_NODE
||
644 n
->GetType() == wxXML_CDATA_SECTION_NODE
)
645 return n
->GetContent();
648 return wxEmptyString
;
653 wxString
wxXmlResourceHandler::GetParamValue(const wxString
& param
)
656 return GetNodeContent(m_Node
);
658 return GetNodeContent(GetParamNode(param
));
663 wxSize
wxXmlResourceHandler::GetSize(const wxString
& param
)
665 wxString s
= GetParamValue(param
);
666 if (s
.IsEmpty()) s
= wxT("-1,-1");
670 is_dlg
= s
[s
.Length()-1] == wxT('d');
671 if (is_dlg
) s
.RemoveLast();
673 if (!s
.BeforeFirst(wxT(',')).ToLong(&sx
) ||
674 !s
.AfterLast(wxT(',')).ToLong(&sy
))
676 wxLogError(_("Cannot parse coordinates from '%s'."), s
.mb_str());
677 return wxDefaultSize
;
682 if (m_InstanceAsWindow
)
683 return wxDLG_UNIT(m_InstanceAsWindow
, wxSize(sx
, sy
));
684 else if (m_ParentAsWindow
)
685 return wxDLG_UNIT(m_ParentAsWindow
, wxSize(sx
, sy
));
688 wxLogError(_("Cannot convert dialog units: dialog unknown."));
689 return wxDefaultSize
;
692 else return wxSize(sx
, sy
);
697 wxPoint
wxXmlResourceHandler::GetPosition(const wxString
& param
)
699 wxSize sz
= GetSize(param
);
700 return wxPoint(sz
.x
, sz
.y
);
705 wxCoord
wxXmlResourceHandler::GetDimension(const wxString
& param
, wxCoord defaultv
)
707 wxString s
= GetParamValue(param
);
708 if (s
.IsEmpty()) return defaultv
;
712 is_dlg
= s
[s
.Length()-1] == wxT('d');
713 if (is_dlg
) s
.RemoveLast();
717 wxLogError(_("Cannot parse dimension from '%s'."), s
.mb_str());
723 if (m_InstanceAsWindow
)
724 return wxDLG_UNIT(m_InstanceAsWindow
, wxSize(sx
, 0)).x
;
725 else if (m_ParentAsWindow
)
726 return wxDLG_UNIT(m_ParentAsWindow
, wxSize(sx
, 0)).x
;
729 wxLogError(_("Cannot convert dialog units: dialog unknown."));
738 wxFont
wxXmlResourceHandler::GetFont(const wxString
& param
)
740 wxXmlNode
*font_node
= GetParamNode(param
);
741 if (font_node
== NULL
)
743 wxLogError(_("Cannot find font node '%s'."), param
.mb_str());
747 wxXmlNode
*oldnode
= m_Node
;
750 long size
= GetLong(wxT("size"), 12);
752 wxString style
= GetParamValue(wxT("style"));
753 wxString weight
= GetParamValue(wxT("weight"));
754 int istyle
= wxNORMAL
, iweight
= wxNORMAL
;
755 if (style
== wxT("italic")) istyle
= wxITALIC
;
756 else if (style
== wxT("slant")) istyle
= wxSLANT
;
757 if (weight
== wxT("bold")) iweight
= wxBOLD
;
758 else if (weight
== wxT("light")) iweight
= wxLIGHT
;
760 wxString family
= GetParamValue(wxT("family"));
761 int ifamily
= wxDEFAULT
;
762 if (family
== wxT("decorative")) ifamily
= wxDECORATIVE
;
763 else if (family
== wxT("roman")) ifamily
= wxROMAN
;
764 else if (family
== wxT("script")) ifamily
= wxSCRIPT
;
765 else if (family
== wxT("swiss")) ifamily
= wxSWISS
;
766 else if (family
== wxT("modern")) ifamily
= wxMODERN
;
768 bool underlined
= GetBool(wxT("underlined"), FALSE
);
770 wxString encoding
= GetParamValue(wxT("encoding"));
772 wxFontEncoding enc
= wxFONTENCODING_DEFAULT
;
773 if (!encoding
.IsEmpty()) enc
= mapper
.CharsetToEncoding(encoding
);
774 if (enc
== wxFONTENCODING_SYSTEM
) enc
= wxFONTENCODING_SYSTEM
;
776 wxString faces
= GetParamValue(wxT("face"));
777 wxString facename
= wxEmptyString
;
778 wxFontEnumerator enu
;
779 enu
.EnumerateFacenames();
780 wxStringTokenizer
tk(faces
, wxT(","));
781 while (tk
.HasMoreTokens())
783 int index
= enu
.GetFacenames()->Index(tk
.GetNextToken(), FALSE
);
784 if (index
!= wxNOT_FOUND
)
786 facename
= (*enu
.GetFacenames())[index
];
793 wxFont
font(size
, ifamily
, istyle
, iweight
, underlined
, facename
, enc
);
798 void wxXmlResourceHandler::SetupWindow(wxWindow
*wnd
)
802 if (HasParam(wxT("exstyle")))
803 wnd
->SetExtraStyle(GetStyle(wxT("exstyle")));
804 if (HasParam(wxT("bg")))
805 wnd
->SetBackgroundColour(GetColour(wxT("bg")));
806 if (HasParam(wxT("fg")))
807 wnd
->SetForegroundColour(GetColour(wxT("fg")));
808 if (GetBool(wxT("enabled"), 1) == 0)
810 if (GetBool(wxT("focused"), 0) == 1)
812 if (GetBool(wxT("hidden"), 0) == 1)
815 if (HasParam(wxT("tooltip")))
816 wnd
->SetToolTip(GetText(wxT("tooltip")));
818 if (HasParam(wxT("font")))
819 wnd
->SetFont(GetFont());
823 void wxXmlResourceHandler::CreateChildren(wxObject
*parent
, bool this_hnd_only
)
825 wxXmlNode
*n
= m_Node
->GetChildren();
829 if (n
->GetType() == wxXML_ELEMENT_NODE
&&
830 n
->GetName() == wxT("object"))
832 if (this_hnd_only
&& CanHandle(n
))
833 CreateResource(n
, parent
, NULL
);
835 m_Resource
->CreateResFromNode(n
, parent
, NULL
);
842 void wxXmlResourceHandler::CreateChildrenPrivately(wxObject
*parent
, wxXmlNode
*rootnode
)
845 if (rootnode
== NULL
) root
= m_Node
; else root
= rootnode
;
846 wxXmlNode
*n
= root
->GetChildren();
850 if (n
->GetType() == wxXML_ELEMENT_NODE
&& CanHandle(n
))
852 CreateResource(n
, parent
, NULL
);
866 // --------------- XMLID implementation -----------------------------
868 #define XMLID_TABLE_SIZE 1024
878 static XMLID_record
*XMLID_Records
[XMLID_TABLE_SIZE
] = {NULL
};
880 /*static*/ int wxXmlResource::GetXMLID(const char *str_id
)
882 static int XMLID_LastID
= wxID_HIGHEST
;
886 for (const char *c
= str_id
; *c
!= '\0'; c
++) index
+= (int)*c
;
887 index
%= XMLID_TABLE_SIZE
;
889 XMLID_record
*oldrec
= NULL
;
891 for (XMLID_record
*rec
= XMLID_Records
[index
]; rec
; rec
= rec
->next
)
893 if (strcmp(rec
->key
, str_id
) == 0)
901 XMLID_record
**rec_var
= (oldrec
== NULL
) ?
902 &XMLID_Records
[index
] : &oldrec
->next
;
903 *rec_var
= new XMLID_record
;
904 (*rec_var
)->id
= ++XMLID_LastID
;
905 (*rec_var
)->key
= strdup(str_id
);
906 (*rec_var
)->next
= NULL
;
908 return (*rec_var
)->id
;
912 static void CleanXMLID_Record(XMLID_record
*rec
)
916 CleanXMLID_Record(rec
->next
);
922 static void CleanXMLID_Records()
924 for (int i
= 0; i
< XMLID_TABLE_SIZE
; i
++)
925 CleanXMLID_Record(XMLID_Records
[i
]);
935 // --------------- module and globals -----------------------------
938 static wxXmlResource gs_XmlResource
;
940 wxXmlResource
*wxTheXmlResource
= &gs_XmlResource
;
943 class wxXmlResourceModule
: public wxModule
945 DECLARE_DYNAMIC_CLASS(wxXmlResourceModule
)
947 wxXmlResourceModule() {}
948 bool OnInit() {return TRUE
;}
951 wxTheXmlResource
->ClearHandlers();
952 CleanXMLID_Records();
956 IMPLEMENT_DYNAMIC_CLASS(wxXmlResourceModule
, wxModule
)