lib/shoes/basic.rb in green_shoes-0.263.0 vs lib/shoes/basic.rb in green_shoes-1.0.273
- old
+ new
@@ -8,11 +8,15 @@
end
(@app.order << self) unless @noorder or self.is_a?(EditBox) or self.is_a?(EditLine)
(@app.cslot.contents << self) unless @nocontrol or @app.cmask
(@app.cmask.contents << self) if @app.cmask
- (@app.focusables << self) if self.is_a? Native
+ if self.is_a? Native
+ @app.focusables << self
+ self.state = args[:state] if args[:state]
+ args.delete :state
+ end
@parent = @app.cslot
Basic.class_eval do
attr_accessor *args.keys
end
@@ -86,12 +90,14 @@
case self
when Button, EditLine, EditBox, ListBox
@app.cslot.contents.delete self
remove
@real = nil
+ when TextBlock
+ @real.clear if @real
else
- @real.clear if @real
+ (@real.clear; @real.destroy) if @real
end
end
alias :clear_all :clear
@@ -132,11 +138,27 @@
move @left, @top
end
end
end
- class Image < Basic; end
+ class Image < Basic
+ def initialize args
+ @path = args[:path]
+ args.delete :path
+ super args
+ end
+
+ attr_reader :path
+
+ def path=(name)
+ @path = name
+ @real.clear
+ args = {width: @width, height: @height}
+ args.merge!({hidden: true}) if @hided
+ @real = @app.image(name, args).move(@left, @top).real
+ end
+ end
class Pattern < Basic
def move2 x, y
return if @hided
clear if @real
@@ -250,10 +272,37 @@
end
def focus
@app.focus_ele = self
end
+
+ attr_reader :state
+
+ def state=(ctl)
+ real = self.is_a?(EditBox) ? @textview : @real
+ case ctl
+ when "disabled"
+ real.sensitive = false
+ when 'readonly'
+ case self
+ when EditLine, EditBox
+ real.sensitive, real.editable = true, false
+ real.modify_base Gtk::STATE_NORMAL, Gdk::Color.new(56540, 56540, 54227)
+ else
+ end
+ when nil
+ real.sensitive = true
+ case self
+ when EditLine, EditBox
+ real.editable = true
+ real.modify_base Gtk::STATE_NORMAL, Gdk::Color.new(65535, 65535, 65535)
+ else
+ end
+ else
+ end
+ @state = ctl
+ end
end
class Button < Native
def click &blk
real.signal_connect "clicked", &proc{parent.append{blk[self]}} if blk
end
@@ -340,8 +389,8 @@
def fraction= n
real.fraction = n
end
- undef_method :focus
+ undef_method :focus, :state, :state=
end
end