4 * Copyright (c) 2011-2012 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 4
44 #define BCHANL_MAINMENU_ITEMNUM_GADGET (BCHANL_MAINMENU_ITEMNUM_WINDOW + 1)
46 EXPORT W bchanl_mainmenu_setup(bchanl_mainmenu_t *mainmenu, Bool subectjoptionenable, Bool extbbsmanageropen, Bool extbbsselected)
48 /* [ɽ¼¨] -> [¥¹¥ì°ìÍ÷ÀßÄê] */
49 if (subectjoptionenable == False) {
50 mchg_atr(mainmenu->mnid, (1 << 8)|2, M_NOSEL);
52 mchg_atr(mainmenu->mnid, (1 << 8)|2, M_SEL);
55 /* [³°ÉôÈÄ] -> [³°ÉôÈÄ´ÉÍý] */
56 if (extbbsmanageropen == False) {
57 mchg_atr(mainmenu->mnid, (3 << 8)|1, M_NOSEL);
59 mchg_atr(mainmenu->mnid, (3 << 8)|1, M_SEL);
62 /* [³°ÉôÈÄ] -> [ÈÄÄɲÃ] */
63 if (extbbsmanageropen != False) {
64 mchg_atr(mainmenu->mnid, (3 << 8)|3, M_ACT);
66 mchg_atr(mainmenu->mnid, (3 << 8)|3, M_INACT);
68 /* [³°ÉôÈÄ] -> [°ì¤Ä¾å¤²¤ë] */
69 /* [³°ÉôÈÄ] -> [°ì¤Ä²¼¤²¤ë] */
70 /* [³°ÉôÈÄ] -> [ºï½ü] */
71 if (extbbsselected == False) {
72 mchg_atr(mainmenu->mnid, (3 << 8)|4, M_INACT);
73 mchg_atr(mainmenu->mnid, (3 << 8)|5, M_INACT);
74 mchg_atr(mainmenu->mnid, (3 << 8)|6, M_INACT);
76 mchg_atr(mainmenu->mnid, (3 << 8)|4, M_ACT);
77 mchg_atr(mainmenu->mnid, (3 << 8)|5, M_ACT);
78 mchg_atr(mainmenu->mnid, (3 << 8)|6, M_ACT);
81 wget_dmn(&(mainmenu->mnitem[BCHANL_MAINMENU_ITEMNUM_WINDOW].ptr));
82 mset_itm(mainmenu->mnid, BCHANL_MAINMENU_ITEMNUM_WINDOW, mainmenu->mnitem+BCHANL_MAINMENU_ITEMNUM_WINDOW);
83 oget_men(0, NULL, &(mainmenu->mnitem[BCHANL_MAINMENU_ITEMNUM_GADGET].ptr), NULL, NULL);
84 mset_itm(mainmenu->mnid, BCHANL_MAINMENU_ITEMNUM_GADGET, mainmenu->mnitem+BCHANL_MAINMENU_ITEMNUM_GADGET);
89 LOCAL W bchanl_mainmenu_select(bchanl_mainmenu_t *mainmenu, W i)
95 ret = BCHANL_MAINMENU_SELECT_CLOSE;
99 case 1: /* [ºÆɽ¼¨] */
100 ret = BCHANL_MAINMENU_SELECT_REDISPLAY;
102 case 2: /* [¥¹¥ì°ìÍ÷ÀßÄê] */
103 ret = BCHANL_MAINMENU_SELECT_SUBJECTOPTION;
106 ret = BCHANL_MAINMENU_SELECT_NOSELECT;
112 case 1: /* [ÈÄ°ìÍ÷ºÆ¼èÆÀ] */
113 ret = BCHANL_MAINMENU_SELECT_BBSMENUFETCH;
116 ret = BCHANL_MAINMENU_SELECT_NOSELECT;
120 case 3: /* [³°ÉôÈÄ] */
122 case 1: /* [³°ÉôÈÄ´ÉÍý] */
123 ret = BCHANL_MAINMENU_SELECT_EXTBBS_MANAGER;
125 case 3: /* [ÈÄÄɲÃ] */
126 ret = BCHANL_MAINMENU_SELECT_EXTBBS_REGISTER;
128 case 4: /* [°ì¤Ä¾å¤²¤ë] */
129 ret = BCHANL_MAINMENU_SELECT_EXTBBS_UP;
131 case 5: /* [°ì¤Ä²¼¤²¤ë] */
132 ret = BCHANL_MAINMENU_SELECT_EXTBBS_DOWN;
135 ret = BCHANL_MAINMENU_SELECT_EXTBBS_DELETE;
138 ret = BCHANL_MAINMENU_SELECT_NOSELECT;
142 case BCHANL_MAINMENU_ITEMNUM_WINDOW: /* [¥¦¥£¥ó¥É¥¦] */
144 ret = BCHANL_MAINMENU_SELECT_NOSELECT;
146 case BCHANL_MAINMENU_ITEMNUM_GADGET: /* [¾®Êª] */
148 ret = BCHANL_MAINMENU_SELECT_NOSELECT;
151 ret = BCHANL_MAINMENU_SELECT_NOSELECT;
158 EXPORT W bchanl_mainmenu_popup(bchanl_mainmenu_t *mainmenu, PNT pos)
161 gset_ptr(PS_SELECT, NULL, -1, -1);
162 i = msel_men(mainmenu->mnid, pos);
164 DP_ER("msel_men error:", i);
168 return BCHANL_MAINMENU_SELECT_NOSELECT;
170 return bchanl_mainmenu_select(mainmenu, i);
173 EXPORT W bchanl_mainmenu_keyselect(bchanl_mainmenu_t *mainmenu, TC keycode)
176 i = mfnd_key(mainmenu->mnid, keycode);
178 DP_ER("mfnd_key error:", i);
182 return BCHANL_MAINMENU_SELECT_NOSELECT;
184 return bchanl_mainmenu_select(mainmenu, i);
187 EXPORT W bchanl_mainmenu_initialize(bchanl_mainmenu_t *mainmenu, W dnum)
189 MENUITEM *mnitem_dbx, *mnitem;
193 err = dget_dtp(8, dnum, (void**)&mnitem_dbx);
195 DP_ER("dget_dtp error:", err);
198 len = dget_siz((B*)mnitem_dbx);
199 mnitem = malloc(len);
200 if (mnitem == NULL) {
201 DP_ER("mallod error", err);
204 memcpy(mnitem, mnitem_dbx, len);
205 mnid = mcre_men(BCHANL_MAINMENU_ITEMNUM_WINDOW+2, mnitem, NULL);
207 DP_ER("mcre_men error", mnid);
212 mainmenu->mnid = mnid;
213 mainmenu->mnitem = mnitem;
218 EXPORT VOID bchanl_mainmenu_finalize(bchanl_mainmenu_t *mainmenu)
220 mdel_men(mainmenu->mnid);
221 free(mainmenu->mnitem);