static int iDialMotionHorizontal_CB(Ihandle* ih, int x, int y, char *status) { IFn cb; if (!iup_isbutton1(status)) return IUP_DEFAULT; y = cdIupInvertYAxis(y, ih->data->h); ih->data->angle += (double)(x-ih->data->px) / ih->data->radius; ih->data->px = x; iDialRepaint(ih); cb = (IFn)IupGetCallback(ih, "VALUECHANGED_CB"); if (cb) cb(ih); else { IFnd cb_old = (IFnd) IupGetCallback(ih, "MOUSEMOVE_CB"); if (cb_old) cb_old(ih, ih->data->angle * ih->data->unit); } return IUP_DEFAULT; }
static void cf_isbutton1(void) { if(iup_isbutton1(luaL_check_string(1))) lua_pushnumber(1); else lua_pushnil(); }
static int iDialMotionCircular_CB(Ihandle* ih, int x, int y, char *status) { int cx = ih->data->w / 2; int cy = ih->data->h / 2; double vet, xa, ya, xb, yb, ma, mb, ab; IFn cb; if (!iup_isbutton1(status)) return IUP_DEFAULT; y = cdIupInvertYAxis(y, ih->data->h); xa = ih->data->px-cx; ya = ih->data->py-cy; ma = sqrt(xa * xa + ya * ya); xb = x - cx; yb = y - cy; mb = sqrt(xb * xb + yb * yb); ab = xa * xb + ya * yb; vet = xa * yb - xb * ya; ab = ab / (ma * mb); /* if the mouse is in the center of the dial, ignore it */ if (ma == 0 || mb == 0 || ab < -1 || ab > 1) return IUP_DEFAULT; if (vet>0) ih->data->angle += acos(ab); else ih->data->angle -= acos(ab); iDialRepaint(ih); ih->data->px = x; ih->data->py = y; cb = (IFn)IupGetCallback(ih, "VALUECHANGED_CB"); if (cb) cb(ih); else { IFnd cb_old = (IFnd) IupGetCallback(ih, "MOUSEMOVE_CB"); if (cb_old) cb_old(ih, ih->data->angle * ih->data->unit); } return IUP_DEFAULT; }
static int iSplitMotion_CB(Ihandle* bar, int x, int y, char *status) { Ihandle* ih = bar->parent; if (ih->data->is_holding) { if (iup_isbutton1(status)) { int cur_x, cur_y; iupStrToIntInt(IupGetGlobal("CURSORPOS"), &cur_x, &cur_y, 'x'); if (ih->data->orientation == ISPLIT_VERT) { int width1 = iSplitGetWidth1(ih); width1 = ih->data->start_size + (cur_x - ih->data->start_pos); ih->data->val = (width1*1000)/(ih->currentwidth-ih->data->barsize); } else { int height1 = iSplitGetHeight1(ih); height1 = ih->data->start_size + (cur_y - ih->data->start_pos); ih->data->val = (height1*1000)/(ih->currentheight-ih->data->barsize); } iSplitCropVal(ih); if (ih->data->layoutdrag) { if (ih->data->autohide) { iSplitSetBarPosition(ih, cur_x, cur_y, 0); iSplitAutoHideXY(ih); } IupRefreshChildren(ih); } else iSplitSetBarPosition(ih, cur_x, cur_y, 1); } else ih->data->is_holding = 0; } (void)x; (void)y; return IUP_DEFAULT; }
static int iScrollBoxMotion_CB(Ihandle *ih, int x, int y, char* status) { if (iup_isbutton1(status) && iupAttribGet(ih, "_IUP_DRAG_SB")) { int start_x = iupAttribGetInt(ih, "_IUP_START_X"); int start_y = iupAttribGetInt(ih, "_IUP_START_Y"); int dx = x - start_x; int dy = y - start_y; int posx = iupAttribGetInt(ih, "_IUP_START_POSX"); int posy = iupAttribGetInt(ih, "_IUP_START_POSY"); IupSetInt(ih, "POSX", posx-dx); /* drag direction is oposite to scrollbar */ IupSetInt(ih, "POSY", posy-dy); iScrollBoxScroll_CB(ih, 0, IupGetFloat(ih, "POSX"), IupGetFloat(ih, "POSY")); } return IUP_DEFAULT; }
static void iRecInputMotionCB(int x, int y, char* status) { if (irec_file) { char button = '0'; int time = iRecClock() - irec_lastclock; iRecWriteStr(irec_file, "MOV", irec_mode); iRecWriteInt(irec_file, time, irec_mode); iRecWriteInt(irec_file, x, irec_mode); iRecWriteInt(irec_file, y, irec_mode); if (iup_isbutton1(status)) button = '1'; if (iup_isbutton2(status)) button = '2'; if (iup_isbutton3(status)) button = '3'; if (iup_isbutton4(status)) button = '4'; if (iup_isbutton5(status)) button = '5'; iRecWriteChar(irec_file, button, irec_mode); iRecWriteByte(irec_file, '\n', IUP_RECBINARY); /* no space after */ irec_lastclock = iRecClock(); } }
/* Callback for the mouse motion in the canvas */ static int iColorBrowserMotion_CB(Ihandle* ih, int x, int y, char *status) { if (!iup_isbutton1(status)) { ih->data->h_down = 0; ih->data->si_down = 0; return IUP_DEFAULT; } if (ih->data->h_down) { cdCanvasUpdateYAxis(ih->data->cdcanvas, &y); iColorBrowserHmouse(ih, x, y, 1); } else if (ih->data->si_down) { cdCanvasUpdateYAxis(ih->data->cdcanvas, &y); iColorBrowserSImouse(ih, x, y, 1); } return IUP_DEFAULT; }
static int cf_isbutton1(lua_State *L) { const char *value = luaL_checkstring(L, 1); lua_pushboolean(L, iup_isbutton1(value)); return 1; }