! Testovani JapiGraf ver.2

module JapiMenu

use japi
use JapiGraf

implicit none
private

public :: AddMenu,StartMenu

integer,public :: menubar,soubor,konec,tisk,tiskcanvas		! pro menu  

contains

subroutine AddMenu(infVP)
	type(ViewPortInfo),intent(in) :: infVP
	
	menubar = j_menubar(infVP%frame)
	soubor  = j_menu(menubar,"Soubor")
	tisk = j_menu(menubar,"Tisk")
	tiskcanvas = j_menuitem(tisk,"Canvas")
	konec	= j_menuitem(soubor,"Konec")
end subroutine AddMenu

subroutine StartMenu(infVP)
	type(ViewPortInfo),intent(in) :: infVP
	integer :: menuobj

	DO
		menuobj = j_nextaction()
		if ((menuobj==infVP%frame).or.(menuobj==konec)) exit
		if (menuobj==tiskcanvas) call j_print(infVP%canvas)
	end do
end subroutine StartMenu

end Module JapiMenu

! --------------- modul funkce --------------

module funkce

use std_type
implicit none

private

public :: Sinus
!real(kind=DP),dimension(3),parameter,public :: pole = (/1.5,0.5,0.2/)

contains
function Sinus(x) result(y)
	real(kind=DP),intent(in) :: x
	!real(kind=DP),dimension(:),intent(in),optional :: pole
	REAL(KIND=DP) :: y
	y = sin(x)+0.5*sin(2*x)+0.25*sin(3*x)
end function Sinus

end module funkce



! -------------------- Zacatek programu ----------------------

program T_JapiGraf22

use std_type
use japi
use JapiGraf
!use JapiMenu
use funkce
use rgbcolor

implicit none

type(ViewPortInfo) :: infoVP1
real(kind=DP),parameter :: Xmin = 0.0, Xmax = 10.0, &
							Ymin = -2.0, Ymax = 2.0, &
							OdX = Xmin, DoX = Xmax, &
							OdY = Ymin, DoY = Ymax, &
							polohaX = Ymin, polohaY = Xmin, &
							krokX = 1.0 , krokY = 0.5

call StartJapi()

call DefViewPort(0.1_DP,0.1_DP,"Test verze 2", &
				0.7_DP,0.4_DP,.false., &
				Xmin, Xmax, Ymin, Ymax, &
				gray90,LightYellow,infoVP1)

!call AddMenu(infoVP1)
call ShowVP(infoVP1)


call OsaX(infoVP1,Xmin,Xmax,polohaX,krokX,5,black,.true.,gray80)
call OsaY(infoVP1,Ymin,Ymax,polohaY,krokY,5,black,.true.,gray80)
call PlotLabels(infoVP1,"X","Funkce","Test PlotFunction",black)
call ULine(infoVP1,Ubod(xmin,0.0_DP),Ubod(xmax,0.0_DP),gray50)

call PlotFunction(infoVP1,Sinus,red,OdX=1.0_DP,krokX=0.05_DP)

! cekani na menu

call StartStdMenu(infoVP1)
!read *
call j_quit()


end program T_JapiGraf22
