Edit a xbrowse

Edit a xbrowse

Postby Silvio.Falconi » Wed May 09, 2018 4:16 pm

Not insert a new date ... why ?

on a column I call a calendar

Code: Select all  Expand view
WITH OBJECT oBrw:aCols[ 8]
            :AddBmpFile(".\bitmaps\sh_cal.bmp")
            :nBtnBmp := 1
            :lBtnTransparent := .t.
            :lBmpStretch := .f.
            :nwidth    := 115
            :nDataStrAlign := AL_CENTER
            :nHeadStrAlign := AL_CENTER
            :nBtnWidth := 30
            :nDataStrAlign := oBrw:aCols[8]:DefStyle(AL_LEFT,.f.)
            :nEditType := EDIT_BUTTON
            :bEditBlock := { ||xCalendar()  }
                   END




Image



I use xcalend of Nages ( xbrcalen.prg) of samples
I add on xcalend.prg these lines
Code: Select all  Expand view

Local lOk:=.f.

FOR i := 1 TO LEN(oBrwCal:aCols)
      oCol := oBrwCal:aCols[ i ]
      oCol:bLDClickData  := {|| ( lOk := .t., oDlg:End() )   }
   NEXT

...
ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont, oFontD

   if lOK
       return dDate
  endif
 



Ho I can insert the new date selected directly on xbrowse row ?

thanks
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7057
Joined: Thu Oct 18, 2012 7:17 pm

Re: Edit a xbrowse

Postby nageswaragunupudi » Thu May 10, 2018 8:34 am

Your changes are correct. It should work.
Anyway please try this new function XBrDatePicker( oBrw:oCol )

Usage:
oCol:bEditBlock := { |r,c,o,k| XbrDatePick( o ) }

Code: Select all  Expand view
#include "fivewin.ch"

static dDate, dBOM, dOffSet
static nMonth, cMonth, nYear
static oBrw, oDate

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

