Setting colors in dialogue
Posted: Tue Jun 04, 2013 12:59 am
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
[/size]
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 ***