1{ This demo shows the use of a browser and a file selector. 2} 3program fbrowse; 4 5uses xforms,strings; 6 7var 8form : PFL_FORM; 9br : PFL_OBJECT; 10 11procedure load_file(ob : PFL_OBJECT; arg : longint);cdecl; 12var 13 fname : pchar; 14 15begin 16 fname := fl_show_fselector ('File To Load','','*.*',''); 17 if (fname = nil) then exit; 18 if (fl_load_browser(br,fname)<>0) then 19 fl_add_browser_line(br,'NO SUCH FILE!'); 20end; 21 22procedure set_size(ob : PFL_OBJECT; arg : longint);cdecl; 23begin 24 fl_set_browser_fontsize(br,arg); 25end; 26 27procedure exit_program(ob : PFL_OBJECT; data : longint);cdecl; 28begin 29 halt(0); 30end; 31 32procedure create_form; 33var 34 obj : PFL_OBJECT; 35 x,dx : TFL_Coord; 36 37begin 38 x := 20; 39 dx := 85; 40 41 form := fl_bgn_form(FL_NO_BOX,590,610); 42 obj := fl_add_box(FL_UP_BOX,0,0,590,610,''); 43 obj := fl_add_browser(FL_NORMAL_BROWSER,20,20,550,530,''); 44 br := obj ; 45 obj := fl_add_button(FL_NORMAL_BUTTON,x,560,dx,30,'Load'); 46 fl_set_object_callback(obj,PFL_CALLBACKPTR(@load_file),0); 47 x :=x+ dx + 10; 48 obj := fl_add_lightbutton(FL_RADIO_BUTTON,x,560,dx,30,'Tiny'); 49 fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_size),FL_TINY_SIZE); 50 x := x+dx; 51 obj := fl_add_lightbutton(FL_RADIO_BUTTON,x ,560,dx,30,'Small'); 52 fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_size),FL_SMALL_SIZE); 53{ Compiler crashes on the next one. Probably the comparing of the 54 constants.. 55 if (longint(FL_SMALL_SIZE)=longint(FL_BROWSER_FONTSIZE)) then 56 fl_set_button(obj, 1); 57} x := x+dx; 58 obj := fl_add_lightbutton(FL_RADIO_BUTTON,x ,560,dx,30,'Normal'); 59 fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_size),FL_NORMAL_SIZE); 60{ idem here. 61 if FL_NORMAL_SIZE = FL_BROWSER_FONTSIZE then 62 fl_set_button(obj,1 ); 63} x := x+dx; 64 obj := fl_add_lightbutton(FL_RADIO_BUTTON,x ,560,dx,30,'Large'); 65 fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_size),FL_LARGE_SIZE); 66 67 obj := fl_add_button(FL_NORMAL_BUTTON,470,560,100,30,'Exit'); 68 fl_set_object_callback(obj,PFL_CALLBACKPTR(@exit_program), 0); 69 fl_end_form(); 70end; 71 72begin 73 fl_initialize(@argc, argv, 'FormDemo', nil, 0); 74 create_form(); 75 76 fl_clear_browser(br); 77 fl_add_browser_line(br,'LOAD A FILE.'); 78 fl_set_browser_fontstyle(br,FL_FIXED_STYLE); 79 80 fl_show_form(form,FL_PLACE_FREE,FL_FULLBORDER,'Browser'); 81 fl_do_forms(); 82 fl_hide_form(form); 83 fl_free_form(form); 84end. 85