Trying Tgantt Fivetech class

Trying Tgantt Fivetech class

Postby Eoeo » Tue Jul 24, 2012 3:53 pm

Antonio ,


I'm trying your gant class into a dialog and I have this error

Code: Select all  Expand view
Application
===========
   Path and name: C:\Work\Prg\BikiniL\BikiniL.Exe (32 bits)
   Size: 3,603,968 bytes
   Compiler version: xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 6715)
   FiveWin  Version: FWHX 12.03
   Windows version: 6.1, Build 7600

   Time from start: 0 hours 0 mins 2 secs
   Error occurred at: 24-07-2012, 17:00:24
   Error description: Error BASE/1083  Argument error: *
   Args:
     [   1] = N   16
     [   2] = U  

Stack Calls
===========
   Called from: .\source\classes\CONTROL.PRG => TGANTT:CTOCHAR( 360 )
   Called from: .\source\classes\DIALOG.PRG => TFSDI:CTOCHAR( 465 )
   Called from: .\source\classes\DIALOG.PRG => TFSDI:ACTIVATE( 284 )
   Called from: Source\Pgant.prg => GANT_PRENOTAZIONI( 115 )

 


then I saw there is not a sample with Xbrowse on samples files

I explain you I use a xbrowse at right and tgant class at left to see the reservations of the umbrellas in that month and draw a graph ( with different color)

I use two DATABSES one for the umbrellas list ( xbowse) and another reservation.dbf to draw the items on tgant class ( it draw the item if found the umbrella number )


any help ?

this sample can you usefull to community ...
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Trying Tgantt Fivetech class

Postby Antonio Linares » Tue Jul 24, 2012 9:44 pm

Silvio,

Please post a small example to reproduce it, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Trying Tgantt Fivetech class

Postby Eoeo » Wed Jul 25, 2012 6:10 pm

I used your sample :

#include "FiveWin.ch"
#include "Gantt.ch"

function Main()

local oFont, oWnd, oGantt

DEFINE FONT oFont NAME "Verdana" SIZE 0, -10

DEFINE DIALOG oWnd TITLE "Class TGantt test DIALOG"
// DEFINE WINDOW oWnd TITLE "Class TGantt test"

@ 1, 1 GANTT oGantt SIZE 300, 300 OF oWnd

oGantt:SetFont( oFont )
oGantt:lGridMonth = .T.

oGantt:AddItem( 30, 10, 50, 80, CLR_BLUE )
oGantt:AddItem( 60, 30, 80, 110, CLR_RED )
oGantt:AddItem( 90, 50, 110, 90, CLR_GREEN )
oGantt:AddItem( 120, 10, 140, 80, CLR_CYAN )
oGantt:AddItem( 150, 50, 170, 120, CLR_YELLOW )

// oWnd:oClient = oGantt

// oWnd:Center()

// ACTIVATE WINDOW oWnd
ACTIVATE DIALOG oWnd
return nil
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Trying Tgantt Fivetech class

Postby Eoeo » Sat Jul 28, 2012 8:07 am

Any solution ?
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Trying Tgantt Fivetech class

Postby Antonio Linares » Sat Jul 28, 2012 1:32 pm

Silvio,

This example works fine here with the below changes in Class TGantt

silvio.prg
Code: Select all  Expand view
#include "FiveWin.ch"
#include "Gantt.ch"

function Main()

   local oFont, oWnd, oGantt

   DEFINE FONT oFont NAME "Verdana" SIZE 0, -10

   DEFINE DIALOG oWnd TITLE "Class TGantt test DIALOG" SIZE 500, 500

  @ 1, 1 GANTT oGantt SIZE 300, 300 OF oWnd

   oGantt:SetFont( oFont )
   oGantt:lGridMonth = .T.

   oGantt:AddItem( 30, 10, 50, 80, CLR_BLUE )
   oGantt:AddItem( 60, 30, 80, 110, CLR_RED )
   oGantt:AddItem( 90, 50, 110, 90, CLR_GREEN )
   oGantt:AddItem( 120, 10, 140, 80, CLR_CYAN )
   oGantt:AddItem( 150, 50, 170, 120, CLR_YELLOW )

   oWnd:oClient = oGantt

   ACTIVATE DIALOG oWnd CENTERED ;
      ON INIT oWnd:Resize()

   oFont:End()

