class ColumnsHeaderLayout

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)

Attributes

header_height[R]
header_layouts[R]
pop[R]
y[R]

Public Class Methods

new(pop,cr,columns,h_font) click to toggle source
# 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
#                       @gr=@gantt.rectangle_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

Public Instance Methods

draw(cr) click to toggle source
# 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() click to toggle source
# File lib/ListHolder/EditableList/ListPrintOperation/ColumnsHeaderLayout.rb, line 36
def height
        @header_height
end
set_y(newY) click to toggle source
# File lib/ListHolder/EditableList/ListPrintOperation/ColumnsHeaderLayout.rb, line 39
def set_y(newY)
        @y=newY
        self
end