forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SET_TOOLTIP_TEXT@ + CHAR(10)

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
Kenneth_Smith



Joined: 18 May 2012
Posts: 499
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Mon Feb 22, 2021 12:48 pm    Post subject: SET_TOOLTIP_TEXT@ + CHAR(10) Reply with quote

In this example there is a %pl[full_mouse_input] region with a callback which updates the %th[at_cursor,ms_style] for the region with the current x,y coordinates at the mouse. At first glance this appears to work, but the call to SET_TOOLTIP_TEXT@ does not recognise the presence of CHAR(10), so the text in the tooltips which should be over two lines, is displayed as a single line.
Code:
module demo_mod
use clrwin
implicit none
integer, parameter :: dp=kind(1.d0), n = 10
real(dp) :: x(1:n), y(1:n)
integer :: show_coord = 1
integer(7) pl_handle
character(len=256) :: coord_string = ''
contains
  integer function gui()
  integer iw, i
    forall (i=1:n) x(i) = dble(i-1) ; forall (i=1:n) y(i) = x(i)*x(i)
    iw = winio@('%mn[Exit]&','exit')
    iw = winio@('%th[at_cursor,ms_style,delay]&', 1, 0)
    iw = winio@('%`rb[Show coordinates]&', show_coord)
    call winop@('%pl[full_mouse_input,x_array,title=Quadratic,gridlines,frame,colour=blue,width=2,symbol=10,smoothing=4]')
    iw = winio@('%nl%^?pl@&', 400, 400, n, x, y, pl_cb, coord_string)
    iw = winio@('%lc&',pl_handle)
    iw = winio@(' ')
    gui = 1
  end function gui
   
  integer function pl_cb()
  integer(7) gx,gy
  integer i
  real(kind=dp) px, py
  character(len=10) str_x, str_y
  if ( clearwin_string@('callback_reason') .eq. 'MOUSE_MOVE') then   
    if (show_coord .eq. 1) then
      gx = CLEARWIN_INFO@('GRAPHICS_MOUSE_X') ; gy = CLEARWIN_INFO@('GRAPHICS_MOUSE_Y')
      i = GET_PLOT_DATA@(gx,gy,px,py)
      if ( px .gt. minval(x) .and. px .lt. maxval(x) .and. py .gt. minval(y) .and. py .lt. maxval(y) ) then
        write(str_x,'(SPF10.3)') px ; write(str_y,'(SPF10.3)') py
        coord_string = trim(adjustl(str_x))//char(10)//trim(adjustl(str_y))
        print*, coord_string   
        call SET_TOOLTIP_TEXT@(pl_handle,coord_string) ! ## Why does SET_TOOLTIP_TEXT@ fail to detect the char(10) in cood_string?
        ! call SET_TOOLTIP_TEXT@(pl_handle,trim(adjustl(str_x))//char(10)//trim(adjustl(str_y))) ! ## Same output as above line
      else
        call SET_TOOLTIP_TEXT@(pl_handle,'')
      end if
    else
      call SET_TOOLTIP_TEXT@(pl_handle,'')
    end if
  end if 
  pl_cb = 2
  end function pl_cb

end module demo_mod

program main
use demo_mod
implicit none
integer i
  i = gui()
end program main
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7068
Location: Salford, UK

PostPosted: Mon Feb 22, 2021 3:21 pm    Post subject: Reply with quote

Ken

The initial value of coord_string must contain char(10).

I will modify the routine so that this will not be necessary in future.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 499
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Mon Feb 22, 2021 4:41 pm    Post subject: Reply with quote

Paul,
Thanks. I was completely bamboozled by that one.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group