return nil


Changes in Class TGantt in Method New:
Code: Select all  Expand view
METHOD New( nTop, nLeft, nWidth, nHeight, oWnd, lBorder,;
            lVScroll, lHScroll, nClrFore, nClrBack, bChange, bPressed, oLbx ) CLASS TGantt

   DEFAULT lBorder := .T., nClrFore := 0, nClrBack := CLR_WHITE,;
           lVScroll := .F., lHScroll := .F.,;
           oWnd := GetWndDefault()

   ::cCaption   = ""
   ::oWnd      = oWnd
   ::bChange   = bChange
   ::bPressed  = bPressed
   ::oLbx      = oLbx
   ::nTop      = nTop    // new !!!
   ::nLeft     = nLeft   // new !!!
   ::nBottom   = nHeight - nTop  // new !!!
   ::nRight    = nWidth - nLeft   // new !!!
   ::nStyle    = nOr( WS_CHILD,;
                      If( lBorder, WS_BORDER, 0 ),;
                      If( lVScroll, WS_VSCROLL, 0 ),;
                      If( lHScroll, WS_HSCROLL, 0 ),;
                      WS_VISIBLE, WS_TABSTOP )
   ::Register()      

   ::SetColor( nClrFore, nClrBack )

   ::hPen = CreatePen( PS_SOLID, 1, nRGB( 128, 128, 128 ) )

   if oWnd:lVisible
      ::Create()
      ::Default()
      ::lVisible = .t.
      oWnd:AddControl( Self )
   else
      oWnd:DefControl( Self )
      ::lVisible  = .F.
   endif

return Self
 


Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Trying Tgantt Fivetech class

Postby Eoeo » Sat Jul 28, 2012 3:35 pm

Thanks a lot Antonio,

I made a test sample with a Xbrowse and Tgantt and a small test data array

but I Not Know how link the data to the bars of Tgant class


Image


the code


Code: Select all  Expand view



#include "FiveWin.ch"
#include "Gantt.ch"
#include "xbrowse.ch"

Static oFont, oWnd, oGantt ,aData,oBrw

function Main()



   DEFINE FONT oFont NAME "Verdana" SIZE 0, -10

   // sample data


    if empty( aData )
      aData := {{"1","test1","07/08/2012","08/08/2012","1"},;
                {"2","test2","1/08/2012","31/08/2012","2"},;
                {"3","test3","21/08/2012","22/08/2012","3"},;
                {"4","test4","11/08/2012","31/08/2012","4"},;
                {"5","test5","11ì0/08/2012","13/08/2012","5"}}
        endif




   DEFINE DIALOG oWnd TITLE "Class TGantt test DIALOG" SIZE 500, 500



   ACTIVATE DIALOG oWnd CENTERED ;
      ON INIT (Create_Grid(oWnd,aData),;
               Create_Gantt(oWnd,oFont),;
               oWnd:Resize())

   oFont:End()

return nil


//-----------------------------------------------------------------------//

Function Create_Grid(oWnd,aData)

    @ 0,0 XBROWSE oBrw OF oWnd ;
      COLUMNS {1,2,3,4,5} ;
      HEADERS {"Code","Desc","DataInit","DataEnd","Type"} ;
      array  aData LINES CELL fastedit SIZE ScreenHeight(),10

    oWnd:oLeft := oBrw
    oBrw:nMarqueeStyle    = MARQSTYLE_HIGHLWIN7
    oBrw:createfromcode()

    // edit

   Return oBrw

//----------------------------------------------------------------------------//

