static char* iMatrixListGetCountAttrib(Ihandle* ih) { ImatrixListData* mtxList = (ImatrixListData*)iupAttribGet(ih, "_IUPMTXLIST_DATA"); if (mtxList->editable) return iupStrReturnInt(ih->data->lines.num-2); else return iupStrReturnInt(ih->data->lines.num-1); /* the attribute does not include the title */ }
static char* motListGetValueAttrib(Ihandle* ih) { if (ih->data->has_editbox) { char *str, *xstr; Widget cbedit; XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL); xstr = XmTextFieldGetString(cbedit); str = iupStrReturnStr(xstr); XtFree(xstr); return str; } else { if (ih->data->is_dropdown) { int pos; XtVaGetValues(ih->handle, XmNselectedPosition, &pos, NULL); return iupStrReturnInt(pos+1); /* IUP starts at 1 */ } else { int *pos, sel_count; if (XmListGetSelectedPos(ih->handle, &pos, &sel_count)) /* XmListGetSelectedPos starts at 1 */ { if (!ih->data->is_multiple) { int ret = pos[0]; XtFree((char*)pos); return iupStrReturnInt(ret); } else { int i, count; char* str; XtVaGetValues(ih->handle, XmNitemCount, &count, NULL); str = iupStrGetMemory(count+1); memset(str, '-', count); str[count]=0; for (i=0; i<sel_count; i++) str[pos[i]-1] = '+'; XtFree((char*)pos); return str; } } } } return NULL; }
static char* iBoxGetCGapAttrib(Ihandle* ih) { if (IupClassMatch(ih, "vbox")) { int charheight; iupdrvFontGetCharSize(ih, NULL, &charheight); return iupStrReturnInt(iupRASTER2HEIGHT(ih->data->gap, charheight)); } else { int charwidth; iupdrvFontGetCharSize(ih, &charwidth, NULL); return iupStrReturnInt(iupRASTER2WIDTH(ih->data->gap, charwidth)); } }
static char* iScintillaGetBraceMatchAttribId(Ihandle* ih, int pos) { if (pos < 0) return "-1"; return iupStrReturnInt(iupScintillaSendMessage(ih, SCI_BRACEMATCH, pos, 0)); }
static char* iMatrixGetSortLineIndexAttrib(Ihandle* ih, int lin) { if (lin > 0 && lin < ih->data->lines.num && ih->data->sort_has_index) return iupStrReturnInt(ih->data->sort_line_index[lin]); else return NULL; }
static char* iGridBoxGetNumLinAttrib(Ihandle* ih) { if (!ih->handle) iupBaseComputeNaturalSize(ih); return iupStrReturnInt(ih->data->num_lin); }
static char* iBaseGetYAttrib(Ihandle *ih) { int x = 0, y = 0; iupdrvClientToScreen(ih, &x, &y); iupdrvAddScreenOffset(&x, &y, -1); return iupStrReturnInt(y); }
char* iupListGetSpacingAttrib(Ihandle* ih) { if (!ih->data->is_dropdown) return iupStrReturnInt(ih->data->spacing); else return NULL; }
char* iupListGetNCAttrib(Ihandle* ih) { if (ih->data->has_editbox) return iupStrReturnInt(ih->data->nc); else return NULL; }
static char* iMatrixExGetNumericUnitCountAttrib(Ihandle* ih, int col) { int quantity = IupGetIntId(ih, "NUMERICQUANTITYINDEX", col); if (!quantity) return NULL; else return iupStrReturnInt(imatex_quantities[quantity].units_count); }
static char* iMatrixGetUndoCountAttrib(Ihandle* ih) { ImatExData* matex_data = (ImatExData*)iupAttribGet(ih, "_IUP_MATEX_DATA"); int undo_stack_count = iupArrayCount(matex_data->undo_stack); if (matex_data->undo_stack && undo_stack_count) return iupStrReturnInt(undo_stack_count); return NULL; }
static char* iTabsGetValuePosAttrib(Ihandle* ih) { if (ih->handle) { int pos = iupdrvTabsGetCurrentTab(ih); return iupStrReturnInt(pos); } else { Ihandle* child = (Ihandle*)iupAttribGet(ih, "_IUPTABS_VALUE_HANDLE"); int pos = IupGetChildPos(ih, child); if (pos != -1) /* found child */ return iupStrReturnInt(pos); } return NULL; }
static char* iScintillaGetFontSizeStyleAttrib(Ihandle* ih, int style) { int size; if(style == IUP_INVALID_ID) style = 0; /* Lexer style default */ size = (int)IupScintillaSendMessage(ih, SCI_STYLEGETSIZE, style, 0); return iupStrReturnInt(size); }
static char* iScintillaGetWeightStyleAttrib(Ihandle* ih, int style) { int weight = (int)IupScintillaSendMessage(ih, SCI_STYLEGETWEIGHT, style, 0); if(style == IUP_INVALID_ID) style = 0; /* Lexer style default */ weight = (int)IupScintillaSendMessage(ih, SCI_STYLEGETWEIGHT, style, 0); return iupStrReturnInt(weight); }
static char* motTextGetLineCountAttrib(Ihandle* ih) { if (ih->data->is_multiline) { int linecount; XtVaGetValues(ih->handle, XmNtotalLines, &linecount, NULL); return iupStrReturnInt(linecount); } else return "1"; }
static char* motTextGetSpinValueAttrib(Ihandle* ih) { Widget spinbox = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT"); if (spinbox && XmIsSpinBox(spinbox)) { int pos; XtVaGetValues(ih->handle, XmNposition, &pos, NULL); return iupStrReturnInt(pos); } return NULL; }
static char* motListGetCaretPosAttrib(Ihandle* ih) { if (ih->data->has_editbox) { XmTextPosition pos; Widget cbedit; XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL); pos = XmTextFieldGetInsertionPosition(cbedit); return iupStrReturnInt((int)pos); } else return NULL; }
static char* iMatrixGetNumericFormatPrecisionAttrib(Ihandle* ih, int col) { int precision; char* value = iupAttribGetId(ih, "NUMERICFORMAT", col); if (!value) value = iupMatrixGetNumericFormatDef(ih); if (!value) return NULL; precision = iupStrGetFormatPrecision(value); if (precision == -1) return NULL; return iupStrReturnInt(precision); }
static char* iZboxGetValuePosAttrib(Ihandle* ih) { Ihandle* child; int pos; if (!iupObjectCheck(ih->data->value_handle)) return NULL; for (pos=0, child = ih->firstchild; child; child = child->brother, pos++) { if (child == ih->data->value_handle) /* found child */ return iupStrReturnInt(pos); } return NULL; }
static char* motTextGetCaretAttrib(Ihandle* ih) { XmTextPosition pos = XmTextGetInsertionPosition(ih->handle); if (ih->data->is_multiline) { int col, lin; char *value = XmTextGetString(ih->handle); motTextGetLinColFromPosition(value, pos, &lin, &col); XtFree(value); return iupStrReturnIntInt(lin, col, ','); } else { pos++; /* IUP starts at 1 */ return iupStrReturnInt((int)pos); } }
static char* iScintillaGetLineCountAttrib(Ihandle* ih) { int count = iupScintillaSendMessage(ih, SCI_GETLINECOUNT, 0, 0); return iupStrReturnInt(count); }
static char* iScintillaGetCountAttrib(Ihandle* ih) { int count = iupScintillaSendMessage(ih, SCI_GETTEXTLENGTH, 0, 0); return iupStrReturnInt(count); }
static char* iScintillaGetVisibleLinesCountAttrib(Ihandle* ih) { int count = iupScintillaSendMessage(ih, SCI_LINESONSCREEN, 0, 0); return iupStrReturnInt(count); }
static char* iScintillaGetCaretPosAttrib(Ihandle* ih) { return iupStrReturnInt(iupScintillaSendMessage(ih, SCI_GETCURRENTPOS, 0, 0)); }
static char* iBoxGetGapAttrib(Ihandle* ih) { return iupStrReturnInt(ih->data->gap); }
static char* iButtonGetSpacingAttrib(Ihandle *ih) { return iupStrReturnInt(ih->data->spacing); }
char* iupdrvGetGlobal(const char* name) { if (iupStrEqual(name, "VIRTUALSCREEN")) { int x = GetSystemMetrics(SM_XVIRTUALSCREEN); int y = GetSystemMetrics(SM_YVIRTUALSCREEN); int w = GetSystemMetrics(SM_CXVIRTUALSCREEN); int h = GetSystemMetrics(SM_CYVIRTUALSCREEN); return iupStrReturnStrf("%d %d %d %d", x, y, w, h); } if (iupStrEqual(name, "MONITORSINFO")) { int i; int monitors_count = GetSystemMetrics(SM_CMONITORS); RECT* monitors_rect = malloc(monitors_count*sizeof(RECT)); char* str = iupStrGetMemory(monitors_count*50); char* pstr = str; win_monitor_index = 0; EnumDisplayMonitors(NULL, NULL, winGlobalMonitorInfoEnum, (LPARAM)monitors_rect); for (i=0; i < monitors_count; i++) pstr += sprintf(pstr, "%d %d %d %d\n", (int)monitors_rect[i].left, (int)monitors_rect[i].top, (int)(monitors_rect[i].right-monitors_rect[i].left), (int)(monitors_rect[i].bottom-monitors_rect[i].top)); free(monitors_rect); return str; } if (iupStrEqual(name, "TRUECOLORCANVAS")) { return iupStrReturnBoolean(iupdrvGetScreenDepth() > 8); } if (iupStrEqual(name, "UTF8MODE")) { return iupStrReturnBoolean(iupwinStrGetUTF8Mode()); } if (iupStrEqual(name, "UTF8MODE_FILE")) { return iupStrReturnBoolean(iupwinStrGetUTF8ModeFile()); } if (iupStrEqual(name, "DLL_HINSTANCE")) { return (char*)iupwin_dll_hinstance; } if (iupStrEqual(name, "COMCTL32VER6")) { return iupStrReturnBoolean(iupwin_comctl32ver6); } if (iupStrEqual(name, "SYSTEMCODEPAGE")) { CPINFOEX info; GetCPInfoEx(CP_ACP, 0, &info); return iupStrReturnInt(info.CodePage); } if (iupStrEqual(name, "LASTERROR")) { DWORD error = GetLastError(); if (error) { LPTSTR lpMsgBuf = NULL; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER| FORMAT_MESSAGE_FROM_SYSTEM| FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0, (LPTSTR)&lpMsgBuf, /* weird but that's correct */ 0, NULL); if (lpMsgBuf) { char* str = iupStrReturnStr(iupwinStrFromSystem(lpMsgBuf)); LocalFree(lpMsgBuf); return str; } else return "Unknown Error"; } } if (iupStrEqual(name, "DWM_COMPOSITION")) { typedef HRESULT(STDAPICALLTYPE *PtrDwmIsCompositionEnabled)(BOOL*); static PtrDwmIsCompositionEnabled dwmIsCompositionEnabled = NULL; if (dwmIsCompositionEnabled == NULL) { HMODULE dwmLibrary = LoadLibrary(TEXT("dwmapi.dll")); if (dwmLibrary) dwmIsCompositionEnabled = (PtrDwmIsCompositionEnabled)GetProcAddress(dwmLibrary, "DwmIsCompositionEnabled"); } if (dwmIsCompositionEnabled != NULL) { /* windows vista or higher (has aero): see if disabled */ BOOL enabled; dwmIsCompositionEnabled(&enabled); return iupStrReturnBoolean(enabled); } else return NULL; } return NULL; }
static char* iListGetCountAttrib(Ihandle* ih) { return iupStrReturnInt(iListGetCount(ih)); }
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 char* iDetachBoxGetBarSizeAttrib(Ihandle* ih) { return iupStrReturnInt(ih->data->barsize); }