added toolbar handling
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8034 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
792064e93f
commit
8576d6a454
@ -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_
|
||||
|
38
contrib/include/wx/xml/xh_toolb.h
Normal file
38
contrib/include/wx/xml/xh_toolb.h
Normal file
@ -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_
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
125
contrib/src/xml/xh_toolb.cpp
Normal file
125
contrib/src/xml/xh_toolb.cpp
Normal file
@ -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
|
@ -66,4 +66,7 @@ void wxXmlResource::InitAllHandlers()
|
||||
#if wxUSE_LISTBOX
|
||||
AddHandler(new wxListBoxXmlHandler);
|
||||
#endif
|
||||
#if wxUSE_TOOLBAR
|
||||
AddHandler(new wxToolBarXmlHandler);
|
||||
#endif
|
||||
}
|
||||
|
@ -2,3 +2,4 @@ node separator
|
||||
icon 0
|
||||
type normal
|
||||
derived from menu_item
|
||||
derived from toolbar_item
|
||||
|
10
contrib/utils/wxrcedit/df/tool.df
Normal file
10
contrib/utils/wxrcedit/df/tool.df
Normal file
@ -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
|
11
contrib/utils/wxrcedit/df/toolbar.df
Normal file
11
contrib/utils/wxrcedit/df/toolbar.df
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user