I''ve painted my gui and I like the background mesh for my gui. I want my static text to inherit the background paint of my gui. Instead I get a gray background around the static text. Here''s a picture: http://i780.photobucket.com/albums/yy89/jdezenzio/example_background.jpg How do I make it so that the background of the StaticText is transparent? Thanks. -- Posted via http://www.ruby-forum.com/.
On 23/01/2010 16:25, Alpha Blue wrote:> I''ve painted my gui and I like the background mesh for my gui. I want > my static text to inherit the background paint of my gui. Instead I get > a gray background around the static text. Here''s a picture: > > http://i780.photobucket.com/albums/yy89/jdezenzio/example_background.jpg > > How do I make it so that the background of the StaticText is > transparent? >Hard to test without the code, but have you tried setting the DC''s brush to TRANSPARENT? eg dc.brush = Wx::TRANSPARENT_BRUSH Also, take a look into evt_erase_background which is specifically designed for drawing bitmaps as a background on controls. hth alex
Joel Dezenzio
2010-Jan-23 21:17 UTC
[wxruby-users] Transparency on WxStaticText background?
Hi Alex, Basically, the control was created inside of DialogBlocks and extended into a module. The code appears like so: @title_st_one = finder.call("title_st_one") @title_st_one.extend(StaticTextControls) I then have a module for: module StaticTextControls self.evt_erase_background do |event| self.paint do |dc| dc.brush = Wx::TRANSPARENT_BRUSH # ?? end end end I can extend into this module using @title_st_one.repaint_my_control and I have some of the code above. I''m not wanting to paint a bitmap onto this control. I just want this control to become transparent so that the underlying bitmap which is already painted onto the parent frame shows. Example: Main Frame (already painted with bitmap) -- StaticTextControl (should be transparent so that it shows the Main Frame) I''ll read up on evt_erase_background but I''m not sure how to use the dc.brush code you supplied with this example. Any further help would be appreciated. Sincerely, Joel Dezenzio Website Bio: http://jdezenzio.com/ Rails Production Sites: http://ncaastatpages.com
So, I took the approach I believe you were trying to get me to do. I believe I found a partial answer but I''m still stumped. The partial answer is that I can''t use a StaticText control and achieve transparency. Windows will force the background to the current theme and you can''t get around that without drawing the text on the canvas instead. So, I removed the StaticText control and created a small panel using the same class and variable name. Here''s what I have: module StaticTextControls def paint_text(message) self.evt_erase_background do |event| self.paint do |dc| dc.set_background_mode(Wx::TRANSPARENT) dc.set_brush(Wx::TRANSPARENT_BRUSH) dc.draw_text(message, 5, 5) end end end end and I call it using the following extension: @title_st_one.paint_text("Test for Paint") And here''s what it shows: http://i780.photobucket.com/albums/yy89/jdezenzio/example_background2.jpg As you can see, the text is now painted on the panel and the panel is the gray looking rectangle behind the text. The problem I have now is how do I make the panel itself transparent so that the window behind it (the gradient steel blue I created) shows? Sure, I can paint a bitmap on the panel but I don''t want to paint a bitmap image. I just want to force it to be transparent. Any ideas on how to do this? Thanks. -- Posted via http://www.ruby-forum.com/.