Color palette

Color palette

Postby ctoas » Sun Jan 24, 2021 10:17 pm

Hello guys...

I am looking for a solution to create a color palette for the user to select. Has anyone done?

Image

Thanks
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil

Re: Color palette

Postby ukoenig » Mon Jan 25, 2021 12:44 pm

Christiano,

I think You want to select a color from a defined colorselection :?:
Just define a array with the colorvalues.
You can create Your own color palette (colorpicker) with xBrowse like :

This sample shows a array with the basiccolors.
Image

Code: Select all  Expand view

FUNCTION RGB_BASIC( oDlgMain )
LOCAL oBrw2, n
// array of cellcolors for colorselection
LOCAL aDat1 := { { nRGB( 255, 128, 128 ), nRGB( 255, 255, 128 ), nRGB( 128, 255, 128 ), nRGB( 0, 255, 128 ), ;
                              nRGB( 128, 255, 255 ), nRGB( 0, 128, 255 ), nRGB( 255, 128, 192 ), nRGB( 255, 128, 255 ) },;
                            { nRGB( 255, 0, 0 ), nRGB( 255, 255, 0 ), nRGB( 128, 255, 0 ), nRGB( 0, 255, 64 ), ;
                               nRGB( 0, 255, 255 ), nRGB( 0, 128, 192 ), nRGB( 128, 128, 192 ), nRGB( 255, 0, 255 ) },;                
                            { nRGB( 64, 0, 0 ), nRGB( 255, 128, 64 ), nRGB( 0, 255, 0 ), nRGB( 0, 128, 128 ), ;
                              nRGB( 0, 64, 128 ), nRGB( 128, 128, 255 ), nRGB( 128, 0, 64 ), nRGB( 255, 0, 128 ) },;         
                            { nRGB( 128, 0, 0 ), nRGB( 255, 128, 0 ), nRGB( 0, 128, 0 ), nRGB( 0, 128, 64 ), ;
                              nRGB( 0, 0, 255 ), nRGB( 0, 0, 160 ), nRGB( 128, 0, 128 ), nRGB( 128, 0, 255 ) },;         
                            { nRGB( 64, 0, 0 ), nRGB( 128, 64, 0 ), nRGB( 0, 64, 0 ), nRGB( 0, 64, 64 ), ;
                              nRGB( 0, 0, 128 ), nRGB( 0, 0, 64 ), nRGB( 64, 0, 64 ), nRGB( 64, 0, 128 ) },;         
                            { nRGB( 0, 0, 0 ), nRGB( 128, 128, 0 ), nRGB( 128, 128, 64 ), nRGB( 128, 128, 128 ), ;
                              nRGB( 64, 128, 128 ), nRGB( 192, 192, 192 ), nRGB( 64, 0, 64 ), nRGB( 255, 255, 255 ) } }

REDEFINE XBROWSE oBrw2 ID 120 OF oDlgMain ARRAY aDat1 ;
FIELDS aDat1[ oBrw2:nArrayAt ][ 1 ], aDat1[ oBrw2:nArrayAt ][ 2 ], aDat1[ oBrw2:nArrayAt ][ 3 ], ;
              aDat1[ oBrw2:nArrayAt ][ 4 ], aDat1[ oBrw2:nArrayAt ][ 5 ], aDat1[ oBrw2:nArrayAt ][ 6 ], ;
              aDat1[ oBrw2:nArrayAt ][ 7 ], aDat1[ oBrw2:nArrayAt ][ 8 ] ;
LINES COLSIZES 30, 30, 30, 30, 30, 30, 30, 30 PIXEL

WITH OBJECT oBrw2
    :lRecordSelector        := .F. // .t.
    :lColDividerComplete    := .T. // .f.
    :lAllowColSwapping      := .F.
    :lAllowColHiding        := .F.
    :lFastEdit              := .F.
    :lHeader                := .F.
    :nStretchCol            := -1
    :lRecordSelector        := .F.
    :lAllowRowSizing        := .F.
    :lHScroll               := .F.
    :lVScroll               := .F.
    :lDrawBorder            := .T.
    :nMarqueeStyle      := 1
    :nRowHeight         := 30

    :aCols[1]:bClrstd := {|| { , aDat1[ oBrw2:KeyNo() ][1] } }
    :aCols[2]:bClrstd := {|| { , aDat1[ oBrw2:KeyNo() ][2] } }
    :aCols[3]:bClrstd := {|| { , aDat1[ oBrw2:KeyNo() ][3] } }
    :aCols[4]:bClrstd := {|| { , aDat1[ oBrw2:KeyNo() ][4] } }
    :aCols[5]:bClrstd := {|| { , aDat1[ oBrw2:KeyNo() ][5] } }
    :aCols[6]:bClrstd := {|| { , aDat1[ oBrw2:KeyNo() ][6] } }
    :aCols[7]:bClrstd := {|| { , aDat1[ oBrw2:KeyNo() ][7] } }
    :aCols[8]:bClrstd := {|| { , aDat1[ oBrw2:KeyNo() ][8] } }
