OSDN Git Service

disable press number action when NG by word.
[bbk/bchan.git] / src / bchan_vobj.c
1 /*
2  * bchan_vobj.c
3  *
4  * Copyright (c) 2010 project bchan
5  *
6  * This software is provided 'as-is', without any express or implied
7  * warranty. In no event will the authors be held liable for any damages
8  * arising from the use of this software.
9  *
10  * Permission is granted to anyone to use this software for any purpose,
11  * including commercial applications, and to alter it and redistribute it
12  * freely, subject to the following restrictions:
13  *
14  * 1. The origin of this software must not be misrepresented; you must not
15  *    claim that you wrote the original software. If you use this software
16  *    in a product, an acknowledgment in the product documentation would be
17  *    appreciated but is not required.
18  *
19  * 2. Altered source versions must be plainly marked as such, and must not be
20  *    misrepresented as being the original software.
21  *
22  * 3. This notice may not be removed or altered from any source
23  *    distribution.
24  *
25  */
26
27 #include    "bchan_vobj.h"
28
29 #include        <basic.h>
30 #include        <bstdlib.h>
31 #include        <bstdio.h>
32 #include        <btron/btron.h>
33 #include        <btron/vobj.h>
34 #include        <btron/hmi.h>
35
36 #include    "cache.h"
37
38 #ifdef BCHAN_CONFIG_DEBUG
39 # define DP(arg) printf arg
40 # define DP_ER(msg, err) printf("%s (%d/%x)\n", msg, err>>16, err)
41 #else
42 # define DP(arg) /**/
43 # define DP_ER(msg, err) /**/
44 #endif
45
46 LOCAL W adjust_vobj(VOBJSEG *seg, VLINK *vlnk)
47 {
48         RECT newr;
49         VID vid;
50         W err;
51
52         seg->view = (RECT){{0,0,300,20}};
53         seg->height = 100;
54         seg->chsz = 16;
55         seg->frcol = 0x10000000;
56         seg->chcol = 0x10000000;
57         err = wget_inf(WI_VOBJBGCOL, &seg->tbcol, sizeof(COLOR));
58         if (err < 0) {
59                 seg->tbcol = 0x10ffffff;
60         }
61         seg->bgcol = 0x10ffffff;
62         seg->dlen = 0;
63
64         vid = oreg_vob(vlnk, seg, -1, V_NODISP);
65         if (vid < 0) {
66                 DP_ER("oreg_vob", vid);
67                 return vid;
68         }
69         err = orsz_vob(vid, &newr, V_ADJUST1|V_NODISP);
70         if (err < 0) {
71                 DP_ER("orsz_vob", vid);
72                 odel_vob(vid, 0);
73                 return err;
74         }
75         seg->view = newr;
76         err = odel_vob(vid, 0);
77         if (err < 0) {
78                 DP_ER("odel_vob", err);
79                 return err;
80         }
81
82         return 0;
83 }
84
85 EXPORT W bchan_createbbbvobj(UB *fsn_bbb, W fsn_bbb_len, UB *fsn_texedit, W fsn_texedit_len, UB *taddata, W taddata_len, VOBJSEG *seg, LINK *lnk)
86 {
87         W fd, err;
88         UB bin[4+24];
89         TADSEG *base = (TADSEG*)bin;
90         INFOSEG *infoseg = (INFOSEG*)(bin + 4);
91         TEXTSEG *textseg = (TEXTSEG*)(bin + 4);
92
93         fd = cre_fil(lnk, (TC*)taddata, NULL, 0x31, F_FLOAT);
94         if (fd < 0) {
95                 DP_ER("cre_fil error", fd);
96                 return fd;
97         }
98
99         err = apd_rec(fd, fsn_bbb, fsn_bbb_len, 8, 0, 0);
100         if (err < 0) {
101                 DP_ER("apd_rec:fusen rec error", err);
102                 cls_fil(fd);
103                 del_fil(NULL, lnk, 0);
104                 return fd;
105         }
106
107         err = apd_rec(fd, fsn_texedit, fsn_texedit_len, 8, 0, 0);
108         if (err < 0) {
109                 DP_ER("apd_rec:fusen rec error", err);
110                 cls_fil(fd);
111                 del_fil(NULL, lnk, 0);
112                 return fd;
113         }
114
115         err = apd_rec(fd, NULL, 0, RT_TADDATA, 0, 0);
116         if (err < 0) {
117                 DP_ER("apd_rec:retrieve info error", err);
118                 cls_fil(fd);
119                 del_fil(NULL, lnk, 0);
120                 return fd;
121         }
122         err = see_rec(fd, -1, -1, NULL);
123         if (err < 0) {
124                 DP_ER("see_rec error", err);
125                 cls_fil(fd);
126                 del_fil(NULL, lnk, 0);
127                 return fd;
128         }
129         base->id = 0xFFE0;
130         base->len = 6;
131         infoseg->subid = 0;
132         infoseg->sublen = 2;
133         infoseg->data[0] = 0x0122;
134         err = wri_rec(fd, -1, bin, 4+6, NULL, NULL, 0);
135         if (err < 0) {
136                 DP_ER("wri_rec:infoseg error", err);
137                 cls_fil(fd);
138                 del_fil(NULL, lnk, 0);
139                 return fd;
140         }
141         base->id = 0xFFE1;
142         base->len = 24;
143         textseg->view = (RECT){{0, 0, 0, 0}};
144         textseg->draw = (RECT){{0, 0, 0, 0}};
145         textseg->h_unit = -120;
146         textseg->v_unit = -120;
147         textseg->lang = 0x21;
148         textseg->bgpat = 0;
149         err = wri_rec(fd, -1, bin, 4+24, NULL, NULL, 0);
150         if (err < 0) {
151                 DP_ER("wri_rec:textseg error", err);
152                 cls_fil(fd);
153                 del_fil(NULL, lnk, 0);
154                 return fd;
155         }
156         err = wri_rec(fd, -1, taddata, taddata_len, NULL, NULL, 0);
157         if (err < 0) {
158                 DP_ER("wri_rec:data error", err);
159                 cls_fil(fd);
160                 del_fil(NULL, lnk, 0);
161                 return fd;
162         }
163         base->id = 0xFFE2;
164         base->len = 0;
165         err = wri_rec(fd, -1, bin, 4, NULL, NULL, 0);
166         if (err < 0) {
167                 DP_ER("wri_rec:textend error", err);
168                 cls_fil(fd);
169                 del_fil(NULL, lnk, 0);
170                 return fd;
171         }
172
173         cls_fil(fd);
174
175         err = adjust_vobj(seg, (VLINK*)lnk);
176         if (err < 0) {
177                 DP_ER("adjust_vobj", err);
178                 del_fil(NULL, lnk, 0);
179                 return err;
180         }
181
182         return 0;
183 }
184
185 EXPORT W bchan_createviewervobj(TC *title, UB *fsn, W fsn_len, UB *host, W host_len, UB *board, W board_len, UB *thread, W thread_len, VOBJSEG *seg, LINK *lnk)
186 {
187         W fd, err;
188
189         fd = cre_fil(lnk, title, NULL, 1, F_FLOAT);
190         if (fd < 0) {
191                 DP_ER("cre_fil error", fd);
192                 return fd;
193         }
194
195         err = apd_rec(fd, fsn, fsn_len, 8, 0, 0);
196         if (err < 0) {
197                 DP_ER("apd_rec:fusen rec error", err);
198                 cls_fil(fd);
199                 del_fil(NULL, lnk, 0);
200                 return fd;
201         }
202
203         err = apd_rec(fd, NULL, NULL, DATCACHE_RECORDTYPE_INFO, DATCACHE_RECORDSUBTYPE_RETRIEVE, 0);
204         if (err < 0) {
205                 DP_ER("apd_rec:retrieve info error", err);
206                 cls_fil(fd);
207                 del_fil(NULL, lnk, 0);
208                 return fd;
209         }
210         err = see_rec(fd, -1, -1, NULL);
211         if (err < 0) {
212                 DP_ER("see_rec error", err);
213                 cls_fil(fd);
214                 del_fil(NULL, lnk, 0);
215                 return fd;
216         }
217
218         err = wri_rec(fd, -1, host, host_len, NULL, NULL, 0);
219         if (err < 0) {
220                 DP_ER("wri_rec:host error", err);
221                 cls_fil(fd);
222                 del_fil(NULL, lnk, 0);
223                 return fd;
224         }
225         err = wri_rec(fd, -1, "\n", 1, NULL, NULL, 0);
226         if (err < 0) {
227                 DP_ER("wri_rec:host error", err);
228                 cls_fil(fd);
229                 del_fil(NULL, lnk, 0);
230                 return fd;
231         }
232         err = wri_rec(fd, -1, board, board_len, NULL, NULL, 0);
233         if (err < 0) {
234                 DP_ER("wri_rec:board error", err);
235                 cls_fil(fd);
236                 del_fil(NULL, lnk, 0);
237                 return fd;
238         }
239         err = wri_rec(fd, -1, "\n", 1, NULL, NULL, 0);
240         if (err < 0) {
241                 DP_ER("wri_rec:board error", err);
242                 cls_fil(fd);
243                 del_fil(NULL, lnk, 0);
244                 return fd;
245         }
246         err = wri_rec(fd, -1, thread, thread_len, NULL, NULL, 0);
247         if (err < 0) {
248                 DP_ER("wri_rec:thread error", err);
249                 cls_fil(fd);
250                 del_fil(NULL, lnk, 0);
251                 return fd;
252         }
253         err = wri_rec(fd, -1, "\n", 1, NULL, NULL, 0);
254         if (err < 0) {
255                 DP_ER("wri_rec:thread error", err);
256                 cls_fil(fd);
257                 del_fil(NULL, lnk, 0);
258                 return fd;
259         }
260
261         cls_fil(fd);
262
263         err = adjust_vobj(seg, (VLINK*)lnk);
264         if (err < 0) {
265                 DP_ER("adjust_vobj", err);
266                 del_fil(NULL, lnk, 0);
267                 return err;
268         }
269
270         return 0;
271 }