added debug mode, fixed panel rendering

This commit is contained in:
Peter Schojer
2008-06-25 07:36:39 +00:00
parent c5a222e8ba
commit 39a77169d3
6 changed files with 34435 additions and 3 deletions

View File

@@ -194,7 +194,7 @@ void PageRenderer::renderBody(const Renderable* pRenderable, const RenderContext
ostr << "<body>"; ostr << "<body>";
if (!pPage->empty()) if (!pPage->empty())
{ {
//process all children: JS is a JavaScript library, we NEVER write to the body //process all children: ExtJS is a JavaScript library, we NEVER write to the body
ostr << "<div id=\"p" << pPage->id() << "\" />"; ostr << "<div id=\"p" << pPage->id() << "\" />";
// also a tmp id for temporary storage! // also a tmp id for temporary storage!
ostr << "<div id=\"" << Utility::getTmpID() << "\" />"; ostr << "<div id=\"" << Utility::getTmpID() << "\" />";

View File

@@ -67,12 +67,18 @@ void PanelRenderer::renderHead(const Renderable* pRenderable, const RenderContex
ostr << ",title:'" << pPanel->getTitle() << "'"; ostr << ",title:'" << pPanel->getTitle() << "'";
if (pPanel->getWidth() > 0) if (pPanel->getWidth() > 0)
ostr << ",width:" << pPanel->getWidth(); ostr << ",width:" << pPanel->getWidth();
else
ostr << ",width:100"; // required!
if (pPanel->getHeight() > 0) if (pPanel->getHeight() > 0)
ostr << ",height:" << pPanel->getHeight(); ostr << ",height:" << pPanel->getHeight();
else
ostr << ",height:100"; // required!
if (pPanel->getModal()) if (pPanel->getModal())
ostr << ",modal:true"; ostr << ",modal:true";
if (!pPanel->hasCloseIcon()) if (!pPanel->hasCloseIcon())
ostr << ",closable:false"; ostr << ",closable:false";
if (pPanel->isVisible())
ostr << ",renderTo:Ext.getBody()";
// minimizable set to true only fires a minimize event, without an event handler attached // minimizable set to true only fires a minimize event, without an event handler attached
// it is pretty useless, instead use collapsible // it is pretty useless, instead use collapsible

View File

@@ -138,9 +138,12 @@ void Utility::initialize(ResourceManager::Ptr ptr, const Poco::Path& extJSDir)
{ {
Poco::Path aDir(extJSDir); Poco::Path aDir(extJSDir);
aDir.makeDirectory(); aDir.makeDirectory();
ptr->appendJSInclude(Poco::Path(aDir, "ext-base.js")); ptr->appendJSInclude(Poco::Path(aDir, "ext-base.js"));
#ifdef _DEBUG
ptr->appendJSInclude(Poco::Path(aDir, "ext-all-debug.js"));
#else
ptr->appendJSInclude(Poco::Path(aDir, "ext-all.js")); ptr->appendJSInclude(Poco::Path(aDir, "ext-all.js"));
#endif
ptr->appendJSInclude(Poco::Path(aDir, "DDView.js")); ptr->appendJSInclude(Poco::Path(aDir, "DDView.js"));
ptr->appendJSInclude(Poco::Path(aDir, "Multiselect.js")); ptr->appendJSInclude(Poco::Path(aDir, "Multiselect.js"));

File diff suppressed because it is too large Load Diff

View File

@@ -1386,6 +1386,82 @@ void ExtJSTest::testJSEvent2()
assert (result == expected); assert (result == expected);
} }
void ExtJSTest::testButtonRename()
{
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);
Button::Ptr pBut(new Button("but1", "Not Clicked"));
ptr->add(pBut);
{
std::ostringstream ostr;
ostr << "function() {";
ostr << "var but=Ext.getCmp('" << pBut->id() << "');";
ostr << "if (but.getText() == 'Clicked') ";
ostr << "but.setText('Not Clicked');";
ostr << "else ";
ostr << "but.setText('Clicked');";
ostr << "}";
pBut->buttonClicked.add(jsDelegate(ostr.str()));
}
std::ostringstream ostr;
std::ofstream fstr("testButtonRename.html");
TeeOutputStream out(ostr);
out.addStream(fstr);
ptr->renderHead(context, out);
ptr->renderBody(context, out);
std::string result = ostr.str();
}
void ExtJSTest::testPanelShowHide()
{
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);
Button::Ptr pBut(new Button("but1", "Show"));
ptr->add(pBut);
Panel::Ptr pWin(new Panel("p","Test Panel"));
pWin->setChild(new Label("lbl1", "Just some dummy text"));
pWin->show(false);
ptr->add(pWin);
{
std::ostringstream ostr;
ostr << "function() {";
ostr << "var but=Ext.getCmp('" << pBut->id() << "');";
ostr << "var win=Ext.getCmp('" << pWin->id() << "');";
ostr << "if (but.getText()=='Show'){";
ostr << "but.setText('Hide');";
ostr << "win.show();";
ostr << "}else{";
ostr << "but.setText('Show');";
ostr << "win.hide();";
ostr << "}";
ostr << "}";
pBut->buttonClicked.add(jsDelegate(ostr.str()));
}
std::ostringstream ostr;
std::ofstream fstr("testPanelShowHide.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()
{ {
} }
@@ -1438,6 +1514,8 @@ CppUnit::Test* ExtJSTest::suite()
CppUnit_addTest(pSuite, ExtJSTest, testTableImageButton); CppUnit_addTest(pSuite, ExtJSTest, testTableImageButton);
CppUnit_addTest(pSuite, ExtJSTest, testJSEvent); CppUnit_addTest(pSuite, ExtJSTest, testJSEvent);
CppUnit_addTest(pSuite, ExtJSTest, testJSEvent2); CppUnit_addTest(pSuite, ExtJSTest, testJSEvent2);
CppUnit_addTest(pSuite, ExtJSTest, testButtonRename);
CppUnit_addTest(pSuite, ExtJSTest, testPanelShowHide);
return pSuite; return pSuite;
} }

View File

@@ -83,6 +83,8 @@ public:
void testTableImageButton(); void testTableImageButton();
void testJSEvent(); void testJSEvent();
void testJSEvent2(); void testJSEvent2();
void testButtonRename();
void testPanelShowHide();
void setUp(); void setUp();
void tearDown(); void tearDown();