Sha256: 285a60519c29f73c11488a82aba1c28285d356dbe34a8624bfa0c3566f2ce0e5

Contents?: true

Size: 1.69 KB

Versions: 42

Compression:

Stored size: 1.69 KB

Contents

#!/usr/bin/env ruby

require 'fox16'

include Fox

=begin
This is the "Cadillac" version of the classic "Hello, World" example;
it has not only an icon, but also a tooltip, and an accelerator.
 
Executing an FXIcon's constructor will cause it to deserialize the pixel-
data by associating a memory stream with the data array; the resulting icon
object will contain a pixel-array, which will be converted to an off-screen
X pixmap when the icons create() method is called.  At that point, the
temporary (client-side) pixel storage will be freed.
=end  

# Construct the application object, with application name "Hello2"
# and vendor key "FoxTest". These strings are primarily used for
# interactions with the FOX registry.

application = FXApp.new("Hello2", "FoxTest")

# Construct the main window
main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL)

# Construct a PNG icon that we'll attach to the button. Note that the
# second argument to the constructor just needs to be a byte stream (i.e.
# a string) from some source; here, we're reading the bytes from a file
# on disk.

icon = nil
File.open(File.join("icons", "hello2.png"), "rb") { |f|
  icon = FXPNGIcon.new(application, f.read)
}

# Construct the button as a child of the main window.
FXButton.new(main, "&Hello, World!\tWow, FOX is really cool!\nClick on the icon to quit the application.", icon, application, FXApp::ID_QUIT, ICON_UNDER_TEXT|JUSTIFY_BOTTOM)

# Construct the tooltip object
FXToolTip.new(application)

# Calling create() on the application recursively creates all of its
# owned resources (e.g. the application's windows)
application.create

# Show the main window
main.show(PLACEMENT_SCREEN)

# Kick off the event loop
application.run

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
fxruby-1.6.22.pre2-x86-mingw32 examples/hello2.rb
fxruby-1.6.22.pre2 examples/hello2.rb
fxrubi-1.6.22.pre1-x86-mingw32 examples/hello2.rb
fxrubi-1.6.22.pre1 examples/hello2.rb
fxruby-1.6.20-x86-mingw32 examples/hello2.rb
fxruby-1.6.20-x86-linux examples/hello2.rb
fxruby-1.6.20 examples/hello2.rb
fxruby-1.6.20-universal-darwin-10 examples/hello2.rb
fxruby-1.6.19-x86-mingw32 examples/hello2.rb
fxruby-1.6.14-mswin32 examples/hello2.rb
fxruby-1.6.13-mswin32 examples/hello2.rb
fxruby-1.6.0 examples/hello2.rb
fxruby-1.6.1 examples/hello2.rb
fxruby-1.6.11 examples/hello2.rb
fxruby-1.6.10 examples/hello2.rb
fxruby-1.6.12 examples/hello2.rb
fxruby-1.6.13 examples/hello2.rb
fxruby-1.6.14-universal-darwin-9 examples/hello2.rb
fxruby-1.6.14 examples/hello2.rb
fxruby-1.6.15-universal-darwin-9 examples/hello2.rb