Modification of xbrowse with new feature

Modification of xbrowse with new feature

Postby Silvio.Falconi » Wed Jun 12, 2024 9:33 am

I wish ask to Nages to make a modify with new feature

I asked Nages to make these changes many months ago, basically I need to display n columns but at the beginning only n default columns, the user can insert them online or remove them. Obviously I have already made these changes by bringing Francisco's idea but every time there is a new release I would have to rewrite part of the xbrowse class

the changes are simple,

you need to add 3 data

DATA aCols2Hide AS ARRAY INIT Array(0)
DATA aDefaultCols INIT ARRAY( 0 )
DATA aPreviousCols INIT ARRAY( 0 )

and a method SetUserCols(lSetUserCol) and change the method



I made a small xbrowse subclass

Code: Select all  Expand view  RUN
CLASS TMyBrowse  FROM TXBrowse
   CLASSDATA lRegistered AS LOGICAL

   DATA aCols2Hide AS ARRAY INIT Array(0)
   DATA aDefaultCols  INIT ARRAY( 0 )
   DATA aPreviousCols INIT ARRAY( 0 )

   METHOD New (nRow, nCol, nWidth, nHeight, oWnd)
   METHOD SetUserCols(lDefCols)
ENDCLASS

METHOD New(nRow, nCol, nWidth, nHeight, oWnd)  CLASS TMyBrowse
return ::SuPer:New()

METHOD SetUserCols(lDefCols)  CLASS TMyBrowse
local aCols
DEFAULT lDefCols := .t.
aCols := if(lDefCols, ::aDefaultCols, ::aPreviousCols )
if Len( aCols ) != 0
   AEval( ::aCols, { |o| If( AScan( aCols, o:nCreationOrder ) > 0, o:Show(),o:Hide() ) } )
endif
RETURN NIL

 



and modified with ovverride command the method SetColumns

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


