FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Help to create a method
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Help to create a method
Posted: Sat Jun 14, 2014 07:33 AM
Friend,
i wish create a method to print a week calendar with tcalex class
I made this method .. but i run bad

CLASS TWeekView FROM TCalex

METHOD PrintWeek()


Code (fw): Select all Collapse
  METHOD PrintWeek()  CLASS TWeekView
   local oPrn, oFont
   local nRowStep, nColStep
   local nRow := 0, nCol := 0, n, m


   local nGridHeight
   local nGridWidth
    local aDataArea := Array( 4 )



   DEFINE PEN oPen WIDTH  2

   PRINT oPrn NAME "Print week" PREVIEW

   if Empty( oPrn:hDC )
         return nil          // Printer was not installed or ready
      endif

     oPrn:SetLandScape()

     nRowStep:=20
     ncolStep:=15
     nHeightHeader := 120

      nGridHeight := oPrn:nHorzRes() / nRowStep
      nGridWidth  := oPrn:nVertRes() / nRowStep






    PAGE

   aDataArea[ 1 ] := ::nTopMargin - ::nVirtualTop
   aDataArea[ 2 ] := ::nLeftMargin + ::nLeftLabelWidth
   aDataArea[ 3 ] := (nGridHeight*nRowStep) + ::nTopMargin - ::nVirtualTop   / oPrn:nLogPixelX()
   aDataArea[ 4 ] := (nGridWidth*ncolStep) + ( ::nLeftMargin + ::nLeftLabelWidth ) /  oPrn:nLogPixelY()



     oPrn:Box(aDataArea[ 1 ], aDataArea[ 2 ], aDataArea[ 3], aDataArea[ 4 ], oPen  )


      ::PaintHorzLinesWithLeftLabels( oPrn )

      nCol2Step = ( Int( nGridWidth / ::nDays )) * ncolStep




   for n = 1 to 6
     oPrn:Line( ::nTopMargin - ::nDNameHeight,;
                ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step ),;
                (nGridHeight*nRowStep) + ::nTopMargin,;
                ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step ) )
  next



    oPrn:Box( ::nTopMargin - ::nDNameHeight,;
               aDataArea[ 2 ], ;
               ::nTopMargin+nHeightHeader, ;
               aDataArea[ 4 ], ;
               open)


       for n = 1 to 6
     oPrn:Line(::nTopMargin - ::nDNameHeight,;
              ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step ),;
              ::nTopMargin+nHeightHeader,;
              ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step ) )
        next



     // ::PaintHeader( oPrn )




       ENDPAGE
     ENDPRINT

   RETURN nil





It create the grid on a page setlandscape but it is too big

then I not Know How insert the record from citas dbf

thanks to all help me
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Help to create a method
Posted: Sat Jun 14, 2014 08:22 AM

Silvio,

If you don't provide us a self contained example its quite difficult to help you... :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Help to create a method
Posted: Sat Jun 14, 2014 11:09 AM
add this command on sampleo1.prg ( I wrote on bold the line to add )

METHOD BuildPop( nRow, nCol, oView, dDateFrom, dDateTo, nTimeFrom, nTimeTo ) CLASS SampleCalex

local oMenu
local oSelf := Self
local lNew := oView:oCalInfoSelected == NIL

MENU oMenu POPUP
MENUITEM If( lNew, "New appointment",;
"Modify appointment" ) ACTION oSelf:BuildDialog( oView, dDateFrom, dDateTo, nTimeFrom, nTimeTo )
if ! lNew
MENUITEM "Delete appointment" ACTION If( MsgYesNo( "Are you sure?" ), oView:DelCalInfo(), )
endif

MENUITEM "Today" ACTION ( oView:SetDate( date() ), If( oView:IsKindOf( "TWEEKVIEW" ),;
oView:SetWeekView(),;
oView:SetDayView() ) )


MENUITEM "Print Week" ACTION oView:oWeekView:PrintWeek()
ENDMENU





Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Help to create a method
Posted: Sat Jun 14, 2014 06:49 PM

Silvio,

Where is sampleo1.prg ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Help to create a method
Posted: Sat Jun 14, 2014 07:47 PM
I download Tcalex,zip of Febbrary from your download list

the test sample is sample01.prg



Antonio,

I made a new relase of METHOD Print Week

I add the Header ( number and day names) of the week I have on video

