int btn_pause_cb(void) { if(!IupGetFunction("IDLE_ACTION")) IupSetFunction("IDLE_ACTION", (Icallback) idle_cb); else IupSetFunction("IDLE_ACTION", NULL); return IUP_DEFAULT; }
static void iDialogSetModal(Ihandle* ih_popup) { iupAttribSet(ih_popup, "MODAL", "YES"); { IFi cb = (IFi)IupGetFunction("GLOBALENTERMODAL_CB"); int popup_level = dlg_popup_level; /* save before it is changed */ iupDialogEnterModal(ih_popup, popup_level); if (cb) cb(popup_level); } }
/* pause button callback */ int pausa_cb(void) { if(IupGetFunction("IDLE_ACTION") == NULL) { // set idle callback IupSetFunction("IDLE_ACTION", (Icallback) idle_cb); } else { // reset idle callback IupSetFunction("IDLE_ACTION", NULL); } return IUP_DEFAULT ; }
static int iExpanderGlobalMotion_cb(int x, int y) { int child_x, child_y; Ihandle* ih = (Ihandle*)IupGetGlobal("_IUP_EXPANDER_GLOBAL"); Ihandle *child = ih->firstchild->brother; if (ih->data->state != IEXPANDER_OPEN_FLOAT) { IupSetGlobal("_IUP_EXPANDER_GLOBAL", NULL); IupSetFunction("GLOBALMOTION_CB", IupGetFunction("_IUP_OLD_GLOBALMOTION_CB")); IupSetFunction("_IUP_OLD_GLOBALMOTION_CB", NULL); IupSetGlobal("INPUTCALLBACKS", "No"); return IUP_DEFAULT; } child_x = 0, child_y = 0; iupdrvClientToScreen(ih->firstchild, &child_x, &child_y); if (x > child_x && x < child_x+ih->firstchild->currentwidth && y > child_y && y < child_y+ih->firstchild->currentheight) return IUP_DEFAULT; /* ignore if inside the bar */ child_x = 0, child_y = 0; iupdrvClientToScreen(child, &child_x, &child_y); if (x < child_x || x > child_x+child->currentwidth || y < child_y || y > child_y+child->currentheight) { ih->data->state = IEXPANDER_CLOSE; iExpanderOpenCloseChild(ih, 0); IupSetGlobal("_IUP_EXPANDER_GLOBAL", NULL); IupSetFunction("GLOBALMOTION_CB", IupGetFunction("_IUP_OLD_GLOBALMOTION_CB")); IupSetFunction("_IUP_OLD_GLOBALMOTION_CB", NULL); IupSetGlobal("INPUTCALLBACKS", "No"); } return IUP_DEFAULT; }
static void iDialogUnSetModal(Ihandle* ih_popup) { if (!iupAttribGetBoolean(ih_popup, "MODAL")) return; iupAttribSet(ih_popup, "MODAL", NULL); { IFi cb = (IFi)IupGetFunction("GLOBALLEAVEMODAL_CB"); int popup_level = dlg_popup_level; /* save before it is changed */ iupDialogLeaveModal(popup_level); if (cb) cb(popup_level); } }
static int iExpanderTimer_cb(Ihandle* timer) { Ihandle* ih = (Ihandle*)iupAttribGet(timer, "_IUP_EXPANDER"); Ihandle *child = ih->firstchild->brother; /* run timer just once each time */ IupSetAttribute(timer, "RUN", "No"); /* just show child on top, that's why child must be a native container when using autoshow. */ ih->data->state = IEXPANDER_OPEN_FLOAT; iExpanderOpenCloseChild(ih, 0); IupRefreshChildren(ih); IupSetAttribute(child, "ZORDER", "TOP"); /* now monitor mouse move */ IupSetGlobal("INPUTCALLBACKS", "Yes"); IupSetFunction("_IUP_OLD_GLOBALMOTION_CB", IupGetFunction("GLOBALMOTION_CB")); IupSetGlobal("_IUP_EXPANDER_GLOBAL", (char*)ih); IupSetFunction("GLOBALMOTION_CB", (Icallback)iExpanderGlobalMotion_cb); return IUP_DEFAULT; }
static LRESULT CALLBACK winHookGetMessageProc(int hcode, WPARAM gm_wp, LPARAM gm_lp) { MSG* gm_msg = (MSG*)gm_lp; UINT msg = gm_msg->message; WPARAM wp = gm_msg->wParam; LPARAM lp = gm_msg->lParam; POINT pt = gm_msg->pt; static int last_button = 0; static int last_pressed = 0; char status[IUPKEY_STATUS_SIZE] = IUPKEY_STATUS_INIT; if (hcode!=HC_ACTION) return CallNextHookEx(win_OldGetMessageHook, hcode, gm_wp, gm_lp); switch (msg) { case WM_MOUSEWHEEL: { IFfiis cb = (IFfiis)IupGetFunction("GLOBALWHEEL_CB"); if (cb) { short delta = (short)HIWORD(wp); iupwinButtonKeySetStatus(LOWORD(wp), status, 0); cb((float)delta/120.0f, LOWORD(lp), HIWORD(lp), status); } break; } case WM_NCXBUTTONDBLCLK: case WM_NCLBUTTONDBLCLK: case WM_NCMBUTTONDBLCLK: case WM_NCRBUTTONDBLCLK: case WM_NCXBUTTONDOWN: case WM_NCLBUTTONDOWN: case WM_NCMBUTTONDOWN: case WM_NCRBUTTONDOWN: case WM_XBUTTONDBLCLK: case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_XBUTTONDOWN: case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: { int doubleclick = 0, button = 0; IFiiiis cb = (IFiiiis) IupGetFunction("GLOBALBUTTON_CB"); if (!cb) break; if (msg==WM_XBUTTONDBLCLK || msg==WM_NCXBUTTONDBLCLK || msg==WM_LBUTTONDBLCLK || msg==WM_NCLBUTTONDBLCLK || msg==WM_MBUTTONDBLCLK || msg==WM_NCMBUTTONDBLCLK || msg==WM_RBUTTONDBLCLK || msg==WM_NCRBUTTONDBLCLK) doubleclick = 1; if (msg>=WM_MOUSEFIRST && msg<=WM_MOUSELAST) iupwinButtonKeySetStatus(LOWORD(wp), status, doubleclick); else if (doubleclick) iupKEY_SETDOUBLE(status); if (msg==WM_LBUTTONDOWN || msg==WM_LBUTTONDBLCLK || msg==WM_NCLBUTTONDOWN || msg==WM_NCLBUTTONDBLCLK) { button = IUP_BUTTON1; iupKEY_SETBUTTON1(status); } else if (msg==WM_MBUTTONDOWN || msg==WM_MBUTTONDBLCLK || msg==WM_NCMBUTTONDOWN || msg==WM_NCMBUTTONDBLCLK) { button = IUP_BUTTON2; iupKEY_SETBUTTON2(status); } else if (msg==WM_RBUTTONDOWN || msg==WM_RBUTTONDBLCLK || msg==WM_NCRBUTTONDOWN || msg==WM_NCRBUTTONDBLCLK) { button = IUP_BUTTON3; iupKEY_SETBUTTON3(status); } else if (msg==WM_XBUTTONDOWN || msg==WM_XBUTTONDBLCLK || msg==WM_NCXBUTTONDOWN || msg==WM_NCXBUTTONDBLCLK) { if (HIWORD(wp) == XBUTTON1) { button = IUP_BUTTON4; iupKEY_SETBUTTON4(status); } else { button = IUP_BUTTON5; iupKEY_SETBUTTON5(status); } } if (last_button == button && last_pressed == 1) break; /* do nothing because last state was already pressed */ cb(button, 1, pt.x, pt.y, status); last_button = button; last_pressed = 1; break; } case WM_NCXBUTTONUP: case WM_NCLBUTTONUP: case WM_NCMBUTTONUP: case WM_NCRBUTTONUP: case WM_XBUTTONUP: case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: { int button=0; IFiiiis cb = (IFiiiis) IupGetFunction("GLOBALBUTTON_CB"); if (!cb) break; if (msg>=WM_MOUSEFIRST && msg<=WM_MOUSELAST) iupwinButtonKeySetStatus(LOWORD(wp), status, 0); /* also updates the button status, since wp could not have the flag */ if (msg==WM_LBUTTONUP || msg==WM_NCLBUTTONUP) { button = IUP_BUTTON1; iupKEY_SETBUTTON1(status); } else if (msg==WM_MBUTTONUP || msg==WM_NCMBUTTONUP) { button = IUP_BUTTON2; iupKEY_SETBUTTON2(status); } else if (msg==WM_RBUTTONUP || msg==WM_NCRBUTTONUP) { button = IUP_BUTTON3; iupKEY_SETBUTTON3(status); } else if (msg==WM_XBUTTONUP || msg==WM_NCXBUTTONUP) { if (HIWORD(wp) == XBUTTON1) { button = IUP_BUTTON4; iupKEY_SETBUTTON4(status); } else { button = IUP_BUTTON5; iupKEY_SETBUTTON5(status); } } if (last_button == button && last_pressed == 0) break; /* do nothing because last state was already released */ cb(button, 0, pt.x, pt.y, status); last_button = button; last_pressed = 0; break; } case WM_NCMOUSEMOVE: case WM_MOUSEMOVE: { IFiis cb = (IFiis)IupGetFunction("GLOBALMOTION_CB"); if (cb) { if (msg>=WM_MOUSEFIRST && msg<=WM_MOUSELAST) iupwinButtonKeySetStatus(LOWORD(wp), status, 0); cb(pt.x, pt.y, status); } break; } case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_SYSKEYUP: case WM_KEYUP: { IFii cb = (IFii)IupGetFunction("GLOBALKEYPRESS_CB"); if (cb) { int pressed = (msg==WM_KEYDOWN || msg==WM_SYSKEYDOWN)? 1: 0; int code = iupwinKeyDecode((int)wp); if (code != 0) cb(code, pressed); } break; } default: break; } return CallNextHookEx(win_OldGetMessageHook, hcode, gm_wp, gm_lp); }
static void iGdkEventFunc(GdkEvent *evt, gpointer data) { switch(evt->type) { case GDK_BUTTON_PRESS: case GDK_2BUTTON_PRESS: case GDK_3BUTTON_PRESS: case GDK_BUTTON_RELEASE: { IFiiiis cb = (IFiiiis)IupGetFunction("GLOBALBUTTON_CB"); if (cb) { GdkEventButton* evt_button = (GdkEventButton*)evt; gint win_x = 0, win_y = 0; int doubleclick = 0, press = 1; int b = IUP_BUTTON1+(evt_button->button-1); char status[IUPKEY_STATUS_SIZE] = IUPKEY_STATUS_INIT; int x = (int)evt_button->x; int y = (int)evt_button->y; if (evt_button->type == GDK_BUTTON_RELEASE) press = 0; if (evt_button->type == GDK_2BUTTON_PRESS) doubleclick = 1; iupgtkButtonKeySetStatus(evt_button->state, evt_button->button, status, doubleclick); gdk_window_get_origin(evt_button->window, &win_x, &win_y); /* GDK window relative to screen */ x += win_x; y += win_y; if (doubleclick) { /* Must compensate the fact that in GTK there is an extra button press event when occours a double click, we compensate that completing the event with a button release before the double click. */ status[5] = ' '; /* clear double click */ cb(b, 0, x, y, status); /* release */ status[5] = 'D'; /* restore double click */ } cb(b, press, x, y, status); } break; } case GDK_MOTION_NOTIFY: { IFiis cb = (IFiis)IupGetFunction("GLOBALMOTION_CB"); if (cb) { GdkEventMotion* evt_motion = (GdkEventMotion*)evt; gint win_x = 0, win_y = 0; int x = (int)evt_motion->x; int y = (int)evt_motion->y; char status[IUPKEY_STATUS_SIZE] = IUPKEY_STATUS_INIT; iupgtkButtonKeySetStatus(evt_motion->state, 0, status, 0); if (evt_motion->is_hint) iupgtkWindowGetPointer(evt_motion->window, &x, &y, NULL); gdk_window_get_origin(evt_motion->window, &win_x, &win_y); /* GDK window relative to screen */ x += win_x; y += win_y; cb(x, y, status); } break; } case GDK_KEY_PRESS: case GDK_KEY_RELEASE: { IFii cb = (IFii)IupGetFunction("GLOBALKEYPRESS_CB"); if (cb) { int pressed = (evt->type==GDK_KEY_PRESS)? 1: 0; int code = iupgtkKeyDecode((GdkEventKey*)evt); if (code != 0) cb(code, pressed); } break; } default: break; } (void)data; gtk_main_do_event(evt); }