Mercurial > MadButterfly
changeset 286:22d771e1b710
Add text program for text API
author | wycc |
---|---|
date | Sat, 31 Jan 2009 16:54:03 +0800 |
parents | 248a40d51473 |
children | 5c066380a84e |
files | examples/dynamic/mytext.svg examples/dynamic/text.c |
diffstat | 2 files changed, 176 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/dynamic/mytext.svg Sat Jan 31 16:54:03 2009 +0800 @@ -0,0 +1,105 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:ns0="http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="640px" + height="480px" + id="svg2383" + sodipodi:version="0.32" + inkscape:version="0.46" + sodipodi:docname="text.svg" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.77472527" + inkscape:cx="132.83688" + inkscape:cy="240" + inkscape:current-layer="layer1" + inkscape:document-units="px" + showgrid="false" + inkscape:window-width="1400" + inkscape:window-height="978" + inkscape:window-x="0" + inkscape:window-y="25" /> + <defs + id="defs2385"> + <inkscape:perspective + id="perspective2391" + inkscape:persp3d-origin="320 : 160 : 1" + inkscape:vp_z="640 : 240 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 240 : 1" + sodipodi:type="inkscape:persp3d" /> + </defs> + <metadata + id="metadata2388"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + <ns0:scenes + current="3"> + <ns0:scene + ref="s7737" + start="1" /> + <ns0:scene + ref="s4405" + start="2" /> + <ns0:scene + ref="s4702" + start="3" /> + </ns0:scenes> + </metadata> + <g + inkscape:groupmode="layer" + inkscape:label="Layer 1" + id="layer1"> + <g + id="s7737"> + <text + xml:space="preserve" + style="font-size:24px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" + x="188.4539" + y="189.57446" + id="text2554"><tspan + sodipodi:role="line" + id="mytext" + x="188.4539" + y="189.57446" + mbname="mytext">This is scene 1</tspan></text> + </g> + <g + style="display:none" + id="s4405"> + <text + id="text2576" + y="199.90071" + x="196.19858" + style="font-size:24px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + y="199.90071" + x="196.19858" + id="tspan2578" + sodipodi:role="line">This is scene 2</tspan></text> + </g> + <g + id="s4702" + style="" /> + </g> +</svg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/dynamic/text.c Sat Jan 31 16:54:03 2009 +0800 @@ -0,0 +1,71 @@ +/*! \file + * + * svg2code_ex is an example that show programmers how to create a + * menu with MadButterfly. + * + */ +#include <stdio.h> +#include <mb.h> +#include <string.h> +#include "menu.h" +#include "mbapp.h" + + +MBApp *myApp; + +typedef struct { + shape_t *rect; + co_aix orx,ory; + int start_x,start_y; + observer_t *obs1,*obs2; + int currentscene; +}MyAppData; + + +void switch_scene(const mb_timeval_t *tmo, const mb_timeval_t *now,void *arg) +{ + MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData ); + mb_timeval_t timer,interval; + shape_t *text = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite,"mytext"); + + + get_now(&timer); + MB_TIMEVAL_SET(&interval, 1 ,0); + MB_TIMEVAL_ADD(&timer, &interval); + mb_tman_timeout( MBApp_getTimer(myApp), &timer, switch_scene, myApp); + + en->currentscene = (en->currentscene + 1) % 2; + printf("xxx\n"); + if (en->currentscene == 0) { + sh_text_set_text(text,"This is 0"); + } else { + sh_text_set_text(text,"This is 1"); + } + rdman_shape_changed(MBAPP_RDMAN(myApp), text); + rdman_redraw_changed(MBAPP_RDMAN(myApp)); +} + +int main(int argc, char * const argv[]) { + subject_t *subject; + mb_button_t *b; + mb_obj_t *button; + MyAppData data; + mb_timeval_t tmo,interval; + + if (argc > 1) + myApp = MBApp_Init(argv[1]); + else + myApp = MBApp_Init("mytext"); + data.currentscene=0; + MBApp_setData(myApp,&data); + get_now(&tmo); + MB_TIMEVAL_SET(&interval, 1 ,0); + mb_tman_timeout( MBApp_getTimer(myApp), &tmo, switch_scene, myApp); + + + MBApp_loop(myApp); + + return 0; +} + +/* vim: set ts=4 */