static int file_open(void) { char filename[100] = ""; IupGetFile(filename); // test key after dlg in multiline printf(filename); return IUP_DEFAULT; }
int main(int argc, char* argv[]) { Ihandle* dlg; IupOpen(&argc, &argv); dlg = CreateDialog(); IupShow(dlg); /* Try to get a file name from the command line. */ if (argc > 1) ShowImage(argv[1], dlg); else { char file_name[1024] = "*.*"; if (IupGetFile(file_name) == 0) ShowImage(file_name, dlg); } IupMainLoop(); IupDestroy(dlg); IupClose(); return 0; }
void guiSave( void ) { int i = ( guiMenu ? IupGetInt ( guiMenu, "MEDIT_I" ) : guiMenu_Org ); char path[ PATH_MAX ] = {0}; char opath[ PATH_MAX ] = {0}; if ( !appMethods.OnDefPath || !appMethods.OnDefExt ) { return; } copystri ( path, ipGetUsrDir(), PATH_MAX ); appendstr ( path, DIR_SEP ".medit" DIR_SEP "data", PATH_MAX ); copystri ( opath, path, PATH_MAX ); appMethods.OnDefPath ( opath ); appMethods.OnApply(); appMethods.OnDefPath ( path ); // Rename Directory if ( _access( opath, 0 ) == 0 && istrcmp( opath, path ).i ) { rename( opath, path ); } if ( i >= guiMenu_Hacks ) { appendstr ( opath, "*.", PATH_MAX ); appendstr ( path, "*.", PATH_MAX ); } else { appendstr ( opath, ".", PATH_MAX ); appendstr ( path, ".", PATH_MAX ); } appMethods.OnDefExt ( path ); appMethods.OnDefExt ( opath ); // Rename File if ( i < guiMenu_Hacks && _access( opath, 0 ) == 0 && istrcmp( opath, path ).i ) { rename( opath, path ); } if ( i >= guiMenu_Hacks ) { if ( IupGetFile ( path ) == -1 ) { return; } } if ( _access( path, 0 ) != 0 ) { _creat( path, _S_IREAD | _S_IWRITE ); } appMethods.OnSave ( path ); }
static void GetFile(void) { char buffer[10240]; int ret; strcpy(buffer, luaL_check_string(1)); ret = IupGetFile(buffer); lua_pushstring(buffer); lua_pushnumber(ret); }
static int GetFile (lua_State *L) { const char *fname = luaL_checkstring(L,1); char returned_fname[4096]; int ret; iupStrCopyN(returned_fname, 4096, fname); ret = IupGetFile(returned_fname); lua_pushstring(L, returned_fname); lua_pushinteger(L, ret); return 2; }
int app_open_cb(Ihandle* self) { imFile* ifile; /* file input */ int ret, error; unsigned char* gl_data = (unsigned char*)IupGetAttribute(self, "APP_GL_DATA"); char filename[1024] = ".\\*.*"; /* get a file name */ ret = IupGetFile(filename); if (ret == -1) return IUP_DEFAULT; ifile = imFileOpen(filename, &error); if (!ifile) { IupMessage("Error", "Error reading image file."); return IUP_DEFAULT; } { int width = 0, height = 0, file_color_mode, color_space; Ihandle* dialog = IupGetDialog(self); imFileReadImageInfo(ifile, 0, &width, &height, &file_color_mode, NULL); /* alocates the buffers */ if (gl_data) free(gl_data); gl_data = malloc(width*height*3); IupSetAttribute(dialog, "APP_GL_DATA", gl_data); IupSetfAttribute(dialog, "APP_GL_WIDTH", "%d", width); IupSetfAttribute(dialog, "APP_GL_HEIGHT", "%d", height); imFileReadImageData(ifile, gl_data, 1, IM_PACKED); color_space = imColorModeSpace(file_color_mode); if (color_space == IM_MAP || color_space == IM_GRAY || color_space == IM_BINARY) { long palette[256]; int palette_count; imFileGetPalette(ifile, palette, &palette_count); ConvertMapToGLData(gl_data, width*height, 3, palette, palette_count); } } imFileClose(ifile); return IUP_DEFAULT; }
static void new_getfile(void) { int ret; char filename[1024] = "*.*"; IupSetGlobal("PARENTDIALOG", "_MAIN_DIALOG_TEST_"); ret = IupGetFile(filename); IupSetGlobal("PARENTDIALOG", NULL); if (ret!=-1) { printf("OK\n"); if (ret == 0) printf("File(%s)\n", filename); else printf("New File(%s)\n", filename); } else printf("CANCEL\n"); }
static int cbCanvasButton(Ihandle* iup_canvas, int but, int pressed) { char file_name[200] = "*.*"; if (but != IUP_BUTTON1 || !pressed) return IUP_DEFAULT; disable_repaint = 1; if (IupGetFile(file_name) != 0) { disable_repaint = 0; return IUP_DEFAULT; } disable_repaint = 0; ShowImage(file_name, IupGetDialog(iup_canvas)); return IUP_DEFAULT; }
void guiLoad ( uchar useDlg ) { // FIXME: i = 0 when attempt to load hacks int i = ( guiMenu ? IupGetInt ( guiMenu, "MEDIT_I" ) : guiMenu_Org ); char path[ PATH_MAX ] = {0}; if ( !appMethods.OnDefPath || !appMethods.OnDefExt ) { return; } copystri ( path, ipGetUsrDir(), PATH_MAX ); appendstr ( path, DIR_SEP ".medit" DIR_SEP "data", PATH_MAX ); appMethods.OnDefPath ( path ); if ( useDlg || i >= guiMenu_Hacks ) { appendstr ( path, "*.", PATH_MAX ); } else { appendstr ( path, ".", PATH_MAX ); } appMethods.OnDefExt ( path ); if ( useDlg || i >= guiMenu_Hacks ) { if ( IupGetFile ( path ) == -1 ) { return; } } if ( _access( path, 0 ) != 0 ) { _creat( path, _S_IREAD | _S_IWRITE ); } appMethods.OnLoad ( path ); appMethods.OnReset(); }