[fxruby-users] Overriding default GUI colors

Lyle Johnson lyle at lylejohnson.name
Sun Jan 25 14:55:27 EST 2009

On Jan 24, 2009, at 6:26 AM, James Hibbard wrote:

> I wrote a GUI using FXRuby under WinXP.
> I then upgraded to Vista, installed Ruby (and thus by default  
> FXRuby) and ran my GUI.
> It was then that I noticed that the colours have gone weird.
> The main user interface is now white (the default colour that Vista  
> uses), but all of the data targets and tables have remained beige  
> (RGB 236, 233, 216).
> Of course one can individualy declare a white background colour for  
> each of these widgets, but then it looks garish if run on XP or Linux.
> I'm looking for a setting I can apply to make the colour for the  
> application uniform and overide the system default.
> I already tried such things as app.backColour = FXRGB(236, 233, 216).

If you didn't build FOX from source code, you probably don't have the  
FOX Control Panel application installed, and so you'll need to change  
these default colors in your application code.

The trick, however, is to change the color values after the FXApp's  
init() method gets called, but before you create any of your  
application's widgets:

	app = FXApp.new
	# Change default colors here, e.g.
	# 	app.backColor = FXRGB(236, 233, 216)
	main_window = FXMainWindow.new(app, ...)

When you construct a widget (like an FXMainWindow), it copies the  
colors from FXApp, and so if you haven't changed them by that point  
you have to go make changes on a widget-by-widget basis (which is a  
pain). Also, note that in many FXRuby applications you won't see  
FXApp#init called explicitly, because it gets called automatically for  
you if you don't need it.

Hope this helps,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20090125/23587b58/attachment.html>

More information about the fxruby-users mailing list