Example #1
0
// iup.Attr(key,value), iup.Attrs(k1,v1,v2,v2,...) ,
// string , IHandle , func(arg *Action)
func New(classname string, a ...interface{}) *Handle {
	cname := NewCS(classname)
	defer FreeCS(cname)
	ptr := C.IupCreate(cname)
	if ptr == nil {
		return nil
	}
	h := NewHandle(ptr)
	if len(a) == 0 {
		return h
	}
	children, attrs, sattrs, funcs := parser(a)
	for i := 0; i < len(children); i++ {
		h.Append(children[i])
	}
	for i := 0; i < len(attrs); i++ {
		h.SetAttribute(attrs[i].Name(), attrs[i].Value())
	}
	for i := 0; i < len(sattrs); i++ {
		h.SetAttributes(sattrs[i])
	}
	for i := 0; i < len(funcs); i++ {
		h.SetCallback(funcs[i])
	}
	return h
}
Example #2
0
func Create(classname string) *Ihandle {
	cClassname := C.CString(classname)
	defer C.free(unsafe.Pointer(cClassname))

	return (*Ihandle)(C.IupCreate(cClassname))
}