/************************************************************************************************** fbrowse.c - File-Browser widget test. This demonstrates the use of Otk's built-in file-selector widget. It is a simple stand-alone program. Comple on Linux: cc -I/usr/X11R6/include -L/usr/X11R6/lib fbrowse.c -lGLU -lGL -lXmu -lXext -lX11 -lm -o fbrowse.exe Comple on MS-Win: gcc -O fbrowse.c -lglu32 -lopengl32 -lwinmm -lgdi32 -o fbrowse.exe **************************************************************************************************/ #include "otk_lib/otk_lib.c" #define MAXSTR 999 char directory[MAXSTR]=".", wildcards[MAXSTR]="", filename[MAXSTR]=""; OtkWidget win1; void my_file_answer( char *filename ) /* Print name of selected file. */ { printf("Browsing returned file-name: '%s'\n", filename ); win1 = OtkMakeWindow( Otk_Raised, Otk_Blue, Otk_LightGray, 10, 25, 85, 20 ); OtkMakeTextLabel( win1, filename, Otk_Black, 1.2, 1, 50.0-0.6*strlen(filename), 20 ); } void browsetest() /* Invoke the File Selection Browser. */ { Otk_Browse_Files( "File to Open:", MAXSTR, directory, wildcards, filename, my_file_answer ); } void quit( void * data ) { exit(0); } main( int argc, char **argv ) { OtkInitWindow( 620, 540, argc, argv ); /* Open a window. */ OtkMakeButton( OtkOuterWindow, 20.0, 30.0, 60.0, 20.0, "Select File(s)", browsetest, 0 ); OtkMakeButton( OtkOuterWindow, 40.0, 80.0, 20.0, 10.0, "Quit ", quit, 0 ); OtkMainLoop(); }