Method: Origami::Template::TextPanel#initialize

Defined in:
lib/origami/template/widgets.rb

#initialize(id, x:, y:, width:, height:) ⇒ TextPanel

Returns a new instance of TextPanel.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/origami/template/widgets.rb', line 120

def initialize(id, x:, y:, width:, height:)
    super()

    set_indirect(true)

    self.Rect = [ x, y, x + width, y + height ]
    self.F = Annotation::Flags::PRINT
    self.NM = id
    self.DA = '/F1 12 Tf 0 g'

    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: false, stroke: true, stroke_color: Graphics::Color::GrayScale.new(0.0))

    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::RGB.new(130, 130, 130))

    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::GrayScale.new(1.0))

    appstm.draw_rectangle(0.5, 0.5, width-1, height-1,
        fill: false, stroke: true, stroke_color: Graphics::Color::GrayScale.new(0.0))

    set_normal_appearance(appstm)
end