static int motion_cb(Ihandle *ih,int x,int y,char* status) { int lin, col, pos; printf("MOTION_CB(x=%d, y=%d [%s])\n",x,y, status); pos = IupConvertXYToPos(ih, x, y); IupTextConvertPosToLinCol(ih, pos, &lin, &col); printf(" (lin=%d, col=%d, pos=%d)\n", lin, col, pos); return IUP_DEFAULT; }
static int button_cb(Ihandle *ih,int but,int pressed,int x,int y,char* status) { int lin, col, pos; printf("BUTTON_CB(but=%c (%d), x=%d, y=%d [%s])\n",(char)but,pressed,x,y, status); pos = IupConvertXYToPos(ih, x, y); IupTextConvertPosToLinCol(ih, pos, &lin, &col); printf(" (lin=%d, col=%d, pos=%d)\n", lin, col, pos); return IUP_DEFAULT; }
static int iListDragBegin_CB(Ihandle* ih, int x, int y) { int pos = IupConvertXYToPos(ih, x, y); iupAttribSetInt(ih, "_IUP_LIST_SOURCEPOS", pos); return IUP_DEFAULT; }
static int iListDropData_CB(Ihandle *ih, char* type, void* data, int len, int x, int y) { int pos = IupConvertXYToPos(ih, x, y); int is_ctrl = 0; char key[5]; /* Data is not the pointer, it contains the pointer */ Ihandle* ih_source; memcpy((void*)&ih_source, data, len); /* A copy operation is enabled with the CTRL key pressed, or else a move operation will occour. A move operation will be possible only if the attribute DRAGSOURCEMOVE is Yes. When no key is pressed the default operation is copy when DRAGSOURCEMOVE=No and move when DRAGSOURCEMOVE=Yes. */ iupdrvGetKeyState(key); if (key[1] == 'C') is_ctrl = 1; if (ih_source->data->is_multiple) { char *buffer = IupGetAttribute(ih_source, "VALUE"); /* Copy all selected items */ int i = 1; /* IUP starts at 1 */ while(buffer[i-1] != '\0') { if(buffer[i-1] == '+') { iupdrvListInsertItem(ih, pos, IupGetAttribute(ih_source, iupStrReturnInt(i))); iupdrvListSetImageHandle(ih, ++pos, iupdrvListGetImageHandle(ih_source, i)); } i++; } if (IupGetInt(ih_source, "DRAGSOURCEMOVE") && !is_ctrl) { /* Remove all item from source if MOVE */ i = 1; /* IUP starts at 1 */ while(*buffer != '\0') { if (*buffer == '+') iupdrvListRemoveItem(ih_source, --i); /* update index in the source */ i++; buffer++; } } } else { iupdrvListInsertItem(ih, pos, IupGetAttribute(ih_source, IupGetAttribute(ih_source, "VALUE"))); iupdrvListSetImageHandle(ih, ++pos, iupdrvListGetImageHandle(ih_source, IupGetInt(ih_source, "VALUE"))); if(IupGetInt(ih_source, "DRAGSOURCEMOVE") && !is_ctrl) { int srcPos = iupAttribGetInt(ih_source, "_IUP_LIST_SOURCEPOS"); iupdrvListRemoveItem(ih_source, --srcPos); /* IUP starts at 1 */ } } (void)type; return IUP_DEFAULT; }
static int ConvertXYToPos(lua_State *L) { lua_pushinteger(L, IupConvertXYToPos(iuplua_checkihandle(L,1), luaL_checkint(L, 2), luaL_checkint(L, 3))); return 1; }
static int motion_cb(Ihandle *ih,int x,int y,char* status) { printf("MOTION_CB(x=%d, y=%d [%s]) - [id=%d]\n",x,y, status,IupConvertXYToPos(ih, x, y)); return IUP_DEFAULT; }
static int button_cb(Ihandle *ih,int but,int pressed,int x,int y,char* status) { printf("BUTTON_CB(but=%c (%d), x=%d, y=%d [%s]) - [id=%d]\n",(char)but,pressed,x,y, status, IupConvertXYToPos(ih, x, y)); return IUP_DEFAULT; }
static void ConvertXYToPos(void) { lua_pushnumber(IupConvertXYToPos(iuplua_checkihandle(1), luaL_check_int(2), luaL_check_int(3))); }
int iupMatrixEditShowXY(Ihandle* ih, int x, int y) { char* mask; /* work around for Windows when using Multiline */ if (iupAttribGet(ih, "_IUPMAT_IGNORE_SHOW")) { iupAttribSet(ih, "_IUPMAT_IGNORE_SHOW", NULL); return 0; } /* there are no cells that can be edited */ if (ih->data->columns.num <= 1 || ih->data->lines.num <= 1) return 0; if (ih->data->editing || iupMatrixEditIsVisible(ih)) { if (ih->data->edit_hide_onfocus) return 0; iupMatrixEditHide(ih); } ih->data->edit_lin = ih->data->lines.focus_cell; ih->data->edit_col = ih->data->columns.focus_cell; /* notify application */ if (iMatrixEditCallEditionCbUpdateValue(ih, 1, 0) == IUP_IGNORE) /* only place where mode=1 */ return 0; if (iMatrixEditCallMenuDropCb(ih, ih->data->edit_lin, ih->data->edit_col)) return 0; ih->data->editing = 1; /* select edit control */ iMatrixEditChooseElement(ih); /* position the cell to make it visible */ /* If the focus is not visible, a scroll is done for that the focus to be visible */ if (!iupMatrixAuxIsCellStartVisible(ih, ih->data->edit_lin, ih->data->edit_col)) iupMatrixScrollToVisible(ih, ih->data->edit_lin, ih->data->edit_col); /* set attributes */ iupMatrixPrepareDrawData(ih); IupStoreAttribute(ih->data->datah, "BGCOLOR", iupMatrixGetBgColorStr(ih, ih->data->edit_lin, ih->data->edit_col)); IupStoreAttribute(ih->data->datah, "FGCOLOR", iupMatrixGetFgColorStr(ih, ih->data->edit_lin, ih->data->edit_col)); IupSetAttribute(ih->data->datah, "FONT", iupMatrixGetFont(ih, ih->data->edit_lin, ih->data->edit_col)); mask = IupGetAttributeId2(ih, "MASK", ih->data->edit_lin, ih->data->edit_col); if (mask) { IupSetAttribute(ih->data->datah, "MASKCASEI", IupGetAttributeId2(ih, "MASKCASEI", ih->data->edit_lin, ih->data->edit_col)); IupSetAttribute(ih->data->datah, "MASKNOEMPTY", IupGetAttributeId2(ih, "MASKNOEMPTY", ih->data->edit_lin, ih->data->edit_col)); IupSetAttribute(ih->data->datah, "MASK", mask); } else { mask = IupGetAttributeId2(ih, "MASKINT", ih->data->edit_lin, ih->data->edit_col); if (mask) IupSetAttribute(ih->data->datah, "MASKINT", mask); else { mask = IupGetAttributeId2(ih, "MASKFLOAT", ih->data->edit_lin, ih->data->edit_col); if (mask) IupSetAttribute(ih->data->datah, "MASKFLOAT", mask); else IupSetAttribute(ih->data->datah, "MASK", NULL); } } iupMatrixEditUpdatePos(ih); /* activate and show */ IupSetAttribute(ih->data->datah, "ACTIVE", "YES"); IupSetAttribute(ih->data->datah, "VISIBLE", "YES"); IupSetFocus(ih->data->datah); if (ih->data->datah == ih->data->texth) { if (iupAttribGetBoolean(ih, "EDITALIGN")) IupSetStrAttribute(ih->data->datah, "ALIGNMENT", IupGetAttributeId(ih, "ALIGNMENT", ih->data->edit_col)); if (x || y) { int pos; x -= ih->data->datah->x; y -= ih->data->datah->y; pos = IupConvertXYToPos(ih->data->datah, x, y); IupSetInt(ih->data->datah, "CARETPOS", pos); } } return 1; }