Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] Composite with transparent background

Hi all,

I need a solution for Linux. Try out the following snippet and look at snapshots.

- The snapshot on Ubuntu is: http://i.imgur.com/zE8g9.png
- The snapshot on Windows 7 is: http://www.rin-shun.com/shoes4/tmp/shoes4-sandbox-012.png

Umm,... the `Swt::SWT::TRANSPARENT` doesn't work well on Ubuntu...
How can I make the composite to have transparent background on Linux?

```ruby
require 'java'
require 'swt'

display = Swt::Widgets::Display.new
white = display.getSystemColor(Swt::SWT::COLOR_WHITE)
red = display.getSystemColor(Swt::SWT::COLOR_RED)
green = display.getSystemColor(Swt::SWT::COLOR_GREEN)

shell = Swt::Widgets::Shell.new display, Swt::SWT::SHELL_TRIM
shell.setBackground white
shell.addListener Swt::SWT::Close, proc{Swt.display.dispose}

cs1 = Swt::Widgets::Composite.new shell, Swt::SWT::TRANSPARENT
cs1.setSize 200, 200

blk = proc do |e|
  gc = e.gc
  gc.setBackground green
  gc.fillOval 25, 25, 100, 100
end
cs1.add_paint_listener(blk)

cs2 = Swt::Widgets::Composite.new cs1, Swt::SWT::TRANSPARENT
cs2.setSize 150, 150
cs2.setLocation 50, 50

blk = proc do |e|
  gc = e.gc
  gc.setBackground red
  gc.fillOval 25, 25, 100, 100
end
cs2.add_paint_listener(blk)

shell.pack
shell.open

Swt.event_loop{Swt.display.isDisposed}
```

Thanks,
ashbb

Back to the top