/* colorbox - sept 97 - by Sylvain Huet color selection interface */ /* login structure : colorbox window */ struct ColorB= [chCBox:Chn,winCBox:ObjWin,rCBox:ObjText,gCBox:ObjText,bCBox:ObjText, colCBox:I,endCBox:fun[I] I] mkColorB;; typeof Font=ObjFont;; fun _calccolor(b)= set b.colCBox= let 255&atoi _GETtext b.rCBox -> r in let 255&atoi _GETtext b.gCBox -> g in let 255&atoi _GETtext b.bCBox -> b in b<<16+g<<8+r;; fun _paintE(x,b)= _calccolor b; _TXTout b.winCBox Font 45 5 TD_TOP+TD_RIGHT 0 "red :"; _TXTout b.winCBox Font 45 30 TD_TOP+TD_RIGHT 0 "green :"; _TXTout b.winCBox Font 45 55 TD_TOP+TD_RIGHT 0 "blue :"; _PAINTrectangle b.winCBox 105 5 90 70 DRAW_INVISIBLE 0 0 DRAW_SOLID b.colCBox;; fun _textE(x,b)= _paintE nil b;; fun _ok(x,b)= _DSwindow b.winCBox; exec b.endCBox with [b.colCBox] ;; fun _cancel(x,b)= _DSwindow b.winCBox; exec b.endCBox with [nil] ;; fun _destroyE(x,b)= exec b.endCBox with [nil];; fun iniColorB(ch,father,x,y,title,end,color)= set Font= if Font!=nil then Font else _CRfont ch 14 0 0 "arial"; let if color==nil then [0 0 0] else [(color>>16)&255 (color>>8)&255 color&255] ->[b g r] in let _CRwindow ch father x y 200 105 WN_MENU+WN_MINBOX title -> win in let _CReditLine ch win 50 5 50 20 ET_DOWN itoa r -> red in let _CReditLine ch win 50 30 50 20 ET_DOWN itoa g -> green in let _CReditLine ch win 50 55 50 20 ET_DOWN itoa b -> blue in let _CRbutton ch win 5 80 80 20 0 "Ok"-> ok in let _CRbutton ch win 90 80 80 20 0 "Cancel"-> cancel in let mkColorB [ch win red green blue b<<16+g<<8+r end]-> b in (_CBwinDestroy win @_destroyE b; _CBwinPaint win @_paintE b; _CBtext red @_textE b; _CBtext green @_textE b; _CBtext blue @_textE b; _AFFfontButton _CBbutton ok @_ok b Font; _AFFfontButton _CBbutton cancel @_cancel b Font; _AFFfontText red Font; _AFFfontText green Font; _AFFfontText blue Font; _paintE nil b; b) ;; fun mydest(i)=_fooI i;_closemachine;; fun main()= iniColorB _channel nil nil nil "color editor" @mydest 0x2040 ;;