• R/O
  • SSH
  • HTTPS

bchan: 提交


Commit MetaInfo

修訂495 (tree)
時間2012-06-17 16:59:26
作者ornse01

Log Message

implement displaying since and vigor.

Change Summary

差異

--- bchanl/trunk/src/subjectlayout.c (revision 494)
+++ bchanl/trunk/src/subjectlayout.c (revision 495)
@@ -1,7 +1,7 @@
11 /*
22 * subjectlayout.c
33 *
4- * Copyright (c) 2009-2011 project bchan
4+ * Copyright (c) 2009-2012 project bchan
55 *
66 * This software is provided 'as-is', without any express or implied
77 * warranty. In no event will the authors be held liable for any damages
@@ -95,15 +95,48 @@
9595 draw = 1;
9696 }
9797 digit = num % 10;
98- if ((digit != 0)||(draw != 0)) {
99- dest[i++] = dec[digit];
100- draw = 1;
101- }
98+ dest[i++] = dec[digit];
99+ draw = 1;
102100 dest[i] = TNULL;
103101
104102 return i;
105103 }
106104
105+LOCAL W DATE_TIMtoTCS(DATE_TIM *dtim, TC *dest)
106+{
107+ W len;
108+
109+ len = WtoTCS(dtim->d_year + 1900, dest);
110+ dest[len++] = TK_SLSH;
111+ len += WtoTCS(dtim->d_month, dest + len);
112+ dest[len++] = TK_SLSH;
113+ len += WtoTCS(dtim->d_day, dest + len);
114+ dest[len] = TNULL;
115+
116+ return len;
117+}
118+
119+LOCAL W VIGORtoTCS(W vigor, TC *dest)
120+{
121+ W n0 = vigor / 10;
122+ W n1 = vigor % 10;
123+ W i;
124+
125+ i = WtoTCS(n0, dest);
126+ dest[i++] = TK_PROD;
127+ i += WtoTCS(n1, dest + i);
128+ dest[i++] = TK_r;
129+ dest[i++] = TK_e;
130+ dest[i++] = TK_s;
131+ dest[i++] = TK_SLSH;
132+ dest[i++] = TK_d;
133+ dest[i++] = TK_a;
134+ dest[i++] = TK_y;
135+ dest[i] = TNULL;
136+
137+ return i;
138+}
139+
107140 typedef struct sbjtlayout_thread_t_ sbjtlayout_thread_t;
108141 struct sbjtlayout_thread_t_ {
109142 sbjtlist_tuple_t *tuple;
@@ -186,9 +219,29 @@
186219 return tadlib_calcdrawsize(str, len, gid, sz);
187220 }
188221
222+LOCAL W sbjtlayout_thread_calcsincedrawsize(sbjtlayout_thread_t *layout_thread, GID gid, SIZE *sz)
223+{
224+ DATE_TIM dtim;
225+ TC str[11];
226+ W len = 10;
227+ sbjtlist_tuple_getsince(layout_thread->tuple, &dtim);
228+ len = DATE_TIMtoTCS(&dtim, str);
229+ return tadlib_calcdrawsize(str, len, gid, sz);
230+}
231+
232+LOCAL W sbjtlayout_thread_calcvigordrawsize(sbjtlayout_thread_t *layout_thread, GID gid, SIZE *sz)
233+{
234+ W vigor;
235+ TC str[100];
236+ W len;
237+ sbjtlist_tuple_getvigor(layout_thread->tuple, &vigor);
238+ len = VIGORtoTCS(vigor, str);
239+ return tadlib_calcdrawsize(str, len, gid, sz);
240+}
241+
189242 LOCAL W sbjtlayout_thread_calcsize(sbjtlayout_thread_t *layout_res, GID gid, W top)
190243 {
191- SIZE sz_index, sz_title, sz_resnum;
244+ SIZE sz_index, sz_title, sz_resnum, sz_since, sz_vigor;
192245 W err;
193246
194247 err = sbjtlayout_thread_calcindexdrawsize(layout_res, gid, &sz_index);
@@ -203,6 +256,14 @@
203256 if (err < 0) {
204257 return err;
205258 }
259+ err = sbjtlayout_thread_calcsincedrawsize(layout_res, gid, &sz_since);
260+ if (err < 0) {
261+ return err;
262+ }
263+ err = sbjtlayout_thread_calcvigordrawsize(layout_res, gid, &sz_vigor);
264+ if (err < 0) {
265+ return err;
266+ }
206267
207268 layout_res->sz_title = sz_title;
208269
@@ -209,7 +270,7 @@
209270 layout_res->view_t = top + 2;
210271 layout_res->view_l = 0;
211272 layout_res->view_b = layout_res->view_t + sz_title.v + 16;
212- layout_res->view_r = 16*6 + sz_title.h + sz_resnum.h;
273+ layout_res->view_r = 16*6 + sz_title.h + sz_resnum.h + 16 + sz_since.h + 16 + sz_vigor.h;
213274
214275 layout_res->baseline = 20;
215276 layout_res->vframe.c.left = sz_index.h + 16;
@@ -366,6 +427,7 @@
366427 }
367428
368429 LOCAL W sbjtdraw_entrydraw_resnumber(sbjtlayout_thread_t *entry, W resnum, GID target)
430+
369431 {
370432 TC str[11];
371433 W len;
@@ -374,6 +436,26 @@
374436 return gdra_str(target, str, len, G_STORE);
375437 }
376438
439+LOCAL W sbjtdraw_entrydraw_drawsince(sbjtlayout_thread_t *entry, GID gid, W dh, W dv)
440+{
441+ DATE_TIM dtim;
442+ TC str[11];
443+ W len = 10;
444+ sbjtlist_tuple_getsince(entry->tuple, &dtim);
445+ len = DATE_TIMtoTCS(&dtim, str);
446+ return gdra_str(gid, str, len, G_STORE);
447+}
448+
449+LOCAL W sbjtdraw_entrydraw_drawvigor(sbjtlayout_thread_t *entry, GID gid, W dh, W dv)
450+{
451+ W vigor;
452+ TC str[100];
453+ W len;
454+ sbjtlist_tuple_getvigor(entry->tuple, &vigor);
455+ len = VIGORtoTCS(vigor, str);
456+ return gdra_str(gid, str, len, G_STORE);
457+}
458+
377459 LOCAL int sectrect_tmp(RECT a, W left, W top, W right, W bottom)
378460 {
379461 return (a.c.left<right && left<a.c.right && a.c.top<bottom && top<a.c.bottom);
@@ -462,6 +544,22 @@
462544 if (err < 0) {
463545 return err;
464546 }
547+ err = gset_chp(target, 16, 0, 0);
548+ if (err < 0) {
549+ return err;
550+ }
551+ err = sbjtdraw_entrydraw_drawsince(entry, target, dh, dv);
552+ if (err < 0) {
553+ return err;
554+ }
555+ err = gset_chp(target, 16, 0, 0);
556+ if (err < 0) {
557+ return err;
558+ }
559+ err = sbjtdraw_entrydraw_drawvigor(entry, target, dh, dv);
560+ if (err < 0) {
561+ return err;
562+ }
465563
466564 return 0;
467565 }
Show on old repository browser