mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-15 07:14:46 +02:00
fixes to table, events, datefields
This commit is contained in:
@@ -144,12 +144,15 @@ private:
|
|||||||
static LookAndFeel::Ptr createDefault();
|
static LookAndFeel::Ptr createDefault();
|
||||||
static int detectMaxParamCount(const std::list<JSDelegate>& delegates);
|
static int detectMaxParamCount(const std::list<JSDelegate>& delegates);
|
||||||
|
|
||||||
static void skipWhiteSpace(const std::string& code, std::string::size_type& pos);
|
static void analyzeFunction(const JSDelegate& delegate, std::string& fctName, std::vector<std::string>& paramNames, std::string& code);
|
||||||
|
// Code contains { ... }
|
||||||
|
|
||||||
static std::string createFunctionSignature(int paramCnt);
|
static std::string createFunctionSignature(int paramCnt);
|
||||||
/// Creates an anonmyous JS function with the given param count
|
/// Creates an anonmyous JS function with the given param count
|
||||||
|
|
||||||
static std::string createFunctionSignature(const std::string& fctName, int paramCnt);
|
static std::string createFunctionSignature(const std::string& fctName, int paramCnt);
|
||||||
|
|
||||||
|
static void writeFunction(std::ostream& out, const std::string& fctName, const std::vector<std::string> ¶ms, const std::string& code);
|
||||||
private:
|
private:
|
||||||
Utility();
|
Utility();
|
||||||
~Utility();
|
~Utility();
|
||||||
|
@@ -81,7 +81,9 @@ void ComboBoxCellRenderer::renderHead(const Renderable* pRenderable, const Rende
|
|||||||
poco_assert_dbg (pRenderable != 0);
|
poco_assert_dbg (pRenderable != 0);
|
||||||
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::ComboBoxCell));
|
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::ComboBoxCell));
|
||||||
ComboBoxCell* pCell = const_cast<ComboBoxCell*>(static_cast<const Poco::WebWidgets::ComboBoxCell*>(pRenderable));
|
ComboBoxCell* pCell = const_cast<ComboBoxCell*>(static_cast<const Poco::WebWidgets::ComboBoxCell*>(pRenderable));
|
||||||
ComboBox* pOwner = dynamic_cast<ComboBox*>(pCell->getOwner());
|
//two scenarios: owner is either a ComboBox or a TableColumn!
|
||||||
|
View* pOwner = pCell->getOwner();
|
||||||
|
ComboBox* pComboOwner = dynamic_cast<ComboBox*>(pOwner);
|
||||||
poco_check_ptr (pOwner);
|
poco_check_ptr (pOwner);
|
||||||
ostr << "new Ext.form.ComboBox({";
|
ostr << "new Ext.form.ComboBox({";
|
||||||
|
|
||||||
@@ -98,10 +100,10 @@ void ComboBoxCellRenderer::renderHead(const Renderable* pRenderable, const Rende
|
|||||||
|
|
||||||
std::string tooltip (pCell->getToolTip());
|
std::string tooltip (pCell->getToolTip());
|
||||||
|
|
||||||
if (!pOwner->selected.jsDelegates().empty())
|
if (pComboOwner && !pComboOwner->selected.jsDelegates().empty())
|
||||||
{
|
{
|
||||||
ostr << ",listeners:{";
|
ostr << ",listeners:{";
|
||||||
Utility::writeJSEvent(ostr, EV_SELECTED, pOwner->selected.jsDelegates());
|
Utility::writeJSEvent(ostr, EV_SELECTED, pComboOwner->selected.jsDelegates());
|
||||||
if (!tooltip.empty())
|
if (!tooltip.empty())
|
||||||
ostr << ",render:function(c){Ext.QuickTips.register({target:c.getEl(),text:'" << Utility::safe(tooltip) << "'});}";
|
ostr << ",render:function(c){Ext.QuickTips.register({target:c.getEl(),text:'" << Utility::safe(tooltip) << "'});}";
|
||||||
ostr << "}";
|
ostr << "}";
|
||||||
|
@@ -64,13 +64,15 @@ void PanelRenderer::renderHead(const Renderable* pRenderable, const RenderContex
|
|||||||
|
|
||||||
Utility::writeRenderableProperties(pRenderable, ostr);
|
Utility::writeRenderableProperties(pRenderable, ostr);
|
||||||
if (!pPanel->getName().empty())
|
if (!pPanel->getName().empty())
|
||||||
ostr << ",title:'" << pPanel->getName() << "'";
|
ostr << ",title:'" << pPanel->getTitle() << "'";
|
||||||
if (pPanel->getWidth() > 0)
|
if (pPanel->getWidth() > 0)
|
||||||
ostr << ",width:" << pPanel->getWidth();
|
ostr << ",width:" << pPanel->getWidth();
|
||||||
if (pPanel->getHeight() > 0)
|
if (pPanel->getHeight() > 0)
|
||||||
ostr << ",height:" << pPanel->getHeight();
|
ostr << ",height:" << pPanel->getHeight();
|
||||||
if (pPanel->getModal())
|
if (pPanel->getModal())
|
||||||
ostr << ",modal:true";
|
ostr << ",modal:true";
|
||||||
|
if (!pPanel->hasCloseIcon())
|
||||||
|
ostr << ",closable:false";
|
||||||
|
|
||||||
// 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
|
||||||
|
@@ -86,7 +86,7 @@ TableCellHandlerFactory::TableCellHandlerFactory()
|
|||||||
registerFactory(typeid(ImageButtonCell), pHandle);
|
registerFactory(typeid(ImageButtonCell), pHandle);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
TableCellHandler<DateFieldCell>::Ptr pHandle(new TableCellHandler<DateFieldCell>(true, false));
|
TableCellHandler<DateFieldCell>::Ptr pHandle(new TableCellHandler<DateFieldCell>(true, true));
|
||||||
registerFactory(typeid(DateFieldCell), pHandle);
|
registerFactory(typeid(DateFieldCell), pHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -97,6 +97,10 @@ void TableRenderer::addCellValueChangedServerCallback(Table* pTable, const std::
|
|||||||
std::map<std::string, std::string> addParams;
|
std::map<std::string, std::string> addParams;
|
||||||
addParams.insert(std::make_pair(Table::FIELD_COL, "+obj.column"));
|
addParams.insert(std::make_pair(Table::FIELD_COL, "+obj.column"));
|
||||||
addParams.insert(std::make_pair(Table::FIELD_ROW, origRow));
|
addParams.insert(std::make_pair(Table::FIELD_ROW, origRow));
|
||||||
|
//problem: I need the displayed string from teh renderer, not the value!
|
||||||
|
// date fields cause problems here, and I only habe one cellclick event per table not per column!
|
||||||
|
// from the tabel get the TableCOlumn, from thsi get the renderer for the given col and render obj.value
|
||||||
|
// {(var r=obj.grid.getColumnModel().getRenderer(obj.col))?r(obj.value);:obj.value;} hm, no working
|
||||||
addParams.insert(std::make_pair(Table::FIELD_VAL, "+obj.value"));
|
addParams.insert(std::make_pair(Table::FIELD_VAL, "+obj.value"));
|
||||||
addParams.insert(std::make_pair(RequestHandler::KEY_EVID, Table::EV_CELLVALUECHANGED));
|
addParams.insert(std::make_pair(RequestHandler::KEY_EVID, Table::EV_CELLVALUECHANGED));
|
||||||
Utility::addServerCallback(pTable->cellValueChanged, signature, addParams, pTable->id(), onSuccess, onFailure);
|
Utility::addServerCallback(pTable->cellValueChanged, signature, addParams, pTable->id(), onSuccess, onFailure);
|
||||||
@@ -207,12 +211,12 @@ void TableRenderer::renderColumn(const Table* pTable, const TableColumn& tc, int
|
|||||||
ostr << ",editor:";
|
ostr << ",editor:";
|
||||||
tc.getCell()->renderHead(context, ostr);
|
tc.getCell()->renderHead(context, ostr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pHandler->useRenderer())
|
if (pHandler->useRenderer())
|
||||||
{
|
{
|
||||||
ostr << ",renderer:";
|
ostr << ",renderer:";
|
||||||
pHandler->writeDynamicData(ostr);
|
pHandler->writeDynamicData(ostr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ostr << "}";
|
ostr << "}";
|
||||||
@@ -244,6 +248,13 @@ void TableRenderer::renderStore(const Table* pTable, std::ostream& ostr)
|
|||||||
{
|
{
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
ostr << ",";
|
ostr << ",";
|
||||||
|
if ((*it)->getCell()->type() == typeid(Poco::WebWidgets::DateFieldCell))
|
||||||
|
{
|
||||||
|
Poco::WebWidgets::DateFieldCell::Ptr pDf = (*it)->getCell().cast<Poco::WebWidgets::DateFieldCell>();
|
||||||
|
|
||||||
|
ostr << "{name:'" << i << "',type:'date',dateFormat:'" << Utility::convertPocoDateToPHPDate(pDf->getFormat()) << "'}";
|
||||||
|
}
|
||||||
|
else
|
||||||
ostr << "{name:'" << i << "'}";
|
ostr << "{name:'" << i << "'}";
|
||||||
}
|
}
|
||||||
ostr << ",{name:'" << i << "'}";
|
ostr << ",{name:'" << i << "'}";
|
||||||
|
@@ -92,6 +92,7 @@
|
|||||||
#include "Poco/WebWidgets/RequestHandler.h"
|
#include "Poco/WebWidgets/RequestHandler.h"
|
||||||
|
|
||||||
#include "Poco/String.h"
|
#include "Poco/String.h"
|
||||||
|
#include "Poco/StringTokenizer.h"
|
||||||
#include "Poco/NumberFormatter.h"
|
#include "Poco/NumberFormatter.h"
|
||||||
#include "Poco/DateTimeFormat.h"
|
#include "Poco/DateTimeFormat.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -412,16 +413,40 @@ bool Utility::writeJSEvent(std::ostream& out, const std::string& eventName, cons
|
|||||||
invoke << "invoke:" << fct <<"{";
|
invoke << "invoke:" << fct <<"{";
|
||||||
std::list<JSDelegate>::const_iterator it = delegates.begin();
|
std::list<JSDelegate>::const_iterator it = delegates.begin();
|
||||||
int cnt(0);
|
int cnt(0);
|
||||||
for (; it != delegates.end(); ++it)
|
for (; it != delegates.end(); ++it, ++cnt)
|
||||||
{
|
{
|
||||||
std::string fctName("d");
|
std::string myFctName("d");
|
||||||
fctName.append(Poco::NumberFormatter::format(cnt));
|
myFctName.append(Poco::NumberFormatter::format(cnt));
|
||||||
if (cnt > 0)
|
out << myFctName << ":";
|
||||||
|
|
||||||
|
std::string fctName;
|
||||||
|
std::vector<std::string> params;
|
||||||
|
std::string code;
|
||||||
|
analyzeFunction(*it, fctName, params, code);
|
||||||
|
if (fctName == "function")
|
||||||
{
|
{
|
||||||
out << ",";
|
// an inline definition, we must have code
|
||||||
|
if (!code.empty())
|
||||||
|
{
|
||||||
|
writeFunction(out, fctName, params, code);
|
||||||
}
|
}
|
||||||
out << fctName << ":" << it->jsCode() << ","; //always write comma because invoke is written as the last method
|
}
|
||||||
invoke << "this." << createFunctionSignature(fctName, maxParams) << ";";
|
else
|
||||||
|
{
|
||||||
|
if (code.empty())
|
||||||
|
{
|
||||||
|
// a reference to another js function
|
||||||
|
//maybe the user defined params too -> ignore them
|
||||||
|
out << fctName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// we have code, so rename the function to function :-)
|
||||||
|
writeFunction(out, "function", params, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out << ","; //always write comma because invoke is written as the last method
|
||||||
|
invoke << "this." << createFunctionSignature(myFctName, maxParams) << ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
invoke << "}";
|
invoke << "}";
|
||||||
@@ -436,6 +461,27 @@ bool Utility::writeJSEvent(std::ostream& out, const std::string& eventName, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Utility::writeFunction(std::ostream& out, const std::string& fctName, const std::vector<std::string> ¶ms, const std::string& code)
|
||||||
|
{
|
||||||
|
out << fctName << "(";
|
||||||
|
std::vector<std::string>::const_iterator it = params.begin();
|
||||||
|
for (; it != params.end(); ++it)
|
||||||
|
{
|
||||||
|
if (it != params.begin())
|
||||||
|
out << ",";
|
||||||
|
out << *it;
|
||||||
|
}
|
||||||
|
out << ")";
|
||||||
|
bool openWritten = false;
|
||||||
|
if (code.find('{') != 0)
|
||||||
|
{
|
||||||
|
out << "{";
|
||||||
|
openWritten = true;
|
||||||
|
}
|
||||||
|
out << code;
|
||||||
|
if (openWritten)
|
||||||
|
out << "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Utility::createURI(const std::map<std::string, std::string>& addParams, Renderable::ID id)
|
std::string Utility::createURI(const std::map<std::string, std::string>& addParams, Renderable::ID id)
|
||||||
@@ -526,39 +572,55 @@ int Utility::detectMaxParamCount(const std::list<JSDelegate>& delegates)
|
|||||||
for (; it != delegates.end(); ++it)
|
for (; it != delegates.end(); ++it)
|
||||||
{
|
{
|
||||||
//count all , between ()
|
//count all , between ()
|
||||||
|
|
||||||
int tmpCnt(0);
|
int tmpCnt(0);
|
||||||
const std::string& code = it->jsCode();
|
std::string tmp;
|
||||||
std::string::size_type pos = code.find('(');
|
std::string tmp2;
|
||||||
if (pos != std::string::npos)
|
std::vector<std::string> params;
|
||||||
{
|
analyzeFunction(*it, tmp, params, tmp2);
|
||||||
++pos; //skip (
|
tmpCnt = (int)params.size();
|
||||||
skipWhiteSpace(code, pos);
|
|
||||||
bool stop = false;
|
|
||||||
while(!stop && pos < code.size())
|
|
||||||
{
|
|
||||||
if (code[pos] == ')')
|
|
||||||
stop = true;
|
|
||||||
else if (code[pos] == ',')
|
|
||||||
++tmpCnt;
|
|
||||||
++pos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tmpCnt > cnt)
|
if (tmpCnt > cnt)
|
||||||
cnt = tmpCnt;
|
cnt = tmpCnt;
|
||||||
}
|
}
|
||||||
if (cnt > 0) // we counted ','
|
|
||||||
++cnt; // we want var count
|
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Utility::skipWhiteSpace(const std::string& code, std::string::size_type& pos)
|
void Utility::analyzeFunction(const JSDelegate& delegate, std::string& fctName, std::vector<std::string>& paramNames, std::string& code)
|
||||||
{
|
{
|
||||||
while (pos < code.size() && std::isspace(code[pos]))
|
// 3 cases:
|
||||||
|
// function(...){...}
|
||||||
|
// myname(....) {}
|
||||||
|
// myname //external call
|
||||||
|
const std::string& jsCode = delegate.jsCode();
|
||||||
|
fctName.clear();
|
||||||
|
paramNames.clear();
|
||||||
|
code.clear();
|
||||||
|
|
||||||
|
std::string::size_type pos = jsCode.find(')');
|
||||||
|
std::string fctHeader = jsCode.substr(0, pos);
|
||||||
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
++pos;
|
++pos;
|
||||||
|
code = jsCode.substr(pos);
|
||||||
|
Poco::trimInPlace(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
Poco::StringTokenizer tok(fctHeader, "(,", Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY);
|
||||||
|
if (tok.count() > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
Poco::StringTokenizer::Iterator it = tok.begin();
|
||||||
|
fctName = *it;
|
||||||
|
++it;
|
||||||
|
for (; it != tok.end(); ++it)
|
||||||
|
paramNames.push_back(*it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string Utility::createFunctionSignature(int paramCnt)
|
std::string Utility::createFunctionSignature(int paramCnt)
|
||||||
{
|
{
|
||||||
static const std::string fct("function");
|
static const std::string fct("function");
|
||||||
|
@@ -1319,33 +1319,64 @@ void ExtJSTest::testTableImageButton()
|
|||||||
void ExtJSTest::testJSEvent()
|
void ExtJSTest::testJSEvent()
|
||||||
{
|
{
|
||||||
Button::Ptr pBut(new Button());
|
Button::Ptr pBut(new Button());
|
||||||
pBut->buttonClicked.add(jsDelegate("someFunction(obj)"));
|
pBut->buttonClicked.add(jsDelegate("someFunction"));
|
||||||
pBut->buttonClicked.add(jsDelegate("function(obj){alert('Click');}"));
|
pBut->buttonClicked.add(jsDelegate("someFunction2(obj)"));
|
||||||
|
pBut->buttonClicked.add(jsDelegate("hello(obj){alert('Click');}")); //hello must get renamed to function
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
Utility::writeJSEvent(out, "clicked", pBut->buttonClicked.jsDelegates());
|
Utility::writeJSEvent(out, "clicked", pBut->buttonClicked.jsDelegates());
|
||||||
std::string result(out.str());
|
std::string result(out.str());
|
||||||
static const std::string expected("'clicked':"
|
static const std::string expected("'clicked':"
|
||||||
"{"
|
"{"
|
||||||
"fn:function(obj){"
|
"fn:function(p1){"
|
||||||
"var all={"
|
"var all={"
|
||||||
"d0:function(obj){"
|
"d0:someFunction,"
|
||||||
|
"d1:someFunction2,"
|
||||||
|
"d2:function(obj){"
|
||||||
"alert('Click');"
|
"alert('Click');"
|
||||||
"},"
|
"},"
|
||||||
"d1:function(obj){"
|
"invoke:function(p1){"
|
||||||
"someFunction(obj);"
|
"this.d0(p1);"
|
||||||
"},"
|
"this.d1(p1);"
|
||||||
"invoke:function(obj){"
|
"this.d2(p1);"
|
||||||
"this.d0(obj);"
|
|
||||||
"this.d1(obj);"
|
|
||||||
"}"
|
"}"
|
||||||
"};"
|
"};"
|
||||||
"all.invoke(obj);"
|
"all.invoke(p1);"
|
||||||
"}"
|
"}"
|
||||||
"}");
|
"}");
|
||||||
assert (result == expected);
|
assert (result == expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtJSTest::testJSEvent2()
|
||||||
|
{
|
||||||
|
Button::Ptr pBut(new Button());
|
||||||
|
pBut->buttonClicked.add(jsDelegate("someFunction"));
|
||||||
|
pBut->buttonClicked.add(jsDelegate("someFunction2(obj,o2)"));
|
||||||
|
pBut->buttonClicked.add(jsDelegate("hello(obj){alert('Click');}")); //hello must get renamed to function
|
||||||
|
std::ostringstream out;
|
||||||
|
Utility::writeJSEvent(out, "clicked", pBut->buttonClicked.jsDelegates());
|
||||||
|
std::string result(out.str());
|
||||||
|
static const std::string expected("'clicked':"
|
||||||
|
"{"
|
||||||
|
"fn:function(p2,p1){"
|
||||||
|
"var all={"
|
||||||
|
"d0:someFunction,"
|
||||||
|
"d1:someFunction2,"
|
||||||
|
"d2:function(obj){"
|
||||||
|
"alert('Click');"
|
||||||
|
"},"
|
||||||
|
"invoke:function(p2,p1){"
|
||||||
|
"this.d0(p2,p1);"
|
||||||
|
"this.d1(p2,p1);"
|
||||||
|
"this.d2(p2,p1);"
|
||||||
|
"}"
|
||||||
|
"};"
|
||||||
|
"all.invoke(p2,p1);"
|
||||||
|
"}"
|
||||||
|
"}");
|
||||||
|
assert (result == expected);
|
||||||
|
}
|
||||||
|
|
||||||
void ExtJSTest::setUp()
|
void ExtJSTest::setUp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1397,6 +1428,7 @@ CppUnit::Test* ExtJSTest::suite()
|
|||||||
CppUnit_addTest(pSuite, ExtJSTest, testTableButton);
|
CppUnit_addTest(pSuite, ExtJSTest, testTableButton);
|
||||||
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);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
}
|
}
|
||||||
|
@@ -82,6 +82,7 @@ public:
|
|||||||
void testTableButton();
|
void testTableButton();
|
||||||
void testTableImageButton();
|
void testTableImageButton();
|
||||||
void testJSEvent();
|
void testJSEvent();
|
||||||
|
void testJSEvent2();
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
|
||||||
|
@@ -64,6 +64,8 @@ public:
|
|||||||
// Cell
|
// Cell
|
||||||
void handleForm(const std::string& field, const std::string& value);
|
void handleForm(const std::string& field, const std::string& value);
|
||||||
|
|
||||||
|
void handleAjaxRequest(const Poco::Net::NameValueCollection& args, Poco::Net::HTTPServerResponse& response);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~ButtonCell();
|
~ButtonCell();
|
||||||
/// Destroys the ButtonCell.
|
/// Destroys the ButtonCell.
|
||||||
|
@@ -79,6 +79,17 @@ public:
|
|||||||
std::vector<Any>::iterator end();
|
std::vector<Any>::iterator end();
|
||||||
/// Iterator to all elements
|
/// Iterator to all elements
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void setElements(const std::vector<T>& elems)
|
||||||
|
/// Initializes the combo box cell with the provided elements
|
||||||
|
{
|
||||||
|
std::vector<Any> result;
|
||||||
|
typename std::vector<T>::const_iterator it = elems.begin();
|
||||||
|
for (; it != elems.end(); ++it)
|
||||||
|
result.push_back(*it);
|
||||||
|
setElements(result);
|
||||||
|
}
|
||||||
|
|
||||||
void setElements(const std::vector<Any>& elems);
|
void setElements(const std::vector<Any>& elems);
|
||||||
/// Initializes the combo box with the provided elements
|
/// Initializes the combo box with the provided elements
|
||||||
|
|
||||||
|
@@ -60,12 +60,18 @@ public:
|
|||||||
Frame(const std::string& name);
|
Frame(const std::string& name);
|
||||||
/// Creates the Frame.
|
/// Creates the Frame.
|
||||||
|
|
||||||
|
Frame(const std::string& name, const std::string& title);
|
||||||
|
/// Creates the Frame.
|
||||||
|
|
||||||
Frame(View::Ptr pChild);
|
Frame(View::Ptr pChild);
|
||||||
/// Creates an unnamed Frame.
|
/// Creates an unnamed Frame.
|
||||||
|
|
||||||
Frame(const std::string& name, View::Ptr pChild);
|
Frame(const std::string& name, View::Ptr pChild);
|
||||||
/// Creates the Frame.
|
/// Creates the Frame.
|
||||||
|
|
||||||
|
Frame(const std::string& name, const std::string& title, View::Ptr pChild);
|
||||||
|
/// Creates the Frame.
|
||||||
|
|
||||||
void setChild(View::Ptr pChild);
|
void setChild(View::Ptr pChild);
|
||||||
/// Sets the child of the panel
|
/// Sets the child of the panel
|
||||||
|
|
||||||
|
@@ -54,16 +54,22 @@ public:
|
|||||||
typedef Poco::AutoPtr<Panel> Ptr;
|
typedef Poco::AutoPtr<Panel> Ptr;
|
||||||
|
|
||||||
Panel();
|
Panel();
|
||||||
/// Creates an unnamed Panel.
|
/// Creates an unnamed Panel without a child
|
||||||
|
|
||||||
Panel(const std::string& name);
|
Panel(const std::string& name);
|
||||||
/// Creates the Panel.
|
/// Creates the Panel without a child and without a title
|
||||||
|
|
||||||
|
Panel(const std::string& name, const std::string& title);
|
||||||
|
/// Creates the Panel without a child
|
||||||
|
|
||||||
Panel(View::Ptr pChild);
|
Panel(View::Ptr pChild);
|
||||||
/// Creates an unnamed Panel.
|
/// Creates an unnamed Panel with its child
|
||||||
|
|
||||||
Panel(const std::string& name, View::Ptr pChild);
|
Panel(const std::string& name, View::Ptr pChild);
|
||||||
/// Creates the Panel.
|
/// Creates the Panel with its child
|
||||||
|
|
||||||
|
Panel(const std::string& name, const std::string& title, View::Ptr pChild);
|
||||||
|
/// Creates the Panel with its child
|
||||||
|
|
||||||
void setChild(View::Ptr pChild);
|
void setChild(View::Ptr pChild);
|
||||||
/// Sets the child of the panel
|
/// Sets the child of the panel
|
||||||
@@ -80,13 +86,35 @@ public:
|
|||||||
|
|
||||||
View::Ptr findChild(const std::string& name) const;
|
View::Ptr findChild(const std::string& name) const;
|
||||||
|
|
||||||
|
void showCloseIcon(bool val);
|
||||||
|
/// Per default the panel has a close icon in the upper right corner.
|
||||||
|
/// Set val to false to hide it
|
||||||
|
|
||||||
|
bool hasCloseIcon() const;
|
||||||
|
/// Returns if the closeicon is shown
|
||||||
|
|
||||||
|
void setText(const std::string& text);
|
||||||
|
/// Sets the title of this View.
|
||||||
|
|
||||||
|
std::string getText() const;
|
||||||
|
/// Returns the title of this View.
|
||||||
|
|
||||||
|
void setTitle(const std::string& text);
|
||||||
|
/// Sets the title of this View.
|
||||||
|
|
||||||
|
const std::string& getTitle() const;
|
||||||
|
/// Returns the title of this View.
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~Panel();
|
~Panel();
|
||||||
/// Destroys the Panel.
|
/// Destroys the Panel.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
View::Ptr _pChild;
|
View::Ptr _pChild;
|
||||||
|
std::string _title;
|
||||||
bool _modal;
|
bool _modal;
|
||||||
|
bool _showCloseIcon;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -112,6 +140,42 @@ inline bool Panel::getModal() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Panel::showCloseIcon(bool val)
|
||||||
|
{
|
||||||
|
_showCloseIcon = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Panel::hasCloseIcon() const
|
||||||
|
{
|
||||||
|
return _showCloseIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Panel::setText(const std::string& text)
|
||||||
|
{
|
||||||
|
setTitle(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string Panel::getText() const
|
||||||
|
{
|
||||||
|
return getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Panel::setTitle(const std::string& text)
|
||||||
|
{
|
||||||
|
_title = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const std::string& Panel::getTitle() const
|
||||||
|
{
|
||||||
|
return _title;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::WebWidgets
|
} } // namespace Poco::WebWidgets
|
||||||
|
|
||||||
|
|
||||||
|
@@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
#include "Poco/WebWidgets/ButtonCell.h"
|
#include "Poco/WebWidgets/ButtonCell.h"
|
||||||
#include "Poco/WebWidgets/Button.h"
|
#include "Poco/WebWidgets/Button.h"
|
||||||
|
#include "Poco/WebWidgets/RequestHandler.h"
|
||||||
|
#include "Poco/Net/HTTPServerResponse.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@@ -68,4 +70,16 @@ void ButtonCell::handleForm(const std::string& field, const std::string& value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ButtonCell::handleAjaxRequest(const Poco::Net::NameValueCollection& args, Poco::Net::HTTPServerResponse& response)
|
||||||
|
{
|
||||||
|
const std::string& ev = args[RequestHandler::KEY_EVID];
|
||||||
|
if (ev == EV_BUTTONCLICKED)
|
||||||
|
{
|
||||||
|
buttonClicked(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::WebWidgets
|
} } // namespace Poco::WebWidgets
|
||||||
|
@@ -87,7 +87,6 @@ void ComboBoxCell::handleForm(const std::string& field, const std::string& value
|
|||||||
|
|
||||||
void ComboBoxCell::handleAjaxRequest(const Poco::Net::NameValueCollection& args, Poco::Net::HTTPServerResponse& response)
|
void ComboBoxCell::handleAjaxRequest(const Poco::Net::NameValueCollection& args, Poco::Net::HTTPServerResponse& response)
|
||||||
{
|
{
|
||||||
// RequestHandler has already called all the handeForm stuff
|
|
||||||
const std::string& ev = args[RequestHandler::KEY_EVID];
|
const std::string& ev = args[RequestHandler::KEY_EVID];
|
||||||
if (ev == EV_LOAD)
|
if (ev == EV_LOAD)
|
||||||
{
|
{
|
||||||
|
@@ -43,21 +43,32 @@ namespace WebWidgets {
|
|||||||
|
|
||||||
Frame::Frame():
|
Frame::Frame():
|
||||||
View(typeid(Frame)),
|
View(typeid(Frame)),
|
||||||
_pChild()
|
_pChild(),
|
||||||
|
_title()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Frame::Frame(const std::string& name):
|
Frame::Frame(const std::string& name):
|
||||||
View(name, typeid(Frame)),
|
View(name, typeid(Frame)),
|
||||||
_pChild()
|
_pChild(),
|
||||||
|
_title()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Frame::Frame(const std::string& name, const std::string& title):
|
||||||
|
View(name, typeid(Frame)),
|
||||||
|
_pChild(),
|
||||||
|
_title(title)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Frame::Frame(View::Ptr pChild):
|
Frame::Frame(View::Ptr pChild):
|
||||||
View(typeid(Frame)),
|
View(typeid(Frame)),
|
||||||
_pChild()
|
_pChild(),
|
||||||
|
_title()
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
@@ -65,7 +76,17 @@ Frame::Frame(View::Ptr pChild):
|
|||||||
|
|
||||||
Frame::Frame(const std::string& name, View::Ptr pChild):
|
Frame::Frame(const std::string& name, View::Ptr pChild):
|
||||||
View(name, typeid(Frame)),
|
View(name, typeid(Frame)),
|
||||||
_pChild()
|
_pChild(),
|
||||||
|
_title()
|
||||||
|
{
|
||||||
|
setChild(pChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Frame::Frame(const std::string& name, const std::string& title, View::Ptr pChild):
|
||||||
|
View(name, typeid(Frame)),
|
||||||
|
_pChild(),
|
||||||
|
_title(title)
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
@@ -73,21 +94,24 @@ Frame::Frame(const std::string& name, View::Ptr pChild):
|
|||||||
|
|
||||||
Frame::Frame(const std::type_info& type):
|
Frame::Frame(const std::type_info& type):
|
||||||
View(type),
|
View(type),
|
||||||
_pChild()
|
_pChild(),
|
||||||
|
_title()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Frame::Frame(const std::string& name, const std::type_info& type):
|
Frame::Frame(const std::string& name, const std::type_info& type):
|
||||||
View(name, type),
|
View(name, type),
|
||||||
_pChild()
|
_pChild(),
|
||||||
|
_title()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Frame::Frame(View::Ptr pChild, const std::type_info& type):
|
Frame::Frame(View::Ptr pChild, const std::type_info& type):
|
||||||
View(type),
|
View(type),
|
||||||
_pChild()
|
_pChild(),
|
||||||
|
_title()
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
@@ -95,7 +119,8 @@ Frame::Frame(View::Ptr pChild, const std::type_info& type):
|
|||||||
|
|
||||||
Frame::Frame(const std::string& name, View::Ptr pChild, const std::type_info& type):
|
Frame::Frame(const std::string& name, View::Ptr pChild, const std::type_info& type):
|
||||||
View(name, typeid(Frame)),
|
View(name, typeid(Frame)),
|
||||||
_pChild()
|
_pChild(),
|
||||||
|
_title()
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,9 @@ namespace WebWidgets {
|
|||||||
Panel::Panel():
|
Panel::Panel():
|
||||||
View(typeid(Panel)),
|
View(typeid(Panel)),
|
||||||
_pChild(),
|
_pChild(),
|
||||||
_modal(false)
|
_title(),
|
||||||
|
_modal(false),
|
||||||
|
_showCloseIcon(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +54,19 @@ Panel::Panel():
|
|||||||
Panel::Panel(const std::string& name):
|
Panel::Panel(const std::string& name):
|
||||||
View(name, typeid(Panel)),
|
View(name, typeid(Panel)),
|
||||||
_pChild(),
|
_pChild(),
|
||||||
_modal(false)
|
_title(),
|
||||||
|
_modal(false),
|
||||||
|
_showCloseIcon(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Panel::Panel(const std::string& name, const std::string& title):
|
||||||
|
View(name, typeid(Panel)),
|
||||||
|
_pChild(),
|
||||||
|
_title(title),
|
||||||
|
_modal(false),
|
||||||
|
_showCloseIcon(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +74,9 @@ Panel::Panel(const std::string& name):
|
|||||||
Panel::Panel(View::Ptr pChild):
|
Panel::Panel(View::Ptr pChild):
|
||||||
View(typeid(Panel)),
|
View(typeid(Panel)),
|
||||||
_pChild(),
|
_pChild(),
|
||||||
_modal(false)
|
_title(),
|
||||||
|
_modal(false),
|
||||||
|
_showCloseIcon(true)
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
@@ -69,7 +85,20 @@ Panel::Panel(View::Ptr pChild):
|
|||||||
Panel::Panel(const std::string& name, View::Ptr pChild):
|
Panel::Panel(const std::string& name, View::Ptr pChild):
|
||||||
View(name, typeid(Panel)),
|
View(name, typeid(Panel)),
|
||||||
_pChild(),
|
_pChild(),
|
||||||
_modal(false)
|
_title(),
|
||||||
|
_modal(false),
|
||||||
|
_showCloseIcon(true)
|
||||||
|
{
|
||||||
|
setChild(pChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Panel::Panel(const std::string& name, const std::string& title, View::Ptr pChild):
|
||||||
|
View(name, typeid(Panel)),
|
||||||
|
_pChild(),
|
||||||
|
_title(title),
|
||||||
|
_modal(false),
|
||||||
|
_showCloseIcon(true)
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user