el diseño de TGantt de Ramón Avendaño

el diseño de TGantt de Ramón Avendaño

Postby Antonio Linares » Sat Oct 01, 2011 2:54 pm

La clase TGantt de Ramón es realmente simple y esa simplicidad le hace ser muy flexible. De hecho las modificaciones que se le hayan hecho al modelo inicial, son meros detalles sin importancia y que realmente no hacen falta :-)

Un objeto TGantt es un control (deriva de TControl) que maneja un array de items. Esos items tienen unas coordenadas y se pintan en la superficie del TGantt. Además de eso, con el ratón podemos mover esos items y redimensionarlos. Y eso es todo! :-)

Lo que queramos representar con esos items, es ya asunto nuestro (como programadores). Vamos a ver un primer ejemplo muy sencillo del uso de TGantt para entenderlo:

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

function Main()

   local oWnd, oGantt

   DEFINE WINDOW oWnd TITLE "Class TGantt test"
   
   @ 1, 1 GANTT oGantt SIZE 300, 300 OF oWnd
   
   AAdd( oGantt:aItems, {  10, 10,  30,  80, CLR_BLUE } )
   AAdd( oGantt:aItems, {  40, 30,  60, 110, CLR_RED } )
   AAdd( oGantt:aItems, {  70, 50,  90,  90, CLR_GREEN } )
   AAdd( oGantt:aItems, { 100, 10, 120,  80, CLR_CYAN } )
   AAdd( oGantt:aItems, { 130, 50, 150, 120, CLR_YELLOW } )
   
   oWnd:oClient = oGantt

   ACTIVATE WINDOW oWnd

return nil


Como veis, definimos 5 items para ese TGantt, y asignamos un color a cada uno de ellos. Podremos asignarles muchas más cosas. Pero de momento, centremonos en la idea. El resultado se ve asi:

Image

Moviendo y redimensionando los items:
Image

Podeis descargar desde aqui el EXE, para que podais mover y redimensionar los items con el ratón. Se incluye todo el código fuente:
http://code.google.com/p/fivewin-contributions/downloads/detail?name=gantt.zop&can=2&q=
regards, saludos

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

Re: el diseño de TGantt de Ramón Avendaño

Postby carlos vargas » Sat Oct 01, 2011 7:05 pm

un poco de revisión en el codigo, uso de cursor de arrantres, verificacion de bloque de codigo en onchange, etc.
eliminacion de codigo sin uso.

Antonio. al dar dobleclick dobre una barra el cursor queda fijo como el de arrastre.
pero a moverlo se restaura al cursorwait

Code: Select all  Expand view

#include "FiveWin.ch"

#define GWL_STYLE           -16

STATIC nOldCol, nOldRow
STATIC nOldCol1, nOldCol2, nOldRow2

/*--------------------------------------------------------------------------*/

CLASS TGantt FROM TControl

   DATA   nWidth, nHeight
   DATA   aItems
   DATA   lCaptured, lCaptuPre
   DATA   nItem, nItePre
   DATA   nRow1, nRow2   AS NUMERIC INIT 0
   DATA   nCol1, nCol2   AS NUMERIC INIT 0
   DATA   nRowi1, nRowi2 AS NUMERIC INIT 0
   DATA   nColi1, nColi2 AS NUMERIC INIT 0
   DATA   hTrazoPen
   DATA   hOldPen
   DATA   iRop
   DATA   bLbx
   DATA   nLCol, nRCol AS LOGICAL INIT .f.
   DATA   bChange
   DATA   bPresed
   DATA   bTrovaTIP
   DATA   cToolTip

   CLASSDATA lRegistered AS LOGICAL

   METHOD New( nTop, nLeft, nWidth, nHeight, ;
               oWnd                        , ;
               lBorder, lVScroll, lHScroll , ;
               nClrFore, nClrBack          , ;
               bChange, bPresed, bLbx        ) CONSTRUCTOR

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

   MESSAGE FillRect( aRect, oBrush, nBarra )  METHOD _FillRect( aRect, oBrush, nBarra )

   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 LDblClick( nRow, nCol, nKeyFlags )

   METHOD Line( nTop, nLeft, nBottom, nRight, oPen )
   METHOD Rectang( nTop, nLeft, nBottom, nRight, oPen, nBarra )
   METHOD Say( nRow, nCol         , ;
               cText              , ;
               nClrFore, nClrBack , ;
               oFont, lPixel      , ;
               lTransparent, nAlign )

   METHOD DibRect()
   METHOD DibLine()
   METHOD End()

