various extensions

This commit is contained in:
Peter Schojer 2008-09-30 08:47:32 +00:00
parent 5c9977d79a
commit 8ae571b205
11 changed files with 153 additions and 25 deletions

View File

@ -79,7 +79,9 @@ public:
/// Renders button properties
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);

View File

@ -109,6 +109,8 @@ void FrameRenderer::writeProperties(const Frame* pFrame, std::ostream& ostr)
ostr << ",x:" << pFrame->getPosition().posX << ",y:" << pFrame->getPosition().posY;
if (pFrame->hasClass())
ostr << ",cls:'" << pFrame->getClass() << "'";
if (!pFrame->showBorder())
ostr << ",border:false,bodyBorder:false";
}

View File

@ -95,10 +95,13 @@ void ListBoxCellRenderer::renderProperties(const ListBoxCell* pListBoxCell, std:
if (pOwner->hasPosition())
ostr << ",x:" << pOwner->getPosition().posX << ",y:" << pOwner->getPosition().posY;
if (!pListBoxCell->autoScroll())
ostr << ",autoScroll:false";
if (pList)
{
bool hasListeners = pList->selectionChanged.hasJavaScriptCode();
bool hasListeners = pList->selectionChanged.hasJavaScriptCode() || !pList->rowSelected.empty() || !pList->rowDeselected.empty();
if (hasListeners)
{
ostr << ",listeners:{";
@ -157,9 +160,9 @@ void ListBoxCellRenderer::renderProperties(const ListBoxCell* pListBoxCell, std:
Poco::WebWidgets::JSDelegate ListBoxCellRenderer::createSelectionChangedServerCallback(const ListBox* pList)
{
// 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;
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));
return Utility::createServerCallback(signature, addParams, pList->id(), pList->selectionChanged.getOnSuccess(), pList->selectionChanged.getOnFailure());
}

View File

@ -155,6 +155,8 @@ void PanelRenderer::renderHeadWithoutChildren(const Panel* pPanel, const RenderC
if (!pPanel->enabled())
ostr << ",disabled:true";
if (!pPanel->showBorder())
ostr << ",border:false,bodyBorder:false";
ostr << "})";
}

View File

@ -103,6 +103,10 @@ public:
bool collapsed() const;
/// Returns how the Frame should be rendered initially
void showBorder(bool show);
bool showBorder() const;
protected:
Frame(const std::type_info& type);
@ -125,6 +129,7 @@ private:
std::string _title;
bool _collapsible;
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

View File

@ -87,9 +87,23 @@ public:
Data::iterator end();
/// Iterator to all elements
void clearElements();
/// Removes all elements
void setElements(const Data& elems);
/// 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;
/// Returns all elements
@ -123,6 +137,12 @@ public:
const Any& getSelected() const;
/// Returns the first selected element, exception if none was selected
void autoScroll(bool val = true);
// sets autoscrolling
bool autoScroll() const;
/// gets autoscroll
protected:
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

View File

@ -107,6 +107,9 @@ public:
StringData::const_iterator endString() const;
/// ConstIterator to all elements
void clearElements();
/// Removes all elements
void setElements(const Data& elems);
/// Initializes the combo box with the provided elements
@ -145,6 +148,12 @@ public:
/// Returns the first selected element, exception if none was selected.
/// To get all selected elements use getElements and iterate over the
/// returned vector
void autoScroll(bool val);
// sets autoscrolling
bool autoScroll() const;
/// gets autoscroll
// Cell
void handleForm(const std::string& field, const std::string& value);
@ -169,6 +178,7 @@ protected:
private:
Data _data;
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

View File

@ -114,6 +114,11 @@ public:
void enable(bool val);
bool enabled() const;
void showBorder(bool show);
bool showBorder() const;
protected:
~Panel();
/// Destroys the Panel.
@ -125,6 +130,7 @@ private:
bool _showCloseIcon;
bool _showHeader;
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

View File

@ -46,7 +46,8 @@ Frame::Frame():
_pChild(),
_title(),
_collapsible(false),
_collapsed(false)
_collapsed(false),
_showBorder(true)
{
}
@ -56,7 +57,8 @@ Frame::Frame(const std::string& name):
_pChild(),
_title(),
_collapsible(false),
_collapsed(false)
_collapsed(false),
_showBorder(true)
{
}
@ -66,7 +68,8 @@ Frame::Frame(const std::string& name, const std::string& title):
_pChild(),
_title(title),
_collapsible(false),
_collapsed(false)
_collapsed(false),
_showBorder(true)
{
}
@ -76,7 +79,8 @@ Frame::Frame(View::Ptr pChild):
_pChild(),
_title(),
_collapsible(false),
_collapsed(false)
_collapsed(false),
_showBorder(true)
{
setChild(pChild);
}
@ -87,7 +91,8 @@ Frame::Frame(const std::string& name, View::Ptr pChild):
_pChild(),
_title(),
_collapsible(false),
_collapsed(false)
_collapsed(false),
_showBorder(true)
{
setChild(pChild);
}
@ -98,7 +103,8 @@ Frame::Frame(const std::string& name, const std::string& title, View::Ptr pChild
_pChild(),
_title(title),
_collapsible(false),
_collapsed(false)
_collapsed(false),
_showBorder(true)
{
setChild(pChild);
}
@ -109,7 +115,8 @@ Frame::Frame(const std::type_info& type):
_pChild(),
_title(),
_collapsible(false),
_collapsed(false)
_collapsed(false),
_showBorder(true)
{
}
@ -119,7 +126,8 @@ Frame::Frame(const std::string& name, const std::type_info& type):
_pChild(),
_title(),
_collapsible(false),
_collapsed(false)
_collapsed(false),
_showBorder(true)
{
}
@ -129,7 +137,8 @@ Frame::Frame(View::Ptr pChild, const std::type_info& type):
_pChild(),
_title(),
_collapsible(false),
_collapsed(false)
_collapsed(false),
_showBorder(true)
{
setChild(pChild);
}
@ -140,7 +149,8 @@ Frame::Frame(const std::string& name, View::Ptr pChild, const std::type_info& ty
_pChild(),
_title(),
_collapsible(false),
_collapsed(false)
_collapsed(false),
_showBorder(true)
{
setChild(pChild);
}

View File

@ -54,7 +54,8 @@ const std::string ListBoxCell::ARG_ROW("row");
ListBoxCell::ListBoxCell(View* pOwner):
Cell(pOwner, typeid(ListBoxCell)),
_data(),
_fmtCache()
_fmtCache(),
_autoScroll(true)
{
}
@ -62,7 +63,8 @@ ListBoxCell::ListBoxCell(View* pOwner):
ListBoxCell::ListBoxCell(View* pOwner, const std::type_info& type):
Cell(pOwner, type),
_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
// may contain multiple values like "field: 1,3"
// 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;
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)
{
clearElements();
_data = elems;
// update _fmtCache
_fmtCache.clear();
Formatter::Ptr ptr = getFormatter();
Data::iterator it = _data.begin();
for (; it != _data.end(); ++it)

View File

@ -48,7 +48,8 @@ Panel::Panel():
_modal(false),
_showCloseIcon(true),
_showHeader(true),
_enabled(true)
_enabled(true),
_showBorder(true)
{
}
@ -60,7 +61,8 @@ Panel::Panel(const std::string& name):
_modal(false),
_showCloseIcon(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),
_showCloseIcon(true),
_showHeader(true),
_enabled(true)
_enabled(true),
_showBorder(true)
{
}
@ -84,7 +87,8 @@ Panel::Panel(View::Ptr pChild):
_modal(false),
_showCloseIcon(true),
_showHeader(true),
_enabled(true)
_enabled(true),
_showBorder(true)
{
setChild(pChild);
}
@ -97,7 +101,8 @@ Panel::Panel(const std::string& name, View::Ptr pChild):
_modal(false),
_showCloseIcon(true),
_showHeader(true),
_enabled(true)
_enabled(true),
_showBorder(true)
{
setChild(pChild);
}
@ -110,7 +115,8 @@ Panel::Panel(const std::string& name, const std::string& title, View::Ptr pChild
_modal(false),
_showCloseIcon(true),
_showHeader(true),
_enabled(true)
_enabled(true),
_showBorder(true)
{
setChild(pChild);
}