I think this example may point to a bug, or perhaps I am doing something silly?
module example_22_5_20
use clrwin
implicit none
integer, parameter :: dp=kind(1.d0), gw = 800, gh = 600
real(kind=dp) :: x_array(1:20)=0.d0 , y_array(1:20)=0.d0
contains
integer function generate_data()
integer i
do i = 1, 20
x_array(i)=random@() - 0.5d0 ; y_array(i)=random@() - 0.5d0
end do
generate_data = 2
end function generate_data
integer function plot()
integer, save :: iw
call winop@('%pl[independent,x_array,link=none,symbol=6,gridlines,frame,margin=(100,100,100,100)]')
iw = winio@('%pl&',gw,gh,20,x_array,y_array)
iw = winio@('%ob&')
iw = winio@('%^tt[SP redraw]&',sp_redraw_cb)
iw = winio@('%2nl%^tt[x_axis]&',x_axis_cb)
iw = winio@('%2nl%ws&','1. Click on x axis button, and note position of text drawn on screen.')
iw = winio@('%1nl%ws&','2. Click on SP redraw button.')
iw = winio@('%1nl%ws&','3. Click on x axis button. Text is now drawn in different position.')
iw = winio@('%2nl%ws&','If the calls to rotate_font@ (associated with drawing y axis text)')
iw = winio@('%1nl%ws&','are commented out this does not happen.')
iw = winio@('%cb&')
iw = winio@(' ')
iw = winio@('%gr&',gw,gh)
iw = winio@('%ob&')
iw = winio@('%^tt[SP redraw]&',sp_redraw_cb)
iw = winio@('%2nl%^tt[x_axis]&',x_axis_cb)
iw = winio@('%2nl%ws&','1. Click on x axis button, and note position of text drawn on screen.')
iw = winio@('%1nl%ws&','2. Click on SP redraw button.')
iw = winio@('%1nl%ws&','3. Click on x axis button. Text is now drawn in different position.')
iw = winio@('%2nl%ws&','If the calls to rotate_font@ (associated with drawing y axis text)')
iw = winio@('%1nl%ws&','are commented out this does not happen.')
iw = winio@('%cb&')
iw = winio@(' ')
plot = 2
end function plot
integer function sp_redraw_cb()
call simpleplot_redraw@()
sp_redraw_cb = 2
end function sp_redraw_cb
integer function x_axis_cb()
integer tw, th
call get_text_size@('x label', tw, th)
call draw_characters@('x label', 400 - tw, gh-50, rgb@(0,0,0))
call rotate_font@(90.d0)
! Here draw y label
!
call rotate_font(0.d0) !Reset default angle for drawing text to horizontal
x_axis_cb = 2
end function x_axis_cb
end module example_22_5_20
program main
use example_22_5_20
implicit none
integer i
i = generate_data() ; i = plot() ; i=i
end program main