ENDCLASS

/*--------------------------------------------------------------------------*/

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

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

   ::cCaption  := ""
   ::lCaptured := .f.
   ::lCaptuPre := .f.
   ::aitems    := {}
   ::nitem     := 0
   ::nitePre   := 0
   ::nTop      := nTop
   ::nLeft     := nLeft
   ::nBottom   := nTop + nHeight - 1
   ::nRight    := nLeft + nWidth - 1
   ::oWnd      := oWnd
   ::bchange   := bChange
   ::bPresed   := bPresed
   ::bLbx      := bLbx
   ::nStyle    := nOr( WS_CHILD                     ,;
                      If( lBorder,  WS_BORDER,  0 ) ,;
                      If( lVScroll, WS_VSCROLL, 0 ) ,;
                      If( lHScroll, WS_HSCROLL, 0 ) ,;
                      WS_VISIBLE                    ,;
                      WS_TABSTOP                     )
   ::Register()

   ::cToolTip    := ""

   ::SetColor( nClrFore, nClrBack )

   ::hTrazOpen := 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

/*--------------------------------------------------------------------------*/

METHOD Redefine( nId, oWnd, nClrFore, nClrBack,bChange, bPresed,blbx ) CLASS TGantt

   DEFAULT oWnd := GetWndDefault()

   ::nId       := nId
   ::cCaption  := ""
   ::lCaptured := .f.
   ::lCaptuPre := .f.
   ::oWnd      := oWnd
   ::bchange   := bChange
   ::bPresed   := bPresed
   ::bLbx      := bLbx
   ::nWidth    := 100
   ::nHeight   := 100

   ::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 Paint() CLASS TGantt
   LOCAL n, hPen

   FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )

   FOR n = 1 to Len( ::aItems )
      hPen := CreatePen( 0, 1, ::aItems[ n , 5 ] )
      FillRect( ::hDC, ::aItems[ n ], hPen )
      DeleteObject( hPen )
   NEXT

   IF ::bPainted != NIL .and. ValType( ::bPainted )
      Eval( ::bPainted, ::hDC )
   ENDIF

   DeleteObject( hPen )

RETURN 0

/*--------------------------------------------------------------------------*/

METHOD Line( nTop, nLeft, nBottom, nRight, oPen ) CLASS TGantt
   LOCAL hPen := iif( oPen = NIL, 0, oPen:hPen )

   ::GetDC()

   MoveTo( ::hDC, nLeft, nTop )
   LineTo( ::hDC, nRight, nBottom, hPen )

   ::ReleaseDC()

RETURN NIL

/*--------------------------------------------------------------------------*/

METHOD Rectang( nTop, nLeft, nBottom, nRight, oPen, nBarra ) CLASS TGantt
   LOCAL hPen := iif( oPen   == NIL, 0, oPen:hPen )
   LOCAL nBar := iif( nBarra == NIL, 0, nBarra    )
   ::GetDC()

   Rectangle( ::hDC, nTop, nLeft, nBottom, nRight, hPen )

   ::ReleaseDC()

RETURN NIL

/*--------------------------------------------------------------------------*/

METHOD Say( nRow, nCol           , ;
            cText                , ;
            nClrFore, nClrBack   , ;
            oFont, lPixel        , ;
            lTransparent, nAlign ) CLASS TGantt

   DEFAULT nClrFore     := ::nClrText ,;
           nClrBack     := ::nClrPane ,;
           oFont        := ::oFont    ,;
           lPixel       := .f.        ,;
           lTransparent := .f.

   IF ValType( nClrFore ) == "C"
      nClrBack := nClrFore
      nClrFore := nGetForeRGB( nClrFore )
      nClrBack := nGetBackRGB( nClrBack )
   ENDIF

   ::GetDC()

   DEFAULT nAlign := GetTextAlign( ::hDC )

   WSay( ::hWnd, ::hDC      , ;
         nRow, nCol         , ;
         cValToChar( cText ), ;
         nClrFore, nClrBack , ;
         If( oFont != NIL, oFont:hFont, 0 ), lPixel, lTransparent, nAlign )

   ::ReleaseDC()