Function Create_Gantt(oWnd,oFont)

    @ 1, 50 GANTT oGantt SIZE 300, 300 OF oWnd

   oGantt:SetFont( oFont )
   oGantt:lGridMonth = .T.

 For n=1 to Len(aData )
          oGantt:AddItem( 30+n, 10,  50,  80,  Color_Set(oBrw:nArrayAt) )
     next


  /* oGantt:AddItem( 30, 10,  50,  80,  Color_Set(oBrw:nArrayAt) )
   oGantt:AddItem( 60, 30,  80, 110,  Color_Set(oBrw:nArrayAt) )
   oGantt:AddItem( 90, 50, 110,  90,  Color_Set(oBrw:nArrayAt) )
   oGantt:AddItem( 120, 10, 140,  80, Color_Set(oBrw:nArrayAt) )
   oGantt:AddItem( 150, 50, 170, 120, Color_Set(oBrw:nArrayAt) )
*/

  oWnd:oRight = oGantt
   Return nil



//------------------------------------------------------------------------------------//
   Function Color_Set(number)
   Local nColor
   Do Case
   Case number =1
        nColor :=  CLR_BLUE
   Case number =2
        nColor :=  CLR_RED
   Case number =3
        nColor :=  CLR_GREEN
   Case number =4
        nColor := CLR_CYAN
   Case number =5
         nColor := CLR_YELLOW
   endcase
   Return nColor




 





and also the GridMonth() method is wrong because the class show allways 31 days instead it must calculate the n days for the mounth past from user
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Trying Tgantt Fivetech class

Postby Eoeo » Sat Jul 28, 2012 4:39 pm

LINKING THE TGANT WITH XBROWSE

oApp():oGantt:= TGantt():New( 40,nSplit+5,nGridBottom2,nGridRight2, oApp():oDlg,;
TRUE,TRUE,TRUE,,,,,oApp():oGrid2)


the bars do not match the records in xbrowse as you can see in this picture ( I write a red line to link the record when I click on each bar )


Image



i TRY TO CALCULATE AND DRAW THE BARS
dDayOri:= 1
nHDay := 3
nRiga :=1



RE->(DbGoTop())
DO WHILE RE->(!EOF())

nColIni := ( RE->DATAIN - dDayOri ) * nHDay
nColEnd := ( RE->DATAFIN - dDayOri + 1 ) * nHDay
nGiorni := RE->DATAFIN - RE->DATAIN

// nRiga := ascan(::,{|nX| nX[1]== RE->NUMTABLE })
// nRiga := RE->NUMTABLE

nRiga := RECNO()

oApp():oGantt:AddItem(nRiga , nColIni, 50, nColEnd, CLR_BLUE )
RE->(dbSKIP())
ENDDO
RE->(dbGOTO( nRecord))


BUT i NOT kNOW HOW MAKE IT !!!
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Trying Tgantt Fivetech class

Postby Andrés González » Sun Jul 29, 2012 5:56 pm

Please Eoeo, could you post the function ScreenHeight(). When I try your function this one is missing.
Saludos

Andrés González desde Mallorca
User avatar
Andrés González
 
Posts: 627
Joined: Thu Jan 19, 2006 10:45 am
Location: Mallorca

Re: Trying Tgantt Fivetech class

Postby Andrés González » Sun Jul 29, 2012 6:21 pm

Sorry I saw that is a new function in fwh 12.03.
Saludos

Andrés González desde Mallorca
User avatar
Andrés González
 
Posts: 627
Joined: Thu Jan 19, 2006 10:45 am
Location: Mallorca

Re: Trying Tgantt Fivetech class

Postby Andrés González » Mon Jul 30, 2012 11:24 am

Antonio take a look of your email alinares@fivetechsoft.com and try to put a sample.
----
Antonio, puedes mirar tu correo en alinares@fivetechsoft.com con el ejemplo de gantt + xbrowse puedes mirar de arreglarlo.
Saludos

Andrés González desde Mallorca
User avatar
Andrés González
 
Posts: 627
Joined: Thu Jan 19, 2006 10:45 am
Location: Mallorca

Re: Trying Tgantt Fivetech class

Postby Antonio Linares » Mon Jul 30, 2012 1:19 pm

Silvio, Andrés,

I don't understand what you mean. What kind of syncronization do you want between the browse and the gant ?

