class ColorWidget
Attributes
ph[RW]
pw[RW]
Public Instance Methods
initial_size()
click to toggle source
# File samples/dasm-plugins/bookmark.rb, line 28 def initial_size [@pw*256, @ph*16] end
initialize_widget(&b)
click to toggle source
Calls superclass method
Metasm::Gui::DrawableWidget#initialize_widget
# File samples/dasm-plugins/bookmark.rb, line 21 def initialize_widget(&b) super() @action = b @pw = 3 @ph = 8 end
mousemove(x, y)
click to toggle source
# File samples/dasm-plugins/bookmark.rb, line 58 def mousemove(x, y) xy_to_col(x, y) end
mouserelease(x, y)
click to toggle source
# File samples/dasm-plugins/bookmark.rb, line 62 def mouserelease(x, y) if c = xy_to_col(x, y) toplevel.destroy @action.call(c) end end
paint()
click to toggle source
# File samples/dasm-plugins/bookmark.rb, line 32 def paint 0x100.times { |x| cx = x if x & 0x10 > 0 cx = (x&0xf0) + (15-(x&0xf)) end 0x10.times { |y| col = '%02x%x' % [cx, y] draw_rectangle_color(col, x*@pw, y*@ph, @pw, @ph) } } end
xy_to_col(x, y)
click to toggle source
# File samples/dasm-plugins/bookmark.rb, line 45 def xy_to_col(x, y) x = x.to_i / @pw y = y.to_i / @ph if x >=0 and y >= 0 and x <= 0xff and y <= 0xf if x & 0x10 > 0 x = (x&0xf0) + (15-(x&0xf)) end col = '%02x%x' % [x, y] toplevel.title = "color #{col}" col end end