1. RE: buttons...

Or, if possible:

copy the way that MS Word and wordpad handle colours..
|------------|--|
| |\         |  |
|  \\        |  |
| __\\_____  |  |
||   |_|   | |__|
||---------| |\/|
|------------|--|
(marvel at my ascii skills)

A button that looks like this, (that odd-shaped thing in the middle is a brush,
btw), where the rectangle in the main window is a certain colour, and you can
click on the down arrow to choose a different color. On choosing it, a new colour
is selected, and that is reflected in the colour of the rectangle.

-----Original Message-----
From: Barnes Patrick 
Sent: Wednesday, 11 December 2002 12:12
To: EUforum
Subject: buttons...



How do I make a button's background a different color?
=======================
Patrick Barnes
Information Systems Group
201 Elizabeth St, Sydney
Patrick.Barnes at tg.nsw.gov.au
Ext: 91-3583
Ph:(02) 9284-3583
Mob: 0410 751 044


***********************************************************************




***********************************************************************





***********************************************************************




***********************************************************************

new topic     » topic index » view message » categorize

2. RE: buttons...

I managed this:
------------------------------------------------------------------
include win32lib.ew

constant win = create(Window, "Test", 0, Default, Default, 100, 100, 0),
		 color_button = create(PictureButton, "", win, 30, 10, 24, 24,0),
		 more_button = create(PictureButton, "", win, 53, 10, 8, 24,0)


