33 lines
1.0 KiB
Ruby
33 lines
1.0 KiB
Ruby
require 'fourmi/prawn/utils/extensions/strokes_and_colors'
|
|
require 'prawn/blank'
|
|
|
|
module Fourmi::Prawn::Utils
|
|
module Extensions
|
|
module VisualForm
|
|
def visual_checkbox(name, checked = false, size: 8, white: false, form: false)
|
|
bounding_box([0, cursor], width: bounds.width) do
|
|
float do
|
|
bounding_box([0, cursor], width: size, height: size) do
|
|
if form
|
|
checkbox name: name, at: [0, bounds.top], checked: checked, width: bounds.width, height: bounds.height
|
|
else
|
|
with_fill_color 'FFFFFF' do
|
|
fill_rectangle [0, bounds.top], bounds.width, bounds.height if white
|
|
end
|
|
fill_rectangle [2, bounds.height - 2], bounds.width - 4, bounds.height - 4 if checked
|
|
end
|
|
stroke_bounds
|
|
end
|
|
end
|
|
indent(size + 7) do
|
|
yield
|
|
end if block_given?
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
require 'prawn/document'
|
|
Prawn::Document.extensions << Prawn::Extensions::VisualForm
|