If you select a row in the browse, what should happen or change in the gant ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Trying Tgantt Fivetech class

Postby Eoeo » Mon Jul 30, 2012 5:32 pm

the fillrect method of Tgant of Ramon link to nBar variable . it is the record of lbx

you can see clear :

oGraficos:FillRect( {nLinea+nVertic+4, nColumnaInicio+nHoriz, nLinea+nVertic+10, nColumnaFinal+nHoriz},oPen5,ActivProg->(Recno()) )
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Trying Tgantt Fivetech class

Postby Antonio Linares » Mon Jul 30, 2012 5:39 pm

Do you mean that the bars in the gant are not at the same row position that the xbrowse rows ?

What kind of syncronization do you mean ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Trying Tgantt Fivetech class

Postby Eoeo » Mon Jul 30, 2012 7:04 pm

>Do you mean that the bars in the gant are not at the same row position that the xbrowse rows ?
yes, and the range day is not showed correctly, and the mounth have not allways 31 days

Why not create a small test with xbrowse having this fields

DbCreate('TEST', { { 'NUM', 'N', 3, 0},;
{ 'DESC' , 'C', 10, 0},;
{ 'INIT' , 'D', 8, 0},;
{ 'END' , 'D', 8, 0},;
{ 'STATE', 'N',1,0}}, 'DBFCDX')

with STATE field u can change the colors of bars
INIT the date of INIT
END the date of End
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Trying Tgantt Fivetech class

Postby Antonio Linares » Tue Jul 31, 2012 11:33 am

I have modified and enhanced the FWH Class TGantt and here it is an example with a xbrowse:

Image

gantt.prg
Code: Select all  Expand view
#include "FiveWin.ch"

#define GWL_STYLE       -16

static nOldCol, nOldRow

//----------------------------------------------------------------------------//

CLASS TGantt FROM TControl

   DATA   aItems INIT {}
   DATA   oItem, oLbx
   DATA   lCaptured AS LOGICAL INIT .F.
   DATA   hPen
   DATA   lLResize, lRResize AS LOGICAL INIT .F.
   DATA   bChange, bPressed
   DATA   lGridMonth INIT .F.
   DATA   nCellWidth, nCellHeight  
   DATA   nCols INIT 31
   DATA   nRows
   DATA   nTopOffset INIT 5

   CLASSDATA lRegistered AS LOGICAL

   METHOD New( nTop, nLeft, nWidth, nHeight, oWnd, lBorder,;
               lVScroll, lHScroll, nClrFore, nClrBack, bchange, dpresed, oLbx ) CONSTRUCTOR

   METHOD Redefine( nId, oWnd, nClrFore, nClrBack ) CONSTRUCTOR

   METHOD AddItem( nRow, nStart, nEnd, nClrBack )

   METHOD AtItem( nRow, nCol )

   METHOD EraseBkGnd( hDC ) INLINE 1

   METHOD GridMonth()

   METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint(), 0

   METHOD Paint()

   METHOD LButtonDown( nRow, nCol, nKeyFlags )

   METHOD LButtonUp( nRow, nCol, nKeyFlags )  

   METHOD MouseMove( nRow, nCol, nKeyFlags )
   
   METHOD End()

   METHOD ReCalculate()
   
   METHOD SetGridMonth( nRows )

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New( nTop, nLeft, nWidth, nHeight, oWnd, lBorder,;
            lVScroll, lHScroll, nClrFore, nClrBack, bChange, bPressed, oLbx ) CLASS TGantt

   DEFAULT lBorder := .T., nClrFore := 0, nClrBack := CLR_WHITE,;
           lVScroll := .F., lHScroll := .F.,;
           oWnd := GetWndDefault()

   ::cCaption   = ""
   ::oWnd      = oWnd
   ::bChange   = bChange
   ::bPressed  = bPressed
   ::oLbx      = oLbx
   ::nTop      = nTop
   ::nLeft     = nLeft
   ::nBottom   = nHeight - nTop
   ::nRight    = nWidth - nLeft
   ::nStyle    = nOr( WS_CHILD,;
                      If( lBorder, WS_BORDER, 0 ),;
                      If( lVScroll, WS_VSCROLL, 0 ),;
                      If( lHScroll, WS_HSCROLL, 0 ),;
                      WS_VISIBLE, WS_TABSTOP )
   ::Register()      

   ::SetColor( nClrFore, nClrBack )

   ::hPen = CreatePen( PS_SOLID, 1, nRGB( 128, 128, 128 ) )

   if oWnd:lVisible
      ::Create()
      ::Default()
      ::lVisible = .t.
      oWnd:AddControl( Self )
   else
      oWnd:DefControl( Self )
      ::lVisible  = .F.
   endif

   /*
   if lVScroll
      DEFINE SCROLLBAR ::oVScroll VERTICAL OF Self
   endif
   if lHScroll
      DEFINE SCROLLBAR ::oHScroll HORIZONTAL OF Self
   endif
   */

   
