Class: Icon_Loader
- Inherits:
-
Object
- Object
- Icon_Loader
- Defined in:
- lib/Icon_Loader.rb
Overview
Converts a Recursive_Open_Struct that contains filenames of PNG-icons into real icons.
Instance Method Summary collapse
-
#cfg_to_icons(cfg) ⇒ Object
Takes each attribute of the given Recursive_Open_Struct, converts it into a real icon, and sets it.
-
#initialize(app) ⇒ Icon_Loader
constructor
Create a new Icon_Loader.
-
#make_icon(filename) ⇒ Object
Constructs an icon from the given filename (from the icons directory).
Constructor Details
#initialize(app) ⇒ Icon_Loader
Create a new Icon_Loader. You need to specify the Fox-application.
6 7 8 |
# File 'lib/Icon_Loader.rb', line 6 def initialize(app) @app = app end |
Instance Method Details
#cfg_to_icons(cfg) ⇒ Object
Takes each attribute of the given Recursive_Open_Struct, converts it into a real icon, and sets it.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/Icon_Loader.rb', line 12 def cfg_to_icons(cfg) cfg.attrs.each do |attr| value = cfg.send(attr.to_sym) if (value.class == Recursive_Open_Struct) cfg_to_icons(value) else # value is a filename icon = make_icon(value) cfg.send((attr + "=").to_sym, icon) end end end |
#make_icon(filename) ⇒ Object
Constructs an icon from the given filename (from the icons directory).
26 27 28 29 30 31 32 33 34 |
# File 'lib/Icon_Loader.rb', line 26 def make_icon(filename) filename = File.join($cfg.icons_path, filename) icon = nil File.open(filename, "rb") do |f| icon = FXPNGIcon.new(@app, f.read, 0) end icon.create icon end |