xbrowse : Order column with color

Post Reply
demont frank
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

xbrowse : Order column with color

Post by demont frank »

Hello,

Working with xbrowse , i try to give the column with order (ocol:corder is 'A' or 'D') a color to make it more visible.

Code: Select all | Expand

#include "FiveWin.ch"#include "xbrowse.ch"#define CLR_1 nRGB( 190, 215, 190 )#define CLR_2 nRGB( 230, 230, 230 )function Main()   local oDlg, oBrw , oCol   DEFINE DIALOG oDlg SIZE 300, 200   @ 0, 0 XBROWSE oBrw OF oDlg ARRAY { { "one","two","three" } , {"aOne","ztwo","bthree"}} AUTOCOLS AUTOSORT         FOR EACH oCol IN oBrw:aCols            oCol:bClrStd := {||{CLR_BLACK, iif( oBrw:nArrayAt % 2 = 0, CLR_1, CLR_2  ) + IIF(oCol:cOrder="A",2000,IIF(oCol:cOrder="D",-1000,0))}}         NEXT   //oBrw:Swapcols(1,2,.T.)   oBrw:CreateFromCode()   oBrw:bKeyDown = { || oDlg:SetText( Str( oBrw:nColSel ) ) }   ACTIVATE DIALOG oDlg CENTER ON INIT ( oDlg:oClient := oBrw, oDlg:Resize() )return nil


This works , BUT the code is wrong when tho columns are swapped or when a column is moved (clicking and dragging in the header)

What is wrong ? maybe something in the code from fivewin ?

Frank
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Color for Index

Post by ukoenig »

Hello Frank,

To show the active indexed Column,
I only changed the Header-color ( also you can show a symbol ),
because inside the data, there can be a cell-color change.
With this solution, you can change the col-position without problems.
If you need a sample, i can make a copy of the application-xbrowse-part
belongs to the color-change.

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
demont frank
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Re: Color for Index

Post by demont frank »

ukoenig wrote:Hello Frank,

To show the active indexed Column,
I only changed the Header-color ( also you can show a symbol ),
because inside the data, there can be a cell-color change.
With this solution, you can change the col-position without problems.
If you need a sample, i can make a copy of the application-xbrowse-part
belongs to the color-change.

Regards
Uwe :lol:


Uwe

My main concern is : why does this code doesn't work , wrong code or wrong code from fivewin ?

Maybe you could test to confirm the problem ?

Frank
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Col-color on Index

Post by ukoenig »

Hello Frank,

I got your source and will check it with a sample of mine.

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Changing COL-Color

Post by ukoenig »

Hello Frank,

the promised source.
Because it is possible to change the Col-position,
you have to find the new position with < oBrw:nAt >
for the col-painting and action.
How it works :
You can click on the Data and the Col changes the color.
Inside the function : PAINT_COL(oBrw, nPos),
You can define any action ( Changing Index ... ) belongs to the column-title.
In this sample i moved col 3 to position 2 and changed the color.
I hope it helps.

Image

Code: Select all | Expand

#include "FiveWin.ch" #include "xbrowse.ch" #define WID  300 #define HGT  150 REQUEST DBFCDX function Main() local oDlg, oBrw , oCol, nFor DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-18 DEFINE DIALOG oDlg SIZE 2*WID,2*HGT PIXEL  FONT oFont aValues := { { "one","two","three" } , {"aOne","ztwo","bthree"} } oBrw := TXBrowse():new( oDlg ) WITH OBJECT oBrw       :nTop      := INT(HGT/2)+5       :nLeft     := 10       :nBottom   := HGT-10       :nRight    := WID-10       :SetArray( aValues, .f. ) END FOR nFor := 1 to LEN( oBrw:aCols )        // set the basic-color    // -------------------------    oBrw:aCols[nFor]:bClrStd := { || { 0, 16054371 } }     oBrw:aCols[ nFor ]:blDClickData  := ;    {|r,c,f,o| ( Msginfo( o:cHeader ), PAINT_COL(oBrw,oBrw:nAt)) } NEXT oBrw:CreateFromCode() ACTIVATE DIALOG oDlg CENTER ON INIT ( oDlg:oClient := oBrw, oDlg:Resize() ) RETURN NIL // ------------------------ FUNCTION PAINT_COL(oBrw, nCol) LOCAL nFor FOR nFor := 1 to LEN( oBrw:aCols )    // refresh the basic-color    // --------------------------    oBrw:aCols[nFor]:bClrStd := { || { 0, 16054371 } }    // paint new Col-color    // ----------------------    IF nCol = 1      oBrw:aCols[1]:bClrStd := { || { 16054371,128 } }       // Your action    ENDIF    IF nCol = 2       oBrw:aCols[2]:bClrStd := { || { 16054371,128 } }      // Your action    ENDIF    IF nCol = 3       oBrw:aCols[3]:bClrStd := { || { 16054371,128 } }      // Your action    ENDIF NEXT RETURN NIL  


Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
demont frank
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Post by demont frank »

Uwe ,

Ok , it is an intresting example how to change a column color on clicking on the data. It works also when columns are moved.

But mine goal is to give in a array (AUTOSORT , incrimental search) the order column (oCol:cOrder = 'A' or 'D') a color , trying to use :

Code: Select all | Expand

FOR EACH oCol IN oBrw:aCols  oCol:bClrStd := {||{CLR_BLACK, iif( oBrw:nArrayAt % 2 = 0, CLR_1, CLR_2  ) + :  IIF(oCol:cOrder="A",2000,IIF(oCol:cOrder="D",-1000,0))}}NEXT


I don't understand why this code doesn't work when two columns are swapped (uncomment line oBrw:Swapcols(1,2,.T.) ) or moved (clicking and draging in the header).

You will see that a wrong column has the color for ordered column.
I will try to test using a function like your paint_Col()

Frank
Post Reply