static void iColorBrowserCallDragCb(Ihandle* ih) { IFnccc drag_cb = (IFnccc) IupGetCallback(ih, "DRAG_CB"); if (drag_cb) drag_cb(ih, ih->data->red, ih->data->green, ih->data->blue); iupBaseCallValueChangedCb(ih); }
static void iColorBrowserCallChangeCb(Ihandle* ih) { IFnccc change_cb = (IFnccc) IupGetCallback(ih, "CHANGE_CB"); if (change_cb) change_cb(ih, ih->data->red, ih->data->green, ih->data->blue); iupBaseCallValueChangedCb(ih); }
static int winCalendarWmNotify(Ihandle* ih, NMHDR* msg_info, int *result) { if (msg_info->code == MCN_SELECT) { iupBaseCallValueChangedCb(ih); } (void)result; return 0; /* result not used */ }
static void motTextValueChangedCallback(Widget w, Ihandle* ih, XmAnyCallbackStruct* valuechanged) { if (iupAttribGet(ih, "_IUPMOT_DISABLE_TEXT_CB")) return; iupBaseCallValueChangedCb(ih); (void)valuechanged; (void)w; }
static void iMatrixExPasteSetData(Ihandle *ih, const char* data, int data_num_lin, int data_num_col, char sep, int start_lin, int start_col, int num_lin, int num_col, const char* busyname) { ImatExData* matex_data = (ImatExData*)iupAttribGet(ih, "_IUP_MATEX_DATA"); int lin, col, len, l, c; char* value = NULL; int value_max_size = 0, value_len; iupMatrixExBusyStart(matex_data, data_num_lin*data_num_col, busyname); lin = start_lin; l = 0; while (lin <= num_lin && l<data_num_lin) { if (iupMatrixExIsLineVisible(ih, lin)) { const char* next_line = iupStrNextLine(data, &len); l++; col = start_col; c = 0; while (col <= num_col && c<data_num_col) { if (iupMatrixExIsColumnVisible(ih, col)) { const char* next_value = iupStrNextValue(data, len, &value_len, sep); c++; value = iMatrixExStrCopyValue(value, &value_max_size, data, value_len); iupMatrixExSetCellValue(matex_data->ih, lin, col, value); data = next_value; len -= value_len+1; if (!iupMatrixExBusyInc(matex_data)) { if (value) free(value); return; } } col++; } data = next_line; } lin++; } iupMatrixExBusyEnd(matex_data); if (value) free(value); iupBaseCallValueChangedCb(matex_data->ih); }
static int iGLValMOTION_CB(Ihandle* ih, int x, int y, char* status) { int redraw = 0; int pressed = iupAttribGetInt(ih, "PRESSED"); /* special highlight processing for handler area */ if (iGLValIsInsideHandler(ih, x, y)) { if (!iupAttribGet(ih, "HIGHLIGHT")) { redraw = 1; iupAttribSet(ih, "HIGHLIGHT", "1"); } } else { if (iupAttribGet(ih, "HIGHLIGHT")) { redraw = 1; iupAttribSet(ih, "HIGHLIGHT", NULL); } } if (pressed) { int start_x = iupAttribGetInt(ih, "_IUP_START_X"); int start_y = iupAttribGetInt(ih, "_IUP_START_Y"); if (iGLValMoveHandler(ih, x - start_x, y - start_y)) { iupGLSubCanvasRedraw(ih); redraw = 0; if (!iupAttribGet(ih, "_IUP_DRAG")) { IFni cb = (IFni)IupGetCallback(ih, "VALUECHANGING_CB"); if (cb) cb(ih, 1); } iupBaseCallValueChangedCb(ih); iupAttribSet(ih, "_IUP_DRAG", "1"); } iupAttribSetInt(ih, "_IUP_START_X", x); iupAttribSetInt(ih, "_IUP_START_Y", y); } if (redraw) iupGLSubCanvasRedraw(ih); (void)status; return IUP_DEFAULT; }
static void motTextValueChangedCallback(Widget w, Ihandle* ih, XmAnyCallbackStruct* valuechanged) { if (ih->data->disable_callbacks) return; if (iupAttribGet(ih, "_IUPMOT_UPDATESPIN")) motTextUpdateSpin(ih); iupBaseCallValueChangedCb(ih); (void)valuechanged; (void)w; }
static void motListBrowseSelectionCallback(Widget w, Ihandle* ih, XmListCallbackStruct* call_data) { IFnsii cb = (IFnsii) IupGetCallback(ih, "ACTION"); if (cb) { int pos = call_data->item_position; /* Here Motif already starts at 1 */ iupListSingleCallActionCb(ih, cb, pos); } if (!ih->data->has_editbox) iupBaseCallValueChangedCb(ih); (void)w; }
static void iFlatButtonNotify(Ihandle* ih, int is_toggle) { Icallback cb = IupGetCallback(ih, "FLAT_ACTION"); if (cb) { int ret = cb(ih); if (ret == IUP_CLOSE) IupExitLoop(); } if (is_toggle) { if (iupObjectCheck(ih)) iupBaseCallValueChangedCb(ih); } }
static int winDatePickWmNotify(Ihandle* ih, NMHDR* msg_info, int *result) { if (msg_info->code == DTN_DATETIMECHANGE) { char* old_value = iupAttribGet(ih, "_IUP_OLDVALUE"); char* value = winDatePickGetValueAttrib(ih); if (!iupStrEqual(old_value, value)) { /* when user uses the dropdown, notification is called twice */ iupBaseCallValueChangedCb(ih); iupAttribSetStr(ih, "_IUP_OLDVALUE", value); } } (void)result; return 0; /* result not used */ }
void iupMatrixAuxCopyLin(Ihandle* ih, int from_lin, int to_lin) { int col, columns_num = ih->data->columns.num; /* since we can not undo the attribute copy, disable data undo */ int old_undo = ih->data->undo_redo; ih->data->undo_redo = 0; for(col = 0; col < columns_num; col++) iMatrixAuxCopyValue(ih, from_lin, col, to_lin, col); ih->data->undo_redo = old_undo; iupBaseCallValueChangedCb(ih); iupMatrixCopyLinAttributes(ih, from_lin, to_lin); }
void iupMatrixAuxCopyCol(Ihandle* ih, int from_col, int to_col) { int lin, lines_num = ih->data->lines.num; /* since we can not undo the attribute copy, disable data undo */ int old_undo = ih->data->undo_redo; ih->data->undo_redo = 0; for(lin = 0; lin < lines_num; lin++) iMatrixAuxCopyValue(ih, lin, from_col, lin, to_col); ih->data->undo_redo = old_undo; iupBaseCallValueChangedCb(ih); iupMatrixCopyColAttributes(ih, from_col, to_col); }
static void iMatrixEditUpdateValue(Ihandle* ih) { char *value = iupMatrixEditGetValue(ih); iupAttribSet(ih, "CELL_EDITED", "Yes"); if (ih->data->undo_redo) iupAttribSetClassObject(ih, "UNDOPUSHBEGIN", "EDITCELL"); iupMatrixSetValue(ih, ih->data->edit_lin, ih->data->edit_col, value, 1); if (ih->data->undo_redo) iupAttribSetClassObject(ih, "UNDOPUSHEND", NULL); iupBaseCallValueChangedCb(ih); iupAttribSet(ih, "CELL_EDITED", NULL); iupMatrixPrepareDrawData(ih); iupMatrixDrawCells(ih, ih->data->edit_lin, ih->data->edit_col, ih->data->edit_lin, ih->data->edit_col); }
static void gtkToggleToggled(GtkToggleButton *widget, Ihandle* ih) { IFni cb; int check; if (iupAttribGet(ih, "_IUPGTK_IGNORE_TOGGLE")) return; check = gtkToggleGetCheck(ih); if (ih->data->type == IUP_TOGGLE_IMAGE) gtkToggleUpdateImage(ih, iupdrvIsActive(ih), check); cb = (IFni)IupGetCallback(ih, "ACTION"); if (cb && cb(ih, check) == IUP_CLOSE) IupExitLoop(); iupBaseCallValueChangedCb(ih); (void)widget; }
static void motListComboBoxSelectionCallback(Widget w, Ihandle* ih, XmComboBoxCallbackStruct* call_data) { IFnsii cb = (IFnsii) IupGetCallback(ih, "ACTION"); if (cb) { int pos = call_data->item_position; if (pos==0) { /* must check if it is really checked or it is for the edit box */ XmString* items; XtVaGetValues(ih->handle, XmNitems, &items, NULL); if (!XmStringCompare(call_data->item_or_text, items[0])) return; } pos++; /* IUP starts at 1 */ iupListSingleCallActionCb(ih, cb, pos); } if (!ih->data->has_editbox) iupBaseCallValueChangedCb(ih); (void)w; }
static int iMatrixSetRedoAttrib(Ihandle* ih, const char* value) { ImatExData* matex_data = (ImatExData*)iupAttribGet(ih, "_IUP_MATEX_DATA"); int undo_stack_count = matex_data->undo_stack? iupArrayCount(matex_data->undo_stack): 0; if (undo_stack_count && matex_data->undo_stack_pos<undo_stack_count) { int i, count = 1, total_cell_count = 0, undo_stack_count = iupArrayCount(matex_data->undo_stack); IundoData* undo_stack_data = (IundoData*)iupArrayGetData(matex_data->undo_stack); iupStrToInt(value, &count); if (count > undo_stack_count - matex_data->undo_stack_pos) count = undo_stack_count - matex_data->undo_stack_pos; for (i=0; i<count; i++) total_cell_count += undo_stack_data[matex_data->undo_stack_pos + i].cell_count; iMatrixSetUndoRedoAttrib(ih, "NO"); /* Disable Undo/Redo systrem during restore */ iupMatrixExBusyStart(matex_data, total_cell_count, "REDO"); for (i=0; i<count; i++) { if (!iMatrixExUndoDataSwap(matex_data, &(undo_stack_data[matex_data->undo_stack_pos + i]))) { matex_data->undo_stack_pos += i; iMatrixSetUndoRedoAttrib(ih, "Yes"); return 0; } } iupMatrixExBusyEnd(matex_data); iMatrixSetUndoRedoAttrib(ih, "Yes"); matex_data->undo_stack_pos += i; iupBaseCallValueChangedCb(ih); } return 0; }
static void motListExtendedSelectionCallback(Widget w, Ihandle* ih, XmListCallbackStruct* call_data) { IFns multi_cb = (IFns)IupGetCallback(ih, "MULTISELECT_CB"); IFnsii cb = (IFnsii) IupGetCallback(ih, "ACTION"); if (multi_cb || cb) { int* pos = call_data->selected_item_positions; int sel_count = call_data->selected_item_count; int i; /* In Motif, the position of item is "plus one". "iupListMultipleCallActionCb" works with the list of selected items from the zero position. So, "minus one" here. */ for (i = 0; i < sel_count; i++) pos[i] -= 1; iupListMultipleCallActionCb(ih, cb, multi_cb, pos, sel_count); } if (!ih->data->has_editbox) iupBaseCallValueChangedCb(ih); (void)w; }
static int winToggleWmCommand(Ihandle* ih, WPARAM wp, LPARAM lp) { (void)lp; switch (HIWORD(wp)) { case BN_DOUBLECLICKED: case BN_CLICKED: { Ihandle *radio; IFni cb; int check = winToggleGetCheck(ih); if (ih->data->type==IUP_TOGGLE_IMAGE && !iupwin_comctl32ver6 && !ih->data->flat) { int active = winToggleIsActive(ih); winToggleUpdateImage(ih, active, check); if (!active) return 0; } radio = iupRadioFindToggleParent(ih); if (radio) { /* This is necessary because Windows does not send a message when a toggle is unchecked in a Radio. Also if the toggle is already checked in a radio, a click will call the callback again. */ Ihandle* last_tg = (Ihandle*)iupAttribGet(radio, "_IUPWIN_LASTTOGGLE"); if (iupObjectCheck(last_tg) && last_tg != ih) { /* uncheck last toggle */ winToggleSetCheck(last_tg, BST_UNCHECKED); cb = (IFni) IupGetCallback(last_tg, "ACTION"); if (cb && cb(last_tg, 0) == IUP_CLOSE) IupExitLoop(); if (iupObjectCheck(last_tg)) iupBaseCallValueChangedCb(last_tg); } iupAttribSet(radio, "_IUPWIN_LASTTOGGLE", (char*)ih); if (last_tg != ih) { /* check new toggle */ winToggleSetCheck(ih, BST_CHECKED); cb = (IFni)IupGetCallback(ih, "ACTION"); if (cb && cb (ih, 1) == IUP_CLOSE) IupExitLoop(); if (iupObjectCheck(ih)) iupBaseCallValueChangedCb(ih); } } else { if ((ih->data->type==IUP_TOGGLE_IMAGE && !iupwin_comctl32ver6 && ih->data->flat) || (HIWORD(wp)==BN_DOUBLECLICKED)) { /* toggle the value manually */ check = check? 0: BST_CHECKED; winToggleSetCheck(ih, check); } if (check == BST_INDETERMINATE) check = -1; cb = (IFni)IupGetCallback(ih, "ACTION"); if (cb && cb (ih, check) == IUP_CLOSE) IupExitLoop(); if (iupObjectCheck(ih)) iupBaseCallValueChangedCb(ih); } } } return 0; /* not used */ }
static int winListWmCommand(Ihandle* ih, WPARAM wp, LPARAM lp) { (void)lp; if (ih->data->is_dropdown || ih->data->has_editbox) { switch (HIWORD(wp)) { case CBN_EDITCHANGE: { iupBaseCallValueChangedCb(ih); break; } case CBN_SETFOCUS: iupwinWmSetFocus(ih); break; case CBN_KILLFOCUS: iupCallKillFocusCb(ih); break; case CBN_CLOSEUP: case CBN_DROPDOWN: { IFni cb = (IFni)IupGetCallback(ih, "DROPDOWN_CB"); if (cb) cb(ih, HIWORD(wp)==CBN_DROPDOWN? 1: 0); break; } case CBN_DBLCLK: { IFnis cb = (IFnis) IupGetCallback(ih, "DBLCLICK_CB"); if (cb) { int pos = SendMessage(ih->handle, CB_GETCURSEL, 0, 0); pos++; /* IUP starts at 1 */ iupListSingleCallDblClickCallback(ih, cb, pos); } break; } case CBN_SELCHANGE: { IFnsii cb = (IFnsii) IupGetCallback(ih, "ACTION"); if (cb) { int pos = SendMessage(ih->handle, CB_GETCURSEL, 0, 0); pos++; /* IUP starts at 1 */ iupListSingleCallActionCallback(ih, cb, pos); } iupBaseCallValueChangedCb(ih); break; } } } else { switch (HIWORD(wp)) { case LBN_DBLCLK: { IFnis cb = (IFnis) IupGetCallback(ih, "DBLCLICK_CB"); if (cb) { int pos = SendMessage(ih->handle, LB_GETCURSEL, 0, 0); pos++; /* IUP starts at 1 */ iupListSingleCallDblClickCallback(ih, cb, pos); } break; } case LBN_SELCHANGE: { if (!ih->data->is_multiple) { IFnsii cb = (IFnsii) IupGetCallback(ih, "ACTION"); if (cb) { int pos = SendMessage(ih->handle, LB_GETCURSEL, 0, 0); pos++; /* IUP starts at 1 */ iupListSingleCallActionCallback(ih, cb, pos); } } else { IFns multi_cb = (IFns)IupGetCallback(ih, "MULTISELECT_CB"); IFnsii cb = (IFnsii) IupGetCallback(ih, "ACTION"); if (multi_cb || cb) { int sel_count = SendMessage(ih->handle, LB_GETSELCOUNT, 0, 0); int* pos = malloc(sizeof(int)*sel_count); SendMessage(ih->handle, LB_GETSELITEMS, sel_count, (LPARAM)pos); iupListMultipleCallActionCallback(ih, cb, multi_cb, pos, sel_count); free(pos); } } iupBaseCallValueChangedCb(ih); break; } } } return 0; /* not used */ }
static void motToggleValueChangedCallback(Widget w, Ihandle* ih, XmToggleButtonCallbackStruct* call_data) { Ihandle *radio; IFni cb; int check = call_data->set; /* Must manually hide the tip if the toggle is pressed. */ iupmotTipLeaveNotify(); /* This is necessary because Motif toggle does not have support for radio. It is implemented using an external RadioBox that we do not use. */ radio = iupRadioFindToggleParent(ih); if (radio) { if (check) { Ihandle* last_tg = (Ihandle*)iupAttribGet(radio, "_IUPMOT_LASTTOGGLE"); if (iupObjectCheck(last_tg) && last_tg != ih) { /* uncheck last toggle */ XtVaSetValues(last_tg->handle, XmNset, XmUNSET, NULL); cb = (IFni) IupGetCallback(last_tg, "ACTION"); if (cb && cb(last_tg, 0) == IUP_CLOSE) IupExitLoop(); iupBaseCallValueChangedCb(last_tg); } iupAttribSetStr(radio, "_IUPMOT_LASTTOGGLE", (char*)ih); if (last_tg != ih) { cb = (IFni)IupGetCallback(ih, "ACTION"); if (cb && cb (ih, 1) == IUP_CLOSE) IupExitLoop(); iupBaseCallValueChangedCb(ih); } } else { /* Force stay checked */ XtVaSetValues(ih->handle, XmNset, XmSET, NULL); } } else { if (check == XmINDETERMINATE) check = -1; cb = (IFni)IupGetCallback(ih, "ACTION"); if (cb) { if (cb(ih, check) == IUP_CLOSE) IupExitLoop(); } iupBaseCallValueChangedCb(ih); } (void)w; }