]> git.saurik.com Git - wxWidgets.git/commitdiff
added toolbar handling
authorVáclav Slavík <vslavik@fastmail.fm>
Fri, 11 Aug 2000 19:10:39 +0000 (19:10 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Fri, 11 Aug 2000 19:10:39 +0000 (19:10 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8034 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

13 files changed:
contrib/include/wx/xml/xh_all.h
contrib/include/wx/xml/xh_toolb.h [new file with mode: 0644]
contrib/src/xml/Makefile.in
contrib/src/xml/makefile.b32
contrib/src/xml/makefile.g95
contrib/src/xml/makefile.vc
contrib/src/xml/makefile.wat
contrib/src/xml/wxXMLVC.dsp
contrib/src/xml/xh_toolb.cpp [new file with mode: 0644]
contrib/src/xml/xmlrsall.cpp
contrib/utils/wxrcedit/df/separator.df
contrib/utils/wxrcedit/df/tool.df [new file with mode: 0644]
contrib/utils/wxrcedit/df/toolbar.df [new file with mode: 0644]

index 59b6f362de6ed96e81bc1a139ed1ee1e2f387e08..a46213b43478c76b8f8deee21d0c6d1ddf5a1201 100644 (file)
@@ -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 (file)
index 0000000..db79997
--- /dev/null
@@ -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_
index c893889804853de6bbe41732c351bc6084e5691d..5ce54915cf7e7e944660d22b708ba677c6caf389 100644 (file)
@@ -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
 
index e36bbc6cbbc12c46eac6eb486692a23607ad436a..2da7a2742870dcd29a6b73a449e6149c1b69e6df 100644 (file)
@@ -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
 
index 6c85194de78fae8d1c28adfc00d0c5c3ad6f66da..4b1e1a64d717e1c38acdbfbb4c29eb9ed74e62f5 100644 (file)
@@ -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
 
index e3efd284244ecb9c30142dd072c91bc34a464280..bc8b3e3eb5be0e8c11de76c88890f80fa38f5ace 100644 (file)
@@ -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
 
index d321dac6de19897980d5d65fbd28ea97321bf3f9..883e948eec13fdd8e8d32ace5f0404ff5470fd9a 100644 (file)
@@ -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)
index ad219f5493786534557ecf8388fb62a5ded47926..ac16ed5c16d9e83cfb93bb1feaf7f9bfdb721a77 100644 (file)
@@ -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 (file)
index 0000000..d4c2887
--- /dev/null
@@ -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 /*<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
index 5e5bda02e41ca8907df8e991ac2537b46d9e8ddf..19312097e9119a4c9bd2107eb149acc2f0c75872 100644 (file)
@@ -66,4 +66,7 @@ void wxXmlResource::InitAllHandlers()
 #if wxUSE_LISTBOX
     AddHandler(new wxListBoxXmlHandler);
 #endif
+#if wxUSE_TOOLBAR
+    AddHandler(new wxToolBarXmlHandler);
+#endif
 }
index ea5458db9a5e28a5fa47468c93abd78f42e2e7e4..d655861352b3d27eef01191084b46f59f3002cba 100644 (file)
@@ -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 (file)
index 0000000..9d4940e
--- /dev/null
@@ -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 (file)
index 0000000..0a8dbd9
--- /dev/null
@@ -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