Class: HtmlGrid::Composite

Inherits:
AbstractComposite show all
Defined in:
lib/htmlgrid/composite.rb

Direct Known Subclasses

CenteredComposite, Form, List, Template

Constant Summary collapse

COLSPAN_MAP =
{}
COMPONENT_CSS_MAP =
{}
CSS_MAP =
{}
DEFAULT_CLASS =
InputText
VERTICAL =
false

Constants inherited from AbstractComposite

AbstractComposite::CSS_CLASS, AbstractComposite::CSS_ID, AbstractComposite::CSS_ID_MAP, AbstractComposite::CSS_STYLE_MAP, AbstractComposite::LABELS, AbstractComposite::LOOKANDFEEL_MAP, AbstractComposite::SYMBOL_MAP

Constants inherited from Component

HtmlGrid::Component::CSS_CLASS, HtmlGrid::Component::CSS_ID, HtmlGrid::Component::HTML_ATTRIBUTES, HtmlGrid::Component::HTTP_HEADERS, HtmlGrid::Component::LABEL

Instance Attribute Summary

Attributes inherited from Component

#attributes, #dojo_tooltip, #model, #value

Instance Method Summary collapse

Methods inherited from AbstractComposite

#create, #init

Methods inherited from Component

#_to_html, #autofill?, #css_class, #css_class=, #css_id, #css_id=, #dojo_dynamic_html, #dojo_parse_widgets, #dojo_tag, #dojo_title=, #dynamic_html, #escape, #escape_symbols, #formname, #http_headers, #initialize, #label=, #label?, #onclick=, #onload=, #onsubmit=, #set_attribute, #tabindex=

Constructor Details

This class inherits a constructor from HtmlGrid::Component

Instance Method Details

#compose(model = @model, offset = [0,0], bg_flag = false) ⇒ Object Also known as: _compose



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/htmlgrid/composite.rb', line 194

def compose(model=@model, offset=[0,0], bg_flag=false)
  comps = components
  css = css_map
    cids = css_id_map
  ccss = component_css_map
  colsp = colspan_map
  suffix = resolve_suffix(model, bg_flag)
  comps.keys.concat(css.keys).concat(colsp.keys).uniq.sort_by { |key| 
      [key.size, key] 
    }.each { |key|
    nkey = key[0,2]
    matrix = resolve_offset(key, offset)
    nmatrix = resolve_offset(nkey, offset)
    comp = compose_component(model, comps[key], matrix)
    if(style = css[key])
      @grid.add_style(style + suffix, *matrix)
    elsif(style = css[nkey])
      @grid.add_style(style + suffix, *nmatrix)
    end
      if(id = cids[key] || cids[nkey])
        comp.css_id = id
      end
    if(span = colsp[key])
      @grid.set_colspan(matrix.at(0), matrix.at(1), span)  
    end
  }
    # component-styles depend on components having been initialized 
    # -> separate iteration
    ccss.each { |key, cstyle|
      matrix = resolve_offset(key, offset)
      @grid.add_component_style(cstyle + suffix, *matrix)
    }
=begin
  compose_components(model, offset)
  compose_css(offset)
  compose_colspan(offset)
=end

end

#compose_colspan(offset) ⇒ Object



233
234
235
236
237
238
# File 'lib/htmlgrid/composite.rb', line 233

def compose_colspan(offset)
  colspan_map.each { |matrix, span|
    res = resolve_offset(matrix, offset)
    @grid.set_colspan(res.at(0), res.at(1), span) 
  }
end

#eventObject



239
240
241
# File 'lib/htmlgrid/composite.rb', line 239

def event
  @container.event if @container.respond_to?(:event)
end

#full_colspanObject

def explode! @grid.explode! super end



248
249
250
251
252
253
# File 'lib/htmlgrid/composite.rb', line 248

def full_colspan
  raw_span = components.keys.collect{ |key|
    key.at(0)
  }.max.to_i
  (raw_span > 0) ? raw_span + 1 : nil
end

#insert_row(ypos, txt, css_class = nil) ⇒ Object



254
255
256
257
258
# File 'lib/htmlgrid/composite.rb', line 254

def insert_row(ypos, txt, css_class=nil)
  @grid.insert_row(ypos, txt)
  @grid.set_colspan(0,ypos)
  @grid.add_style(css_class, 0, ypos) if(css_class)
end

#to_html(context) ⇒ Object



259
260
261
262
263
264
265
266
# File 'lib/htmlgrid/composite.rb', line 259

def to_html(context)
  @grid.set_attributes(@attributes)
    if RUBY_VERSION > "1.9"
      super << @grid.to_html(context).force_encoding('utf-8')
    else
      super << @grid.to_html(context)
    end
end