Class: Fidgit::Grid

Inherits:
Packer show all
Defined in:
lib/fidgit/elements/grid.rb

Overview

A vertically aligned element packing container.

Direct Known Subclasses

Horizontal, Vertical

Constant Summary

Constants inherited from Element

Element::DEFAULT_SCHEMA_FILE, Element::VALID_ALIGN_H, Element::VALID_ALIGN_V

Instance Attribute Summary collapse

Attributes inherited from Packer

#spacing_h, #spacing_v

Attributes inherited from Element

#align_h, #align_v, #background_color, #border_thickness, #font, #padding_bottom, #padding_left, #padding_right, #padding_top, #parent, #tip, #z

Instance Method Summary collapse

Methods inherited from Container

#add, #button, #clear, #color_picker, #color_well, #combo_box, #file_browser, #grid, #group, #hit_element, #horizontal, #image_frame, #insert, #label, #list, #radio_button, #remove, #scroll_area, #scroll_window, #slider, #text_area, #to_s, #toggle_button, #update, #vertical, #write_tree, #x=, #y=

Methods inherited from Element

#default, #drag?, #draw, #draw_frame, #draw_rect, #enabled=, #enabled?, #height, #height=, #hit?, #max_height, #max_width, #min_height, #min_width, new, original_new, #outer_height, #outer_width, #recalc, schema, #to_s, #update, #width, #width=, #with, #x, #x=, #y, #y=

Methods included from Event

#events, included, new_event_handlers, #publish, #subscribe, #unsubscribe

Constructor Details

#initialize(options = {}) ⇒ Grid

Note:

Currently only supports num_columns mode (not num_rows).

Returns a new instance of Grid.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :num_columns (Integer)

    Maximum number of columns to use (incompatible with :num_rows)

  • :num_rows (Integer)

    Maximum number of rows to use (incompatible with :num_columns)

Raises:

  • (ArgumentError)


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fidgit/elements/grid.rb', line 23

def initialize(options = {})
  options = {
    cell_border_color: default(:cell_border_color),
    cell_background_color: default(:cell_background_color),
    cell_border_thickness: default(:cell_border_thickness),
  }.merge! options

  @num_columns = options[:num_columns]
  @num_rows = options[:num_rows]
  raise ArgumentError, "options :num_rows and :num_columns are not compatible" if @num_rows and @num_columns

  @cell_border_color = options[:cell_border_color].dup
  @cell_border_thickness = options[:cell_border_thickness]
  @cell_background_color = options[:cell_background_color].dup

  @type = @num_rows ? :fixed_rows : :fixed_columns

  super options
end

Instance Attribute Details

#num_columnsInteger (readonly)

Returns:

  • (Integer)


14
15
16
# File 'lib/fidgit/elements/grid.rb', line 14

def num_columns
  @num_columns
end

#num_rowsInteger (readonly)

Returns:

  • (Integer)


11
12
13
# File 'lib/fidgit/elements/grid.rb', line 11

def num_rows
  @num_rows
end

#typeSymbol (readonly)

Returns:

  • (Symbol)


8
9
10
# File 'lib/fidgit/elements/grid.rb', line 8

def type
  @type
end