From ab708d5defa637ac6f284f94acb706d13cd15eb1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 2 May 2001 23:09:55 +0000 Subject: [PATCH] switched wxXML to expat parser ; some minor formatting mods git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9979 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/xml/Makefile.in | 17 +- contrib/src/xml/README.EXPAT | 39 ++++ contrib/src/xml/xh_bmpbt.cpp | 2 +- contrib/src/xml/xh_bttn.cpp | 2 +- contrib/src/xml/xh_cald.cpp | 2 +- contrib/src/xml/xh_chckb.cpp | 2 +- contrib/src/xml/xh_chckl.cpp | 12 +- contrib/src/xml/xh_choic.cpp | 12 +- contrib/src/xml/xh_combo.cpp | 12 +- contrib/src/xml/xh_dlg.cpp | 4 +- contrib/src/xml/xh_frame.cpp | 4 +- contrib/src/xml/xh_gauge.cpp | 2 +- contrib/src/xml/xh_html.cpp | 2 +- contrib/src/xml/xh_listb.cpp | 12 +- contrib/src/xml/xh_listc.cpp | 2 +- contrib/src/xml/xh_menu.cpp | 22 +-- contrib/src/xml/xh_notbk.cpp | 34 ++-- contrib/src/xml/xh_panel.cpp | 6 +- contrib/src/xml/xh_radbt.cpp | 2 +- contrib/src/xml/xh_radbx.cpp | 12 +- contrib/src/xml/xh_scrol.cpp | 2 +- contrib/src/xml/xh_sizer.cpp | 84 ++++---- contrib/src/xml/xh_slidr.cpp | 2 +- contrib/src/xml/xh_spin.cpp | 4 +- contrib/src/xml/xh_stbmp.cpp | 2 +- contrib/src/xml/xh_stbox.cpp | 2 +- contrib/src/xml/xh_stlin.cpp | 2 +- contrib/src/xml/xh_sttxt.cpp | 2 +- contrib/src/xml/xh_text.cpp | 2 +- contrib/src/xml/xh_toolb.cpp | 34 ++-- contrib/src/xml/xh_tree.cpp | 2 +- contrib/src/xml/xh_unkwn.cpp | 8 +- contrib/src/xml/xml.cpp | 153 +++++++-------- contrib/src/xml/xmlexpat.cpp | 192 ++++++++++++++++++ contrib/src/xml/xmlpars.cpp | 366 ----------------------------------- contrib/src/xml/xmlres.cpp | 138 ++++++------- contrib/src/xml/xmlwrite.cpp | 152 +++++++++++++++ 37 files changed, 687 insertions(+), 662 deletions(-) create mode 100644 contrib/src/xml/README.EXPAT create mode 100644 contrib/src/xml/xmlexpat.cpp delete mode 100644 contrib/src/xml/xmlpars.cpp create mode 100644 contrib/src/xml/xmlwrite.cpp diff --git a/contrib/src/xml/Makefile.in b/contrib/src/xml/Makefile.in index d56dcf4abe..ed04437d35 100644 --- a/contrib/src/xml/Makefile.in +++ b/contrib/src/xml/Makefile.in @@ -2,7 +2,10 @@ top_srcdir = @top_srcdir@/.. top_builddir = ../../.. -libsrc_dir = contrib/src/xml + +expat_dir = $(top_srcdir)/contrib/src/xml/expat +libsrc_dir = contrib/src/xml@PATH_IFS@$(expat_dir)/xmlparse@PATH_IFS@$(expat_dir)/xmltok + TARGET_LIBNAME=libwxxml @@ -13,6 +16,9 @@ LIBVERSION_AGE=0 HEADER_PATH=$(top_srcdir)/contrib/include/wx HEADER_SUBDIR=xml +EXPAT_DEFS=-I$(expat_dir)/xmlparse -I$(expat_dir)/xmltok +EXPAT_OBJECTS=xmltok.o xmlrole.o xmlparse.o + HEADERS=xh_all.h xh_bttn.h xh_chckb.h xh_chckl.h xh_choic.h xh_combo.h \ xh_dlg.h xh_gauge.h xh_html.h xh_menu.h xh_notbk.h xh_panel.h \ xh_radbt.h xh_radbx.h xh_sizer.h xh_slidr.h xh_spin.h xh_stbmp.h \ @@ -20,15 +26,16 @@ HEADERS=xh_all.h xh_bttn.h xh_chckb.h xh_chckl.h xh_choic.h xh_combo.h \ xh_bmpbt.h xh_cald.h xh_listc.h xh_scrol.h xh_stbox.h xh_tree.h \ xh_stlin.h xh_bmp.h xh_unkwn.h xh_frame.h - -OBJECTS=xml.o xmlbin.o xmlbinz.o xmlpars.o xmlres.o xmlrsall.o \ +OBJECTS=$(EXPAT_OBJECTS) \ + xml.o xmlbin.o xmlbinz.o xmlexpat.o xmlwrite.o xmlres.o xmlrsall.o \ xh_bttn.o xh_chckb.o xh_chckl.o xh_choic.o xh_combo.o xh_dlg.o \ xh_gauge.o xh_html.o xh_menu.o xh_notbk.o xh_panel.o xh_radbt.o \ xh_radbx.o xh_sizer.o xh_slidr.o xh_spin.o xh_stbmp.o xh_sttxt.o \ xh_text.o xh_listb.o xh_toolb.o xh_stlin.o xh_bmp.o xh_unkwn.o \ - xh_bmpbt.o xh_cald.o xh_listc.o xh_scrol.o xh_stbox.o xh_tree.o + xh_bmpbt.o xh_cald.o xh_listc.o xh_scrol.o xh_stbox.o xh_tree.o \ + xh_frame.o -APPEXTRADEFS=-I$(top_srcdir)/contrib/include +APPEXTRADEFS=-I$(top_srcdir)/contrib/include $(EXPAT_DEFS) include $(top_builddir)/src/makelib.env diff --git a/contrib/src/xml/README.EXPAT b/contrib/src/xml/README.EXPAT new file mode 100644 index 0000000000..a85c615062 --- /dev/null +++ b/contrib/src/xml/README.EXPAT @@ -0,0 +1,39 @@ + +./expat directory contains stripped-down version of Expat parser distribution +by J. Clark. I removed stuff not neccessary for wxXML (docs, samples), if you +are interested in it, please download full distribution from Clark's site +(http://www.jclark.com). + +Version used is expat-1.2. + +The Expat parser is available is licensed under the MIT license as follows: + + + + Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +In other words, there shouldn't be any legal issues with using Expat in +your application. + + Vaclav Slavik diff --git a/contrib/src/xml/xh_bmpbt.cpp b/contrib/src/xml/xh_bmpbt.cpp index 69327e7609..314d91e24c 100644 --- a/contrib/src/xml/xh_bmpbt.cpp +++ b/contrib/src/xml/xh_bmpbt.cpp @@ -36,7 +36,7 @@ wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler() wxObject *wxBitmapButtonXmlHandler::DoCreateResource() { - wxBitmapButton *button = new wxBitmapButton(m_ParentAsWindow, + wxBitmapButton *button = new wxBitmapButton(m_parentAsWindow, GetID(), GetBitmap(wxT("bitmap")), GetPosition(), GetSize(), diff --git a/contrib/src/xml/xh_bttn.cpp b/contrib/src/xml/xh_bttn.cpp index 1bb47f4362..b0c31f12c1 100644 --- a/contrib/src/xml/xh_bttn.cpp +++ b/contrib/src/xml/xh_bttn.cpp @@ -32,7 +32,7 @@ wxButtonXmlHandler::wxButtonXmlHandler() wxObject *wxButtonXmlHandler::DoCreateResource() { - wxButton *button = new wxButton(m_ParentAsWindow, + wxButton *button = new wxButton(m_parentAsWindow, GetID(), GetText(wxT("label")), GetPosition(), GetSize(), diff --git a/contrib/src/xml/xh_cald.cpp b/contrib/src/xml/xh_cald.cpp index 5e980a478f..0101a610ab 100644 --- a/contrib/src/xml/xh_cald.cpp +++ b/contrib/src/xml/xh_cald.cpp @@ -37,7 +37,7 @@ wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler() wxObject *wxCalendarCtrlXmlHandler::DoCreateResource() { - wxCalendarCtrl *calendar = new wxCalendarCtrl(m_ParentAsWindow, + wxCalendarCtrl *calendar = new wxCalendarCtrl(m_parentAsWindow, GetID(), wxDefaultDateTime, /*TODO: take it from resource*/ diff --git a/contrib/src/xml/xh_chckb.cpp b/contrib/src/xml/xh_chckb.cpp index 057de6e462..c675c6663e 100644 --- a/contrib/src/xml/xh_chckb.cpp +++ b/contrib/src/xml/xh_chckb.cpp @@ -32,7 +32,7 @@ wxCheckBoxXmlHandler::wxCheckBoxXmlHandler() wxObject *wxCheckBoxXmlHandler::DoCreateResource() { - wxCheckBox *control = new wxCheckBox(m_ParentAsWindow, + wxCheckBox *control = new wxCheckBox(m_parentAsWindow, GetID(), GetText(wxT("label")), GetPosition(), GetSize(), diff --git a/contrib/src/xml/xh_chckl.cpp b/contrib/src/xml/xh_chckl.cpp index 51f307adc3..928f486511 100644 --- a/contrib/src/xml/xh_chckl.cpp +++ b/contrib/src/xml/xh_chckl.cpp @@ -23,7 +23,7 @@ #include "wx/checklst.h" wxCheckListXmlHandler::wxCheckListXmlHandler() -: wxXmlResourceHandler(), m_InsideBox(FALSE) +: wxXmlResourceHandler(), m_insideBox(FALSE) { // no styles AddWindowStyles(); @@ -31,10 +31,10 @@ wxCheckListXmlHandler::wxCheckListXmlHandler() wxObject *wxCheckListXmlHandler::DoCreateResource() { - if (m_Class == wxT("wxCheckList")) + if (m_class == wxT("wxCheckList")) { // need to build the list of strings from children - m_InsideBox = TRUE; + m_insideBox = TRUE; CreateChildrenPrivately(NULL, GetParamNode(wxT("content"))); wxString *strings = (wxString *) NULL; if( strList.GetCount() > 0 ) @@ -46,7 +46,7 @@ wxObject *wxCheckListXmlHandler::DoCreateResource() } - wxCheckListBox *control = new wxCheckListBox(m_ParentAsWindow, + wxCheckListBox *control = new wxCheckListBox(m_parentAsWindow, GetID(), GetPosition(), GetSize(), strList.GetCount(), @@ -90,7 +90,7 @@ wxObject *wxCheckListXmlHandler::DoCreateResource() // handle Label // add to the list - strList.Add( GetNodeContent(m_Node) ); + strList.Add( GetNodeContent(m_node) ); return NULL; } @@ -102,7 +102,7 @@ wxObject *wxCheckListXmlHandler::DoCreateResource() bool wxCheckListXmlHandler::CanHandle(wxXmlNode *node) { return (IsOfClass(node, wxT("wxCheckList")) || - (m_InsideBox && node->GetName() == wxT("item")) + (m_insideBox && node->GetName() == wxT("item")) ); } diff --git a/contrib/src/xml/xh_choic.cpp b/contrib/src/xml/xh_choic.cpp index 0417f076e1..a7843e91b7 100644 --- a/contrib/src/xml/xh_choic.cpp +++ b/contrib/src/xml/xh_choic.cpp @@ -23,7 +23,7 @@ #include "wx/choice.h" wxChoiceXmlHandler::wxChoiceXmlHandler() -: wxXmlResourceHandler() , m_InsideBox(FALSE) +: wxXmlResourceHandler() , m_insideBox(FALSE) { ADD_STYLE(wxCB_SORT); AddWindowStyles(); @@ -31,13 +31,13 @@ wxChoiceXmlHandler::wxChoiceXmlHandler() wxObject *wxChoiceXmlHandler::DoCreateResource() { - if( m_Class == wxT("wxChoice")) + if( m_class == wxT("wxChoice")) { // find the selection long selection = GetLong( wxT("selection"), -1 ); // need to build the list of strings from children - m_InsideBox = TRUE; + m_insideBox = TRUE; CreateChildrenPrivately( NULL, GetParamNode(wxT("content"))); wxString *strings = (wxString *) NULL; if( strList.GetCount() > 0 ) @@ -49,7 +49,7 @@ wxObject *wxChoiceXmlHandler::DoCreateResource() } - wxChoice *control = new wxChoice(m_ParentAsWindow, + wxChoice *control = new wxChoice(m_parentAsWindow, GetID(), GetPosition(), GetSize(), strList.GetCount(), @@ -76,7 +76,7 @@ wxObject *wxChoiceXmlHandler::DoCreateResource() // handle Label // add to the list - strList.Add( GetNodeContent(m_Node) ); + strList.Add( GetNodeContent(m_node) ); return NULL; } @@ -88,7 +88,7 @@ wxObject *wxChoiceXmlHandler::DoCreateResource() bool wxChoiceXmlHandler::CanHandle(wxXmlNode *node) { return (IsOfClass(node, wxT("wxChoice")) || - (m_InsideBox && node->GetName() == wxT("item")) + (m_insideBox && node->GetName() == wxT("item")) ); } diff --git a/contrib/src/xml/xh_combo.cpp b/contrib/src/xml/xh_combo.cpp index 4f80166701..e69a343b1c 100644 --- a/contrib/src/xml/xh_combo.cpp +++ b/contrib/src/xml/xh_combo.cpp @@ -25,7 +25,7 @@ #if wxUSE_COMBOBOX wxComboBoxXmlHandler::wxComboBoxXmlHandler() -: wxXmlResourceHandler() , m_InsideBox(FALSE) +: wxXmlResourceHandler() , m_insideBox(FALSE) { ADD_STYLE(wxCB_SIMPLE); ADD_STYLE(wxCB_SORT); @@ -36,13 +36,13 @@ wxComboBoxXmlHandler::wxComboBoxXmlHandler() wxObject *wxComboBoxXmlHandler::DoCreateResource() { - if( m_Class == wxT("wxComboBox")) + if( m_class == wxT("wxComboBox")) { // find the selection long selection = GetLong( wxT("selection"), -1 ); // need to build the list of strings from children - m_InsideBox = TRUE; + m_insideBox = TRUE; CreateChildrenPrivately( NULL, GetParamNode(wxT("content"))); wxString *strings = (wxString *) NULL; if( strList.GetCount() > 0 ) @@ -54,7 +54,7 @@ wxObject *wxComboBoxXmlHandler::DoCreateResource() } - wxComboBox *control = new wxComboBox(m_ParentAsWindow, + wxComboBox *control = new wxComboBox(m_parentAsWindow, GetID(), GetText(wxT("value")), GetPosition(), GetSize(), @@ -82,7 +82,7 @@ wxObject *wxComboBoxXmlHandler::DoCreateResource() // handle Label // add to the list - strList.Add( GetNodeContent(m_Node) ); + strList.Add( GetNodeContent(m_node) ); return NULL; } @@ -94,7 +94,7 @@ wxObject *wxComboBoxXmlHandler::DoCreateResource() bool wxComboBoxXmlHandler::CanHandle(wxXmlNode *node) { return (IsOfClass(node, wxT("wxComboBox")) || - (m_InsideBox && node->GetName() == wxT("item")) + (m_insideBox && node->GetName() == wxT("item")) ); } diff --git a/contrib/src/xml/xh_dlg.cpp b/contrib/src/xml/xh_dlg.cpp index 6110b807e7..045093f899 100644 --- a/contrib/src/xml/xh_dlg.cpp +++ b/contrib/src/xml/xh_dlg.cpp @@ -48,11 +48,11 @@ wxDialogXmlHandler::wxDialogXmlHandler() : wxXmlResourceHandler() wxObject *wxDialogXmlHandler::DoCreateResource() { - wxDialog *dlg = wxDynamicCast(m_Instance, wxDialog); + wxDialog *dlg = wxDynamicCast(m_instance, wxDialog); wxASSERT_MSG(dlg, _("XML resource: Cannot create dialog without instance.")); - dlg->Create(m_ParentAsWindow, + dlg->Create(m_parentAsWindow, GetID(), GetText(wxT("title")), wxDefaultPosition, wxDefaultSize, diff --git a/contrib/src/xml/xh_frame.cpp b/contrib/src/xml/xh_frame.cpp index dd56ad7004..5c9faea52d 100644 --- a/contrib/src/xml/xh_frame.cpp +++ b/contrib/src/xml/xh_frame.cpp @@ -52,11 +52,11 @@ wxFrameXmlHandler::wxFrameXmlHandler() : wxXmlResourceHandler() wxObject *wxFrameXmlHandler::DoCreateResource() { - wxFrame *frame = wxDynamicCast(m_Instance, wxFrame); + wxFrame *frame = wxDynamicCast(m_instance, wxFrame); wxASSERT_MSG(frame, _("XML resource: Cannot create dialog without instance.")); - frame->Create(m_ParentAsWindow, + frame->Create(m_parentAsWindow, GetID(), GetText(_T("title")), wxDefaultPosition, wxDefaultSize, diff --git a/contrib/src/xml/xh_gauge.cpp b/contrib/src/xml/xh_gauge.cpp index 2341a469c2..9e7d7fcf5a 100644 --- a/contrib/src/xml/xh_gauge.cpp +++ b/contrib/src/xml/xh_gauge.cpp @@ -36,7 +36,7 @@ wxGaugeXmlHandler::wxGaugeXmlHandler() wxObject *wxGaugeXmlHandler::DoCreateResource() { - wxGauge *control = new wxGauge(m_ParentAsWindow, + wxGauge *control = new wxGauge(m_parentAsWindow, GetID(), GetLong( wxT("range"), wxGAUGE_DEFAULT_RANGE), GetPosition(), GetSize(), diff --git a/contrib/src/xml/xh_html.cpp b/contrib/src/xml/xh_html.cpp index fba431d79f..30ab0b46b2 100644 --- a/contrib/src/xml/xh_html.cpp +++ b/contrib/src/xml/xh_html.cpp @@ -36,7 +36,7 @@ wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler() wxObject *wxHtmlWindowXmlHandler::DoCreateResource() { - wxHtmlWindow *control = new wxHtmlWindow(m_ParentAsWindow, + wxHtmlWindow *control = new wxHtmlWindow(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle( wxT("style" ), wxHW_SCROLLBAR_AUTO), diff --git a/contrib/src/xml/xh_listb.cpp b/contrib/src/xml/xh_listb.cpp index 2dc087e1be..064e43b9ad 100644 --- a/contrib/src/xml/xh_listb.cpp +++ b/contrib/src/xml/xh_listb.cpp @@ -23,7 +23,7 @@ #include "wx/listbox.h" wxListBoxXmlHandler::wxListBoxXmlHandler() -: wxXmlResourceHandler() , m_InsideBox(FALSE) +: wxXmlResourceHandler() , m_insideBox(FALSE) { ADD_STYLE(wxLB_SINGLE); ADD_STYLE(wxLB_MULTIPLE); @@ -37,13 +37,13 @@ wxListBoxXmlHandler::wxListBoxXmlHandler() wxObject *wxListBoxXmlHandler::DoCreateResource() { - if( m_Class == wxT("wxListBox")) + if( m_class == wxT("wxListBox")) { // find the selection long selection = GetLong( wxT("selection"), -1 ); // need to build the list of strings from children - m_InsideBox = TRUE; + m_insideBox = TRUE; CreateChildrenPrivately( NULL, GetParamNode(wxT("content"))); wxString *strings = (wxString *) NULL; if( strList.GetCount() > 0 ) @@ -55,7 +55,7 @@ wxObject *wxListBoxXmlHandler::DoCreateResource() } - wxListBox *control = new wxListBox(m_ParentAsWindow, + wxListBox *control = new wxListBox(m_parentAsWindow, GetID(), GetPosition(), GetSize(), strList.GetCount(), @@ -82,7 +82,7 @@ wxObject *wxListBoxXmlHandler::DoCreateResource() // handle Label // add to the list - strList.Add( GetNodeContent(m_Node) ); + strList.Add( GetNodeContent(m_node) ); return NULL; } @@ -94,7 +94,7 @@ wxObject *wxListBoxXmlHandler::DoCreateResource() bool wxListBoxXmlHandler::CanHandle(wxXmlNode *node) { return (IsOfClass(node, wxT("wxListBox")) || - (m_InsideBox && node->GetName() == wxT("item")) + (m_insideBox && node->GetName() == wxT("item")) ); } diff --git a/contrib/src/xml/xh_listc.cpp b/contrib/src/xml/xh_listc.cpp index aa0372661a..5b944bd5df 100644 --- a/contrib/src/xml/xh_listc.cpp +++ b/contrib/src/xml/xh_listc.cpp @@ -46,7 +46,7 @@ wxListCtrlXmlHandler::wxListCtrlXmlHandler() wxObject *wxListCtrlXmlHandler::DoCreateResource() { - wxListCtrl *list = new wxListCtrl(m_ParentAsWindow, + wxListCtrl *list = new wxListCtrl(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(), diff --git a/contrib/src/xml/xh_menu.cpp b/contrib/src/xml/xh_menu.cpp index 94334f41ad..0550600690 100644 --- a/contrib/src/xml/xh_menu.cpp +++ b/contrib/src/xml/xh_menu.cpp @@ -24,7 +24,7 @@ wxMenuXmlHandler::wxMenuXmlHandler() : - wxXmlResourceHandler(), m_InsideMenu(FALSE) + wxXmlResourceHandler(), m_insideMenu(FALSE) { ADD_STYLE(wxMENU_TEAROFF); } @@ -33,23 +33,23 @@ wxMenuXmlHandler::wxMenuXmlHandler() : wxObject *wxMenuXmlHandler::DoCreateResource() { - if (m_Class == wxT("wxMenu")) + if (m_class == wxT("wxMenu")) { wxMenu *menu = new wxMenu(GetStyle()); wxString title = GetText(wxT("label")); wxString help = GetText(wxT("help")); - bool oldins = m_InsideMenu; - m_InsideMenu = TRUE; + bool oldins = m_insideMenu; + m_insideMenu = TRUE; CreateChildren(menu, TRUE/*only this handler*/); - m_InsideMenu = oldins; + m_insideMenu = oldins; - wxMenuBar *p_bar = wxDynamicCast(m_Parent, wxMenuBar); + wxMenuBar *p_bar = wxDynamicCast(m_parent, wxMenuBar); if (p_bar) p_bar->Append(menu, title); else { - wxMenu *p_menu = wxDynamicCast(m_Parent, wxMenu); + wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu); if (p_menu) p_menu->Append(GetID(), title, menu, help); } @@ -59,11 +59,11 @@ wxObject *wxMenuXmlHandler::DoCreateResource() else { - wxMenu *p_menu = wxDynamicCast(m_Parent, wxMenu); + wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu); - if (m_Class == wxT("separator")) + if (m_class == wxT("separator")) p_menu->AppendSeparator(); - else if (m_Class == wxT("break")) + else if (m_class == wxT("break")) p_menu->Break(); else /*wxMenuItem*/ { @@ -90,7 +90,7 @@ wxObject *wxMenuXmlHandler::DoCreateResource() bool wxMenuXmlHandler::CanHandle(wxXmlNode *node) { return IsOfClass(node, wxT("wxMenu")) || - (m_InsideMenu && + (m_insideMenu && (IsOfClass(node, wxT("wxMenuItem")) || IsOfClass(node, wxT("break")) || IsOfClass(node, wxT("separator"))) diff --git a/contrib/src/xml/xh_notbk.cpp b/contrib/src/xml/xh_notbk.cpp index 0810468f8d..51f18c983d 100644 --- a/contrib/src/xml/xh_notbk.cpp +++ b/contrib/src/xml/xh_notbk.cpp @@ -28,7 +28,7 @@ #include "wx/sizer.h" wxNotebookXmlHandler::wxNotebookXmlHandler() -: wxXmlResourceHandler(), m_IsInside(FALSE), m_Notebook(NULL) +: wxXmlResourceHandler(), m_isInside(FALSE), m_notebook(NULL) { ADD_STYLE(wxNB_FIXEDWIDTH); ADD_STYLE(wxNB_LEFT); @@ -41,20 +41,20 @@ wxNotebookXmlHandler::wxNotebookXmlHandler() wxObject *wxNotebookXmlHandler::DoCreateResource() { - if (m_Class == wxT("notebookpage")) + if (m_class == wxT("notebookpage")) { wxXmlNode *n = GetParamNode(wxT("object")); if (n) { - bool old_ins = m_IsInside; - m_IsInside = FALSE; - m_IsInside = old_ins; - wxObject *item = CreateResFromNode(n, m_Notebook, NULL); + bool old_ins = m_isInside; + m_isInside = FALSE; + m_isInside = old_ins; + wxObject *item = CreateResFromNode(n, m_notebook, NULL); wxWindow *wnd = wxDynamicCast(item, wxWindow); if (wnd) - m_Notebook->AddPage(wnd, GetText(wxT("label")), + m_notebook->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected"), 0)); else wxLogError(wxT("Error in resource.")); @@ -68,19 +68,19 @@ wxObject *wxNotebookXmlHandler::DoCreateResource() } else { - wxNotebook *nb = new wxNotebook(m_ParentAsWindow, + wxNotebook *nb = new wxNotebook(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle( wxT("style" )), GetName()); - wxNotebook *old_par = m_Notebook; - m_Notebook = nb; - bool old_ins = m_IsInside; - m_IsInside = TRUE; - CreateChildren(m_Notebook, TRUE/*only this handler*/); - m_IsInside = old_ins; - m_Notebook = old_par; + wxNotebook *old_par = m_notebook; + m_notebook = nb; + bool old_ins = m_isInside; + m_isInside = TRUE; + CreateChildren(m_notebook, TRUE/*only this handler*/); + m_isInside = old_ins; + m_notebook = old_par; if (GetBool(wxT("usenotebooksizer"), FALSE)) return new wxNotebookSizer(nb); @@ -93,8 +93,8 @@ wxObject *wxNotebookXmlHandler::DoCreateResource() bool wxNotebookXmlHandler::CanHandle(wxXmlNode *node) { - return ((!m_IsInside && IsOfClass(node, wxT("wxNotebook"))) || - (m_IsInside && IsOfClass(node, wxT("notebookpage")))); + return ((!m_isInside && IsOfClass(node, wxT("wxNotebook"))) || + (m_isInside && IsOfClass(node, wxT("notebookpage")))); } #endif diff --git a/contrib/src/xml/xh_panel.cpp b/contrib/src/xml/xh_panel.cpp index 0c09dd27d6..2c870618e5 100644 --- a/contrib/src/xml/xh_panel.cpp +++ b/contrib/src/xml/xh_panel.cpp @@ -36,16 +36,16 @@ wxPanelXmlHandler::wxPanelXmlHandler() : wxXmlResourceHandler() wxObject *wxPanelXmlHandler::DoCreateResource() { - wxPanel *panel = wxDynamicCast(m_Instance, wxPanel); + wxPanel *panel = wxDynamicCast(m_instance, wxPanel); if (panel == NULL) - panel = new wxPanel(m_ParentAsWindow, + panel = new wxPanel(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style"), 0), GetName()); else - panel->Create(m_ParentAsWindow, + panel->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style"), 0), diff --git a/contrib/src/xml/xh_radbt.cpp b/contrib/src/xml/xh_radbt.cpp index 4be009e0a9..2c3bc840be 100644 --- a/contrib/src/xml/xh_radbt.cpp +++ b/contrib/src/xml/xh_radbt.cpp @@ -40,7 +40,7 @@ wxObject *wxRadioButtonXmlHandler::DoCreateResource() * normal radio button. */ - wxRadioButton *control = new wxRadioButton(m_ParentAsWindow, + wxRadioButton *control = new wxRadioButton(m_parentAsWindow, GetID(), GetText(wxT("label")), GetPosition(), GetSize(), diff --git a/contrib/src/xml/xh_radbx.cpp b/contrib/src/xml/xh_radbx.cpp index eba8f45be7..fcf365a8d7 100644 --- a/contrib/src/xml/xh_radbx.cpp +++ b/contrib/src/xml/xh_radbx.cpp @@ -25,7 +25,7 @@ #if wxUSE_RADIOBOX wxRadioBoxXmlHandler::wxRadioBoxXmlHandler() -: wxXmlResourceHandler() , m_InsideBox(FALSE) +: wxXmlResourceHandler() , m_insideBox(FALSE) { ADD_STYLE(wxRA_SPECIFY_COLS); ADD_STYLE(wxRA_HORIZONTAL); @@ -36,13 +36,13 @@ wxRadioBoxXmlHandler::wxRadioBoxXmlHandler() wxObject *wxRadioBoxXmlHandler::DoCreateResource() { - if( m_Class == wxT("wxRadioBox")) + if( m_class == wxT("wxRadioBox")) { // find the selection long selection = GetLong( wxT("selection"), -1 ); // need to build the list of strings from children - m_InsideBox = TRUE; + m_insideBox = TRUE; CreateChildrenPrivately( NULL, GetParamNode(wxT("content"))); wxString *strings = (wxString *) NULL; if( strList.GetCount() > 0 ) @@ -54,7 +54,7 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource() } - wxRadioBox *control = new wxRadioBox(m_ParentAsWindow, + wxRadioBox *control = new wxRadioBox(m_parentAsWindow, GetID(), GetText(wxT("label")), GetPosition(), GetSize(), @@ -83,7 +83,7 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource() // handle Label // add to the list - strList.Add( GetNodeContent(m_Node) ); + strList.Add( GetNodeContent(m_node) ); return NULL; } @@ -95,7 +95,7 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource() bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode *node) { return (IsOfClass(node, wxT("wxRadioBox")) || - (m_InsideBox && node->GetName() == wxT("item")) + (m_insideBox && node->GetName() == wxT("item")) ); } diff --git a/contrib/src/xml/xh_scrol.cpp b/contrib/src/xml/xh_scrol.cpp index 73531f1401..c614a6b9dd 100644 --- a/contrib/src/xml/xh_scrol.cpp +++ b/contrib/src/xml/xh_scrol.cpp @@ -33,7 +33,7 @@ wxScrollBarXmlHandler::wxScrollBarXmlHandler() wxObject *wxScrollBarXmlHandler::DoCreateResource() { - wxScrollBar *control = new wxScrollBar(m_ParentAsWindow, + wxScrollBar *control = new wxScrollBar(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(), diff --git a/contrib/src/xml/xh_sizer.cpp b/contrib/src/xml/xh_sizer.cpp index 3db7d8ad66..cd38979085 100644 --- a/contrib/src/xml/xh_sizer.cpp +++ b/contrib/src/xml/xh_sizer.cpp @@ -37,7 +37,7 @@ bool wxSizerXmlHandler::IsSizerNode(wxXmlNode *node) wxSizerXmlHandler::wxSizerXmlHandler() -: wxXmlResourceHandler(), m_IsInside(FALSE), m_ParentSizer(NULL) +: wxXmlResourceHandler(), m_isInside(FALSE), m_parentSizer(NULL) { ADD_STYLE(wxHORIZONTAL); ADD_STYLE(wxVERTICAL); @@ -74,36 +74,36 @@ wxSizerXmlHandler::wxSizerXmlHandler() wxObject *wxSizerXmlHandler::DoCreateResource() { - if (m_Class == wxT("sizeritem")) + if (m_class == wxT("sizeritem")) { wxXmlNode *n = GetParamNode(wxT("object")); if (n) { - bool old_ins = m_IsInside; - wxSizer *old_par = m_ParentSizer; - m_IsInside = FALSE; - if (!IsSizerNode(n)) m_ParentSizer = NULL; - wxObject *item = CreateResFromNode(n, m_Parent, NULL); - m_IsInside = old_ins; - m_ParentSizer = old_par; + bool old_ins = m_isInside; + wxSizer *old_par = m_parentSizer; + m_isInside = FALSE; + if (!IsSizerNode(n)) m_parentSizer = NULL; + wxObject *item = CreateResFromNode(n, m_parent, NULL); + m_isInside = old_ins; + m_parentSizer = old_par; wxSizer *sizer = wxDynamicCast(item, wxSizer); wxWindow *wnd = wxDynamicCast(item, wxWindow); wxSize minsize = GetSize(wxT("minsize")); if (sizer) { - m_ParentSizer->Add(sizer, GetLong(wxT("option")), + m_parentSizer->Add(sizer, GetLong(wxT("option")), GetStyle(wxT("flag")), GetDimension(wxT("border"))); if (!(minsize == wxDefaultSize)) - m_ParentSizer->SetItemMinSize(sizer, minsize.x, minsize.y); + m_parentSizer->SetItemMinSize(sizer, minsize.x, minsize.y); } else if (wnd) { - m_ParentSizer->Add(wnd, GetLong(wxT("option")), + m_parentSizer->Add(wnd, GetLong(wxT("option")), GetStyle(wxT("flag")), GetDimension(wxT("border"))); if (!(minsize == wxDefaultSize)) - m_ParentSizer->SetItemMinSize(wnd, minsize.x, minsize.y); + m_parentSizer->SetItemMinSize(wnd, minsize.x, minsize.y); } else wxLogError(wxT("Error in resource.")); @@ -117,11 +117,11 @@ wxObject *wxSizerXmlHandler::DoCreateResource() } } - else if (m_Class == wxT("spacer")) + else if (m_class == wxT("spacer")) { - wxCHECK_MSG(m_ParentSizer, NULL, wxT("Incorrect syntax of XML resource: spacer not within sizer!")); + wxCHECK_MSG(m_parentSizer, NULL, wxT("Incorrect syntax of XML resource: spacer not within sizer!")); wxSize sz = GetSize(); - m_ParentSizer->Add(sz.x, sz.y, + m_parentSizer->Add(sz.x, sz.y, GetLong(wxT("option")), GetStyle(wxT("flag")), GetDimension(wxT("border"))); return NULL; } @@ -130,29 +130,29 @@ wxObject *wxSizerXmlHandler::DoCreateResource() else { wxSizer *sizer = NULL; - wxXmlNode *parentNode = m_Node->GetParent(); + wxXmlNode *parentNode = m_node->GetParent(); - wxCHECK_MSG(m_ParentSizer != NULL || + wxCHECK_MSG(m_parentSizer != NULL || ((IsOfClass(parentNode, wxT("wxPanel")) || IsOfClass(parentNode, wxT("wxDialog"))) && parentNode->GetType() == wxXML_ELEMENT_NODE), NULL, wxT("Incorrect use of sizer: parent is not 'wxDialog' or 'wxPanel'.")); - if (m_Class == wxT("wxBoxSizer")) + if (m_class == wxT("wxBoxSizer")) sizer = new wxBoxSizer(GetStyle(wxT("orient"), wxHORIZONTAL)); - else if (m_Class == wxT("wxStaticBoxSizer")) + else if (m_class == wxT("wxStaticBoxSizer")) { sizer = new wxStaticBoxSizer( - new wxStaticBox(m_ParentAsWindow, -1, GetText(wxT("label"))), + new wxStaticBox(m_parentAsWindow, -1, GetText(wxT("label"))), GetStyle(wxT("orient"), wxHORIZONTAL)); } - else if (m_Class == wxT("wxGridSizer")) + else if (m_class == wxT("wxGridSizer")) sizer = new wxGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")), GetDimension(wxT("vgap")), GetDimension(wxT("hgap"))); - else if (m_Class == wxT("wxFlexGridSizer")) + else if (m_class == wxT("wxFlexGridSizer")) { wxFlexGridSizer *fsizer = new wxFlexGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")), @@ -182,27 +182,27 @@ wxObject *wxSizerXmlHandler::DoCreateResource() if (!(minsize == wxDefaultSize)) sizer->SetMinSize(minsize); - wxSizer *old_par = m_ParentSizer; - m_ParentSizer = sizer; - bool old_ins = m_IsInside; - m_IsInside = TRUE; - CreateChildren(m_Parent, TRUE/*only this handler*/); - m_IsInside = old_ins; - m_ParentSizer = old_par; + wxSizer *old_par = m_parentSizer; + m_parentSizer = sizer; + bool old_ins = m_isInside; + m_isInside = TRUE; + CreateChildren(m_parent, TRUE/*only this handler*/); + m_isInside = old_ins; + m_parentSizer = old_par; - if (m_ParentSizer == NULL) // setup window: + if (m_parentSizer == NULL) // setup window: { - m_ParentAsWindow->SetAutoLayout(TRUE); - m_ParentAsWindow->SetSizer(sizer); + m_parentAsWindow->SetAutoLayout(TRUE); + m_parentAsWindow->SetSizer(sizer); - wxXmlNode *nd = m_Node; - m_Node = parentNode; + wxXmlNode *nd = m_node; + m_node = parentNode; if (GetSize() == wxDefaultSize) - sizer->Fit(m_ParentAsWindow); - m_Node = nd; + sizer->Fit(m_parentAsWindow); + m_node = nd; - if (m_ParentAsWindow->GetWindowStyle() & (wxRESIZE_BOX | wxRESIZE_BORDER)) - sizer->SetSizeHints(m_ParentAsWindow); + if (m_parentAsWindow->GetWindowStyle() & (wxRESIZE_BOX | wxRESIZE_BORDER)) + sizer->SetSizeHints(m_parentAsWindow); } return sizer; @@ -213,7 +213,7 @@ wxObject *wxSizerXmlHandler::DoCreateResource() bool wxSizerXmlHandler::CanHandle(wxXmlNode *node) { - return ((!m_IsInside && IsSizerNode(node)) || - (m_IsInside && IsOfClass(node, wxT("sizeritem"))) || - (m_IsInside && IsOfClass(node, wxT("spacer")))); + return ((!m_isInside && IsSizerNode(node)) || + (m_isInside && IsOfClass(node, wxT("sizeritem"))) || + (m_isInside && IsOfClass(node, wxT("spacer")))); } diff --git a/contrib/src/xml/xh_slidr.cpp b/contrib/src/xml/xh_slidr.cpp index ad0c0076aa..fa53fe9cc4 100644 --- a/contrib/src/xml/xh_slidr.cpp +++ b/contrib/src/xml/xh_slidr.cpp @@ -42,7 +42,7 @@ wxSliderXmlHandler::wxSliderXmlHandler() wxObject *wxSliderXmlHandler::DoCreateResource() { - wxSlider *control = new wxSlider(m_ParentAsWindow, + wxSlider *control = new wxSlider(m_parentAsWindow, GetID(), GetLong( wxT("value"), wxSL_DEFAULT_VALUE), GetLong( wxT("min"), wxSL_DEFAULT_MIN), diff --git a/contrib/src/xml/xh_spin.cpp b/contrib/src/xml/xh_spin.cpp index 3cc514893e..689fe6f21a 100644 --- a/contrib/src/xml/xh_spin.cpp +++ b/contrib/src/xml/xh_spin.cpp @@ -36,7 +36,7 @@ wxSpinButtonXmlHandler::wxSpinButtonXmlHandler() wxObject *wxSpinButtonXmlHandler::DoCreateResource() { - wxSpinButton *control = new wxSpinButton(m_ParentAsWindow, + wxSpinButton *control = new wxSpinButton(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle( wxT("style"), wxSP_VERTICAL | wxSP_ARROW_KEYS ), @@ -73,7 +73,7 @@ wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler() wxObject *wxSpinCtrlXmlHandler::DoCreateResource() { - wxSpinCtrl *control = new wxSpinCtrl(m_ParentAsWindow, + wxSpinCtrl *control = new wxSpinCtrl(m_parentAsWindow, GetID(), GetText(wxT("value")), GetPosition(), GetSize(), diff --git a/contrib/src/xml/xh_stbmp.cpp b/contrib/src/xml/xh_stbmp.cpp index 699e5339a5..2d5b3c9472 100644 --- a/contrib/src/xml/xh_stbmp.cpp +++ b/contrib/src/xml/xh_stbmp.cpp @@ -30,7 +30,7 @@ wxStaticBitmapXmlHandler::wxStaticBitmapXmlHandler() wxObject *wxStaticBitmapXmlHandler::DoCreateResource() { - wxStaticBitmap *bmp = new wxStaticBitmap(m_ParentAsWindow, + wxStaticBitmap *bmp = new wxStaticBitmap(m_parentAsWindow, GetID(), GetBitmap(wxT("bitmap"), GetSize()), GetPosition(), GetSize(), diff --git a/contrib/src/xml/xh_stbox.cpp b/contrib/src/xml/xh_stbox.cpp index 2572364e3e..04dd72e4dd 100644 --- a/contrib/src/xml/xh_stbox.cpp +++ b/contrib/src/xml/xh_stbox.cpp @@ -30,7 +30,7 @@ wxStaticBoxXmlHandler::wxStaticBoxXmlHandler() wxObject *wxStaticBoxXmlHandler::DoCreateResource() { - wxStaticBox *box = new wxStaticBox(m_ParentAsWindow, + wxStaticBox *box = new wxStaticBox(m_parentAsWindow, GetID(), GetText(wxT("label")), GetPosition(), GetSize(), diff --git a/contrib/src/xml/xh_stlin.cpp b/contrib/src/xml/xh_stlin.cpp index d65fc08fe6..ae9d9f0b6e 100644 --- a/contrib/src/xml/xh_stlin.cpp +++ b/contrib/src/xml/xh_stlin.cpp @@ -34,7 +34,7 @@ wxStaticLineXmlHandler::wxStaticLineXmlHandler() wxObject *wxStaticLineXmlHandler::DoCreateResource() { - wxStaticLine *line = new wxStaticLine(m_ParentAsWindow, + wxStaticLine *line = new wxStaticLine(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style"), wxLI_HORIZONTAL), diff --git a/contrib/src/xml/xh_sttxt.cpp b/contrib/src/xml/xh_sttxt.cpp index fbf8fd0938..bfecff2584 100644 --- a/contrib/src/xml/xh_sttxt.cpp +++ b/contrib/src/xml/xh_sttxt.cpp @@ -31,7 +31,7 @@ wxStaticTextXmlHandler::wxStaticTextXmlHandler() wxObject *wxStaticTextXmlHandler::DoCreateResource() { - wxStaticText *text = new wxStaticText(m_ParentAsWindow, + wxStaticText *text = new wxStaticText(m_parentAsWindow, GetID(), GetText(wxT("label")), GetPosition(), GetSize(), diff --git a/contrib/src/xml/xh_text.cpp b/contrib/src/xml/xh_text.cpp index a5d9b35a93..bdba8d57cc 100644 --- a/contrib/src/xml/xh_text.cpp +++ b/contrib/src/xml/xh_text.cpp @@ -35,7 +35,7 @@ wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler() wxObject *wxTextCtrlXmlHandler::DoCreateResource() { - wxTextCtrl *text = new wxTextCtrl(m_ParentAsWindow, + wxTextCtrl *text = new wxTextCtrl(m_parentAsWindow, GetID(), GetText(wxT("value")), GetPosition(), GetSize(), diff --git a/contrib/src/xml/xh_toolb.cpp b/contrib/src/xml/xh_toolb.cpp index 87c4d2eb69..9b57f77986 100644 --- a/contrib/src/xml/xh_toolb.cpp +++ b/contrib/src/xml/xh_toolb.cpp @@ -26,7 +26,7 @@ #if wxUSE_TOOLBAR wxToolBarXmlHandler::wxToolBarXmlHandler() -: wxXmlResourceHandler(), m_IsInside(FALSE), m_Toolbar(NULL) +: wxXmlResourceHandler(), m_isInside(FALSE), m_toolbar(NULL) { ADD_STYLE(wxTB_FLAT); ADD_STYLE(wxTB_DOCKABLE); @@ -38,10 +38,10 @@ wxToolBarXmlHandler::wxToolBarXmlHandler() wxObject *wxToolBarXmlHandler::DoCreateResource() { - if (m_Class == wxT("tool")) + if (m_class == wxT("tool")) { - wxCHECK_MSG(m_Toolbar, NULL, wxT("Incorrect syntax of XML resource: tool not within a toolbar!")); - m_Toolbar->AddTool(GetID(), + wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XML resource: tool not within a toolbar!")); + m_toolbar->AddTool(GetID(), GetBitmap(wxT("bitmap")), GetBitmap(wxT("bitmap2")), GetBool(wxT("toggle")), @@ -50,14 +50,14 @@ wxObject *wxToolBarXmlHandler::DoCreateResource() NULL, GetText(wxT("tooltip")), GetText(wxT("longhelp"))); - return m_Toolbar; // must return non-NULL + return m_toolbar; // must return non-NULL } - else if (m_Class == wxT("separator")) + else if (m_class == wxT("separator")) { - wxCHECK_MSG(m_Toolbar, NULL, wxT("Incorrect syntax of XML resource: separator not within a toolbar!")); - m_Toolbar->AddSeparator(); - return m_Toolbar; // must return non-NULL + wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XML resource: separator not within a toolbar!")); + m_toolbar->AddSeparator(); + return m_toolbar; // must return non-NULL } else /**/ @@ -66,7 +66,7 @@ wxObject *wxToolBarXmlHandler::DoCreateResource() #ifdef __WXMSW__ if (!(style & wxNO_BORDER)) style |= wxNO_BORDER; #endif - wxToolBar *toolbar = new wxToolBar(m_ParentAsWindow, + wxToolBar *toolbar = new wxToolBar(m_parentAsWindow, GetID(), GetPosition(), GetSize(), @@ -89,8 +89,8 @@ wxObject *wxToolBarXmlHandler::DoCreateResource() wxXmlNode *children_node = GetParamNode(wxT("object")); if (children_node == NULL) return toolbar; - m_IsInside = TRUE; - m_Toolbar = toolbar; + m_isInside = TRUE; + m_toolbar = toolbar; wxXmlNode *n = children_node; @@ -109,8 +109,8 @@ wxObject *wxToolBarXmlHandler::DoCreateResource() n = n->GetNext(); } - m_IsInside = FALSE; - m_Toolbar = NULL; + m_isInside = FALSE; + m_toolbar = NULL; toolbar->Realize(); return toolbar; @@ -121,9 +121,9 @@ wxObject *wxToolBarXmlHandler::DoCreateResource() bool wxToolBarXmlHandler::CanHandle(wxXmlNode *node) { - return ((!m_IsInside && IsOfClass(node, wxT("wxToolBar"))) || - (m_IsInside && IsOfClass(node, wxT("tool"))) || - (m_IsInside && IsOfClass(node, wxT("separator")))); + return ((!m_isInside && IsOfClass(node, wxT("wxToolBar"))) || + (m_isInside && IsOfClass(node, wxT("tool"))) || + (m_isInside && IsOfClass(node, wxT("separator")))); } #endif diff --git a/contrib/src/xml/xh_tree.cpp b/contrib/src/xml/xh_tree.cpp index 30582f9d55..b1f5d3625a 100644 --- a/contrib/src/xml/xh_tree.cpp +++ b/contrib/src/xml/xh_tree.cpp @@ -35,7 +35,7 @@ wxTreeCtrlXmlHandler::wxTreeCtrlXmlHandler() wxObject *wxTreeCtrlXmlHandler::DoCreateResource() { - wxTreeCtrl *tree = new wxTreeCtrl(m_ParentAsWindow, + wxTreeCtrl *tree = new wxTreeCtrl(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(), diff --git a/contrib/src/xml/xh_unkwn.cpp b/contrib/src/xml/xh_unkwn.cpp index 5a8145c1ff..161b700fd2 100644 --- a/contrib/src/xml/xh_unkwn.cpp +++ b/contrib/src/xml/xh_unkwn.cpp @@ -38,16 +38,16 @@ wxObject *wxUnknownWidgetXmlHandler::DoCreateResource() wxWindow *wnd = NULL; if (id != -1) - wnd = m_ParentAsWindow->FindWindow(id); + wnd = m_parentAsWindow->FindWindow(id); if (wnd == NULL && !name.IsEmpty()) - wnd = m_ParentAsWindow->FindWindow(name); + wnd = m_parentAsWindow->FindWindow(name); if (wnd == NULL) wxLogError(wxT("Cannot find specified window for class 'unknown' (id=%li, name='%s')."), id, name.mb_str()); else { - if (wnd->GetParent() != m_ParentAsWindow) - wnd->Reparent(m_ParentAsWindow); + if (wnd->GetParent() != m_parentAsWindow) + wnd->Reparent(m_parentAsWindow); SetupWindow(wnd); } diff --git a/contrib/src/xml/xml.cpp b/contrib/src/xml/xml.cpp index c7fc2f4746..022ab9b9a4 100644 --- a/contrib/src/xml/xml.cpp +++ b/contrib/src/xml/xml.cpp @@ -35,19 +35,19 @@ wxXmlNode::wxXmlNode(wxXmlNode *parent,wxXmlNodeType type, const wxString& name, const wxString& content, wxXmlProperty *props, wxXmlNode *next) - : m_Type(type), m_Name(name), m_Content(content), - m_Properties(props), m_Parent(parent), - m_Children(NULL), m_Next(next) + : m_type(type), m_name(name), m_content(content), + m_properties(props), m_parent(parent), + m_children(NULL), m_next(next) { - if (m_Parent) + if (m_parent) { - if (m_Parent->m_Children) + if (m_parent->m_children) { - m_Next = m_Parent->m_Children; - m_Parent->m_Children = this; + m_next = m_parent->m_children; + m_parent->m_children = this; } else - m_Parent->m_Children = this; + m_parent->m_children = this; } } @@ -55,17 +55,17 @@ wxXmlNode::wxXmlNode(wxXmlNode *parent,wxXmlNodeType type, wxXmlNode::wxXmlNode(wxXmlNodeType type, const wxString& name, const wxString& content) - : m_Type(type), m_Name(name), m_Content(content), - m_Properties(NULL), m_Parent(NULL), - m_Children(NULL), m_Next(NULL) + : m_type(type), m_name(name), m_content(content), + m_properties(NULL), m_parent(NULL), + m_children(NULL), m_next(NULL) {} wxXmlNode::wxXmlNode(const wxXmlNode& node) { - m_Next = NULL; - m_Parent = NULL; + m_next = NULL; + m_parent = NULL; DoCopy(node); } @@ -73,8 +73,8 @@ wxXmlNode::wxXmlNode(const wxXmlNode& node) wxXmlNode& wxXmlNode::operator=(const wxXmlNode& node) { - delete m_Properties; - delete m_Children; + delete m_properties; + delete m_children; DoCopy(node); return *this; } @@ -83,20 +83,20 @@ wxXmlNode& wxXmlNode::operator=(const wxXmlNode& node) void wxXmlNode::DoCopy(const wxXmlNode& node) { - m_Type = node.m_Type; - m_Name = node.m_Name; - m_Content = node.m_Content; - m_Children = NULL; + m_type = node.m_type; + m_name = node.m_name; + m_content = node.m_content; + m_children = NULL; - wxXmlNode *n = node.m_Children; + wxXmlNode *n = node.m_children; while (n) { AddChild(new wxXmlNode(*n)); n = n->GetNext(); } - m_Properties = NULL; - wxXmlProperty *p = node.m_Properties; + m_properties = NULL; + wxXmlProperty *p = node.m_properties; while (p) { AddProperty(p->GetName(), p->GetValue()); @@ -152,16 +152,16 @@ wxString wxXmlNode::GetPropVal(const wxString& propName, const wxString& default void wxXmlNode::AddChild(wxXmlNode *child) { - if (m_Children == NULL) - m_Children = child; + if (m_children == NULL) + m_children = child; else { - wxXmlNode *ch = m_Children; - while (ch->m_Next) ch = ch->m_Next; - ch->m_Next = child; + wxXmlNode *ch = m_children; + while (ch->m_next) ch = ch->m_next; + ch->m_next = child; } - child->m_Next = NULL; - child->m_Parent = this; + child->m_next = NULL; + child->m_parent = this; } @@ -170,45 +170,45 @@ void wxXmlNode::InsertChild(wxXmlNode *child, wxXmlNode *before_node) { wxASSERT_MSG(before_node->GetParent() == this, wxT("wxXmlNode::InsertChild - the node has incorrect parent")); - if (m_Children == before_node) - m_Children = child; + if (m_children == before_node) + m_children = child; else { - wxXmlNode *ch = m_Children; - while (ch->m_Next != before_node) ch = ch->m_Next; - ch->m_Next = child; + wxXmlNode *ch = m_children; + while (ch->m_next != before_node) ch = ch->m_next; + ch->m_next = child; } - child->m_Parent = this; - child->m_Next = before_node; + child->m_parent = this; + child->m_next = before_node; } bool wxXmlNode::RemoveChild(wxXmlNode *child) { - if (m_Children == NULL) + if (m_children == NULL) return FALSE; - else if (m_Children == child) + else if (m_children == child) { - m_Children = child->m_Next; - child->m_Parent = NULL; - child->m_Next = NULL; + m_children = child->m_next; + child->m_parent = NULL; + child->m_next = NULL; return TRUE; } else { - wxXmlNode *ch = m_Children; - while (ch->m_Next) + wxXmlNode *ch = m_children; + while (ch->m_next) { - if (ch->m_Next == child) + if (ch->m_next == child) { - ch->m_Next = child->m_Next; - child->m_Parent = NULL; - child->m_Next = NULL; + ch->m_next = child->m_next; + child->m_parent = NULL; + child->m_next = NULL; return TRUE; } - ch = ch->m_Next; + ch = ch->m_next; } return FALSE; } @@ -223,11 +223,11 @@ void wxXmlNode::AddProperty(const wxString& name, const wxString& value) void wxXmlNode::AddProperty(wxXmlProperty *prop) { - if (m_Properties == NULL) - m_Properties = prop; + if (m_properties == NULL) + m_properties = prop; else { - wxXmlProperty *p = m_Properties; + wxXmlProperty *p = m_properties; while (p->GetNext()) p = p->GetNext(); p->SetNext(prop); } @@ -237,13 +237,13 @@ void wxXmlNode::AddProperty(wxXmlProperty *prop) bool wxXmlNode::DeleteProperty(const wxString& name) { - if (m_Properties == NULL) + if (m_properties == NULL) return FALSE; - else if (m_Properties->GetName() == name) + else if (m_properties->GetName() == name) { - wxXmlProperty *prop = m_Properties; - m_Properties = prop->GetNext(); + wxXmlProperty *prop = m_properties; + m_properties = prop->GetNext(); prop->SetNext(NULL); delete prop; return TRUE; @@ -251,7 +251,7 @@ bool wxXmlNode::DeleteProperty(const wxString& name) else { - wxXmlProperty *p = m_Properties; + wxXmlProperty *p = m_properties; while (p->GetNext()) { if (p->GetNext()->GetName() == name) @@ -275,29 +275,29 @@ bool wxXmlNode::DeleteProperty(const wxString& name) -wxList *wxXmlDocument::sm_Handlers = NULL; +wxList *wxXmlDocument::sm_handlers = NULL; wxXmlDocument::wxXmlDocument(const wxString& filename, wxXmlIOType io_type) - : wxObject(), m_Root(NULL) + : wxObject(), m_root(NULL) { if (!Load(filename, io_type)) { - delete m_Root; - m_Root = NULL; + delete m_root; + m_root = NULL; } } wxXmlDocument::wxXmlDocument(wxInputStream& stream, wxXmlIOType io_type) - : wxObject(), m_Root(NULL) + : wxObject(), m_root(NULL) { if (!Load(stream, io_type)) { - delete m_Root; - m_Root = NULL; + delete m_root; + m_root = NULL; } } @@ -312,7 +312,7 @@ wxXmlDocument::wxXmlDocument(const wxXmlDocument& doc) wxXmlDocument& wxXmlDocument::operator=(const wxXmlDocument& doc) { - delete m_Root; + delete m_root; DoCopy(doc); return *this; } @@ -321,9 +321,9 @@ wxXmlDocument& wxXmlDocument::operator=(const wxXmlDocument& doc) void wxXmlDocument::DoCopy(const wxXmlDocument& doc) { - m_Version = doc.m_Version; - m_Encoding = doc.m_Encoding; - m_Root = new wxXmlNode(*doc.m_Root); + m_version = doc.m_version; + m_encoding = doc.m_encoding; + m_root = new wxXmlNode(*doc.m_root); } @@ -338,7 +338,7 @@ bool wxXmlDocument::Load(const wxString& filename, wxXmlIOType io_type) bool wxXmlDocument::Load(wxInputStream& stream, wxXmlIOType io_type) { - wxNode *n = sm_Handlers->GetFirst(); + wxNode *n = sm_handlers->GetFirst(); while (n) { wxXmlIOHandler *h = (wxXmlIOHandler*) n->GetData(); @@ -366,7 +366,7 @@ bool wxXmlDocument::Save(const wxString& filename, wxXmlIOType io_type) const bool wxXmlDocument::Save(wxOutputStream& stream, wxXmlIOType io_type) const { - wxNode *n = sm_Handlers->GetFirst(); + wxNode *n = sm_handlers->GetFirst(); while (n) { wxXmlIOHandler *h = (wxXmlIOHandler*) n->GetData(); @@ -387,19 +387,19 @@ bool wxXmlDocument::Save(wxOutputStream& stream, wxXmlIOType io_type) const void wxXmlDocument::AddHandler(wxXmlIOHandler *handler) { - if (sm_Handlers == NULL) + if (sm_handlers == NULL) { - sm_Handlers = new wxList; - sm_Handlers->DeleteContents(TRUE); + sm_handlers = new wxList; + sm_handlers->DeleteContents(TRUE); } - sm_Handlers->Append(handler); + sm_handlers->Append(handler); } void wxXmlDocument::CleanUpHandlers() { - delete sm_Handlers; - sm_Handlers = NULL; + delete sm_handlers; + sm_handlers = NULL; } @@ -407,7 +407,8 @@ void wxXmlDocument::InitStandardHandlers() { AddHandler(new wxXmlIOHandlerBin); AddHandler(new wxXmlIOHandlerBinZ); - AddHandler(new wxXmlIOHandlerLibxml); + AddHandler(new wxXmlIOHandlerExpat); + AddHandler(new wxXmlIOHandlerWriter); } diff --git a/contrib/src/xml/xmlexpat.cpp b/contrib/src/xml/xmlexpat.cpp new file mode 100644 index 0000000000..95443131d3 --- /dev/null +++ b/contrib/src/xml/xmlexpat.cpp @@ -0,0 +1,192 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xmlexpat.cpp +// Purpose: wxXmlDocument - XML reader via Expat +// Author: Vaclav Slavik +// Created: 2001/04/30 +// RCS-ID: $Id$ +// Copyright: (c) 2001 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +// nothing - already in xml.cpp +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/wfstream.h" +#include "wx/intl.h" +#include "wx/log.h" +#include "wx/strconv.h" +#include "wx/xml/xmlio.h" + +#include "xmlparse.h" + +/* + + FIXME: + + - handle unknown encodings + - process all elements, including CDATA + - XML resources should automatically select desired encoding besed on + runtime environment (?) (would need BIN and BINZ formats modification, + too) + + */ + + +// converts Expat-produced string in UTF-8 into wxString. +inline static wxString CharToString(const char *s, size_t len = wxSTRING_MAXLEN) +{ +#if wxUSE_UNICODE + return wxString(s, wxMBConvUTF8, len); +#else + return wxString(s, len); +#endif +} + +bool wxXmlIOHandlerExpat::CanLoad(wxInputStream& stream) +{ + char cheader[7]; + cheader[6] = 0; + stream.Read(cheader, 6); + stream.SeekI(-6, wxFromCurrent); + return (strcmp(cheader, "AddProperty(CharToString(a[0]), CharToString(a[1])); + a += 2; + } + if (ctx->root == NULL) + ctx->root = node; + else + ctx->node->AddChild(node); + ctx->node = node; + ctx->lastAsText = NULL; +} + +static void EndElementHnd(void *userData, const char *name) +{ + wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData; + + ctx->node = ctx->node->GetParent(); + ctx->lastAsText = NULL; +} + +static void TextHnd(void *userData, const char *s, int len) +{ + wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData; + char *buf = new char[len + 1]; + + buf[len] = '\0'; + memcpy(buf, s, (size_t)len); + + if (ctx->lastAsText) + { + ctx->lastAsText->SetContent(ctx->lastAsText->GetContent() + + CharToString(buf)); + } + else + { + bool whiteOnly = TRUE; + for (char *c = buf; *c != '\0'; c++) + if (*c != ' ' && *c != '\t' && *c != '\n' && *c != '\r') + { + whiteOnly = FALSE; + break; + } + if (!whiteOnly) + { + ctx->lastAsText = new wxXmlNode(wxXML_TEXT_NODE, wxT("text"), + CharToString(buf)); + ctx->node->AddChild(ctx->lastAsText); + } + } + + delete[] buf; +} + +static void CommentHnd(void *userData, const char *data) +{ + wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData; + + ctx->node->AddChild(new wxXmlNode(wxXML_COMMENT_NODE, + wxT("comment"), CharToString(data))); + ctx->lastAsText = NULL; +} + +static void DefaultHnd(void *userData, const char *s, int len) +{ + // XML header: + if (len > 6 && memcmp(s, "encoding = buf.Mid(pos + 10).BeforeFirst(buf[pos+9]); + pos = buf.Find(wxT("version=")); + if (pos != wxNOT_FOUND) + ctx->version = buf.Mid(pos + 9).BeforeFirst(buf[pos+8]); + } +} + +bool wxXmlIOHandlerExpat::Load(wxInputStream& stream, wxXmlDocument& doc) +{ + const size_t BUFSIZE = 1024; + char buf[BUFSIZE]; + wxXmlParsingContext ctx; + bool done; + XML_Parser parser = XML_ParserCreate(NULL); + + ctx.root = ctx.node = NULL; + XML_SetUserData(parser, (void*)&ctx); + XML_SetElementHandler(parser, StartElementHnd, EndElementHnd); + XML_SetCharacterDataHandler(parser, TextHnd); + XML_SetCommentHandler(parser, CommentHnd); + XML_SetDefaultHandler(parser, DefaultHnd); + + do + { + size_t len = stream.Read(buf, BUFSIZE).LastRead(); + done = (len < BUFSIZE); + if (!XML_Parse(parser, buf, len, done)) + { + wxLogError(_("XML parsing error: '%s' at line %d"), + XML_ErrorString(XML_GetErrorCode(parser)), + XML_GetCurrentLineNumber(parser)); + return FALSE; + } + } while (!done); + + doc.SetVersion(ctx.version); + doc.SetEncoding(ctx.encoding); + doc.SetRoot(ctx.root); + + XML_ParserFree(parser); + return TRUE; +} diff --git a/contrib/src/xml/xmlpars.cpp b/contrib/src/xml/xmlpars.cpp deleted file mode 100644 index ba56cb3c13..0000000000 --- a/contrib/src/xml/xmlpars.cpp +++ /dev/null @@ -1,366 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: xmlpars.cpp -// Purpose: wxXmlDocument - XML parser -// Author: Vaclav Slavik -// Created: 2000/03/05 -// RCS-ID: $Id$ -// Copyright: (c) 2000 Vaclav Slavik -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -// nothing - already in xml.cpp -#endif - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/wfstream.h" -#include "wx/intl.h" -#include "wx/log.h" -#include "wx/dynlib.h" -#include "wx/xml/xmlio.h" - -#include -#include - - -// wxWindows SAX handlers for bugs reporting: - -static void wxXmlParserError(void *ctx, const char *msg, ...) -{ - wxString text; - xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; - if (ctxt->input) - text.Printf( _("XML parser error at line %d: "), ctxt->input->line ); - va_list args; - wxString tmp; - va_start(args, msg); - tmp.PrintfV( msg, args ); - va_end(args); - text += tmp; - wxLogError( text.c_str() ); -} - -static void wxXmlParserWarning(void *ctx, const char *msg, ...) -{ - wxString text; - xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; - if (ctxt->input) - text.Printf( _("XML parser warning at line %d: "), ctxt->input->line ); - va_list args; - wxString tmp; - va_start(args, msg); - tmp.PrintfV( msg, args ); - va_end(args); - text += tmp; - wxLogWarning( text.c_str() ); -} - -static xmlSAXHandler gs_wxXmlSAXHandler; - - - -// dynamically loaded functions from libxml: -typedef xmlParserCtxtPtr (*type_xmlCreatePushParserCtxt) - (xmlSAXHandlerPtr sax, void *, const char *, int, const char *); -typedef xmlNodePtr (*type_xmlNewText)(const xmlChar *); -typedef xmlAttrPtr (*type_xmlSetProp)(xmlNodePtr, const xmlChar *, const xmlChar *); -typedef int (*type_xmlParseChunk)(xmlParserCtxtPtr, const char *, int, int); -typedef void (*type_xmlFreeParserCtxt)(xmlParserCtxtPtr); -typedef xmlDocPtr (*type_xmlNewDoc)(const xmlChar *); -typedef void (*type_xmlFreeDoc)(xmlDocPtr); -typedef xmlNodePtr (*type_xmlNewDocNode)(xmlDocPtr, xmlNsPtr, const xmlChar *, const xmlChar *); -typedef void (*type_xmlDocDumpMemory)(xmlDocPtr, xmlChar**, int *); -typedef xmlNodePtr (*type_xmlAddChild)(xmlNodePtr, xmlNodePtr); -typedef xmlNodePtr (*type_xmlNewChild)(xmlNodePtr, xmlNsPtr, const xmlChar *, const xmlChar *); -typedef xmlChar * (*type_xmlNodeListGetString)(xmlDocPtr, xmlNodePtr, int); -typedef xmlNodePtr (*type_xmlDocGetRootElement)(xmlDocPtr); -typedef xmlNodePtr (*type_xmlDocSetRootElement)(xmlDocPtr doc, xmlNodePtr root); -typedef void (*(*type_xmlFree))(void *); -typedef int (*type_xmlKeepBlanksDefault)(int); -typedef void (*type_xmlInitParser)(void); -typedef void (*type_xmlCleanupParser)(void); -typedef xmlSAXHandler *type_xmlDefaultSAXHandler; - -static struct -{ - wxDllType Handle; - - type_xmlCreatePushParserCtxt xmlCreatePushParserCtxt; - type_xmlNewText xmlNewText; - type_xmlSetProp xmlSetProp; - type_xmlParseChunk xmlParseChunk; - type_xmlFreeParserCtxt xmlFreeParserCtxt; - type_xmlNewDoc xmlNewDoc; - type_xmlFreeDoc xmlFreeDoc; - type_xmlNewDocNode xmlNewDocNode; - type_xmlDocDumpMemory xmlDocDumpMemory; - type_xmlAddChild xmlAddChild; - type_xmlNewChild xmlNewChild; - type_xmlNodeListGetString xmlNodeListGetString; - type_xmlDocGetRootElement xmlDocGetRootElement; - type_xmlDocSetRootElement xmlDocSetRootElement; - type_xmlFree xmlFree; - type_xmlKeepBlanksDefault xmlKeepBlanksDefault; - type_xmlInitParser xmlInitParser; - type_xmlCleanupParser xmlCleanupParser; - type_xmlDefaultSAXHandler xmlDefaultSAXHandler; -} gs_libxmlDLL; - -static bool gs_libxmlLoaded = FALSE; -static bool gs_libxmlLoadFailed = FALSE; - - - -static void ReleaseLibxml() -{ - if (gs_libxmlLoaded) - { - // Check for CleanupParser ..may have failed before initialised - // during LOAD_SYMBOL in LoadLibxml() - if (gs_libxmlDLL.xmlCleanupParser) - gs_libxmlDLL.xmlCleanupParser(); - wxDllLoader::UnloadLibrary(gs_libxmlDLL.Handle); - } - gs_libxmlLoaded = FALSE; - gs_libxmlLoadFailed = FALSE; -} - - -static bool LoadLibxml() -{ - if (gs_libxmlLoaded) return TRUE; - if (gs_libxmlLoadFailed) return FALSE; - gs_libxmlLoadFailed = TRUE; - - { - wxLogNull lg; -#ifdef __UNIX__ - gs_libxmlDLL.Handle = - wxDllLoader::LoadLibrary(wxT("wxlibxml.so.2"), &gs_libxmlLoaded); - if (!gs_libxmlLoaded) gs_libxmlDLL.Handle = - wxDllLoader::LoadLibrary(wxT("libxml.so.2"), &gs_libxmlLoaded); -#endif -#ifdef __WXMSW__ - gs_libxmlDLL.Handle = - wxDllLoader::LoadLibrary(wxT("wxlibxml2.dll"), &gs_libxmlLoaded); - if (!gs_libxmlLoaded) gs_libxmlDLL.Handle = - wxDllLoader::LoadLibrary(wxT("libxml2.dll"), &gs_libxmlLoaded); -#endif - } - - if (!gs_libxmlLoaded) - { - wxLogError(_("Failed to load libxml shared library.")); - return FALSE; - } - -#define LOAD_SYMBOL(sym) \ - gs_libxmlDLL.sym = \ - (type_##sym)wxDllLoader::GetSymbol(gs_libxmlDLL.Handle, wxT(#sym)); \ - if (!gs_libxmlDLL.sym) \ - { \ - ReleaseLibxml(); \ - wxLogError(_("Failed to load libxml shared library.")); \ - return FALSE; \ - } - - LOAD_SYMBOL(xmlCreatePushParserCtxt) - LOAD_SYMBOL(xmlNewText) - LOAD_SYMBOL(xmlSetProp) - LOAD_SYMBOL(xmlParseChunk) - LOAD_SYMBOL(xmlFreeParserCtxt) - LOAD_SYMBOL(xmlNewDoc) - LOAD_SYMBOL(xmlFreeDoc) - LOAD_SYMBOL(xmlNewDocNode) - LOAD_SYMBOL(xmlDocDumpMemory) - LOAD_SYMBOL(xmlAddChild) - LOAD_SYMBOL(xmlNewChild) - LOAD_SYMBOL(xmlNodeListGetString) - LOAD_SYMBOL(xmlDocGetRootElement) - LOAD_SYMBOL(xmlDocSetRootElement) - LOAD_SYMBOL(xmlFree) - LOAD_SYMBOL(xmlKeepBlanksDefault) - LOAD_SYMBOL(xmlInitParser) - LOAD_SYMBOL(xmlCleanupParser) - LOAD_SYMBOL(xmlDefaultSAXHandler) - -#undef LOAD_SYMBOL - - gs_libxmlLoadFailed = FALSE; - - gs_libxmlDLL.xmlInitParser(); - memcpy(&gs_wxXmlSAXHandler, gs_libxmlDLL.xmlDefaultSAXHandler, - sizeof(xmlSAXHandler)); - gs_wxXmlSAXHandler.error = wxXmlParserError; - gs_wxXmlSAXHandler.fatalError = wxXmlParserError; - gs_wxXmlSAXHandler.warning = wxXmlParserWarning; - - return TRUE; -} - - - - -bool wxXmlIOHandlerLibxml::CanLoad(wxInputStream& stream) -{ - if (!LoadLibxml()) return FALSE; - char cheader[7]; - cheader[6] = 0; - stream.Read(cheader, 6); - stream.SeekI(-6, wxFromCurrent); - return strcmp(cheader, "children, 1); - wxXmlProperty *prop = - new wxXmlProperty(attr->name, val, CreateWXProperty(doc, attr->next)); - (*gs_libxmlDLL.xmlFree)(val); - return prop; -} - - - -static wxXmlNode *CreateWXNode(xmlDocPtr doc, wxXmlNode *parent, xmlNodePtr node) -{ - if (node == NULL) return NULL; - - wxXmlNode *nd = new wxXmlNode(parent, (wxXmlNodeType)node->type, - node->name, node->content, - CreateWXProperty(doc, node->properties), - CreateWXNode(doc, parent, node->next)); - CreateWXNode(doc, nd, node->children); - return nd; -} - - - -bool wxXmlIOHandlerLibxml::Load(wxInputStream& stream, wxXmlDocument& doc) -{ - if (!LoadLibxml()) return FALSE; - - xmlDocPtr dc; - xmlParserCtxtPtr ctxt; - - char buffer[1024]; - int res; - - res = stream.Read(buffer, 4).LastRead(); - if (res > 0) - { - bool okay = TRUE; - gs_libxmlDLL.xmlKeepBlanksDefault(0); - ctxt = gs_libxmlDLL.xmlCreatePushParserCtxt(&gs_wxXmlSAXHandler, - NULL, buffer, res, ""/*docname*/); - while ((res = stream.Read(buffer, 1024).LastRead()) > 0) - if (gs_libxmlDLL.xmlParseChunk(ctxt, buffer, res, 0) != 0) - okay = FALSE; - if (gs_libxmlDLL.xmlParseChunk(ctxt, buffer, 0, 1) != 0) okay = FALSE; - dc = ctxt->myDoc; - gs_libxmlDLL.xmlFreeParserCtxt(ctxt); - - doc.SetVersion(dc->version); - doc.SetEncoding(dc->encoding); - doc.SetRoot(CreateWXNode(dc, NULL, gs_libxmlDLL.xmlDocGetRootElement(dc))); - - gs_libxmlDLL.xmlFreeDoc(dc); - - return okay; - } - else return FALSE; -} - - - -static void CreateLibxmlNode(xmlNodePtr node, wxXmlNode *wxnode) -{ - node->type = (xmlElementType)wxnode->GetType(); - - wxXmlProperty *prop = wxnode->GetProperties(); - while (prop) - { - gs_libxmlDLL.xmlSetProp(node, (xmlChar*)prop->GetName().mb_str(), - (xmlChar*)prop->GetValue().mb_str()); - prop = prop->GetNext(); - } - - wxXmlNode *child = wxnode->GetChildren(); - xmlNodePtr n; - xmlChar *content, *name; - - while (child) - { - name = (xmlChar*)child->GetName().mb_str(); - if (!child->GetContent()) content = NULL; - else content = (xmlChar*)child->GetContent().mb_str(); - if (child->GetType() == wxXML_TEXT_NODE) - gs_libxmlDLL.xmlAddChild(node, n = gs_libxmlDLL.xmlNewText(content)); - else - n = gs_libxmlDLL.xmlNewChild(node, NULL, name, content); - CreateLibxmlNode(n, child); - child = child->GetNext(); - } -} - - - -bool wxXmlIOHandlerLibxml::Save(wxOutputStream& stream, const wxXmlDocument& doc) -{ - if (!LoadLibxml()) return FALSE; - - xmlDocPtr dc; - - wxASSERT_MSG(doc.GetRoot() != NULL, _("Trying to save empty document!")); - - gs_libxmlDLL.xmlKeepBlanksDefault(0); - dc = gs_libxmlDLL.xmlNewDoc((xmlChar*)doc.GetVersion().mb_str()); - - gs_libxmlDLL.xmlDocSetRootElement(dc, - gs_libxmlDLL.xmlNewDocNode(dc, NULL, - (xmlChar*)doc.GetRoot()->GetName().mb_str(), NULL)); - CreateLibxmlNode(gs_libxmlDLL.xmlDocGetRootElement(dc), doc.GetRoot()); - - xmlChar *buffer; - int size; - - gs_libxmlDLL.xmlDocDumpMemory(dc, &buffer, &size); - gs_libxmlDLL.xmlFreeDoc(dc); - stream.Write(buffer, size); - (*gs_libxmlDLL.xmlFree)(buffer); - return stream.LastWrite() == (unsigned)size; -} - - - - -#include "wx/module.h" - -class wxXmlLibxmlModule: public wxModule -{ - DECLARE_DYNAMIC_CLASS(wxXmlLibxmlModule) - public: - wxXmlLibxmlModule() {} - bool OnInit() { return TRUE; } - void OnExit() { ReleaseLibxml(); } -}; - -IMPLEMENT_DYNAMIC_CLASS(wxXmlLibxmlModule, wxModule) diff --git a/contrib/src/xml/xmlres.cpp b/contrib/src/xml/xmlres.cpp index 19c6eaf4cf..16b68d55d3 100644 --- a/contrib/src/xml/xmlres.cpp +++ b/contrib/src/xml/xmlres.cpp @@ -42,14 +42,14 @@ WX_DEFINE_OBJARRAY(wxXmlResourceDataRecords); wxXmlResource::wxXmlResource(bool use_locale) { - m_Handlers.DeleteContents(TRUE); - m_UseLocale = use_locale; + m_handlers.DeleteContents(TRUE); + m_useLocale = use_locale; } wxXmlResource::wxXmlResource(const wxString& filemask, bool use_locale) { - m_UseLocale = use_locale; - m_Handlers.DeleteContents(TRUE); + m_useLocale = use_locale; + m_handlers.DeleteContents(TRUE); Load(filemask); } @@ -91,7 +91,7 @@ bool wxXmlResource::Load(const wxString& filemask) { drec = new wxXmlResourceDataRecord; drec->File = fnd2; - m_Data.Add(drec); + m_data.Add(drec); fnd2 = fs2.FindNext(); } } @@ -100,7 +100,7 @@ bool wxXmlResource::Load(const wxString& filemask) { drec = new wxXmlResourceDataRecord; drec->File = fnd; - m_Data.Add(drec); + m_data.Add(drec); } if (iswild) @@ -117,7 +117,7 @@ bool wxXmlResource::Load(const wxString& filemask) void wxXmlResource::AddHandler(wxXmlResourceHandler *handler) { - m_Handlers.Append(handler); + m_handlers.Append(handler); handler->SetParentResource(this); } @@ -125,7 +125,7 @@ void wxXmlResource::AddHandler(wxXmlResourceHandler *handler) void wxXmlResource::ClearHandlers() { - m_Handlers.Clear(); + m_handlers.Clear(); } @@ -259,20 +259,20 @@ void wxXmlResource::UpdateResources() wxFileSystem fsys; # endif - for (size_t i = 0; i < m_Data.GetCount(); i++) + for (size_t i = 0; i < m_data.GetCount(); i++) { - modif = (m_Data[i].Doc == NULL); + modif = (m_data[i].Doc == NULL); if (!modif) { # if wxUSE_FILESYSTEM - file = fsys.OpenFile(m_Data[i].File); - modif = file && file->GetModificationTime() > m_Data[i].Time; + file = fsys.OpenFile(m_data[i].File); + modif = file && file->GetModificationTime() > m_data[i].Time; if (!file) - wxLogError(_("Cannot open file '%s'."), m_Data[i].File.c_str()); + wxLogError(_("Cannot open file '%s'."), m_data[i].File.c_str()); wxDELETE(file); # else - modif = wxDateTime(wxFileModificationTime(m_Data[i].File)) > m_Data[i].Time; + modif = wxDateTime(wxFileModificationTime(m_data[i].File)) > m_data[i].Time; # endif } @@ -281,32 +281,32 @@ void wxXmlResource::UpdateResources() wxInputStream *stream = NULL; # if wxUSE_FILESYSTEM - file = fsys.OpenFile(m_Data[i].File); + file = fsys.OpenFile(m_data[i].File); if (file) stream = file->GetStream(); # else - stream = new wxFileInputStream(m_Data[i].File); + stream = new wxFileInputStream(m_data[i].File); # endif if (stream) { - delete m_Data[i].Doc; - m_Data[i].Doc = new wxXmlDocument; + delete m_data[i].Doc; + m_data[i].Doc = new wxXmlDocument; } - if (!stream || !m_Data[i].Doc->Load(*stream)) + if (!stream || !m_data[i].Doc->Load(*stream)) { - wxLogError(_("Cannot load resources from file '%s'."), m_Data[i].File.c_str()); - wxDELETE(m_Data[i].Doc); + wxLogError(_("Cannot load resources from file '%s'."), m_data[i].File.c_str()); + wxDELETE(m_data[i].Doc); } - else if (m_Data[i].Doc->GetRoot()->GetName() != wxT("resource")) + else if (m_data[i].Doc->GetRoot()->GetName() != wxT("resource")) { - wxLogError(_("Invalid XML resource '%s': doesn't have root node 'resource'."), m_Data[i].File.c_str()); - wxDELETE(m_Data[i].Doc); + wxLogError(_("Invalid XML resource '%s': doesn't have root node 'resource'."), m_data[i].File.c_str()); + wxDELETE(m_data[i].Doc); } else { - ProcessPlatformProperty(m_Data[i].Doc->GetRoot()); - m_Data[i].Time = file->GetModificationTime(); + ProcessPlatformProperty(m_data[i].Doc->GetRoot()); + m_data[i].Time = file->GetModificationTime(); } # if wxUSE_FILESYSTEM @@ -325,10 +325,10 @@ wxXmlNode *wxXmlResource::FindResource(const wxString& name, const wxString& cla UpdateResources(); //ensure everything is up-to-date wxString dummy; - for (size_t f = 0; f < m_Data.GetCount(); f++) + for (size_t f = 0; f < m_data.GetCount(); f++) { - if (m_Data[f].Doc == NULL || m_Data[f].Doc->GetRoot() == NULL) continue; - for (wxXmlNode *node = m_Data[f].Doc->GetRoot()->GetChildren(); + if (m_data[f].Doc == NULL || m_data[f].Doc->GetRoot() == NULL) continue; + for (wxXmlNode *node = m_data[f].Doc->GetRoot()->GetChildren(); node; node = node->GetNext()) if (node->GetType() == wxXML_ELEMENT_NODE && (!classname || @@ -338,7 +338,7 @@ wxXmlNode *wxXmlResource::FindResource(const wxString& name, const wxString& cla dummy == name) { #if wxUSE_FILESYSTEM - m_CurFileSystem.ChangePathTo(m_Data[f].File); + m_curFileSystem.ChangePathTo(m_data[f].File); #endif return node; } @@ -357,7 +357,7 @@ wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent, wx wxXmlResourceHandler *handler; wxObject *ret; - wxNode * ND = m_Handlers.GetFirst(); + wxNode * ND = m_handlers.GetFirst(); while (ND) { handler = (wxXmlResourceHandler*)ND->GetData(); @@ -384,32 +384,32 @@ wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent, wx wxXmlResourceHandler::wxXmlResourceHandler() - : m_Node(NULL), m_Parent(NULL), m_Instance(NULL), - m_ParentAsWindow(NULL), m_InstanceAsWindow(NULL) + : m_node(NULL), m_parent(NULL), m_instance(NULL), + m_parentAsWindow(NULL), m_instanceAsWindow(NULL) {} wxObject *wxXmlResourceHandler::CreateResource(wxXmlNode *node, wxObject *parent, wxObject *instance) { - wxXmlNode *myNode = m_Node; - wxString myClass = m_Class; - wxObject *myParent = m_Parent, *myInstance = m_Instance; - wxWindow *myParentAW = m_ParentAsWindow, *myInstanceAW = m_InstanceAsWindow; + wxXmlNode *myNode = m_node; + wxString myClass = m_class; + wxObject *myParent = m_parent, *myInstance = m_instance; + wxWindow *myParentAW = m_parentAsWindow, *myInstanceAW = m_instanceAsWindow; - m_Node = node; - m_Class = node->GetPropVal(wxT("class"), wxEmptyString); - m_Parent = parent; - m_Instance = instance; - m_ParentAsWindow = wxDynamicCast(m_Parent, wxWindow); - m_InstanceAsWindow = wxDynamicCast(m_Instance, wxWindow); + m_node = node; + m_class = node->GetPropVal(wxT("class"), wxEmptyString); + m_parent = parent; + m_instance = instance; + m_parentAsWindow = wxDynamicCast(m_parent, wxWindow); + m_instanceAsWindow = wxDynamicCast(m_instance, wxWindow); wxObject *returned = DoCreateResource(); - m_Node = myNode; - m_Class = myClass; - m_Parent = myParent; m_ParentAsWindow = myParentAW; - m_Instance = myInstance; m_InstanceAsWindow = myInstanceAW; + m_node = myNode; + m_class = myClass; + m_parent = myParent; m_parentAsWindow = myParentAW; + m_instance = myInstance; m_instanceAsWindow = myInstanceAW; return returned; } @@ -417,8 +417,8 @@ wxObject *wxXmlResourceHandler::CreateResource(wxXmlNode *node, wxObject *parent void wxXmlResourceHandler::AddStyle(const wxString& name, int value) { - m_StyleNames.Add(name); - m_StyleValues.Add(value); + m_styleNames.Add(name); + m_styleValues.Add(value); } @@ -456,9 +456,9 @@ int wxXmlResourceHandler::GetStyle(const wxString& param, int defaults) while (tkn.HasMoreTokens()) { fl = tkn.GetNextToken(); - index = m_StyleNames.Index(fl); + index = m_styleNames.Index(fl); if (index != wxNOT_FOUND) - style |= m_StyleValues[index]; + style |= m_styleValues[index]; else wxLogError(_("Unknown style flag ") + fl); } @@ -495,7 +495,7 @@ wxString wxXmlResourceHandler::GetText(const wxString& param) else str2 << *dt; } - if (m_Resource->GetUseLocale()) + if (m_resource->GetUseLocale()) return wxGetTranslation(str2); else return str2; @@ -543,7 +543,7 @@ int wxXmlResourceHandler::GetID() wxString wxXmlResourceHandler::GetName() { - return m_Node->GetPropVal(wxT("name"), wxT("-1")); + return m_node->GetPropVal(wxT("name"), wxT("-1")); } @@ -623,7 +623,7 @@ wxIcon wxXmlResourceHandler::GetIcon(const wxString& param, wxSize size) wxXmlNode *wxXmlResourceHandler::GetParamNode(const wxString& param) { - wxXmlNode *n = m_Node->GetChildren(); + wxXmlNode *n = m_node->GetChildren(); while (n) { @@ -656,7 +656,7 @@ wxString wxXmlResourceHandler::GetNodeContent(wxXmlNode *node) wxString wxXmlResourceHandler::GetParamValue(const wxString& param) { if (param.IsEmpty()) - return GetNodeContent(m_Node); + return GetNodeContent(m_node); else return GetNodeContent(GetParamNode(param)); } @@ -682,10 +682,10 @@ wxSize wxXmlResourceHandler::GetSize(const wxString& param) if (is_dlg) { - if (m_InstanceAsWindow) - return wxDLG_UNIT(m_InstanceAsWindow, wxSize(sx, sy)); - else if (m_ParentAsWindow) - return wxDLG_UNIT(m_ParentAsWindow, wxSize(sx, sy)); + if (m_instanceAsWindow) + return wxDLG_UNIT(m_instanceAsWindow, wxSize(sx, sy)); + else if (m_parentAsWindow) + return wxDLG_UNIT(m_parentAsWindow, wxSize(sx, sy)); else { wxLogError(_("Cannot convert dialog units: dialog unknown.")); @@ -723,10 +723,10 @@ wxCoord wxXmlResourceHandler::GetDimension(const wxString& param, wxCoord defaul if (is_dlg) { - if (m_InstanceAsWindow) - return wxDLG_UNIT(m_InstanceAsWindow, wxSize(sx, 0)).x; - else if (m_ParentAsWindow) - return wxDLG_UNIT(m_ParentAsWindow, wxSize(sx, 0)).x; + if (m_instanceAsWindow) + return wxDLG_UNIT(m_instanceAsWindow, 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.")); @@ -747,8 +747,8 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param) return wxNullFont; } - wxXmlNode *oldnode = m_Node; - m_Node = font_node; + wxXmlNode *oldnode = m_node; + m_node = font_node; long size = GetLong(wxT("size"), 12); @@ -791,7 +791,7 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param) } } - m_Node = oldnode; + m_node = oldnode; wxFont font(size, ifamily, istyle, iweight, underlined, facename, enc); return font; @@ -825,7 +825,7 @@ void wxXmlResourceHandler::SetupWindow(wxWindow *wnd) void wxXmlResourceHandler::CreateChildren(wxObject *parent, bool this_hnd_only) { - wxXmlNode *n = m_Node->GetChildren(); + wxXmlNode *n = m_node->GetChildren(); while (n) { @@ -835,7 +835,7 @@ void wxXmlResourceHandler::CreateChildren(wxObject *parent, bool this_hnd_only) if (this_hnd_only && CanHandle(n)) CreateResource(n, parent, NULL); else - m_Resource->CreateResFromNode(n, parent, NULL); + m_resource->CreateResFromNode(n, parent, NULL); } n = n->GetNext(); } @@ -845,7 +845,7 @@ void wxXmlResourceHandler::CreateChildren(wxObject *parent, bool this_hnd_only) void wxXmlResourceHandler::CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode) { wxXmlNode *root; - if (rootnode == NULL) root = m_Node; else root = rootnode; + if (rootnode == NULL) root = m_node; else root = rootnode; wxXmlNode *n = root->GetChildren(); while (n) diff --git a/contrib/src/xml/xmlwrite.cpp b/contrib/src/xml/xmlwrite.cpp new file mode 100644 index 0000000000..51cdfaf04a --- /dev/null +++ b/contrib/src/xml/xmlwrite.cpp @@ -0,0 +1,152 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xmlwrite.cpp +// Purpose: wxXmlDocument - XML text writer +// Author: Vaclav Slavik +// Created: 2001/04/30 +// RCS-ID: $Id$ +// Copyright: (c) 2001 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +// nothing - already in xml.cpp +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/wfstream.h" +#include "wx/intl.h" +#include "wx/log.h" +#include "wx/strconv.h" +#include "wx/xml/xml.h" +#include "wx/xml/xmlio.h" + +// write string to output: +inline static void OutputString(wxOutputStream& stream, const wxString& str) +{ + if (str.IsEmpty()) return; +#if wxUSE_UNICODE + char *buf = str.mb_str(wxMBConvUTF8); + stream.Write(buf, strlen(buf)); +#else + stream.Write(str.mb_str(), str.Len()); +#endif +} + +// Same as above, but create entities first. +// Translates '<' to "<", '>' to ">" and '&' to "&" +static void OutputStringEnt(wxOutputStream& stream, const wxString& str) +{ + wxString buf; + size_t i, last, len; + char c; + + len = str.Len(); + last = 0; + for (i = 0; i < len; i++) + { + c = str.GetChar(i); + if (c == '<' || c == '>' || + (c == '&' && str.Mid(i+1, 4) != wxT("amp;"))) + { + OutputString(stream, str.Mid(last, i - last)); + switch (c) + { + case '<': OutputString(stream, wxT("<")); break; + case '>': OutputString(stream, wxT(">")); break; + case '&': OutputString(stream, wxT("&")); break; + default: break; + } + last = i + 1; + } + } + OutputString(stream, str.Mid(last, i - last)); +} + +inline static void OutputIndentation(wxOutputStream& stream, int indent) +{ + wxString str = wxT("\n"); + for (int i = 0; i < indent; i++) + str << wxT(' ') << wxT(' '); + OutputString(stream, str); +} + +static void OutputNode(wxOutputStream& stream, wxXmlNode *node, int indent) +{ + wxXmlNode *n, *prev; + wxXmlProperty *prop; + + switch (node->GetType()) + { + case wxXML_TEXT_NODE: + OutputStringEnt(stream, node->GetContent()); + break; + + case wxXML_ELEMENT_NODE: + OutputString(stream, wxT("<")); + OutputString(stream, node->GetName()); + + prop = node->GetProperties(); + while (prop) + { + OutputString(stream, wxT(" ") + prop->GetName() + + wxT("=\"") + prop->GetValue() + wxT("\"")); + // FIXME - what if prop contains '"'? + prop = prop->GetNext(); + } + + if (node->GetChildren()) + { + OutputString(stream, wxT(">")); + prev = NULL; + n = node->GetChildren(); + while (n) + { + if (n && n->GetType() != wxXML_TEXT_NODE) + OutputIndentation(stream, indent + 1); + OutputNode(stream, n, indent + 1); + prev = n; + n = n->GetNext(); + } + if (prev && prev->GetType() != wxXML_TEXT_NODE) + OutputIndentation(stream, indent); + OutputString(stream, wxT("GetName()); + OutputString(stream, wxT(">")); + } + else + OutputString(stream, wxT("/>")); + break; + + case wxXML_COMMENT_NODE: + OutputString(stream, wxT("")); + break; + + default: + wxFAIL_MSG(wxT("unsupported node type")); + } +} + +bool wxXmlIOHandlerWriter::Save(wxOutputStream& stream, const wxXmlDocument& doc) +{ + if (!doc.IsOk()) + return FALSE; + + wxString s; + + s = wxT("\n"); + OutputString(stream, s); + + OutputNode(stream, doc.GetRoot(), 0); + OutputString(stream, wxT("\n")); + + return TRUE; +} -- 2.45.2