added WebWidgets

This commit is contained in:
Peter Schojer
2008-05-12 13:12:39 +00:00
parent 9661e08347
commit 6c80fe82c1
577 changed files with 34601 additions and 10 deletions

View File

@@ -0,0 +1,57 @@
//
// AbstractTableCellHandler.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/AbstractTableCellHandler.cpp#1 $
//
// Library: ExtJS
// Package: Core
// Module: AbstractTableCellHandler
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/AbstractTableCellHandler.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
AbstractTableCellHandler::AbstractTableCellHandler(bool editor, bool renderer):
_editor(editor),
_renderer(renderer)
{
}
AbstractTableCellHandler::~AbstractTableCellHandler()
{
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,109 @@
//
// ButtonCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/ButtonCellRenderer.cpp#8 $
//
// Library: ExtJS
// Package: Core
// Module: ButtonCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/ButtonCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/ButtonCell.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
ButtonCellRenderer::ButtonCellRenderer()
{
}
ButtonCellRenderer::~ButtonCellRenderer()
{
}
void ButtonCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
const ButtonCell* pButtonCell = static_cast<const Poco::WebWidgets::ButtonCell*>(pRenderable);
std::string content = "'" + Utility::safe(pButtonCell->getString()) + "'";
ButtonCellRenderer::renderButton(pButtonCell, content, true, false,ostr);
}
void ButtonCellRenderer::renderCell(const Cell* pCell, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pCell != 0);
const ButtonCell* pButtonCell = static_cast<const Poco::WebWidgets::ButtonCell*>(pCell);
// is now a variable name
ButtonCellRenderer::renderButton(pButtonCell, "val", false, false, ostr);
}
void ButtonCellRenderer::renderProperties(const ButtonCell* pButtonCell, const std::string& content, bool writeId, bool submitButton, std::ostream& ostr, bool showText)
{
if (showText && !content.empty())
ostr << "text:" << content << ",";
if (submitButton)
{
ostr << "type:'submit',";
Form::Ptr pForm = Utility::insideForm(pButtonCell);
//ostr << "handler: function(){Ext.getCmp('" << pForm->id() << "').getForm().submit({url:'" << pForm->getURI().toString() << "',waitMsg:'Loading'});},";
ostr << "handler: function(){Ext.getCmp('" << pForm->id() << "').getForm().submit();},";
}
Utility::writeCellProperties(pButtonCell, ostr, writeId);
std::string toolTip(pButtonCell->getToolTip());
if (!toolTip.empty())
ostr << ",tooltip:'" << Utility::safe(toolTip) << "'";
}
void ButtonCellRenderer::renderButton(const ButtonCell* pCell, const std::string& content, bool writeId, bool submitButton, std::ostream& ostr, bool showText)
{
ostr << "new Ext.Button({";
ButtonCellRenderer::renderProperties(pCell, content, writeId, submitButton, ostr);
ostr << "})";
}
void ButtonCellRenderer::writeConfigData(const Cell* pCell, const RenderContext& context, std::ostream& ostr)
{
ostr << "'" << Utility::safe(pCell->getString()) << "'";
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,191 @@
//
// CellInitializer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/CellInitializer.cpp#3 $
//
// Library: ExtJS
// Package: Core
// Module: CellInitializer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/CellInitializer.h"
#include "Poco/WebWidgets/ExtJS/AbstractTableCellHandler.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/ToggleButtonCell.h"
#include "Poco/WebWidgets/CheckButtonCell.h"
#include "Poco/WebWidgets/TextEditCell.h"
#include "Poco/WebWidgets/TextFieldCell.h"
#include "Poco/WebWidgets/ComboBoxCell.h"
#include "Poco/WebWidgets/ButtonCell.h"
#include "Poco/NumberFormatter.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
void cellInitializer(const Cell* pCell, AbstractTableCellHandler* pHandler)
{
//don't support label for cell, keep this separate
pHandler->addFixed("hideLabel", "true");
if (!pCell->isEnabled())
pHandler->addFixed("disabled", "true");
View* pOwner = pCell->getOwner();
if (pOwner)
{
if (pOwner->getWidth() > 0)
pHandler->addFixed("width", Poco::NumberFormatter::format(pOwner->getWidth()));
if (pOwner->getHeight() > 0)
pHandler->addFixed("height", Poco::NumberFormatter::format(pOwner->getHeight()));
/* if (!pOwner->getName().empty())
pHandler->addFixed("name", "'"+pOwner->getName()+"'"); */
}
}
void cellInitializer(const ToggleButtonCell* pToggleButtonCell, AbstractTableCellHandler* pHandler)
{
if (!pToggleButtonCell->getLabel().empty())
pHandler->addFixed("boxLabel", "'" + Utility::safe(pToggleButtonCell->getLabel()) + "'");
// renderer is always readonly
pHandler->addFixed("disabled", "true");
//tooltip is not supported by togglebutton
std::string tooltip (pToggleButtonCell->getToolTip());
if (!tooltip.empty())
{
std::string fct("{render:function(c){c.getEl().dom.qtip='");
fct.append(Utility::safe(tooltip));
fct.append("'; c.getEl().dom.qclass = 'x-form-tip';}}");
pHandler->addFixed("listeners", fct);
}
const Cell* pCell = pToggleButtonCell;
cellInitializer(pCell, pHandler);
}
void cellInitializer(const CheckButtonCell* pCell, AbstractTableCellHandler* pHandler)
{
const ToggleButtonCell* pToggleButtonCell = pCell;
cellInitializer(pToggleButtonCell, pHandler);
}
void cellInitializer(const TextEditCell* pCell, AbstractTableCellHandler* pHandler)
{
cellInitializer(static_cast<const Cell*>(pCell), pHandler);
if (!pCell->isEditable())
pHandler->addFixed("readOnly", "true");
if (pCell->getHeightInPixel() > 0)
pHandler->addFixed("height", Poco::NumberFormatter::format(pCell->getHeightInPixel()));
if (pCell->getGrow())
pHandler->addFixed("grow","true");
if (!pCell->getPlaceHolder().empty())
pHandler->addFixed("emptyText", "'" + Utility::safe(pCell->getPlaceHolder()) + "'");
//tooltip is not supported by textEdit, add listeners
std::string tooltip (pCell->getToolTip());
if (!tooltip.empty())
{
std::string fct("{render: function(c) {Ext.QuickTips.register({target: c.getEl(),text: '");
fct.append(Utility::safe(tooltip));
fct.append("'});}}");
pHandler->addFixed("listeners", fct);
}
}
void cellInitializer(const TextFieldCell* pCell, AbstractTableCellHandler* pHandler)
{
cellInitializer(static_cast<const Cell*>(pCell), pHandler);
if (!pCell->isEditable())
pHandler->addFixed("readOnly", "true");
if (pCell->getMaxLength() > 0)
pHandler->addFixed("maxLength", Poco::NumberFormatter::format(pCell->getMaxLength()));
if (!pCell->getPlaceHolder().empty())
pHandler->addFixed("emptyText", "'" + Utility::safe(pCell->getPlaceHolder()) + "'");
//tooltip is not supported by textEdit, add listeners
std::string tooltip (pCell->getToolTip());
if (!tooltip.empty())
{
std::string fct("{render: function(c) {Ext.QuickTips.register({target: c.getEl(),text: '");
fct.append(Utility::safe(tooltip));
fct.append("'});}}");
pHandler->addFixed("listeners", fct);
}
}
void cellInitializer(const ComboBoxCell* pCell, AbstractTableCellHandler* pHandler)
{
cellInitializer(static_cast<const TextFieldCell*>(pCell), pHandler);
std::string store("new Ext.data.SimpleStore({fields:['d'], data:[");
//now serialize data
std::vector<Any>::const_iterator it = pCell->begin();
std::vector<Any>::const_iterator itEnd = pCell->end();
Formatter::Ptr ptrFormatter = pCell->getFormatter();
for (; it != itEnd; ++it)
{
if (it != pCell->begin())
store.append(",");
store.append("['");
if (ptrFormatter)
store.append(ptrFormatter->format(*it));
else
store.append(RefAnyCast<std::string>(*it));
store.append("']");
}
store.append("]})");
pHandler->addFixed("store", store);
pHandler->addFixed("displayField", "'d'");
pHandler->addFixed("typeAhead","true");
pHandler->addFixed("mode", "'local'");
pHandler->addFixed("triggerAction","'all'");
}
void cellInitializer(const ButtonCell* pCell, AbstractTableCellHandler* pHandler)
{
cellInitializer(static_cast<const Cell*>(pCell), pHandler);
std::string toolTip(pCell->getToolTip());
if (!toolTip.empty())
pHandler->addFixed("tooltip:", "'" + Utility::safe(toolTip) + "'");
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,59 @@
//
// CellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/DateFieldCelllRenderer.cpp#3 $
//
// Library: ExtJS
// Package: Core
// Module: CellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/CellRenderer.h"
#include "Poco/WebWidgets/ExtJS/TextFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/Cell.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
CellRenderer::CellRenderer()
{
}
CellRenderer::~CellRenderer()
{
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,72 @@
//
// CheckButtonCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/CheckButtonCellRenderer.cpp#2 $
//
// Library: ExtJS
// Package: Core
// Module: CheckButtonCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/CheckButtonCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/CheckButtonCell.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
CheckButtonCellRenderer::CheckButtonCellRenderer()
{
}
CheckButtonCellRenderer::~CheckButtonCellRenderer()
{
}
void CheckButtonCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::CheckButtonCell));
const CheckButtonCell* pCheckButtonCell = static_cast<const Poco::WebWidgets::CheckButtonCell*>(pRenderable);
ostr << "new Ext.form.Checkbox({";
ToggleButtonCellRenderer::renderProperties(pCheckButtonCell, ostr);
ostr << "})";
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,64 @@
//
// CollapsibleRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/CollapsibleRenderer.cpp#1 $
//
// Library: ExtJS
// Package: Core
// Module: CollapsibleRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/CollapsibleRenderer.h"
#include "Poco/WebWidgets/Collapsible.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
CollapsibleRenderer::CollapsibleRenderer()
{
}
CollapsibleRenderer::~CollapsibleRenderer()
{
}
void CollapsibleRenderer::writeProperties(const Frame* pFrame, std::ostream& ostr)
{
const Collapsible* pC = static_cast<const Collapsible*>(pFrame);
FrameRenderer::writeProperties(pFrame, ostr);
ostr << ",collapsible:true,titleCollapse:true, header:true,collapsed:" << (pC->getCollapse()?"true":"false");
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,93 @@
//
// ComboBoxCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/ComboBoxCellRenderer.cpp#3 $
//
// Library: ExtJS
// Package: Core
// Module: ComboBoxCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/ComboBoxCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/TextFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/ComboBoxCell.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
ComboBoxCellRenderer::ComboBoxCellRenderer()
{
}
ComboBoxCellRenderer::~ComboBoxCellRenderer()
{
}
void ComboBoxCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::ComboBoxCell));
const ComboBoxCell* pCell = static_cast<const Poco::WebWidgets::ComboBoxCell*>(pRenderable);
ostr << "new Ext.form.ComboBox({";
TextFieldCellRenderer::writeCellProperties(pCell, ostr);
ostr << ", store: new Ext.data.SimpleStore({fields:['d'], data:[";
//now serialize data
std::vector<Any>::const_iterator it = pCell->begin();
std::vector<Any>::const_iterator itEnd = pCell->end();
Formatter::Ptr ptrFormatter = pCell->getFormatter();
for (; it != itEnd; ++it)
{
if (it != pCell->begin())
ostr << ",";
if (ptrFormatter)
ostr << "['" << ptrFormatter->format(*it) << "']";
else
ostr << "['" << RefAnyCast<std::string>(*it) << "']";
}
ostr << "]})";
ostr << ",displayField:'d',typeAhead:true,mode:'local',triggerAction:'all'";
ostr << "})";
}
void ComboBoxCellRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,90 @@
//
// DateFieldCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/DateFieldCellRenderer.cpp#2 $
//
// Library: ExtJS
// Package: Core
// Module: DateFieldCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/DateFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/TextFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/DateFieldCell.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
DateFieldCellRenderer::DateFieldCellRenderer()
{
}
DateFieldCellRenderer::~DateFieldCellRenderer()
{
}
void DateFieldCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::DateFieldCell));
const DateFieldCell* pCell = static_cast<const Poco::WebWidgets::DateFieldCell*>(pRenderable);
ostr << "new Ext.form.DateField({";
DateFieldCellRenderer::writeCellProperties(pCell, ostr);
ostr << "})";
}
void DateFieldCellRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
void DateFieldCellRenderer::writeCellProperties(const DateFieldCell* pCell, std::ostream& ostr)
{
TextFieldCellRenderer::writeCellProperties(pCell, ostr);
//a time value in UTC timezone will have a Z at the end of the time
//unfortunately there is a bug in the iso8601 code of extjs 2.0.2
//it fails to parse the Z
// we avoid that bug in the WebWidgets DateFormatter where values are never written with UTC but with 0 offset if required
const std::string& fmt = pCell->getFormat();
ostr << ",format:'" << Utility::convertPocoDateToPHPDate(fmt) << "'";
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,98 @@
//
// FormRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/FormRenderer.cpp#7 $
//
// Library: ExtJS
// Package: Core
// Module: FormRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/Form.h"
#include "Poco/WebWidgets/Button.h"
#include "Poco/NumberFormatter.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
FormRenderer::FormRenderer()
{
}
FormRenderer::~FormRenderer()
{
}
void FormRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::Form));
const Form* pForm = static_cast<const Poco::WebWidgets::Form*>(pRenderable);
ostr << "new Ext.FormPanel({id:'" << pForm->id() << "',";
ostr << "onSubmit:Ext.emptyFn,submit:function(){this.getEl().dom.submit();},";
if (pForm->getMethod() == Form::METHOD_POST)
ostr << "method:'POST',";
ostr << "title:'" << pForm->getName() << "',autoHeight:true,autoWidth:true,url:'" << pForm->getURI().toString() << "',frame:true,items:[";
ContainerView::ConstIterator it = pForm->begin();
ContainerView::ConstIterator itEnd = pForm->end();
for (; it != itEnd; ++it)
{
if (it != pForm->begin())
ostr << ",";
// it points to a view pointer
(*it)->renderHead(context, ostr);
}
ostr << "]})";
//ostr << varName << ".render('p" << pForm->id() << "');";
}
void FormRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
std::string FormRenderer::formVariableName(const Form* pForm)
{
static const std::string prefix("f");
return prefix + Poco::NumberFormatter::format(pForm->id());
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,105 @@
//
// FrameRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/FrameRenderer.cpp#2 $
//
// Library: ExtJS
// Package: Core
// Module: FrameRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/FrameRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/Frame.h"
#include "Poco/WebWidgets/Layout.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
FrameRenderer::FrameRenderer()
{
}
FrameRenderer::~FrameRenderer()
{
}
void FrameRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
const Frame* pPanel = static_cast<const Poco::WebWidgets::Frame*>(pRenderable);
ostr << "new Ext.Panel({";
writeProperties(pPanel, ostr);
// a frame has exactly one child
// if this child is a layout we are fine otherwise we have to generate the items array
View::Ptr pChild = pPanel->getChild();
if (pChild)
{
Layout::Ptr pLayout = pChild.cast<Layout>();
if (pLayout)
{
ostr << ",";
pLayout->renderHead(context, ostr);
}
else
{
ostr << ",items:[";
pChild->renderHead(context, ostr);
ostr << "]";
}
}
ostr << "})";
}
void FrameRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
void FrameRenderer::writeProperties(const Frame* pFrame, std::ostream& ostr)
{
Utility::writeRenderableProperties(pFrame, ostr);
ostr << ",frame:true";
if (pFrame->getWidth() > 0)
ostr << ",width:" << pFrame->getWidth();
if (pFrame->getHeight() > 0)
ostr << ",height:" << pFrame->getHeight();
if (!pFrame->getTitle().empty())
ostr << ",title:'" << pFrame->getTitle() << "'";
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,70 @@
//
// GridLayoutRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/GridLayoutRenderer.cpp#3 $
//
// Library: ExtJS
// Package: Core
// Module: GridLayoutRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/GridLayoutRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/GridLayout.h"
#include <sstream>
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
GridLayoutRenderer::GridLayoutRenderer()
{
}
GridLayoutRenderer::~GridLayoutRenderer()
{
}
void GridLayoutRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::GridLayout));
const GridLayout* pLayout = static_cast<const Poco::WebWidgets::GridLayout*>(pRenderable);
std::ostringstream layoutConfig;
layoutConfig << "{columns:" << pLayout->columns() << "}";
std::string layout("table");
LayoutRenderer::renderLayoutHead(pLayout, context, ostr, layout, layoutConfig.str());
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,74 @@
//
// HTMLRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/HTMLRenderer.cpp#3 $
//
// Library: ExtJS
// Package: Core
// Module: HTMLRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/HTMLRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/HTML.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
HTMLRenderer::HTMLRenderer()
{
}
HTMLRenderer::~HTMLRenderer()
{
}
void HTMLRenderer::renderHead(const Renderable* pRenderable, const RenderContext&, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::HTML));
const HTML* pHTML = static_cast<const Poco::WebWidgets::HTML*>(pRenderable);
ostr << "new Ext.Panel({border:false,bodyBorder:false,";
ostr << "html:'" << pHTML->getText() << "'})";
}
void HTMLRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,70 @@
//
// HorizontalLayoutRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/HorizontalLayoutRenderer.cpp#1 $
//
// Library: ExtJS
// Package: Core
// Module: HorizontalLayoutRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/HorizontalLayoutRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/HorizontalLayout.h"
#include <sstream>
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
HorizontalLayoutRenderer::HorizontalLayoutRenderer()
{
}
HorizontalLayoutRenderer::~HorizontalLayoutRenderer()
{
}
void HorizontalLayoutRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::HorizontalLayout));
const HorizontalLayout* pLayout = static_cast<const Poco::WebWidgets::HorizontalLayout*>(pRenderable);
std::ostringstream layoutConfig;
layoutConfig << "{columns:" << pLayout->size() << "}";
std::string layout("column");
LayoutRenderer::renderLayoutHead(pLayout, context, ostr, layout, layoutConfig.str());
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,113 @@
//
// ImageButtonCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/ImageButtonCellRenderer.cpp#5 $
//
// Library: ExtJS
// Package: Core
// Module: ImageButtonCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/ImageButtonCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/ImageButtonCell.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
ImageButtonCellRenderer::ImageButtonCellRenderer()
{
}
ImageButtonCellRenderer::~ImageButtonCellRenderer()
{
}
void ImageButtonCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::ImageButtonCell));
const ImageButtonCell* pButtonCell = static_cast<const Poco::WebWidgets::ImageButtonCell*>(pRenderable);
Image::Ptr ptrImg = pButtonCell->getImage();
bool hasImg = ptrImg && !ptrImg->getURI().empty();
if (!hasImg)
ostr << "new Ext.Button({";
else
ostr << "new Ext.Panel({border:false,bodyBorder:false,";
if (!hasImg) // write a normal button
ButtonCellRenderer::renderHead(pButtonCell, context, ostr);
else
{
ostr << "html:";
bool showTxt = pButtonCell->getShowText() || !hasImg;
writeHTML(pButtonCell, showTxt, ostr);
}
ostr << "})";
}
void ImageButtonCellRenderer::writeHTML(const ImageButtonCell* pButtonCell, bool showTxt, std::ostream& ostr)
{
Image::Ptr ptrImg = pButtonCell->getImage();
ostr << "'<div>";
ostr << "<div>";
ostr << "<input src=\"" << Utility::safe(ptrImg->getURI().toString()) << "\"";
if (!ptrImg->getName().empty())
ostr << " name=\"" << ptrImg->getName() << "\"";
if (ptrImg->getWidth() > 0)
ostr << " width=\"" << ptrImg->getWidth() << "\"";
if (ptrImg->getHeight() > 0)
ostr << " height=\"" << ptrImg->getHeight() << "\"";
std::string tooltip = ptrImg->getToolTip();
if (!tooltip.empty())
ostr << " alt=\"" << Utility::safe(tooltip) << "\"";
ostr << " type=\"image\"/>";
ostr << "</div>";
std::string txt(pButtonCell->getOwner()->getText());
if (showTxt && !txt.empty())
ostr << "<div>" << Utility::safe(pButtonCell->getOwner()->getText()) << "</div>";
ostr << "</div>'";
}
void ImageButtonCellRenderer::writeConfigData(const Cell* pCell, const RenderContext& context, std::ostream& ostr)
{
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,89 @@
//
// ImageRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/ImageRenderer.cpp#3 $
//
// Library: ExtJS
// Package: Core
// Module: ImageRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/ImageRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/Image.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
ImageRenderer::ImageRenderer()
{
}
ImageRenderer::~ImageRenderer()
{
}
void ImageRenderer::renderHead(const Renderable* pRenderable, const RenderContext&, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::Image));
const Image* pImage = static_cast<const Poco::WebWidgets::Image*>(pRenderable);
ostr << "new Ext.Panel({border:false,bodyBorder:false,";
ostr << "html:";
writeHTML(pImage, ostr);
ostr << "})";
}
void ImageRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
void ImageRenderer::writeHTML(const Image* pImage, std::ostream& ostr)
{
ostr << "'<img src=\"" << Utility::safe(pImage->getURI().toString()) << "\" ";
std::string txt(pImage->getText());
if (!txt.empty())
ostr << "alt=\"" << txt << "\" ";
std::string tooltip(pImage->getToolTip());
if (!tooltip.empty())
ostr << "title=\"" << tooltip << "\" ";
ostr << "/>'";
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,74 @@
//
// LabelRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/LabelRenderer.cpp#3 $
//
// Library: ExtJS
// Package: Core
// Module: LabelRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/LabelRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/Label.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
LabelRenderer::LabelRenderer()
{
}
LabelRenderer::~LabelRenderer()
{
}
void LabelRenderer::renderHead(const Renderable* pRenderable, const RenderContext&, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::Label));
const Label* pLabel = static_cast<const Poco::WebWidgets::Label*>(pRenderable);
ostr << "{xtype:'label', text:'" << Utility::safe(pLabel->getText()) << "'}";
}
void LabelRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,130 @@
//
// LayoutRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/LayoutRenderer.cpp#5 $
//
// Library: ExtJS
// Package: Core
// Module: LayoutRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/LayoutRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/Layout.h"
#include "Poco/WebWidgets/Frame.h"
#include "Poco/WebWidgets/Panel.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
LayoutRenderer::LayoutRenderer()
{
}
LayoutRenderer::~LayoutRenderer()
{
}
void LayoutRenderer::renderLayoutHead(const Layout* pLayout, const RenderContext& context, std::ostream& ostr, const std::string& layoutId, const std::string& layoutConfig)
{
poco_assert_dbg(pLayout != 0);
Renderable::ID id(0);
View::Ptr ptrParent = pLayout->parent();
if (!(ptrParent && (ptrParent.cast<Frame>() || ptrParent.cast<Panel>())))
{
// the parent is not a panel
// assume that the direct parent is a panel
ostr << "new Ext.Panel({border:false,bodyBorder:false,";
renderParameters(pLayout, context, ostr, layoutId, layoutConfig);
ostr << "})";
}
else
{
renderParameters(pLayout, context, ostr, layoutId, layoutConfig);
}
}
void LayoutRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
void LayoutRenderer::renderParameters(const Layout* pLayout, const RenderContext& context, std::ostream& ostr, const std::string& layoutId, const std::string& layoutConfig)
{
poco_assert_dbg(pLayout != 0);
bool writeComma = false;
if (pLayout->getWidth() > 0)
ostr << "width:" << pLayout->getWidth() << ",";
if (!layoutId.empty())
{
ostr << "layout:'" << layoutId << "'";
writeComma = true;
}
if (!layoutConfig.empty())
{
if (writeComma)
ostr << ",layoutConfig:" << layoutConfig;
else
ostr << ",layoutConfig:" << layoutConfig;
writeComma = true;
}
if (writeComma)
ostr << ",items:[";
else
ostr << "items:[";
visitChildren(pLayout, context, ostr);
ostr << "]";
}
void LayoutRenderer::visitChildren(const Layout* pLayout, const RenderContext& context, std::ostream& ostr)
{
ContainerView::ConstIterator it = pLayout->begin();
for (; it != pLayout->end(); ++it)
{
if (it != pLayout->begin())
ostr << ",";
if (*it)
(*it)->renderHead(context, ostr);
else
ostr << "{}";
}
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,118 @@
//
// ListBoxCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/ListBoxCellRenderer.cpp#1 $
//
// Library: ExtJS
// Package: Core
// Module: ListBoxCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/ListBoxCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/ListBoxCell.h"
#include <sstream>
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
ListBoxCellRenderer::ListBoxCellRenderer()
{
}
ListBoxCellRenderer::~ListBoxCellRenderer()
{
}
void ListBoxCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::ListBoxCell));
const ListBoxCell* pListBoxCell = static_cast<const Poco::WebWidgets::ListBoxCell*>(pRenderable);
ostr << "new Ext.ux.Multiselect({";
ListBoxCellRenderer::renderProperties(pListBoxCell, ostr);
ostr << "})";
}
void ListBoxCellRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
void ListBoxCellRenderer::renderProperties(const ListBoxCell* pListBoxCell, std::ostream& ostr)
{
Utility::writeRenderableProperties(pListBoxCell, ostr);
if (pListBoxCell->getHeight() > 0)
ostr << ",height:" << pListBoxCell->getHeight();
if (pListBoxCell->getWidth() > 0)
ostr << ",width:" << pListBoxCell->getWidth();
ostr << ",dataFields:['i','d'],data:[";
//now serialize data, use cached content for that
ListBoxCell::StringData::const_iterator it = pListBoxCell->beginString();
ListBoxCell::StringData::const_iterator itEnd = pListBoxCell->endString();
ListBoxCell::Data::const_iterator itV = pListBoxCell->begin();
ListBoxCell::Data::const_iterator itVEnd = pListBoxCell->end();
int cnt = 0;
bool selected=false;
std::ostringstream initValue;
initValue << "'";
for (; it != itEnd; ++it, ++cnt, ++itV)
{
if (it != pListBoxCell->beginString())
ostr << ",";
if (itV->second)
{
if (selected)
initValue << ",";
initValue << cnt;
selected = true;
}
ostr << "['" << cnt << "','" << *it << "']";
}
initValue << "'";
ostr << "]";
ostr << ",valueField:'i',displayField:'d',initVal:" << initValue.str();
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,78 @@
//
// NumberFieldCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/NumberFieldCellRenderer.cpp#3 $
//
// Library: ExtJS
// Package: Core
// Module: NumberFieldCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/NumberFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/TextFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/NumberFieldCell.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
NumberFieldCellRenderer::NumberFieldCellRenderer()
{
}
NumberFieldCellRenderer::~NumberFieldCellRenderer()
{
}
void NumberFieldCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::NumberFieldCell));
const NumberFieldCell* pCell = static_cast<const Poco::WebWidgets::NumberFieldCell*>(pRenderable);
ostr << "new Ext.form.NumberField({";
TextFieldCellRenderer::writeCellProperties(pCell, ostr);
ostr << "})";
}
void NumberFieldCellRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,142 @@
//
// PageRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/PageRenderer.cpp#8 $
//
// Library: ExtJS
// Package: Core
// Module: PageRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/PageRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/Page.h"
#include "Poco/WebWidgets/RenderContext.h"
#include "Poco/WebWidgets/LookAndFeel.h"
#include "Poco/WebWidgets/WebApplication.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
PageRenderer::PageRenderer()
{
}
PageRenderer::~PageRenderer()
{
}
void PageRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
static const std::string STRO_HTML("<html>");
static const std::string STRO_HEAD ("<head>");
static const std::string STRO_TITLE ("<title>");
static const std::string STRC_HEAD ("</head>");
static const std::string STRC_TITLE ("</title>");
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::Page));
const Page* pPage = static_cast<const Poco::WebWidgets::Page*>(pRenderable);
poco_assert_dbg (WebApplication::instance().getCurrentPage().get() == pPage);
const LookAndFeel& laf = context.lookAndFeel();
ostr << STRO_HTML << STRO_HEAD << STRO_TITLE;
ostr << pPage->getName();
ostr << STRC_TITLE;
//include javascript files: TODO: use ResourceManager
ostr << "<script type=\"text/javascript\" src=\"ext-base.js\"></script>";
ostr << "<script type=\"text/javascript\" src=\"ext-all.js\"></script>";
ostr << "<script type=\"text/javascript\" src=\"DDView.js\"></script>";
ostr << "<script type=\"text/javascript\" src=\"MultiSelect.js\"></script>";
ostr << "<link rel=\"stylesheet\" type=\"text/css\" href=\"resources/css/ext-all.css\">";
ostr << "<link rel=\"stylesheet\" type=\"text/css\" href=\"MultiSelect.css\">";
if (!pPage->empty())
{
//start inline javascript block
ostr << "<script type=\"text/javascript\">";
ostr << "Ext.onReady(function() {";
ostr << "Ext.QuickTips.init();";
// always nest a panel around, so we can get rid of dynamic casts to check for parent type
ostr << "new Ext.Panel({renderTo:'p" << pPage->id() << "',border:false,bodyBorder:false";
if (pPage->getHeight() > 0)
ostr << ",height:" << pPage->getHeight();
else
ostr << ",height:Ext.lib.Dom.getViewHeight()";
if (pPage->getWidth() > 0)
ostr << ",width:" << pPage->getWidth();
else
ostr << ",width:Ext.lib.Dom.getViewWidth()";
ostr << ",items:[";
//process all children
ContainerView::ConstIterator it = pPage->begin();
ContainerView::ConstIterator itEnd = pPage->end();
for (; it != itEnd; ++it)
{
if (it != pPage->begin())
ostr << ",";
(*it)->renderHead(context, ostr);
}
//close the panel
ostr << "]});";
//auto-show all windows
ostr << "Ext.WindowMgr.each( function(w) {w.show(this);});";
//close onReady
ostr << "});";
//close inline JS block
ostr << "</script>";
}
ostr << STRC_HEAD;
}
void PageRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::Page));
const Page* pPage = static_cast<const Poco::WebWidgets::Page*>(pRenderable);
const LookAndFeel& laf = context.lookAndFeel();
ostr << "<body>";
if (!pPage->empty())
{
//process all children: JS is a JavaScript library, we NEVER write to the body
ostr << "<div id=\"p" << pPage->id() << "\" />";
// also a tmp id for temporary storage!
ostr << "<div id=\"" << Utility::getTmpID() << "\" />";
}
ostr << "</body>";

