mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-19 00:46:03 +01:00
various fixes
This commit is contained in:
parent
8dddbfb147
commit
cdab287496
@ -114,18 +114,10 @@ void ButtonCellRenderer::renderProperties(const ButtonCell* pButtonCell, const s
|
|||||||
{
|
{
|
||||||
ostr << ",listeners:{";
|
ostr << ",listeners:{";
|
||||||
Utility::writeJSEvent(ostr, EV_CLICK, pOwner->buttonClicked, &ButtonCellRenderer::createClickServerCallback, pOwner);
|
Utility::writeJSEvent(ostr, EV_CLICK, pOwner->buttonClicked, &ButtonCellRenderer::createClickServerCallback, pOwner);
|
||||||
/*
|
|
||||||
if (pOwner->buttonClicked.willDoServerCallback())
|
|
||||||
Utility::writeJSEvent(ostr, EV_CLICK, pOwner->buttonClicked.jsDelegates(),
|
|
||||||
createClickServerCallback(pOwner), pOwner->buttonClicked.getServerCallbackPos());
|
|
||||||
else
|
|
||||||
Utility::writeJSEvent(ostr, EV_CLICK, pOwner->buttonClicked.jsDelegates());*/
|
|
||||||
ostr << "}";
|
ostr << "}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string toolTip(pButtonCell->getToolTip());
|
std::string toolTip(pButtonCell->getToolTip());
|
||||||
if (!toolTip.empty())
|
if (!toolTip.empty())
|
||||||
ostr << ",tooltip:'" << Utility::safe(toolTip) << "'";
|
ostr << ",tooltip:'" << Utility::safe(toolTip) << "'";
|
||||||
|
@ -63,7 +63,7 @@ void FormRenderer::renderHead(const Renderable* pRenderable, const RenderContext
|
|||||||
|
|
||||||
ostr << "new Ext.FormPanel({id:'" << pForm->id() << "',";
|
ostr << "new Ext.FormPanel({id:'" << pForm->id() << "',";
|
||||||
|
|
||||||
ostr << "onSubmit:Ext.emptyFn,submit:function(){this.getEl().dom.submit();},";
|
//ostr << "onSubmit:Ext.emptyFn,submit:function(){this.getEl().dom.submit();},";
|
||||||
if (pForm->getMethod() == Form::METHOD_POST)
|
if (pForm->getMethod() == Form::METHOD_POST)
|
||||||
ostr << "method:'POST',";
|
ostr << "method:'POST',";
|
||||||
ostr << "title:'" << pForm->getName() << "',autoHeight:true,autoWidth:true,url:'" << pForm->getURI().toString() << "',frame:true,items:[";
|
ostr << "title:'" << pForm->getName() << "',autoHeight:true,autoWidth:true,url:'" << pForm->getURI().toString() << "',frame:true,items:[";
|
||||||
|
@ -87,7 +87,7 @@ void ImageButtonCellRenderer::writeHTML(const ImageButtonCell* pButtonCell, bool
|
|||||||
const Poco::WebWidgets::ImageButton* pOwner = static_cast<const Poco::WebWidgets::ImageButton*>(pButtonCell->getOwner());
|
const Poco::WebWidgets::ImageButton* pOwner = static_cast<const Poco::WebWidgets::ImageButton*>(pButtonCell->getOwner());
|
||||||
poco_check_ptr (pOwner);
|
poco_check_ptr (pOwner);
|
||||||
ostr << "'<div>";
|
ostr << "'<div>";
|
||||||
ostr << "<div>";
|
ostr << "<div><center>";
|
||||||
ostr << "<input src=\"" << Utility::safe(ptrImg->getURI().toString()) << "\"";
|
ostr << "<input src=\"" << Utility::safe(ptrImg->getURI().toString()) << "\"";
|
||||||
if (!pOwner->getName().empty())
|
if (!pOwner->getName().empty())
|
||||||
ostr << " name=\"" << pOwner->getName() << "\"";
|
ostr << " name=\"" << pOwner->getName() << "\"";
|
||||||
@ -107,7 +107,7 @@ void ImageButtonCellRenderer::writeHTML(const ImageButtonCell* pButtonCell, bool
|
|||||||
ostr << "\"";
|
ostr << "\"";
|
||||||
}
|
}
|
||||||
ostr << " type=\"image\"/>";
|
ostr << " type=\"image\"/>";
|
||||||
ostr << "</div>";
|
ostr << "</center></div>";
|
||||||
std::string txt(pOwner->getText());
|
std::string txt(pOwner->getText());
|
||||||
if (showTxt && !txt.empty())
|
if (showTxt && !txt.empty())
|
||||||
ostr << "<div><center>" << Utility::safe(pButtonCell->getOwner()->getText()) << "</center></div>";
|
ostr << "<div><center>" << Utility::safe(pButtonCell->getOwner()->getText()) << "</center></div>";
|
||||||
|
@ -115,8 +115,6 @@ void LayoutRenderer::renderParameters(const Layout* pLayout, const RenderContext
|
|||||||
|
|
||||||
void LayoutRenderer::visitChildren(const Layout* pLayout, int cols, int horPad, int vertPad, const RenderContext& context, std::ostream& ostr)
|
void LayoutRenderer::visitChildren(const Layout* pLayout, int cols, int horPad, int vertPad, const RenderContext& context, std::ostream& ostr)
|
||||||
{
|
{
|
||||||
ContainerView::ConstIterator it = pLayout->begin();
|
|
||||||
int cnt(0);
|
|
||||||
std::string padHor;
|
std::string padHor;
|
||||||
|
|
||||||
if (horPad > 0)
|
if (horPad > 0)
|
||||||
@ -133,10 +131,11 @@ void LayoutRenderer::visitChildren(const Layout* pLayout, int cols, int horPad,
|
|||||||
pad << "<p style=\"margin-top:" << vertPad << "px\"></p>";
|
pad << "<p style=\"margin-top:" << vertPad << "px\"></p>";
|
||||||
padVert = pad.str();
|
padVert = pad.str();
|
||||||
}
|
}
|
||||||
|
ContainerView::ConstIterator it = pLayout->begin();
|
||||||
|
int cnt(0);
|
||||||
for (; it != pLayout->end(); ++it, ++cnt)
|
for (; it != pLayout->end(); ++it, ++cnt)
|
||||||
{
|
{
|
||||||
if (it != pLayout->begin())
|
if (cnt > 0)
|
||||||
{
|
{
|
||||||
ostr << ",";
|
ostr << ",";
|
||||||
if (cnt < cols && !padHor.empty())
|
if (cnt < cols && !padHor.empty())
|
||||||
|
@ -1542,6 +1542,35 @@ void ExtJSTest::testGridLayout()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtJSTest::testGridLayout2()
|
||||||
|
{
|
||||||
|
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||||
|
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||||
|
webApp.setLookAndFeel(laf);
|
||||||
|
RenderContext context(*laf, webApp);
|
||||||
|
Utility::initialize(laf);
|
||||||
|
|
||||||
|
Page::Ptr ptr = new Page("test");
|
||||||
|
webApp.setCurrentPage(ptr);
|
||||||
|
GridLayout::Ptr pHor(new GridLayout(5,2));
|
||||||
|
pHor->setHorizontalPadding(30);
|
||||||
|
pHor->setVerticalPadding(15);
|
||||||
|
pHor->add(new Label("", "txt"));
|
||||||
|
pHor->add(new Button("b1", "But1"));
|
||||||
|
pHor->add(new Button("b2", "But2"));
|
||||||
|
pHor->add(new Button("b3", "But3"));
|
||||||
|
pHor->add(new Button("b4", "But4"));
|
||||||
|
ptr->add(pHor);
|
||||||
|
std::ostringstream ostr;
|
||||||
|
std::ofstream fstr("testGridLayout.html");
|
||||||
|
TeeOutputStream out(ostr);
|
||||||
|
out.addStream(fstr);
|
||||||
|
ptr->renderHead(context, out);
|
||||||
|
ptr->renderBody(context, out);
|
||||||
|
std::string result = ostr.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtJSTest::setUp()
|
void ExtJSTest::setUp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -1598,6 +1627,7 @@ CppUnit::Test* ExtJSTest::suite()
|
|||||||
CppUnit_addTest(pSuite, ExtJSTest, testPanelShowHide);
|
CppUnit_addTest(pSuite, ExtJSTest, testPanelShowHide);
|
||||||
CppUnit_addTest(pSuite, ExtJSTest, testHorizontalLayout);
|
CppUnit_addTest(pSuite, ExtJSTest, testHorizontalLayout);
|
||||||
CppUnit_addTest(pSuite, ExtJSTest, testGridLayout);
|
CppUnit_addTest(pSuite, ExtJSTest, testGridLayout);
|
||||||
|
CppUnit_addTest(pSuite, ExtJSTest, testGridLayout2);
|
||||||
CppUnit_addTest(pSuite, ExtJSTest, testVerticalLayout);
|
CppUnit_addTest(pSuite, ExtJSTest, testVerticalLayout);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
|
@ -88,6 +88,7 @@ public:
|
|||||||
void testHorizontalLayout();
|
void testHorizontalLayout();
|
||||||
void testVerticalLayout();
|
void testVerticalLayout();
|
||||||
void testGridLayout();
|
void testGridLayout();
|
||||||
|
void testGridLayout2();
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
|
||||||
|
@ -56,11 +56,14 @@ class WebWidgets_API SubmitButton: public Button
|
|||||||
public:
|
public:
|
||||||
typedef Poco::AutoPtr<SubmitButton> Ptr;
|
typedef Poco::AutoPtr<SubmitButton> Ptr;
|
||||||
|
|
||||||
|
SubmitButton();
|
||||||
|
/// Creates an anonymous SubmitButton.
|
||||||
|
|
||||||
SubmitButton(const std::string& name);
|
SubmitButton(const std::string& name);
|
||||||
/// Creates a SubmitButton with the given name.
|
/// Creates a SubmitButton with the given name.
|
||||||
|
|
||||||
SubmitButton();
|
SubmitButton(const std::string& name, const std::string& lblTxt);
|
||||||
/// Creates an anonymous SubmitButton.
|
/// Creates a SubmitButton with the given name and label text.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SubmitButton(const std::string& name, const std::type_info& type);
|
SubmitButton(const std::string& name, const std::type_info& type);
|
||||||
|
@ -84,6 +84,12 @@ public:
|
|||||||
void fireTextChanged(void* pSender);
|
void fireTextChanged(void* pSender);
|
||||||
/// Fires the textChanged event.
|
/// Fires the textChanged event.
|
||||||
|
|
||||||
|
const std::string& getContent() const;
|
||||||
|
/// returns the text content of the TextField. Same value as returned by getText(),getString()
|
||||||
|
|
||||||
|
void setContent(const std::string& txt);
|
||||||
|
/// Sets the content
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TextField(const std::string& name, const std::type_info& type);
|
TextField(const std::string& name, const std::type_info& type);
|
||||||
/// Creates a TextField and assigns it the given name.
|
/// Creates a TextField and assigns it the given name.
|
||||||
@ -108,6 +114,12 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline void TextField::setContent(const std::string& txt)
|
||||||
|
{
|
||||||
|
setString(txt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::WebWidgets
|
} } // namespace Poco::WebWidgets
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,9 +44,13 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
class DateTime;
|
||||||
namespace WebWidgets {
|
namespace WebWidgets {
|
||||||
|
|
||||||
|
|
||||||
|
class TimeFieldCell;
|
||||||
|
|
||||||
|
|
||||||
class WebWidgets_API TimeField: public TextField
|
class WebWidgets_API TimeField: public TextField
|
||||||
/// A TimeField
|
/// A TimeField
|
||||||
{
|
{
|
||||||
@ -73,6 +77,13 @@ public:
|
|||||||
void setFormat(TimeField::Format fmt);
|
void setFormat(TimeField::Format fmt);
|
||||||
/// Sets the time format
|
/// Sets the time format
|
||||||
|
|
||||||
|
void setTime(const Poco::DateTime& dt);
|
||||||
|
/// Sets the date
|
||||||
|
|
||||||
|
const Poco::DateTime& getTime() const;
|
||||||
|
/// returns the time if set, otherwise an exception, use getValue().empty() to check if it is valid
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TimeField(const std::string& name, const std::type_info& type);
|
TimeField(const std::string& name, const std::type_info& type);
|
||||||
/// Creates a TimeField and assigns it the given name.
|
/// Creates a TimeField and assigns it the given name.
|
||||||
@ -83,6 +94,8 @@ protected:
|
|||||||
~TimeField();
|
~TimeField();
|
||||||
/// Destroys the TimeField.
|
/// Destroys the TimeField.
|
||||||
|
|
||||||
|
private:
|
||||||
|
TimeFieldCell* _pMyCell;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include "Poco/WebWidgets/TextFieldCell.h"
|
#include "Poco/WebWidgets/TextFieldCell.h"
|
||||||
#include "Poco/WebWidgets/TimeField.h"
|
#include "Poco/WebWidgets/TimeField.h"
|
||||||
|
#include "Poco/DateTime.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@ -66,7 +67,14 @@ public:
|
|||||||
void setFormat(TimeField::Format fmt);
|
void setFormat(TimeField::Format fmt);
|
||||||
/// Sets the time format
|
/// Sets the time format
|
||||||
|
|
||||||
|
void setTime(const Poco::DateTime& dt);
|
||||||
|
/// Sets the date
|
||||||
|
|
||||||
|
const Poco::DateTime& getTime() const;
|
||||||
|
/// returns the time if set, otherwise an exception, use getValue().empty() to check if it is valid
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string _format;
|
||||||
TimeField::Format _fmt;
|
TimeField::Format _fmt;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -77,9 +85,15 @@ inline TimeField::Format TimeFieldCell::getFormat() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void TimeFieldCell::setFormat(TimeField::Format fmt)
|
inline void TimeFieldCell::setTime(const Poco::DateTime& dt)
|
||||||
{
|
{
|
||||||
_fmt = fmt;
|
setValue(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Poco::DateTime& TimeFieldCell::getTime() const
|
||||||
|
{
|
||||||
|
return RefAnyCast<Poco::DateTime>(getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,6 +66,13 @@ SubmitButton::SubmitButton(const std::type_info& type):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SubmitButton::SubmitButton(const std::string& name, const std::string& lbl):
|
||||||
|
Button(name, typeid(SubmitButton), new SubmitButtonCell(this))
|
||||||
|
{
|
||||||
|
setText(lbl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SubmitButton::SubmitButton(const std::string& name):
|
SubmitButton::SubmitButton(const std::string& name):
|
||||||
Button(name, typeid(SubmitButton), new SubmitButtonCell(this))
|
Button(name, typeid(SubmitButton), new SubmitButtonCell(this))
|
||||||
{
|
{
|
||||||
|
@ -148,4 +148,10 @@ void TextField::fireTextChanged(void* pSender)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const std::string& TextField::getContent() const
|
||||||
|
{
|
||||||
|
return RefAnyCast<std::string>(this->getCell()->getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::WebWidgets
|
} } // namespace Poco::WebWidgets
|
||||||
|
@ -43,26 +43,34 @@ namespace WebWidgets {
|
|||||||
|
|
||||||
|
|
||||||
TimeField::TimeField(const std::string& name, const std::type_info& type):
|
TimeField::TimeField(const std::string& name, const std::type_info& type):
|
||||||
TextField(name, type, new TimeFieldCell(this))
|
TextField(name, type, new TimeFieldCell(this)),
|
||||||
|
_pMyCell(0)
|
||||||
{
|
{
|
||||||
|
_pMyCell = cell<TimeFieldCell>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TimeField::TimeField(const std::type_info& type):
|
TimeField::TimeField(const std::type_info& type):
|
||||||
TextField(type, new TimeFieldCell(this))
|
TextField(type, new TimeFieldCell(this)),
|
||||||
|
_pMyCell(0)
|
||||||
{
|
{
|
||||||
|
_pMyCell = cell<TimeFieldCell>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TimeField::TimeField(const std::string& name):
|
TimeField::TimeField(const std::string& name):
|
||||||
TextField(name, typeid(TimeField), new TimeFieldCell(this))
|
TextField(name, typeid(TimeField), new TimeFieldCell(this)),
|
||||||
|
_pMyCell(0)
|
||||||
{
|
{
|
||||||
|
_pMyCell = cell<TimeFieldCell>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TimeField::TimeField():
|
TimeField::TimeField():
|
||||||
TextField(typeid(TimeField), new TimeFieldCell(this))
|
TextField(typeid(TimeField), new TimeFieldCell(this)),
|
||||||
|
_pMyCell(0)
|
||||||
{
|
{
|
||||||
|
_pMyCell = cell<TimeFieldCell>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -73,13 +81,25 @@ TimeField::~TimeField()
|
|||||||
|
|
||||||
TimeField::Format TimeField::getFormat() const
|
TimeField::Format TimeField::getFormat() const
|
||||||
{
|
{
|
||||||
return cell<TimeFieldCell>()->getFormat();
|
return _pMyCell->getFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TimeField::setFormat(TimeField::Format fmt)
|
void TimeField::setFormat(TimeField::Format fmt)
|
||||||
{
|
{
|
||||||
cell<TimeFieldCell>()->setFormat(fmt);
|
_pMyCell->setFormat(fmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TimeField::setTime(const Poco::DateTime& dt)
|
||||||
|
{
|
||||||
|
_pMyCell->setTime(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Poco::DateTime& TimeField::getTime() const
|
||||||
|
{
|
||||||
|
return _pMyCell->getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Poco/WebWidgets/TimeFieldCell.h"
|
#include "Poco/WebWidgets/TimeFieldCell.h"
|
||||||
|
#include "Poco/WebWidgets/DateFormatter.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@ -43,8 +44,10 @@ namespace WebWidgets {
|
|||||||
|
|
||||||
TimeFieldCell::TimeFieldCell(View* pOwner):
|
TimeFieldCell::TimeFieldCell(View* pOwner):
|
||||||
TextFieldCell(pOwner, typeid(TimeFieldCell)),
|
TextFieldCell(pOwner, typeid(TimeFieldCell)),
|
||||||
|
_format("%h:%M %A"),
|
||||||
_fmt(TimeField::FMT_AMPM)
|
_fmt(TimeField::FMT_AMPM)
|
||||||
{
|
{
|
||||||
|
setFormatter(new DateFormatter(_format));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -53,4 +56,23 @@ TimeFieldCell::~TimeFieldCell()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void TimeFieldCell::setFormat(TimeField::Format fmt)
|
||||||
|
{
|
||||||
|
if (_fmt != fmt)
|
||||||
|
{
|
||||||
|
_fmt = fmt;
|
||||||
|
if (_fmt == TimeField::FMT_AMPM)
|
||||||
|
_format = "%h:%M %A";
|
||||||
|
else if (_fmt == TimeField::FMT_24H)
|
||||||
|
_format = "%H:%M";
|
||||||
|
else if (_fmt == TimeField::FMT_AMPM_WITHSECONDS)
|
||||||
|
_format = "%h:%M:%S %A";
|
||||||
|
else if (_fmt == TimeField::FMT_24H_WITHSECONDS)
|
||||||
|
_format = "%H:%M:%S";
|
||||||
|
setFormatter(new DateFormatter(_format));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::WebWidgets
|
} } // namespace Poco::WebWidgets
|
||||||
|
Loading…
x
Reference in New Issue
Block a user