Top Level Namespace

Defined Under Namespace

Modules: FX, ImgAccessors, MiddleBtn, RadioGroup1, RadioWidget, RightBtn Classes: FileSelector, FlatStyle, Module, PathSelector, StyleVisitor

Instance Method Summary collapse

Instance Method Details

#hasExtension(filename, ext) ⇒ Object



111
112
113
# File 'lib/libGUIb14.rb', line 111

def hasExtension(filename, ext)
  File.basename(filename, ext) != File.basename(filename)
end

#load_dummyObject

Raises:

  • (TypeError)


102
103
104
105
106
107
108
109
# File 'lib/libGUIb14.rb', line 102

def load_dummy
  raise TypeError unless $fxapp
  imgdata = "9805e474d0a0a1a0000000d0948444250000000100000001803000000082d2f035000000a247548547342756164796f6e6024596d65600d4f60293026456260223030343021363a33363a3133302b2031303037c63ded4000000704794d454704d2090f0627041559b9c00000090078495370000b0210000b021102ddde7cf000000407614d41400001bf8b0cf16500000003305c44554000000ffefeffff0f0ffc1c1ffcbcbff7878ff5b5bffc5c5ff7979ff9292ffadadff2f2fff7171ff4747ffb4b4ff6e6eff8383bfe98b0d000000104725e43500046e8d66000000b59444144587ad58ec1ee008028040069333b223d7ff7adec6a39c5b57f38d8f406a3992ea61d0508294b382bda9d373840c595953630f0c1c930ece73e940ee8506f8dc0446f14600fddfa260877711b0c50971c4f5ff898f7819b1678020e2a25402a2000000009454e444ea240628"
  imgdata = [imgdata].pack("h#{imgdata.size * 2}")
  $dummy_img = img = Fox::FXPNGIcon.new($fxapp, imgdata, Fox::IMAGE_KEEP | Fox::IMAGE_SHMI | Fox::IMAGE_SHMP)
  img.create
  img
end

#loadImage(file) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/libGUIb14.rb', line 115

def loadImage(file)
  img = load_dummy unless $dummy_img
  unless File.exist? file
    return img
  end
  begin
    opts = Fox::IMAGE_KEEP | Fox::IMAGE_SHMI | Fox::IMAGE_SHMP
    if hasExtension(file, ".gif")
      img = Fox::FXGIFIcon.new($fxapp, nil, opts)
    elsif hasExtension(file, ".bmp")
      img = Fox::FXBMPIcon.new($fxapp, nil, opts)
    elsif hasExtension(file, ".xpm")
      img = Fox::FXXPMIcon.new($fxapp, nil, opts)
    elsif hasExtension(file, ".png")
      img = Fox::FXPNGIcon.new($fxapp, nil, opts)
    elsif hasExtension(file, ".jpg")
      img = Fox::FXJPGIcon.new($fxapp, nil, opts)
    elsif hasExtension(file, ".pcx")
      img = Fox::FXPCXIcon.new($fxapp, nil, opts)
    elsif hasExtension(file, ".tif")
      img = Fox::FXTIFIcon.new($fxapp, nil, opts)
    elsif hasExtension(file, ".tga")
      img = Fox::FXTGAIcon.new($fxapp, nil, opts)
    elsif hasExtension(file, ".ico")
      img = Fox::FXICOIcon.new($fxapp, nil, opts)
    end
    unless img
      puts("Unsupported image type: #{file}")
      return img
    end
    Fox::FXFileStream.open(file, Fox::FXStreamLoad) { |stream| img.loadPixels(stream) }
    img.filename = file
    img.create
  rescue Exception
    puts "load Image: #{$!}"
  end
  img
end

#loadImageFromString(s, icon_class = Fox::FXPNGIcon) ⇒ Object

Raises:

  • (TypeError)


94
95
96
97
98
99
100
# File 'lib/libGUIb14.rb', line 94

def loadImageFromString s, icon_class = Fox::FXPNGIcon
  raise TypeError unless $fxapp
  imgdata = [s].pack("h#{s.size * 2}")
  img = icon_class.new($fxapp, imgdata, Fox::IMAGE_KEEP | Fox::IMAGE_SHMI | Fox::IMAGE_SHMP)
  img.create
  img
end

#loadImageToString(filename) ⇒ Object



88
89
90
91
92
# File 'lib/libGUIb14.rb', line 88

def loadImageToString filename
  data = nil
  File.open(filename, "rb") { |f| data = f.read }
  data.unpack1("h#{data.size * 2}")
end

#rel_path(a, b) ⇒ Object

Raises:

  • (TypeError)


6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/libGUIb14.rb', line 6

def rel_path(a, b)
  raise TypeError unless a.is_a? String and b.is_a? String
  a.tr!("\\", "/")
  b.tr!("\\", "/")
  a = a.split("/")
  b = b.split("/")
  i = 0
  while (a[i] == b[i]) && (i < a.size)
    i += 1
  end
  "../" * (a.size - i) + b[i..-1].join("/")
end