View File

@@ -0,0 +1,105 @@
//
// PanelRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/PanelRenderer.cpp#5 $
//
// Library: ExtJS
// Package: Core
// Module: PanelRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/PanelRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/Panel.h"
#include "Poco/WebWidgets/Layout.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
PanelRenderer::PanelRenderer()
{
}
PanelRenderer::~PanelRenderer()
{
}
void PanelRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::Panel));
const Panel* pPanel = static_cast<const Poco::WebWidgets::Panel*>(pRenderable);
ostr << "new Ext.Window({";
Utility::writeRenderableProperties(pRenderable, ostr);
if (!pPanel->getName().empty())
ostr << ",title:'" << pPanel->getName() << "'";
if (pPanel->getWidth() > 0)
ostr << ",width:" << pPanel->getWidth();
if (pPanel->getHeight() > 0)
ostr << ",height:" << pPanel->getHeight();
if (pPanel->getModal())
ostr << ",modal:true";
// minimizable set to true only fires a minimize event, without an event handler attached
// it is pretty useless, instead use collapsible
ostr << ",header:true,maximizable:true,collapsible:true";
// a panel has exactly one child
// if this child is a layout we are fine otherwise we have to generate the items array
View::Ptr pChild = pPanel->getChild();
if (pChild)
{
Layout::Ptr pLayout = pChild.cast<Layout>();
if (pLayout)
{
ostr << ",";
pLayout->renderHead(context, ostr);
}
else
{
ostr << ",items:[";
pChild->renderHead(context, ostr);
ostr << "]";
}
}
ostr << "})";
}
void PanelRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,78 @@
//
// PasswordFieldCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/PasswordFieldCellRenderer.cpp#3 $
//
// Library: ExtJS
// Package: Core
// Module: PasswordFieldCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/PasswordFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/TextFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/PasswordFieldCell.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
PasswordFieldCellRenderer::PasswordFieldCellRenderer()
{
}
PasswordFieldCellRenderer::~PasswordFieldCellRenderer()
{
}
void PasswordFieldCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::PasswordFieldCell));
const PasswordFieldCell* pCell = static_cast<const Poco::WebWidgets::PasswordFieldCell*>(pRenderable);
//textfield with inputType: 'password'
ostr << "new Ext.form.TextField({inputType:'password',";
TextFieldCellRenderer::writeCellProperties(pCell, ostr);
ostr << "})";
}
void PasswordFieldCellRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,88 @@
//
// ProgressIndicatorRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/ProgressIndicatorRenderer.cpp#4 $
//
// Library: ExtJS
// Package: Core
// Module: ProgressIndicatorRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/ProgressIndicatorRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/ProgressIndicator.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
ProgressIndicatorRenderer::ProgressIndicatorRenderer()
{
}
ProgressIndicatorRenderer::~ProgressIndicatorRenderer()
{
}
void ProgressIndicatorRenderer::renderHead(const Renderable* pRenderable, const RenderContext&, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::ProgressIndicator));
const ProgressIndicator* pProgressIndicator = static_cast<const Poco::WebWidgets::ProgressIndicator*>(pRenderable);
//use progressbar
ostr << "new Ext.ProgressBar({";
Utility::writeRenderableProperties(pRenderable, ostr);
std::string txt(pProgressIndicator->getText());
if (!txt.empty())
ostr << ",text:'" << txt << "'";
if (pProgressIndicator->getHeight() > 0)
ostr << ",height:" << pProgressIndicator->getHeight();
if (pProgressIndicator->getWidth() > 0)
ostr << ",width:" << pProgressIndicator->getWidth();
if (pProgressIndicator->getUpdateMode() == ProgressIndicator::UM_MANUAL)
ostr << ",value:" << pProgressIndicator->getProgressPercent();
//in automatic use we simply call wait
//TODO: how should we integrate that???
ostr << "})";
}
void ProgressIndicatorRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,72 @@
//
// RadioButtonCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/RadioButtonCellRenderer.cpp#2 $
//
// Library: ExtJS
// Package: Core
// Module: RadioButtonCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/RadioButtonCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/RadioButtonCell.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
RadioButtonCellRenderer::RadioButtonCellRenderer()
{
}
RadioButtonCellRenderer::~RadioButtonCellRenderer()
{
}
void RadioButtonCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::RadioButtonCell));
const RadioButtonCell* pRadioButtonCell = static_cast<const Poco::WebWidgets::RadioButtonCell*>(pRenderable);
ostr << "new Ext.form.Radio({";
ToggleButtonCellRenderer::renderProperties(pRadioButtonCell, ostr);
ostr << "})";
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,69 @@
//
// SubmitButtonCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/SubmitButtonCellRenderer.cpp#1 $
//
// Library: ExtJS
// Package: Core
// Module: SubmitButtonCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/SubmitButtonCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/SubmitButtonCell.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
SubmitButtonCellRenderer::SubmitButtonCellRenderer()
{
}
SubmitButtonCellRenderer::~SubmitButtonCellRenderer()
{
}
void SubmitButtonCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::SubmitButtonCell));
const SubmitButtonCell* pButtonCell = static_cast<const Poco::WebWidgets::SubmitButtonCell*>(pRenderable);
std::string content = "'" + Utility::safe(pButtonCell->getString()) + "'";
ButtonCellRenderer::renderButton(pButtonCell, content, true, true, ostr);
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,105 @@
//
// TabViewRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/TabViewRenderer.cpp#3 $
//
// Library: ExtJS
// Package: Core
// Module: TabViewRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/TabViewRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/TabView.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
TabViewRenderer::TabViewRenderer()
{
}
TabViewRenderer::~TabViewRenderer()
{
}
void TabViewRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::TabView));
const TabView* pTabView = static_cast<const Poco::WebWidgets::TabView*>(pRenderable);
// mhh, a tabPanel inside a form??? is this even possible?
ostr << "new Ext.TabPanel({";
if (pTabView->getActiveView() != TabView::NONE_SELECTED)
ostr << "activeTab:" << pTabView->getActiveView() << ",layoutOnTabChange: true,";
Utility::writeRenderableProperties(pRenderable, ostr);
ostr << ",";
renderParameters(pTabView, context, ostr);
ostr << "})";
}
void TabViewRenderer::renderParameters(const TabView* pTabView, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg(pTabView != 0);
ostr << "items:[";
visitChildren(pTabView, context, ostr);
ostr << "]";
}
void TabViewRenderer::visitChildren(const TabView* pTabView, const RenderContext& context, std::ostream& ostr)
{
ContainerView::ConstIterator it = pTabView->begin();
for (; it != pTabView->end(); ++it)
{
if (it != pTabView->begin())
ostr << ",";
if (*it)
{
ostr << "{title:'" << (*it)->getName() << "',";
ostr << "items:[";
(*it)->renderHead(context, ostr);
ostr << "]}";
}
else
ostr << "{}";
}
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,128 @@
//
// TableCellHandlerFactory.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/TableCellHandlerFactory.cpp#3 $
//
// Library: ExtJS
// Package: Core
// Module: TableCellHandlerFactory
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/TableCellHandlerFactory.h"
#include "Poco/WebWidgets/CheckButtonCell.h"
#include "Poco/WebWidgets/TextEditCell.h"
#include "Poco/WebWidgets/TextFieldCell.h"
#include "Poco/WebWidgets/ComboBoxCell.h"
#include "Poco/WebWidgets/ButtonCell.h"
#include "Poco/WebWidgets/NumberFieldCell.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
TableCellHandlerFactory::TableCellHandlerFactory()
{
{
TableCellHandler<CheckButtonCell>::Ptr pHandle(new TableCellHandler<CheckButtonCell>("Ext.form.Checkbox", true, true));
pHandle->addDynamic("checked", &CheckButtonCell::getBool);
registerFactory(typeid(CheckButtonCell), pHandle);
}
{
TableCellHandler<TextEditCell>::Ptr pHandle(new TableCellHandler<TextEditCell>("Ext.form.TextArea", true, true));
pHandle->addDynamic("value", &TextEditCell::getString);
registerFactory(typeid(TextEditCell), pHandle);
}
{
TableCellHandler<TextFieldCell>::Ptr pHandle(new TableCellHandler<TextFieldCell>("Ext.form.TextField", true, false));
pHandle->addDynamic("value", &TextFieldCell::getString);
registerFactory(typeid(TextFieldCell), pHandle);
}
{
TableCellHandler<NumberFieldCell>::Ptr pHandle(new TableCellHandler<NumberFieldCell>("Ext.form.NumberField", true, false));
pHandle->addDynamic("value", &NumberFieldCell::getString);
registerFactory(typeid(NumberFieldCell), pHandle);
}
{
TableCellHandler<ComboBoxCell>::Ptr pHandle(new TableCellHandler<ComboBoxCell>("Ext.form.ComboBox", true, false));
pHandle->addDynamic("value", &ComboBoxCell::getString);
registerFactory(typeid(ComboBoxCell), pHandle);
}
{
TableCellHandler<ButtonCell>::Ptr pHandle(new TableCellHandler<ButtonCell>("Ext.Button", false, true));
pHandle->addDynamic("text", &ButtonCell::getString);
registerFactory(typeid(ButtonCell), pHandle);
}
{
TableCellHandler<ImageButtonCell>::Ptr pHandle(new TableCellHandler<ImageButtonCell>(false, true));
registerFactory(typeid(ImageButtonCell), pHandle);
}
}
TableCellHandlerFactory::~TableCellHandlerFactory()
{
}
TableCellHandlerFactory& TableCellHandlerFactory::instance()
{
static TableCellHandlerFactory fct;
return fct;
}
AbstractTableCellHandler::Ptr TableCellHandlerFactory::factory(const Cell::Ptr& t) const
{
ConstIterator it = _handlers.find(Type(t->type()));
if (it == _handlers.end())
throw NotFoundException();
AbstractTableCellHandler::Ptr pCopy = it->second->clone();
pCopy->init(t);
return pCopy;
}
void TableCellHandlerFactory::registerFactory(const Type& t, AbstractTableCellHandler::Ptr ptr)
{
std::pair<Iterator, bool> res = _handlers.insert(std::make_pair(t, ptr));
if (!res.second)
res.first->second = ptr;
}
void TableCellHandlerFactory::registerFactory(const std::type_info& t, AbstractTableCellHandler::Ptr ptr)
{
registerFactory(Type(t), ptr);
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,256 @@
//
// TableRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/TableRenderer.cpp#4 $
//
// Library: ExtJS
// Package: Core
// Module: TableRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/TableRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/ExtJS/TableCellHandlerFactory.h"
#include "Poco/WebWidgets/Table.h"
#include "Poco/WebWidgets/WebApplication.h"
#include "Poco/WebWidgets/RequestHandler.h"
#include <sstream>
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
TableRenderer::TableRenderer()
{
}
TableRenderer::~TableRenderer()
{
}
void TableRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::Table));
const Table* pTable = static_cast<const Poco::WebWidgets::Table*>(pRenderable);
ostr << "new Ext.grid.EditorGridPanel({";
TableRenderer::renderProperties(pTable, context, ostr);
ostr << "})";
}
void TableRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
void TableRenderer::renderProperties(const Table* pTable, const RenderContext& context, std::ostream& ostr)
{
Utility::writeRenderableProperties(pTable, ostr);
WebApplication& app = WebApplication::instance();
Renderable::ID id = app.getCurrentPage()->id();
// add an afterEdit handler
// event handlers can be defined in the constructor after the listeners member
//{
// 'afterEdit' : {
// fn: function(obj){obj.row, obj.column, obj.value, tableId}
//},
std::ostringstream uri;
uri << "'" <<app.getURI().toString();
uri << ";"; //mark as AJAX request
uri << RequestHandler::KEY_ID << "=" << id << "&";
uri << Table::FIELD_COL << "='+obj.column+'&";
uri << Table::FIELD_ROW << "='+obj.row+'&" << Table::FIELD_VAL << "='+obj.value";
//obj.commitChanges... hides the red triangle
ostr << ", listeners: {'afteredit':{fn:function(obj){var uri=" << uri.str() << ";obj.grid.getStore().commitChanges();";
ostr << "Ext.Ajax.request({url:uri,";
ostr << "failure:function(){Ext.MessageBox.alert('Status','Failed to write changes back to server.');}});}}},";
renderColumns(pTable, context, ostr);
ostr << ",clicksToEdit:1,store:";
renderStore(pTable, ostr);
app.registerAjaxProcessor(Poco::NumberFormatter::format(id), const_cast<Table*>(pTable));
}
void TableRenderer::renderColumns(const Table* pTable, const RenderContext& context, std::ostream& ostr)
{
//columns: [...]
ostr << "columns:[";
const Table::TableColumns& columns = pTable->getColumns();
Table::TableColumns::const_iterator it = columns.begin();
int i = 0;
for (; it != columns.end(); ++it, ++i)
{
if (i != 0)
ostr << ",";
renderColumn(pTable, *(*it), i, context, ostr);
}
ostr << "]";
}
void TableRenderer::renderColumn(const Table* pTable, const TableColumn& tc, int idx, const RenderContext& context, std::ostream& ostr)
{
static LookAndFeel& laf = Utility::getDefaultRenderers();
// {id:'company', header: "Company", width: 200, sortable: true, dataIndex: 'company'}
// {header: "Last Updated", width: 135, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
ostr << "{";
std::string hdr(Utility::safe(tc.getHeader()));
ostr << "header:'" << hdr << "',dataIndex:'" << idx << "'";
if (tc.getWidth() > 0)
ostr << ",width:" << tc.getWidth();
if (tc.isSortable())
ostr << ",sortable:true";
static TableCellHandlerFactory& fty = TableCellHandlerFactory::instance();
if (tc.getCell())
{
AbstractTableCellHandler::Ptr pHandler = fty.factory(tc.getCell());
if (tc.getCell()->isEditable())
ostr << ",editable:true";
if (tc.getCell()->isEditable() && pHandler->useEditor())
{
ostr << ",editor:";
tc.getCell()->renderHead(context, ostr);
}
if (pHandler->useRenderer())
{
ostr << ",renderer:";
pHandler->writeDynamicData(ostr);
}
}
ostr << "}";
}
void TableRenderer::renderDataModel(const Table* pTable, std::ostream& ostr)
{
//[
//[ ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
//[ ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am']
//]
const TableModel& tm = pTable->getModel();
const Table::TableColumns& tc = pTable->getColumns();
poco_assert_dbg (tc.size() == tm.getColumnCount());
std::size_t colCnt = tm.getColumnCount();
std::size_t rowCnt = tm.getRowCount();
ostr << "[";
for (std::size_t row = 0; row < rowCnt; ++row)
{
if (row != 0)
ostr << ",[";
else
ostr << "[";
for (std::size_t col = 0; col < colCnt; ++col)
{
if (col != 0)
ostr << ",";
//FIXME: how do we distinguish if we want to write something as text or GUIElement?
// Example: Checkbutton can be written as text "true"/"false" or as a CheckButton
// we use the Cell: if we have a Cell set -> complex Type otherwise text
// -> already handled by the renderer!
const Poco::Any& aVal = tm.getValue(row, col);
if (aVal.empty())
ostr << "''";
else
{
//FIXME: we have no type nfo at all, assume string for everything
bool isString = (typeid(std::string) == aVal.type());
Cell::Ptr ptrCell = tc[col]->getCell();
if (isString)
ostr << "'" << RefAnyCast<std::string>(aVal) << "'";
else if (ptrCell)
ostr << tc[col]->getCell()->getFormatter()->format(aVal);
else
; //FIXME:
}
}
ostr << "]";
}
ostr << "]";
}
void TableRenderer::renderStore(const Table* pTable, std::ostream& ostr)
{
//new Ext.data.SimpleStore({
// fields: [
// {name: 'company'},
// {name: 'price', type: 'float'},
// {name: 'change', type: 'float'},
// {name: 'pctChange', type: 'float'},
// {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
// ],
// data: [...]
//});
// we don't know the type, we just have a formatter, the name is always the idx!
// we use the formatter later to set a renderer for a different type than string
const Table::TableColumns& columns = pTable->getColumns();
ostr << "new Ext.data.SimpleStore({fields:[";
Table::TableColumns::const_iterator it = columns.begin();
int i = 0;
for (; it != columns.end(); ++it, ++i)
{
if (i != 0)
ostr << ",";
ostr << "{name:'" << i << "'}";
}
ostr << "],"; // close fields
//Write data
ostr << "data:";
renderDataModel(pTable, ostr);
ostr << "})";
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,109 @@
//
// TextEditCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/TextEditCellRenderer.cpp#3 $
//
// Library: ExtJS
// Package: Core
// Module: TextEditCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/TextEditCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/TextEditCell.h"
#include "Poco/WebWidgets/Control.h"
#include "Poco/WebWidgets/Form.h"
#include "Poco/WebWidgets/WebApplication.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
TextEditCellRenderer::TextEditCellRenderer()
{
}
TextEditCellRenderer::~TextEditCellRenderer()
{
}
void TextEditCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::TextEditCell));
const TextEditCell* pCell = static_cast<const Poco::WebWidgets::TextEditCell*>(pRenderable);
ostr << "new Ext.form.TextArea({";
TextEditCellRenderer::writeCellProperties(pCell, ostr);
ostr << "})";
if (pCell->getOwner() && !pCell->getOwner()->getName().empty())
{
WebApplication::instance().registerFormProcessor(pCell->getOwner()->getName(), const_cast<TextEditCell*>(pCell));
}
}
void TextEditCellRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
void TextEditCellRenderer::writeCellProperties(const TextEditCell* pCell, std::ostream& ostr, bool writeValue)
{
Utility::writeCellProperties(pCell, ostr);
if (writeValue&& !pCell->getValue().empty())
{
ostr << ", value:'" << Utility::safe(pCell->getString()) << "'";
}
if (!pCell->isEditable())
ostr << ", readOnly:true";
if (pCell->getHeightInPixel() > 0)
ostr << ", height:" << pCell->getHeightInPixel();
if (pCell->getGrow())
ostr << ", grow:true";
if (!pCell->getPlaceHolder().empty())
ostr << ", emptyText:'" << Utility::safe(pCell->getPlaceHolder()) << "'";
//tooltip is not supported by textEdit, add listeners
std::string tooltip (pCell->getToolTip());
if (!tooltip.empty())
ostr << ", listeners: {render: function(c) {Ext.QuickTips.register({target: c.getEl(),text: '" << Utility::safe(tooltip) << "'});}}";
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,107 @@
//
// TextFieldCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/TextFieldCellRenderer.cpp#6 $
//
// Library: ExtJS
// Package: Core
// Module: TextFieldCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/TextFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/TextFieldCell.h"
#include "Poco/WebWidgets/Control.h"
#include "Poco/WebWidgets/Form.h"
#include "Poco/WebWidgets/WebApplication.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
TextFieldCellRenderer::TextFieldCellRenderer()
{
}
TextFieldCellRenderer::~TextFieldCellRenderer()
{
}
void TextFieldCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::TextFieldCell));
const TextFieldCell* pCell = static_cast<const Poco::WebWidgets::TextFieldCell*>(pRenderable);
ostr << "new Ext.form.TextField({";
TextFieldCellRenderer::writeCellProperties(pCell, ostr);
ostr << "})";
if (pCell->getOwner() && !pCell->getOwner()->getName().empty())
{
WebApplication::instance().registerFormProcessor(pCell->getOwner()->getName(), const_cast<TextFieldCell*>(pCell));
}
}
void TextFieldCellRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
void TextFieldCellRenderer::writeCellProperties(const TextFieldCell* pCell, std::ostream& ostr, bool writeValue)
{
Utility::writeCellProperties(pCell, ostr);
if (writeValue&& !pCell->getValue().empty())
{
ostr << ",value:'" << Utility::safe(pCell->getString()) << "'";
}
if (!pCell->isEditable())
ostr << ",readOnly:true";
if (!pCell->getPlaceHolder().empty())
ostr << ",emptyText:'" << Utility::safe(pCell->getPlaceHolder()) << "'";
if (pCell->getMaxLength() > 0)
ostr << ",maxLength:" << pCell->getMaxLength();
//tooltip is not supported by textField, add listeners
std::string tooltip (pCell->getToolTip());
if (!tooltip.empty())
ostr << ",listeners:{render:function(c){Ext.QuickTips.register({target:c.getEl(),text:'" << Utility::safe(tooltip) << "'});}}";
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,101 @@
//
// TimeFieldCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/TimeFieldCellRenderer.cpp#4 $
//
// Library: ExtJS
// Package: Core
// Module: TimeFieldCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/TimeFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/TextFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/TimeFieldCell.h"
#include "Poco/WebWidgets/WebApplication.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
TimeFieldCellRenderer::TimeFieldCellRenderer()
{
}
TimeFieldCellRenderer::~TimeFieldCellRenderer()
{
}
void TimeFieldCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::TimeFieldCell));
const TimeFieldCell* pCell = static_cast<const Poco::WebWidgets::TimeFieldCell*>(pRenderable);
ostr << "new Ext.form.TimeField({";
TimeFieldCellRenderer::writeCellProperties(pCell, ostr);
ostr << "})";
if (pCell->getOwner() && !pCell->getOwner()->getName().empty())
{
WebApplication::instance().registerFormProcessor(pCell->getOwner()->getName(), const_cast<TimeFieldCell*>(pCell));
}
}
void TimeFieldCellRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
void TimeFieldCellRenderer::writeCellProperties(const TimeFieldCell* pCell, std::ostream& ostr)
{
TextFieldCellRenderer::writeCellProperties(pCell, ostr);
TimeField::Format fmt = pCell->getFormat();
static const std::string fmt24h("'H:i'");
static const std::string fmt24hs("'H:i:s'");
static const std::string fmtAmPms("'h:i:s A'");
if (fmt == TimeField::FMT_24H)
ostr << ",format:" << fmt24h;
else if (fmt == TimeField::FMT_24H_WITHSECONDS)
ostr << ",format:" << fmt24hs;
else if (fmt == TimeField::FMT_AMPM_WITHSECONDS)
ostr << ",format:" << fmtAmPms;
else
; // this is the default
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,81 @@
//
// ToggleButtonCellRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/ToggleButtonCellRenderer.cpp#4 $
//
// Library: ExtJS
// Package: Core
// Module: ToggleButtonCellRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/ToggleButtonCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/WebApplication.h"
#include "Poco/WebWidgets/ToggleButtonCell.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
ToggleButtonCellRenderer::ToggleButtonCellRenderer()
{
}
ToggleButtonCellRenderer::~ToggleButtonCellRenderer()
{
}
void ToggleButtonCellRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
}
void ToggleButtonCellRenderer::renderProperties(const ToggleButtonCell* pToggleButtonCell, std::ostream& ostr)
{
if (!pToggleButtonCell->getLabel().empty())
ostr << "boxLabel:'" << Utility::safe(pToggleButtonCell->getLabel()) << "',";
ostr << "checked:" << (pToggleButtonCell->isChecked()?"true":"false") << ",";
Utility::writeCellProperties(pToggleButtonCell, ostr);
//tooltip is not supported by togglebutton
std::string tooltip (pToggleButtonCell->getToolTip());
if (!tooltip.empty())
ostr << ",listeners:{render:function(c){c.getEl().dom.qtip='" << Utility::safe(tooltip) << "'; c.getEl().dom.qclass = 'x-form-tip';}}";
if (pToggleButtonCell->getOwner() && !pToggleButtonCell->getOwner()->getName().empty())
{
WebApplication::instance().registerFormProcessor(pToggleButtonCell->getOwner()->getName(), const_cast<ToggleButtonCell*>(pToggleButtonCell));
}
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,382 @@
//
// Utility.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/Utility.cpp#17 $
//
// Library: ExtJS
// Package: Core
// Module: Utility
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/ExtJS/LabelRenderer.h"
#include "Poco/WebWidgets/ExtJS/PageRenderer.h"
#include "Poco/WebWidgets/ExtJS/ButtonCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/SubmitButtonCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/CollapsibleRenderer.h"
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/FrameRenderer.h"
#include "Poco/WebWidgets/ExtJS/TextFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/TimeFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/DateFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/PasswordFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/NumberFieldCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/ComboBoxCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/ImageButtonCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/TextEditCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/CheckButtonCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/RadioButtonCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/GridLayoutRenderer.h"
#include "Poco/WebWidgets/ExtJS/PanelRenderer.h"
#include "Poco/WebWidgets/ExtJS/HorizontalLayoutRenderer.h"
#include "Poco/WebWidgets/ExtJS/VerticalLayoutRenderer.h"
#include "Poco/WebWidgets/ExtJS/ImageRenderer.h"
#include "Poco/WebWidgets/ExtJS/TabViewRenderer.h"
#include "Poco/WebWidgets/ExtJS/ListBoxCellRenderer.h"
#include "Poco/WebWidgets/ExtJS/TableRenderer.h"
#include "Poco/WebWidgets/Label.h"
#include "Poco/WebWidgets/Page.h"
#include "Poco/WebWidgets/ButtonCell.h"
#include "Poco/WebWidgets/SubmitButtonCell.h"
#include "Poco/WebWidgets/Collapsible.h"
#include "Poco/WebWidgets/Form.h"
#include "Poco/WebWidgets/Frame.h"
#include "Poco/WebWidgets/Panel.h"
#include "Poco/WebWidgets/Cell.h"
#include "Poco/WebWidgets/View.h"
#include "Poco/WebWidgets/GridLayout.h"
#include "Poco/WebWidgets/TextFieldCell.h"
#include "Poco/WebWidgets/TimeFieldCell.h"
#include "Poco/WebWidgets/DateFieldCell.h"
#include "Poco/WebWidgets/PasswordFieldCell.h"
#include "Poco/WebWidgets/NumberFieldCell.h"
#include "Poco/WebWidgets/ComboBoxCell.h"
#include "Poco/WebWidgets/ImageButtonCell.h"
#include "Poco/WebWidgets/TextEditCell.h"
#include "Poco/WebWidgets/CheckButtonCell.h"
#include "Poco/WebWidgets/RadioButtonCell.h"
#include "Poco/WebWidgets/HorizontalLayout.h"
#include "Poco/WebWidgets/VerticalLayout.h"
#include "Poco/WebWidgets/Image.h"
#include "Poco/WebWidgets/TabView.h"
#include "Poco/WebWidgets/ListBoxCell.h"
#include "Poco/WebWidgets/Table.h"
#include "Poco/String.h"
#include "Poco/DateTimeFormat.h"
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
void Utility::initialize(LookAndFeel::Ptr ptr)
{
ptr->registerRenderer(typeid(Label), new LabelRenderer());
ptr->registerRenderer(typeid(Page), new PageRenderer());
ptr->registerRenderer(typeid(ButtonCell), new ButtonCellRenderer());
ptr->registerRenderer(typeid(SubmitButtonCell), new SubmitButtonCellRenderer());
ptr->registerRenderer(typeid(Form), new FormRenderer());
ptr->registerRenderer(typeid(Frame), new FrameRenderer());
ptr->registerRenderer(typeid(Collapsible), new CollapsibleRenderer());
ptr->registerRenderer(typeid(TextFieldCell), new TextFieldCellRenderer());
ptr->registerRenderer(typeid(TimeFieldCell), new TimeFieldCellRenderer());
ptr->registerRenderer(typeid(DateFieldCell), new DateFieldCellRenderer());
ptr->registerRenderer(typeid(PasswordFieldCell), new PasswordFieldCellRenderer());
ptr->registerRenderer(typeid(NumberFieldCell), new NumberFieldCellRenderer());
ptr->registerRenderer(typeid(ComboBoxCell), new ComboBoxCellRenderer());
ptr->registerRenderer(typeid(ImageButtonCell), new ImageButtonCellRenderer());
ptr->registerRenderer(typeid(TextEditCell), new TextEditCellRenderer());
ptr->registerRenderer(typeid(CheckButtonCell), new CheckButtonCellRenderer());
ptr->registerRenderer(typeid(RadioButtonCell), new RadioButtonCellRenderer());
ptr->registerRenderer(typeid(ListBoxCell), new ListBoxCellRenderer());
ptr->registerRenderer(typeid(GridLayout), new GridLayoutRenderer());
ptr->registerRenderer(typeid(Panel), new PanelRenderer());
ptr->registerRenderer(typeid(HorizontalLayout), new HorizontalLayoutRenderer());
ptr->registerRenderer(typeid(VerticalLayout), new VerticalLayoutRenderer());
ptr->registerRenderer(typeid(Image), new ImageRenderer());
ptr->registerRenderer(typeid(TabView), new TabViewRenderer());
ptr->registerRenderer(typeid(Table), new TableRenderer());
}
const std::string& Utility::getTmpID()
{
static const std::string tmp("tmp");
return tmp;
}
void Utility::writeRenderableProperties(const Renderable* pRend, std::ostream& ostr)
{
ostr << "id:'" << pRend->id() << "'";
}
void Utility::writeRenderableProperties(const std::string& id, std::ostream& ostr)
{
if (!id.empty())
ostr << "id:'" << id << "'";
}
void Utility::writeCellProperties(const Cell* pCell, std::ostream& ostr, bool writeId)
{
if (writeId)
writeRenderableProperties(pCell, ostr);
//don't support label for cell, keep this separate
ostr << ",hideLabel:true";
if (!pCell->isEnabled())
ostr << ",disabled:true";
View* pOwner = pCell->getOwner();
if (pOwner)
{
if (!pOwner->getName().empty())
ostr << ",name:'" << pOwner->getName() << "'";
if (pOwner->getWidth() != 0)
ostr << ",width:" << pOwner->getWidth();
if (pOwner->getHeight() != 0)
ostr << ",height:" << pOwner->getHeight();
}
}
void Utility::writeCellProperties(const std::string& id,
const std::string& disabled,
const std::string& name,
const std::string& width,
const std::string& height,
std::ostream& ostr)
{
writeRenderableProperties(id, ostr);
//don't support label for cell, keep this separate
if (!id.empty())
ostr << ",";
ostr << "hideLabel:true,";
if (!disabled.empty())
ostr << ",disabled:" << disabled;
if (!name.empty())
ostr << ",name:" << name;
if (!width.empty())
ostr << ",width:" << width;
if (!height.empty())
ostr << ",height:" << height;
}
std::string Utility::safe(const std::string& str)
{
std::string safe(Poco::replace(str, "\\", "\\\\"));
Poco::replaceInPlace(safe, "'", "\\'");
return safe;
}
std::string Utility::convertPocoDateToPHPDate(const std::string& dateTimeFmt)
{
if (dateTimeFmt == Poco::DateTimeFormat::ISO8601_FORMAT)
return "c";
std::string result;
bool inPercent = false;
for (int i = 0; i < dateTimeFmt.length(); ++i)
{
if (inPercent)
{
convertPocoDateToPHPDate(dateTimeFmt[i], result);
inPercent = false;
}
else
{
if (dateTimeFmt[i] == '%')
{
poco_assert_dbg(!inPercent);
inPercent = true;
}
else
escapeCharForPHP(dateTimeFmt[i], result);
}
}
return result;
}
void Utility::convertPocoDateToPHPDate(char in, std::string& result)
{
//Not supported in POCO:
// *??->w - Numeric representation of the day of the week (1-7)
// *??->z - Day of the year starting with zero for jan the 1st (0 - 364/365)
// *??->W - ISO-8601 week number of year, weeks starting on Monday (01-53)
// *??->t - Number of days in the given month (28-31)
// *??->L - 1 for a yeap lear, 0 otherwise
// *??->o - ISO-8601 year number but if the ISO week number (W) belongs to the previous or next year, that year is used instead
// *??->g - 12-hour format of an hour without leading zeros
// *??->G - 24-hour format of an hour without leading zeros
// *??->T - Timezone abbreviation of the machine running the code, examples: EST, MDT, PDT
// *??->Z - Timezone offset in seconds (negative if west of UTC, positive if east) -43200 to 50400
// *??->c - ISO 8601 date, should be handled in the caller must not occur here
// *??->U - Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) 1193432466 or -2138434463
// * %w->D - abbreviated weekday (Mon, Tue, ...)
// * %W->l - full weekday (Monday, Tuesday, ...)
// * %b->M - abbreviated month (Jan, Feb, ...)
// * %B->F - full month (January, February, ...)
// * %d->d - zero-padded day of month (01 .. 31)
// * %e->j - day of month (1 .. 31)
// * %m->m - zero-padded month (01 .. 12)
// * %n->n - month (1 .. 12)
// * %y->y - year without century (70)
// * %Y->Y - year with century (1970)
// * %H->H - hour (00 .. 23)
// * %h->h - hour (00 .. 12)
// * %a->a - am/pm
// * %A->A - AM/PM
// * %M->i - minute (00 .. 59)
// * %S->s - second (00 .. 59)
// * %i->u - millisecond (000 .. 999)
// * %z->P - time zone differential in ISO 8601 format (Z or +NN.NN).
// * %Z->O - time zone differential in RFC format (GMT or +NNNN)
// * %%->% - percent sign
//Not supported in PHP/extjs
// * %f - space-padded day of month ( 1 .. 31), solution: map this to zeropadded: d
// * %o - space-padded month ( 1 .. 12), solution: map this to zeropadded: m
// * %c - centisecond (0 .. 9), solution use millisecond: u
static const char table[]={
'\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0A', '\x0B', '\x0C', '\x0D', '\x0E', '\x0F',
'\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1A', '\x1B', '\x1C', '\x1D', '\x1E', '\x1F',
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'F', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'i', 'N', 'O',
'P', 'Q', 'R', 's', 'T', 'U', 'V', 'l', 'X', 'Y', 'O', '[', '\\', ']', '^', '_',
'`', 'a', 'M', 'u', 'd', 'j', 'f', 'g', 'h', 'u', 'j', 'k', 'l', 'm', 'n', 'm',
'p', 'q', 'r', 's', 't', 'u', 'v', 'D', 'x', 'y', 'P', '{', '|', '}', '~', '\x7F'};
if (in < 0 || in > 127)
{
result.append(1, in);
return;
}
result.append(1, table[in]);
}
void Utility::escapeCharForPHP(char in, std::string& result)
{
// lowest ascii value is 32 ' '
static const char table[]={
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '1', '0', '0', '1', '0', '1', '1', '1', '0', '0', '0', '1', '1', '1', '1',
'1', '0', '0', '1', '1', '1', '0', '1', '0', '1', '1', '0', '0', '0', '0', '0',
'0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1',
'0', '0', '0', '1', '1', '1', '0', '1', '0', '1', '1', '0', '0', '0', '0', '0'};
if (in < 0 || in > 127)
{
result.append(1, in);
return;
}
if (table[in] == '1')
{
result.append(1, '\\');
}
result.append(1, in);
}
void Utility::convertPHPDateToPocoDate(char in, std::string& result)
{
static const char table[]={
'\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0A', '\x0B', '\x0C', '\x0D', '\x0E', '\x0F',
'\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1A', '\x1B', '\x1C', '\x1D', '\x1E', '\x1F',
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '\x7F'};
if (in < 0 || in > 127)
{
result.append(1, in);
return;
}
}
LookAndFeel::Ptr Utility::createDefault()
{
LookAndFeel::Ptr ptr = new LookAndFeel();
Utility::initialize(ptr);
return ptr;
}
LookAndFeel& Utility::getDefaultRenderers()
{
static LookAndFeel::Ptr ptr = createDefault();
return *ptr;
}
Form::Ptr Utility::insideForm(const View* pChild)
{
Form::Ptr ptr;
while (pChild && !ptr)
{
View::Ptr ptrView = pChild->parent();
ptr = ptrView.cast<Form>();
pChild = ptrView;
}
return ptr;
}
Form::Ptr Utility::insideForm(const Cell* pChild)
{
return Utility::insideForm(pChild->getOwner());
}
} } } // namespace Poco::WebWidgets::ExtJS

View File

@@ -0,0 +1,70 @@
//
// VerticalLayoutRenderer.cpp
//
// $Id: //poco/Main/WebWidgets/ExtJS/src/VerticalLayoutRenderer.cpp#2 $
//
// Library: ExtJS
// Package: Core
// Module: VerticalLayoutRenderer
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/WebWidgets/ExtJS/VerticalLayoutRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/VerticalLayout.h"
#include <sstream>
namespace Poco {
namespace WebWidgets {
namespace ExtJS {
VerticalLayoutRenderer::VerticalLayoutRenderer()
{
}
VerticalLayoutRenderer::~VerticalLayoutRenderer()
{
}
void VerticalLayoutRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::VerticalLayout));
const VerticalLayout* pLayout = static_cast<const Poco::WebWidgets::VerticalLayout*>(pRenderable);
// a vertical layout is a table with one column
std::string layoutConfig("{columns:1}");
std::string layout("table");
LayoutRenderer::renderLayoutHead(pLayout, context, ostr, layout, layoutConfig);
}
} } } // namespace Poco::WebWidgets::ExtJS