XBROWSE SetColumns()

XBROWSE SetColumns()

Postby TimStone » Fri Dec 09, 2022 9:47 pm

In xBrowse, right clicking on the header displays a popup with a list of all columns.

To the left is an icon, and it can be clicked to change the status of show() or hide() for the selected column.

The problem appears that this popup displays, but once one field is changed, it closes. For a large database, when only a few fields are desired, this takes a lot of mouse clicks: Rt click the header, select the field and click to change it's status, then repeat. If one only wants to track, for example, 5 fields, but the database has 60, thats a lot. It would be nice if there was an ability to select/deselect ALL, and also if the popup could stay open until one is finished making their choices.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2940
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: XBROWSE SetColumns()

Postby karinha » Sat Dec 10, 2022 12:05 am

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7766
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: XBROWSE SetColumns()

Postby TimStone » Sat Dec 10, 2022 12:31 am

I saw that, and it is over a year ago when it was stated "We'll look at it"

To be specific, the Hide/Seek popup would be better if it stayed open for multiple selections, and then modified the oBrw after an OK button was selected. Here is how I implemented this ability in a File Editor I use:

Code: Select all  Expand view

METHOD SelectCols(  )

  MEMVAR oBrush, oMFont
  LOCAL aSetCols := {}, lDoColSel := .f., n, oDcs, oColBrw, oHb1, oCol

  FOR n := 1 TO LEN( ::oFbrw:aCols )
    AADD( aSetCols, { .t., ::oFbrw:aCols[n]:cHeader } )
  NEXT

   // Create the dialog
   DEFINE DIALOG oDcs RESOURCE "PROBROW" BRUSH oBrush TRANSPARENT FONT oMFont
    oDcs:nHelpID := 1300

        // Create buttons
        REDEFINE BTNBMP RESOURCE "HROK" ID 2101 OF oDcs TOOLTIP "Process" PROMPT "Process" ;
            ACTION ( lDoColSel := .T., oDcs:end() ) NOBORDER TRANSPARENT
        REDEFINE BTNBMP RESOURCE "HREXIT" ID 2102 OF oDcs TOOLTIP "Cancel" PROMPT "Cancel" ;
            ACTION oDcs:end() NOBORDER TRANSPARENT
        REDEFINE BTNBMP oHb1 RESOURCE "HROK" ID 2103 OF oDcs

     /* Create the browse control  Browse the records in the listbox.  Double click will change the action
       flag for the items.  The YES button processes, the NO button does not  */

        REDEFINE XBROWSE oColBrw ID 2100 OF oDcs    ON DBLCLICK( aSetCols[ oColBrw:nArrayAt, 1 ] ;
         := IIF( aSetCols[ oColBrw:nArrayAt, 1 ] = .t., .f., .t. ), oColBrw:refresh() ) ;
         MESSAGE "Double click to change from show to hide, or back to show"

        // Attach the database
        oColBrw:setArray( aSetCols )
        oColBrw:aCols := {}

        // Add the columns
        ADD oCol TO oColBrw DATA ARRAY ELEMENT 1 HEADER "Show" SIZE 100 ALIGN CENTER
        oCol:SetCheck( )
        ADD oCol TO oColBrw DATA ARRAY ELEMENT 2 HEADER "Field" SIZE 300 ALIGN LEFT

        // Turn off horizontal scrolling
        oColBrw:lHScroll := .F.
        // Set the styles
        oColBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
        oColBrw:nColDividerStyle := LINESTYLE_RAISED
        oColBrw:nRowDividerStyle := LINESTYLE_RAISED

        // Activate the dialog screen
        ACTIVATE DIALOG oDcs ON INIT ( oHb1:hide( ), oDcs:center(wndmain()))

   IF lDoColSel

       FOR n := 1 TO LEN( aSetCols )
        IF aSetCols[n,1]
            ::oFbrw:aCols[n]:Show( )
            ELSE
            ::oFbrw:acols[n]:Hide( )
        ENDIF
    NEXT

   ENDIF

RETURN NIL
 
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2940
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: XBROWSE SetColumns()

Postby Marc Venken » Sat Dec 10, 2022 10:40 am

This is how I change colums, sizes on the fly. I put some extra data in (index, fieldlen, ....) that is easy while running and programming at the same time.
Most of my xbrowses are generated from a dbf-layout.

Image

Code: Select all  Expand view

oBrwSel:bRClickHeaders := { || XbrColSelector( oBrwSel, cNaam ) }  // Kies welke velden tezien zijn

function XbrColSelector( oBrowse, cNaam ) //  Toont de koppen om te tonen in Xbrowse

   local oDlg, oBrw
   local aSave    := aCopy( oBrowse:aCols )
   local cSavefile:="Temp.dbf"
   DEFAULT cNaam:=""

   DEFINE DIALOG oDlg SIZE 1000,800 PIXEL TRUEPIXEL

   @ 60,20 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE oBrowse:aCols ;
      COLUMNS "lHide", "cHeader", "cExpr", "nWidth", "cDatatype","nDataLen", "cSortorder", "Value" ;
      HEADERS "", "Header","Field","Width","Type","F_Len","Index", "Waarde" ;
      COLSIZES 40, 120,120,50,50,50,100,450 ;
      CELL LINES NOBORDER

   oBrw:bRClickHeaders := { || msginfo("Test") }  // Kies welke velden tezien zijn

   WITH OBJECT oBrw
      :nStretchCol   := 2
      WITH OBJECT :aCols[ 1 ]
         :bEditValue    := { |x| If( x == nil, !oBrw:aRow:lHide, oBrw:aRow:lHide := !x ) }
         :SetCheck( nil, .t. )
         :nHeadBmpNo    := 2
      END
      WITH OBJECT :Width
         :nEditType     := EDIT_GET
         :bClrSel          := { || { CLR_BLACK, CLR_YELLOW }}
      END

      :CreateFromCode()
   END

//   @ 20,05 BTNBMP PROMPT "DBF" SIZE 80,30 FLAT PIXEL OF oDlg ACTION (cSaveFile:=msgget("Filename",,@cSaveFile), oBrowse:todbf( cSaveFile ,,,.t.))
   @ 20,20 BTNBMP PROMPT "Save new Values" SIZE 120,30 2007 PIXEL OF oDlg CENTER ACTION (updatebrowselengte(oBrowse, cNaam))
   @ 20,200 BTNBMP PROMPT "Show ALL" SIZE 120,30 2007 PIXEL OF oDlg CENTER ACTION (AEval( oBrowse:aCols, { |o| o:lHide := .f. } ),oDlg:End() )

   ACTIVATE DIALOG oDlg CENTERED

   oBrowse:Refresh()


return nil

Function updatebrowselengte(oBrw, cNaam)
   msginfo("UpdateNaam : "+cNaam)
   netopen("brwdetail","code","Tempupd",.f.)
   select tempupd
   FOR n := 1 TO Len( oBrw:aCols )
      oCol  := oBrw:aCols[ n ]
      cHeader := oBrw:cHeaders[n]
      nSize := oBrw:nWidths[n]
      tempUpd->(dbgotop())
      do while !tempupd->(eof())
         if tempupd->brwnaam = cNaam .and. tempupd->veld = oCol:cExpr
            tempupd->size = nSize
         endif
         tempUpd->(dbskip())
      enddo
   next
   close TempUpd
return NIL

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: TimStone and 28 guests