--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: xh_toolb.h
+// Purpose: XML resource handler for wxBoxSizer
+// Author: Vaclav Slavik
+// Created: 2000/08/11
+// RCS-ID: $Id$
+// Copyright: (c) 2000 Vaclav Slavik
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_XH_TOOLB_H_
+#define _WX_XH_TOOLB_H_
+
+#ifdef __GNUG__
+#pragma interface "xh_toolb.h"
+#endif
+
+#include "wx/xml/xmlres.h"
+
+#if wxUSE_TOOLBAR
+
+class WXDLLEXPORT wxToolBar;
+
+class WXDLLEXPORT wxToolBarXmlHandler : public wxXmlResourceHandler
+{
+ public:
+ wxToolBarXmlHandler();
+ virtual wxObject *DoCreateResource();
+ virtual bool CanHandle(wxXmlNode *node);
+
+ private:
+ bool m_IsInside;
+ wxToolBar *m_Toolbar;
+};
+
+#endif
+
+#endif // _WX_XH_TOOLBAR_H_
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 \
- xh_sttxt.h xh_text.h xh_listb.h xml.h xmlio.h xmlres.h
+ xh_sttxt.h xh_text.h xh_listb.h xml.h xmlio.h xmlres.h xh_toolb.h
OBJECTS=xml.o xmlbin.o xmlbinz.o xmlpars.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_text.o xh_listb.o xh_toolb.o \
APPEXTRADEFS=-I$(top_srcdir)/contrib/include
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: xh_toolb.cpp
+// Purpose: XML resource for wxBoxSizer
+// Author: Vaclav Slavik
+// Created: 2000/08/11
+// RCS-ID: $Id$
+// Copyright: (c) 2000 Vaclav Slavik
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "xh_toolb.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#include "wx/xml/xh_toolb.h"
+#include "wx/toolbar.h"
+
+
+#if wxUSE_TOOLBAR
+
+wxToolBarXmlHandler::wxToolBarXmlHandler()
+: wxXmlResourceHandler(), m_IsInside(FALSE), m_Toolbar(NULL)
+{
+ ADD_STYLE(wxTB_FLAT);
+ ADD_STYLE(wxTB_DOCKABLE);
+ ADD_STYLE(wxTB_VERTICAL);
+ ADD_STYLE(wxTB_HORIZONTAL);
+}
+
+
+
+wxObject *wxToolBarXmlHandler::DoCreateResource()
+{
+ if (m_Node->GetName() == _T("tool"))
+ {
+ wxCHECK_MSG(m_Toolbar, NULL, _T("Incorrect syntax of XML resource: tool not within a toolbar!"));
+ m_Toolbar->AddTool(GetID(),
+ GetBitmap(_T("bitmap")),
+ GetBitmap(_T("bitmap2")),
+ GetBool(_T("toggle")),
+ GetPosition().x,
+ GetPosition().y,
+ NULL,
+ GetText(_T("tooltip")),
+ GetText(_T("longhelp")));
+ return m_Toolbar; // must return non-NULL
+ }
+
+ else if (m_Node->GetName() == _T("separator"))
+ {
+ wxCHECK_MSG(m_Toolbar, NULL, _T("Incorrect syntax of XML resource: separator not within a toolbar!"));
+ m_Toolbar->AddSeparator();
+ return m_Toolbar; // must return non-NULL
+ }
+
+ else /*<toolbar>*/
+ {
+ wxToolBar *toolbar = new wxToolBar(m_ParentAsWindow,
+ GetID(),
+ GetPosition(),
+ GetSize(),
+ GetStyle(),
+ GetName());
+
+ wxSize bmpsize = GetSize(_T("bitmapsize"));
+ if (!(bmpsize == wxDefaultSize))
+ toolbar->SetToolBitmapSize(bmpsize);
+ wxSize margins = GetSize(_T("margins"));
+ if (!(margins == wxDefaultSize))
+ toolbar->SetMargins(margins.x, margins.y);
+ long packing = GetLong(_T("packing"), -1);
+ if (packing != -1)
+ toolbar->SetToolPacking(packing);
+ long separation = GetLong(_T("separation"), -1);
+ if (separation != -1)
+ toolbar->SetToolSeparation(separation);
+
+
+ wxXmlNode *children_node = GetParamNode(_T("children"));
+ if (children_node == NULL) return toolbar;
+
+ m_IsInside = TRUE;
+ m_Toolbar = toolbar;
+
+ wxXmlNode *n = children_node->GetChildren();
+
+ while (n)
+ {
+ if (n->GetType() == wxXML_ELEMENT_NODE)
+ {
+ wxObject *created = CreateResFromNode(n, toolbar, NULL);
+ wxControl *control = wxDynamicCast(created, wxControl);
+ if (n->GetName() != _T("tool") &&
+ n->GetName() != _T("separator") &&
+ control != NULL)
+ toolbar->AddControl(control);
+ }
+ n = n->GetNext();
+ }
+
+ m_IsInside = FALSE;
+ m_Toolbar = NULL;
+
+ toolbar->Realize();
+ return toolbar;
+ }
+}
+
+
+
+bool wxToolBarXmlHandler::CanHandle(wxXmlNode *node)
+{
+ return ((!m_IsInside && node->GetName() == _T("toolbar")) ||
+ (m_IsInside && node->GetName() == _T("tool")) ||
+ (m_IsInside && node->GetName() == _T("separator")));
+}
+
+#endif