xbrowse : Order column with color

xbrowse : Order column with color

Postby demont frank » Sat Nov 01, 2008 9:01 am

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 view
#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
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Color for Index

Postby ukoenig » Sat Nov 01, 2008 6:23 pm

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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Color for Index

Postby demont frank » Sat Nov 01, 2008 7:06 pm

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
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Col-color on Index

Postby ukoenig » Sat Nov 01, 2008 7:19 pm

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

Changing COL-Color

Postby ukoenig » Sat Nov 01, 2008 11:00 pm

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 view
#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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby demont frank » Sun Nov 02, 2008 6:47 am

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 view
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
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am


Return to FiveWin for Harbour/xHarbour

Who is online

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