return Self

//----------------------------------------------------------------------------//

METHOD Redefine( nId, oWnd, nClrFore, nClrBack, bChange, bPressed, oLbx ) CLASS TGantt

   DEFAULT oWnd := GetWndDefault()

   ::nId       = nId
   ::cCaption  = ""
   ::lCaptured = .F.
   ::oWnd      = oWnd
   ::bChange   = bChange
   ::bPressed   = bPressed
   ::oLbx      = oLbx

   ::Register()

   ::SetColor( nClrFore, nClrBack )
   
   if lAnd( GetWindowLong( ::hWnd, GWL_STYLE ), WS_VSCROLL )
      DEFINE SCROLLBAR ::oVScroll VERTICAL OF Self
   endif
   if lAnd( GetWindowLong( ::hWnd, GWL_STYLE ), WS_HSCROLL )
      DEFINE SCROLLBAR ::oHScroll HORIZONTAL OF Self
   endif

   oWnd:DefControl( Self )

return Self

//----------------------------------------------------------------------------//

METHOD AddItem( nRow, nStart, nEnd, nClrBack ) CLASS TGantt

   local oItem := TGanttItem():New( Self, nRow, nStart, nEnd, nClrBack )
   
   AAdd( ::aItems, oItem )
   
return oItem  
   
//----------------------------------------------------------------------------//

METHOD AtItem( nRow, nCol ) CLASS TGantt

   local nItem := AScan( ::aItems, { | oItem | oItem:IsOver( nRow, nCol ) } )

return If( nItem != 0, ::aItems[ nItem ], nil )

//----------------------------------------------------------------------------//

METHOD GridMonth() CLASS TGantt

   local n, nWidth := ::nWidth() / 31
   
   MoveTo( ::hDC, 0, 18 )
   LineTo( ::hDC, ::nWidth, 18 )
   
   for n = 1 to 30
      MoveTo( ::hDC, nWidth * n, 0 )
      LineTo( ::hDC, nWidth * n, ::nHeight )
   next  
   
   for n = 1 to 31
      ::Say( 3, 7 + ( ( n - 1 ) * nWidth ),;
             If( n < 10, " ", "" ) + AllTrim( Str( n ) ),,, If( ::oFont != nil, ::oFont,), .T. )
   next    

return nil

//----------------------------------------------------------------------------//

METHOD Paint() CLASS TGantt

   local aInfo := ::DispBegin()
   
   FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
   
   if ::lGridMonth
      ::GridMonth()
   endif  
   
   AEval( ::aItems, { | oItem | oItem:Paint() } )

   if ::bPainted != nil
      Eval( ::bPainted, ::hDC )
   endif

   ::DispEnd( aInfo )

return 0

//----------------------------------------------------------------------------//

METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS TGantt

   local oItem

   if ::lCaptured
      if ::oItem:IsOver( nRow, nCol, 5 )
         ::oItem:DrawBorder() // to remove the previous painted lines
         if ::lRResize
            ::oItem:nRight = nCol - ( nOldCol - ::oItem:nRight )
         elseif ::lLResize
            ::oItem:nLeft = nCol - ( nOldCol - ::oItem:nLeft )
         else
            ::oItem:nLeft = nCol - ( nOldCol - ::oItem:nLeft )
            ::oItem:nRight = nCol - ( nOldCol - ::oItem:nRight )
         endif
         ::oItem:DrawBorder()
         nOldCol = nCol
         return nil
      endif  
   else
      if ( oItem := ::AtItem( nRow, nCol ) ) != nil
         if nCol < oItem:nLeft + 5 .or. nCol > oItem:nRight - 5
            CursorWE()
            return nil
         endif
      endif      
   endif      

return Super:MouseMove( nRow, nCol, nKeyFlags )

//----------------------------------------------------------------------------//

METHOD LButtonDown( nRow, nCol, nKeyFlags ) CLASS TGantt

   local oItem

   if ::oLbx != nil
      ::oLbx:LButtonDown( nRow + 32, 40, nKeyFlags )
   endif

   if ( oItem := ::AtItem( nRow, nCol ) ) != nil
      nOldCol = nCol
      nOldRow = nRow
      ::lCaptured = .T.
      ::oItem = oItem
      ::oItem:DrawBorder()
      ::lLResize = nCol < oItem:nLeft + 5
      ::lRResize = nCol > oItem:nRight - 5
      if ::lLResize .or. ::lRResize
         CursorWE()
      else  
         CursorHand()  
      endif    
   endif
       
return Super:LButtonDown( nRow, nCol, nKeyFlags )

//----------------------------------------------------------------------------//

METHOD LButtonUp( nRow, nCol, nKeyFlags ) CLASS TGantt

   if ::lCaptured
      ::oItem:DrawBorder() // to remove the last painted lines
      ::Refresh()
      if ::bChange != nil
         Eval( ::bChange, Self )
      endif
      ::lCaptured = .F.
   endif

return Super:LButtonUp( nRow, nCol, nKeyFlags )

//----------------------------------------------------------------------------//

METHOD End() CLASS TGantt

   DeleteObject( ::hPen )

return Super:End()

//----------------------------------------------------------------------------//

METHOD ReCalculate() CLASS TGantt

   ::nCellWidth  = ::nWidth / 31
   ::nCellHeight = ::nHeight / ::nRows
   
   AEval( ::aItems, { | oItem | oItem:CoorsUpdate() } )
   
return nil    

//----------------------------------------------------------------------------//

METHOD SetGridMonth( nRows ) CLASS TGantt

   ::lGridMonth  = .T.
   ::nCellWidth  = ::nWidth / 31
   ::nCellHeight = ::nHeight / nRows
   ::nRows       = nRows
   
return nil  

//----------------------------------------------------------------------------//

CLASS TGanttItem

   DATA   nRow, nStart, nEnd
   DATA   nTop, nLeft, nBottom, nRight
   DATA   nClrBack
   DATA   oGantt
   
   METHOD New( oGantt, nRow, nStart, nEnd, nClrBack )

   METHOD DrawBorder()
   
   METHOD IsOver( nRow, nCol, nMargin )
   
   METHOD Paint()

   METHOD CoorsUpdate()
   
ENDCLASS

//----------------------------------------------------------------------------//

METHOD New( oGantt, nRow, nStart, nEnd, nClrBack ) CLASS TGanttItem

   ::oGantt   = oGantt
   ::nRow     = nRow
   ::nStart   = nStart
   ::nEnd     = nEnd
   ::CoorsUpdate()
   ::nClrBack = nClrBack
   
return Self

//----------------------------------------------------------------------------//

METHOD IsOver( nRow, nCol, nMargin ) CLASS TGanttItem

   DEFAULT nMargin := 0

return nRow >= ::nTop .and. nCol >= ::nLeft - nMargin .and. ;
       nRow <= ::nBottom .and. nCol <= ::nRight + nMargin

//----------------------------------------------------------------------------//