RETURN NIL

/*--------------------------------------------------------------------------*/

METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS TGantt
   LOCAL neoitem, cText

   IF ::lCaptured

      neoItem := AScan( ::aItems,{ |val| val[ 1 ] <= nRow .and. ;
                                         val[ 2 ] <= ncol .and. ;
                                         val[ 4 ] >= ncol .and. ;
                                         val[ 3 ] >= nRow      })

      IF neoItem = 0 .and. ( nRow <= ::nRow1 + 2 .or. nRow >= ::nRow2 - 1 ) .and. ::nlCol .and. ::nRCol

         IF nCol > nOldCol1 .and. nCol < nOldCol2

            CursorHand()

            ::DibRect()

            SelectObject( ::hDC, ::hOldPen )
            ::ReleaseDC()

            ::lCaptured := .f.
            ::lCaptuPre := .t.
            ::nRowi1    := ::nRow2 - 1
            ::nColi1    := nOldCol2
            ::nColi2    := nCol
            ::nRowi2    := nRow
            nOldRow     := ::nRow2 - 1
            nOldRow2    := ::nRow2 - 1
            nOldCol     := nOldCol2
            ::nRowi2    := nOldRow2 + ( nRow - nOldRow )
            ::nColi2    := nOldCol2 + ( nCol - nOldCol )
            ::hOldpen   := Selectobject( ::hDC, ::hTrazoPen )

            ::DibLine()

            RETURN 0

         ENDIF

      ENDIF

      ::DibRect()

      IF ::nRCol .and. !::nLCol
         Cursor( "CURSOR_2" )
         IF nOldCol2 + ( nCol - nOldCol ) > ::nCol1
            ::nCol2 := nOldCol2 + ( nCol - nOldCol )
         ENDIF
      ENDIF

      IF ::nLCol .and. !::nRCol
         Cursor( "CURSOR_3" )
         IF nOldCol1 + ( nCol - nOldCol) < ::nCol2
            ::nCol1 := nOldCol1 + ( nCol - nOldCol )
         ENDIF
      ENDIF

      IF ::nLCol .and. ::nRCol
         CursorDrag()
         ::nCol1 := nOldCol1 + ( nCol - nOldCol )
         ::nCol2 := nOldCol2 + ( nCol - nOldCol )
      ENDIF

      ::DibRect()

      RETURN 0

   ENDIF

   IF ::lCaptuPre

      ::DibLine()

      ::nRowi2 := nOldRow2+(nRow-nOldRow)
      ::nColi2 := nOldCol2+(nCol-nOldCol)

      ::DibLine()

      ::nItePre := AScan( ::aitems,{ |val| val[1] <= nRow .and. ;
                                           val[2] <= ncol .and. ;
                                           val[4] >= ncol .and. ;
                                           val[3] >= nRow      })
      IF ::nItepre != 0
         CursorHand()
      ELSE
         CursorArrow()
      ENDIF

      RETURN 0

   ENDIF

   ::nItem :=AScan( ::aItems, { |val| val[ 1 ]     <= nRow .and. ;
                                      val[ 2 ]     <= ncol .and. ;
                                      val[ 4 ] + 5 >= ncol .and. ;
                                      val[ 3 ]     >= nRow      })
   IF ::lCaptured
      IF ::nItem == 0
         CursorHand()
         ::lCaptured := .f.
         ::lCaptuPre := .t.
      ENDIF
   ENDIF

   IF ::nItem !=0

      IF ::aitems[ ::nItem, 2 ]         <= nCol      .and. ::aItems[ ::nItem, 2 ] + 2 >= nCol
         CursorWE()
      ELSEIF ::aItems[ ::nItem, 4 ] - 3 <= nCol      .and. ::aItems[ ::nItem, 4 ]     >= nCol
         CursorWE()
      ELSEIF ::aItems[ ::nItem, 4 ] + 2 <= nCol      .and. ::aItems[ ::nItem, 4 ] + 5 >= nCol
         CursorHand()
      ELSEIF ::aItems[ ::nItem, 2 ]     <  nCol + 2  .and. ::aItems[ ::nItem, 4 ] - 3 >  nCol
         CursorHand()
      ELSE
         Cursorarrow()
      ENDIF

      IF ::bTrovaTip != NIL .and. ValType( ::bTrovaTip ) == "B"

         Eval( ::bTrovaTip, Self )

         IF !Empty( ::cToolTip )
            ::lTooltipBallon    := .t.
            ::nTooltipwidth     := 600
            ::nTooltipTexColor  := RGB( 000, 000, 000 )
            ::nTooltipBkColor   := RGB( 058, 116, 241 )
            ::nTooltipIcon      := 0
            ::ShowToolTip( nRow, nCol, ::cToolTip )
         ENDIF

      ENDIF

   ELSE

      IF ::bTrovaTip != NIL
         ::DestroyToolTip()
      ENDIF

      CursorArrow()

   ENDIF

