Class: Shoes
- 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
Defined Under Namespace
Modules: Mod, Mod2 Classes: Download, Video, Widget
Class Method Summary collapse
- .call_back_procs(app) ⇒ Object
- .contents_alignment(slot) ⇒ Object
- .dps_reset(dps, gc) ⇒ Object
- .init_contents(contents) ⇒ Object
- .mouse_hover_control(app) ⇒ Object
- .mouse_leave_control(app) ⇒ Object
- .mouse_motion_control(app) ⇒ Object
- .mouse_on?(e) ⇒ Boolean
- .mouse_shape_control(app) ⇒ Object
- .repaint_all(slot) ⇒ Object
- .reset_rotate(tr, gc, angle, left, top) ⇒ Object
- .set_pattern(s, gc, pat, m = :Background) ⇒ Object
- .set_rotate(gc, angle, left, top) ⇒ Object
- .show_manual(lang = 'English') ⇒ Object
Class Method Details
.call_back_procs(app) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/shoes/helper_methods.rb', line 233 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.setThumb h * h / scrollable_height vb.setMaximum scrollable_height - h + vb.getThumb vb.setIncrement h / 2 else location = app.cs.getLocation location.y = 0 app.cs.setLocation location end repaint_all app.cslot end |
.contents_alignment(slot) ⇒ Object
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/shoes/helper_methods.rb', line 210 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
337 338 339 340 341 |
# File 'lib/shoes/helper_methods.rb', line 337 def self.dps_reset dps, gc dps.each{|dp| dp.dispose if dp} dps.clear dps << gc end |
.init_contents(contents) ⇒ Object
253 254 255 256 257 258 259 260 |
# File 'lib/shoes/helper_methods.rb', line 253 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_hover_control(app) ⇒ Object
266 267 268 269 270 271 272 273 |
# File 'lib/shoes/helper_methods.rb', line 266 def self.mouse_hover_control app app.mhcs.each do |e| if mouse_on?(e) and !e.hovered e.hovered = true e.hover_proc[e] if e.hover_proc end end end |
.mouse_leave_control(app) ⇒ Object
275 276 277 278 279 280 281 282 |
# File 'lib/shoes/helper_methods.rb', line 275 def self.mouse_leave_control app app.mhcs.each do |e| if !mouse_on?(e) and e.hovered e.hovered = false e.leave_proc[e] if e.leave_proc end end end |
.mouse_motion_control(app) ⇒ Object
262 263 264 |
# File 'lib/shoes/helper_methods.rb', line 262 def self.mouse_motion_control app app.mmcs.each{|blk| blk[*app.mouse_pos]} end |
.mouse_on?(e) ⇒ Boolean
284 285 286 287 288 |
# File 'lib/shoes/helper_methods.rb', line 284 def self.mouse_on? e mb, mx, my = e.app.mouse dx, dy = e.is_a?(Star) ? [e.width / 2.0, e.height / 2.0] : [0, 0] e.left - dx <= mx and mx <= e.left - dx + e.width and e.top - dy <= my and my <= e.top - dy + e.height end |
.mouse_shape_control(app) ⇒ Object
290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/shoes/helper_methods.rb', line 290 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
227 228 229 230 231 |
# File 'lib/shoes/helper_methods.rb', line 227 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
330 331 332 333 334 335 |
# File 'lib/shoes/helper_methods.rb', line 330 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
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/shoes/helper_methods.rb', line 305 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
321 322 323 324 325 326 327 328 |
# File 'lib/shoes/helper_methods.rb', line 321 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 |