Hi!
This is program was created by Luis Basso, analog clock.
Works fine with xHarbour, with Harbour I get this is error:

error base/1001 Undefined function: HTIMER
Called from HTIME(0)
Called from HRELOGANALOGICO:ADDNEWOBJECT(297)
Called from HRELOGANALOGICO:CREATE(78)
Called from HRELOGANALOGICO:ACTIVATE(400)
Called from HCONTAINER:NEW(371)
Called from HRELOGANALOGICO:NEW(69)
Called from MAIN(28)

#include "hwgui.ch"
#include "hbclass.ch"

#IfnDef __XHARBOUR__
    REQUEST HB_GT_GUI
    ANNOUNCE HB_GTSYS
    REQUEST HB_GT_GUI_DEFAULT
#EndIf

STATIC Thisform


//FUNCTION HRELOGIO
Function Main()

 LOCAL oShape1, oRelogio1, oRelogio2, oRelogio3, oLabel1, oLabel2

  INIT DIALOG oDlg TITLE "Relógios Analógicos" ;
    AT 247,101 SIZE 441,247 ;
        FONT HFont():Add( 'Verdana',0,-13,400,,,) CLIPPER  NOEXIT  ;
     STYLE WS_POPUP+WS_CAPTION+WS_SYSMENU+WS_SIZEBOX+DS_CENTER  ;
             COLOR 12320767
    Thisform := oDlg

   @ 225,20 SAY oLabel1 CAPTION "Italia" TRANSPARENT SIZE 80,19
   @ 348,24 SAY oLabel2 CAPTION "Tokio"  TRANSPARENT SIZE 80,19

    oRelogio1 := HRelogAnalogico():New(,,150,150)
    oRelogio1:reset(29,21)
    oRelogio1:bcolor := rgb(255,255,255)
    oRelogio2 := HRelogAnalogico():New(202,56,100,100)
    oRelogio2:bcolor :=  7303167
    oRelogio2:fuso :=  3
    oRelogio3 := HRelogAnalogico():New(328,72,75,75)
    oRelogio3:bcolor := 16761220
    oRelogio3:fuso := 11

   @ 140,199 BUTTONEX oButtonex1 CAPTION "Close"  SIZE 161,32 ;
        STYLE WS_TABSTOP   ;
        ON CLICK {|| ThisForm:CLOSE()  }

   ACTIVATE DIALOG oDlg


RETURN oDlg:lresult