RETURN 0

/*--------------------------------------------------------------------------*/

METHOD LButtonDown( nRow, nCol, nKeyFlags ) CLASS TGantt

   IF ::bLbx != NIL
      ::bLbx:LbuttonDown( nRow + 32, 40, nKeyFlags )
   ENDIF

   ::GetDC()

   nOldCol := nCol
   nOldRow := nRow

   ::nItem := AScan( ::aItems, { |Val| Val[ 1 ]     <= nRow .and. ;
                                       Val[ 2 ]     <= nCol .and. ;
                                       Val[ 4 ] + 5 >= nCol .and. ;
                                       Val[ 3 ]     >= nRow       })

   IF ::nItem != 0

      ::hOldPen := Selectobject( ::hDC, ::hTrazoPen )

      IF ( ::aItems[ ::nItem , 2 ] <= nCol ) .and. ( ::aItems[ ::nItem, 2 ] + 2 >= nCol )

         ::lCaptured :=.t.

         ::nRow1 := ::aItems[ ::nItem , 1 ] - 2
         ::nCol1 := ::aItems[ ::nItem , 2 ]
         ::nCol2 := ::aItems[ ::nItem , 4 ]
         ::nrow2 := ::aItems[ ::nItem , 3 ] + 1

         ::nLCol := .t.
         ::nRCol := .f.

         nOldCol1 := ::nCol1
         nOldCol2 := ::nCol2

         ::DibRect()

         CursorWE()

      ELSEIF ( ::aItems[ ::nItem, 4 ] - 3 <= nCol ) .and. ( ::aItems[ ::nItem , 4 ] >= nCol )

         ::lCaptured := .t.

         ::nRow1 := ::aItems[ ::nItem , 1 ] - 2
         ::nCol1 := ::aItems[ ::nItem , 2 ]
         ::nCol2 := ::aItems[ ::nItem , 4 ]
         ::nRow2 := ::aItems[ ::nItem , 3 ] + 1
         ::nLCol := .f.
         ::nRcol := .t.

         nOldCol1 := ::nCol1
         nOldCol2 := ::nCol2

         ::DibRect()

         CursorWE()

      ELSEIF ( ::aItems[ ::nItem , 4 ] + 2 <= nCol ) .and. ( ::aItems[ ::nItem , 4 ] + 5 > nCol )

         ::lCaptured := .f.
         ::lCaptuPre := .t.

         ::nRowi1 := nRow
         ::nColi1 := nCol
         ::nColi2 := nCol
         ::nRowi2 := nRow

         nOldRow2 := nRow
         nOldCol2 := nCol

         ::DibLine()

         CursorHand()

      ELSEIF ( ::aitems[ ::nItem , 2 ] < nCol + 2 ) .and. ( ::aItems[ ::nItem , 4 ] - 3 > nCol )

         ::lCaptured := .t.

         ::nRow1 := ::aItems[ ::nItem , 1 ] - 2
         ::nCol1 := ::aItems[ ::nItem , 2 ]
         ::nCol2 := ::aItems[ ::nItem , 4 ]
         ::nRow2 := ::aItems[ ::nItem , 3 ] + 1
         ::nLCol := .t.
         ::nRcol := .t.

         nOldCol1 := ::nCol1
         nOldCol2 := ::nCol2

         ::DibRect()

         CursorDrag()

      ENDIF
   ENDIF

