represents a clickable area with a label (aka button)
create a new Button with the specified text & border color
# File metasm/gui/win32.rb, line 1961 def initialize(text='Ok', c1=:palegrey, c2=:grey, &b) @x = @y = @w = @h = 0 @c1, @c2 = c1, c2 @text = text @down = false @action = b end
checks if the click is on the button, returns true if so
# File metasm/gui/win32.rb, line 1986 def click(x, y) @down = true if x >= @x and x < @x+@w and y >= @y and y < @y+@h end
# File metasm/gui/win32.rb, line 1990 def mouserelease(x, y) if @down @down = false @action.call true end end
move the button (x y w h)
# File metasm/gui/win32.rb, line 1970 def move(nx=@x, ny=@y, nw=@w, nh=@h) @x, @y, @w, @h = nx, ny, nw, nh end
draw the button on the parent widget
# File metasm/gui/win32.rb, line 1975 def paint(w) c1, c2 = @c1, @c2 c1, c2 = c2, c1 if @down w.draw_string_color(:text, @x+(@w-w.font_width*@text.length)/2, @y+(@h - w.font_height)/2, @text) w.draw_line_color(c1, @x, @y, @x, @y+@h) w.draw_line_color(c1, @x, @y, @x+@w, @y) w.draw_line_color(c2, @x+@w, @y+@h, @x, @y+@h) w.draw_line_color(c2, @x+@w, @y+@h, @x+@w, @y) end