# HG changeset patch # User Thinker K.F. Li # Date 1248851017 -28800 # Node ID 331467b8e77897332c044fef2776abc7dab8418d # Parent bf1addb037b714bd96d21e4328c3d9f32436b1b1 Make calcuator uses stext instead of text. It is a demo for sh_stext. To use stext, program should call functions of stext and invoke svg2code.py with '-s' option. diff -r bf1addb037b7 -r 331467b8e778 examples/calculator/Makefile.am --- a/examples/calculator/Makefile.am Wed Jul 29 15:03:26 2009 +0800 +++ b/examples/calculator/Makefile.am Wed Jul 29 15:03:37 2009 +0800 @@ -12,7 +12,7 @@ CLEANFILES = calculator_scr.c calculator_scr.h calculator_scr.mb calculator_scr.mb: $(srcdir)/calculator_scr.svg - $(top_srcdir)/tools/svg2code.py $? $@ + $(top_srcdir)/tools/svg2code.py -s $? $@ calculator_scr.h: calculator_scr.mb m4 -I $(top_srcdir)/tools mb_c_header.m4 $< > $@ diff -r bf1addb037b7 -r 331467b8e778 examples/calculator/main.c --- a/examples/calculator/main.c Wed Jul 29 15:03:26 2009 +0800 +++ b/examples/calculator/main.c Wed Jul 29 15:03:37 2009 +0800 @@ -1,4 +1,5 @@ #include +#include #include #include "calculator_scr.h" @@ -66,14 +67,20 @@ rdman = X_MB_rdman(calc_data->rt); sprintf(buf, "%d%s", num, suffix); - sh_text_set_text(calc_data->code->screen_text_u, buf); + sh_stext_set_text(calc_data->code->screen_text_u, buf); + calc_data->code->screen_text_u_style_blks[0].n_chars = strlen(buf); + sh_stext_set_style(calc_data->code->screen_text_u, + calc_data->code->screen_text_u_style_blks, 1); rdman_shape_changed(rdman, calc_data->code->screen_text_u); if(op == 'n') sprintf(buf, "None"); else sprintf(buf, "%d%c", saved, op); - sh_text_set_text(calc_data->code->saved_text, buf); + sh_stext_set_text(calc_data->code->saved_text, buf); + calc_data->code->saved_text_style_blks[0].n_chars = strlen(buf); + sh_stext_set_style(calc_data->code->saved_text, + calc_data->code->saved_text_style_blks, 1); rdman_shape_changed(rdman, calc_data->code->saved_text); }