class Origami::Template::Button

def initialize(caption, id: nil, x:, y:, width:, height:)

def initialize(caption, id: nil, x:, y:, width:, height:)
    super()
    set_indirect(true)
    self.set_name(id)
    self.H = Annotation::Widget::Highlight::INVERT
    self.Rect = [ x, y, x + width, y + height ]
    self.F = Annotation::Flags::PRINT
    appstm = Annotation::AppearanceStream.new.setFilter(:FlateDecode)
    appstm.BBox = [ 0, 0, width, height ]
    appstm.Matrix = [ 1, 0, 0, 1, 0, 0 ]
    appstm.draw_rectangle(0, 0, width, height,
        fill: true, stroke: false, fill_color: Graphics::Color::RGB.new(0xE6, 0xE6, 0xFA))
    appstm.draw_polygon([[1,1],[1,height-1],[width-1,height-1],[width-2,height-2],[2,height-2],[2,2]],
        fill: true, stroke: false, fill_color: Graphics::Color::GrayScale.new(1.0))
    appstm.draw_polygon([[width-1,height-1],[width-1,1],[1,1],[2,2],[width-2,2],[width-2,height-2]],
        fill: true, stroke: false, fill_color: Graphics::Color::RGB.new(130, 130, 130))
    appstm.draw_rectangle(0.5, 0.5, width-1, height-1,
        fill: false, stroke: true, stroke_color: Graphics::Color::GrayScale.new(0.0))
    text_width = 4.75 * caption.length
    appstm.write(caption,
        x: (width - text_width)/2, y: height/2-5, size: 10)
    appstm.Resources = Resources.new
    set_normal_appearance(appstm)
end