void decl_radio(const char *name, int *sel, ...) { va_list ap; int i; const char *o; va_start(ap, name); if (mode == 'w') { for (i = 0; o = va_arg(ap, const char *); i++) { startnode("radio"); attr("name", "%s", name); attr("value", "%s", o); if (i == *sel) attr("checked", "%s", ""); endnode(); } } if (mode == 'r') { for (i = 0; o = va_arg(ap, const char *); i++) { if (nodeis("radio") && attris("name", name) && attris("value", o) && attris("checked", "")) *sel = i; } } va_end(ap); }
void elemtag(std::string& id, AttriMap& m) { if (tryConsumeToken(TT_id)) { id = getPreviewToken().value; attris(m); } }
void decl_btn(const char *name, void (*cb)(const char *)) { if (mode == 'w') { startnode("button"); attr("name", "%s", name); endnode(); } if (mode == 'r' && acting && nodeis("button") && attris("name", name)) cb(name); }
void decl_var_float(const char *name, float *p, float min, float max) { if (mode == 'w') { startnode("float"); attr("name", "%s", name); attr("max", "%f", max); attr("min", "%f", min); attr("val", "%f", *p); endnode(); } if (mode == 'r' && nodeis("float") && attris("name", name)) { float v; if (getattr("val", "%f", &v) && v >= min && v <= max) *p = v; } }