char *iupdrvGetDefault (Ihandle *n, const char *a) { char *def; if (n == NULL || a == NULL) return NULL; if (iupStrEqual(a, IUP_FONT) || iupStrEqual(a, "_IUPMOT_FONT")) { return iupmot_fontname; } else if (iupStrEqual(a, "EXPAND")) { if(type(n) == FILL_ || type(n) == CANVAS_ || type(n) == FRAME_ || type(n) == HBOX_ || type(n) == RADIO_ || type(n) == VBOX_ || type(n) == ZBOX_) return IUP_YES; else return IUP_NO; } def = (char *)iupTableGet(attrDefEnv, a); return def; }
void iupdrvActivate(Ihandle* ih) { if (iupStrEqual(ih->iclass->name, "text") || iupStrEqual(ih->iclass->name, "multiline")) XmProcessTraversal(ih->handle, XmTRAVERSE_CURRENT); else XtCallActionProc(ih->handle, "ArmAndActivate", 0, 0, 0 ); }
int iupBaseNoSaveCheck(Ihandle* ih, const char* name) { if (iupStrEqual(name, "BGCOLOR") || iupStrEqual(name, "VISIBLE") || iupStrEqual(name, "SIZE")) { if (iupAttribGet(ih, name)) /* save if stored at the hash table */ return 0; /* save the attribute */ else return 1; } if (iupStrEqual(name, "RASTERSIZE")) { if (!iupAttribGet(ih, "SIZE") && /* save if SIZE is not set, and user size is set */ (ih->userwidth!=0 || ih->userheight!=0)) return 0; else return 1; } if (iupStrEqual(name, "POSITION")) { if (ih->flags&IUP_FLOATING && /* save only if floating is set */ (ih->x != 0 || ih->y != 0)) return 0; else return 1; } return 1; /* default is NOT to save */ }
int iupdrvSetGlobal(const char *name, const char *value) { if (iupStrEqual(name, "LANGUAGE")) { iupStrMessageUpdateLanguage(value); return 1; } if (iupStrEqual(name, "AUTOREPEAT")) { XKeyboardControl values; if (iupStrBoolean(value)) values.auto_repeat_mode = 1; else values.auto_repeat_mode = 0; XChangeKeyboardControl(iupmot_display, KBAutoRepeatMode, &values); return 0; } if (iupStrEqual(name, "CURSORPOS")) { int x, y; if (iupStrToIntInt(value, &x, &y, 'x') == 2) XWarpPointer(iupmot_display,None,RootWindow(iupmot_display, iupmot_screen),0,0,0,0,x,y); return 0; } return 1; }
int iupdrvSetGlobal(const char *name, const char *value) { if (iupStrEqual(name, "INPUTCALLBACKS")) { if (iupStrBoolean(value)) gdk_event_handler_set(iGdkEventFunc, NULL, NULL); else gdk_event_handler_set((GdkEventFunc)gtk_main_do_event, NULL, NULL); return 1; } if (iupStrEqual(name, "UTF8MODE")) { iupgtkStrSetUTF8Mode(iupStrBoolean(value)); return 1; } if (iupStrEqual(name, "UTF8AUTOCONVERT")) { iupgtkStrSetUTF8Mode(!iupStrBoolean(value)); return 0; } if (iupStrEqual(name, "SHOWMENUIMAGES")) { #if !GTK_CHECK_VERSION(3, 10, 0) /* deprecated since 3.10 */ /* make sure the type is realized */ g_type_class_unref (g_type_class_ref (GTK_TYPE_IMAGE_MENU_ITEM)); #endif if (iupStrBoolean(value)) g_object_set (gtk_settings_get_default (), "gtk-menu-images", TRUE, NULL); else g_object_set (gtk_settings_get_default (), "gtk-menu-images", FALSE, NULL); } return 1; }
static void motTimerSetAttr(Ihandle *n, char *a, char *v) { if(iupStrEqual(a, IUP_RUN)) { if(!iupStrEqual(v, IUP_YES)) motTimerDestroy(n); else motTimerRun(n); } }
static char *boxgetattr (Ihandle * self, char *attr) { if(iupStrEqual(attr, "EXPAND")) return IUP_NO; else if(iupStrEqual(attr, "SCROLLBAR")) return IUP_NO; else if(iupStrEqual(attr, "BGCOLOR")) return iupGetBgColor(self); else return iupCpiDefaultGetAttr (self, attr); }
int IupGetInt (Ihandle *n, const char* a) { int i=0; char *s=IupGetAttribute (n,a); if (s) { if (sscanf (s,"%d",&i) != 1) /* if not just one field or failed */ { if (iupStrEqual(s, IUP_YES) || iupStrEqual(s, IUP_ON)) i = 1; } } return i; }
/** * Function used to get an attribute value of a IupCells object * @param h handle to the IupCells object * @param attr attribute to be read * @return the attribute value */ static char* cells_getattrib(Ihandle *h, char *attr) { static char buffer[ 80 ]; TCells* obj = NULL; /* Getting cell struct pointer saved in iup handle */ obj = (TCells*) iupGetEnv(h, "_IUPCELLS_DATA"); if (obj == NULL) return iupCpiDefaultGetAttr(h, attr); /* Sequence of ifs, onde for each attribute */ if (iupStrEqual(attr, IUP_BOXED)) { if (obj->boxed == 0) return IUP_NO; else return IUP_YES; } else if (iupStrEqual(attr, IUP_CLIPPED)) { if (obj->clipped == 0) return IUP_NO; else return IUP_YES; } else if (iupStrEqual(attr, IUP_NO_COLOR)) { return (char*) cd_to_iup(obj->no_color); } else if (iupStrEqual(attr, IUP_IMAGE_CANVAS)) { return (char*) obj->cddbuffer; } else if (iupStrEqual(attr, IUP_CANVAS)) { return (char*) obj->cdcanvas; } else if (iupStrEqual(attr, IUP_FIRST_LINE)) { sprintf(buffer, "%d", get_first_line(obj)); return buffer; } else if (iupStrEqual(attr, IUP_FIRST_COL)) { sprintf(buffer, "%d", get_first_col(obj)); return buffer; } else if (iupStrEqual(attr, IUP_NON_SCROLLABLE_COLS)) { sprintf(buffer, "%d", obj->non_scrollable_cols); return buffer; } else if (iupStrEqual(attr, IUP_NON_SCROLLABLE_LINES)) { sprintf(buffer, "%d", obj->non_scrollable_lins); return buffer; } else if (strstr(attr, IUP_LIMITS)) { int xmin, xmax, ymin, ymax; int i, j; int read = sscanf(attr, "%[^:]:%d:%d", buffer, &i, &j); if (read != 3) return NULL; get_cell_limit(obj, i, j, &xmin, &xmax, &ymin, &ymax); sprintf(buffer, "%d:%d:%d:%d", xmin, xmax, ymin, ymax); return buffer; } /* default case: using default iup search in hash table */ else return iupCpiDefaultGetAttr(h, attr); }
/** * Function used to set an attribute value of a IupCells object * @param h handle to the IupCells object * @param attr attribute to be read * @param value the new attribute value */ static void cells_setattrib(Ihandle *h, char *attr, char *value) { /* Getting cell struct pointer saved in iup handle */ TCells* obj = (TCells*) iupGetEnv(h, "_IUPCELLS_DATA"); if (obj == NULL || attr == NULL) return; if (iupStrEqual(attr, IUP_BUFFERIZE)) { if (value == NULL || iupStrEqualNoCase(value, IUP_NO)) { obj->bufferize = 0; adjust_scrolls(obj); repaint_all(obj); } else obj->bufferize = 1; } else if (iupStrEqual(attr, IUP_REPAINT)) { obj->bufferize = 0; adjust_scrolls(obj); repaint_all(obj); } else if (iupStrEqual(attr, IUP_NO_COLOR)) { if (value != NULL) obj->no_color = cdIupConvertColor(value); repaint_all(obj); } else if (iupStrEqual(attr, IUP_ORIGIN)) { if (adjust_origin(obj, value)) repaint_all(obj); } else if (iupStrEqual(attr, IUP_NON_SCROLLABLE_COLS)) { obj->non_scrollable_cols = atoi(value); repaint_all(obj); } else if (iupStrEqual(attr, IUP_NON_SCROLLABLE_LINES)) { obj->non_scrollable_lins = atoi(value); repaint_all(obj); } else if (iupStrEqual(attr, IUP_BOXED)) { if (value != NULL && iupStrEqualNoCase(value, IUP_NO)) obj->boxed = 0; else obj->boxed = 1; repaint_all(obj); } else if (iupStrEqual(attr, IUP_CLIPPED)) { if (value != NULL && iupStrEqualNoCase(value, IUP_NO)) obj->clipped = 0; else obj->clipped = 1; repaint_all(obj); } else if (iupStrEqual(attr, IUP_FULL_VISIBLE)) { int i, j; if (iupStrToIntInt(value, &i, &j, ':') != 2) return; set_full_visible(obj, i, j); repaint_all(obj); } /* default case: using default iup adition in hash table */ else iupCpiDefaultSetAttr(h, attr, value); }
/* %F Muda o cursor quando ele passa sobre uma juncao de titulos de coluna. %i h : handle da matriz, x,y : coordenadas do mouse (coordenadas do canvas). */ void iupmatColresChangeCursor(Ihandle *h, int x, int y) { Tmat *mat=(Tmat*)matrix_data(h); int ativo; char *attr = IupGetAttribute(h,IUP_RESIZEMATRIX); if (attr) ativo = !iupStrEqual(attr,IUP_NO); else ativo = 0; if(mat_ht(mat) && y<mat_ht(mat) && ativo) { /* Esta na area de tituos de coluna e o modo de resize esta ligado */ int achou=0,width=mat_wt(mat),col; if(abs(width-x)<TOL) achou=1; /*titulos de linha */ else { for (col=mat_fc(mat);col<=mat_lc(mat)&&!achou;col++) { width+=mat_w(mat)[col]; if (abs(width-x) < TOL) achou = 1; } } if (achou) iupCpiDefaultSetAttr(mat_self(mat),IUP_CURSOR,IUP_RESIZE_W); else setMatrixCursor(mat_self(mat)); /* Esta na area vazia apos a ultima coluna */ } else setMatrixCursor(mat_self(mat)); }
static Ihandle* getCBox(Ihandle* self) { Ihandle* parent = IupGetParent(self); while (parent && !iupStrEqual("cbox", IupGetClassName(parent))) parent = IupGetParent(parent); return parent; }
static void motFontDlgInitFamilyList(Ihandle* ih) { int i, j = 1, count = 0; char prev[1024]="", family[1024]; Ihandle* list1 = IupGetDialogChild(ih, "LIST1"); /* this will reduce the initial number */ char**font_list_str = XListFonts(iupmot_display, "-*-*-medium-r-*-*-0-0-*-*-*-*-*-*", 32767, &count); char*backup_list[32767]; if (!font_list_str) return; memcpy(backup_list, font_list_str, count*sizeof(char*)); qsort(font_list_str, count, sizeof(char*), motFontDlgCompareStr); for (i=0; i<count; i++) { motFontGetFamily(font_list_str[i], family); if (!iupStrEqual(family, prev)) /* avoid duplicates */ { IupStoreAttributeId(list1, "", j, family); strcpy(prev, family); j++; } } IupSetAttributeId(list1, "", j, NULL); memcpy(font_list_str, backup_list, count*sizeof(char*)); XFreeFontNames(font_list_str); }
static int iNormalizerSetNormalizeAttrib(Ihandle* ih, const char* value) { int i, count; Ihandle** ih_list; Ihandle* ih_control; int natural_maxwidth = 0, natural_maxheight = 0; int normalize = iNormalizeGetNormalizeSize(value); if (!normalize) return 1; count = iupArrayCount(ih->data->ih_array); ih_list = (Ihandle**)iupArrayGetData(ih->data->ih_array); for (i = 0; i < count; i++) { ih_control = ih_list[i]; iupClassObjectComputeNaturalSize(ih_control); natural_maxwidth = iupMAX(natural_maxwidth, ih_control->naturalwidth); natural_maxheight = iupMAX(natural_maxheight, ih_control->naturalheight); } for (i = 0; i < count; i++) { ih_control = ih_list[i]; if (!ih_control->floating && (ih_control->iclass->nativetype != IUP_TYPEVOID || !iupStrEqual(ih_control->iclass->name, "fill"))) { if (normalize & NORMALIZE_WIDTH) ih_control->userwidth = natural_maxwidth; if (normalize & NORMALIZE_HEIGHT) ih_control->userheight = natural_maxheight; } } return 1; }
static int iMatrixExSetNumericUnitSymbolSearchAttrib(Ihandle* ih, const char* value) { int q, u; int utf8 = IupGetInt(NULL, "UTF8MODE"); iupAttribSet(ih, "NUMERICFOUNDQUANTITY", NULL); iupAttribSet(ih, "NUMERICFOUNDUNIT", NULL); iupAttribSet(ih, "NUMERICFOUNDUNITSYMBOL", NULL); for (q=0; q<imatex_quantity_count; q++) { ImatExUnit* units = (ImatExUnit*)(imatex_quantities[q].units); int units_count = imatex_quantities[q].units_count; for (u=0; u<units_count; u++) { const char* symbol; if (utf8 && units[u].symbol_utf8) symbol = units[u].symbol_utf8; else symbol = units[u].symbol; if (iupStrEqual(symbol, value)) { iupAttribSet(ih, "NUMERICFOUNDQUANTITY", imatex_quantities[q].q_name); iupAttribSet(ih, "NUMERICFOUNDUNIT", units[u].u_name); iupAttribSetStr(ih, "NUMERICFOUNDUNITSYMBOL", symbol); return 0; } } } (void)ih; return 0; }
void IupGLPalette(Ihandle* ih, int index, float r, float g, float b) { iupASSERT(iupObjectCheck(ih)); if (!iupObjectCheck(ih)) return; /* must be a IupGLCanvas */ if (!iupStrEqual(ih->iclass->name, "glcanvas")) return; /* must be mapped */ if (!ih->handle) return; /* must have a palette */ if (ih->data->palette) { PALETTEENTRY entry; entry.peRed = (BYTE)(r*255); entry.peGreen = (BYTE)(g*255); entry.peBlue = (BYTE)(b*255); entry.peFlags = PC_NOCOLLAPSE; SetPaletteEntries(ih->data->palette,index,1,&entry); UnrealizeObject(ih->data->device); SelectPalette(ih->data->device,ih->data->palette,FALSE); RealizePalette(ih->data->device); } }
static void iuplua_index(void) { lua_Object t, f, result; t = lua_getparam(1); f = lua_getparam(2); if (!(lua_isstring(f) && iupStrEqual(lua_getstring(f), "parent"))) { lua_Object p; lua_pushobject(t); lua_pushstring("parent"); p = lua_gettable(); if (lua_istable(p)) { lua_pushobject(p); lua_pushobject(f); result = lua_gettable(); if (lua_isnil(result)) lua_pushnil(); else lua_pushobject(result); return; } } lua_pushnil(); }
void iupTreeSelectLastCollapsedBranch(Ihandle* ih, int *last_id) { /* if last selected item is a branch, then select its children */ if (iupStrEqual(IupTreeGetAttribute(ih, "KIND", *last_id), "BRANCH") && iupStrEqual(IupTreeGetAttribute(ih, "STATE", *last_id), "COLLAPSED")) { int childcount = IupTreeGetInt(ih, "CHILDCOUNT", *last_id); if (childcount > 0) { int start = *last_id + 1; int end = *last_id + childcount; IupSetfAttribute(ih, "MARK", "%d-%d", start, end); *last_id = *last_id + childcount; } } }
static tMsgResult winLoopStep(tMsgMode mode) { MSG Message; if (PeekMessage(&Message, 0, 0, 0, PM_REMOVE)) { if (win_globalmouse && winInterceptMsg(&Message)) return WIN_MSG; if (Message.message == WM_QUIT) /* IUP_CLOSE returned or IupHide in a popup dialog */ return WIN_CLOSE; else if (!winIgnoreMessage(Message)) { TranslateMessage(&Message); DispatchMessage(&Message); return WIN_MSG; } else return WIN_MSG; } else if (win_nvisiblewin==0) /* no visible dialogs ends the message loop */ { char *ll = IupGetGlobal(IUP_LOCKLOOP); if(ll && iupStrEqual(ll, "YES")) return WIN_MSG; else return WIN_CLOSE; } else if (win_idle_cb) { if (win_idle_cb() == IUP_CLOSE) return WIN_CLOSE; return WIN_IDLE; } else if (mode == WIN_WAIT) { int ret = GetMessage(&Message, NULL, 0, 0); if (ret != 0 && ret != -1) { if (win_globalmouse && winInterceptMsg(&Message)) return WIN_MSG; if (!winIgnoreMessage(Message)) { TranslateMessage(&Message); DispatchMessage(&Message); } return WIN_MSG; } else return WIN_CLOSE; } else if(mode == WIN_NOWAIT) return WIN_NOMSG; assert(0); /* nao e' para chegar aqui */ return WIN_MSG; }
void IupTextConvertLinColToPos(Ihandle* ih, int lin, int col, int *pos) { iupASSERT(iupObjectCheck(ih)); if (!iupObjectCheck(ih)) return; if (!ih->handle) return; if (iupStrEqual(ih->iclass->name, "text") || iupStrEqual(ih->iclass->name, "multiline")) { if (ih->data->is_multiline) iupdrvTextConvertLinColToPos(ih, lin, col, pos); else *pos = col - 1; /* IUP starts at 1 */ } }
int iupKeyDecode(char *c) { int i; for (i=0; ikey_map[i].s; ++i) if (iupStrEqual (c, ikey_map[i].s)) return ikey_map[i].c; return -1; }
int iupKeyNameToCode(const char *name) { int i; for (i = 0; ikey_map_list[i].name; i++) if (iupStrEqual(name, ikey_map_list[i].name)) return ikey_map_list[i].code; return 0; }
void IupCdSetFont(Ihandle* ih, cdCanvas *canvas, const char* font) { char* lastfont = iupAttribGetStr(ih, "_IUPLAST_FONT"); if (!lastfont || !iupStrEqual(lastfont, font)) { iupAttribSetStr(ih, "_IUPLAST_FONT", font); cdCanvasNativeFont(canvas, font); } }
char *iupwinGetSystemVersion(void) { char *str; #ifndef OSVERSIONINFOEX OSVERSIONINFO osvi; osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) return FALSE; #else OSVERSIONINFOEX osvi; BOOL bOsVersionInfoEx; ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) ) { /* If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO. */ osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) return FALSE; } #endif str = iupStrGetMemory(sizeof(char)*(IUP_MAX_SYSTEM_NAME+1)); memset(str, 0, IUP_MAX_SYSTEM_NAME); sprintf(str, "%d.%d.%d", osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber); /* Display service pack (if any). */ if(osvi.szCSDVersion != NULL && !iupStrEqual(osvi.szCSDVersion, "")) { strcat(str, " "); strcat(str, osvi.szCSDVersion); } #ifdef OSVERSIONINFOEX if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwOSVersionInfoSize == sizeof (OSVERSIONINFOEX)) { OSVERSIONINFOEX* osviex = (OSVERSIONINFOEX*)&osvi; if ( osviex->wProductType == VER_NT_WORKSTATION ) { if( osviex->wSuiteMask & VER_SUITE_PERSONAL ) strcat(str, " Home Edition"); else strcat(str, " Professional" ); } else strcat(str, " Server" ); } #endif return str; }
int iupmaskSet(Ihandle* ih, const char* mask_str, int autofill, int casei) { (void)autofill; IupSetAttribute(ih,"MASKCASEI", casei?"YES":"NO"); IupStoreAttribute(ih,"MASK", mask_str); if (iupStrEqual(mask_str, IupGetAttribute(ih,"MASK"))) return 1; else return 0; }
int iupmaskMatSet(Ihandle* ih, const char* mask_str, int autofill, int casei, int lin, int col) { (void)autofill; IupMatSetAttribute(ih,"MASKCASEI", lin, col, casei?"YES":"NO"); IupMatSetAttribute(ih,"MASK", lin, col, (char*)mask_str); if (iupStrEqual(mask_str, IupMatGetAttribute(ih,"MASK", lin, col))) return 1; else return 0; }
static int winToggleInactive(Ihandle *n) { if(type(n) == TOGGLE_) { char *active = iupGetEnv(n, "ACTIVE"); if(active != NULL && iupStrEqual(active, "NO")) return 1; } return 0; }
char* iupdrvGetGlobal(const char *name) { if (iupStrEqual(name, "CURSORPOS")) { int x, y; char* str = iupStrGetMemory(50); iupdrvGetCursorPos(&x, &y); sprintf(str, "%dx%d", x, y); return str; } if (iupStrEqual(name, "SHIFTKEY")) { char key[5]; iupdrvGetKeyState(key); if (key[0] == 'S') return "ON"; return "OFF"; } if (iupStrEqual(name, "CONTROLKEY")) { char key[5]; iupdrvGetKeyState(key); if (key[1] == 'C') return "ON"; return "OFF"; } if (iupStrEqual(name, "MODKEYSTATE")) { char *str = iupStrGetMemory(5); iupdrvGetKeyState(str); return str; } if (iupStrEqual(name, "SCREENSIZE")) { char *str = iupStrGetMemory(50); int w, h; iupdrvGetScreenSize(&w, &h); sprintf(str, "%dx%d", w, h); return str; } if (iupStrEqual(name, "FULLSIZE")) { char *str = iupStrGetMemory(50); int w, h; iupdrvGetFullSize(&w, &h); sprintf(str, "%dx%d", w, h); return str; } if (iupStrEqual(name, "SCREENDEPTH")) { char *str = iupStrGetMemory(50); int bpp = iupdrvGetScreenDepth(); sprintf(str, "%d", bpp); return str; } return NULL; }
void IupTextConvertPosToLinCol(Ihandle* ih, int pos, int *lin, int *col) { iupASSERT(iupObjectCheck(ih)); if (!iupObjectCheck(ih)) return; if (!ih->handle) return; if (iupStrEqual(ih->iclass->name, "text") || iupStrEqual(ih->iclass->name, "multiline")) { if (ih->data->is_multiline) iupdrvTextConvertPosToLinCol(ih, pos, lin, col); else { *col = pos + 1; /* IUP starts at 1 */ *lin = 1; } } }
char* iupScintillaGetLexerLanguageAttrib(Ihandle* ih) { int len = iupScintillaSendMessage(ih, SCI_GETLEXERLANGUAGE, 0, (sptr_t)NULL); char *str = iupStrGetMemory(len+1); len = iupScintillaSendMessage(ih, SCI_GETLEXERLANGUAGE, 0, (sptr_t)str); if (len) { if (!iupStrEqual(str, "null")) return str; } return NULL; }