home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windoware
/
WINDOWARE_1_6.iso
/
source
/
f4w3api
/
f4w3api.kit
/
WINDEV
/
FORTRAN
/
FWCLOCK
/
DRAWFACE.FOR
< prev
next >
Wrap
Text File
|
1991-11-09
|
5KB
|
136 lines
$DEFINE GDI
$DEFINE USER
INCLUDE 'WINDOWS.FI'
SUBROUTINE DRAW_FACE
IMPLICIT NONE
C
C Author : Kevin B Black
C Date written : 23-Oct-1991
C Abstract :
C
C DRAW ANALOGUE CLOCK
C
C Subroutine to handle computation of window size specific values for the
C clock face and hand, and to draw the clock face (spots and numbers).
C
INCLUDE 'WINDOWS.FD' ! Include windows functions and parameters
INTEGER*2 I,J,X,Y,IDIGIT ! Work integers
REAL F,COSA,SINA ! Work reals
INTEGER*2 XSPOT,YSPOT ! Offsets to create spots on clock face
INTEGER*2 XDOT,YDOT ! Offsets tp create dots on clock face
INCLUDE 'FWCLOCK.FD' ! Include FWClock variables and parameters
C
C Set centre coordinates and radius of clock face
C
IF(WWIDTH.GT.WHEIGHT)THEN
RADIUS=WHEIGHT/2
ELSE
RADIUS=WWIDTH/2
ENDIF
IF(.NOT.IMANICON)RADIUS=RADIUS*0.95
AXC=WWIDTH/2
AYC=WHEIGHT/2
C
C Compute the sizes of the minute and hour `spots' for the clock face.
C
IF(.NOT.IMANICON)THEN
XSPOT=NINT(FLOAT(RADIUS)/60.0)
YSPOT=NINT(FLOAT(RADIUS)/60.0*VARATIO)
IF(XSPOT.EQ.0.OR.YSPOT.EQ.0)THEN
XSPOT=1
YSPOT=1
ENDIF
XDOT=1+NINT(FLOAT(RADIUS)/320.0)
YDOT=1.0+NINT(FLOAT(RADIUS)/320.0*VARATIO)
ENDIF
C
C Compute the vectors for the second hand for each minute of arc.
C
DO I=0,59
IF(I.GE.30)THEN
J=I-30
ELSE
J=I+30
ENDIF
IF(IMANICON)THEN
SHANDV(1,I).X=AXC
SHANDV(1,I).Y=AYC
ELSE
F=FLOAT(RADIUS)*0.10
SHANDV(1,I).X=AXC+NINT(F*SIN(PI-FLOAT(J)*ZINC))
SHANDV(1,I).Y=AYC+NINT(F*COS(PI-FLOAT(J)*ZINC)*VARATIO)
ENDIF
F=FLOAT(RADIUS)*0.695
SHANDV(2,I).X=AXC+NINT(F*SIN(PI-FLOAT(I)*ZINC))
SHANDV(2,I).Y=AYC+NINT(F*COS(PI-FLOAT(I)*ZINC)*VARATIO)
ENDDO
C
C Compute the vectors for the hour hand when FWClock is in the iconic state
C
IF(IMANICON)THEN
DO I=0,59
COSA=COS(PI-FLOAT(I)*ZINC)
SINA=SIN(PI-FLOAT(I)*ZINC)
F=FLOAT(RADIUS)*0.45
HHAND2(I).X=AXC+NINT(F*SINA)
HHAND2(I).Y=AYC+NINT(F*COSA*VARATIO)
F=FLOAT(RADIUS)*0.65
MHAND2(I).X=AXC+NINT(F*SINA)
MHAND2(I).Y=AYC+NINT(F*COSA*VARATIO)
ENDDO
ENDIF
C
C Select pen and brushes for drawing clock face
C
WSTATUS=SelectObject(FWCPS.HDC,FPEN)
WSTATUS=SelectObject(FWCPS.HDC,FBRUSH)
C
C Fill in the clock area
C
WSTATUS=FillRect(FWCPS.HDC,RCLOCK,BBRUSH)
C
C Label face, digits are drawn by the routine DIGIT, see later for
C more information. Also a single point is drawn at each of the
C second positions and a small circle at each five-minute interval
C (adjacent to the numerals).
C
DO I=1,60
COSA=COS(PI-FLOAT(I)*ZINC)
SINA=SIN(PI-FLOAT(I)*ZINC)
X=AXC+NINT(FLOAT(RADIUS)*0.7*SINA)
Y=AYC+NINT(FLOAT(RADIUS)*0.7*COSA*VARATIO)
IF((I/5)*5.EQ.I)THEN
IF(IMANICON)THEN
TRECT.LEFT=X-1
TRECT.TOP=Y+1
TRECT.RIGHT=X
TRECT.BOTTOM=Y
WSTATUS=FillRect(FWCPS.HDC,TRECT,FBRUSH)
ELSE
WSTATUS=Ellipse(FWCPS.HDC,X-XSPOT,Y+YSPOT,
* X+XSPOT,Y-YSPOT)
IDIGIT=I/5
X=AXC+NINT(FLOAT(RADIUS)*0.85*SINA)
Y=AYC+NINT(FLOAT(RADIUS)*0.85*COSA*VARATIO)
IF(IDIGIT.LT.10)THEN
CALL DIGIT(X,Y,IDIGIT,.TRUE.,0)
ELSE IF(IDIGIT.EQ.10)THEN
CALL DIGIT(X,Y,1,.TRUE.,-10)
CALL DIGIT(X,Y,0,.FALSE.,0)
ELSE IF(IDIGIT.EQ.11)THEN
CALL DIGIT(X,Y,1,.TRUE.,-10)
CALL DIGIT(X,Y,1,.FALSE.,0)
ELSE IF(IDIGIT.EQ.12)THEN
CALL DIGIT(X,Y,1,.TRUE.,-10)
CALL DIGIT(X,Y,2,.FALSE.,0)
ENDIF
ENDIF
ELSE IF(.NOT.IMANICON)THEN
WSTATUS=Rectangle(FWCPS.HDC,X-XDOT,Y+XDOT,
* X+XDOT,Y-YDOT)
ENDIF
ENDDO
RETURN
END