function XBrDtPicker( dParam, cTitle, nSize )

   local oDlg, oFont, oFontD, oCbx, d, a, oCol, nTop, nLeft
   local aMth[ 12 ]
   local aWeek[ 7 ]
   local lOk      := .f.

   if ValType( dParam ) == "O" .and. dParam:IsKindOf( "TXBrwColumn" )
      oCol     := dParam
      dParam   := oCol:Value
      DEFAULT cTitle := oCol:cHeader, nSize := 0.6
      a        := oCol:oBrw:aCellCoor()
      nTop     := a[ 3 ]
      nLeft    := a[ 2 ]
      a        := ClientToScreen( oCol:oBrw:hWnd, { nTop, nLeft } )
      nTop     := a[ 1 ]
      nLeft    := a[ 2 ]
   else
      DEFAULT nSize  := 1.0
   endif
   nSize    := Min( 1.5, Max( 0.6, nSize ) )

   SET CENTURY ON
   SET DATE ITALIAN

   AEval( aMth,  { |c,i| aMth[ i ]  := NToCMonth( i ) } )
   AEval( aWeek, { |c,i| aWeek[ i ] := Left( NToCDOW( i ), 3 ) } )

   SetDate( dDate := IfNil( dParam, Date() ) )

   DEFINE FONT oFont  NAME "Segoe UI" SIZE 0,-20*nSize
   DEFINE FONT oFontD NAME "COPPERPLATE GOTHIC BOLD" SIZE 0,-36*nSize

   DEFINE DIALOG oDlg SIZE 542*nSize,490*nSize PIXEL TRUEPIXEL ;
      FONT oFont TITLE IfNil( cTitle, "CALENDAR WITH XBROWSE" )

   @ 20*nSize, 20*nSize COMBOBOX oCbx VAR nMonth ITEMS aMth SIZE 150*nSize,300 PIXEL OF oDlg UPDATE ;
      ON CHANGE ResetCal()

   @ 20*nSize,190*nSize GET nYear PICTURE "9999" SIZE 60*nSize,34*nSize PIXEL OF oDlg UPDATE ;
      SPINNER MAX 2999 MIN 1900 ;
      ON CHANGE ReSetCal()

   @ 20*nSize,280*nSize GET oDate VAR dDate SIZE 120*nSize,34*nSize PIXEL OF oDlg ;
      SPINNER ;
      ; //ON CHANGE SetDate( dDate ) ;
      VALID     SetDate( dDate )

   @ 20*nSize,435*nSize BTNBMP RESOURCE 0x200CD SIZE 40*nSize,34*nSize PIXEL OF oDlg FLAT ;
      ACTION oDlg:End()

   @ 20*nSize,480*nSize BTNBMP RESOURCE 0x100FC SIZE 40*nSize,34*nSize PIXEL OF oDlg FLAT ;
      ACTION ( lOk := .t., oDlg:End() )

   if nSize < 0.6
      AEval( oDlg:aControls, { |o| o:nTop -= 5, o:nHeight += 5 } )
   endif

   @ 60*nSize,20*nSize XBROWSE oBrw SIZE 502*nSize,-20*nSize PIXEL OF oDlg ;
      DATASOURCE Array( 6 ) COLUMNS 1,2,3,4,5,6,7 ;
      HEADERS aWeek ;
      NOBORDER CLASS TDtXBrowse()

   AEval( oBrw:aCols, { |o| SetupCol( o ) } )

   WITH OBJECT oBrw
      :lRecordSelector  := .f.
      :lHScroll      := .f.
      :lVScroll      := .f.
      :lDisplayZeros := .f.
      :lColChangeNotify := .t.
      :lRelyOnKeyNo  := .f.
      :nRowHeight    := 60*nSize
      :nwidths       := 70*nSize
      :nRowDividerStyle := ;
      :nColDividerStyle := LINESTYLE_LIGHTGRAY
      :oDataFonts    := oFontD
      :nDataStrAligns:= AL_CENTER
      :bChange       := { || dDate := dOffSet + oBrw:nColSel + 7 * ( oBrw:nRowSel - 1 ), oDate:Refresh() }
      :bLDClickDatas := { || lOk := .t., oDlg:End() }
      //
      :CreateFromCode()
   END

   oDlg:bStart := { || SetDate( dDate ) }

   if nTop != nil

      if nTop > ScreenHeight() * 0.9 - oDlg:nHeight
         nTop  -= ( oDlg:nHeight + oCol:oBrw:nRowHeight + 30 )
      endif
      if ( a := ( nLeft + oDlg:nWidth - ( ScreenWidth() - 50 ) ) ) > 0
         nLeft -= a
      endif

      oDlg:bInit  := { || oDlg:Move( nTop, nLeft ) }
   endif

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont, oFontD

return If( lOk, dDate, nil )

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

function SetUpCol( oCol )

   local nClrPane := oCol:oBrw:oWnd:nClrPane

   oCol:bEditValue   := { || dOffSet + 7 * ( oCol:oBrw:nArrayAt - 1 ) + oCol:nArrayCol }
   oCol:bStrData     := { |x,o| DAY( o:Value ) }
   if oCol:nArrayCol == 1
      oCol:bClrStd   := { || If( MONTH( oCol:Value ) == nMonth, { CLR_HRED, CLR_WHITE }, ;
                                 {  CLR_HGRAY, nClrPane  } ) }
      oCol:bClrHeader:= { || { CLR_HRED, CLR_WHITE } }
   else
      oCol:bClrStd   := { || If( MONTH( oCol:Value ) == nMonth, { CLR_BLACK, CLR_WHITE }, ;
                                 { CLR_HGRAY, nClrPane } ) }
   endif

return nil

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

