void menubase_clrrect(VRAMHDL vram) { RECT_T rct; if (vram) { vram_getrect(vram, &rct); vram_fillalpha(menuvram, &rct, 1); menubase_setrect(vram, NULL); // movieredraw = 1; } }
static void itemdraw(MENUSYS *sys, int depth, int pos, int flag) { MENUHDL menu; VRAMHDL vram; void (*drawfn)(VRAMHDL vram, MENUHDL menu, int flag); menu = getitem(sys, depth, pos); if (menu) { vram = sys->wnd[depth].vram; drawfn = (depth)?citemdraw:bitemdraw; drawfn(vram, menu, flag); menubase_setrect(vram, &menu->rct); } }
static BRESULT childopn(MENUSYS *sys, int depth, int pos) { MENUHDL menu; RECT_T parent; int dir; int width; int height; int items; MSYSWND wnd; int drawitems; POINT_T pt; menu = getitem(sys, depth, pos); if ((menu == NULL) || (menu->child == NULL)) { TRACEOUT(("child not found.")); goto copn_err; } wnd = sys->wnd + depth; if ((menu->flag & MENUS_CTRLMASK) == MENUS_POPUP) { parent.left = sys->popupx; parent.top = max(sys->popupy, wnd->vram->height); parent.right = parent.left; parent.bottom = parent.top; dir = 0; } else { parent.left = wnd->vram->posx + menu->rct.left; parent.top = wnd->vram->posy + menu->rct.top; parent.right = wnd->vram->posx + menu->rct.right; parent.bottom = wnd->vram->posy + menu->rct.bottom; dir = depth + 1; } if (depth >= (MENUSYS_MAX - 1)) { TRACEOUT(("menu max.")); goto copn_err; } wnd++; width = 0; height = (MENU_FBORDER + MENU_BORDER); items = 0; drawitems = 0; menu = menu->child; wnd->menu = menu; while(menu) { if (!(menu->flag & MENU_DISABLE)) { menu->rct.left = (MENU_FBORDER + MENU_BORDER); menu->rct.top = height; if (menu->flag & MENU_SEPARATOR) { if (height > (menubase.height - MENUSYS_CYSEP - (MENU_FBORDER + MENU_BORDER))) { break; } height += MENUSYS_CYSEP; menu->rct.bottom = height; } else { if (height > (menubase.height - MENUSYS_CYITEM - (MENU_FBORDER + MENU_BORDER))) { break; } height += MENUSYS_CYITEM; menu->rct.bottom = height; fontmng_getsize(menubase.font, menu->string, &pt); if (width < pt.x) { width = pt.x; } } } items++; menu = menu->next; } width += ((MENU_FBORDER + MENU_BORDER + MENUSYS_SXITEM) * 2) + MENUSYS_CXCHECK + MENUSYS_CXNEXT; if (width >= menubase.width) { width = menubase.width; } height += (MENU_FBORDER + MENU_BORDER); wnd->vram = menuvram_create(width, height, menubase.bpp); if (wnd->vram == NULL) { TRACEOUT(("sub menu vram couldn't create")); goto copn_err; } if (dir == 1) { if ((parent.top < height) || (parent.bottom < (menubase.height - height))) { parent.top = parent.bottom; } else { parent.top -= height; } } else if (dir >= 2) { if ((parent.left < width) || (parent.right < (menubase.width - width))) { parent.left = parent.right; } else { parent.left -= width; } if ((parent.top > (menubase.height - height)) && (parent.bottom >= height)) { parent.top = parent.bottom - height; } } wnd->vram->posx = min(parent.left, menubase.width - width); wnd->vram->posy = min(parent.top, menubase.height - height); wnd->items = items; wnd->focus = -1; sys->depth++; menu = wnd->menu; drawitems = items; while(drawitems--) { if (!(menu->flag & MENU_DISABLE)) { menu->rct.right = width - (MENU_FBORDER + MENU_BORDER); citemdraw(wnd->vram, menu, 0); } menu = menu->next; } menubase_setrect(wnd->vram, NULL); return(SUCCESS); copn_err: return(FAILURE); }
static BRESULT wndopenbase(MENUSYS *sys) { MENUHDL menu; RECT_T mrect; VRAMHDL vram; int items; int posx; UINT rootflg; int menutype; int height; POINT_T pt; wndclose(sys, 0); rootflg = 0; menu = sys->root; while(menu) { // メニュー内容を調べる。 if (!(menu->flag & (MENU_DISABLE | MENU_SEPARATOR))) { switch(menu->flag & MENUS_CTRLMASK) { case MENUS_POPUP: break; case MENUS_SYSTEM: rootflg |= MEXIST_SYS; break; case MENUS_MINIMIZE: rootflg |= MEXIST_MINIMIZE; break; case MENUS_CLOSE: rootflg |= MEXIST_CLOSE; break; default: rootflg |= MEXIST_ITEM; break; } } menu = menu->next; } mrect.left = MENU_FBORDER + MENU_BORDER; mrect.top = MENU_FBORDER + MENU_BORDER; mrect.right = menubase.width - (MENU_FBORDER + MENU_BORDER); mrect.bottom = (MENU_FBORDER + MENU_BORDER) + MENUSYS_CYCAPTION; height = ((MENU_FBORDER + MENU_BORDER) * 2) + MENUSYS_CYCAPTION; if (rootflg & MEXIST_ITEM) { height += (MENUSYS_BCAPTION * 3) + MENUSYS_CYSYS; mrect.left += MENUSYS_BCAPTION; mrect.top += MENUSYS_BCAPTION; mrect.right -= MENUSYS_BCAPTION; mrect.bottom += MENUSYS_BCAPTION; } vram = menuvram_create(menubase.width, height, menubase.bpp); sys->wnd[0].vram = vram; if (vram == NULL) { goto wopn0_err; } if (sys->style & MENUSTYLE_BOTTOM) { vram->posy = max(0, menuvram->height - height); } menuvram_caption(vram, &mrect, sys->icon, sys->title); menubase_setrect(vram, NULL); menu = sys->root; sys->wnd[0].menu = menu; sys->wnd[0].focus = -1; sys->depth++; items = 0; posx = MENU_FBORDER + MENU_BORDER + MENUSYS_BCAPTION; while(menu) { if (!(menu->flag & (MENU_DISABLE | MENU_SEPARATOR))) { menutype = menu->flag & MENUS_CTRLMASK; if (menutype == MENUS_POPUP) { } else if (menutype == MENUS_SYSTEM) { menu->rct.left = mrect.left + MENU_PXCAPTION; menu->rct.right = menu->rct.left; menu->rct.top = mrect.top + MENU_PYCAPTION; menu->rct.bottom = menu->rct.top; if (sys->icon) { menu->rct.right += MENUSYS_SZICON; menu->rct.bottom += MENUSYS_SZICON; } } else if (menutype == MENUS_MINIMIZE) { menu->rct.right = mrect.right - MENU_PXCAPTION; if (rootflg & MEXIST_CLOSE) { menu->rct.right -= MENUSYS_CXCLOSE + (MENU_LINE * 2); } menu->rct.left = menu->rct.right - MENUSYS_CXCLOSE; menu->rct.top = mrect.top + ((MENUSYS_CYCAPTION - MENUSYS_CYCLOSE) / 2); menu->rct.bottom = menu->rct.top + MENUSYS_CYCLOSE; menuvram_minimizebtn(vram, &menu->rct, 0); } else if (menutype == MENUS_CLOSE) { menu->rct.right = mrect.right - MENU_PXCAPTION; menu->rct.left = menu->rct.right - MENUSYS_CXCLOSE; menu->rct.top = mrect.top + ((MENUSYS_CYCAPTION - MENUSYS_CYCLOSE) / 2); menu->rct.bottom = menu->rct.top + MENUSYS_CYCLOSE; menuvram_closebtn(vram, &menu->rct, 0); } else { menu->rct.left = posx; menu->rct.top = mrect.bottom + MENUSYS_BCAPTION; menu->rct.bottom = menu->rct.top + MENUSYS_CYSYS; fontmng_getsize(menubase.font, menu->string, &pt); posx += MENUSYS_SXSYS + pt.x + MENUSYS_LXSYS; if (posx >= (menubase.width - (MENU_FBORDER + MENU_BORDER + MENUSYS_BCAPTION))) { break; } menu->rct.right = posx; bitemdraw(vram, menu, 0); } } items++; menu = menu->next; } sys->wnd[0].items = items; return(SUCCESS); wopn0_err: return(FAILURE); }