1. wxEuphoria

Have been unable to find a way to change text color..

See comments in the code below..

Help appreciated

Buzzo

code text

-- code from several demos  
-- OS = win 7 
 include wxeud.e 
 
constant 
    HelloFrame = create( wxFrame, {0, -1, "My First Message", -1, -1, 200, 100} ), 
    HelloWin   = create( wxPanel, {HelloFrame,-1,-1,-1,-1,-1, wxWANTS_CHARS}), 
	SomeText	= create( wxStaticText, {HelloWin,0,"Some Text", 1,1,18}), 
-- from demo 'text_on_window' 
    Black           = rgb(   0,   0,   0 ), 
    Blue            = rgb(   0,   0, 128 ), 
    SkyBlue         = rgb(   0, 128, 255 ), 
    Green           = rgb(   0, 128,   0 ), 
    Cyan            = rgb(   0, 128, 128 ), 
    Red             = rgb( 128,   0,   0 ), 
    Magenta         = rgb( 128,   0, 128 ), 
    DarkBrown       = rgb(  64,  64,   0 ), 
    Brown           = rgb( 128, 128,   0 ), 
    DarkGray        = rgb(  64,  64,  64 ), 
    Gray            = rgb( 128, 128, 128 ), 
    LightGray       = rgb( 192, 192, 192 ), 
    BrightBlue      = rgb(   0,   0, 255 ), 
    BrightGreen     = rgb(   0, 255,   0 ), 
    BrightCyan      = rgb(   0, 255, 255 ), 
    BrightRed       = rgb( 255,   0,   0 ), 
    Pink            = rgb( 255, 176, 176 ), 
    BrightMagenta   = rgb( 255,   0, 255 ), 
    Purple          = rgb( 208, 128, 208 ), 
    Yellow          = rgb( 255, 255,   0 ), 
    White           = rgb( 224, 224, 224 ), 
    Parchment       = rgb( 255, 255, 224 ), 
    BrightWhite     = rgb( 255, 255, 255 ) 
-- from demo 'bench_draw'.. this exw locks up on Win7 Home 
	, RedPen      = create( wxPen, {BrightRed, 1, wxSOLID}) 
	, GreenPen    = create( wxPen, {BrightGreen, 1, wxSOLID}) 
	, BluePen     = create( wxPen, {BrightBlue, 1, wxSOLID}) 
	, RedBrush  = create( wxBrush, {BrightRed, wxSOLID}) 
	, GreenBrush  = create( wxBrush, {BrightGreen, wxSOLID}) 
	, TransBrush  = create( wxBrush, {BrightGreen, wxTRANSPARENT}) 
	, BlueBrush  = create( wxBrush, {BrightBlue, wxSOLID}) 
 
-- this works 
	set_back_color(HelloWin,Pink)  
-- this does not work 
	set_text_color(SomeText,BrightWhite)  
--	set_background_mode(SomeText,wxTRANSPARENT)-- crashes 
 
	procedure onPaint_HelloWin( atom this, atom event, atom it, atom event_type ) 
-- this works in paint event..on the StaticText only... not on wx_puts 
		set_back_color(SomeText, BrightRed )  
-- this does not work here either 
		set_text_color(SomeText,BrightWhite)  
--		set_background_mode(HelloWin,wxTRANSPARENT)	-- this crashes ? 
		wx_puts( {this,10,20}, "HelloWin, World!")	-- unable to change color 
	end procedure 
	set_event_handler( HelloWin, get_id(HelloWin), wxEVT_PAINT, routine_id( "onPaint_HelloWin" )) 
 
	function rgb( integer r, integer g, integer b) 
    	return create( wxColour, {r,g,b}) 
	end function 
 
	wxMain( HelloFrame ) 
new topic     » topic index » view message » categorize

2. Re: wxEuphoria

buzzo said...

Have been unable to find a way to change text color..

See comments in the code below..

Help appreciated

When setting the text for a window, you need to use set_fore_color(). set_text_color() is for setting the color of text when you're drawing in a DC. I've changed the code below to use set_fore_color() to set the color of the static text, and created and used a wxPaintDC in the paint handler:

-- this works 
	set_back_color(HelloWin,Pink) 
-- this does not work 
	set_fore_color(SomeText,BrightWhite) 
--	set_background_mode(SomeText,wxTRANSPARENT)-- crashes 
 
	procedure onPaint_HelloWin( atom this, atom event, atom it, atom event_type ) 
		atom dc = create( wxPaintDC, this ) 
-- this works in paint event..on the StaticText only... not on wx_puts 
		set_back_color( dc, BrightRed ) 
-- this does not work here either 
		set_text_color( dc, BrightWhite) 
--		set_background_mode(HelloWin,wxTRANSPARENT)	-- this crashes ? 
		wx_puts( {this,10,20, dc}, "HelloWin, World!")	-- unable to change color 
	end procedure 

Matt

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

3. Re: wxEuphoria

You missed a ## in there. blink

-Greg

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

4. Re: wxEuphoria

ghaberek said...

You missed a ## in there. blink

-Greg

Hmm...I didn't miss it, but it didn't pick it up. getlost

I just removed them around the link.

Matt

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

5. Re: wxEuphoria

Don't forget your begin_drawing(), end_drawing(), and delete_instance() calls!

See wxEVT_PAINT.

procedure onPaint_HelloWin( atom this, atom event, atom it, atom event_type ) 
	atom dc = create( wxPaintDC, this ) 
	begin_drawing( dc ) 
-- this works in paint event..on the StaticText only... not on wx_puts 
	set_back_color( dc, BrightRed ) 
-- this does not work here either 
	set_text_color( dc, BrightWhite) 
--	set_background_mode(HelloWin,wxTRANSPARENT)	-- this crashes ? 
	wx_puts( {this,10,20, dc}, "HelloWin, World!")	-- unable to change color 
	end_drawing( dc ) 
	delete_instance( dc ) 
end procedure 
new topic     » goto parent     » topic index » view message » categorize

6. Re: wxEuphoria

Thanks guys.... however....

	procedure onPaint_HelloWin( atom this, atom event, atom it, atom event_type ) 
-- this works in paint event..on the StaticText only... not on wx_puts 
--		set_back_color(SomeText, Parchment )  
--		set_fore_color(SomeText,BrightBlue)  
--		wx_puts( {this,10,20}, "HelloWin, World!") 
-- ************ this does not display  
-- ************ produces a rapid display (flash) of the window 
		atom dc = create (wxPaintDC,this) 
		begin_drawing(dc) 
			set_back_color(dc, BrightWhite) 
			set_text_color(dc, BrightBlue) 
			wx_puts( {this,10,20,dc}, "HelloWin, World!") 
		end_drawing(dc) 
		delete_instance(dc) 
	end procedure 
new topic     » goto parent     » topic index » view message » categorize

7. Re: wxEuphoria

Found it.. commented out set_back_color... Thanks again..

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

Search



Quick Links

User menu

Not signed in.

Misc Menu