function bgr( atom col)
return rgb( and_bits(col, #0000FF),	and_bits(col, #00FF00) / 256, and_bits(col,
#FF0000) / (256*256) )
end function

sequence fontxpm fontxpm ={"24 24 4 1",
"2   c #C0C0C0",
"3   c #000080",
"4   c #808080",
"5   c #000000",
"222222222222222222222222",
"222222222222222222222222",
"222222222222222222222222",
"222222222222222222222222",
"222222222223222222222222",
"222222222243422222222222",
"222222222233322222222222",
"222222222433342222222222",
"222222222332332222222222",
"222222224322334222222222",
"222222223333333222222222",
"222222243222233422222222",
"222222233222243322222222",
"222222432222243342222222",
"222223333222333333222222",
"222222222222222222222222",
"222225555555555555555222",
"222225555555555555555222",
"222225555555555555555222",
"222225555555555555555222",
"222222222222222222222222",
"222222222222222222222222",
"222222222222222222222222",
"222222222222222222222222"} 	

global constant downxpm ={"7 20 2 1",
"2   c #C0C0C0",
"3   c #000000",
"2222222","2222222","2222222",
"2222222","2222222","2222222",
"2222222","2222222","2222222",
"2333332","2233322","2223222",
"2222222","2222222","2222222",
"2222222","2222222","2222222",
"2222222","2222222"}


atom nowcolor nowcolor = #000000
procedure getColor(integer ID, integer Event, object params)
	nowcolor = bgr( getColorDialog(win, nowcolor) )
	fontxpm[5][8..13] = sprintf( "%06x", nowcolor)
	setBitmap(color_button,createDIB(xpmToEuBmp(fontxpm)))
end procedure

procedure setColor(integer ID, integer Event, object params)
	setWindowBackColor(win, nowcolor)
end procedure

setBitmap(color_button,createDIB(xpmToEuBmp(fontxpm)))
setBitmap(more_button,createDIB(xpmToEuBmp(downxpm)))
setHandler(more_button, w32HClick, routine_id("getColor"))
setHandler(color_button, w32HClick, routine_id("setColor"))


WinMain(win, Normal)
------------------------------------------------------------------




















-----Original Message-----
From: Pete Lomax [mailto:petelomax at blueyonder.co.uk]
Sent: Wednesday, 11 December 2002 21:12
To: EUforum
Subject: Re: buttons...



On Wed, 11 Dec 2002 12:34:46 +1100, Patrick.Barnes at transgrid.com.au
wrote:

>copy the way that MS Word and wordpad handle colours..
...
>How do I make a button's background a different color?

Use an xpm with a solid background, eg
sequence test test = {
"24 24 13 1",
" 	c None",
"B	c #808080",	-- the background
".	c #000000",
"+	c #E4E4DC",
"@	c #BE7579",
"#	c #C67D81",
"$	c #2D2D2D",
"%	c #8A4D4F",
"&	c #9E575B",
"*	c #A75E5F",
"=	c #AF6668",
"-	c #B66D71",
";	c #CD8689",
">	c #080808",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBB.........BBBBB",
"BBBBBBBBBB.++++++..BBBBB",
"BBBBBBBBBB.++++++..BBBBB",
"BBBBBBBB...++++++..BBBBB",
"BBBBBBBB. at .++++++..BBBBB",
"BBB...... at #.++$.+..BBBBB",
"BBB.%&*=- at #;.+.$+..BBBBB",
"BBB.%&*=- at #;.++++..BBBBB",
"BBB...... at #.+++++..BBBBB",
"BBBBBBBB. at .++++++..BBBBB",
"BBBBBBBB...++++++..BBBBB",
"BBBBBBBBBB.++++....BBBBB",
"BBBBBBBBBB.++......BBBBB",
"BBBBBBBBBB...>>>>>>BBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB"}

change the background colour, eg
test[3][7..12]="FF0000"	-- Red

and stick it on the button

setBitmap(Button,createDIB(xpmToEuBmp(test)))

I would imagine that the drop-down is just a very narrow button next
to the normal sized button.

There is a simple palette I inherited in the editor, see options.ew

Apparently someone is going to post about 2,500 xpm files real soon
now.

Pete

==^^===============================================================
This email was sent to: Patrick.Barnes at transgrid.com.au




***********************************************************************




***********************************************************************

new topic     » goto parent     » topic index » view message » categorize

3. RE: buttons...

Are there other color dialogs available?

'Cause there is a dialog in word that acts like a pop-up window.

-----Original Message-----
From: Barnes Patrick 
Subject: RE: buttons...



I managed this:
------------------------------------------------------------------
include win32lib.ew

constant win = create(Window, "Test", 0, Default, Default, 100, 100, 0),
		 color_button = create(PictureButton, "", win, 30, 10, 24, 24,0),
		 more_button = create(PictureButton, "", win, 53, 10, 8, 24,0)


function bgr( atom col)
return rgb( and_bits(col, #0000FF),	and_bits(col, #00FF00) / 256, and_bits(col,
#FF0000) / (256*256) )
end function

sequence fontxpm fontxpm ={"24 24 4 1",
"2   c #C0C0C0",
"3   c #000080",
"4   c #808080",
"5   c #000000",
"222222222222222222222222",
"222222222222222222222222",
"222222222222222222222222",
"222222222222222222222222",
"222222222223222222222222",
"222222222243422222222222",
"222222222233322222222222",
"222222222433342222222222",
"222222222332332222222222",
"222222224322334222222222",
"222222223333333222222222",
"222222243222233422222222",
"222222233222243322222222",
"222222432222243342222222",
"222223333222333333222222",
"222222222222222222222222",
"222225555555555555555222",
"222225555555555555555222",
"222225555555555555555222",
"222225555555555555555222",
"222222222222222222222222",
"222222222222222222222222",
"222222222222222222222222",
"222222222222222222222222"} 	

global constant downxpm ={"7 20 2 1",
"2   c #C0C0C0",
"3   c #000000",
"2222222","2222222","2222222",
"2222222","2222222","2222222",
"2222222","2222222","2222222",
"2333332","2233322","2223222",
"2222222","2222222","2222222",
"2222222","2222222","2222222",
"2222222","2222222"}


atom nowcolor nowcolor = #000000
procedure getColor(integer ID, integer Event, object params)
	nowcolor = bgr( getColorDialog(win, nowcolor) )
	fontxpm[5][8..13] = sprintf( "%06x", nowcolor)
	setBitmap(color_button,createDIB(xpmToEuBmp(fontxpm)))
end procedure

procedure setColor(integer ID, integer Event, object params)
	setWindowBackColor(win, nowcolor)
end procedure

setBitmap(color_button,createDIB(xpmToEuBmp(fontxpm)))
setBitmap(more_button,createDIB(xpmToEuBmp(downxpm)))
setHandler(more_button, w32HClick, routine_id("getColor"))
setHandler(color_button, w32HClick, routine_id("setColor"))


WinMain(win, Normal)
------------------------------------------------------------------




















-----Original Message-----
From: Pete Lomax [mailto:petelomax at blueyonder.co.uk]
Sent: Wednesday, 11 December 2002 21:12
To: EUforum
Subject: Re: buttons...



On Wed, 11 Dec 2002 12:34:46 +1100, Patrick.Barnes at transgrid.com.au
wrote:

>copy the way that MS Word and wordpad handle colours..
...
>How do I make a button's background a different color?

Use an xpm with a solid background, eg
sequence test test = {
"24 24 13 1",
" 	c None",
"B	c #808080",	-- the background
".	c #000000",
"+	c #E4E4DC",
"@	c #BE7579",
"#	c #C67D81",
"$	c #2D2D2D",
"%	c #8A4D4F",
"&	c #9E575B",
"*	c #A75E5F",
"=	c #AF6668",
"-	c #B66D71",
";	c #CD8689",
">	c #080808",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBB.........BBBBB",
"BBBBBBBBBB.++++++..BBBBB",
"BBBBBBBBBB.++++++..BBBBB",
"BBBBBBBB...++++++..BBBBB",
"BBBBBBBB. at .++++++..BBBBB",
"BBB...... at #.++$.+..BBBBB",
"BBB.%&*=- at #;.+.$+..BBBBB",
"BBB.%&*=- at #;.++++..BBBBB",
"BBB...... at #.+++++..BBBBB",
"BBBBBBBB. at .++++++..BBBBB",
"BBBBBBBB...++++++..BBBBB",
"BBBBBBBBBB.++++....BBBBB",
"BBBBBBBBBB.++......BBBBB",
"BBBBBBBBBB...>>>>>>BBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB",
"BBBBBBBBBBBBBBBBBBBBBBBB"}

change the background colour, eg
test[3][7..12]="FF0000"	-- Red

and stick it on the button

setBitmap(Button,createDIB(xpmToEuBmp(test)))

I would imagine that the drop-down is just a very narrow button next
to the normal sized button.

There is a simple palette I inherited in the editor, see options.ew

Apparently someone is going to post about 2,500 xpm files real soon
now.

Pete

==^^===============================================================
This email was sent to: Patrick.Barnes at transgrid.com.au




***********************************************************************




***********************************************************************





***********************************************************************




***********************************************************************

new topic     » goto parent     » topic index » view message » categorize

4. RE: buttons...

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C2A19B.ADABB770

Does this code work?


It's in an attachment because I think the last one got mangled by the email
system.

-----Original Message-----
From: Dan Moyer [mailto:DANIELMOYER at prodigy.net]
Subject: Re: buttons...



Fails for me on click the down button & either select or cancel color
selection,

Test\buttons\butt1.exw:57 in procedure getColor()
slice ends past end of sequence (13 > 11)

Dan Moyer

----- Original Message -----
From: <Patrick.Barnes at transgrid.com.au>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, December 11, 2002 5:44 PM
Subject: RE: buttons...


>
> I managed this:
> ------------------------------------------------------------------
> include win32lib.ew
>
> constant win = create(Window, "Test", 0, Default, Default, 100, 100, 0),
> color_button = create(PictureButton, "", win, 30, 10, 24, 24,0),
> more_button = create(PictureButton, "", win, 53, 10, 8, 24,0)
>
>
> function bgr( atom col)
> return rgb( and_bits(col, #0000FF), and_bits(col, #00FF00) / 256,
and_bits(col, #FF0000) / (256*256) )
> end function
>
> sequence fontxpm fontxpm ={"24 24 4 1",
> "2   c #C0C0C0",
> "3   c #000080",
> "4   c #808080",
> "5   c #000000",
> "222222222222222222222222",
> "222222222222222222222222",
> "222222222222222222222222",
> "222222222222222222222222",
> "222222222223222222222222",
> "222222222243422222222222",
> "222222222233322222222222",
> "222222222433342222222222",
> "222222222332332222222222",
> "222222224322334222222222",
> "222222223333333222222222",
> "222222243222233422222222",
> "222222233222243322222222",
> "222222432222243342222222",
> "222223333222333333222222",
> "222222222222222222222222",
> "222225555555555555555222",
> "222225555555555555555222",
> "222225555555555555555222",
> "222225555555555555555222",
> "222222222222222222222222",
> "222222222222222222222222",
> "222222222222222222222222",
> "222222222222222222222222"}
>
> global constant downxpm ={"7 20 2 1",
> "2   c #C0C0C0",
> "3   c #000000",
> "2222222","2222222","2222222",
> "2222222","2222222","2222222",
> "2222222","2222222","2222222",
> "2333332","2233322","2223222",
> "2222222","2222222","2222222",
> "2222222","2222222","2222222",
> "2222222","2222222"}
>
>
> atom nowcolor nowcolor = #000000
> procedure getColor(integer ID, integer Event, object params)
> nowcolor = bgr( getColorDialog(win, nowcolor) )
> fontxpm[5][8..13] = sprintf( "%06x", nowcolor)
> setBitmap(color_button,createDIB(xpmToEuBmp(fontxpm)))
> end procedure
>
> procedure setColor(integer ID, integer Event, object params)
> setWindowBackColor(win, nowcolor)
> end procedure
>
> setBitmap(color_button,createDIB(xpmToEuBmp(fontxpm)))
> setBitmap(more_button,createDIB(xpmToEuBmp(downxpm)))
> setHandler(more_button, w32HClick, routine_id("getColor"))
> setHandler(color_button, w32HClick, routine_id("setColor"))
>
>
> WinMain(win, Normal)
> ------------------------------------------------------------------
>
>
> -----Original Message-----
> From: Pete Lomax [mailto:petelomax at blueyonder.co.uk]
> Sent: Wednesday, 11 December 2002 21:12
> To: EUforum
> Subject: Re: buttons...
>
>
> On Wed, 11 Dec 2002 12:34:46 +1100, Patrick.Barnes at transgrid.com.au
> wrote:
>
> >copy the way that MS Word and wordpad handle colours..
> ...
> >How do I make a button's background a different color?
>
> Use an xpm with a solid background, eg
> sequence test test = {
<snip>

>
>






***********************************************************************




***********************************************************************


------_=_NextPart_000_01C2A19B.ADABB770
Content-Type: application/octet-stream;
	name="colorbtn.exw"
Content-Disposition: attachment;
	filename="colorbtn.exw"

include win32lib.ew

constant win = create(Window, "Test", 0, Default, Default, 400, 400, 0),
         color_button = create(PictureButton, "", win, 30, 10, 24, 24,0),
         cdown_button = create(PictureButton, "", win, 53, 10, 8, 24,0)


function bgr( atom col)
return rgb( and_bits(col, #FF0000) / (256*256), and_bits(col, #00FF00) /
    256, and_bits(col, #0000FF) )
end function

sequence fontxpm fontxpm ={"24 24 4 1",
"2   c #C0C0C0",
"3   c #000080",
"4   c #808080",
"5   c #000000",
"222222222222222222222222",
"222222222222222222222222",
"222222222222222222222222",
"222222222222222222222222",
"222222222223222222222222",
"222222222243422222222222",
"222222222233322222222222",
"222222222433342222222222",
"222222222332332222222222",
"222222224322334222222222",
"222222223333333222222222",
"222222243222233422222222",
"222222233222243322222222",
"222222432222243342222222",
"222223333222333333222222",
"222222222222222222222222",
"222225555555555555555222",
"222225555555555555555222",
"222225555555555555555222",
"222225555555555555555222",
"222222222222222222222222",
"222222222222222222222222",
"222222222222222222222222",
"222222222222222222222222"}     

global constant downxpm ={"7 20 2 1",
"2   c #C0C0C0",
"3   c #000000",
"2222222","2222222","2222222",
"2222222","2222222","2222222",
"2222222","2222222","2222222",
"2333332","2233322","2223222",
"2222222","2222222","2222222",
"2222222","2222222","2222222",
"2222222","2222222"}


atom nowcolor nowcolor = #000000
procedure getColor(integer ID, integer Event, object params)
    nowcolor = bgr( getColorDialog(win, bgr(nowcolor) ) )
    fontxpm[5][8..13] = sprintf( "%06x", nowcolor)

    setBitmap(color_button,createDIB(xpmToEuBmp(fontxpm)))
end procedure

procedure setColor(integer ID, integer Event, object params)
    setWindowBackColor(win, bgr(nowcolor))
end procedure

procedure setRandColor(integer ID, integer Event, object params)
    setWindowBackColor(win, rand( #FFFFFF ) )
end procedure


setBitmap(color_button,createDIB(xpmToEuBmp(fontxpm)))
setBitmap(cdown_button,createDIB(xpmToEuBmp(downxpm)))
setHandler(cdown_button, w32HClick, routine_id("getColor"))
setHandler(color_button, w32HClick, routine_id("setColor"))
setHandler(win, w32HClick, routine_id("setRandColor") )


WinMain(win, Normal)
------_=_NextPart_000_01C2A19B.ADABB770--

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu