Class: GanttScaler
- Inherits:
-
Gtk::Viewport
- Object
- Gtk::Viewport
- GanttScaler
- Includes:
- Conf
- Defined in:
- lib/ListHolder/GanttHolder/GanttScaler.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
-
#gantt_holder ⇒ Object
readonly
Returns the value of attribute gantt_holder.
-
#widget ⇒ Object
readonly
Returns the value of attribute widget.
Instance Method Summary collapse
- #clear ⇒ Object
- #gantt ⇒ Object
-
#initialize(gantt_holder) ⇒ GanttScaler
constructor
A new instance of GanttScaler.
- #to_s ⇒ Object
- #update(notifier) ⇒ Object
Methods included from Conf
#get_conf, #load_conf, #save_conf, #set_conf
Constructor Details
#initialize(gantt_holder) ⇒ GanttScaler
Returns a new instance of GanttScaler.
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ListHolder/GanttHolder/GanttScaler.rb', line 7 def initialize(gantt_holder) @gantt_holder=gantt_holder super(gantt.hadjustment,Gtk::Adjustment.new(0,0,0,0,0,0)) # set_policy(Gtk::POLICY_NEVER,Gtk::POLICY_NEVER) # add_with_viewport(Gtk::EventBox.new.add(@widget=Gtk::Fixed.new)) add(@widget=Gtk::Fixed.new) @widget.set_height_request(gantt.list.columns_height) #set width the same as gantt's gantt.hadjustment.signal_connect("changed"){|vad| @widget.set_width_request(vad.upper) false } #font=get_conf(0,0,"list-cell-font")||"Sans 6" font="Sans 6" @widget.signal_connect("expose-event",font){|me,ev,font| cr=me.window.create_cairo_context pl=cr.create_pango_layout pl.set_font_description(Pango::FontDescription.new(font)) pl.set_wrap(Pango::Layout::WRAP_WORD_CHAR).set_ellipsize(Pango::Layout::ELLIPSIZE_NONE) unless gantt.points.size == 0 start=gantt.points.first/gantt.res gantt.points.each{|point| x=point/gantt.res-start cr.set_source_rgba(48.0/255,88.0/255,116.0/255,1).set_line_width(0.3) cr.move_to(x,3) cr.rel_line_to(0,@widget.allocation.height-6) 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,1) cr.show_pango_layout(pl) cr.stroke } end } end |
Instance Attribute Details
#gantt_holder ⇒ Object (readonly)
Returns the value of attribute gantt_holder.
48 49 50 |
# File 'lib/ListHolder/GanttHolder/GanttScaler.rb', line 48 def gantt_holder @gantt_holder end |
#widget ⇒ Object (readonly)
Returns the value of attribute widget.
48 49 50 |
# File 'lib/ListHolder/GanttHolder/GanttScaler.rb', line 48 def @widget end |
Instance Method Details
#clear ⇒ Object
49 50 51 |
# File 'lib/ListHolder/GanttHolder/GanttScaler.rb', line 49 def clear @widget.queue_draw_area(0, 0, @widget.allocation.width, @widget.allocation.height) end |
#gantt ⇒ Object
56 57 58 |
# File 'lib/ListHolder/GanttHolder/GanttScaler.rb', line 56 def gantt gantt_holder.gantt end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/ListHolder/GanttHolder/GanttScaler.rb', line 59 def to_s "Scaler of #{gantt}" end |
#update(notifier) ⇒ Object
52 53 54 55 |
# File 'lib/ListHolder/GanttHolder/GanttScaler.rb', line 52 def update(notifier) @widget.set_height_request(gantt.list.columns_height) clear end |