RETURN Super:LButtonDown( nRow, nCol, nKeyFlags )

/*--------------------------------------------------------------------------*/

METHOD LButtonUp( nRow, nCol, nKeyFlags )  CLASS TGantt

   ::DestroyToolTip()

   IF ::lCaptured

      ::DibRect()
      selectObject( ::hDC, ::hOldPen )

      ::ReleaseDC()
      ::lCaptuPre := .f.
      ::lCaptured := .f.

      IF nOldCol1 != ::nCol1 .or. nOldCol2 != ::nCol2

         ::aItems[ ::nItem ] := { ::nRow1 + 2, ::nCol1, ::nRow2 - 1, ::nCol2, ::aItems[ ::nItem , 5 ] }
         ::Refresh()

         IF ::bChange != NIL .and. ValType( ::bChange ) == "B"
            Eval( ::bChange, Self )
         ENDIF

      ENDIF

   ENDIF

   IF ::lCaptuPre

      ::DibLine()
      selectObject( ::hDC, ::hOldPen )

      ::ReleaseDC()
      ::lCaptured := .f.
      ::lCaptuPre := .f.

      IF ::nItePre !=0 .and. ::nItem != 0
         IF ::nItePre != ::nItem
            IF ::bPresed != NIL .and. ValType( ::bPresed ) == "B"
               Eval( ::bPresed, Self )
            ENDIF
         ENDIF
      ENDIF

      ::nItePre := 0

   ENDIF

RETURN Super:LButtonUp( nRow, nCol, nKeyFlags )

/*--------------------------------------------------------------------------*/

METHOD DibRect() CLASS TGantt

   ::iRop := ClsetroP2( ::hDC, 7 )

   MoveTo( ::hDC, ::nCol1, ::nRow1  )

   LineTo( ::hDC, ::nCol2, ::nRow1 )
   LineTo( ::hDC, ::nCol2, ::nRow2 )
   LineTo( ::hDC, ::nCol1, ::nRow2 )
   LineTo( ::hDC, ::nCol1, ::nRow1 )

   ClseTroP2( ::hDC, ::iRop )

RETURN NIL

/*--------------------------------------------------------------------------*/

METHOD DibLine() CLASS TGantt

   ::iRop := ClsetroP2( ::hDC, 7 )

   MoveTo( ::hDC, ::nColi1,::nRowi1  )
   LineTo( ::hDC, ::nColi2,::nRowi2 )

   ClseTroP2( ::hDC, ::iRop )

RETURN NIL

/*--------------------------------------------------------------------------*/

METHOD End() CLASS TGantt

   DeleteObject( ::hTrazoPen )
   Super:End()

RETURN NIL

/*--------------------------------------------------------------------------*/

METHOD LDblClick( nRow, nCol, nKeyFlags )

   ::lCaptured := .f.
   ::lCaptuPre := .f.

   IF ::bLbx != NIL
      ::bLbx:LDblClick( nRow, nCol, nKeyFlags )
   ENDIF

   Super:LDblClick( nRow, nCol, nKeyFlags )

RETURN NIL

/*--------------------------------------------------------------------------*/

METHOD _FillRect( aCols, oBrush, nBarra ) CLASS TGantt
   LOCAL nBar := iif( nBarra = NIL, 0, nBarra )

   ::GetDC()
   FillRect( ::hDC ,aCols, oBrush:hBrush )
   ::ReleaseDC()

   IF nBar > 0
      IF len( ::aItems ) >= nBar
         ::aItems[ nBar ] := { aCols[1], aCols[2], aCols[3], aCols[4] }
      ELSE
         AAdd( ::aItems, { aCols[1], aCols[2], aCols[3], aCols[4] } )
      ENDIF
   ENDIF

