!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Demo widget
!
begin procedure demo_display_values
  message r demo-widget "&1 values are :"
  message r demo-widget "  Your integer is           : "'demo%widget%&1%winteger'
  message r demo-widget "  Your float number is      : "'demo%widget%&1%wdouble'
  message r demo-widget "  Your integer array is     : "'demo%widget%&1%winteg3[1]' 'demo%widget%&1%winteg3[2]' 'demo%widget%&1%winteg3[3]'
  message r demo-widget "  Your character string is  : "'demo%widget%&1%wstring'
  message r demo-widget "  The slider is at position : "'demo%widget%&1%wslider'
  message r demo-widget "  You chose file            : "'demo%widget%&1%wfile'
  message r demo-widget "  Your choice 1 is          : "'demo%widget%&1%wchoice'
  message r demo-widget "  Your choice 2 is          : "'demo%widget%&1%weditch'
  message r demo-widget "  Your choice 3 has index # : "'demo%widget%&1%windex'
  message r demo-widget "  The check box status is   : "'demo%widget%&1%wlogical'
  message r demo-widget " "
end procedure demo_display_values
!
begin procedure demo_display_all_values
  @ demo_display_values main
  @ demo_display_values sub
  @ demo_display_values sub1
  @ demo_display_values sub2
  @ demo_display_values sub3
end procedure demo_display_all_values
!
begin procedure demo_prompt_values
  sic\say "Fill the fields for the &1 variables (found in demo%widget%&1%)"
  sic\let demo%widget%&1%winteger 'demo%widget%&1%winteger'  /prompt "&1:         give an integer"
  sic\let demo%widget%&1%wdouble  'demo%widget%&1%wdouble'   /prompt "&1:     give a float number"
  sic\let demo%widget%&1%winteg3  'demo%widget%&1%winteg3[1]' 'demo%widget%&1%winteg3[2]' 'demo%widget%&1%winteg3[3]'  /prompt "&1:         give 3 integers"
  sic\let demo%widget%&1%wstring  'demo%widget%&1%wstring'   /prompt "&1: give a character string"
  sic\let demo%widget%&1%wslider  'demo%widget%&1%wslider'   /prompt "&1:          tune the value" /range 0 100
  sic\let demo%widget%&1%wfile    'demo%widget%&1%wfile'     /prompt "&1:           choose a file" /file
  sic\let demo%widget%&1%wchoice  'demo%widget%&1%wchoice'   /prompt "&1:   make a choice in list" /choice Choice1  Choice2  Choice3
  sic\let demo%widget%&1%weditch  'demo%widget%&1%weditch'   /prompt "&1:   edit or make a choice" /choice "Value1" "Value2" "Value3" *
  sic\let demo%widget%&1%windex   'demo%widget%&1%windex'    /prompt "&1: choose an index in list" /index Index1 Index2 Index3
  sic\let demo%widget%&1%wlogical 'demo%widget%&1%wlogical'  /prompt "&1:          check the box?"
end procedure demo_prompt_values
!
begin procedure demo_default_values
  ! (Re)set the default values in the input sub-structure
  sic\let demo%widget%&1%winteger 123
  sic\let demo%widget%&1%wdouble  1.23
  sic\let demo%widget%&1%winteg3  1 2 3
  sic\let demo%widget%&1%wstring  "Some default string"
  sic\let demo%widget%&1%wslider  50
  sic\let demo%widget%&1%wfile    " "
  sic\let demo%widget%&1%wchoice  "CHOICE1"
  sic\let demo%widget%&1%weditch  "Default"
  sic\let demo%widget%&1%windex   1
  sic\let demo%widget%&1%wlogical .false.
end procedure demo_default_values
!
begin data gag_scratch:demo-widget.hlp
1 GILDAS Demo widget

This widget exposes a part of the Gildas capabilities. It is fully
written with Sic commands (SIC\ and GUI\ languages).

2 DEMO%WIDGET%MAIN%WINTEGER
	is an integer value of your choice
2 DEMO%WIDGET%MAIN%WDOUBLE
	is a float value of your choice
2 DEMO%WIDGET%MAIN%WINTEG3
	is an array of 3 Integer values of your choice