#xcommand OVERRIDE METHOD <!Message!> [IN] CLASS <!Class!> ;
                             WITH [METHOD] <!Method!> [SCOPE <Scope>] => ;
            __clsModMsg( <Class>():classH, #<Message>, @<Method>() )


function Ut_Xbrowse_override()
   OVERRIDE METHOD SetColumns IN CLASS TXbrowse  WITH SetMyColumns
return nil

//----------------------------------------------------------------------------------------//
Function SetMyColumns(nRow, nCol, nFlags, oColumn )
   local Self := HB_QSelf()
   local oMenu, oCol, cPrompt
   local nFor, nLen
   local cPrvGrp  := ""
   local oGrpMenu
   local lChecked , lDefCols
   local bPrevCols := {|| ::aPreviousCols := ::GetDisplayCols() }
   local bUserCols := {|| aCols := if(lDefCols, ::aDefaultCols, ::aPreviousCols ) ,;
                          if( Len( aCols ) != 0, AEval( ::aCols, { |o| If( AScan( aCols, o:nCreationOrder ) > 0, o:Show(),o:Hide() ) } ) ,)}

   nLen := Len( ::aCols )
   MENU oMenu POPUP

      if ::l2000
         OSend( oMenu, "_L" + Str( Min( 2015, ::n2KStyle ), 4 ), .t. )
      else
         oMenu:l2013 := .t.
      endif

      Menuitem fwstring("Show/Hide") SEPARATOR BOLD COLORPNEL CLR_BLACK, ::nRecSelColor
      separator

      for nFor := 1 to nLen
         oCol := ::aCols[ nFor ]
         if !( IfNil( oCol:cGrpHdr, "" ) == cPrvGrp )
            if ! Empty( cPrvGrp )
               ENDMENU
               oGrpMenu := nil
            endif
            if ! Empty( oCol:cGrpHdr )
               MENUITEM oCol:cGrpHdr BOLD
               MENU
                  MENUITEM oGrpMenu PROMPT oCol:cGrpHdr BOLD ;
                     ACTION ( lChecked := oMenuItem:lChecked, ;
                        AEval( oMenuItem:Cargo, ;
                        { |o| If( lChecked, o:Hide(), o:Show() ) } ) )
                  oGrpMenu:Cargo := {}
                  SEPARATOR
            endif
            cPrvGrp  := IfNil( oCol:cGrpHdr, "" )
         endif

         MenuAddItem( If( Empty( oCol:cHeader ), "Col-" + cValToChar( nFor ), oCol:cHeader ), ;
            nil, !oCol:lHide, ;
            ( Len(::aDisplay) != 1 .or. ocol:nPos != 1 ), ;
            { |o| If( o:Cargo:lHide, o:Cargo:Show(), o:Cargo:Hide() ) } ):Cargo := oCol

         if oGrpMenu != nil
            AAdd( oGrpMenu:Cargo, oCol )
            if !oCol:lHide
               oGrpMenu:lChecked := .t.
            endif
         endif

      next
      if ! Empty( cPrvGrp )
         ENDMENU
      endif

      if oColumn != nil .and. !Empty( oColumn:bHRClickMenu )
         Eval( oColumn:bHRClickMenu, oColumn, oMenu )
      endif
         separator
        if Len( ::aDefaultCols ) != 0
         Menuitem fwstring("Default Columns")   ACTION ( Eval( bPrevCols ), lDefCols:=.t., Eval( bUserCols ), ::Refresh() )
         Menuitem fwstring("All Columns")       ACTION ( Eval( bPrevCols ), AEval( ::aCols, { |o| o:lHide := .f. } ) , ::Refresh() )
         Menuitem fwstring("Previous Columns")  ACTION ( lDefCols:=.f., Eval( bUserCols ), ::Refresh() )
      endif

   ENDMENU

   ACTIVATE POPUP oMenu AT ::FirstRow(), nCol OF Self

return nil

 




Usage:

local aDefCols := {1, 2, 4 } // columns I wish see at init

@ 110,10 XBROWSE oBrw SIZE -5,-60 PIXEL OF oDlg ;
DATASOURCE oDbf ;//
COLUMNS "First","Last","Street", "City","State","Zip","Hiredate","Married", "Age" ; //
CELL LINES AUTOSORT NOBORDER FOOTERS CLASS TmyBrowse()


WITH OBJECT oBrw
:RestoreState( cState )
:aDefaultCols := aDefCols
:SetUserCols(lSetUserCol)

:lIncrFilter := .t.
:bOnSort := { |b,oCol| oBrw:Seek( "" ), ;
oBrw:cFilterFld := oCol:cExpr, ;
oBrw:SetFocus() }
:lDrawBorder := .t.
:lHScroll := .f.
:SetMultiSelectCol()

:oSeek := oGet
:CreateFromCode()
END
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: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Modification of xbrowse with new feature

Postby nageswaragunupudi » Wed Jun 12, 2024 1:45 pm

There is already a method
oBrw:ReArrangeCols( aCols )
for many years
Regards

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

Re: Modification of xbrowse with new feature

Postby Silvio.Falconi » Wed Jun 12, 2024 5:02 pm

nageswaragunupudi wrote:There is already a method
oBrw:ReArrangeCols( aCols )
for many years


and how I must use it ?

can make a sample ?

You already told me this another time but I think I didn't explain it well

for a practical example I want to set 25 columns but by default at the beginning in xbrowse you only see 5 columns, the user can insert some of the 25 (up to 25) or hide, so I have the default columns, the columns he has chosen the user and previous columns....
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: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Modification of xbrowse with new feature

Postby Marc Venken » Thu Jun 13, 2024 7:37 am

Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1446
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Modification of xbrowse with new feature

Postby Silvio.Falconi » Thu Jun 13, 2024 8:29 am

Marc Venken wrote:https://forums.fivetechsupport.com/viewtopic.php?f=3&t=40084

viewtopic.php?f=3&t=40956


Per haps you nou understood what I mean
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: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Modification of xbrowse with new feature

Postby Otto » Thu Jun 13, 2024 9:35 am

Silvio, is this what you want?

Regards,
Otto

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


Return to FiveWin for Harbour/xHarbour

Who is online

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