mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-17 19:25:53 +02:00
various extensions
This commit is contained in:
@@ -79,7 +79,9 @@ public:
|
|||||||
/// Renders button properties
|
/// Renders button properties
|
||||||
|
|
||||||
static Poco::WebWidgets::JSDelegate createSelectionChangedServerCallback(const ListBox* pList);
|
static Poco::WebWidgets::JSDelegate createSelectionChangedServerCallback(const ListBox* pList);
|
||||||
/// JS signature: function(dataView, selArray){
|
/// JS signature: function(multiselectObj, dataView, selArray, idxArray)
|
||||||
|
/// selArray contains the selected elements (selArray[i].viewIndex contains the index
|
||||||
|
/// idxArray is a compact string of all selected indizes (ie "3", "1,3,4"
|
||||||
|
|
||||||
static void onBeforeLoad(void* pSender, std::pair<ListBoxCell*, Poco::Net::HTTPServerResponse*>& ld);
|
static void onBeforeLoad(void* pSender, std::pair<ListBoxCell*, Poco::Net::HTTPServerResponse*>& ld);
|
||||||
|
|
||||||
|
@@ -109,6 +109,8 @@ void FrameRenderer::writeProperties(const Frame* pFrame, std::ostream& ostr)
|
|||||||
ostr << ",x:" << pFrame->getPosition().posX << ",y:" << pFrame->getPosition().posY;
|
ostr << ",x:" << pFrame->getPosition().posX << ",y:" << pFrame->getPosition().posY;
|
||||||
if (pFrame->hasClass())
|
if (pFrame->hasClass())
|
||||||
ostr << ",cls:'" << pFrame->getClass() << "'";
|
ostr << ",cls:'" << pFrame->getClass() << "'";
|
||||||
|
if (!pFrame->showBorder())
|
||||||
|
ostr << ",border:false,bodyBorder:false";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -95,10 +95,13 @@ void ListBoxCellRenderer::renderProperties(const ListBoxCell* pListBoxCell, std:
|
|||||||
|
|
||||||
if (pOwner->hasPosition())
|
if (pOwner->hasPosition())
|
||||||
ostr << ",x:" << pOwner->getPosition().posX << ",y:" << pOwner->getPosition().posY;
|
ostr << ",x:" << pOwner->getPosition().posX << ",y:" << pOwner->getPosition().posY;
|
||||||
|
|
||||||
|
if (!pListBoxCell->autoScroll())
|
||||||
|
ostr << ",autoScroll:false";
|
||||||
|
|
||||||
if (pList)
|
if (pList)
|
||||||
{
|
{
|
||||||
bool hasListeners = pList->selectionChanged.hasJavaScriptCode();
|
bool hasListeners = pList->selectionChanged.hasJavaScriptCode() || !pList->rowSelected.empty() || !pList->rowDeselected.empty();
|
||||||
if (hasListeners)
|
if (hasListeners)
|
||||||
{
|
{
|
||||||
ostr << ",listeners:{";
|
ostr << ",listeners:{";
|
||||||
@@ -157,9 +160,9 @@ void ListBoxCellRenderer::renderProperties(const ListBoxCell* pListBoxCell, std:
|
|||||||
Poco::WebWidgets::JSDelegate ListBoxCellRenderer::createSelectionChangedServerCallback(const ListBox* pList)
|
Poco::WebWidgets::JSDelegate ListBoxCellRenderer::createSelectionChangedServerCallback(const ListBox* pList)
|
||||||
{
|
{
|
||||||
// selectionchange : ( dataView, selArray )
|
// selectionchange : ( dataView, selArray )
|
||||||
static const std::string signature("function(view, sel)");
|
static const std::string signature("function(ms, v, s, idx)");
|
||||||
std::map<std::string, std::string> addParams;
|
std::map<std::string, std::string> addParams;
|
||||||
addParams.insert(std::make_pair(ListBoxCell::ARG_ROW, "+sel.toString()"));
|
addParams.insert(std::make_pair(ListBoxCell::ARG_ROW, "+idx"));
|
||||||
addParams.insert(std::make_pair(RequestHandler::KEY_EVID, ListBoxCell::EV_SELECTIONCHANGED));
|
addParams.insert(std::make_pair(RequestHandler::KEY_EVID, ListBoxCell::EV_SELECTIONCHANGED));
|
||||||
return Utility::createServerCallback(signature, addParams, pList->id(), pList->selectionChanged.getOnSuccess(), pList->selectionChanged.getOnFailure());
|
return Utility::createServerCallback(signature, addParams, pList->id(), pList->selectionChanged.getOnSuccess(), pList->selectionChanged.getOnFailure());
|
||||||
}
|
}
|
||||||
|
@@ -155,6 +155,8 @@ void PanelRenderer::renderHeadWithoutChildren(const Panel* pPanel, const RenderC
|
|||||||
|
|
||||||
if (!pPanel->enabled())
|
if (!pPanel->enabled())
|
||||||
ostr << ",disabled:true";
|
ostr << ",disabled:true";
|
||||||
|
if (!pPanel->showBorder())
|
||||||
|
ostr << ",border:false,bodyBorder:false";
|
||||||
|
|
||||||
ostr << "})";
|
ostr << "})";
|
||||||
}
|
}
|
||||||
|
@@ -103,6 +103,10 @@ public:
|
|||||||
|
|
||||||
bool collapsed() const;
|
bool collapsed() const;
|
||||||
/// Returns how the Frame should be rendered initially
|
/// Returns how the Frame should be rendered initially
|
||||||
|
|
||||||
|
void showBorder(bool show);
|
||||||
|
|
||||||
|
bool showBorder() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Frame(const std::type_info& type);
|
Frame(const std::type_info& type);
|
||||||
@@ -125,6 +129,7 @@ private:
|
|||||||
std::string _title;
|
std::string _title;
|
||||||
bool _collapsible;
|
bool _collapsible;
|
||||||
bool _collapsed;
|
bool _collapsed;
|
||||||
|
bool _showBorder;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -186,6 +191,18 @@ inline bool Frame::collapsed() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Frame::showBorder(bool show)
|
||||||
|
{
|
||||||
|
_showBorder = show;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Frame::showBorder() const
|
||||||
|
{
|
||||||
|
return _showBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::WebWidgets
|
} } // namespace Poco::WebWidgets
|
||||||
|
|
||||||
|
|
||||||
|
@@ -87,9 +87,23 @@ public:
|
|||||||
|
|
||||||
Data::iterator end();
|
Data::iterator end();
|
||||||
/// Iterator to all elements
|
/// Iterator to all elements
|
||||||
|
|
||||||
|
void clearElements();
|
||||||
|
/// Removes all elements
|
||||||
|
|
||||||
void setElements(const Data& elems);
|
void setElements(const Data& elems);
|
||||||
/// Initializes the combo box with the provided elements
|
/// Initializes the combo box with the provided elements
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void setElements(const std::vector<T>& elems)
|
||||||
|
/// Initializes the combo box with the provided elements
|
||||||
|
{
|
||||||
|
Data anyElems;
|
||||||
|
typename std::vector<T>::const_iterator it = elems.begin();
|
||||||
|
for (; it != elems.end(); ++it)
|
||||||
|
anyElems.push_back(std::make_pair(Poco::Any(*it), false));
|
||||||
|
setElements(anyElems);
|
||||||
|
}
|
||||||
|
|
||||||
const Data& getElements() const;
|
const Data& getElements() const;
|
||||||
/// Returns all elements
|
/// Returns all elements
|
||||||
@@ -123,6 +137,12 @@ public:
|
|||||||
|
|
||||||
const Any& getSelected() const;
|
const Any& getSelected() const;
|
||||||
/// Returns the first selected element, exception if none was selected
|
/// Returns the first selected element, exception if none was selected
|
||||||
|
|
||||||
|
void autoScroll(bool val = true);
|
||||||
|
// sets autoscrolling
|
||||||
|
|
||||||
|
bool autoScroll() const;
|
||||||
|
/// gets autoscroll
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ListBox(const std::string& name, const std::type_info& type);
|
ListBox(const std::string& name, const std::type_info& type);
|
||||||
@@ -262,6 +282,24 @@ inline void ListBox::deselectAll()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void ListBox::clearElements()
|
||||||
|
{
|
||||||
|
_pLBCell->clearElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void ListBox::autoScroll(bool val)
|
||||||
|
{
|
||||||
|
_pLBCell->autoScroll(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool ListBox::autoScroll() const
|
||||||
|
{
|
||||||
|
return _pLBCell->autoScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::WebWidgets
|
} } // namespace Poco::WebWidgets
|
||||||
|
|
||||||
|
|
||||||
|
@@ -107,6 +107,9 @@ public:
|
|||||||
|
|
||||||
StringData::const_iterator endString() const;
|
StringData::const_iterator endString() const;
|
||||||
/// ConstIterator to all elements
|
/// ConstIterator to all elements
|
||||||
|
|
||||||
|
void clearElements();
|
||||||
|
/// Removes all elements
|
||||||
|
|
||||||
void setElements(const Data& elems);
|
void setElements(const Data& elems);
|
||||||
/// Initializes the combo box with the provided elements
|
/// Initializes the combo box with the provided elements
|
||||||
@@ -145,6 +148,12 @@ public:
|
|||||||
/// Returns the first selected element, exception if none was selected.
|
/// Returns the first selected element, exception if none was selected.
|
||||||
/// To get all selected elements use getElements and iterate over the
|
/// To get all selected elements use getElements and iterate over the
|
||||||
/// returned vector
|
/// returned vector
|
||||||
|
|
||||||
|
void autoScroll(bool val);
|
||||||
|
// sets autoscrolling
|
||||||
|
|
||||||
|
bool autoScroll() const;
|
||||||
|
/// gets autoscroll
|
||||||
|
|
||||||
// Cell
|
// Cell
|
||||||
void handleForm(const std::string& field, const std::string& value);
|
void handleForm(const std::string& field, const std::string& value);
|
||||||
@@ -169,6 +178,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
Data _data;
|
Data _data;
|
||||||
StringData _fmtCache;
|
StringData _fmtCache;
|
||||||
|
bool _autoScroll;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -237,6 +247,25 @@ inline void ListBoxCell::deselectAll()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void ListBoxCell::clearElements()
|
||||||
|
{
|
||||||
|
_data.clear();
|
||||||
|
_fmtCache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void ListBoxCell::autoScroll(bool val)
|
||||||
|
{
|
||||||
|
_autoScroll = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool ListBoxCell::autoScroll() const
|
||||||
|
{
|
||||||
|
return _autoScroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::WebWidgets
|
} } // namespace Poco::WebWidgets
|
||||||
|
|
||||||
|
|
||||||
|
@@ -114,6 +114,11 @@ public:
|
|||||||
void enable(bool val);
|
void enable(bool val);
|
||||||
|
|
||||||
bool enabled() const;
|
bool enabled() const;
|
||||||
|
|
||||||
|
void showBorder(bool show);
|
||||||
|
|
||||||
|
bool showBorder() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~Panel();
|
~Panel();
|
||||||
/// Destroys the Panel.
|
/// Destroys the Panel.
|
||||||
@@ -125,6 +130,7 @@ private:
|
|||||||
bool _showCloseIcon;
|
bool _showCloseIcon;
|
||||||
bool _showHeader;
|
bool _showHeader;
|
||||||
bool _enabled;
|
bool _enabled;
|
||||||
|
bool _showBorder;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -210,6 +216,18 @@ inline bool Panel::enabled() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Panel::showBorder(bool show)
|
||||||
|
{
|
||||||
|
_showBorder = show;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Panel::showBorder() const
|
||||||
|
{
|
||||||
|
return _showBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::WebWidgets
|
} } // namespace Poco::WebWidgets
|
||||||
|
|
||||||
|
|
||||||
|
@@ -46,7 +46,8 @@ Frame::Frame():
|
|||||||
_pChild(),
|
_pChild(),
|
||||||
_title(),
|
_title(),
|
||||||
_collapsible(false),
|
_collapsible(false),
|
||||||
_collapsed(false)
|
_collapsed(false),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +57,8 @@ Frame::Frame(const std::string& name):
|
|||||||
_pChild(),
|
_pChild(),
|
||||||
_title(),
|
_title(),
|
||||||
_collapsible(false),
|
_collapsible(false),
|
||||||
_collapsed(false)
|
_collapsed(false),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +68,8 @@ Frame::Frame(const std::string& name, const std::string& title):
|
|||||||
_pChild(),
|
_pChild(),
|
||||||
_title(title),
|
_title(title),
|
||||||
_collapsible(false),
|
_collapsible(false),
|
||||||
_collapsed(false)
|
_collapsed(false),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +79,8 @@ Frame::Frame(View::Ptr pChild):
|
|||||||
_pChild(),
|
_pChild(),
|
||||||
_title(),
|
_title(),
|
||||||
_collapsible(false),
|
_collapsible(false),
|
||||||
_collapsed(false)
|
_collapsed(false),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
@@ -87,7 +91,8 @@ Frame::Frame(const std::string& name, View::Ptr pChild):
|
|||||||
_pChild(),
|
_pChild(),
|
||||||
_title(),
|
_title(),
|
||||||
_collapsible(false),
|
_collapsible(false),
|
||||||
_collapsed(false)
|
_collapsed(false),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
@@ -98,7 +103,8 @@ Frame::Frame(const std::string& name, const std::string& title, View::Ptr pChild
|
|||||||
_pChild(),
|
_pChild(),
|
||||||
_title(title),
|
_title(title),
|
||||||
_collapsible(false),
|
_collapsible(false),
|
||||||
_collapsed(false)
|
_collapsed(false),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
@@ -109,7 +115,8 @@ Frame::Frame(const std::type_info& type):
|
|||||||
_pChild(),
|
_pChild(),
|
||||||
_title(),
|
_title(),
|
||||||
_collapsible(false),
|
_collapsible(false),
|
||||||
_collapsed(false)
|
_collapsed(false),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +126,8 @@ Frame::Frame(const std::string& name, const std::type_info& type):
|
|||||||
_pChild(),
|
_pChild(),
|
||||||
_title(),
|
_title(),
|
||||||
_collapsible(false),
|
_collapsible(false),
|
||||||
_collapsed(false)
|
_collapsed(false),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +137,8 @@ Frame::Frame(View::Ptr pChild, const std::type_info& type):
|
|||||||
_pChild(),
|
_pChild(),
|
||||||
_title(),
|
_title(),
|
||||||
_collapsible(false),
|
_collapsible(false),
|
||||||
_collapsed(false)
|
_collapsed(false),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
@@ -140,7 +149,8 @@ Frame::Frame(const std::string& name, View::Ptr pChild, const std::type_info& ty
|
|||||||
_pChild(),
|
_pChild(),
|
||||||
_title(),
|
_title(),
|
||||||
_collapsible(false),
|
_collapsible(false),
|
||||||
_collapsed(false)
|
_collapsed(false),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
|
@@ -54,7 +54,8 @@ const std::string ListBoxCell::ARG_ROW("row");
|
|||||||
ListBoxCell::ListBoxCell(View* pOwner):
|
ListBoxCell::ListBoxCell(View* pOwner):
|
||||||
Cell(pOwner, typeid(ListBoxCell)),
|
Cell(pOwner, typeid(ListBoxCell)),
|
||||||
_data(),
|
_data(),
|
||||||
_fmtCache()
|
_fmtCache(),
|
||||||
|
_autoScroll(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +63,8 @@ ListBoxCell::ListBoxCell(View* pOwner):
|
|||||||
ListBoxCell::ListBoxCell(View* pOwner, const std::type_info& type):
|
ListBoxCell::ListBoxCell(View* pOwner, const std::type_info& type):
|
||||||
Cell(pOwner, type),
|
Cell(pOwner, type),
|
||||||
_data(),
|
_data(),
|
||||||
_fmtCache()
|
_fmtCache(),
|
||||||
|
_autoScroll(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +79,7 @@ void ListBoxCell::handleForm(const std::string& field, const std::string& value)
|
|||||||
// a ListBox inside a form will just send the selected values
|
// a ListBox inside a form will just send the selected values
|
||||||
// may contain multiple values like "field: 1,3"
|
// may contain multiple values like "field: 1,3"
|
||||||
// a deselectAll() would be wrong event wise
|
// a deselectAll() would be wrong event wise
|
||||||
Poco::StringTokenizer tok(value, ",", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
|
Poco::StringTokenizer tok(value, ", []", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
|
||||||
std::set<int> selected;
|
std::set<int> selected;
|
||||||
for (Poco::StringTokenizer::Iterator it = tok.begin(); it != tok.end(); ++it)
|
for (Poco::StringTokenizer::Iterator it = tok.begin(); it != tok.end(); ++it)
|
||||||
{
|
{
|
||||||
@@ -140,9 +142,8 @@ ListBoxCell::Data::const_iterator ListBoxCell::find(const Any& elem) const
|
|||||||
|
|
||||||
void ListBoxCell::setElements(const Data& elems)
|
void ListBoxCell::setElements(const Data& elems)
|
||||||
{
|
{
|
||||||
|
clearElements();
|
||||||
_data = elems;
|
_data = elems;
|
||||||
// update _fmtCache
|
|
||||||
_fmtCache.clear();
|
|
||||||
Formatter::Ptr ptr = getFormatter();
|
Formatter::Ptr ptr = getFormatter();
|
||||||
Data::iterator it = _data.begin();
|
Data::iterator it = _data.begin();
|
||||||
for (; it != _data.end(); ++it)
|
for (; it != _data.end(); ++it)
|
||||||
|
@@ -48,7 +48,8 @@ Panel::Panel():
|
|||||||
_modal(false),
|
_modal(false),
|
||||||
_showCloseIcon(true),
|
_showCloseIcon(true),
|
||||||
_showHeader(true),
|
_showHeader(true),
|
||||||
_enabled(true)
|
_enabled(true),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +61,8 @@ Panel::Panel(const std::string& name):
|
|||||||
_modal(false),
|
_modal(false),
|
||||||
_showCloseIcon(true),
|
_showCloseIcon(true),
|
||||||
_showHeader(true),
|
_showHeader(true),
|
||||||
_enabled(true)
|
_enabled(true),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +74,8 @@ Panel::Panel(const std::string& name, const std::string& title):
|
|||||||
_modal(false),
|
_modal(false),
|
||||||
_showCloseIcon(true),
|
_showCloseIcon(true),
|
||||||
_showHeader(true),
|
_showHeader(true),
|
||||||
_enabled(true)
|
_enabled(true),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +87,8 @@ Panel::Panel(View::Ptr pChild):
|
|||||||
_modal(false),
|
_modal(false),
|
||||||
_showCloseIcon(true),
|
_showCloseIcon(true),
|
||||||
_showHeader(true),
|
_showHeader(true),
|
||||||
_enabled(true)
|
_enabled(true),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
@@ -97,7 +101,8 @@ Panel::Panel(const std::string& name, View::Ptr pChild):
|
|||||||
_modal(false),
|
_modal(false),
|
||||||
_showCloseIcon(true),
|
_showCloseIcon(true),
|
||||||
_showHeader(true),
|
_showHeader(true),
|
||||||
_enabled(true)
|
_enabled(true),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
@@ -110,7 +115,8 @@ Panel::Panel(const std::string& name, const std::string& title, View::Ptr pChild
|
|||||||
_modal(false),
|
_modal(false),
|
||||||
_showCloseIcon(true),
|
_showCloseIcon(true),
|
||||||
_showHeader(true),
|
_showHeader(true),
|
||||||
_enabled(true)
|
_enabled(true),
|
||||||
|
_showBorder(true)
|
||||||
{
|
{
|
||||||
setChild(pChild);
|
setChild(pChild);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user