function SetDate( dDate )

   local nDays, nRow, nCol, nLen

   if dBOM != BOM( dDate )
      dBOM     := BOM( dDate )
      dOffSet  := dBOM - DOW( dBOM )
      nMonth   := Month(  dDate )
      cMonth   := CMONTH( dDate )
      nYear    := Year(   dDate )
   endif

   if oBrw != nil
      nDays    := dDate - dOffSet
      nRow     := Int( nDays / 7 ) + 1
      if ( nCol := nDays % 7 ) == 0
         nCol  := 7
         nRow--
      endif
      WITH OBJECT oBrw
         :nRowSel    := ;
         :nArrayAt   := nRow
         :nColSel    := nCol
         nLen        := Ceiling( ( EOM( dDate ) - dOffSet ) / 7 )
         :bKeyCount  := { || nLen }
         :Refresh()
         :oWnd:Update()
         :SetFocus()
      END
   endif

return .t.

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

function ResetCal()

   local dNewDate := STOD( STRZERO( nYear, 4 ) + STRZERO( nMonth, 2 ) + "01" )

   dDate    := dNewDate + MIN( DAY( dDate ), LASTDAYOM( dNewDate ) ) - 1
   oDate:Refresh()
   SetDate( dDate )

return .t.

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

CLASS TDtXBrowse FROM TXBrowse

   CLASSDATA lRegistered INIT .f.

   METHOD GoLeft()
   METHOD GoRight()
   METHOD GoUp()
   METHOD GoDown()

ENDCLASS

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

METHOD GoLeft() CLASS TDtXBrowse

   if ::nColSel == 1
      if ::nArrayAt == 1
         SetDate( dDate - 1 )
      else
         ::nColSel := 7
         ::GoUp()
      endif
      return nil
   endif

return ::Super:GoLeft()

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

METHOD GoRight() CLASS TDtXBrowse

   if ::nColSel == 7
      if ::nArrayAt == ::nLen
         SetDate( dDate + 1 )
      else
         ::nColSel   := 1
         ::GoDown()
      endif
      return nil
   endif

return ::Super:GoRight()

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

METHOD GoUp( n ) CLASS TDtXBrowse

   if ::nArrayAt == 1
      SetDate( dDate - 7 )
      return nil
   endif

return ::Super:GoUp( n )

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

METHOD GoDown( n ) CLASS TDtXBrowse

   if ::nArrayAt == ::nLen
      SetDate( dDate + 7 )
      return nil
   endif

return ::Super:GoDown( n )

//----------------------------------------------------------------------------//
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Edit a xbrowse

Postby Silvio.Falconi » Thu May 10, 2018 12:03 pm

the calendar run but the not save the value
Code: Select all  Expand view
WITH OBJECT oBrw:aCols[ 8]
            :AddBmpFile(".\bitmaps\sh_cal.bmp")
            :nBtnBmp := 1
            :lBtnTransparent := .t.
            :lBmpStretch := .f.
            :nwidth    := 115
            :nDataStrAlign := AL_CENTER
            :nHeadStrAlign := AL_CENTER

            :nDataStrAlign := oBrw:aCols[8]:DefStyle(AL_LEFT,.f.)
            :nEditType := EDIT_BUTTON
            *:bEditBlock := { ||(xCalendar("Seleziona una data",RES->CHECK_IN,1),oBrw:refresh())  }
            :bEditBlock := { |r,c,o,k|XBrDtPicker( o ) }
         END


Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7057
Joined: Thu Oct 18, 2012 7:17 pm

Re: Edit a xbrowse

Postby nageswaragunupudi » Thu May 10, 2018 12:50 pm

I do not know why. It is saving the value here.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Edit a xbrowse

Postby Silvio.Falconi » Thu May 10, 2018 10:50 pm

here not save on xbrowse
I add a parameter
function XBrDtPicker( dParam, cTitle, nSize, nField )

then

ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont, oFontD

if lOK
If nField = 1
replace res->check_in with dDate
else
replace res->check_out with dDate
endif
endif

and not it save on xbrowse the new date
I not Know why
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7057
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 84 guests