/** Set value of the DOM element. Sets value for elements recognized by get_ctl_type() function. * \param[in] el \b const dom::element&, The element. * \param[in] v \b const value_t&, The value. **/ inline void set_value(dom::element& el, const value_t& v ) { switch(get_ctl_type(el)) { case CTL_UNKNOWN: break; case CTL_EDIT: case CTL_DECIMAL: case CTL_CURRENCY: case CTL_PASSWORD: case CTL_NUMERIC: case CTL_PROGRESS: case CTL_SLIDER: case CTL_SELECT_SINGLE: case CTL_SELECT_MULTIPLE: case CTL_DD_SELECT: case CTL_TEXTAREA: case CTL_DATE: case CTL_CALENDAR: case CTL_HIDDEN: default: el.set_value(v); break; // special cases: case CTL_BUTTON: break; case CTL_CHECKBOX: set_checkbox_bits(el,v); break; case CTL_RADIO: set_radio_index(el,v); break; case CTL_HTMLAREA: { utf8::ostream os; os << v.get( L"" ); el.set_html( os.data(), os.length() ); el.update(); } break; case CTL_NO: assert(false); break; } }
/** Set value of the DOM element. Sets value for elements recognized by get_ctl_type() function. * \param[in] el \b const dom::element&, The element. * \param[in] v \b const json::value&, The value. **/ inline void set_value(dom::element& el, const json::value& v ) { switch(get_ctl_type(el)) { case CTL_UNKNOWN: break; case CTL_EDIT: case CTL_DECIMAL: case CTL_CURRENCY: case CTL_PASSWORD: case CTL_NUMERIC: case CTL_PROGRESS: case CTL_SLIDER: case CTL_SELECT_SINGLE: case CTL_SELECT_MULTIPLE: case CTL_DD_SELECT: case CTL_TEXTAREA: case CTL_DATE: case CTL_CALENDAR: case CTL_HIDDEN: default: el.set_value(v); break; // special cases: case CTL_BUTTON: break; case CTL_CHECKBOX: set_checkbox_bits(el,v); break; case CTL_RADIO: set_radio_index(el,v); break; case CTL_HTMLAREA: { aux::w2utf utf8(static_cast<const wchar_t*>(v.get( L"" ))); el.set_html( utf8, utf8.length() ); //el.update(); } break; case CTL_NO: assert(false); break; } }