! Test functii grafice:
! Lineto; Rectangle; Ellipse;

Program QW2

use dflib
USE DFWIN

type(qwinfo) winfo

integer bkcolor, textcolor

!TYPE (rccoord) curpos
!integer(2) row, col

!TYPE (xycoord) xy
!integer(2) x2,y2

type(wxycoord) wxy
real(8) wx1, wy1, wx2, wy2

character(100) text
integer status

type(wxycoord), allocatable :: vertex(:)
integer(2) no_vert

integer(1) mask(8), horzmask(8)
integer(1) oldstyle(8)

DATA horzmask / #FF, #00, #7F, #FE, #00, #00, #00, #CC /

integer(2) line_mask

integer(4) handle_win

real(8) wx3, wy3, wx4, wy4, wx, wy



! 1sr window: bkcolor =bright white
open(10, file ='user', title ='Window 1')

! Maximize:
winfo%TYPE = QWIN$MAX
result = SETWSIZEQQ (10, winfo)


bkcolor =#FFFFFF
result = SETBKCOLORRGB (bkcolor)

call CLEARSCREEN($GWINDOW)

! Coordonate de fereastra:
status = SETWINDOW(.false., -100D0, -100D0, 500D0, 400D0) 

! Functii grafice:
result = INITIALIZEFONTS()


result = SETFONT('t''tms rmn''h18p')
grstat=SETCOLORRGB(#0000FF)		! red

wx1 =-100.D0
wy1 =-100.D0
CALL MOVETO_w(wx1, wy1, wxy)

text ='Times New Roman'
call outgtext(trim(text))


! LINETO:
wx1 =-90.D0
wy1 =-90.D0
CALL MOVETO_w(wx1, wy1, wxy)

call outgtext('(-90,-90)')
wx2 =-40.D0
wy2 =-40.D0
status =Lineto_w(wx2, wy2)

call outgtext('(-40,-40)')

! RECTANGLE:
wx1 =-90.D0
wy1 =0.D0

wx2 =wx1+50
wy2 =wy1 +30
status =rectangle_w($GBORDER, wx1,wy1, wx2, wy2)


CALL MOVETO_w(wx1, wy1, wxy)
call outgtext('(-90,0)')


CALL MOVETO_w(wx2, wy2, wxy)
call outgtext('(-40,30)')

ig =incharqq()
status =rectangle_w($GFILLINTERIOR , wx1,wy1, wx2, wy2)

handle_win =GETHWNDQQ (10) 
im =messagebox(handle_win, 'Dreptunghi plin'C, 'Mesaj'C, ior(MB_ICONEXCLAMATION, MB_OKCANCEL))


! POLYGON:
allocate(vertex(6))
vertex(1).wx =0D0;  vertex(1).wy =0D0; 
vertex(2).wx =10D0; vertex(2).wy =20D0; 
vertex(3).wx =20D0; vertex(3).wy =60D0; 
vertex(4).wx =30D0; vertex(4).wy =50D0; 
vertex(5).wx =20D0; vertex(5).wy =100D0; 
vertex(6).wx =10D0; vertex(6).wy =120D0; 

! Border:
status =polygon_w($GBORDER, vertex, int2(6))

! Filled:
ig =incharqq()
status =polygon_w($GFILLINTERIOR, vertex, int2(6))


! Filled with mask:
ig =incharqq()
CALL GetFILLMASK( oldstyle )
!* 
!write(*,*) oldstyle
!*

mask =(/0, 1, 0, 1, 0, 1, 0, 1/)

CALL SetFILLMASK(mask)

status =polygon_w($GFILLINTERIOR, vertex, int2(6))

! Oldstyle:
ig =incharqq()
CALL SetFILLMASK( horzmask )

status =polygon_w($GFILLINTERIOR, vertex, int2(6))


! restore "oldstyle"
!CALL SetFILLMASK( oldstyle )


! ELLIPSE:
wx1 =100.D0
wy1 =0.D0

wx2 =wx1+50
wy2 =wy1 +30

ig =incharqq()

status =ellipse_w($GBORDER, wx1,wy1, wx2, wy2)

! Filled - full:
ig =incharqq()
mask =#FF

CALL SetFILLMASK( mask )

status =ellipse_w($GFILLINTERIOR, wx1,wy1, wx2, wy2)


! LineStyle:
line_mask =#EEEE		! dash
call SetLineStyle(line_mask)

! Re-draw the rectangle:
! RECTANGLE:
wx1 =-90.D0
wy1 =150.D0

wx2 =wx1+50d0
wy2 =wy1 +30d0
status =rectangle_w($GBORDER, wx1,wy1, wx2, wy2)

ig =incharqq()
line_mask =#ECEC		! dash-dot
call SetLineStyle(line_mask)

wx1 =wx1 +100; wx2 =wx2+100
CALL MOVETO_w(wx1, wy1, wxy)
call outgtext('(*,*)')


status =rectangle_w($GBORDER, wx1,wy1, wx2, wy2)


! PIE:
wx1 =-90.D0
wy1 =200.D0

wx2 =wx1+50d0
wy2 =wy1 +30d0

wx3 =10d0
wy3 =10d0

wx4 =50d0
wy4 =200d0

ig =incharqq()

status =SetColorRGB(#FF0000)	! blue
status =PIE_W($Gborder, wx1, wy1, wx2, wy2, wx3, wy3, wx4, wy4)

! Fill:
ig =incharqq()

status =SetColorRGB(#AAAAAA)	! ~ Grey

status =PIE_W($GFillinterior, wx1, wy1, wx2, wy2, wx3, wy3, wx4, wy4)


end program QW2



