int mouse_on_key(int row, int col) { int i; for(i = 0; i < 12; i++) if(M_ACTIVE(row, col, &menuitems[i])) return(TRUE); return(FALSE); }
/* * checkmouse - Check mouse and return maped command. * * EXPORTED to pico. * NOTE: "down", "xxx", and "yyy" aren't used under windows. */ int checkmouse (unsigned long *ch, int ddd, int xxx, int yyy) { static int oindex; /* Index of previous mouse down. */ int mcol; /* current mouse column */ int mrow; /* current mouse row */ unsigned long r; int rv = 0; /* TRUE when we have something to return. */ MEvent mouse; int i = 0; MENUITEM *mp; *ch = 0; /* Mouse installed? */ if (!mexist) return (FALSE); if (!mswin_getmouseevent (&mouse)) return (FALSE); /* Location of mouse event. */ mcol = mouse.nColumn; mrow = mouse.nRow; /* * If there is a tracking function it gets all the mouse events * reguardless of where they occur. */ if (mtrack != NULL) { r = mtrack (mouse.event, mrow, mcol, mouse.button, mouse.keys); if (r & 0xffff){ *ch = r; rv = TRUE; } return (rv); } /* Mouse down or up? */ if (mouse.event == M_EVENT_DOWN) { /* button down */ oindex = -1; /* No Previous mouse down. */ } /* In special screen region? */ for(mp = mfunc; mp; mp = mp->next) if(mp->action && M_ACTIVE(mrow, mcol, mp)) break; if(mp){ r = (*mp->action)(mouse.event, mrow, mcol, mouse.button, mouse.keys); if (r){ *ch = r; rv = TRUE; } } else if(mouse.button == M_BUTTON_LEFT){ /* In any of the menuitems? */ while(1){ /* see if we understand event */ if(i >= 12){ i = -1; /* Not Found. */ break; } if(M_ACTIVE(mrow, mcol, &menuitems[i])) break; /* Found. */ i++; /* Next. */ } /* Now, was that a mouse down or mouse up? */ if (mouse.event == M_EVENT_DOWN) { /* button down */ oindex = i; /* remember where */ if(i != -1){ /* invert label */ if(menuitems[i].label_hiliter != NULL) (*menuitems[i].label_hiliter)(1, &menuitems[i]); else invert_label(1, &menuitems[i]); } } else if (mouse.event == M_EVENT_UP) {/* button up */ if (oindex != -1) { /* If up in menu item. */ if (i == oindex){ /* And same item down in. */ *ch = menuitems[i].val; /* Return menu character. */ rv = 1; } } } } else if(mouse.button == M_BUTTON_RIGHT){ if (mouse.event == M_EVENT_UP) { mswin_keymenu_popup(); } } /* If this is mouse up AND there was a mouse down in a menu item * then uninvert that menu item */ if(mouse.event == M_EVENT_UP && oindex != -1){ if(menuitems[oindex].label_hiliter != NULL) (*menuitems[oindex].label_hiliter)(0, &menuitems[oindex]); else invert_label(0, &menuitems[oindex]); } return(rv); }
/* * checkmouse - look for mouse events in key menu and return * appropriate value. */ int checkmouse(unsigned long *ch, int down, int mcol, int mrow) { static int oindex; int i = 0, rv = 0; MENUITEM *mp; if(!mexist || mcol < 0 || mrow < 0) return(FALSE); if(down) /* button down */ oindex = -1; for(mp = mfunc; mp; mp = mp->next) if(mp->action && M_ACTIVE(mrow, mcol, mp)) break; if(mp){ unsigned long r; r = (*mp->action)(down ? M_EVENT_DOWN : M_EVENT_UP, mrow, mcol, M_BUTTON_LEFT, 0); if(r){ *ch = r; rv = TRUE; } } else{ while(1){ /* see if we understand event */ if(i >= 12){ i = -1; break; } if(M_ACTIVE(mrow, mcol, &menuitems[i])) break; i++; } if(down){ /* button down */ oindex = i; /* remember where */ if(i != -1 && menuitems[i].label_hiliter != NULL && menuitems[i].val != mnoop) /* invert label */ (*menuitems[i].label_hiliter)(1, &menuitems[i]); } else{ /* button up */ if(oindex != -1){ if(i == oindex){ *ch = menuitems[i].val; rv = TRUE; } } } } /* restore label */ if(!down && oindex != -1 && menuitems[oindex].label_hiliter != NULL && menuitems[oindex].val != mnoop) (*menuitems[oindex].label_hiliter)(0, &menuitems[oindex]); return(rv); }