xBrowse With DatePicker & TimePicker

xBrowse With DatePicker & TimePicker

Postby Daniel Garcia-Gil » Sat Feb 28, 2009 5:02 am

Saludos/Regards

Hoy les dejo otra contribucion para la xBrowse, uso de DatePicker y TimePicker en edicion de celdas.
Other contribution for xbrowse class, use datepicker and timepicker in celledition


Comenzamos/Start
Este Link es un Exe si quieren probar antes de hacer cambios
this link is EXE, if you want to try first before making any changes ...

http://www.sitasoft.com/fivewin/test/testdtp.rar


Archivos a editar / file to edit
xbrowse.ch
xbrowse.prg

Metodos a Editar en xBrowse.prg/ Methods to Edit in xBrwose.prg
METHOD PaintData() CLASS TXBrwColumn
METHOD Edit() CLASS TXBrwColumn
function EditGetkeyDown()
METHOD PostEdit() CLASS TXBrwColumn


Abrir/open xBrowse.ch

Buscar / find
Code: Select all  Expand view
#define EDIT_GET_BUTTON       5


Agregar Despues/ Add After
Code: Select all  Expand view
#define EDIT_DATE             6
#define EDIT_TIME             7


Guardar/save

Abrir xBrowse.prg

Bucar / Find
Code: Select all  Expand view
#include "Report.ch"


Agregar Despues / Add After
Code: Select all  Expand view
#include "dtpicker.ch"


Buscar METHOD nEditType(); // Sets or Gets de Edit Mode / Find METHOD nEditType(); // Sets or Gets de Edit Mode

Agregar Antes / Add Before
Code: Select all  Expand view
  METHOD EditDateTime( nKey )


Buscar en METHOD PaintData() / Find in METHOD PaintData()
Code: Select all  Expand view
  if nType > 1
      if lSelected
 

Reemplazar con / Replace With
Code: Select all  Expand view
  if nType > 1 .and. nType < EDIT_DATE
      if lSelected


Buscar en Method Edit / Find In Edit Method
Code: Select all  Expand view
  aColors := Eval( ::bClrEdit )


Agregar Antes / Add Before
Code: Select all  Expand view
  if ::nEditType >= EDIT_DATE
      return ::EditDateTime( nKey )
   endif
 

Buscar en function EditGetkeyDown / Find in function EditGetkeyDown
Code: Select all  Expand view
  If lExit
      ::oEditGet:nLastKey := nKey
      ::oEditGet:End()
   Endif



Reemplazar con / Replace With please check it in http://forums.fivetechsupport.com/viewtopic.php?p=76306#p76306 (see post bellow)
Code: Select all  Expand view
  If lExit .and. ::nEditType != EDIT_DATE
      ::oEditGet:nLastKey := nKey
      ::oEditGet:End()
   else
      ::PostEdit()
   Endif


Buscar en function EditGetkeyDown / Find in function EditGetkeyDown
Code: Select all  Expand view
return nil


Agregar Depues / Add After
Code: Select all  Expand view
METHOD EditDateTime( nKey ) CLASS TXBrwColumn
local aColors
local lCenter, lRight
local nRow, nCol, nWidth, nHeight
local hBrush
local oFont
local uValue



   if ValType ( ::oEditFont ) == "B"
         oFont = Eval( ::oEditFont, Self )
    else
         oFont = ::oEditFont
   endif

   uValue  := Eval( ::bEditValue )

   aColors := Eval( ::bClrEdit )
   lCenter := ( ::nDataStrAlign == AL_CENTER )
   lRight  := ( ::nDataStrAlign == AL_RIGHT )

   nRow    := ( ( ::oBrw:nRowSel - 1 ) * ::oBrw:nRowHeight ) + ::oBrw:HeaderHeight()

   hBrush := CreateSolidBrush( aColors[ 2 ] )
   ::EraseData( nRow, ::nDisplayCol, ::oBrw:nRowHeight , hBrush )
   DeleteObject( hBrush )

   if ::nEditType == EDIT_DATE
      ::oEditGet := TDatePick():New( 0, 0, { | u | If(PCount()==0,uValue,uValue:= u ) }, ::oBrw, 0, 0, , aColors[ 1 ],;
                  aColors[ 2 ], oFont, .f., , , , .f., , , )
   else
      ::oEditGet := TTimePick():New( 0, 0, { | u | If(PCount()==0,uValue,uValue:= u ) }, ::oBrw, 0, 0, , aColors[ 1 ],;
                  aColors[ 2 ], oFont, .f., , , , .f., , , )
      ::oEditGet:SetTime( uValue )
   endif  
       
   nRow    := ( ( ::oBrw:nRowSel - 1 ) * ::oBrw:nRowHeight ) + ::oBrw:HeaderHeight() + 2
   nCol    := ::nDisplayCol + 3

   nWidth  := ::nWidth - 4

   nHeight := ::oBrw:nRowHeight - 4

   if ::bEditValid != nil
      ::oEditGet:bValid := { | oGet, lRet | oGet:lValidating := .T., lRet := Eval( ::bEditValid, oGet, Self ), oGet:lValidating := .F., If( ! lRet, oGet:SetFocus(),), lRet }
   endif

   ::oEditGet:bKeyDown   := { | nKey | EditGetkeyDown( Self, nKey ) }
   
   if ::nEditType != EDIT_DATE
      ::oEditGet:bLostFocus := { | oGet, hWndFocus | EditGetLostFocus( oGet, hWndFocus, ::oBrw, ::oEditGet, Self ) }
   endif


   ::oEditGet:nLastKey := 0

   ::oEditGet:Move( nRow, nCol, nWidth, nHeight, .t. )
   ::oEditGet:SetFocus()
   ::oEditGet:SelectAll()

   ::oBrw:lEditMode := .T.

    if ::lEditBorder
      WndBoxIn( ::oBrw:GetDC(), nRow-1, nCol-1, nRow + nHeight + 1, nCol + nWidth + 1)
       ::oBrw:ReleaseDC()
   endif

    if nKey != nil
      PostMessage( ::oEditGet:hWnd, WM_CHAR, nKey )
    endif

   ::oBrw:nLastEditCol := ::nPos        
   
       