2 DEMO%WIDGET%MAIN%WFILE
	is a file name of your choice
2 DEMO%WIDGET%MAIN%WCHOICE
	is a string of your choice chosen among a list
2 DEMO%WIDGET%MAIN%WINDEX
	is the Integer value of your choice among a list
2 DEMO%WIDGET%MAIN%WLOGICAL
	is a logical value of your choice
end data gag_scratch:demo-widget.hlp
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Define the widget variables
if (.not.exist(demo)) then
  define structure demo /global
end if
!
if (.not.exist(demo%widget)) then
  define structure demo%widget /global
end if
!
if (.not.exist(demo%widget%main)) then
  define structure demo%widget%main            /global
  define integer   demo%widget%main%winteger   /global
  define double    demo%widget%main%wdouble    /global
  define integer   demo%widget%main%winteg3[3] /global
  define character demo%widget%main%wstring*64 /global
  define double    demo%widget%main%wslider    /global
  define character demo%widget%main%wfile*128  /global
  define character demo%widget%main%wchoice*10 /global
  define character demo%widget%main%weditch*20 /global
  define integer   demo%widget%main%windex     /global
  define logical   demo%widget%main%wlogical   /global
end if
!
if (.not.exist(demo%widget%sub)) then
  define structure demo%widget%sub /like demo%widget%main  /global
end if
!
if (.not.exist(demo%widget%sub1)) then
  define structure demo%widget%sub1 /like demo%widget%main  /global
end if
!
if (.not.exist(demo%widget%sub2)) then
  define structure demo%widget%sub2 /like demo%widget%main  /global
end if
!
if (.not.exist(demo%widget%sub3)) then
  define structure demo%widget%sub3 /like demo%widget%main  /global
end if
!
! Set the default values for the widget variables
@ demo_default_values main
@ demo_default_values sub
@ demo_default_values sub1
@ demo_default_values sub2
@ demo_default_values sub3
!
! Create the widget
gui\panel "This is the demo widget" gag_scratch:demo-widget.hlp
!
! Toolbar
gui\button "sic\say Hello world"  "Say Hello world"
gui\menu "Defaults" /choices
  gui\button "sic\say Hello1" "Say Hello1"
  gui\button "sic\say Hello2" "Say Hello2"
  gui\button "sic\say Hello3" "Say Hello3"
gui\menu /close
gui\menu "Defaults" /choices
  gui\button "@ demo_default_values main" "Default main%"
  gui\button "@ demo_default_values sub"  "Default sub%"
  gui\button "@ demo_default_values sub1" "Default sub1%"
  gui\button "@ demo_default_values sub2" "Default sub2%"
  gui\button "@ demo_default_values sub3" "Default sub3%"
gui\menu /close
!
! Content
@ demo_prompt_values main
!
! Something more advanced
sic\say ""  ! Draw a line
sic\say "Access MAIN and SUB values in sub-widgets"
!
! First sub-widget
gui\button "@ demo_display_all_values" "Action" "Access the SUB variable set?" gag_demo:none.hlp "Parameters"
sic\say "First sub-widget: access the SUB variable set"
sic\say ""  ! Draw a line
@ demo_prompt_values sub
!
! Second sub-widget
gui\button "@ demo_display_all_values" "Action" "Access MAIN and SUB variable sets?" gag_demo:none.hlp "Parameters"
sic\say "Second sub-widget: access the MAIN and SUB variable sets"
sic\say ""  ! Draw a line
@ demo_prompt_values main
sic\say ""  ! Draw a line
@ demo_prompt_values sub
!
! Third sub-widget: too long
gui\button "@ demo_display_all_values" "Action" "Test long widget?" gag_demo:none.hlp "Parameters"
sic\say "Third sub-widget: long widget"
sic\say ""  ! Draw a line
@ demo_prompt_values main
sic\say ""  ! Draw a line
@ demo_prompt_values sub
sic\say ""  ! Draw a line
@ demo_prompt_values sub1
sic\say ""  ! Draw a line
@ demo_prompt_values sub2
sic\say ""  ! Draw a line
@ demo_prompt_values sub3
!
gui\go "@ demo_display_all_values"  ! Main GO button
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
