/////////////////////////////////////////////////////// // LevelCode /////////////////////////////////////////////////////// HRESULT LevelCode(void *v, DWORD s) { if(WalkOnMap) Walk(); else MapMenu(); return 0; }
void SelectItem(MenuItem *item, unsigned int state) { if(selectedMenuItem){ DrawBevel(selectedMenuItem->win, 0, 0, selectedMenuItem->menu->width - 2 * MENUBORDERW - 1, selectedMenuItem->menu->ItemHeight - 1, MENUBORDERW, TheScreen.MenuBackGC, TheScreen.MenuBackGC); } selectedMenuItem=item; if(selectedMenuItem){ if((selectedMenuItem->y+selectedMenuItem->menu->y + selectedMenuItem->menu->ItemHeight) >= TheScreen.height){ XWarpPointer(disp,None,None,0,0,0,0,0,-MENUSCROLLHEIGHT*\ selectedMenuItem->menu->ItemHeight); selectedMenuItem->menu->y -= MENUSCROLLHEIGHT * selectedMenuItem->menu->ItemHeight; XMoveWindow(disp, selectedMenuItem->menu->win, selectedMenuItem->menu->x, selectedMenuItem->menu->y); } if((selectedMenuItem->y+selectedMenuItem->menu->y)<=0){ XWarpPointer(disp,None,None,0,0,0,0,0,MENUSCROLLHEIGHT*\ selectedMenuItem->menu->ItemHeight); selectedMenuItem->menu->y += MENUSCROLLHEIGHT * selectedMenuItem->menu->ItemHeight; XMoveWindow(disp, selectedMenuItem->menu->win, selectedMenuItem->menu->x, selectedMenuItem->menu->y); } if(ButtonCount(state)>0) MenuDontKeepItAnymore(); if(selectedMenuItem->menu != activemen){ DeleteSubMenus(selectedMenuItem->menu); activemen = selectedMenuItem->menu; } if(selectedMenuItem->type == I_SUBMENU) { long int x,y; Menu *men; men=selectedMenuItem->data; men->parent=selectedMenuItem->menu; x=selectedMenuItem->menu->x+selectedMenuItem->menu->width*0.8; if((x+men->width)>TheScreen.width) x=selectedMenuItem->menu->x-men->width; if(x<30) x=30; y=selectedMenuItem->menu->y+selectedMenuItem->y; if(y>(((signed long int)TheScreen.height)-((signed long int)men->height-\ 1))) y=TheScreen.height-men->height-1; if(y<0) y=0; MapMenu(men, x, y); } DrawBevel(item->win, 0, 0, item->menu->width - 2 * MENUBORDERW - 1, item->menu->ItemHeight - 1, MENUBORDERW, TheScreen.MenuShadowGC, TheScreen.MenuLightGC); } }
MenuItem *StartMenu(Menu *menu, int x, int y, Bool q, void (*prc)(XEvent *event, MenuItem *selectedMenuItem)) { selectedMenuItem=NULL; quittable = q; keepIt = ((TheScreen.desktop.flags & UDETransientMenus) ? 0 : KeepNonTransMenu) | KeepMenuActive; SpecialProc = prc; if(x>(TheScreen.width-menu->width)) x=TheScreen.width-menu->width; if(y>(TheScreen.height-menu->height-1)) y=TheScreen.height-menu->height-1; Menu2ws(menu,TheScreen.desktop.ActiveWorkSpace); InstallMenuHandle(); GrabPointer(TheScreen.root,ButtonPressMask|ButtonReleaseMask|LeaveWindowMask|\ EnterWindowMask,TheScreen.Mice[C_DEFAULT]); menu->parent=NULL; XInstallColormap(disp,TheScreen.colormap); MapMenu(menu, x, y); while(keepIt){ XEvent event; XNextEvent(disp,&event); if(Handle[event.type]) (*Handle[event.type])(&event); } UngrabPointer(); ReinstallDefaultHandle(); DeleteMenuTree(menu); if(ActiveWin) XInstallColormap(disp,ActiveWin->Attributes.colormap); activemen=NULL; return(selectedMenuItem); }