RETURN .t.


Buscar En METHOD PostEdit / Find In METHOD PostEdit
Code: Select all  Expand view
     case ::nEditType == EDIT_GET


En linea Agregar Despues (Fin de Linea) / IN Line Add After (end of Line)

Code: Select all  Expand view
.or. ::nEditType >= EDIT_DATE


Guardar / Save

Ejemplo / Sample...
Code: Select all  Expand view
#include "fivewin.ch"
#include "xbrowse.ch"
#include "dtpicker.ch"

Function main()
local oWnd, oBrw, oBrw2, oFld
local aArray := { {"one",time(),DATE()},;
                  {"two",time(),DATE()},;
                  {"three",time(),DATE()},;
                  {"four",time(),DATE()},;
                  {"five",time(),DATE()} }


    set date format to "mm/dd/yyyy"

    use customer alias customer new

    define window oWnd title "Test DatePick and TimePick on xBrwose"
   
 
    @ 0,0 FOLDER oFld OF oWnd size 300,300;
      PROMPTS "Array", "Dbf"

    @ 0,0 xbrowse oBrw columns {1,2,3} array aArray of oFld:aDialogs[ 1 ] fastedit
   
    oBrw:nRowHeight := 25
   
    oBrw:aCols[ 1 ]:nEditType := EDIT_GET
   
    oBrw:aCols[ 2 ]:nEditType := EDIT_TIME
    oBrw:aCols[ 2 ]:nWidth := 130
   
    oBrw:aCols[ 3 ]:nEditType := EDIT_DATE
    oBrw:aCols[ 3 ]:nWidth := 130

    oBrw:lAutoappend := .f.
    oBrw:CreateFromCode()
   
    @ 0,0 xbrowse oBrw2 columns "first", "last", "hiredate" alias "customer" of oFld:aDialogs[ 2 ] fastedit
   
    oBrw2:nRowHeight := 25
   
   
    oBrw2:aCols[ 3 ]:nEditType := EDIT_DATE
    oBrw2:aCols[ 3 ]:nWidth := 130

    oBrw2:lAutoappend := .f.
    oBrw2:CreateFromCode()

    oWnd:oClient := oFld
    oFld:aDialogs[ 1 ]:oClient := oBrw
    oFld:aDialogs[ 2 ]:oClient := oBrw2
   
    activate window oWnd on init (oFld:aDialogs[ 1 ]:resize())
   
   
return nil
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: xBrowse With DatePicker & TimePicker

Postby Otto » Sat Feb 28, 2009 3:31 pm

Hello Daniel,
thank you very much. These are really useful features.

One question:
Is there a reason why you must commit a change made with the mouse with the enter key?

Thanks again,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: xBrowse With DatePicker & TimePicker

Postby Daniel Garcia-Gil » Sat Feb 28, 2009 3:45 pm

thank otto for feedback

One question:
Is there a reason why you must commit a change made with the mouse with the enter key?


no for me, is xbrowse, when you do edit any cell, it never commit the change with mouse only enter key
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: xBrowse With DatePicker & TimePicker

Postby Otto » Sat Feb 28, 2009 4:23 pm

Hello Daniel,
but if you have a look at the object inspector of FW VISUAL it is different.
If you select a item with the mouse it is changed without ENTER.

I think it should be that way.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: xBrowse With DatePicker & TimePicker

Postby Daniel Garcia-Gil » Sat Feb 28, 2009 5:32 pm

Otto...

Yes, you have reason but... dtpicker have edit features no button features

i dont know how get control on dtpicker button

:(
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: xBrowse With DatePicker & TimePicker

Postby Daniel Garcia-Gil » Sat Feb 28, 2009 5:33 pm

Please change this line on function EditGetkeyDown
find
Code: Select all  Expand view
        ::PostEdit()
 

replace with
Code: Select all  Expand view

      if lExit
         ::PostEdit()
      endif
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: xBrowse With DatePicker & TimePicker

Postby Otto » Sat Feb 28, 2009 6:39 pm

Hello Daniel,
thank you.
I will make the changes this evening.
Regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

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