comparison examples/calculator/main.c @ 432:331467b8e778

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.
author Thinker K.F. Li <thinker@branda.to>
date Wed, 29 Jul 2009 15:03:37 +0800
parents c8b6ca46950b
children 32425882e351
comparison
equal deleted inserted replaced
431:bf1addb037b7 432:331467b8e778
1 #include <stdio.h> 1 #include <stdio.h>
2 #include <string.h>
2 #include <mb.h> 3 #include <mb.h>
3 #include "calculator_scr.h" 4 #include "calculator_scr.h"
4 5
5 typedef struct _calc_data calc_data_t; 6 typedef struct _calc_data calc_data_t;
6 struct _calc_data { 7 struct _calc_data {
64 redraw_man_t *rdman; 65 redraw_man_t *rdman;
65 66
66 rdman = X_MB_rdman(calc_data->rt); 67 rdman = X_MB_rdman(calc_data->rt);
67 68
68 sprintf(buf, "%d%s", num, suffix); 69 sprintf(buf, "%d%s", num, suffix);
69 sh_text_set_text(calc_data->code->screen_text_u, buf); 70 sh_stext_set_text(calc_data->code->screen_text_u, buf);
71 calc_data->code->screen_text_u_style_blks[0].n_chars = strlen(buf);
72 sh_stext_set_style(calc_data->code->screen_text_u,
73 calc_data->code->screen_text_u_style_blks, 1);
70 rdman_shape_changed(rdman, calc_data->code->screen_text_u); 74 rdman_shape_changed(rdman, calc_data->code->screen_text_u);
71 75
72 if(op == 'n') 76 if(op == 'n')
73 sprintf(buf, "None"); 77 sprintf(buf, "None");
74 else 78 else
75 sprintf(buf, "%d%c", saved, op); 79 sprintf(buf, "%d%c", saved, op);
76 sh_text_set_text(calc_data->code->saved_text, buf); 80 sh_stext_set_text(calc_data->code->saved_text, buf);
81 calc_data->code->saved_text_style_blks[0].n_chars = strlen(buf);
82 sh_stext_set_style(calc_data->code->saved_text,
83 calc_data->code->saved_text_style_blks, 1);
77 rdman_shape_changed(rdman, calc_data->code->saved_text); 84 rdman_shape_changed(rdman, calc_data->code->saved_text);
78 } 85 }
79 86
80 static void compute(calc_data_t *calc_data, coord_t *tgt) { 87 static void compute(calc_data_t *calc_data, coord_t *tgt) {
81 int i; 88 int i;