RETURN NIL

/*--------------------------------------------------------------------------*/

#pragma BEGINDUMP

#define HB_API_MACROS

#include <Windows.h>
#include <hbApi.h>

#include <windows.h>
#include <hbapi.h>

HB_FUNC( CLSETROP2 ) // ( hDll, Ctex )
{
   hb_retni(  SetROP2( ( HDC ) hb_parnl( 1 ), hb_parni( 2 ) ) );
}

#pragma ENDDUMP

/*--------------------------------------------------------------------------*/
/*EOF*/
/*--------------------------------------------------------------------------*/

 
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1683
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: el diseño de TGantt de Ramón Avendaño

Postby Antonio Linares » Sat Oct 01, 2011 7:09 pm

Consideremos ahora que queremos representar datos relacionados con un "mes". Hemos implementado un Método GridMonth() en la Clase TGantt que muestra una útil rejilla :-)

Code: Select all  Expand view
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


Modificamos nuestro primer ejemplo de esta forma:
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 WINDOW oWnd TITLE "Class TGantt test"
   
   @ 1, 1 GANTT oGantt SIZE 300, 300 OF oWnd
   
   oGantt:SetFont( oFont )
   oGantt:lGridMonth = .T.
   
   AAdd( oGantt:aItems, {  30, 10,  50,  80, CLR_BLUE } )
   AAdd( oGantt:aItems, {  60, 30,  80, 110, CLR_RED } )
   AAdd( oGantt:aItems, {  90, 50, 110,  90, CLR_GREEN } )
   AAdd( oGantt:aItems, { 120, 10, 140,  80, CLR_CYAN } )
   AAdd( oGantt:aItems, { 150, 50, 170, 120, CLR_YELLOW } )
   
   oWnd:oClient = oGantt

   ACTIVATE WINDOW oWnd

return nil


Y aqui tenemos el resultado:
Image

EXE y código fuente incluido:
http://code.google.com/p/fivewin-contributions/downloads/detail?name=gantt2.zop&can=2&q=
regards, saludos

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

Re: el diseño de TGantt de Ramón Avendaño

Postby Antonio Linares » Sat Oct 01, 2011 7:11 pm

Carlos,

gracias! :-)

Por favor prueba a implementar tus cambios en esta nueva versión que acabo de publicar :-)
regards, saludos

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

Re: el diseño de TGantt de Ramón Avendaño

Postby lubin » Sat Oct 01, 2011 7:25 pm

Gracias Antonio

Esto es un buen hilo para hacer uso de esta clase, pues la verdad estaba perdido en su uso,
es posible aplicar scrooll Horizontal o Vertical para el manejo de muchas actividades?? asi como tambien definir las activades y sus marcas

Sera algo tonta la pregunta pero los valores de las coordenadas bajo que criterio las calculas ???

Reitero, tu apoyo en sacarle provecho a esta clase
Gracias
Lubin
User avatar
lubin
 
Posts: 439
Joined: Fri Dec 09, 2005 12:41 am
Location: Lima, Peru

Re: el diseño de TGantt de Ramón Avendaño

Postby lubin » Sat Oct 01, 2011 7:53 pm

Antonio

He probado el ultimo test de Tgantt donde muestras los 31 Dias. el cual permite jalar las barras hasta una nueva posicion,

Un detalle : Esta ventana al cambiarse de tamaño, las barras no se redimensionan, son fijas, y esto no debe ser asi, porque obviamente la barra marcara "otro dia" con solo el hecho de agrandar o reducir la ventana. Las barras deben redimensionarse con la venta.

otra consulta : Es posible que este metodo me devuelva los "nuevos dias marcados" luego de haberlos movido el tamaño de cada barra del grafico ??

Gracias
Lubin
User avatar
lubin
 
Posts: 439
Joined: Fri Dec 09, 2005 12:41 am
Location: Lima, Peru

