void svg_sani_init_a(Render2D *sr, GF_Node *node) { SVG_SANI_handlerElement *handler; gf_node_set_callback_function(node, svg_sani_render_a); /*listener for onClick event*/ handler = gf_dom_listener_build(node, GF_EVENT_CLICK, 0, NULL); /*and overwrite handler*/ handler->handle_event = svg_sani_a_HandleEvent; gf_node_set_private((GF_Node *)handler, sr->compositor); /*listener for activate event*/ handler = gf_dom_listener_build(node, GF_EVENT_ACTIVATE, 0, NULL); /*and overwrite handler*/ handler->handle_event = svg_sani_a_HandleEvent; gf_node_set_private((GF_Node *)handler, sr->compositor); /*listener for mouseover event*/ handler = gf_dom_listener_build(node, GF_EVENT_MOUSEOVER, 0, NULL); /*and overwrite handler*/ handler->handle_event = svg_sani_a_HandleEvent; gf_node_set_private((GF_Node *)handler, sr->compositor); }
void compositor_init_svg_a(GF_Compositor *compositor, GF_Node *node) { SVG_handlerElement *handler; gf_node_set_callback_function(node, svg_traverse_a); /*listener for onClick event*/ handler = gf_dom_listener_build(node, GF_EVENT_CLICK, 0); /*and overwrite handler*/ handler->handle_event = svg_a_handle_event; gf_node_set_private((GF_Node *)handler, compositor); /*listener for activate event*/ handler = gf_dom_listener_build(node, GF_EVENT_ACTIVATE, 0); /*and overwrite handler*/ handler->handle_event = svg_a_handle_event; gf_node_set_private((GF_Node *)handler, compositor); /*listener for mousemove event*/ handler = gf_dom_listener_build(node, GF_EVENT_MOUSEOVER, 0); /*and overwrite handler*/ handler->handle_event = svg_a_handle_event; gf_node_set_private((GF_Node *)handler, compositor); }
Bool osd_load_scene(GF_OSD *osd) { GF_Node *n; GF_List *nodes; const char *opt; GF_DOMHandler *hdl; /*BT/VRML from string*/ GF_List *gf_sm_load_bt_from_string(GF_SceneGraph *in_scene, const char *node_str, Bool force_wrl); /*create a new scene*/ osd->odm = gf_odm_new(); osd->odm->term = osd->term; osd->odm->subscene = gf_scene_new(NULL); osd->odm->subscene->root_od = osd->odm; gf_sg_set_scene_size_info(osd->odm->subscene->graph, 0, 0, 1); /*create a scene graph*/ nodes = gf_sm_load_bt_from_string(osd->odm->subscene->graph, osd_scene_graph, 0); n = gf_list_get(nodes, 0); gf_list_del(nodes); if (!n) return 0; gf_sg_set_root_node(osd->odm->subscene->graph, n); gf_sg_set_scene_size_info(osd->odm->subscene->graph, 0, 0, 1); hdl = gf_dom_listener_build(n, GF_EVENT_RESIZE, 0); hdl->handle_event = osd_on_resize; hdl->evt_listen_obj = osd; osd->visible = (M_Switch *)gf_sg_find_node_by_name(osd->odm->subscene->graph, "N1"); osd->transform = (M_Transform2D *)gf_sg_find_node_by_name(osd->odm->subscene->graph, "N2"); osd->ct2d = (M_CompositeTexture2D *)gf_sg_find_node_by_name(osd->odm->subscene->graph, "N3"); osd->text = (M_Text *)gf_sg_find_node_by_name(osd->odm->subscene->graph, "N4"); if (osd->text->string.vals[0]) { gf_free(osd->text->string.vals[0]); osd->text->string.vals[0] = NULL; } strcpy(osd->statBuffer, "Hello World !"); osd->text->string.vals[0] = osd->statBuffer; opt = gf_cfg_get_key(osd->term->user->config, "OSD", "Visible"); if (!opt || strcmp(opt, "yes")) osd->visible->whichChoice = -1; return 1; }
void compositor_init_svg_font(GF_Compositor *compositor, GF_Node *node) { SVG_handlerElement *handler; GF_Err e; SVGAllAttributes atts; GF_Font *font; GF_Node *node_font = gf_node_get_parent(node, 0); if (!node_font) return; if (gf_node_get_tag(node_font)!=TAG_SVG_font) return; gf_svg_flatten_attributes((SVG_Element*)node, &atts); if (!atts.font_family) return; /*register font to font manager*/ GF_SAFEALLOC(font, GF_Font); e = gf_font_manager_register_font(compositor->font_manager, font); if (e) { gf_free(font); return; } font->ft_mgr = compositor->font_manager; font->get_glyphs = svg_font_get_glyphs; font->load_glyph = svg_font_load_glyph; font->udta = node_font; gf_node_set_private(node_font, font); gf_node_set_callback_function(node_font, svg_traverse_font); font->name = gf_strdup(atts.font_family->value); font->em_size = atts.units_per_em ? FIX2INT( gf_ceil(atts.units_per_em->value) ) : 1000; /*Inconsistency between SVG 1.2 and 1.1 when not specify, ascent and descent are computed based on font.vert-origin-y, WHICH DOES NOT EXIST IN Tiny 1.2 !!! We assume it to be 0. */ font->ascent = atts.ascent ? FIX2INT( gf_ceil(atts.ascent->value) ) : 0; if (!font->ascent) font->ascent = font->em_size; font->descent = atts.descent ? FIX2INT( gf_ceil(atts.descent->value) ) : 0; font->baseline = atts.alphabetic ? FIX2INT( gf_ceil(atts.alphabetic->value) ) : 0; font->line_spacing = font->em_size; font->styles = 0; if (atts.font_style) { switch (*atts.font_style) { case SVG_FONTSTYLE_ITALIC: font->styles |= GF_FONT_ITALIC; break; case SVG_FONTSTYLE_OBLIQUE: font->styles |= GF_FONT_OBLIQUE; break; } } if (atts.font_variant && (*atts.font_variant ==SVG_FONTVARIANT_SMALLCAPS)) font->styles |= GF_FONT_SMALLCAPS; if (atts.font_weight) { switch(*atts.font_weight) { case SVG_FONTWEIGHT_100: font->styles |= GF_FONT_WEIGHT_100; break; case SVG_FONTWEIGHT_LIGHTER: font->styles |= GF_FONT_WEIGHT_LIGHTER; break; case SVG_FONTWEIGHT_200: font->styles |= GF_FONT_WEIGHT_200; break; case SVG_FONTWEIGHT_300: font->styles |= GF_FONT_WEIGHT_300; break; case SVG_FONTWEIGHT_400: font->styles |= GF_FONT_WEIGHT_400; break; case SVG_FONTWEIGHT_NORMAL: font->styles |= GF_FONT_WEIGHT_NORMAL; break; case SVG_FONTWEIGHT_500: font->styles |= GF_FONT_WEIGHT_500; break; case SVG_FONTWEIGHT_600: font->styles |= GF_FONT_WEIGHT_600; break; case SVG_FONTWEIGHT_700: font->styles |= GF_FONT_WEIGHT_700; break; case SVG_FONTWEIGHT_BOLD: font->styles |= GF_FONT_WEIGHT_BOLD; break; case SVG_FONTWEIGHT_800: font->styles |= GF_FONT_WEIGHT_800; break; case SVG_FONTWEIGHT_900: font->styles |= GF_FONT_WEIGHT_900; break; case SVG_FONTWEIGHT_BOLDER: font->styles |= GF_FONT_WEIGHT_BOLDER; break; } } gf_svg_flatten_attributes((SVG_Element*)node_font, &atts); font->max_advance_h = atts.horiz_adv_x ? FIX2INT( gf_ceil(atts.horiz_adv_x->value) ) : 0; font->not_loaded = 1; /*wait for onLoad event before activating the font, otherwise we may not have all the glyphs*/ handler = gf_dom_listener_build(node_font, GF_EVENT_LOAD, 0); handler->handle_event = svg_font_on_load; gf_node_set_private((GF_Node *)handler, compositor); }