]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/xml/xh_toolb.cpp
87c4d2eb69fbdf3017c1d7586ea3e285290c64b7
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XML resource for wxBoxSizer
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2000 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "xh_toolb.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
22 #include "wx/xml/xh_toolb.h"
23 #include "wx/toolbar.h"
28 wxToolBarXmlHandler::wxToolBarXmlHandler()
29 : wxXmlResourceHandler(), m_IsInside(FALSE
), m_Toolbar(NULL
)
32 ADD_STYLE(wxTB_DOCKABLE
);
33 ADD_STYLE(wxTB_VERTICAL
);
34 ADD_STYLE(wxTB_HORIZONTAL
);
39 wxObject
*wxToolBarXmlHandler::DoCreateResource()
41 if (m_Class
== wxT("tool"))
43 wxCHECK_MSG(m_Toolbar
, NULL
, wxT("Incorrect syntax of XML resource: tool not within a toolbar!"));
44 m_Toolbar
->AddTool(GetID(),
45 GetBitmap(wxT("bitmap")),
46 GetBitmap(wxT("bitmap2")),
47 GetBool(wxT("toggle")),
51 GetText(wxT("tooltip")),
52 GetText(wxT("longhelp")));
53 return m_Toolbar
; // must return non-NULL
56 else if (m_Class
== wxT("separator"))
58 wxCHECK_MSG(m_Toolbar
, NULL
, wxT("Incorrect syntax of XML resource: separator not within a toolbar!"));
59 m_Toolbar
->AddSeparator();
60 return m_Toolbar
; // must return non-NULL
63 else /*<object class="wxToolBar">*/
65 int style
= GetStyle(wxT("style"), wxNO_BORDER
| wxTB_HORIZONTAL
);
67 if (!(style
& wxNO_BORDER
)) style
|= wxNO_BORDER
;
69 wxToolBar
*toolbar
= new wxToolBar(m_ParentAsWindow
,
76 wxSize bmpsize
= GetSize(wxT("bitmapsize"));
77 if (!(bmpsize
== wxDefaultSize
))
78 toolbar
->SetToolBitmapSize(bmpsize
);
79 wxSize margins
= GetSize(wxT("margins"));
80 if (!(margins
== wxDefaultSize
))
81 toolbar
->SetMargins(margins
.x
, margins
.y
);
82 long packing
= GetLong(wxT("packing"), -1);
84 toolbar
->SetToolPacking(packing
);
85 long separation
= GetLong(wxT("separation"), -1);
87 toolbar
->SetToolSeparation(separation
);
89 wxXmlNode
*children_node
= GetParamNode(wxT("object"));
90 if (children_node
== NULL
) return toolbar
;
95 wxXmlNode
*n
= children_node
;
99 if (n
->GetType() == wxXML_ELEMENT_NODE
&&
100 n
->GetName() == wxT("object"))
102 wxObject
*created
= CreateResFromNode(n
, toolbar
, NULL
);
103 wxControl
*control
= wxDynamicCast(created
, wxControl
);
104 if (IsOfClass(n
, wxT("tool")) &&
105 IsOfClass(n
, wxT("separator")) &&
107 toolbar
->AddControl(control
);
122 bool wxToolBarXmlHandler::CanHandle(wxXmlNode
*node
)
124 return ((!m_IsInside
&& IsOfClass(node
, wxT("wxToolBar"))) ||
125 (m_IsInside
&& IsOfClass(node
, wxT("tool"))) ||
126 (m_IsInside
&& IsOfClass(node
, wxT("separator"))));