[Cppcms-users] [PATCH] Add support for readonly HTML attribute
Brought to you by:
artyom-beilis
From: Christian G. <chr...@gm...> - 2012-09-27 06:16:38
|
This patch adds support for readonly HTML attribute [0]. [0] http://www.w3schools.com/tags/att_input_readonly.asp Signed-off-by: Christian Gmeiner <chr...@gm...> --- diff -Nur build_org/dependencies/src/cppcms-1.0.2/cppcms/form.h build/dependencies/src/cppcms-1.0.2/cppcms/form.h --- build_org/dependencies/src/cppcms-1.0.2/cppcms/form.h 2012-08-14 09:42:24.000000000 +0200 +++ build/dependencies/src/cppcms-1.0.2/cppcms/form.h 2012-09-26 18:32:21.869608847 +0200 @@ -533,6 +533,17 @@ /// void disabled(bool); + + /// + /// Get the HTML \c readonly attribute. + /// + bool readonly(); + + /// + /// Set/Unset the HTML \c readonly attribute. + /// + void readonly(bool); + /// /// Get the general user defined attribute string that can be added to the widget. /// @@ -685,11 +696,12 @@ uint32_t is_valid_ : 1; uint32_t is_set_ : 1; uint32_t is_disabled_ : 1; + uint32_t is_readonly_ : 1; uint32_t is_generation_done_ : 1; uint32_t has_message_ : 1; uint32_t has_error_ : 1; uint32_t has_help_ : 1; - uint32_t reserverd_ : 25; + uint32_t reserverd_ : 24; struct _data; booster::hold_ptr<_data> d; diff -Nur build_org/dependencies/src/cppcms-1.0.2/src/form.cpp build/dependencies/src/cppcms-1.0.2/src/form.cpp --- build_org/dependencies/src/cppcms-1.0.2/src/form.cpp 2012-08-14 09:42:24.000000000 +0200 +++ build/dependencies/src/cppcms-1.0.2/src/form.cpp 2012-09-26 18:23:51.181619376 +0200 @@ -280,6 +280,7 @@ is_valid_(1), is_set_(0), is_disabled_(0), + is_readonly_(0), is_generation_done_(0), has_message_(0), has_error_(0), @@ -411,6 +412,16 @@ is_disabled_=v; } +bool base_widget::readonly() +{ + return is_readonly_; +} + +void base_widget::readonly(bool v) +{ + is_readonly_=v; +} + std::string base_widget::attributes_string() { return attr_; @@ -676,6 +687,9 @@ if(lm.second >= 0 && validate_charset()) { output << boost::format("maxlength=\"%1%\" ",std::locale::classic()) % lm.second; } + if(readonly()) { + output << "readonly=\"readonly\""; + } } |