示例#1
0
void scripto_dblclick(t_scripto *x)
{
	if (x->s_patcher)
		object_method(x->s_patcher, gensym("vis"));
	else {
		t_dictionary *d = dictionary_new();
		char parsebuf[256];
		t_atom a;
		long ac = 0;
		t_atom *av = NULL;

		// create a patcher without scroll bars and a toolbar
		sprintf(parsebuf,"@defrect 0 0 300 400 @title scripto @enablehscroll 0 @enablevscroll 0 @presentation 0 @toolbarid \"\"");
		atom_setparse(&ac,&av,parsebuf);
		attr_args_dictionary(d,ac,av);
		atom_setobj(&a,d);
		sysmem_freeptr(av);
		x->s_patcher = (t_object *)object_new_typed(CLASS_NOBOX,gensym("jpatcher"),1, &a);
		freeobject((t_object *)d);	// we created this dictionary and we don't need it anymore

		object_method(x->s_patcher,gensym("vis"));
		x->s_ui = newobject_sprintf(x->s_patcher, "@maxclass scripto_ui @patching_rect 0 0 300 400 @oncolor %.2f %.2f %.2f %.2f @offcolor %.2f %.2f %.2f %.2f",
									x->s_oncolor.red, x->s_oncolor.green, x->s_oncolor.blue, x->s_oncolor.alpha, x->s_offcolor.red, x->s_offcolor.green, x->s_offcolor.blue, x->s_offcolor.alpha);
		object_attach_byptr_register(x, x->s_ui, CLASS_BOX);			// attach our UI object to us
		object_attach_byptr_register(x, x->s_patcher, CLASS_NOBOX);		// attach our UI object to us
	}
}
示例#2
0
// Don't pass memory in for this function!  It will allocate what it needs
// -- then the caller is responsible for freeing
void jamoma_patcher_getargs(t_object *patcher, long *argc, t_atom **argv)
{
	t_symbol		*context = jamoma_patcher_getcontext(patcher);
	t_object		*box = object_attr_getobj(patcher, jps_box);
	t_object		*textfield = NULL;
	char			*text = NULL;
	unsigned long	textlen = 0;

	if(context == gensym("bpatcher"))
		object_attr_getvalueof(box, gensym("args"), argc, argv);
	else if(context == gensym("subpatcher")){
		textfield = object_attr_getobj(box, gensym("textfield"));
		object_method(textfield, gensym("gettextptr"), &text, &textlen);
		atom_setparse(argc, argv, text);
	}
	else{
		*argc = 0;
		*argv = NULL;
	}
}