Class: Shoes

Inherits:
Object show all
Defined in:
lib/shoes/colors.rb,
lib/shoes/manual.rb,
lib/shoes/widget.rb,
lib/plugins/video.rb,
lib/plugins/video.rb,
lib/shoes/download.rb,
lib/shoes/helper_methods.rb

Direct Known Subclasses

Manual

Defined Under Namespace

Modules: Mod, Mod2 Classes: Download, Video, Widget

Class Method Summary collapse

Class Method Details

.call_back_procs(app) ⇒ Object



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/shoes/helper_methods.rb', line 218

def self.call_back_procs app
  init_contents app.cslot.contents
  w, h = app.width, app.height
  app.cslot.width, app.cslot.height = w, h
  scrollable_height = contents_alignment app.cslot
  app.cs.setSize w, [scrollable_height, h].max
  vb = app.shell.getVerticalBar
  vb.setVisible(scrollable_height > h)
  if scrollable_height > h
    vb.setMaximum scrollable_height - h + 12
  else
    location = app.cs.getLocation
    location.y = 0
    app.cs.setLocation location
  end
  repaint_all app.cslot
end

.contents_alignment(slot) ⇒ Object



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/shoes/helper_methods.rb', line 195

def self.contents_alignment slot
  x, y = slot.left.to_i, slot.top.to_i
  max = Struct.new(:top, :height).new
  max.top, max.height = y, 0
  slot_height, slot_top = 0, y

  slot.contents.each do |ele|
    tmp = max
    max = ele.positioning x, y, max
    x, y = ele.left + ele.width, ele.top + ele.height
    unless max == tmp
      slot_height = max.top + max.height - slot_top
    end
  end
  slot_height
end

.dps_reset(dps, gc) ⇒ Object



296
297
298
299
300
# File 'lib/shoes/helper_methods.rb', line 296

def self.dps_reset dps, gc
  dps.each{|dp| dp.dispose if dp}
  dps.clear
  dps << gc
end

.init_contents(contents) ⇒ Object



236
237
238
239
240
241
242
243
# File 'lib/shoes/helper_methods.rb', line 236

def self.init_contents contents
  contents.each do |ele|
    next unless ele.is_a? Slot
    ele.initials.each do |k, v|
      ele.send "#{k}=", v
    end
  end
end

.mouse_motion_control(app) ⇒ Object



245
246
247
# File 'lib/shoes/helper_methods.rb', line 245

def self.mouse_motion_control app
  app.mmcs.each{|blk| blk[*app.mouse_pos]}
end

.mouse_shape_control(app) ⇒ Object



249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/shoes/helper_methods.rb', line 249

def self.mouse_shape_control app
  flag = false
  mouse_x, mouse_y = app.mouse_pos
  app.mscs.each do |s|
    if s.is_a?(Link) and !s.parent.hided
      flag = true if ((s.pl..(s.pl+s.pw)).include?(mouse_x) and (s.sy..s.ey).include?(mouse_y) and !((s.pl..s.sx).include?(mouse_x) and (s.sy..(s.sy+s.lh)).include?(mouse_y)) and !((s.ex..(s.pl+s.pw)).include?(mouse_x) and ((s.ey-s.lh)..s.ey).include?(mouse_y)))
    elsif !s.is_a?(Link) and !s.hided
      dx, dy = s.is_a?(Star) ? [s.width / 2.0, s.height / 2.0] : [0, 0]
      flag = true if s.left - dx <= mouse_x and mouse_x <= s.left - dx + s.width and s.top - dy <= mouse_y and mouse_y <= s.top - dy + s.height
    end
  end
  cursor = flag ? Swt::SWT::CURSOR_HAND : Swt::SWT::CURSOR_ARROW
  app.shell.setCursor  Shoes.display.getSystemCursor(cursor)
end

.repaint_all(slot) ⇒ Object



212
213
214
215
216
# File 'lib/shoes/helper_methods.rb', line 212

def self.repaint_all slot
  slot.contents.each do |ele|
    ele.is_a?(Basic) ? ele.move2(ele.left + ele.margin_left, ele.top + ele.margin_top) : repaint_all(ele)
  end
end

.reset_rotate(tr, gc, angle, left, top) ⇒ Object



289
290
291
292
293
294
# File 'lib/shoes/helper_methods.rb', line 289

def self.reset_rotate tr, gc, angle, left, top
  tr.translate left, top
  tr.rotate angle
  tr.translate -left, -top
  gc.setTransform tr
end

.set_pattern(s, gc, pat, m = :Background) ⇒ Object



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/shoes/helper_methods.rb', line 264

def self.set_pattern s, gc, pat, m = :Background
  pat = s.app.tr_color(pat) if pat.is_a? String
  if pat.is_a? Array
    eval "gc.set#{m} Swt::Color.new(Shoes.display, *pat[0,3])"
    gc.setAlpha(pat[3] ? pat[3]*255 : 255)
  elsif pat.is_a? Range
    if s.is_a? Star
      eval "gc.set#{m}Pattern s.app.gradient(pat, s.left-s.width/2.0, s.top-s.height/2.0, s.width, s.height, s.angle)"
    else
      eval "gc.set#{m}Pattern s.app.gradient(pat, s.left, s.top, s.width, s.height, s.angle)"
    end
  elsif pat.is_a? String
    eval "gc.set#{m}Pattern Swt::Pattern.new(Shoes.display, Swt::Image.new(Shoes.display, pat))"
  end
end

.set_rotate(gc, angle, left, top) ⇒ Object



280
281
282
283
284
285
286
287
# File 'lib/shoes/helper_methods.rb', line 280

def self.set_rotate gc, angle, left, top
  if block_given?
    tr = Swt::Transform.new Shoes.display
    reset_rotate tr, gc, angle, left, top
    yield
    reset_rotate tr, gc, -angle, left, top
  end
end

.show_manual(lang = 'English') ⇒ Object



2
3
4
5
# File 'lib/shoes/manual.rb', line 2

def self.show_manual lang='English'
  $lang = lang
  load File.join(DIR, 'shoes/help.rb')
end