I've been thinking that my applications would be easier to use if the user could select a graphics region and export it to the clipboard for inclusion into a report. Generally I have multiple graphics regions open at any one time. I've come up with the following lines of code, which does the job when the user right clicks on the graphic region they want to copy but I need to have a dedicated call back function for each graphic region. Is there a way that I can simplify this so that there is only a single call back for every %gr or %pl region, perhaps there is a way to identify the handle of the graphics region that initiated the call back, or use of a 'compound call-back' - I have found a fleeting reference to such a beast in the help files.
Any suggestions would be most welcome.
Thanks
Ken
program test
implicit none
include<windows.ins>
integer i, hand1, hand2, gw, gh
common /graphics/ hand1, hand2, gw, gh
integer gr_call_cb_1 ; external gr_call_cb_1
integer gr_call_cb_2 ; external gr_call_cb_2
real(kind=2) x(1:100), y(1:100), z(1:100), t, dt
hand1 = 1
hand2 = 2
gw = 300
gh = 200
t = 0.d0 ; dt = 0.0005d0
do i = 1, 100
x(i) = t
y(i) = sin(315.d0*t)
z(i) = cos(315.d0*t)
t = t + dt
end do
i = winio@('%`^pl[native,x_array,width=2,smoothing=4]&',gw,gh,100,x,y,hand1,gr_call_cb_1)
i = winio@('%`^pl[native,x_array,width=2,smoothing=4]' ,gw,gh,100,x,z,hand2,gr_call_cb_2)
!i = winio@('%`^gr[RED]&',gw,gh,hand1,gr_call_cb_1)
!i = winio@('%`^gr[BLUE]',gw,gh,hand2,gr_call_cb_2)
end program test
integer function gr_call_cb_1()
implicit none
include<windows.ins>
integer i1, i2, hand1, hand2, gw, gh
common /graphics/ hand1, hand2, gw, gh
integer SELECT_GRAPHICS_OBJECT@
if (clearwin_string@('CALLBACK_REASON') .eq. 'MOUSE_RIGHT_CLICK') then
i1 = SELECT_GRAPHICS_OBJECT@(hand1)
i2 = GRAPHICS_TO_CLIPBOARD@(0,0,gw,gh)
if (( i1 .eq. 1) .and. (i2 .eq. 1) ) write(6,*) 'STATUS: Graphics copied to clipboard'
end if
gr_call_cb_1 = 1
end function gr_call_cb_1
integer function gr_call_cb_2()
implicit none
include<windows.ins>
integer i1, i2, hand1, hand2, gw, gh
common /graphics/ hand1, hand2, gw, gh
integer SELECT_GRAPHICS_OBJECT@
if (clearwin_string@('CALLBACK_REASON') .eq. 'MOUSE_RIGHT_CLICK') then
i1 = SELECT_GRAPHICS_OBJECT@(hand2)
i2 = GRAPHICS_TO_CLIPBOARD@(0,0,gw,gh)
if (( i1 .eq. 1) .and. (i2 .eq. 1) ) write(6,*) 'STATUS: Graphics copied to clipboard'
end if
gr_call_cb_2 = 1
end function gr_call_cb_2