static int k_any(Ihandle *ih, int c) { if (iup_isprint(c)) printf("K_ANY(%s, %d = %s \'%c\')\n", IupGetClassName(ih), c, iupKeyCodeToName(c), (char)c); else printf("K_ANY(%s, %d = %s)\n", IupGetClassName(ih), c, iupKeyCodeToName(c)); return IUP_CONTINUE; }
static int k_any(Ihandle *ih, int c) { if (iup_isprint(c)) printf("K_ANY(%s, %d = %s \'%c\')\n", IupGetClassName(ih), c, iupKeyCodeToName(c), (char)c); else printf("K_ANY(%s, %d = %s)\n", IupGetClassName(ih), c, iupKeyCodeToName(c)); if (c==K_r) { IupRecordInput("inputtest.iup", IUP_RECTEXT); return IUP_IGNORE; } //IUP_RECBINARY, IUP_RECTEXT if (c==K_s) { IupRecordInput(NULL, 0); IupPlayInput(NULL); return IUP_IGNORE; } if (c==K_p) { IupPlayInput("inputtest.iup"); return IUP_IGNORE; } return IUP_CONTINUE; }
static Ihandle* getCBox(Ihandle* self) { Ihandle* parent = IupGetParent(self); while (parent && !iupStrEqual("cbox", IupGetClassName(parent))) parent = IupGetParent(parent); return parent; }
void iuplua_pushihandle(lua_State *L, Ihandle *ih) { if (ih) { char* sref = IupGetAttribute(ih, "_IUPLUA_WIDGET_TABLE_REF"); if (!sref) { /* was not created in Lua */ iuplua_plugstate(L, ih); /* push iup.RegisterHandle */ iuplua_push_name(L, "RegisterHandle"); iuplua_pushihandle_raw(L, ih); lua_pushstring(L, IupGetClassName(ih)); lua_call(L, 2, 1); /* iup.RegisterHandle(ih, type) */ } else { /* already created in Lua */ iuplua_pushihandle_raw(L, ih); /* TODO: luaL_getmetatable(L, "iupHandle"); */ lua_pushstring(L, "iupHandle"); lua_gettable(L, LUA_REGISTRYINDEX); /* t = registry["iupHandle"] */ lua_setmetatable(L, -2); /* metatable(ih) = t */ } } else lua_pushnil(L); }
static int val_action_cb(Ihandle *ih) { Ihandle* pbar = (Ihandle*)IupGetAttribute(ih, "PROGRESSBAR"); IupSetStrAttribute(pbar, "VALUE", IupGetAttribute(ih, "VALUE")); printf("ACTION_CB(%s, value=%0.1f) NAME=%s\n", IupGetClassName(ih), IupGetFloat(ih, "VALUE"), IupGetAttribute(ih, "NAME")); return IUP_DEFAULT; }
void iuplua_regihandle(Ihandle *h) { if (h) { lua_pushusertag((void*)h, iuplua_tag); lua_pushstring(IupGetClassName(h)); lua_call("IupRegisterHandle"); } }
static int ihandle_tostring (lua_State *L) { Ihandle *ih = iuplua_checkihandle(L, 1); if (!ih) lua_pushstring (L, "(not an IUP handle)"); else lua_pushfstring (L, "IUP(%s): %p", IupGetClassName(ih), ih); return 1; }
void iuplua_pushihandle(Ihandle *h) { if (h) { lua_pushusertag((void*)h, iuplua_tag); lua_pushstring(IupGetClassName(h)); lua_call("IupRegisterHandle"); lua_pushobject(lua_getresult(1)); } else lua_pushnil(); }
static int motion_cb(Ihandle *self,int x,int y,char *r) { int dx, dy, posx, posy, w, h; int maxwidth = 0, maxheight = 0; IupSetAttribute(self, "CURSOR", "ARROW"); /* move all the controls except the CBOX itself */ if (iupStrEqual("cbox", IupGetClassName(self))) return IUP_DEFAULT; IupSetAttribute(self, "CURSOR", "HAND"); if (!isbutton1(r)) return IUP_DEFAULT; if (!moving) return IUP_DEFAULT; dx = x - start_x; dy = y - start_y; posx = iupGetPosX(self); posy = iupGetPosY(self); posx += dx; posy += dy; if (posx < 0) posx = 0; if (posy < 0) posy = 0; iupGetSize(self, &w, &h); iupGetSize(getCBox(self), &maxwidth, &maxheight); if (posx+w > maxwidth) posx = maxwidth-1 - w; if (posy+h > maxheight) posy = maxheight-1 - h; updateCXY(self, posx, posy); iupCpiSetPosition(self, posx, posy); iupdrvResizeObjects(self); IupUpdate(IupGetDialog(self)); return IUP_DEFAULT; }
static int enterwindow_cb(Ihandle *ih) { printf("ENTERWINDOW_CB(%s)\n", IupGetClassName(ih)); return IUP_DEFAULT; }
static int leavewindow_cb(Ihandle *ih) { printf("LEAVEWINDOW_CB(%s)\n", IupGetClassName(ih)); return IUP_DEFAULT; }
static int killfocus_cb(Ihandle *ih) { printf("KILLFOCUS_CB(%s)\n", IupGetClassName(ih)); return IUP_DEFAULT; }
static int getfocus_cb(Ihandle *ih) { printf("GETFOCUS_CB(%s)\n", IupGetClassName(ih)); return IUP_DEFAULT; }
static int valuechanged_cb(Ihandle *ih) { printf("VALUECHANGED_CB(%s)=%s\n", IupGetClassName(ih), IupGetAttribute(ih, "VALUE")); return IUP_DEFAULT; }
static int button_action_cb(Ihandle *ih) { printf("ACTION_CB(%s) NAME=%s\n", IupGetClassName(ih), IupGetAttribute(ih, "NAME")); return IUP_DEFAULT; }
static int GetClassName(lua_State *L) { Ihandle *ih = iuplua_checkihandle(L, 1); lua_pushstring(L, IupGetClassName(ih)); return 1; }
static void ClassName(void) { lua_pushstring(IupGetClassName(iuplua_checkihandle(1))); }
static int toggle_action_cb(Ihandle *ih, int state) { printf("ACTION_CB(%s, state=%d) NAME=%s\n", IupGetClassName(ih), state, IupGetAttribute(ih, "NAME")); return IUP_DEFAULT; }
static int link_action_cb(Ihandle *ih, const char* url) { printf("ACTION_CB(%s, url=%s)\n", IupGetClassName(ih), url); return IUP_DEFAULT; }
static int extrabutton_cb(Ihandle *ih, int button, int pressed) { printf("EXTRABUTTON_CB(%s, but=%d, press=%d)\n", IupGetClassName(ih), button, pressed); return IUP_DEFAULT; }
static int expand_cb(Ihandle *ih) { printf("ACTION(%s)\n", IupGetClassName(ih)); return IUP_DEFAULT; }
static int help_cb(Ihandle* ih) { printf("HELP_CB(%s)\n", IupGetClassName(ih)); return IUP_DEFAULT; }
int getfocus_cb(Ihandle *d) { printf("GETFOCUS no %s\n", IupGetClassName(d)); return IUP_DEFAULT; }