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"
25 #include "wx/wfstream.h"
26 #include "wx/filesys.h"
29 #include "wx/tokenzr.h"
30 #include "wx/fontenum.h"
31 #include "wx/module.h"
32 #include "wx/bitmap.h"
34 #include "wx/fontmap.h"
36 #include "wx/xml/xml.h"
37 #include "wx/xml/xmlres.h"
39 #include "wx/arrimpl.cpp"
40 WX_DEFINE_OBJARRAY(wxXmlResourceDataRecords
);
43 wxXmlResource::wxXmlResource(bool use_locale
)
45 m_Handlers
.DeleteContents(TRUE
);
46 m_UseLocale
= use_locale
;
49 wxXmlResource::wxXmlResource(const wxString
& filemask
, bool use_locale
)
51 m_UseLocale
= use_locale
;
52 m_Handlers
.DeleteContents(TRUE
);
56 wxXmlResource::~wxXmlResource()
62 bool wxXmlResource::Load(const wxString
& filemask
)
65 wxXmlResourceDataRecord
*drec
;
66 bool iswild
= wxIsWild(filemask
);
70 # define wxXmlFindFirst fsys.FindFirst(filemask, wxFILE)
71 # define wxXmlFindNext fsys.FindNext()
73 # define wxXmlFindFirst wxFindFirstFile(filemask, wxFILE)
74 # define wxXmlFindNext wxFindNextFile()
83 if (filemask
.Lower().Matches("*.zip") ||
84 filemask
.Lower().Matches("*.rsc"))
89 fnd2
= fs2
.FindFirst(fnd
+ wxT("#zip:*.xmb"), wxFILE
);
92 drec
= new wxXmlResourceDataRecord
;
95 fnd2
= fs2
.FindNext();
101 drec
= new wxXmlResourceDataRecord
;
111 # undef wxXmlFindFirst
112 # undef wxXmlFindNext
118 void wxXmlResource::AddHandler(wxXmlResourceHandler
*handler
)
120 m_Handlers
.Append(handler
);
121 handler
->SetParentResource(this);
126 void wxXmlResource::ClearHandlers()
133 wxMenu
*wxXmlResource::LoadMenu(const wxString
& name
)
135 return (wxMenu
*)CreateResFromNode(FindResource(name
, wxT("wxMenu")), NULL
, NULL
);
140 wxMenuBar
*wxXmlResource::LoadMenuBar(const wxString
& name
)
142 return (wxMenuBar
*)CreateResFromNode(FindResource(name
, wxT("wxMenuBar")), NULL
, NULL
);
147 wxToolBar
*wxXmlResource::LoadToolBar(wxWindow
*parent
, const wxString
& name
)
149 return (wxToolBar
*)CreateResFromNode(FindResource(name
, wxT("wxToolBar")), parent
, NULL
);
154 wxDialog
*wxXmlResource::LoadDialog(wxWindow
*parent
, const wxString
& name
)
156 wxDialog
*dialog
= new wxDialog
;
157 if (!LoadDialog(dialog
, parent
, name
))
158 { delete dialog
; return NULL
; }
162 bool wxXmlResource::LoadDialog(wxDialog
*dlg
, wxWindow
*parent
, const wxString
& name
)
164 return CreateResFromNode(FindResource(name
, wxT("wxDialog")), parent
, dlg
) != NULL
;
169 wxPanel
*wxXmlResource::LoadPanel(wxWindow
*parent
, const wxString
& name
)
171 return (wxPanel
*)CreateResFromNode(FindResource(name
, wxT("wxPanel")), parent
, NULL
);
174 bool wxXmlResource::LoadPanel(wxPanel
*panel
, wxWindow
*parent
, const wxString
& name
)
176 return CreateResFromNode(FindResource(name
, wxT("wxPanel")), parent
, panel
) != NULL
;
179 bool wxXmlResource::LoadFrame(wxFrame
* frame
, wxWindow
*parent
, const wxString
& name
)
181 return CreateResFromNode(FindResource(name
, wxT("wxFrame")), parent
, frame
) != NULL
;
184 wxBitmap
wxXmlResource::LoadBitmap(const wxString
& name
)
186 wxBitmap
*bmp
= (wxBitmap
*)CreateResFromNode(
187 FindResource(name
, wxT("wxBitmap")), NULL
, NULL
);
190 if (bmp
) { rt
= *bmp
; delete bmp
; }
194 wxIcon
wxXmlResource::LoadIcon(const wxString
& name
)
196 wxIcon
*icon
= (wxIcon
*)CreateResFromNode(
197 FindResource(name
, wxT("wxIcon")), NULL
, NULL
);
200 if (icon
) { rt
= *icon
; delete icon
; }
206 void wxXmlResource::ProcessPlatformProperty(wxXmlNode
*node
)
211 wxXmlNode
*c
= node
->GetChildren();
215 if (!c
->GetPropVal(wxT("platform"), &s
))
219 wxStringTokenizer
tkn(s
, " |");
221 while (tkn
.HasMoreTokens())
223 s
= tkn
.GetNextToken();
226 s
== wxString(wxT("win"))
227 #elif defined(__UNIX__)
228 s
== wxString(wxT("unix"))
229 #elif defined(__MAC__)
230 s
== wxString(wxT("mac"))
231 #elif defined(__OS2__)
232 s
== wxString(wxT("os2"))
241 ProcessPlatformProperty(c
);
244 node
->RemoveChild(c
);
254 void wxXmlResource::UpdateResources()
257 # if wxUSE_FILESYSTEM
262 for (size_t i
= 0; i
< m_Data
.GetCount(); i
++)
264 modif
= (m_Data
[i
].Doc
== NULL
);
268 # if wxUSE_FILESYSTEM
269 file
= fsys
.OpenFile(m_Data
[i
].File
);
270 modif
= file
&& file
->GetModificationTime() > m_Data
[i
].Time
;
272 wxLogError(_("Cannot open file '%s'."), m_Data
[i
].File
.c_str());
275 modif
= wxDateTime(wxFileModificationTime(m_Data
[i
].File
)) > m_Data
[i
].Time
;
281 wxInputStream
*stream
;
283 # if wxUSE_FILESYSTEM
284 file
= fsys
.OpenFile(m_Data
[i
].File
);
285 stream
= file
->GetStream();
287 stream
= new wxFileInputStream(m_Data
[i
].File
);
292 delete m_Data
[i
].Doc
;
293 m_Data
[i
].Doc
= new wxXmlDocument
;
295 if (!stream
|| !m_Data
[i
].Doc
->Load(*stream
))
297 wxLogError(_("Cannot load resources from file '%s'."), m_Data
[i
].File
.c_str());
298 delete m_Data
[i
].Doc
;
299 m_Data
[i
].Doc
= NULL
;
301 else if (m_Data
[i
].Doc
->GetRoot()->GetName() != wxT("resource"))
303 wxLogError(_("Invalid XML resource '%s': doesn't have root node 'resource'."), m_Data
[i
].File
.c_str());
304 delete m_Data
[i
].Doc
;
305 m_Data
[i
].Doc
= NULL
;
308 ProcessPlatformProperty(m_Data
[i
].Doc
->GetRoot());
310 # if wxUSE_FILESYSTEM
321 wxXmlNode
*wxXmlResource::FindResource(const wxString
& name
, const wxString
& classname
)
323 UpdateResources(); //ensure everything is up-to-date
326 for (size_t f
= 0; f
< m_Data
.GetCount(); f
++)
328 if (m_Data
[f
].Doc
== NULL
|| m_Data
[f
].Doc
->GetRoot() == NULL
) continue;
329 for (wxXmlNode
*node
= m_Data
[f
].Doc
->GetRoot()->GetChildren();
330 node
; node
= node
->GetNext())
331 if (node
->GetType() == wxXML_ELEMENT_NODE
&&
333 node
->GetPropVal(wxT("class"), wxEmptyString
) == classname
) &&
334 node
->GetName() == wxT("object") &&
335 node
->GetPropVal(wxT("name"), &dummy
) &&
339 m_CurFileSystem
.ChangePathTo(m_Data
[f
].File
);
345 wxLogError(_("XML resource '%s' (class '%s') not found!"),
346 name
.c_str(), classname
.c_str());
352 wxObject
*wxXmlResource::CreateResFromNode(wxXmlNode
*node
, wxObject
*parent
, wxObject
*instance
)
354 if (node
== NULL
) return NULL
;
356 wxXmlResourceHandler
*handler
;
358 wxNode
* ND
= m_Handlers
.GetFirst();
361 handler
= (wxXmlResourceHandler
*)ND
->GetData();
362 if (node
->GetName() == wxT("object") && handler
->CanHandle(node
))
364 ret
= handler
->CreateResource(node
, parent
, instance
);
370 wxLogError(_("No handler found for XML node '%s', class '%s'!"),
371 node
->GetName().c_str(),
372 node
->GetPropVal(wxT("class"), wxEmptyString
).c_str());
384 wxXmlResourceHandler::wxXmlResourceHandler()
385 : m_Node(NULL
), m_Parent(NULL
), m_Instance(NULL
),
386 m_ParentAsWindow(NULL
), m_InstanceAsWindow(NULL
)
391 wxObject
*wxXmlResourceHandler::CreateResource(wxXmlNode
*node
, wxObject
*parent
, wxObject
*instance
)
393 wxXmlNode
*myNode
= m_Node
;
394 wxString myClass
= m_Class
;
395 wxObject
*myParent
= m_Parent
, *myInstance
= m_Instance
;
396 wxWindow
*myParentAW
= m_ParentAsWindow
, *myInstanceAW
= m_InstanceAsWindow
;
399 m_Class
= node
->GetPropVal(wxT("class"), wxEmptyString
);
401 m_Instance
= instance
;
402 m_ParentAsWindow
= wxDynamicCast(m_Parent
, wxWindow
);
403 m_InstanceAsWindow
= wxDynamicCast(m_Instance
, wxWindow
);
405 wxObject
*returned
= DoCreateResource();
409 m_Parent
= myParent
; m_ParentAsWindow
= myParentAW
;
410 m_Instance
= myInstance
; m_InstanceAsWindow
= myInstanceAW
;
416 void wxXmlResourceHandler::AddStyle(const wxString
& name
, int value
)
418 m_StyleNames
.Add(name
);
419 m_StyleValues
.Add(value
);
424 void wxXmlResourceHandler::AddWindowStyles()
426 ADD_STYLE(wxSIMPLE_BORDER
);
427 ADD_STYLE(wxSUNKEN_BORDER
);
428 ADD_STYLE(wxDOUBLE_BORDER
);
429 ADD_STYLE(wxRAISED_BORDER
);
430 ADD_STYLE(wxSTATIC_BORDER
);
431 ADD_STYLE(wxTRANSPARENT_WINDOW
);
432 ADD_STYLE(wxWANTS_CHARS
);
433 ADD_STYLE(wxNO_FULL_REPAINT_ON_RESIZE
);
438 bool wxXmlResourceHandler::HasParam(const wxString
& param
)
440 return (GetParamNode(param
) != NULL
);
444 int wxXmlResourceHandler::GetStyle(const wxString
& param
, int defaults
)
446 wxString s
= GetParamValue(param
);
448 if (!s
) return defaults
;
450 wxStringTokenizer
tkn(s
, wxT("| "), wxTOKEN_STRTOK
);
454 while (tkn
.HasMoreTokens())
456 fl
= tkn
.GetNextToken();
457 index
= m_StyleNames
.Index(fl
);
458 if (index
!= wxNOT_FOUND
)
459 style
|= m_StyleValues
[index
];
461 wxLogError(_("Unknown style flag ") + fl
);
468 wxString
wxXmlResourceHandler::GetText(const wxString
& param
)
470 wxString str1
= GetParamValue(param
);
474 for (dt
= str1
.c_str(); *dt
; dt
++)
476 // Remap $ to &, map $$ to $ (for things like "&File..." --
477 // this is illegal in XML, so we use "$File..."):
481 case '$' : str2
<< '$'; break;
482 default : str2
<< '&' << *dt
; break;
484 // Remap \n to CR, \r LF, \t to TAB:
485 else if (*dt
== '\\')
488 case 'n' : str2
<< '\n'; break;
489 case 't' : str2
<< '\t'; break;
490 case 'r' : str2
<< '\r'; break;
491 default : str2
<< '\\' << *dt
; break;
496 if (m_Resource
->GetUseLocale())
497 return wxGetTranslation(str2
);
504 long wxXmlResourceHandler::GetLong(const wxString
& param
, long defaultv
)
507 wxString str1
= GetParamValue(param
);
509 if (!str1
.ToLong(&value
))
516 int wxXmlResourceHandler::GetID()
518 wxString sid
= GetName();
521 if (sid
== wxT("-1")) return -1;
522 else if (sid
.IsNumber() && sid
.ToLong(&num
)) return num
;
523 #define stdID(id) else if (sid == wxT(#id)) return id
524 stdID(wxID_OPEN
); stdID(wxID_CLOSE
); stdID(wxID_NEW
);
525 stdID(wxID_SAVE
); stdID(wxID_SAVEAS
); stdID(wxID_REVERT
);
526 stdID(wxID_EXIT
); stdID(wxID_UNDO
); stdID(wxID_REDO
);
527 stdID(wxID_HELP
); stdID(wxID_PRINT
); stdID(wxID_PRINT_SETUP
);
528 stdID(wxID_PREVIEW
); stdID(wxID_ABOUT
); stdID(wxID_HELP_CONTENTS
);
529 stdID(wxID_HELP_COMMANDS
); stdID(wxID_HELP_PROCEDURES
);
530 stdID(wxID_CUT
); stdID(wxID_COPY
); stdID(wxID_PASTE
);
531 stdID(wxID_CLEAR
); stdID(wxID_FIND
); stdID(wxID_DUPLICATE
);
532 stdID(wxID_SELECTALL
); stdID(wxID_OK
); stdID(wxID_CANCEL
);
533 stdID(wxID_APPLY
); stdID(wxID_YES
); stdID(wxID_NO
);
534 stdID(wxID_STATIC
); stdID(wxID_FORWARD
); stdID(wxID_BACKWARD
);
535 stdID(wxID_DEFAULT
); stdID(wxID_MORE
); stdID(wxID_SETUP
);
536 stdID(wxID_RESET
); stdID(wxID_HELP_CONTEXT
);
538 else return XMLID(sid
.c_str());
542 wxString
wxXmlResourceHandler::GetName()
544 return m_Node
->GetPropVal(wxT("name"), wxT("-1"));
549 bool wxXmlResourceHandler::GetBool(const wxString
& param
, bool defaultv
)
551 wxString v
= GetParamValue(param
);
553 if (!v
) return defaultv
;
554 else return (v
== wxT("1"));
559 wxColour
wxXmlResourceHandler::GetColour(const wxString
& param
)
561 wxString v
= GetParamValue(param
);
562 unsigned long tmp
= 0;
564 if (v
.Length() != 7 || v
[0] != wxT('#') ||
565 wxSscanf(v
.c_str(), wxT("#%lX"), &tmp
) != 1)
567 wxLogError(_("XML resource: Incorrect colour specification '%s' for property '%s'."),
568 v
.c_str(), param
.c_str());
572 return wxColour((tmp
& 0xFF0000) >> 16 ,
573 (tmp
& 0x00FF00) >> 8,
579 wxBitmap
wxXmlResourceHandler::GetBitmap(const wxString
& param
, wxSize size
)
581 wxString name
= GetParamValue(param
);
582 if (name
.IsEmpty()) return wxNullBitmap
;
584 wxFSFile
*fsfile
= GetCurFileSystem().OpenFile(name
);
587 wxLogError(_("XML resource: Cannot create bitmap from '%s'."), param
.mb_str());
590 wxImage
img(*(fsfile
->GetStream()));
593 wxImage
img(GetParamValue(wxT("bitmap")));
597 wxLogError(_("XML resource: Cannot create bitmap from '%s'."), param
.mb_str());
600 if (!(size
== wxDefaultSize
)) img
.Rescale(size
.x
, size
.y
);
601 return img
.ConvertToBitmap();
606 wxIcon
wxXmlResourceHandler::GetIcon(const wxString
& param
, wxSize size
)
608 #if wxCHECK_VERSION(2,3,0) || defined(__WXMSW__)
610 icon
.CopyFromBitmap(GetBitmap(param
, size
));
613 wxBitmap bmppt
= GetBitmap(param
, size
);
614 iconpt
= (wxIcon
*)(&bmppt
);
615 wxIcon
icon(*iconpt
);
622 wxXmlNode
*wxXmlResourceHandler::GetParamNode(const wxString
& param
)
624 wxXmlNode
*n
= m_Node
->GetChildren();
628 if (n
->GetType() == wxXML_ELEMENT_NODE
&& n
->GetName() == param
)
636 wxString
wxXmlResourceHandler::GetNodeContent(wxXmlNode
*node
)
639 if (n
== NULL
) return wxEmptyString
;
640 n
= n
->GetChildren();
644 if (n
->GetType() == wxXML_TEXT_NODE
||
645 n
->GetType() == wxXML_CDATA_SECTION_NODE
)
646 return n
->GetContent();
649 return wxEmptyString
;
654 wxString
wxXmlResourceHandler::GetParamValue(const wxString
& param
)
657 return GetNodeContent(m_Node
);
659 return GetNodeContent(GetParamNode(param
));
664 wxSize
wxXmlResourceHandler::GetSize(const wxString
& param
)
666 wxString s
= GetParamValue(param
);
667 if (s
.IsEmpty()) s
= wxT("-1,-1");
671 is_dlg
= s
[s
.Length()-1] == wxT('d');
672 if (is_dlg
) s
.RemoveLast();
674 if (!s
.BeforeFirst(wxT(',')).ToLong(&sx
) ||
675 !s
.AfterLast(wxT(',')).ToLong(&sy
))
677 wxLogError(_("Cannot parse coordinates from '%s'."), s
.mb_str());
678 return wxDefaultSize
;
683 if (m_InstanceAsWindow
)
684 return wxDLG_UNIT(m_InstanceAsWindow
, wxSize(sx
, sy
));
685 else if (m_ParentAsWindow
)
686 return wxDLG_UNIT(m_ParentAsWindow
, wxSize(sx
, sy
));
689 wxLogError(_("Cannot convert dialog units: dialog unknown."));
690 return wxDefaultSize
;
693 else return wxSize(sx
, sy
);
698 wxPoint
wxXmlResourceHandler::GetPosition(const wxString
& param
)
700 wxSize sz
= GetSize(param
);
701 return wxPoint(sz
.x
, sz
.y
);
706 wxCoord
wxXmlResourceHandler::GetDimension(const wxString
& param
, wxCoord defaultv
)
708 wxString s
= GetParamValue(param
);
709 if (s
.IsEmpty()) return defaultv
;
713 is_dlg
= s
[s
.Length()-1] == wxT('d');
714 if (is_dlg
) s
.RemoveLast();
718 wxLogError(_("Cannot parse dimension from '%s'."), s
.mb_str());
724 if (m_InstanceAsWindow
)
725 return wxDLG_UNIT(m_InstanceAsWindow
, wxSize(sx
, 0)).x
;
726 else if (m_ParentAsWindow
)
727 return wxDLG_UNIT(m_ParentAsWindow
, wxSize(sx
, 0)).x
;
730 wxLogError(_("Cannot convert dialog units: dialog unknown."));
739 wxFont
wxXmlResourceHandler::GetFont(const wxString
& param
)
741 wxXmlNode
*font_node
= GetParamNode(param
);
742 if (font_node
== NULL
)
744 wxLogError(_("Cannot find font node '%s'."), param
.mb_str());
748 wxXmlNode
*oldnode
= m_Node
;
751 long size
= GetLong(wxT("size"), 12);
753 wxString style
= GetParamValue(wxT("style"));
754 wxString weight
= GetParamValue(wxT("weight"));
755 int istyle
= wxNORMAL
, iweight
= wxNORMAL
;
756 if (style
== wxT("italic")) istyle
= wxITALIC
;
757 else if (style
== wxT("slant")) istyle
= wxSLANT
;
758 if (weight
== wxT("bold")) iweight
= wxBOLD
;
759 else if (weight
== wxT("light")) iweight
= wxLIGHT
;
761 wxString family
= GetParamValue(wxT("family"));
762 int ifamily
= wxDEFAULT
;
763 if (family
== wxT("decorative")) ifamily
= wxDECORATIVE
;
764 else if (family
== wxT("roman")) ifamily
= wxROMAN
;
765 else if (family
== wxT("script")) ifamily
= wxSCRIPT
;
766 else if (family
== wxT("swiss")) ifamily
= wxSWISS
;
767 else if (family
== wxT("modern")) ifamily
= wxMODERN
;
769 bool underlined
= GetBool(wxT("underlined"), FALSE
);
771 wxString encoding
= GetParamValue(wxT("encoding"));
773 wxFontEncoding enc
= wxFONTENCODING_DEFAULT
;
774 if (!encoding
.IsEmpty()) enc
= mapper
.CharsetToEncoding(encoding
);
775 if (enc
== wxFONTENCODING_SYSTEM
) enc
= wxFONTENCODING_SYSTEM
;
777 wxString faces
= GetParamValue(wxT("face"));
778 wxString facename
= wxEmptyString
;
779 wxFontEnumerator enu
;
780 enu
.EnumerateFacenames();
781 wxStringTokenizer
tk(faces
, wxT(","));
782 while (tk
.HasMoreTokens())
784 int index
= enu
.GetFacenames()->Index(tk
.GetNextToken(), FALSE
);
785 if (index
!= wxNOT_FOUND
)
787 facename
= (*enu
.GetFacenames())[index
];
794 wxFont
font(size
, ifamily
, istyle
, iweight
, underlined
, facename
, enc
);
799 void wxXmlResourceHandler::SetupWindow(wxWindow
*wnd
)
803 if (HasParam(wxT("exstyle")))
804 wnd
->SetExtraStyle(GetStyle(wxT("exstyle")));
805 if (HasParam(wxT("bg")))
806 wnd
->SetBackgroundColour(GetColour(wxT("bg")));
807 if (HasParam(wxT("fg")))
808 wnd
->SetForegroundColour(GetColour(wxT("fg")));
809 if (GetBool(wxT("enabled"), 1) == 0)
811 if (GetBool(wxT("focused"), 0) == 1)
813 if (GetBool(wxT("hidden"), 0) == 1)
816 if (HasParam(wxT("tooltip")))
817 wnd
->SetToolTip(GetText(wxT("tooltip")));
819 if (HasParam(wxT("font")))
820 wnd
->SetFont(GetFont());
824 void wxXmlResourceHandler::CreateChildren(wxObject
*parent
, bool this_hnd_only
)
826 wxXmlNode
*n
= m_Node
->GetChildren();
830 if (n
->GetType() == wxXML_ELEMENT_NODE
&&
831 n
->GetName() == wxT("object"))
833 if (this_hnd_only
&& CanHandle(n
))
834 CreateResource(n
, parent
, NULL
);
836 m_Resource
->CreateResFromNode(n
, parent
, NULL
);
843 void wxXmlResourceHandler::CreateChildrenPrivately(wxObject
*parent
, wxXmlNode
*rootnode
)
846 if (rootnode
== NULL
) root
= m_Node
; else root
= rootnode
;
847 wxXmlNode
*n
= root
->GetChildren();
851 if (n
->GetType() == wxXML_ELEMENT_NODE
&& CanHandle(n
))
853 CreateResource(n
, parent
, NULL
);
867 // --------------- XMLID implementation -----------------------------
869 #define XMLID_TABLE_SIZE 1024
879 static XMLID_record
*XMLID_Records
[XMLID_TABLE_SIZE
] = {NULL
};
881 /*static*/ int wxXmlResource::GetXMLID(const char *str_id
)
883 static int XMLID_LastID
= wxID_HIGHEST
;
887 for (const char *c
= str_id
; *c
!= '\0'; c
++) index
+= (int)*c
;
888 index
%= XMLID_TABLE_SIZE
;
890 XMLID_record
*oldrec
= NULL
;
892 for (XMLID_record
*rec
= XMLID_Records
[index
]; rec
; rec
= rec
->next
)
894 if (strcmp(rec
->key
, str_id
) == 0)
902 XMLID_record
**rec_var
= (oldrec
== NULL
) ?
903 &XMLID_Records
[index
] : &oldrec
->next
;
904 *rec_var
= new XMLID_record
;
905 (*rec_var
)->id
= ++XMLID_LastID
;
906 (*rec_var
)->key
= strdup(str_id
);
907 (*rec_var
)->next
= NULL
;
909 return (*rec_var
)->id
;
913 static void CleanXMLID_Record(XMLID_record
*rec
)
917 CleanXMLID_Record(rec
->next
);
923 static void CleanXMLID_Records()
925 for (int i
= 0; i
< XMLID_TABLE_SIZE
; i
++)
926 CleanXMLID_Record(XMLID_Records
[i
]);
936 // --------------- module and globals -----------------------------
939 static wxXmlResource gs_XmlResource
;
941 wxXmlResource
*wxTheXmlResource
= &gs_XmlResource
;
944 class wxXmlResourceModule
: public wxModule
946 DECLARE_DYNAMIC_CLASS(wxXmlResourceModule
)
948 wxXmlResourceModule() {}
949 bool OnInit() {return TRUE
;}
952 wxTheXmlResource
->ClearHandlers();
953 CleanXMLID_Records();
957 IMPLEMENT_DYNAMIC_CLASS(wxXmlResourceModule
, wxModule
)