Class: ColumnsHeaderLayout
- Inherits:
-
Object
- Object
- ColumnsHeaderLayout
- Defined in:
- lib/ListHolder/EditableList/ListPrintOperation/ColumnsHeaderLayout.rb
Overview
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])
Instance Attribute Summary collapse
-
#header_height ⇒ Object
readonly
Returns the value of attribute header_height.
-
#header_layouts ⇒ Object
readonly
Returns the value of attribute header_layouts.
-
#pop ⇒ Object
readonly
Returns the value of attribute pop.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #draw(cr) ⇒ Object
- #height ⇒ Object
-
#initialize(pop, cr, columns, h_font) ⇒ ColumnsHeaderLayout
constructor
A new instance of ColumnsHeaderLayout.
- #set_y(newY) ⇒ Object
Constructor Details
#initialize(pop, cr, columns, h_font) ⇒ ColumnsHeaderLayout
Returns a new instance of ColumnsHeaderLayout.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ListHolder/EditableList/ListPrintOperation/ColumnsHeaderLayout.rb', line 6 def initialize(pop,cr,columns,h_font) @header_height=0 @y=0 @header_layouts=Hash.new @pop=pop columns.each{|col| if col.printable? text_cell = cr.create_pango_layout text_cell.set_font_description(Pango::FontDescription.new(h_font)).set_width((pop.column_width[col.data]-@pop.header_line_width*2)*Pango::SCALE) text_cell.set_alignment(col.pango_layout_alignment) text_cell.set_wrap(Pango::Layout::WRAP_WORD_CHAR).set_ellipsize(Pango::Layout::ELLIPSIZE_NONE) #set_alignment(Pango::Layout::ALIGN_CENTER). text_cell.set_text(col.text) text_cell_text_height = text_cell.size[1].to_f / Pango::SCALE text_cell_text_width = text_cell.size[0].to_f / Pango::SCALE @header_height = text_cell_text_height+@pop.header_line_width*2 if @header_height < text_cell_text_height+@pop.header_line_width*2 header_layouts[col.data]=text_cell end } @header_height = @header_height + @pop.header_line_width if pop.print_with_gantt @gantt=pop.list.holder.gantt.gantt # @[email protected]_by_id?(@iter[@pop.list.list_model.column_of_id]) min_x=pop.column_pos[:gantt] gres=(@gantt.max_time-@gantt.min_time).to_f/pop.column_width[:gantt].to_f end end |
Instance Attribute Details
#header_height ⇒ Object (readonly)
Returns the value of attribute header_height.
34 35 36 |
# File 'lib/ListHolder/EditableList/ListPrintOperation/ColumnsHeaderLayout.rb', line 34 def header_height @header_height end |
#header_layouts ⇒ Object (readonly)
Returns the value of attribute header_layouts.
34 35 36 |
# File 'lib/ListHolder/EditableList/ListPrintOperation/ColumnsHeaderLayout.rb', line 34 def header_layouts @header_layouts end |
#pop ⇒ Object (readonly)
Returns the value of attribute pop.
34 35 36 |
# File 'lib/ListHolder/EditableList/ListPrintOperation/ColumnsHeaderLayout.rb', line 34 def pop @pop end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
34 35 36 |
# File 'lib/ListHolder/EditableList/ListPrintOperation/ColumnsHeaderLayout.rb', line 34 def y @y end |
Instance Method Details
#draw(cr) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ListHolder/EditableList/ListPrintOperation/ColumnsHeaderLayout.rb', line 44 def draw(cr) #column header header_layouts.each_pair{|key,layout| if @pop.draw_header_cell_borders cr.set_line_width(@pop.header_line_width) cr.rectangle(@pop.column_pos[key],y,@pop.column_width[key],header_height) if @pop.fill_header_background cr.move_to(@pop.column_pos[key]+@pop.header_line_width+3,y+@pop.header_line_width+3) cr.set_source_rgb(0.9,0.9,0.9) cr.fill_preserve() cr.set_source_rgb(0,0,0) end end cr.move_to(@pop.column_pos[key]+@pop.header_line_width,y+@pop.header_line_width) cr.show_pango_layout(layout) cr.stroke } #gantt header/scaler if pop.print_with_gantt #border cr.set_line_width(@pop.header_line_width).set_source_rgb(0,0,0).set_dash(100000) cr.rectangle(pop.column_pos[:gantt],y,pop.column_width[:gantt].to_f,header_height) cr.stroke #points pl=cr.create_pango_layout pl.set_font_description(Pango::FontDescription.new(pop.gantt_cell_font)) pl.set_wrap(Pango::Layout::WRAP_WORD_CHAR).set_ellipsize(Pango::Layout::ELLIPSIZE_NONE) gres=(@gantt.max_time-@gantt.min_time).to_f/pop.column_width[:gantt].to_f start=nil (@gantt.min_time).step(@gantt.max_time,@gantt.scaler_step){|i| point=@gantt.time_round_res(i).to_i start=point/gres if start.nil? x=pop.column_pos[:gantt] + point/gres-start cr.set_source_rgba(48.0/255,88.0/255,116.0/255,1).set_line_width(@pop.header_line_width) cr.move_to(x,y+3) cr.rel_line_to(0,y + header_height - 3) cr.stroke cr.set_source_rgba(48.0/255,88.0/255,116.0/255,0.8) pl.set_text(Time.at(point).strftime_w(@gantt.scaler_format)) cr.move_to(x+2,y) cr.show_pango_layout(pl) cr.stroke } end end |
#height ⇒ Object
36 37 38 |
# File 'lib/ListHolder/EditableList/ListPrintOperation/ColumnsHeaderLayout.rb', line 36 def height @header_height end |
#set_y(newY) ⇒ Object
39 40 41 42 |
# File 'lib/ListHolder/EditableList/ListPrintOperation/ColumnsHeaderLayout.rb', line 39 def set_y(newY) @y=newY self end |