Esempio n. 1
0
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);
}
Esempio n. 2
0
 void elemtag(std::string& id, AttriMap& m)
 {
     if (tryConsumeToken(TT_id)) {
         id = getPreviewToken().value;
         attris(m);
     }
 }
Esempio n. 3
0
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);
}
Esempio n. 4
0
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;
	}
}