END

FOR n := 1 to LEN( oBrw2:aCols )
      oBrw2:aCols[ n ]:bPaintText = { | oCol, hDC, cText | "" }
      oBrw2:aCols[ n ]:lAllowSizing := .F.
NEXT

oBrw2:bLClicked := { | nRow, nCol | ( nRPos := oBrw2:KeyNo(), ;
                                                        nCPos := oBrw2:SelectedCol():nCreationOrder, ;
                            COLORVALUE( aDat1[nRPos][nCPos]) ) }
oBrw2:bChange := { | nRow, nCol | (  nRPos := oBrw2:KeyNo(), ;
                                                        nCPos := oBrw2:SelectedCol():nCreationOrder, ;
                            COLORVALUE( aDat1[nRPos][nCPos]) ) }
RETURN NIL

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

FUNCTION COLORVALUE( nColor )
LOCAL nRed := nRGBRed( nColor )
LOCAL nGreen := nRGBGreen( nColor )
LOCAL nBlue := nRGBBlue( nColor )

LOCal cWordRGB := "nRGB( " + ALLTRIM(STR(nRed)) + ", " + ;
                                     ALLTRIM(STR(nGreen)) + ", " + ;
                                     ALLTRIM(STR(nBlue)) + " )"

// save result to ???
MsgAlert( nColor, "Color NUMERIC")
MsgAlert( cWordRGB, "Color RGB")

RETURN NIL

 


best regards
Uwe :D
Last edited by ukoenig on Thu Feb 11, 2021 9:19 am, edited 3 times in total.
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 palette

Postby ctoas » Mon Jan 25, 2021 9:30 pm

Thank you, perfect!
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil

Re: Color palette (solved)

Postby ctoas » Sat Feb 06, 2021 7:30 pm

Hello guys.

Some adjustments are still missing, but it's perfect!

Image
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil

Re: Color palette

Postby nageswaragunupudi » Sun Feb 07, 2021 3:26 am

May I know why can't we use Microsoft Windows color picker? This is a standard Windows interface and all Windows users are familiar with its use and functionality.
This is available in fwh function ChooseColor( nClr ) ---> nClr
Regards

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

Re: Color palette

Postby ctoas » Sun Feb 07, 2021 4:21 pm

Hello Nages.

I didn't know this function, but I would only use it if there was no option since it is out of the standard of my screens.

Hugs
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil

Re: Color palette

Postby ukoenig » Sun Feb 07, 2021 6:49 pm

I*m building the needed array for this selection :!:

I didn't know this function, but
I would only use it if there was no option since it is out of the standard of my screens.


Image

a defined column-array looks like

Code: Select all  Expand view

Row     Column 1 ( red )

1       nRGB( 51, 0, 0 )
2       nRGB( 102, 0, 0 )
3       nRGB( 153, 0, 0 )
4       nRGB( 204, 0, 0 )
5       nRGB( 255, 0, 0 )
6       nRGB( 255, 51, 51 )
7       nRGB( 255, 102, 102 )
8       nRGB( 255, 153, 153 )
9       nRGB( 255, 204, 204 )

Row     Column 2 ( brown )

1       nRGB( 51, 25, 0 )
2       nRGB( 102, 51, 0 )
3       nRGB( 153, 76, 0 )
4       nRGB( 204, 102, 0 )
5       nRGB( 255, 128, 0 )
6       nRGB( 255, 153, 51 )
7       nRGB( 255, 178, 102 )
8       nRGB( 255, 204, 153 )
9       nRGB( 255, 229, 204 )

Row     Column 3 ( yellow )

1       nRGB( 51, 51, 0 )
2       nRGB( 102, 102, 0 )
3       nRGB( 153, 153, 0 )
4       nRGB( 204, 204, 0 )
5       nRGB( 255, 255, 0 )
6       nRGB( 255, 255, 51 )
7       nRGB( 255, 255, 102 )
8       nRGB( 255, 255, 153 )
9       nRGB( 255, 255, 204 )

 


like You can see with this function ChooseColor( nClr ) the colors are not splitted to the same brightness-level
I think that is the solution You are looking for :?:

Image

regards
Uwe :D
Last edited by ukoenig on Sun Feb 07, 2021 7:40 pm, edited 1 time in total.
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 palette

Postby nageswaragunupudi » Sun Feb 07, 2021 7:24 pm

This is Windows API ChooseColor() made available by FWH through its function ChooseColor().
One can make his own function, but can not easily match its functionality.
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 59 guests