!! Modul JapiMenu + program T_japigraf21
!!
!! Testovani JapiGraf ver.2
!! Test - menu definovane v modulu JapiMenu
!! Test - tisk z menu
!!

module JapiMenu

use japi
use JapiGraf2

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

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

program T_JapiGraf21

use std_type
use japi
use JapiGraf2
use JapiMenu
use rgbcolor2

implicit none

integer :: frame1,canvas1
type(ViewPortInfo) :: infoVP1
type(UPinfo) :: infoPA1, infoCA1
real(kind=DP) :: UOdX = 0.4, UDoX = 10.3, UodY = -1.1, UDoY = 1.1,&
					UkrokX = 1.0, UkrokY = 0.2
integer :: DilkuX = 5, DilkuY = 2

call StartJapi()

call DefViewPort(0.1_DP,0.1_DP,"Test verze 2",&
				0.7_DP,0.5_DP,.true.,&
				UOdX,UDoX,UOdY,UDoY,&
				gray90,LightYellow,infoVP1)

infoPA1 = infoVP1%PlotAreaUPinfo
infoCA1 = infoVP1%canvasUPinfo
frame1 =infoVP1%frame
canvas1 = infoVP1%canvas

call AddMenu(infoVP1)

print *,"Hodnoty v infoCA a infoPA)"
Print *,"Canvas"
Print "(4F10.2)",infoCA1%Uinfo%uxmin,infoCA1%Uinfo%uxmax,&
				infoCA1%Uinfo%uymin,infoCA1%Uinfo%uymax
Print "(4I10)", infoCA1%Pinfo%polx,infoCA1%Pinfo%poly,&
				infoCA1%Pinfo%Psirka,infoCA1%Pinfo%pvyska
print *, "PlotArea"
Print "(4F10.2)",infoPA1%Uinfo%uxmin,infoPA1%Uinfo%uxmax,&
				infoPA1%Uinfo%uymin,infoPA1%Uinfo%uymax
Print "(4I10)",	infoPA1%Pinfo%polx,infoPA1%Pinfo%poly,&
				infoPA1%Pinfo%psirka,infoPA1%Pinfo%pvyska

Print *, "pix2ux a pix2uy",infoVP1%pix2ux, infoVP1%pix2uy
print *,"AspRatio = ",AspRatio
call j_show(frame1)


call OsaX(infoVP1,UOdX,UDoX,UOdY,UKrokX,DilkuX,black,.true.,gray80)
call PlotLabels(infoVP1,"Toto je osa X","Osa Y","Test T_JapiGraf1",purple4)
call OsaY(infoVP1,UOdY,UDoY,UOdX,UKrokY,DilkuY,black,.true.,gray80)
!~ call Uline(infoVP1,Ubod(10.0,0.0),Ubod(10.0,10.0),black)
!~ call Uline(infoVP1,Ubod(0.0,10.0),Ubod(10.0,10.0),black)
!~ call ULine(infoVP1,Ubod(0.0_DP,0.0_DP),Ubod(10.0_DP,10.0_DP),red)
!~ call DrawCircle(infoVP1,Ubod(5.0,5.0),1.0_DP,green)

call PlotSymbol5(infoVP1,Ubod(5.0,5.0),kruh5,cyan)
call PlotSymbol3(infoVP1,Ubod(1.0,1.0),plus3,blue)
call PlotSymbol3(infoVP1,Ubod(2.0,2.0),krat3,blue)

! cekani na menu

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


end program T_JapiGraf21