METHOD DrawBorder() CLASS TGanttItem

   local hDC     := ::oGantt:GetDC()
   local nOldRop := SetROP2( hDC, 7 )
   local nOldPen := SelectObject( hDC, ::oGantt:hPen )
   
   MoveTo( hDC, ::nLeft,  ::nTop )
   LineTo( hDC, ::nRight - 1, ::nTop )
   LineTo( hDC, ::nRight - 1, ::nBottom - 1 )
   LineTo( hDC, ::nLeft,  ::nBottom - 1 )
   LineTo( hDC, ::nLeft,  ::nTop )
   SetROP2( hDC, nOldRop )
   SelectObject( hDC, nOldPen )
   ::oGantt:ReleaseDC()
   
return nil

//----------------------------------------------------------------------------//

METHOD Paint() CLASS TGanttItem

   local hPen := CreatePen( 0, 1, ::nClrBack )
   
   FillRect( ::oGantt:GetDC(), { ::nTop, ::nLeft, ::nBottom, ::nRight }, hPen )
   
   DeleteObject( hPen )  
   ::oGantt:ReleaseDC()
   
return nil

//----------------------------------------------------------------------------//

METHOD CoorsUpdate() CLASS TGanttItem

   ::nTop    = ::oGantt:nCellHeight * ::nRow + ::oGantt:nTopOffset
   ::nLeft   = ::oGantt:nCellWidth * ( ::nStart - 1 )
   ::nBottom = ::nTop + ::oGantt:nCellHeight
   ::nRight  = ::oGantt:nCellWidth * ::nEnd
   
return nil  

//----------------------------------------------------------------------------//          


silvio.prg
Code: Select all  Expand view
#include "FiveWin.ch"
#include "xbrowse.ch"
#include "gantt.ch"

REQUEST DBFCDX

function Main()

   local oWnd, oBrw, oGnt, n

   SET DATE FRENCH

   if ! File( "gantdata.dbf" )
      DbCreate( "gantdata.dbf",;
                { { 'NUM', 'N', 3, 0 },;
                  { 'DESC' , 'C', 10, 0 },;
                  { 'INIT' , 'D', 8, 0 },;
                  { 'END' , 'D', 8, 0 },;
                  { 'STATE', 'N', 1, 0 } }, "DBFCDX" )
   endif

   USE gantdata
   ZAP
   
   for n = 1 to 20
      APPEND BLANK
      gantdata->num   := n
      gantdata->Desc  := AllTrim( Str( n ) )
      gantdata->Init  := CToD( AllTrim( Str( Max( nRandom( 15 ), 1 ) ) ) + "/07/2012" )    
      gantdata->End   := CToD( AllTrim( Str( Min( 16 + nRandom( 31 ), 31 ) ) ) + "/07/2012" )    
      gantdata->State := Max( nRandom( 6 ), 1 )
      SKIP
   next  

   DEFINE WINDOW oWnd

   @ 0, 0 XBROWSE oBrw ;
      FIELDS GantData->Num, GantData->Desc, GantData->Init, GantData->End, GantData->State ;
      OF oWnd SIZE 300, 500

   oBrw:CreateFromCode()

   oWnd:oLeft = oBrw

   @ 0, 301 GANTT oGnt OF oWnd SIZE 300, 300
   
   oWnd:oClient = oGnt
   oWnd:Show()
   oWnd:Maximize()
   oGnt:SetGridMonth( 44.5 )
   AddDays( oGnt )
   oGnt:bResized = { || oGnt:ReCalculate(), oGnt:Refresh() }

   oBrw:GoTop()

   ACTIVATE WINDOW oWnd MAXIMIZED
   
return nil

function AddDays( oGnt )

   local nCellWidth  := oGnt:nCellWidth
   local nCellHeight := oGnt:nCellHeight
   local oItem
   local aColors := { CLR_HRED, CLR_HGREEN, CLR_HBLUE, CLR_HCYAN, CLR_HMAGENTA, CLR_YELLOW }
   
   GO TOP
   
   while ! EOF()
      oItem = oGnt:AddItem( RecNo(), Day( GantData->Init ), Day( GantData->End ),;
                            aColors[ GantData->State ] )
      SKIP
   end  
           
   GO TOP
   
return nil                
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 92 guests

cron