CLASS HRelogAnalogico INHERIT HContainer

  DATA oLabelTime
  DATA Fuso INIT 0

   METHOD NEW()
   METHOD INIT()
   METHOD Hora()
   METHOD Reset( nleft,nTop,nWidth,nHeigt )
   METHOD Visible( lVisible ) SETGET
   METHOD Penduricos( )
   METHOD Create()
  METHOD AddNewObject()

   END CLASS

   METHOD NEW( nleft,ntop,nwidth,nheight ) CLASS HRelogAnalogico

  nWidth := IIF(  nWidth = Nil ,150, nWidth )
  nHeight := IIF( nHeight = Nil ,150, nHeight )

  Super:New(,,,nLeft,nTop,nWidth+1,nHeight+1)
  ::lnoBorder := .T.

  RETURN Self

 METHOD CREATE() CLASS HRelogAnalogico
 // METHOD Activate() CLASS HRelogAnalogico

   IF !::lCreate
      ::addnewobject( "tmrTimer" ,"htimer" )
      ::addnewobject( "shpesfera" ,"hshape", {|This| shpesfera_Init( This, 
self ) })
      ::addNewobject( "oShapepino", 'HShape' )
      FOR lnI = 0 TO 55 STEP 5
          lcO := "shp"+TRANS(lnI,"@L 99")
          lcL := "lbl"+TRANS(lnI,"@L 99")
         lcO := ::addNewobject( lco, 'HShape' )
         lcL :=  ::addNewobject( lcL, 'HStatic' )
        NEXT
      ::LinHor := ::addNewobject( "LinHor", 'HLine' )
      ::LinMin := ::addNewobject( "LinMin", 'HLine' )
      ::LinSeg := ::addNewobject( "LinSeg", 'HLine' )
   ENDIF
   ::lCreate := .T.
   RETURN NIL

   METHOD Init CLASS HRelogAnalogico
      LOCAL lnCX,lnCY,lnH, lcL, lcO


   ::tmrTimer:baction := {|| ::Hora() }

  ::shpesfera:nLeft := 0
  ::shpesfera:nTop := 0
  ::shpesfera:nWidth := ::nWidth
  ::shpesfera:nHeight := ::nheight

  ::shpesfera:nCurvature := 360
  ::shpesfera:nfStyle := 10
  ::shpesfera:BCOLOR := ::bColor

      *--- Horas

      lnCX := ::nWIDTH / 2
      lnCY := ::nHEIGHT / 2

     WITH OBJECT ::oShapepino
        :nwidth = 8
        :nheight = 8
        :nborder = 1
      :nCurvature := 45
      :nfStyle := 10
      :setcolor(,96)
    END

      lnH := 0
      FOR lnI = 0 TO 55 STEP 5
        lcO := "shp"+TRANS(lnI,"@L 99")
        //lcL := "lbl"+TRANS(lnI,"@L 99")
        lnA := lnI * 6
       lcO := ::addNewobject( lco, 'HShape' )
       //lcL :=  ::addNewobject( lcL, 'HStatic' )
        WITH OBJECT  lcO
          :nwidth = 5 + int( ::nwidth/100 )
          :nheight = 5 + int( ::nheight/100 )
          :nborder = 2
          :ncurvature := 20
          :bcolor := 250
        END

      NEXT
  ::linHor:nBORDER := 5
  ::linHor:setCOLOR(RGB(0,0,255))
  ::linHor:LineSlant := "/"
  ::linHor:oPenLight := HPen():Add( BS_SOLID, 3, RGB(0,0,255) )
  ::linMin:nBORDER := 3
  ::linMin:LineSlant := "\"
  ::linMin:tCOLOR := RGB(0,0,255)
  ::linMin:oPenLight := HPen():Add( BS_SOLID, 2, RGB(0,0,255) )
  ::linSeg:nBORDER := 1
  ::linSeg:LineSlant := "/"
  ::linSeg:tCOLOR := RGB(0,0,255)
  ::linSeg:oPenLight := HPen():Add( BS_SOLID, 1, RGB(0,0,0) )
  ::Penduricos()
  ::tmrTimer:Interval := 1000
   ::Hora()

   RETURN Nil

  METHOD Penduricos CLASS HRelogAnalogico
      LOCAL lnCX,lnCY,lnH, lcL, lcO

     shpesfera_Init( ::shpesfera, Self )

       lnCX := ::nWIDTH / 2
      lnCY := ::nHEIGHT / 2
      ::oShapepino:nLeft :=  lnCX - 4
      ::oShapepino:nTop :=   lnCY - 4
      ::oShapepino:move()
      lnH := 0
      FOR lnI = 0 TO 55 STEP 5
        lnA := lnI * 6
      lcO := ::&("shp"+TRANS(lnI,"@L 99") )
      //lcL := ::&("lbl"+TRANS(lnI,"@L 99") )
        WITH OBJECT  lcO
        //*
          // SIN(DTOR(lnA+90))<0 parte de baixo
          :nTOP := :nTop + lnCY - (lnCY * SIN(DTOR(lnA+90))) + ;
            IIF(SIN(DTOR(lnA+90))<0,-6,IIF(SIN(DTOR(lnA+90))>0,0,-6))
          :nLEFT := :nLeft + lnCX - (lnCX * COS(DTOR(lnA+90))) + ;
            IIF(COS(DTOR(lnA+90))<0,-6,IIF(COS(DTOR(lnA+90))>0,0,-6))
          :move()
         */
         *:hide()
        END
    NEXT
    ::hora()
   RETURN Nil

   METHOD hora( ) CLASS HRelogAnalogico
      LOCAL ln, lnAng, lnCos, lnSen, ;
        lnCoI, lnCoD, lnSeI, lnSeD
     LOCAL lnCX, lnCY, lnA, lnX1, lnX2, lnY1, lnY2, lnC

      lnCX := ::nWIDTH / 2 //+ ::nLeft
      lnCY := ::nHEIGHT / 2 //+ ::nTop
      *--- Hora actual
      ln := SECONDS() + ( ::Fuso * 3600 )
      *--- Posi?Æo segundos
      lnA := INT(ln % 60) * 6

      lnC := .95
      lnX1 := MIN(lnCX - (lnCX * COS(DTOR(lnA + 90))) * lnC, lnCX)
      lnY1 := MIN(lnCY - (lnCY * SIN(DTOR(lnA + 90))) * lnC, lnCY)
      lnX2 := MAX(lnCX - (lnCX * COS(DTOR(lnA + 90))) * lnC, lnCX)
      lnY2 := MAX(lnCY - (lnCY * SIN(DTOR(lnA + 90))) * lnC, lnCY)
      ::linSeg:nTOP :=  lnY1 //+ ::nTop
      ::linSeg:nLEFT := lnX1 //+ ::nLeft
      ::linSeg:nHEIGHT := lnY2-lnY1 + 1
      ::linSeg:nWIDTH := lnX2 - lnX1 + 1
     ::linSeg:lineSLANT := IIF(((lnA>=0.and.lnA<=90) .OR. 
(lnA>=180.and.lnA<=270)),"/","\")

      *--- Posi?Æo minutos
      lnA := INT((ln / 60) % 60) * 6
      lnC := .75
      lnX1 := MIN(lnCX - (lnCX * COS(DTOR(lnA + 90))) * lnC, lnCX)
      lnY1 := MIN(lnCY - (lnCY * SIN(DTOR(lnA + 90))) * lnC, lnCY)
      lnX2 := MAX(lnCX - (lnCX * COS(DTOR(lnA + 90))) * lnC, lnCX)
      lnY2 := MAX(lnCY - (lnCY * SIN(DTOR(lnA + 90))) * lnC, lnCY)
      ::linMin:nTOP :=  lnY1 //+ ::nTop
      ::linMin:nLEFT := lnX1 //+ ::nLeft
      ::linMin:nHEIGHT := lnY2-lnY1 + 1
      ::linMin:nWIDTH := lnX2 - lnX1 + 1
      ::linMin:lineSLANT := IIF(((lnA>=0.and.lnA<=90) .OR. 
(lnA>=180.and.lnA<=270)),"/","\")
      *--- Posi?Æo horas
      lnA := ( (ln / 3600) % 12)* 30
      lnC := .55
      lnX1 := MIN(lnCX - (lnCX * COS(DTOR(lnA + 90))) * lnC, lnCX)
      lnY1 := MIN(lnCY - (lnCY * SIN(DTOR(lnA + 90))) * lnC, lnCY)
      lnX2 := MAX(lnCX - (lnCX * COS(DTOR(lnA + 90))) * lnC, lnCX)
      lnY2 := MAX(lnCY - (lnCY * SIN(DTOR(lnA + 90))) * lnC, lnCY)
      ::linHor:nTOP := lnY1 //+ ::nTop
      ::linHor:nLEFT := lnX1 //+ ::nLeft
      ::linHor:nHEIGHT := lnY2-lnY1 + 1
      ::linHor:nWIDTH := lnX2 - lnX1 + 1
    // horas
      ::linHor:lineSLANT := IIF(((lnA>=0.and.lnA<=90) .OR. 
(lnA>=180.and.lnA<=270)),"/","\")
    RedrawWindow(::linhor:handle,RDW_ERASE + RDW_INVALIDATE )
    ::linhor:move(::linhor:nLeft,::linhor:nTOP , ::linhor:nWidth, 
::linhor:nHeight)
    // minutos
    RedrawWindow(::linmin:handle,RDW_ERASE + RDW_INVALIDATE )
    ::linmin:move(::linmin:nLeft,::linmin:nTOP , ::linmin:nWidth, 
::linmin:nHeight)
    // segundos
    RedrawWindow(::linseg:handle,RDW_ERASE + RDW_INVALIDATE )
    ::linseg:move(::linseg:nLeft,::linseg:nTOP , ::linseg:nWidth, 
::linseg:nHeight)

    IF !empty( ::oLabelTime )
        ::olabeltime:caption := TIME() 
//str(::linmin:nwidth)+str(::linmin:nheight)
     ENDIF


   RETURN Nil

  METHOD Visible( lVisible )
  LOCAL  lnI, lcO,lcL
    IF lVisible != Nil
      IF lVisible
        ::TMRTIMER:Interval := 1000
      ELSE
        ::TMRTIMER:Interval := 0
      ENDIF
       if lvisible
          ::penduricos()
          ::shpesfera:INIT( ::shpesfera, self )
       endif
    ENDIF
    RETURN super:visible( lVisible )

   METHOD Reset( nLeft, nTop, nWidth, nHeight, tcolor, bcolor )
     LOCAL  lnI, lcO,lcL

    RedrawWindow( ::oParent:Handle, RDW_ERASE + RDW_INVALIDATE , ::nLeft, 
::nTop, ::nWidth , ::nHeight )
     ::nLeft   := nLeft
     ::nTop    := nTop
      ::nHeight := IIF( nHeight != Nil, nHeight, ::nHeight )
      ::nWidth  := IIF( nWidth != Nil, nWidth, ::nWidth )
     IF ::lINit
        ::penduricos()
        shpesfera_Init( ::shpesfera, Self )
      ENDIF
    ::move()

  RETURN Nil

METHOD AddNewObject( cName, cClass, bInit ) //CLASS HCustomWindow
   Local oSelf, cClassNew &&, oContainer
   Memvar oContainer
   Private oContainer

   IF EMPTY( cName ) .OR. EMPTY( cClass )
      RETURN Nil
   ENDIF
   oContainer := Self
   cClass := UPPER( cClass )
   IF oContainer:oParent != NiL
       cClassNew := "New( oContainer, , )"
   ELSE
       cClassNew := "New( , , )" // 0, 0, 0, 0 )"
   ENDIF
   oSelf := & ( cClass + "():" + cClassNew )
   IF VALTYPE( oSelf ) = "O"
      IF __objHasData( oSelf, "Name" )
         oSelf:Name := cName
      ELSE
         ADDPROPERTY( oSelf, "Name", cName )
      ENDIF
      ADDPROPERTY( oContainer, cName, oSelf )
      IF ISBLOCK( bInit )
         oSelf:bInit := bInit
         Eval( bInit, oSelf )
      ENDIF
   ENDIF
   Release oContainer
   RETURN oSelf

   FUNCTION shpesfera_Init( This, oParent  )

     This:nLeft   := 0 //oParent:nLeft+1
     This:nTop    := 0 //oParent:nTop+1
      THIS:nHEIGHT := oParent:nHEIGHT - 1
      THIS:nWIDTH  := oParent:nWIDTH - 1
      this:move()

   RETURN Nil


*
*-- EndDefine: relojanalogico
**************************************************




_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to