Setting colors in dialogue

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Setting colors in dialogue

#1 Post by Eugene Lutsenko »

How do I make an example out of 15 hdemo () returned to the calling program the brightness of colors specified in the dialogue?

A better way to have horizontal scroll bar, as in the Demo Program # 3

Code: Select all

FUNCTION XSample_15

/*
SCROLL-BARS

This example uses three scrollbars to change the RED, GREEN
and BLUE colors and display the result in a box.
*/

 LOCAL nRed := 50, nGreen := 100, nBlue := 150, GetList := {}, oColorBox

 @ 2, 44 DCSAY 'R' SAYSIZE 2
 @ 3, 43 DCSCROLLBAR DATA nRed SIZE 3,7 ;
         TYPE XBPSCROLL_VERTICAL RANGE 0,255 ;
         SCROLL { |a,x,o| nRed := a[1], ;
           o:SetData(), RGB(nRed,nGreen,nBlue,oColorBox) }

 @ 2, 48 DCSAY 'G' SAYSIZE 2
 @ 3, 47 DCSCROLLBAR DATA nGreen SIZE 3,7 ;
         TYPE XBPSCROLL_VERTICAL RANGE 0,255 ;
         SCROLL { |a,x,o| nGreen := a[1], ;
           o:SetData(), RGB(nRed,nGreen,nBlue,oColorBox) }

 @ 2, 52 DCSAY 'B' SAYSIZE 2
 @ 3, 51 DCSCROLLBAR DATA nBlue  SIZE 3,7 ;
         TYPE XBPSCROLL_VERTICAL RANGE 0,255 ;
         SCROLL { |a,x,o| nBlue := a[1], ;
           o:SetData(), RGB(nRed,nGreen,nBlue,oColorBox) }

 @ 11, 40 DCSTATIC TYPE XBPSTATIC_TYPE_RAISEDBOX SIZE 20,2 ;
         OBJECT oColorBox ;
         EVAL {|o|o:paint := {||RGB(nRed,nGreen,nBlue,oColorBox)} }

 DCREAD GUI ;
   TITLE 'Scroll-bar Demo' ;
   FIT ;
   MODAL ;
   BUTTONS DCGUI_BUTTON_EXIT ;
   EVAL {||RGB(nRed,nGreen,nBlue,oColorBox)}

 RETURN nil

 /* ---------------- */

 STATIC FUNCTION RGB( nRed, nGreen, nBlue, oColorBox )

 LOCAL aAttr := Array(GRA_AA_COUNT)  // area attributes
 LOCAL nMax, aOldAttr, aOldRGB, oPS

 oPS   := oColorBox:LockPS()
 nMax  := oPS:maxColorIndex()  // max colors

 // Set new RGB color and draw box
 aAttr[ GRA_AA_COLOR  ] := nMax
 aOldAttr := oPS:setAttrArea( aAttr )
 aOldRGB  := oPS:setColorIndex( nMax, {nRed,nGreen,nBlue} )
 GraBox( oPS, {0,0}, {200,200}, GRA_FILL )
 oPS:setAttrArea( aOldAttr )
 oPS:setColorIndex( nMax, aOldRGB )
 oColorBox:unlockPS( oPS )

 RETURN nil
 *** END OF EXAMPLE ***
[/size]

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Setting colors in dialogue

#2 Post by rdonnay »

If you want to return an RGB array do the following:

Code: Select all

RETURN { nRed, nGreen, nBlue }
If you want to return a numeric value that represents a color to be used in a dialog, do the following:

Code: Select all

RETURN GraMakeRBGColor( { nRed, nGreen, nBlue } )
The eXpress train is coming - and it has more cars.

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Setting colors in dialogue

#3 Post by Eugene Lutsenko »

Thank you, Roger! I'll try to use your advice, but as long as I can this time trouble Activities. Later, I'll write out or not

Post Reply