program T_japi1

!! test knihovny JAPI - osy a menu

use std_type
use japi

integer :: framew,frameh,canvasw,canvash,canvasxp,canvasyp
Integer :: frame,canvas,menubar,soubor,konec,menobj

integer,parameter :: CanvasWidth=600 ,CanvasHeight=400

! standardni inicializace
IF( .NOT. j_start()) THEN
		PRINT*, "can't connect to JAPI server"
  		CALL j_quit()
  		stop
	END IF


frame = j_frame("Test1-frame")
call j_setsize(frame,CanvasWidth,CanvasHeight+100)
call j_setpos(frame,100,100)

menubar = j_menubar(frame)
soubor  = j_menu(menubar,"Soubor")
konec	= j_menuitem(soubor,"Konec")

print *,"FRAME"
frameh=j_getheight(frame)
print*,"Vyska frame = ",frameh
framew=j_getwidth(frame)
print*,"Sirka frame = ",framew


canvas = j_canvas(frame,CanvasWidth,CanvasHeight)
call j_setpos(canvas,0,45)
call j_setnamedcolorbg(canvas,J_light_gray)
!call j_translate(canvas,0,45)
call j_pack(frame)

print *,"CANVAS"
canvash=j_getheight(canvas)
print*,"Vyska canvas = ",canvash
canvasw=j_getwidth(canvas)
print*,"Sirka canvas = ",canvasw
canvasxp = j_getxpos(canvas)
print*,"X poloha canvas = ",canvasxp
canvasyp = j_getypos(canvas)
print*,"Y poloha canvas = ",canvasyp

call j_show(frame)

print *,"FRAME po j_pack"
frameh=j_getheight(frame)
print*,"Vyska frame = ",frameh
framew=j_getwidth(frame)
print*,"Sirka frame = ",framew

call j_setnamedcolor(canvas,J_blue)
call j_drawline(canvas,0,0,canvasw,canvash)
call j_cliprect(canvas,canvasw/4,canvash/4,canvasw/2+1,canvash/2+1)
call j_setnamedcolorbg(canvas,J_Yellow)
call j_drawrect(canvas,canvasw/4,canvash/4,canvasw/2,canvash/2)

call j_setnamedcolor(canvas,J_RED)
call j_drawline(canvas,0,0,canvasw,canvash)

! Ukoncit bud v okne cekanim na Enter prikazem
! read *
! nebo z menu Soubor/Konec
!
! Ceka na udalost z menu, zde jen Konec
NEXTACTION: DO
menobj = j_nextaction()
if (menobj==konec) call j_quit()
END DO NEXTACTION

end program T_japi1

