various fixes

This commit is contained in:
Peter Schojer 2008-08-27 12:55:57 +00:00
parent 8dddbfb147
commit cdab287496
15 changed files with 146 additions and 27 deletions

View File

@ -114,17 +114,9 @@ void ButtonCellRenderer::renderProperties(const ButtonCell* pButtonCell, const s
{
ostr << ",listeners:{";
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 << "}";
}
}
std::string toolTip(pButtonCell->getToolTip());
if (!toolTip.empty())

View File

@ -63,7 +63,7 @@ void FormRenderer::renderHead(const Renderable* pRenderable, const RenderContext
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)
ostr << "method:'POST',";
ostr << "title:'" << pForm->getName() << "',autoHeight:true,autoWidth:true,url:'" << pForm->getURI().toString() << "',frame:true,items:[";

View File

@ -87,7 +87,7 @@ void ImageButtonCellRenderer::writeHTML(const ImageButtonCell* pButtonCell, bool
const Poco::WebWidgets::ImageButton* pOwner = static_cast<const Poco::WebWidgets::ImageButton*>(pButtonCell->getOwner());
poco_check_ptr (pOwner);
ostr << "'<div>";
ostr << "<div>";
ostr << "<div><center>";
ostr << "<input src=\"" << Utility::safe(ptrImg->getURI().toString()) << "\"";
if (!pOwner->getName().empty())
ostr << " name=\"" << pOwner->getName() << "\"";
@ -107,7 +107,7 @@ void ImageButtonCellRenderer::writeHTML(const ImageButtonCell* pButtonCell, bool
ostr << "\"";
}
ostr << " type=\"image\"/>";
ostr << "</div>";
ostr << "</center></div>";
std::string txt(pOwner->getText());
if (showTxt && !txt.empty())
ostr << "<div><center>" << Utility::safe(pButtonCell->getOwner()->getText()) << "</center></div>";

View File

@ -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)
{
ContainerView::ConstIterator it = pLayout->begin();
int cnt(0);
std::string padHor;
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>";
padVert = pad.str();
}
ContainerView::ConstIterator it = pLayout->begin();
int cnt(0);
for (; it != pLayout->end(); ++it, ++cnt)
{
if (it != pLayout->begin())
if (cnt > 0)
{
ostr << ",";
if (cnt < cols && !padHor.empty())

View File

@ -94,7 +94,7 @@ void TimeFieldCellRenderer::writeCellProperties(const TimeFieldCell* pCell, std:
else if (fmt == TimeField::FMT_AMPM_WITHSECONDS)
ostr << ",format:" << fmtAmPms;
else
; // this is the default
; // this is the default
}

View File

@ -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()
{
}
@ -1598,6 +1627,7 @@ CppUnit::Test* ExtJSTest::suite()
CppUnit_addTest(pSuite, ExtJSTest, testPanelShowHide);
CppUnit_addTest(pSuite, ExtJSTest, testHorizontalLayout);
CppUnit_addTest(pSuite, ExtJSTest, testGridLayout);
CppUnit_addTest(pSuite, ExtJSTest, testGridLayout2);
CppUnit_addTest(pSuite, ExtJSTest, testVerticalLayout);
return pSuite;

View File

@ -88,6 +88,7 @@ public:
void testHorizontalLayout();
void testVerticalLayout();
void testGridLayout();
void testGridLayout2();
void setUp();
void tearDown();

View File

@ -56,11 +56,14 @@ class WebWidgets_API SubmitButton: public Button
public:
typedef Poco::AutoPtr<SubmitButton> Ptr;
SubmitButton(const std::string& name);
/// Creates a SubmitButton with the given name.
SubmitButton();
/// Creates an anonymous SubmitButton.
SubmitButton(const std::string& name);
/// Creates a SubmitButton with the given name.
SubmitButton(const std::string& name, const std::string& lblTxt);
/// Creates a SubmitButton with the given name and label text.
protected:
SubmitButton(const std::string& name, const std::type_info& type);

View File

@ -83,7 +83,13 @@ public:
void fireTextChanged(void* pSender);
/// 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:
TextField(const std::string& name, const std::type_info& type);
/// 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

View File

@ -44,9 +44,13 @@
namespace Poco {
class DateTime;
namespace WebWidgets {
class TimeFieldCell;
class WebWidgets_API TimeField: public TextField
/// A TimeField
{
@ -72,6 +76,13 @@ public:
void setFormat(TimeField::Format fmt);
/// 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:
TimeField(const std::string& name, const std::type_info& type);
@ -83,6 +94,8 @@ protected:
~TimeField();
/// Destroys the TimeField.
private:
TimeFieldCell* _pMyCell;
};

View File

@ -42,6 +42,7 @@
#include "Poco/WebWidgets/TextFieldCell.h"
#include "Poco/WebWidgets/TimeField.h"
#include "Poco/DateTime.h"
namespace Poco {
@ -65,8 +66,15 @@ public:
void setFormat(TimeField::Format fmt);
/// 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:
std::string _format;
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());
}

View File

@ -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):
Button(name, typeid(SubmitButton), new SubmitButtonCell(this))
{

View File

@ -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

View File

@ -43,26 +43,34 @@ namespace WebWidgets {
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):
TextField(type, new TimeFieldCell(this))
TextField(type, new TimeFieldCell(this)),
_pMyCell(0)
{
_pMyCell = cell<TimeFieldCell>();
}
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():
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
{
return cell<TimeFieldCell>()->getFormat();
return _pMyCell->getFormat();
}
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();
}

View File

@ -35,6 +35,7 @@
#include "Poco/WebWidgets/TimeFieldCell.h"
#include "Poco/WebWidgets/DateFormatter.h"
namespace Poco {
@ -43,8 +44,10 @@ namespace WebWidgets {
TimeFieldCell::TimeFieldCell(View* pOwner):
TextFieldCell(pOwner, typeid(TimeFieldCell)),
_format("%h:%M %A"),
_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