Class: Prawn::Blank::Checkbox

Inherits:
Field show all
Defined in:
lib/prawn/blank/checkbox.rb

Constant Summary

Constants inherited from FieldBase

FieldBase::FF_FLAGS

Instance Method Summary collapse

Methods inherited from FieldBase

#_parent=, #appearance, #appearance=, #at, #at=, create, #denormalize_color, field_attr_accessor, flag_accessor, from_ref, #height, #height=, #initialize, #leaf?, #parent=, #root?, #validate!, #width, #width=

Constructor Details

This class inherits a constructor from Prawn::Blank::FieldBase

Instance Method Details

#checkedObject



4
5
6
# File 'lib/prawn/blank/checkbox.rb', line 4

def checked
  return @data[:AS] == :Yes
end

#checked=(value) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/prawn/blank/checkbox.rb', line 8

def checked=(value)
  if value
    @data[:AS] = :Yes
    @data[:V] = :Yes
  else
    @data[:AS] = :Off
    @data[:V] = :Off
  end
end

#finalize(document) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/prawn/blank/checkbox.rb', line 18

def finalize(document)
  # render this field
  
  app = self.appearance || document.default_appearance
  
  @data[:AP] = {:N =>{:Off=>app.checkbox_off(self),:Yes=>app.checkbox_on(self)},
                :R =>{:Off=>app.checkbox_off_over(self),:Yes=>app.checkbox_on_over(self)},
                :D =>{:Off=>app.checkbox_off_down(self),:Yes=>app.checkbox_on_down(self)}}
  return
end