Class: Writexlsx::Package::Button

Inherits:
Object
  • Object
show all
Includes:
Utility
Defined in:
lib/write_xlsx/package/button.rb

Constant Summary

Constants included from Utility

Utility::COL_MAX, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utility

#absolute_char, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #convert_date_time, #dash_types, delete_files, #fill_properties, #float_to_str, #layout_properties, #line_fill_properties, #line_properties, #palette_color, #pixels_to_points, #process_workbook_options, #ptrue?, #put_deprecate_message, #quote_sheetname, #r_id_attributes, #row_col_notation, #shape_style_base, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #v_shape_attributes_base, #v_shape_style_base, #value_or_raise, #write_anchor, #write_auto_fill, #write_color, #write_comment_path, #write_div, #write_fill, #write_font, #write_stroke, #write_xml_declaration, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xml_str

Instance Attribute Details

#fontObject

Returns the value of attribute font


10
11
12
# File 'lib/write_xlsx/package/button.rb', line 10

def font
  @font
end

#macroObject

Returns the value of attribute macro


10
11
12
# File 'lib/write_xlsx/package/button.rb', line 10

def macro
  @macro
end

#verticesObject

Returns the value of attribute vertices


10
11
12
# File 'lib/write_xlsx/package/button.rb', line 10

def vertices
  @vertices
end

Instance Method Details

#colorObject


25
26
27
# File 'lib/write_xlsx/package/button.rb', line 25

def color
  'buttonFace [67]'
end

#fill_attributesObject

attributes for <v:fill> element.


51
52
53
54
55
56
# File 'lib/write_xlsx/package/button.rb', line 51

def fill_attributes
  [
   ['color2',             'buttonFace [67]'],
   ['o:detectmouseclick', 't']
  ]
end

#style_additionObject


29
30
31
# File 'lib/write_xlsx/package/button.rb', line 29

def style_addition
  ['mso-wrap-style:tight']
end

#typeObject


21
22
23
# File 'lib/write_xlsx/package/button.rb', line 21

def type
  '#_x0000_t201'
end

#v_shape_attributes(id, z_index) ⇒ Object


12
13
14
15
16
17
18
19
# File 'lib/write_xlsx/package/button.rb', line 12

def v_shape_attributes(id, z_index)
  attributes = v_shape_attributes_base(id, z_index)
  attributes << ['o:button',    't']
  attributes << ['fillcolor',   color]
  attributes << ['strokecolor', 'windowText [64]']
  attributes << ['o:insetmode', 'auto']
  attributes
end

#write_client_dataObject

Write the <x:ClientData> element.


87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/write_xlsx/package/button.rb', line 87

def write_client_data
  attributes = [ ['ObjectType', 'Button'] ]

  @writer.tag_elements('x:ClientData', attributes) do
    # Write the x:Anchor element.
    write_anchor
    # Write the x:PrintObject element.
    write_print_object
    # Write the x:AutoFill element.
    write_auto_fill
    # Write the x:FmlaMacro element.
    write_fmla_macro
    # Write the x:TextHAlign element.
    write_text_halign
    # Write the x:TextVAlign element.
    write_text_valign
  end
end

#write_fmla_macroObject

Write the <x:FmlaMacro> element.


116
117
118
# File 'lib/write_xlsx/package/button.rb', line 116

def write_fmla_macro
  @writer.data_element('x:FmlaMacro', macro)
end

#write_print_objectObject

Write the <x:PrintObject> element.


109
110
111
# File 'lib/write_xlsx/package/button.rb', line 109

def write_print_object
  @writer.data_element('x:PrintObject', 'False')
end

#write_rotation_lockObject

Write the <o:lock> element.


61
62
63
64
65
66
67
# File 'lib/write_xlsx/package/button.rb', line 61

def write_rotation_lock
  attributes = [
                ['v:ext',    'edit'],
                ['rotation', 't']
               ]
  @writer.empty_tag('o:lock', attributes)
end

#write_shape(writer, id, z_index) ⇒ Object


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/write_xlsx/package/button.rb', line 33

def write_shape(writer, id, z_index)
  @writer = writer

  attributes = v_shape_attributes(id, z_index)

  @writer.tag_elements('v:shape', attributes) do
    # Write the v:fill element.
    write_fill
    # Write the o:lock element.
    write_rotation_lock
    # Write the v:textbox element.
    write_textbox
    # Write the x:ClientData element.
    write_client_data
  end
end

#write_text_halignObject

Write the <x:TextHAlign> element.


123
124
125
# File 'lib/write_xlsx/package/button.rb', line 123

def write_text_halign
  @writer.data_element('x:TextHAlign', 'Center')
end

#write_text_valignObject

Write the <x:TextVAlign> element.


130
131
132
# File 'lib/write_xlsx/package/button.rb', line 130

def write_text_valign
  @writer.data_element('x:TextVAlign', 'Center')
end

#write_textboxObject

Write the <v:textbox> element.


72
73
74
75
76
77
78
79
80
81
82
# File 'lib/write_xlsx/package/button.rb', line 72

def write_textbox
  attributes = [
                ['style', 'mso-direction-alt:auto'],
                ['o:singleclick', 'f']
               ]

  @writer.tag_elements('v:textbox', attributes) do
    # Write the div element.
    write_div('center', font)
  end
end