Code (fw): Select all Collapse
 


 METHOD PrintWeek()  CLASS TWeekView
   local oPrn, oFont
   local nRowStep, nColStep
   local nRow := 0, nCol := 0, n, m
   local nGridHeight
   local nGridWidth
   local aDataArea := Array( 4 )
   Local oPen
   Local dFirstDateWeek := ::GetFirstDateWeek()
   local aArea := Array( 4 )




   DEFINE PEN oPen WIDTH  2
   DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -90 OF oPrn
   PRINT oPrn NAME "Print week" PREVIEW

   if Empty( oPrn:hDC )
         return nil          // Printer was not installed or ready
      endif


      oPrn:SetLandScape()

      nGridHeight    := oPrn:nVertRes() / 20
      nGridWidth     := oPrn:nHorzRes() / 15

      nRowStep = oPrn:nVertRes() / 20
      nColStep = oPrn:nHorzRes() / 15

      nGridHeight = nGridHeight*nColStep  / 25.4
      nGridWidth  = nGridWidth*nRowStep   / 25.4

      nHeightHeader := 120

      nModCol = nGridWidth % ::nDays


    PAGE

   aDataArea[ 1 ] := ::nTopMargin - ::nVirtualTop
   aDataArea[ 2 ] := ::nLeftMargin + ::nLeftLabelWidth
   aDataArea[ 3 ] := nGridHeight + ::nTopMargin - ::nVirtualTop
   aDataArea[ 4 ] := nGridWidth + ( ::nLeftMargin + ::nLeftLabelWidth )


   // Print Box around
   oPrn:Box(aDataArea[ 1 ], aDataArea[ 2 ], aDataArea[ 3], aDataArea[ 4 ], oPen  )

      nCol2Step = ( Int( nGridWidth / ::nDays ))


   //  lines

      for n = 1 to 6

     oPrn:Line( ::nTopMargin - ::nDNameHeight,;
                ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step ),;
                (nGridHeight) + ::nTopMargin,;
                ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step ) )
  next



    oPrn:Box( ::nTopMargin - ::nDNameHeight,;
               aDataArea[ 2 ], ;
               ::nTopMargin+nHeightHeader, ;
               aDataArea[ 4 ], ;
               oPen)


       for n = 1 to 6
     oPrn:Line(::nTopMargin - ::nDNameHeight,;
              ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step ),;
              ::nTopMargin+nHeightHeader,;
              ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step ) )
        next







     //Print Header

     for n = 0 to 6


         aArea[ 1 ] = ::nTopMargin - ::nDNameHeight
         aArea[ 2 ] = ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step )



        dTemp = dFirstDateWeek + n
        cText = oemtoansi(CDoW( dFirstDateWeek + n ))
        cDay = Str( Day( dFirstDateWeek + n ), 2 )


      //Display character day week


        oPrn:Say( aArea[ 1 ], aArea[ 2 ]+210, cText, oFont )


      //Display numeric day

       oPrn:Say( aArea[ 1 ], aArea[ 2 ], cDay, oFont )


         next



        // Print appointments











       ENDPAGE
     ENDPRINT

   RETURN nil




But Now I not Know how insert the Hours and the record on Right columns
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Help to create a method
Posted: Sat Jun 14, 2014 08:42 PM
Antonio, I add also the colums of Hour at Left but now all is wrong ... perhaps you understand how make it good





Methods to add on CLASS TWeekView


METHOD PrintWeek() CLASS TWeekView // print week on Printer
METHOD PrintHourHorzLines(oPrn) CLASS TWeekView // print Hours and horizontal lines at left

Code (fw): Select all Collapse
 