Re: el diseño de TGantt de Ramón Avendaño

Postby Antonio Linares » Sat Oct 01, 2011 8:56 pm

Lubin,

La Clase TGantt admite muchas posibilidades, pues es un diseño básico que puede ampliarse tanto como se desee.

Habría que definir las DATAs de tamaño de columna y de fila, y asi podriamos definir un Método AdItem() que calculase las coordenadas automaticamente. Los items podrian auto redimensionarse en base al tamaño de la columna y fila.

Asi mismo lo idóneo seria crear una Clase TGanttItem con DATAs para saber si se ha modificado, etiqueta, tooltip, colores, gradientes, etc.

El scroll lateral y vertical es calcular una posición relativa a la hora de pintar (method Paint()).

Las posibilidades son muchas, ahora veamos que tal aceptación tiene y que interés despierta, y todo se andará :-)
regards, saludos

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

Re: el diseño de TGantt de Ramón Avendaño

Postby lubin » Mon Oct 03, 2011 3:20 pm

Antonio

Creo que tambien habria que ir avanzando la impresion del Gantt, pues e 99.99% de los usuarios que usan gant lo desean ver en un papel pegado en la pared para su control,

Pensaba una alternativa mientras tanto.. imprimir lo que se ve en la pantalla (siepre y cuando todo el proyecto completo se vea en la pantalla...)

voy a estudiar bien la clase a ver que mas puedo aportar, Yo (y nosotros ) sabemos el esfuerzo que hacen en ir atendiediendo las necesidades, pero quiza te parecera algo extremo pedirte en el desarrollo en esta clase insertar comentarios basicos de las operaciones que se hacen.. de tal manera que podamos aprender el tipo de operacion o efecto que se hace,, y asi entender mejor la clase y poder aportar mas en ella.. ??? por ejemplo en el metodo GridMonth():

local n, nWidth := ::nWidth() / 31 && me imagino que sera dividir el ancho de la ventana entre los 31 dias... :D

MoveTo( ::hDC, 0, 18 ) && aqui me perdi... :shock:
LineTo( ::hDC, ::nWidth, 18 ) && sigo perdidooo.. :( :(

El saber la accion que se esta haciendo tendra un efecto multiplicador.. !!!

Bueno.. ahi iremos avanzando..

Lubin
User avatar
lubin
 
Posts: 439
Joined: Fri Dec 09, 2005 12:41 am
Location: Lima, Peru

Re: el diseño de TGantt de Ramón Avendaño

Postby carlos vargas » Mon Oct 03, 2011 9:07 pm

MoveTo
Changes the painting coordinates
Syntax:
MoveTo( <hDC>, <nCol>, <nRow> ) --> nLOldPos

Code: Select all  Expand view
MoveTo( ::hDC, 0, 18 ) && aqui me perdi... :shock:

LineTo
Draws a line from the current position up to another
Syntax:
LineTo( <hDC>, <nRow>, <nCol>, <hPen> ) --> lSuccess

Code: Select all  Expand view
LineTo( ::hDC, ::nWidth, 18 ) && sigo perdidooo..

Aclaracion:
::hDC = Dispositivo de contexto del control, se refiere al area usada para pintar trazados o dibujos, cada control tiene uno. (a mi se me parece como un plano bidimensional) :-)
::nWidth = Ancho del area del control.
nRow y nCol posiciones en el Dispositivo de contexto dado en pixel.

*asi cada control o ventana en windows tiene un ::hDC,
*tiene una posicion inicial:
::nTop
::nLeft
*tiene un alto y un ancho
::nWidth
::nHeight

para dibujar algo (lineas, cuadros, circulos, poligonos) o pintar algo (iconos, bitmaps, otros controles) hay que ubicar la posicion con MoveTo, para dibujar la linea partiendo de la posicion especificada antes hasta una posicion final se usa LineTo

salu2
carlos vargas
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1683
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: el diseño de TGantt de Ramón Avendaño

Postby AIDA » Mon Oct 03, 2011 10:26 pm

Hola

Perdón por mi indiorancia pero para que es la clase :oops:


Saluditos :wink:
Que es mejor que programar? creo que nada :)
Atropellada pero aqui ando :P

