[fxruby-users] Display an arrow, or transparent image colors

Tobias Herzke fxrbu1 at gi2.herzkes.de
Mon Apr 10 17:35:56 EDT 2006

I want to display an arrow in the user interface between 2 GUI Components.

I think I know how I can do it, but I ran into a problem displaying
pixel images with transparent background. I describe this image display
problem here and ask for advice. but if someone knows of a different and
easier way to display arrows, please tell me.

Example Problem: I want a FXHorizontalFrame to contain, from left to
right, (1) a FXTextField, (2) the arrow, pointing from to the right, (3)
a FXDial.

I figured I can display the Arrow using a .png image containing a red
arrow on transparent background, loading that image using FXPNGIcon, and
display it in FXImageFrame. Example code:

require "fox14"
include Fox

app = FXApp.new
window = FXMainWindow.new(app, "Demo")

hframe = FXHorizontalFrame.new(window)

file_display = FXTextField.new(hframe, 40, nil, 0, LAYOUT_CENTER_Y)
file_display.text = "SoundFile.wav"

arrow_image = File.open("ArrowShortRightRedT.png", "rb") {|f|
  FXPNGIcon.new(app, f.read)
arrow = FXImageFrame.new(hframe, arrow_image, FRAME_NONE)

dial = FXDial.new(hframe, nil, 0,



Using this program, my red arrow will display on black background. I had
expected the background to be of the same gray as used everywhere else
in the fox window. Anyone know how to achieve this? I've tried various
combinations of setting the options as in the commented-out line above,
and using images without transparent background in .png and .gif format.
The result was that the background color that should have been
transparent was actually displayed.

I know I can use a .png image of my red arrow with grey background
already present in the bitmap. But this is calling for trouble: fox uses
different shades of gray on linux and windows, and I don't know about
other platforms.

Please help!


More information about the fxruby-users mailing list