19 may 2007:
There is no detailed documentation on this module yet
To use it, please look at this example and note that the module/library is not complete yet. The program below illustrates the use of the FTKGUI module:
! Simple program to show the Ftkgui library
!
module callbacks
use ftkgui
contains
subroutine drawtext( cmdname, noargs, ierror )
character(len=*) :: cmdname
integer :: noargs
integer :: ierror
type(widget) :: canvas
character(len=40) :: cname
character(len=40) :: text
integer :: id
real :: xcrd
real :: ycrd
ierror = 0
call ftcl_get_arg( 1, cname )
call ftcl_get_arg( 2, xcrd )
call ftcl_get_arg( 3, ycrd )
call gui_get_value( 'vname', text )
canvas%wname = cname
id = gui_canvas_create_text( canvas, (/ xcrd, ycrd /), text )
end subroutine
end module callbacks
program calc
use FTKGUI
use callbacks
implicit none
type(widget) :: mainw
type(widget) :: canvas
type(widget) :: label
type(widget) :: entry
type(command) :: callback
integer :: id
!
! Initialise the GUI library
!
call gui_start( mainw )
!
! Create a few widgets as children of the main window
!
label = gui_create_label( mainw, 'Edit the text and click in the window below' )
call gui_grid_add_row( (/ label, fill_column /) )
label = gui_create_label( mainw, 'Text to draw:' )
entry = gui_create_entry( mainw, 'vname' )
canvas = gui_create_canvas( mainw )
!
! Arrange them in the main window
!
call gui_grid_add_row( (/ label, entry /) )
call gui_grid_add_row( (/ canvas, fill_column /) )
!
! Text shown in the entry widget "vname"
!
call gui_set_value( 'vname', 'Text' )
!
! Draw a few items in the canvas
!
id = gui_canvas_create_line( canvas, (/ 10.0, 10.0, 40.0, 40.0 /), 'red' )
id = gui_canvas_create_oval( canvas, (/ 100.0, 100.0, 140.0, 140.0 /), 'green' )
id = gui_canvas_create_text( canvas, (/ 230.0, 100.0 /), 'This is arbitrary text' )
!
! To make the GUI really do something, we register a callback for
! the canvas: draw the text shown in the entry widget "vname" at the
! location where you click inside the canvas
!
callback = gui_create_command( drawtext )
call gui_canvas_register_callback( canvas, gui_button_1, callback, '%W %x %y' )
!
! Let the library do its work
!
call gui_loop
!
! The routine gui_loop simply takes over control, it never returns
end program
Here is the result after clicking a few times: