Search for a number on xbrowse and highlight it

Search for a number on xbrowse and highlight it

Postby Silvio.Falconi » Tue Oct 11, 2022 11:11 am

i have an array with some numbers i would like that

the user selects on the bar "N" if he wants to color a single number or "N +" if he wants to color all numbers equal to the one selected

The user can delete the colors from the browse by pressing "X"

Image

the colors to highlight the number (or numbers) are taken on the basis of a table, it is calculated if the number belongs to a specific decade and according to the decade there are different colors

if the user presses "N +" the procedure must search in the oBrw array for all numbers equal to the one selected but I don't know how to do it


I made this easy test but run only when it found all same numbers
test
Code: Select all  Expand view


 
#include "fivewin.ch"
#include "constant.ch"

#define START_OF_NUMBERS  2

#define MEM_FILE "test.ini"



FUNCTION Main()

   RddSetDefault( "DBFCDX" )

   SetHandleCount( 100 )

   SET DATE FORMAT "dd-mm-yyyy"
   SET DELETED     ON
   SET CENTURY     ON
   SET EPOCH TO    year( date() ) - 20
   SET MULTIPLE    OFF


      test()

      RETURN nil
//---------------------------------------------------//
      /*
Colors


*/



Function test()
local aData:= { ;
                { "17.08.2019",76,83,39,10,61,90,32,55,33,67},;
                { "20.08.2019",44, 4,25,29,66,74,36,55,73,30},;
                { "22.08.2019",89,54,42,12,10,35,24,46,35,47},;
                { "24.08.2019",30,64,38,60,55,44,49,66,11,16},;
                { "27.08.2019",68,11,16,72,80,15, 1,62,76,83},;
                { "29.08.2019",31,35,47,80, 2,72,12, 4,39,10},;
                { "31.08.2019",69,11,28,51,53,36,66,77,25,29},;
                { "03.09.2019",73,30,15,59,62,36, 6,24, 4,25}}

local oDlg,oBar
local oNumber,oPlus,oCancel
local lNumber

 DEFINE DIALOG oDlg SIZE 800,400 PIXEL TRUEPIXEL RESIZABLE

    DEFINE BUTTONBAR oBar OF oDlg 2015



    //double click to evidence a number
    DEFINE BUTTON onumber Prompt "N"     OF oBar    ;
      TOOLTIP "number"  ACTION lNumber:=.t.

    //double click to evidence all number same the number select
    DEFINE BUTTON oPlus Prompt "N+"     OF oBar    ;
      TOOLTIP "number"  ACTION lNumber:=.f.

    //clear the number evidence
    DEFINE BUTTON oCancel Prompt "X"     OF oBar    ;
      TOOLTIP "number"  ACTION clear()

  @ 30,05 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      COLUMNS {1,2,3,4,5,6,7,8,9,10,11} ;
      HEADERS {"Date","1","2","3","4","5","1","2","3","4","5"} ;
      ARRAY aData LINES CELL fastedit  ;
      on dblclick  Evidence(lNumber,oBrw) //Specivalue(oBrw)
     // Evidence(lNumber,oBrw)

    WITH OBJECT oBrw


      :nMarqueeStyle   := 2

      FOR i := 2 TO LEN(:aCols)
         oCol := :aCols[ i ]
         oCol:nWidth   := 17
      NEXT


     :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

   return nil

    Function Clear();Return nil

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


Function Evidence(lNumber,oBrw)
   local nrow:=  oBrw:nArrayAt
   local nColNo := oBrw:SelectedCol():nCreationOrder
   local nNumber:=  oBrw:aArrayData[ nrow ][ nColNo ]
   local nDecina:=  CalC_Decina(nNumber)
   local nBack,nGradient,nText
   local i

   Do case
   Case nDecina=1
      nBack    :="#A9A9A9"
      nGradient:="#696969"
      nText    :="#FFFFFF"
   Case nDecina=2
      nBack    :="#FF0000"
      nGradient:="#D93737"
      nText    :="#FFFFFF"
   Case nDecina=3
      nBack    :="#FF4848"
      nGradient:="#D93737"
      nText    :="#FFFFFF"
   Case nDecina=4
      nBack    :="#FF6F6F"
      nGradient:="#FB5200"
      nText    :="#FFFFFF"
   Case nDecina=5
      nBack    :="#32CD32"
      nGradient:="#008000"
      nText    :="#FFFFFF"
   Case nDecina=6
      nBack    :="#66B9CE"
      nGradient:="#548DD4"
      nText    :="#FFFFFF"
   Case nDecina=7
      nBack    :="#548DD4"
      nGradient:="#31859B"
      nText    :="#FFFFFF"
   Case nDecina=8
      nBack    :="#31859B"
      nGradient:="#366092"
      nText    :="#FFFFFF"
   Case nDecina=9
      nBack    :="#FF00FF"
      nGradient:="#BA55D3"
      nText    :="#FFFFFF"
   endcase

          nGradient :=  nRGB( nGradient )
            nBack  :=  nRGB( nBack )
           nText   :=  nRGB(nText )


   IF lNumber
       //one number
                for i= 2 to Len( oBrw:aCols)
                * ShowOneNumber(i,nNumber,oBrw,nBack )
               NEXT
       else
      //all same  numbers
       for i= 2 to Len( oBrw:aCols)
                 ShowAllNumbers(i,nNumber,oBrw,nBack )
               NEXT
  Endif
  oBrw:refresh()


  return nil
//----------------------------------------------------------//
Function ShowAllNumbers(i,nNumber,oBrw,nBack )
 local  oCol := oBrw:aCols[ i ]
 oCol:bClrStd := {|| IF(oCol:value =nNumber, {CLR_BLACK,nBack },{CLR_BLACK,CLR_WHITE })}
 RETURN nil
//----------------------------------------------------------//

 Function Calc_Decina(k)
 local ck:= array(9)
 local nAp,nDecina
 local cstring:="Decina"

 ck[1]:={1,2,3,4,5,6,7,8,9,10}
 ck[2]:={11,12,13,14,15,16,17,18,19,20}
 ck[3]:={21,22,23,24,25,26,27,28,29,30}
 ck[4]:={31,32,33,34,35,36,37,38,39,40}
 ck[5]:={41,42,43,44,45,46,47,48,49,50}
 ck[6]:={51,52,53,54,55,56,57,58,59,60}
 ck[7]:={61,62,63,64,65,66,67,68,69,70}
 ck[8]:={71,72,73,74,75,76,77,78,79,80}
 ck[9]:={81,82,83,84,85,86,87,88,89,90}

   For v= 1 to 9
      nAp:= AScan( ck[v], (k) )
      IF nAp>0
         nDecina:=v
      Endif
   next
   return nDecina

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


 


Image

This test run only when it found all same numbers on all columns

Problem When I click on another number the procedure erase the oldest selection,


I wish have many numbers with different colors ( as my table color) and not erase the oldest selection as this

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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Search for a number on xbrowse and highlight it

Postby Silvio.Falconi » Wed Oct 12, 2022 8:56 am

Now run ok only when I click on a number and there is a number ( colorized) on the same column it erase it

on Default lNumber is true

if I press "N" I wish select only one number
If I press "N+" I wish select all number = number selected
If I press "X" the procedure go to initial state

Image

Code: Select all  Expand view

#include "fivewin.ch"
#include "constant.ch"

#define START_OF_NUMBERS  2

#define MEM_FILE "test.ini"



FUNCTION Main()

   RddSetDefault( "DBFCDX" )

   SetHandleCount( 100 )

   SET DATE FORMAT "dd-mm-yyyy"
   SET DELETED     ON
   SET CENTURY     ON
   SET EPOCH TO    year( date() ) - 20
   SET MULTIPLE    OFF


      test()

      RETURN nil
//---------------------------------------------------//
      /*
Colors


*/



Function test()
local aData:= { ;
                { "17.08.2019",76,83,39,10,61,90,32,55,33,67},;
                { "20.08.2019",44, 4,25,29,66,74,36,55,73,30},;
                { "22.08.2019",89,54,42,12,10,35,24,46,35,47},;
                { "24.08.2019",30,64,38,60,55,44,49,66,11,16},;
                { "27.08.2019",68,11,16,72,80,15, 1,62,76,83},;
                { "29.08.2019",31,35,47,80, 2,72,12, 4,39,10},;
                { "31.08.2019",69,11,28,51,53,36,66,77,25,29},;
                { "03.09.2019",73,30,15,59,62,36, 6,24, 4,25}}

local oDlg,oBar
local oNumber,oPlus,oCancel
local lNumber:= .t.

 DEFINE DIALOG oDlg SIZE 800,400 PIXEL TRUEPIXEL RESIZABLE

    DEFINE BUTTONBAR oBar OF oDlg 2015



    //double click to evidence a number
    DEFINE BUTTON onumber Prompt "N"     OF oBar    ;
      TOOLTIP "number"  ACTION lNumber:=.t.

    //double click to evidence all number same the number select
    DEFINE BUTTON oPlus Prompt "N+"     OF oBar    ;
      TOOLTIP "number"  ACTION lNumber:=.f.

    //clear the number evidence
    DEFINE BUTTON oCancel Prompt "X"     OF oBar    ;
      TOOLTIP "number"  ACTION Clear(oBrw)

  @ 30,05 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      COLUMNS {1,2,3,4,5,6,7,8,9,10,11} ;
      HEADERS {"Date","1","2","3","4","5","1","2","3","4","5"} ;
      ARRAY aData LINES CELL fastedit  ;
      on dblclick  Evidence(lNumber,oBrw)

    WITH OBJECT oBrw


      :nMarqueeStyle   := 2

      FOR i := 2 TO LEN(:aCols)
         oCol := :aCols[ i ]
         oCol:nWidth   := 17
      NEXT


     :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

   return nil

Function Clear(oBrw)
            FOR i := 1 TO len(oBrw:aCols)
             oCol := oBrw:aCols[ i ]
             oCol:nColDividerStyle    := LINESTYLE_BLACK
             oCol:bClrStd := {|| { CLR_BLACK,CLR_WHITE } }
          NEXT
   oBrw:refresh()
   Return nil

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


Function Evidence(lNumber,oBrw)
   local nrow:=  oBrw:nArrayAt
   local nColNo := oBrw:SelectedCol():nCreationOrder
   local nNumber:=  oBrw:aArrayData[ nrow ][ nColNo ]
   local nDecina:=  CalC_Decina(nNumber)
   local nBack,nGradient,nText
   local i

   Do case
   Case nDecina=1
      nBack    :="#A9A9A9"
      nGradient:="#696969"
      nText    :="#FFFFFF"
   Case nDecina=2
      nBack    :="#FF0000"
      nGradient:="#D93737"
      nText    :="#FFFFFF"
   Case nDecina=3
      nBack    :="#FF4848"
      nGradient:="#D93737"
      nText    :="#FFFFFF"
   Case nDecina=4
      nBack    :="#FF6F6F"
      nGradient:="#FB5200"
      nText    :="#FFFFFF"
   Case nDecina=5
      nBack    :="#32CD32"
      nGradient:="#008000"
      nText    :="#FFFFFF"
   Case nDecina=6
      nBack    :="#66B9CE"
      nGradient:="#548DD4"
      nText    :="#FFFFFF"
   Case nDecina=7
      nBack    :="#548DD4"
      nGradient:="#31859B"
      nText    :="#FFFFFF"
   Case nDecina=8
      nBack    :="#31859B"
      nGradient:="#366092"
      nText    :="#FFFFFF"
   Case nDecina=9
      nBack    :="#FF00FF"
      nGradient:="#BA55D3"
      nText    :="#FFFFFF"
   endcase

          nGradient :=  nRGB( nGradient )
            nBack  :=  nRGB( nBack )
           nText   :=  nRGB(nText )


   IF lNumber
       //one number
               * for i= 2 to Len( oBrw:aCols)
                * ShowOneNumber(i,nNumber,oBrw,nBack )
             ShowAllNumbers(nColNo,nNumber,oBrw,nBack )
             *NEXT
       else
      //all same  numbers
       for i= 2 to Len( oBrw:aCols)
                 ShowAllNumbers(i,nNumber,oBrw,nBack )
               NEXT
  Endif
  oBrw:refresh()


  return nil
//----------------------------------------------------------//
Function ShowAllNumbers(i,nNumber,oBrw,nBack )
 local  oCol := oBrw:aCols[ i ]
 oCol:bClrStd := {|| IF(oCol:value =nNumber, {CLR_BLACK,nBack },{CLR_BLACK,CLR_WHITE })}
 RETURN nil
//----------------------------------------------------------//

 Function Calc_Decina(k)
 local ck:= array(9)
 local nAp,nDecina
 local cstring:="Decina"

 ck[1]:={1,2,3,4,5,6,7,8,9,10}
 ck[2]:={11,12,13,14,15,16,17,18,19,20}
 ck[3]:={21,22,23,24,25,26,27,28,29,30}
 ck[4]:={31,32,33,34,35,36,37,38,39,40}
 ck[5]:={41,42,43,44,45,46,47,48,49,50}
 ck[6]:={51,52,53,54,55,56,57,58,59,60}
 ck[7]:={61,62,63,64,65,66,67,68,69,70}
 ck[8]:={71,72,73,74,75,76,77,78,79,80}
 ck[9]:={81,82,83,84,85,86,87,88,89,90}

   For v= 1 to 9
      nAp:= AScan( ck[v], (k) )
      IF nAp>0
         nDecina:=v
      Endif
   next
   return nDecina

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


How I can correct it ?
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Search for a number on xbrowse and highlight it

Postby karinha » Wed Oct 12, 2022 3:22 pm

Dear Silvio, aqui funciona mui bien. Excellent job. Congratulations.

Code: Select all  Expand view

// C:\FWH..\SAMPLES\DECINA.PRG By Silvio Falconi.
// MODIFIED by Joao Santos - 12/10/2022 - kapiabafwh@gmail.com

#Include "FiveWin.ch"
#Include "Constant.ch"

#Define START_OF_NUMBERS  2
#Define MEM_FILE "test.ini"

ANNOUNCE RDDSYS
REQUEST OrdKeyNo, OrdKeyCount, OrdCreate, OrdKeyGoto
REQUEST DBFCDX, DBFFPT

STATIC oFont

FUNCTION Main()

   RddSetDefault( "DBFCDX" )

   SET CENTURY ON
   SET DATE BRITISH
   SET TIME FORMAT TO "HH:MM:SS"
   SET EPOCH TO YEAR( DATE() ) - 30
   SET SOFTSEEK OFF
   SET WRAP ON
   SETCANCEL( .F. )
   SET CONFIRM OFF
   SET DELETED ON
   SET _3DLOOK ON
   SET UNIQUE OFF
   SET ESCAPE OFF
   SET EXACT ON
   SET EXCLUSIVE OFF
   SET MULTIPLE OFF

   SetBalloon( .T. )

   SkinButtons()

   Test()

RETURN NIL

/* Colors */
FUNCTION Test()

   LOCAL aData := { ;
      { "17.08.2019", 76, 83, 39, 10, 61, 90, 32, 55, 33, 67 }, ;
      { "20.08.2019", 44, 4, 25, 29, 66, 74, 36, 55, 73, 30 },  ;
      { "22.08.2019", 89, 54, 42, 12, 10, 35, 24, 46, 35, 47 }, ;
      { "24.08.2019", 30, 64, 38, 60, 55, 44, 49, 66, 11, 16 }, ;
      { "27.08.2019", 68, 11, 16, 72, 80, 15, 1, 62, 76, 83 },  ;
      { "29.08.2019", 31, 35, 47, 80, 2, 72, 12, 4, 39, 10 },   ;
      { "31.08.2019", 69, 11, 28, 51, 53, 36, 66, 77, 25, 29 }, ;
      { "03.09.2019", 73, 30, 15, 59, 62, 36, 6, 24, 4, 25 } }

   LOCAL oDlg, oBar, oBrw, I, oCol, oExit, oBrush
   LOCAL oNumber, oPlus, oCancel
   LOCAL lNumber := .T.

   DEFINE BRUSH oBrush COLOR nRGB( 250, 213, 174 )
   DEFINE FONT oFont NAME "Calibri" SIZE 0, -16 BOLD

   DEFINE DIALOG oDlg SIZE 800, 400 PIXEL TRUEPIXEL RESIZABLE FONT oFont     ;
      BRUSH oBrush TRANSPARENT

   oDlg:LHelpIcon := .F.

   DEFINE BUTTONBAR oBar OF oDlg 2007 //2015

   //double click to evidence a number
   DEFINE BUTTON oNumber PROMPT "N" OF oBar ;
      TOOLTIP "Only 1 number" ACTION( lNumber := .T. )

   //double click to evidence all number same the number select
   DEFINE BUTTON oPlus PROMPT "N+" OF oBar ;
      TOOLTIP "Several number" ACTION( lNumber := .F. )

   //clear the number evidence
   DEFINE BUTTON oCancel PROMPT "X" OF oBar ;
      TOOLTIP "Clear Number"                ;
      ACTION( Clear( oBrw ), oBrw:SetFocus(), oBrw:Refresh() )

   DEFINE BUTTON oExit PROMPT "&Exit" OF oBar ;
      TOOLTIP "Exit" ACTION( oDlg:End() )

   @ 30, 05 XBROWSE oBrw SIZE - 10, - 10 PIXEL OF oDlg                     ;
      COLUMNS { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }                        ;
      HEADERS { "Date", "1", "2", "3", "4", "5", "1", "2", "3", "4", "5" } ;
      ARRAY aData LINES CELL fastedit                                      ;
      ON DBLCLICK ( Evidence( lNumber, oBrw ), oBrw:SetFocus(), oBrw:Refresh() )

   oBrw:cTooltip := { "Click number", "Click number", 1, CLR_WHITE, CLR_CYAN }

   BrwColors( oBrw )  // Colores en el xBrowse()

   WITH OBJECT oBrw

      :nMarqueeStyle := 2

      FOR i := 2 TO LEN( :aCols )

         oCol := :aCols[ i ]
         oCol:nWidth := 30

      NEXT

      :CreateFromCode()

   END

   ACTIVATE DIALOG oDlg CENTERED

   oBrush:End()
   oFont:End()

   CLEAR MEMORY

RETURN NIL

FUNCTION CLEAR( oBrw )

   LOCAL I, oCol

   FOR i := 1 TO len( oBrw:aCols )

      oCol := oBrw:aCols[ i ]
      oCol:nColDividerStyle := LINESTYLE_BLACK
      oCol:bClrStd := {|| { CLR_BLACK, CLR_WHITE } }

   NEXT

   oBrw:GoBottom()
   oBrw:Refresh()
   oBrw:GoTop()

RETURN NIL

FUNCTION Evidence( lNumber, oBrw )

   LOCAL nrow    :=  oBrw:nArrayAt
   LOCAL nColNo  := oBrw:SelectedCol():nCreationOrder
   LOCAL nNumber :=  oBrw:aArrayData[ nrow ][ nColNo ]
   LOCAL nDecina :=  CalC_Decina( nNumber )
   LOCAL nBack, nGradient, nText
   LOCAL i

   DO CASE
   CASE nDecina = 1
      nBack     := "#A9A9A9"
      nGradient := "#696969"
      nText     := "#FFFFFF"
   CASE nDecina = 2
      nBack     := "#FF0000"
      nGradient := "#D93737"
      nText     := "#FFFFFF"
   CASE nDecina = 3
      nBack     := "#FF4848"
      nGradient := "#D93737"
      nText     := "#FFFFFF"
   CASE nDecina = 4
      nBack     := "#FF6F6F"
      nGradient := "#FB5200"
      nText     := "#FFFFFF"
   CASE nDecina = 5
      nBack     := "#32CD32"
      nGradient := "#008000"
      nText     := "#FFFFFF"
   CASE nDecina = 6
      nBack     := "#66B9CE"
      nGradient := "#548DD4"
      nText     := "#FFFFFF"
   CASE nDecina = 7
      nBack     := "#548DD4"
      nGradient := "#31859B"
      nText     := "#FFFFFF"
   CASE nDecina = 8
      nBack     := "#31859B"
      nGradient := "#366092"
      nText     := "#FFFFFF"
   CASE nDecina = 9
      nBack     := "#FF00FF"
      nGradient := "#BA55D3"
      nText     := "#FFFFFF"
   ENDCASE

   nGradient :=  nRGB( nGradient )

   nBack     :=  nRGB( nBack )
   nText     :=  nRGB( nText )

   IF lNumber

      // one number
      // for i= 2 to Len( oBrw:aCols)
      // ShowOneNumber(i,nNumber,oBrw,nBack )
      ShowAllNumbers( nColNo, nNumber, oBrw, nBack )

   ELSE

      //all same  numbers
      FOR i = 2 TO Len( oBrw:aCols )

         ShowAllNumbers( i, nNumber, oBrw, nBack )

      NEXT

   ENDIF

   oBrw:GoBottom()
   oBrw:Refresh()
   oBrw:GoTop()

RETURN NIL

FUNCTION ShowAllNumbers( i, nNumber, oBrw, nBack )

   LOCAL oCol := oBrw:aCols[ i ]

   oCol:bClrStd := {|| IF( oCol:value = nNumber, { CLR_BLACK, nBack }, { CLR_BLACK, CLR_WHITE } ) }

RETURN NIL

FUNCTION Calc_Decina( k )

   LOCAL ck := array( 9 )
   LOCAL nAp, nDecina, V
   LOCAL cstring := "Decina"

   ck[1] := { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
   ck[2] := { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }
   ck[3] := { 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 }
   ck[4] := { 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 }
   ck[5] := { 41, 42, 43, 44, 45, 46, 47, 48, 49, 50 }
   ck[6] := { 51, 52, 53, 54, 55, 56, 57, 58, 59, 60 }
   ck[7] := { 61, 62, 63, 64, 65, 66, 67, 68, 69, 70 }
   ck[8] := { 71, 72, 73, 74, 75, 76, 77, 78, 79, 80 }
   ck[9] := { 81, 82, 83, 84, 85, 86, 87, 88, 89, 90 }

   FOR v = 1 TO 9

      nAp := AScan( ck[v], ( k ) )

      IF nAp > 0
         nDecina := v
      ENDIF

   NEXT

RETURN( nDecina )

STATIC FUNCTION BrwColors( oBrw, lFoot )

   LOCAL cClrBack

   DEFAULT lFoot          := .F.

   oBrw:l2007             := .F.
   oBrw:nRowHeight        := 30  // 24
   oBrw:nHeaderHeight     := 30  // 24
   oBrw:lFooter           := lFoot
   
   // oBrw:lRecordSelector     := .F.
   // oBrw:lColDividerComplete := .F.
   // oBrw:lRowDividerComplete := .F.
   
   oBrw:lFlatStyle        := .T.
   // oBrw:bClrHeader        := { || { CLR_BLACK, CLR_WHITE, CLR_WHITE } } //RGB( 232, 255, 232 ), RGB( 232, 255, 232 ) }}
   oBrw:bClrHeader        := { || { CLR_GREEN, CLR_WHITE, CLR_WHITE } }
   oBrw:lFullGrid         := .F.
   oBrw:nRowDividerStyle  := LINESTYLE_NOLINES //DARKGRAY  //LINESTYLE_LIGHTGRAY
   oBrw:nColDividerStyle  := LINESTYLE_NOLINES //LIGHTGRAY // LINESTYLE_NOLINES

   oBrw:bClrStd = { || If( oBrw:KeyNo() % 2 == 0,  ;
                     { If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_HBLUE ),;
                           RGB( 198, 255, 198 ) }, ;
                     { If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_HBLUE ),;
                           RGB( 232, 255, 232 ) } ) }

   cClrBack = Eval( oBrw:bClrSelFocus )[ 2 ]

   oBrw:SetColor( CLR_BLUE, RGB( 232, 255, 232 ) )

   oBrw:SetFont( oFont )
   oBrw:lContrastClr := .F.

RETURN NIL

// FIN / END
 


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

Re: Search for a number on xbrowse and highlight it

Postby Silvio.Falconi » Wed Oct 12, 2022 3:37 pm

no it's not correct.
I explain to you.

at the beginning lnumber is true (.t.)

so the button "N" is activated.

in xbrowse when the user clicks a number the procedure has to fill the background with the corresponding color and the procedure works fine.

For example, if there are numbers selected and the user clicks a number that is in the column where there is already a colored number, it fills the background of the number but deletes the number that was already selected.

It shouldn't be doing it wrong.

the same thing happens when the "N +" button is selected, the procedure looks for the same numbers and colors them but removes the color from the other numbers already selected previously.
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Search for a number on xbrowse and highlight it

Postby nageswaragunupudi » Wed Oct 12, 2022 7:27 pm

Image

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

REQUEST DBFCDX

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

function Main()

   test1()

return nil

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

INIT PROCEDURE PrgInit

   RddSetDefault( "DBFCDX" )

   SET DATE ITALIAN
   SET DELETED     ON
   SET CENTURY     ON
   SET EPOCH TO    YEAR( DATE() ) - 20
//   SET MULTIPLE    OFF

return

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

static function Test1()

   local aData:= { ;
            { "17.08.2019",76,83,39,10,61,90,32,55,33,67},;
            { "20.08.2019",44, 4,25,29,66,74,36,55,73,30},;
            { "22.08.2019",89,54,42,12,10,35,24,46,35,47},;
            { "24.08.2019",30,64,38,60,55,44,49,66,11,16},;
            { "27.08.2019",68,11,16,72,80,15, 1,62,76,83},;
            { "29.08.2019",31,35,47,80, 2,72,12, 4,39,10},;
            { "31.08.2019",69,11,28,51,53,36,66,77,25,29},;
            { "03.09.2019",73,30,15,59,62,36, 6,24, 4,25}}
   local aColors := { ;
            {0,0xa9a9a9},{0,0x0000ff},{0,0x4848ff},{0,0x6f6fff},{0,0x32cd32}, ;
            {0,0xceb966},{0,0xd48d54},{0,0x9b8531},{0,0xff00ff}}

   local oDlg,oBar,oFont,oBrw,n
   local oNumber,oPlus,oCancel
   local lNumber
   local aCell    := {}
   local aVals    := {}

   DEFINE FONT oFont NAME "VERDANA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 800,400 PIXEL TRUEPIXEL RESIZABLE FONT oFont
   DEFINE BUTTONBAR oBar OF oDlg SIZE 80,30 2015
   oBar:SetFont( oFont:Bold() )

   DEFINE BUTTON onumber Prompt "N" OF oBar    ;
      TOOLTIP "number"  ;
      ACTION ( lNumber:=.f., aVals := {}, oBar:Refresh(), oBrw:Refresh() )
   oNumber:nClrText := { || If( lNumber == .f., CLR_HRED, CLR_BLACK ) }

   DEFINE BUTTON oPlus Prompt "N+"  OF oBar    ;
      TOOLTIP "number"  ;
      ACTION ( lNumber:=.t., aCell := {}, oBar:Refresh(), oBrw:Refresh() )
   oPlus:nClrText := { || If( lNumber == .t., CLR_HRED, CLR_BLACK ) }

   DEFINE BUTTON oCancel Prompt "X"     OF oBar    ;
      TOOLTIP "number"  ;
      ACTION ( lNumber := nil, aCell := {}, aVals := {}, oBar:Refresh(), oBrw:Refresh() )

  @ 30,05 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      COLUMNS {1,2,3,4,5,6,7,8,9,10,11} ;
      HEADERS {"Date","1","2","3","4","5","1","2","3","4","5"} ;
      ARRAY aData LINES NOBORDER FASTEDIT

   WITH OBJECT oBrw
      :nMarqueeStyle   := 2

      AEval( :aCols, { |o| o:nWidth := 36 }, 2 )

      for n := 2 to Len( :aCols )
         :aCols[ n ]:bLDClickData   := < |r,c,f,oCol|
            local nRow,nCol,nVal,nAt
            if lNumber == .f.
               nRow  := oCol:oBrw:nArrayAt
               nCol  := oCol:nCreationOrder
               nAt   := AScan( aCell, nRow * 100 + nCol )
               if nAt == 0
                  AAdd( aCell, nRow * 100 + nCol )
               else
                  HB_ADel( aCell, nAt, .t. )
               endif
               oCol:oBrw:Refresh()
            elseif lNumber == .t.
               nVal  := oCol:Value
               nAt   := AScan( aVals, nVal )
               if nAt == 0
                  AAdd( aVals, nVal )
               else
                  HB_ADel( aVals, nAt, .t. )
               endif
               oCol:oBrw:Refresh()
            endif
            return nil
            >
      next

      :bClrStd := < |b,oCol|
         local nRow, nVal, n
         local nCol  := oCol:nCreationOrder
         if nCol > 1
            if lNumber == .f.
               nRow  := b:nArrayAt
               if AScan( aCell, nRow * 100 + nCol ) > 0
                  return ValToColor( oCol:Value )
               endif
            elseif lNumber == .t.
               nVal  := oCol:Value
               if AScan( aVals, nVal ) > 0
                  return ValToColor( nVal )
               endif
            endif
         endif
         return { 0, CLR_WHITE }
         >

     :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

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

static function ValToColor( nVal )
/*
   local aColors := { ;
            {0,0xa9a9a9},{0,0x0000ff},{0,0x4848ff},{0,0x6f6fff},{0,0x32cd32}, ;
            {0,0xceb966},{0,0xd48d54},{0,0x9b8531},{0,0xff00ff}}
*/


   local aColors := { ;
      {CLR_WHITE,METRO_AMBER},{CLR_WHITE,METRO_OLIVE},{CLR_WHITE,CLR_HMAGENTA},;
      {CLR_WHITE,CLR_HBLUE},{CLR_WHITE,CLR_HRED},{0,CLR_HGREEN},;
      {CLR_WHITE,CLR_RED},{CLR_WHITE,CLR_MAGENTA},{CLR_WHITE,CLR_GREEN} }

return aColors[ Max( 1, Int( ( nVal - 1 ) / 10 ) + 1 ) ]

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

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

Re: Search for a number on xbrowse and highlight it

Postby Silvio.Falconi » Thu Oct 13, 2022 7:24 am

nageswaragunupudi wrote:Image



THANKS RAO

now I make a new Method on mt Tlotto Class
called Method NagesProcedure(aCell,aVals) CLASS TLotto

where I put your source and now seems run ok
and call this method every time I go to change the structure of the array :: aArray

on noption Horizontal

Image

Annual Extractions
In this mode, the draws of the reference year are displayed. To scroll back and forth through the years, I use the buttons on the toolbar

Continuous extractions
In this mode the extractions are displayed sequentially without interruption. I set the total of the extractions through the selection box. (combobox)

on nOption Vertical

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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Search for a number on xbrowse and highlight it

Postby horacio » Thu Oct 13, 2022 3:33 pm

Hola, al compilar el ejemplo de Mr. Rao Obtengo este error

Code: Select all  Expand view

  Time from start: 0 hours 0 mins 0 secs
   Error occurred at: 13-10-2022, 12:30:32
   Error description: Error BASE/1004  No exported method: NCREATIONORDER
   Args:
     [   1] = U  

Stack Calls
===========
   Called from:  => NCREATIONORDER( 0 )
   Called from: celda_colores.prg => (b)TEST1( 108 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTCELLBACK( 13553 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTCELL( 13650 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTDATA( 13507 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT( 2350 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY( 2046 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1793 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT( 11276 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 304 )
   Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG( 448 )
   Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS( 24 )
   Called from:  => NCREATIONORDER( 0 )
   Called from: celda_colores.prg => (b)TEST1( 108 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTCELLBACK( 13553 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTCELL( 13650 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTDATA( 13507 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT( 2350 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY( 2046 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1793 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT( 11276 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 304 )
   Called from: celda_colores.prg => TEST1( 128 )
   Called from: celda_colores.prg => MAIN( 9 )
 


Uso FWH20.04, BCC7 Y Harbour. Muchas Gracias

Saludos
horacio
 
Posts: 1363
Joined: Wed Jun 21, 2006 12:39 am
Location: Capital Federal Argentina

Re: Search for a number on xbrowse and highlight it

Postby Silvio.Falconi » Thu Oct 13, 2022 6:41 pm

Strange...do you have change the structure of Array?
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Search for a number on xbrowse and highlight it

Postby nageswaragunupudi » Thu Oct 13, 2022 8:14 pm

Requires FWH version 20.08 or later.
Does not work with FWH2004
Regards

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

Re: Search for a number on xbrowse and highlight it

Postby Silvio.Falconi » Thu Oct 13, 2022 9:58 pm

Thanks Rao
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: 7061
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 63 guests