From: Václav Slavík Date: Fri, 11 Aug 2000 19:10:39 +0000 (+0000) Subject: added toolbar handling X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/8576d6a4546855a1358c84e45e1bc4f1bc39e496 added toolbar handling git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8034 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/contrib/include/wx/xml/xh_all.h b/contrib/include/wx/xml/xh_all.h index 59b6f362de..a46213b434 100644 --- a/contrib/include/wx/xml/xh_all.h +++ b/contrib/include/wx/xml/xh_all.h @@ -34,5 +34,6 @@ #include "wx/xml/xh_notbk.h" #include "wx/xml/xh_text.h" #include "wx/xml/xh_listb.h" +#include "wx/xml/xh_toolb.h" #endif // _WX_XMLRES_H_ diff --git a/contrib/include/wx/xml/xh_toolb.h b/contrib/include/wx/xml/xh_toolb.h new file mode 100644 index 0000000000..db79997ef2 --- /dev/null +++ b/contrib/include/wx/xml/xh_toolb.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////// +// 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_ diff --git a/contrib/src/xml/Makefile.in b/contrib/src/xml/Makefile.in index c893889804..5ce54915cf 100644 --- a/contrib/src/xml/Makefile.in +++ b/contrib/src/xml/Makefile.in @@ -16,14 +16,14 @@ HEADER_SUBDIR=xml 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 diff --git a/contrib/src/xml/makefile.b32 b/contrib/src/xml/makefile.b32 index e36bbc6cbb..2da7a27428 100644 --- a/contrib/src/xml/makefile.b32 +++ b/contrib/src/xml/makefile.b32 @@ -17,7 +17,7 @@ OBJECTS=xml.obj xmlbin.obj xmlbinz.obj xmlpars.obj xmlres.obj xmlrsall.obj \ xh_bttn.obj xh_chckb.obj xh_chckl.obj xh_choic.obj xh_combo.obj xh_dlg.obj \ xh_gauge.obj xh_html.obj xh_menu.obj xh_notbk.obj xh_panel.obj xh_radbt.obj \ xh_radbx.obj xh_sizer.obj xh_slidr.obj xh_spin.obj xh_stbmp.obj xh_sttxt.obj \ - xh_text.obj xh_listb.obj + xh_text.obj xh_listb.obj xh_toolb.obj !include $(WXDIR)\src\makelib.b32 diff --git a/contrib/src/xml/makefile.g95 b/contrib/src/xml/makefile.g95 index 6c85194de7..4b1e1a64d7 100644 --- a/contrib/src/xml/makefile.g95 +++ b/contrib/src/xml/makefile.g95 @@ -16,7 +16,7 @@ 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 include $(WXDIR)/src/makelib.g95 diff --git a/contrib/src/xml/makefile.vc b/contrib/src/xml/makefile.vc index e3efd28424..bc8b3e3eb5 100644 --- a/contrib/src/xml/makefile.vc +++ b/contrib/src/xml/makefile.vc @@ -37,7 +37,7 @@ OBJECTS=$(D)\xml.obj $(D)\xmlbin.obj $(D)\xmlbinz.obj $(D)\xmlpars.obj $(D)\xmlr $(D)\xh_bttn.obj $(D)\xh_chckb.obj $(D)\xh_chckl.obj $(D)\xh_choic.obj $(D)\xh_combo.obj $(D)\xh_dlg.obj \ $(D)\xh_gauge.obj $(D)\xh_html.obj $(D)\xh_menu.obj $(D)\xh_notbk.obj $(D)\xh_panel.obj $(D)\xh_radbt.obj \ $(D)\xh_radbx.obj $(D)\xh_sizer.obj $(D)\xh_slidr.obj $(D)\xh_spin.obj $(D)\xh_stbmp.obj $(D)\xh_sttxt.obj \ - $(D)\xh_text.obj $(D)\xh_listb.obj + $(D)\xh_text.obj $(D)\xh_listb.obj $(D)\xh_toolb.obj !include $(WXDIR)\src\makelib.vc diff --git a/contrib/src/xml/makefile.wat b/contrib/src/xml/makefile.wat index d321dac6de..883e948eec 100644 --- a/contrib/src/xml/makefile.wat +++ b/contrib/src/xml/makefile.wat @@ -16,7 +16,7 @@ OBJECTS=xml.obj xmlbin.obj xmlbinz.obj xmlpars.obj xmlres.obj xmlrsall.obj & xh_bttn.obj xh_chckb.obj xh_chckl.obj xh_choic.obj xh_combo.obj xh_dlg.obj & xh_gauge.obj xh_html.obj xh_menu.obj xh_notbk.obj xh_panel.obj xh_radbt.obj & xh_radbx.obj xh_sizer.obj xh_slidr.obj xh_spin.obj xh_stbmp.obj xh_sttxt.obj & - xh_text.obj xh_listb.obj + xh_text.obj xh_listb.obj xh_toolb.obj all: $(WXXMLLIB) diff --git a/contrib/src/xml/wxXMLVC.dsp b/contrib/src/xml/wxXMLVC.dsp index ad219f5493..ac16ed5c16 100644 --- a/contrib/src/xml/wxXMLVC.dsp +++ b/contrib/src/xml/wxXMLVC.dsp @@ -164,6 +164,10 @@ SOURCE=.\xh_listb.cpp # End Source File # Begin Source File +SOURCE=.\xh_toolb.cpp +# End Source File +# Begin Source File + SOURCE=.\xml.cpp # End Source File # Begin Source File diff --git a/contrib/src/xml/xh_toolb.cpp b/contrib/src/xml/xh_toolb.cpp new file mode 100644 index 0000000000..d4c2887621 --- /dev/null +++ b/contrib/src/xml/xh_toolb.cpp @@ -0,0 +1,125 @@ +///////////////////////////////////////////////////////////////////////////// +// 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 /**/ + { + 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 diff --git a/contrib/src/xml/xmlrsall.cpp b/contrib/src/xml/xmlrsall.cpp index 5e5bda02e4..19312097e9 100644 --- a/contrib/src/xml/xmlrsall.cpp +++ b/contrib/src/xml/xmlrsall.cpp @@ -66,4 +66,7 @@ void wxXmlResource::InitAllHandlers() #if wxUSE_LISTBOX AddHandler(new wxListBoxXmlHandler); #endif +#if wxUSE_TOOLBAR + AddHandler(new wxToolBarXmlHandler); +#endif } diff --git a/contrib/utils/wxrcedit/df/separator.df b/contrib/utils/wxrcedit/df/separator.df index ea5458db9a..d655861352 100644 --- a/contrib/utils/wxrcedit/df/separator.df +++ b/contrib/utils/wxrcedit/df/separator.df @@ -2,3 +2,4 @@ node separator icon 0 type normal derived from menu_item +derived from toolbar_item diff --git a/contrib/utils/wxrcedit/df/tool.df b/contrib/utils/wxrcedit/df/tool.df new file mode 100644 index 0000000000..9d4940ec7f --- /dev/null +++ b/contrib/utils/wxrcedit/df/tool.df @@ -0,0 +1,10 @@ +node tool +type normal +icon 0 +var bitmap of text +var bitmap2 of text +var toggle of bool +var pos of coord +var tooltip of text +var longhelp of text +derived from toolbar_item \ No newline at end of file diff --git a/contrib/utils/wxrcedit/df/toolbar.df b/contrib/utils/wxrcedit/df/toolbar.df new file mode 100644 index 0000000000..0a8dbd919a --- /dev/null +++ b/contrib/utils/wxrcedit/df/toolbar.df @@ -0,0 +1,11 @@ +node toolbar +type panel +icon 0 +childtype toolbar_item +var style of flags wxTB_FLAT,wxTB_DOCKABLE,wxTB_VERTICAL,wxTB_HORIZONTAL +var bitmapsize of coord +var pos of coord +var size of coord +var margins of coord +var packing of integer +var separation of integer