I love Fivewin

séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
User avatar
AIDA
 
Posts: 877
Joined: Fri Jan 12, 2007 8:35 pm

Re: el diseño de TGantt de Ramón Avendaño

Postby Antonio Linares » Tue Oct 04, 2011 6:37 am

Aida,

Un objeto TGantt es un control (deriva de TControl) que maneja un array de items. Esos items tienen unas coordenadas y se pintan en la superficie del TGantt. Además de eso, con el ratón podemos mover esos items y redimensionarlos


http://es.wikipedia.org/wiki/Diagrama_de_Gantt

:-)
regards, saludos

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

Re: el diseño de TGantt de Ramón Avendaño

Postby lubin » Wed Oct 05, 2011 2:51 pm

Aida

El diagrama Gant como habras leido es muy usado para el control de proyectos, planes de produccion, o plan de actividades como por ejemplo controlar la construccion de una casa, permite ver las etapas de la cosntruccion de la casa y como se van desarrollando las actividades ,, finalmente sabran para cuando tienen la casa construida o si estan atrasados... etc etc.. algo asi...

1.Preparar el terreno _____________xxxx
2.Construir la base de la casa__________xxxx
3.plantar las columas_____________________xxxxx
4.Poner las paredes de la Zona A________________xxxxxxxx
5. Poner la paredes de la Zona B______________________xxxxxx
6. Poner las Paredes de la Zona C_______________________xxxxxxx
7. Techado Zona A_____________________________________xxx
8. Techado Zona B________________________________________xxx
9. Cableados instalaciones electricas________________________xxxxxxxxxxxxx
10 Instalaciones Sanitarias__________________________________xxxxxxxxxxxx
9. Acabados Zona A, B_______________________________________xxxxxxxx
10 Acabados Zona C____________________________________________xxxxxxxx
11 Control final / entrega_______________________________________________xxx
semanas de proyecto________________xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
_________________________________12345678901234567890123456789012345678

Es de esta manera se grafica ... pero en Fivein .. debe salir muchisimo mas bonito.. :D
El sistema debe controlar como van los avances , los atrasos , adelantos de las operaciones
es muy util para planificacion.
Lubin
User avatar
lubin
 
Posts: 439
Joined: Fri Dec 09, 2005 12:41 am
Location: Lima, Peru

Re: el diseño de TGantt de Ramón Avendaño

Postby Bayron » Wed Oct 05, 2011 3:43 pm

AIDA, una foto explica más que mil palabras, así que aquí esta algo mas visual:

Image

Con un diagrama de Gantt puedes mostrar el inicio y el final de una actividad y su relación con otras actividades dentro de determinado projecto...

Puedes usar OpenProj que es gratis... (Windows y Linux)
http://softlayer.dl.sourceforge.net/project/openproj/OpenProj%20Binaries/1.4/openproj-1.4.msi
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: el diseño de TGantt de Ramón Avendaño

Postby lubin » Wed Oct 05, 2011 4:37 pm

Efectivamente Bayron ...

Tu imagen lo muestra mucho mejor... pero la idea es tenerlo integrado en un sistema hecho en fiveWin,, la pantalla mostrada es del software OpenProj el cual es bastante bueno.. y como dices es gratuito..

El objetivo del desarrollo de la clase TGantt es obtener este tipo de diagramas.

Lubin
User avatar
lubin
 
Posts: 439
Joined: Fri Dec 09, 2005 12:41 am
Location: Lima, Peru

Re: el diseño de TGantt de Ramón Avendaño

Postby AIDA » Fri Oct 07, 2011 2:59 am

Hola


Muchas Gracias por las explicaciones y ejemplos ahora si ya entendí para que son :mrgreen:


Saluditos :wink:
Que es mejor que programar? creo que nada :)
Atropellada pero aqui ando :P

I love Fivewin

séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
User avatar
AIDA
 
Posts: 877
Joined: Fri Jan 12, 2007 8:35 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 85 guests