METHOD PrintWeek()  CLASS TWeekView
   local oPrn, oFont
   local nRowStep, nColStep
   local nRow := 0, nCol := 0, n, m
   local nGridHeight
   local nGridWidth
   local aDataArea := Array( 4 )
   Local oPen
   Local dFirstDateWeek := ::GetFirstDateWeek()
   local aArea := Array( 4 )




   DEFINE PEN oPen WIDTH  2
   DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -90 OF oPrn
   PRINT oPrn NAME "Print week" PREVIEW

   if Empty( oPrn:hDC )
         return nil          // Printer was not installed or ready
      endif


      oPrn:SetLandScape()

      nGridHeight    := oPrn:nVertRes() / 20
      nGridWidth     := oPrn:nHorzRes() / 15

      nRowStep = oPrn:nVertRes() / 20
      nColStep = oPrn:nHorzRes() / 15

      nGridHeight = nGridHeight*nColStep  / 25.4
      nGridWidth  = nGridWidth*nRowStep   / 25.4

      nHeightHeader := 120

      nModCol = nGridWidth % ::nDays


      PAGE




   aDataArea[ 1 ] := ::nTopMargin - ::nVirtualTop
   aDataArea[ 2 ] := ::nLeftMargin + ::nLeftLabelWidth +800
   aDataArea[ 3 ] := nGridHeight + ::nTopMargin - ::nVirtualTop
   aDataArea[ 4 ] := nGridWidth + ( ::nLeftMargin + ::nLeftLabelWidth )


   // Print Box around
   oPrn:Box(aDataArea[ 1 ], aDataArea[ 2 ], aDataArea[ 3], aDataArea[ 4 ], oPen  )




      nCol2Step = ( Int( nGridWidth / ::nDays ))


   //  lines

      for n = 1 to 6

     oPrn:Line( ::nTopMargin - ::nDNameHeight,;
                ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step ),;
                (nGridHeight) + ::nTopMargin,;
                ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step ) )
  next



    oPrn:Box( ::nTopMargin - ::nDNameHeight,;
               aDataArea[ 2 ], ;
               ::nTopMargin+nHeightHeader, ;
               aDataArea[ 4 ], ;
               oPen)


       for n = 1 to 6
     oPrn:Line(::nTopMargin - ::nDNameHeight,;
              ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step ),;
              ::nTopMargin+nHeightHeader,;
              ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step ) )
        next







     //Print Header

     for n = 0 to 6


         aArea[ 1 ] = ::nTopMargin - ::nDNameHeight
         aArea[ 2 ] = ::nLeftMargin + ::nLeftLabelWidth + ( n * nCol2Step )



        dTemp = dFirstDateWeek + n
        cText = oemtoansi(CDoW( dFirstDateWeek + n ))
        cDay = Str( Day( dFirstDateWeek + n ), 2 )


      //Display character day week


        oPrn:Say( aArea[ 1 ], aArea[ 2 ]+210, cText, oFont )


      //Display numeric day

       oPrn:Say( aArea[ 1 ], aArea[ 2 ], cDay, oFont )


         next



        // Print appointments
        // Print the Hour first
    ::PrintHourHorzLines(oPrn)




       */





       ENDPAGE
     ENDPRINT

   RETURN nil




     METHOD PrintHourHorzLines(oPrn) CLASS TWeekView
   local nGridWidth,nGridHeight
   local n, nColStep, nRowStep
   local nTop, nBottom
   local aLabelArea
   local cTime := ""
   local nTime
   local oFontTime



      nGridWidth     := oPrn:nHorzRes() / 15
      nGridHeight    := oPrn:nVertRes() / 20

      nRowStep = oPrn:nVertRes() / 20
      nColStep = oPrn:nHorzRes() / 15

      nGridHeight = nGridHeight*nColStep  / 25.4
      nGridWidth  = nGridWidth*nRowStep   / 25.4



     DEFINE FONT oFontTime NAME "Ms Sans Serif" SIZE 0, -12 OF oPrn




   nRowStep   = 100

   nTime      = ::nStartHour * 100

   for n = 1 to ::nRowCount

      nTop    = ::nTopMargin + ( n * nRowStep ) - ::nVirtualTop

      //Only paint the visibles rows
      if nTop > 0 .and. nTop < nGridHeight + nRowStep

         if nTime % 100 == 0
            oPrn:Line(nTop - nRowStep,;
                    ::nLeftMargin,;
                    nTop - nRowStep,;
                    nGridWidth + ::nLeftMargin + ::nLeftLabelWidth,;
                    )

         //Show Left label

            aLabelArea = { ::nTopMargin + ( ( n - 1 ) * nRowStep ) - ::nVirtualTop, ;
                           ::nLeftMargin, ::nTopMargin + ( n  * nRowStep ) - ::nVirtualTop, ;
                           ::nLeftLabelWidth - 2 }


            cTime = ::oCalex:ConvertTime( nTime )

         *   DrawTextTransparent( hDC, cTime , ;
         *                    aLabelArea, nOR( DT_SINGLELINE, DT_VCENTER, DT_RIGHT ) )


              oPrn:Say( aLabelArea[ 1 ], aLabelArea[ 2 ]+210, cTime, oFontTime )

         else
            oPrn:Line(nTop - nRowStep,;
                    ::nLeftMargin + ::nLeftLabelWidth + 1,;
                    nTop - nRowStep,;
                    nGridWidth + ::nLeftMargin + ::nLeftLabelWidth,;
                     )

            oPrn:Line( nTop - nRowStep,;
                    ::nLeftMargin + ::nLeftLabelWidth / 2,;
                    nTop - nRowStep,;
                    ::nLeftMargin + ::nLeftLabelWidth - 4,;
                     )
         endif

         if n = ::nRowCount
           oPrn:Line( nTop,;
                   ::nLeftMargin,;
                   nTop,;
                   nGridWidth + ::nLeftMargin + ::nLeftLabelWidth,;
                    )
         endif
      endif

      nTime := ::NextInterval( nTime )

   next

Return NIL
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Help to create a method
Posted: Mon Jun 16, 2014 11:02 AM

Any solution ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion