4 * Copyright (c) 2011-2015 project bchan
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.
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:
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.
19 * 2. Altered source versions must be plainly marked as such, and must not be
20 * misrepresented as being the original software.
22 * 3. This notice may not be removed or altered from any source
27 #include "bchanl_menus.h"
32 #include <btron/hmi.h>
33 #include <btron/vobj.h>
35 #ifdef BCHANL_CONFIG_DEBUG
36 # define DP(arg) printf arg
37 # define DP_ER(msg, err) printf("%s (%d/%x)\n", msg, err>>16, err)
40 # define DP_ER(msg, err) /**/
43 #define BCHANL_MAINMENU_ITEMNUM_WINDOW 5
44 #define BCHANL_MAINMENU_ITEMNUM_GADGET (BCHANL_MAINMENU_ITEMNUM_WINDOW + 1)
46 EXPORT W bchanl_mainmenu_setup(bchanl_mainmenu_t *mainmenu, Bool subjectactive, Bool subectjoptionenable, Bool extbbsmanageropen, Bool extbbsselected, Bool fromtray, Bool totray, Bool resnumdisplay, Bool sincedisplay, Bool vigordisplay)
48 /* [ɽ¼¨] -> [¥¹¥ì°ìÍ÷ÀßÄê] */
49 if (subjectactive == False) {
50 mchg_atr(mainmenu->mnid, (1 << 8)|2, M_INACT);
52 mchg_atr(mainmenu->mnid, (1 << 8)|2, M_ACT);
54 if (subectjoptionenable == False) {
55 mchg_atr(mainmenu->mnid, (1 << 8)|2, M_NOSEL);
57 mchg_atr(mainmenu->mnid, (1 << 8)|2, M_SEL);
60 /* [ɽ¼¨] -> [¥ì¥¹¿ô] */
61 if (resnumdisplay == False) {
62 mchg_atr(mainmenu->mnid, (1 << 8)|4, M_NOSEL);
64 mchg_atr(mainmenu->mnid, (1 << 8)|4, M_SEL);
67 /* [ɽ¼¨] -> [£Ó£é£î£ã£å] */
68 if (sincedisplay == False) {
69 mchg_atr(mainmenu->mnid, (1 << 8)|5, M_NOSEL);
71 mchg_atr(mainmenu->mnid, (1 << 8)|5, M_SEL);
74 /* [ɽ¼¨] -> [Àª¤¤] */
75 if (vigordisplay == False) {
76 mchg_atr(mainmenu->mnid, (1 << 8)|6, M_NOSEL);
78 mchg_atr(mainmenu->mnid, (1 << 8)|6, M_SEL);
81 /* [ÊÔ½¸] -> [¥È¥ì¡¼¤«¤é*] */
82 if (fromtray == False) {
83 mchg_atr(mainmenu->mnid, (2 << 8)|2, M_INACT);
84 mchg_atr(mainmenu->mnid, (2 << 8)|4, M_INACT);
86 mchg_atr(mainmenu->mnid, (2 << 8)|2, M_ACT);
87 mchg_atr(mainmenu->mnid, (2 << 8)|4, M_ACT);
89 /* [ÊÔ½¸] -> [¥È¥ì¡¼¤Ø*] */
90 if (totray == False) {
91 mchg_atr(mainmenu->mnid, (2 << 8)|1, M_INACT);
92 mchg_atr(mainmenu->mnid, (2 << 8)|3, M_INACT);
93 mchg_atr(mainmenu->mnid, (2 << 8)|5, M_INACT);
95 mchg_atr(mainmenu->mnid, (2 << 8)|1, M_ACT);
96 mchg_atr(mainmenu->mnid, (2 << 8)|3, M_ACT);
97 mchg_atr(mainmenu->mnid, (2 << 8)|5, M_ACT);
100 /* [Áàºî] -> [ÈÄ°ìÍ÷ºÆ¼èÆÀ] */
101 mchg_atr(mainmenu->mnid, (3 << 8)|1, M_INACT);
103 /* [³°ÉôÈÄ] -> [³°ÉôÈÄ´ÉÍý] */
104 if (extbbsmanageropen == False) {
105 mchg_atr(mainmenu->mnid, (4 << 8)|1, M_NOSEL);
107 mchg_atr(mainmenu->mnid, (4 << 8)|1, M_SEL);
110 /* [³°ÉôÈÄ] -> [ÈÄÄɲÃ] */
111 if (extbbsmanageropen != False) {
112 mchg_atr(mainmenu->mnid, (4 << 8)|3, M_ACT);
114 mchg_atr(mainmenu->mnid, (4 << 8)|3, M_INACT);
116 /* [³°ÉôÈÄ] -> [°ì¤Ä¾å¤²¤ë] */
117 /* [³°ÉôÈÄ] -> [°ì¤Ä²¼¤²¤ë] */
118 /* [³°ÉôÈÄ] -> [ºï½ü] */
119 if (extbbsselected == False) {
120 mchg_atr(mainmenu->mnid, (4 << 8)|4, M_INACT);
121 mchg_atr(mainmenu->mnid, (4 << 8)|5, M_INACT);
122 mchg_atr(mainmenu->mnid, (4 << 8)|6, M_INACT);
124 mchg_atr(mainmenu->mnid, (4 << 8)|4, M_ACT);
125 mchg_atr(mainmenu->mnid, (4 << 8)|5, M_ACT);
126 mchg_atr(mainmenu->mnid, (4 << 8)|6, M_ACT);
129 wget_dmn(&(mainmenu->mnitem[BCHANL_MAINMENU_ITEMNUM_WINDOW].ptr));
130 mset_itm(mainmenu->mnid, BCHANL_MAINMENU_ITEMNUM_WINDOW, mainmenu->mnitem+BCHANL_MAINMENU_ITEMNUM_WINDOW);
131 oget_men(0, NULL, &(mainmenu->mnitem[BCHANL_MAINMENU_ITEMNUM_GADGET].ptr), NULL, NULL);
132 mset_itm(mainmenu->mnid, BCHANL_MAINMENU_ITEMNUM_GADGET, mainmenu->mnitem+BCHANL_MAINMENU_ITEMNUM_GADGET);
137 LOCAL W bchanl_mainmenu_select(bchanl_mainmenu_t *mainmenu, W i)
143 ret = BCHANL_MAINMENU_SELECT_CLOSE;
147 case 1: /* [ºÆɽ¼¨] */
148 ret = BCHANL_MAINMENU_SELECT_REDISPLAY;
150 case 2: /* [¥¹¥ì°ìÍ÷ÀßÄê] */
151 ret = BCHANL_MAINMENU_SELECT_SUBJECTOPTION;
153 case 4: /* [¥ì¥¹¿ô] */
154 ret = BCHANL_MAINMENU_SELECT_DISPLAY_RESNUMBER;
156 case 5: /* [£Ó£é£î£ã£å] */
157 ret = BCHANL_MAINMENU_SELECT_DISPLAY_SINCE;
160 ret = BCHANL_MAINMENU_SELECT_DISPLAY_VIGOR;
163 ret = BCHANL_MAINMENU_SELECT_NOSELECT;
169 case 1: /* [¥È¥ì¡¼¤ØÊ£¼Ì] */
170 ret = BCHANL_MAINMENU_SELECT_EDIT_COPY_TO_TRAY;
172 case 2: /* [¥È¥ì¡¼¤«¤éÊ£¼Ì] */
173 ret = BCHANL_MAINMENU_SELECT_EDIT_COPY_FROM_TRAY;
175 case 3: /* [¥È¥ì¡¼¤Ø°ÜÆ°] */
176 ret = BCHANL_MAINMENU_SELECT_EDIT_MOVE_TO_TRAY;
178 case 4: /* [¥È¥ì¡¼¤«¤é°ÜÆ°] */
179 ret = BCHANL_MAINMENU_SELECT_EDIT_MOVE_FROM_TRAY;
182 ret = BCHANL_MAINMENU_SELECT_EDIT_DELETE;
185 ret = BCHANL_MAINMENU_SELECT_NOSELECT;
191 case 1: /* [ÈÄ°ìÍ÷ºÆ¼èÆÀ] */
192 ret = BCHANL_MAINMENU_SELECT_BBSMENUFETCH;
195 ret = BCHANL_MAINMENU_SELECT_NOSELECT;
199 case 4: /* [³°ÉôÈÄ] */
201 case 1: /* [³°ÉôÈÄ´ÉÍý] */
202 ret = BCHANL_MAINMENU_SELECT_EXTBBS_MANAGER;
204 case 3: /* [ÈÄÄɲÃ] */
205 ret = BCHANL_MAINMENU_SELECT_EXTBBS_REGISTER;
207 case 4: /* [°ì¤Ä¾å¤²¤ë] */
208 ret = BCHANL_MAINMENU_SELECT_EXTBBS_UP;
210 case 5: /* [°ì¤Ä²¼¤²¤ë] */
211 ret = BCHANL_MAINMENU_SELECT_EXTBBS_DOWN;
214 ret = BCHANL_MAINMENU_SELECT_EXTBBS_DELETE;
217 ret = BCHANL_MAINMENU_SELECT_NOSELECT;
221 case BCHANL_MAINMENU_ITEMNUM_WINDOW: /* [¥¦¥£¥ó¥É¥¦] */
223 ret = BCHANL_MAINMENU_SELECT_NOSELECT;
225 case BCHANL_MAINMENU_ITEMNUM_GADGET: /* [¾®Êª] */
227 ret = BCHANL_MAINMENU_SELECT_NOSELECT;
230 ret = BCHANL_MAINMENU_SELECT_NOSELECT;
237 EXPORT W bchanl_mainmenu_popup(bchanl_mainmenu_t *mainmenu, PNT pos)
240 gset_ptr(PS_SELECT, NULL, -1, -1);
241 i = msel_men(mainmenu->mnid, pos);
243 DP_ER("msel_men error:", i);
247 return BCHANL_MAINMENU_SELECT_NOSELECT;
249 return bchanl_mainmenu_select(mainmenu, i);
252 EXPORT W bchanl_mainmenu_keyselect(bchanl_mainmenu_t *mainmenu, TC keycode)
255 i = mfnd_key(mainmenu->mnid, keycode);
257 DP_ER("mfnd_key error:", i);
261 return BCHANL_MAINMENU_SELECT_NOSELECT;
263 return bchanl_mainmenu_select(mainmenu, i);
266 EXPORT W bchanl_mainmenu_initialize(bchanl_mainmenu_t *mainmenu, W dnum)
268 MENUITEM *mnitem_dbx, *mnitem;
272 err = dget_dtp(8, dnum, (void**)&mnitem_dbx);
274 DP_ER("dget_dtp error:", err);
277 len = dget_siz((B*)mnitem_dbx);
278 mnitem = malloc(len);
279 if (mnitem == NULL) {
280 DP_ER("mallod error", err);
283 memcpy(mnitem, mnitem_dbx, len);
284 mnid = mcre_men(BCHANL_MAINMENU_ITEMNUM_WINDOW+2, mnitem, NULL);
286 DP_ER("mcre_men error", mnid);
291 mainmenu->mnid = mnid;
292 mainmenu->mnitem = mnitem;
297 EXPORT VOID bchanl_mainmenu_finalize(bchanl_mainmenu_t *mainmenu)
299 mdel_men(mainmenu->mnid);
300 free(mainmenu->mnitem);