manqod 1.1532.0 → 1.1556.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,8 +23,15 @@ class ColumnsHeaderLayout
23
23
  end
24
24
  }
25
25
  @header_height = @header_height + @pop.header_line_width
26
+ if pop.print_with_gantt
27
+ @gantt=pop.list.holder.gantt.gantt
28
+ # @gr=@gantt.rectangle_by_id?(@iter[@pop.list.list_model.column_of_id])
29
+ min_x=pop.column_pos[:gantt]
30
+ gres=(@gantt.max_time-@gantt.min_time).to_f/pop.column_width[:gantt].to_f
31
+ end
32
+
26
33
  end
27
- attr_accessor :header_height, :y, :header_layouts
34
+ attr_reader :header_height, :y, :header_layouts, :pop
28
35
 
29
36
  def height
30
37
  @header_height
@@ -35,6 +42,7 @@ class ColumnsHeaderLayout
35
42
  end
36
43
 
37
44
  def draw(cr)
45
+ #column header
38
46
  header_layouts.each_pair{|key,layout|
39
47
  if @pop.draw_header_cell_borders
40
48
  cr.set_line_width(@pop.header_line_width)
@@ -50,7 +58,38 @@ class ColumnsHeaderLayout
50
58
  cr.show_pango_layout(layout)
51
59
  cr.stroke
52
60
  }
53
- cr.stroke
61
+ #gantt header/scaler
62
+ if pop.print_with_gantt
63
+ #border
64
+ cr.set_line_width(@pop.header_line_width).set_source_rgb(0,0,0).set_dash(100000)
65
+ cr.rectangle(pop.column_pos[:gantt],y,pop.column_width[:gantt].to_f,header_height)
66
+ cr.stroke
67
+ #points
68
+ pl=cr.create_pango_layout
69
+ pl.set_font_description(Pango::FontDescription.new(pop.gantt_cell_font))
70
+ pl.set_wrap(Pango::Layout::WRAP_WORD_CHAR).set_ellipsize(Pango::Layout::ELLIPSIZE_NONE)
71
+
72
+ gres=(@gantt.max_time-@gantt.min_time).to_f/pop.column_width[:gantt].to_f
73
+ start=nil
74
+ (@gantt.min_time).step(@gantt.max_time,@gantt.scaler_step){|i|
75
+ point=@gantt.time_round_res(i).to_i
76
+ start=point/gres if start.nil?
77
+
78
+ x=pop.column_pos[:gantt] + point/gres-start
79
+ cr.set_source_rgba(48.0/255,88.0/255,116.0/255,1).set_line_width(@pop.header_line_width)
80
+ cr.move_to(x,y+3)
81
+ cr.rel_line_to(0,y + header_height - 3)
82
+ cr.stroke
83
+
84
+ cr.set_source_rgba(48.0/255,88.0/255,116.0/255,0.8)
85
+
86
+ pl.set_text(Time.at(point).strftime_w(@gantt.scaler_format))
87
+ cr.move_to(x+2,y)
88
+ cr.show_pango_layout(pl)
89
+
90
+ cr.stroke
91
+ }
92
+ end
54
93
  end
55
94
  end
56
95
 
@@ -22,7 +22,7 @@ class HeaderLayout
22
22
 
23
23
  def draw(cr)
24
24
  cr.move_to(0,0) #position on begining of page
25
- cr.show_pango_layout(layout) #draw header
25
+ cr.show_pango_layout(layout) if @pop.print_title
26
26
  cr.show_pango_layout(tlayout) if @pop.print_date
27
27
  if @pop.draw_header_line
28
28
  cr.set_line_width(@pop.header_line_width)
@@ -9,10 +9,12 @@ class IterLayout
9
9
  @page=0
10
10
  @y=0
11
11
  @pop=pop
12
+ @iter=iter.clone
12
13
  @cell_layouts=Hash.new
13
14
  @insptext=""
14
15
  @cr=cr
15
16
  @crlw=0
17
+ @gr=nil
16
18
  #create the layouts for the cells, and find out the highest cell
17
19
  columns.each{|col|
18
20
  if col.printable?
@@ -21,14 +23,15 @@ class IterLayout
21
23
  text_cell.set_alignment(col.pango_layout_alignment)
22
24
  text_cell.set_wrap(Pango::Layout::WRAP_WORD_CHAR).set_ellipsize(Pango::Layout::ELLIPSIZE_NONE)
23
25
  text_to_display=case col.header["type"]
24
- when "gtk_duration" then Time.at(iter[col.colnum] || 0).strftime(col.duration_format)
25
- when "gtk_timestamp" then Time.at(iter[col.colnum] || 0).strftime(col.timestamp_format)
26
- when "gtk_const_text" then col.renderer.get_display(iter[col.colnum].to_s)
27
- when "gtk_const_combo","gtk_combo" then col.renderer.get_text_from_value(iter[col.colnum].to_s)
26
+ when "gtk_ordering" then col.path_format(@iter) unless iter.nil?
27
+ when "gtk_duration" then (@iter[col.colnum] || 0).to_i.strftime(col.duration_format)
28
+ when "gtk_timestamp" then Time.at(@iter[col.colnum] || 0).strftime(col.timestamp_format)
29
+ when "gtk_const_text" then col.renderer.get_display(@iter[col.colnum].to_s)
30
+ when "gtk_const_combo","gtk_combo" then col.renderer.get_text_from_value(@iter[col.colnum].to_s)
28
31
  else
29
32
  case col.data_type.to_s
30
- when "Bignum","Integer","Float" then number_format(iter[col.colnum],col.decimals_attribute)
31
- else iter[col.colnum].to_s
33
+ when "Bignum","Integer","Float" then number_format(@iter[col.colnum],col.decimals_attribute)
34
+ else @iter[col.colnum].to_s
32
35
  end
33
36
  end
34
37
  text_cell.set_text(text_to_display.to_s)
@@ -38,8 +41,20 @@ class IterLayout
38
41
  @insptext+="#{col.data_type}:#{text_cell.text}\t"
39
42
  end
40
43
  }
44
+ if pop.print_with_gantt
45
+ @gantt=pop.list.holder.gantt.gantt
46
+ @gr=@gantt.rectangle_by_id?(@iter[@pop.list.list_model.column_of_id])
47
+ min_x=pop.column_pos[:gantt]
48
+ end
49
+ if @gr
50
+ gres=(@gantt.max_time-@gantt.min_time).to_f/pop.column_width[:gantt].to_f
51
+ @gr.px1=min_x+(@gr.start-@gantt.min_time)/gres
52
+ @gr.pwidth=@gr.dur/gres
53
+ @gr.pheight=height
54
+ @gr.py1=@y
55
+ end
41
56
  end
42
- attr_accessor :page, :y, :pop, :cell_layouts, :row_height
57
+ attr_reader :page, :y, :pop, :cell_layouts, :row_height
43
58
 
44
59
  def set_line_above(line_above)
45
60
  if @line_above=line_above
@@ -54,12 +69,17 @@ class IterLayout
54
69
  end
55
70
  def set_y(newY)
56
71
  @y=newY
72
+ @gr.py1=@y if @gr
57
73
  self
58
74
  end
75
+ def set_page(page)
76
+ @page=page
77
+ end
59
78
 
60
79
  def draw(cr)
61
80
  min_x=60000
62
81
  max_x=0
82
+ cr.set_line_width(1).set_source_rgb(0,0,0).set_dash(100000).set_line_cap(Cairo::LineCap::ROUND)
63
83
  cell_layouts.each_pair{|key,layout|
64
84
  min_x=pop.column_pos[key] if min_x>pop.column_pos[key]
65
85
  max_x=pop.column_pos[key]+pop.column_width[key] if max_x<pop.column_pos[key]+pop.column_width[key]
@@ -67,7 +87,65 @@ class IterLayout
67
87
  cr.show_pango_layout(layout)
68
88
  cr.stroke
69
89
  }
70
-
90
+ if @gr
91
+ if @gr.has_child? then
92
+ #draw a parent
93
+ cr.set_line_width(1).set_source_rgba(0.1,0.1,0.1,0.9).set_dash(100000)
94
+ cr.move_to(@gr.px1,@gr.py2).line_to(@gr.px1,@gr.py).line_to(@gr.px2,@gr.py).line_to(@gr.px2,@gr.py2)
95
+ else
96
+ #fill rectangle
97
+ cr.set_line_width(0.3).set_dash(100000).set_source_rgba(0.1,0.1,0.1,0.04)
98
+ cr.rounded_rectangle(@gr.px1,@gr.py1+1,@gr.pwidth,@gr.pheight-2,2)
99
+ cr.fill
100
+ cr.stroke
101
+ #draw rectangle
102
+ cr.set_source_rgba(0.1,0.1,0.9,0.7)
103
+ cr.rounded_rectangle(@gr.px1,@gr.py1+1,@gr.pwidth,@gr.pheight-2,2)
104
+ cr.stroke
105
+ max_x=@gr.px2 if max_x<@gr.px2
106
+ end
107
+ cr.stroke
108
+ #successors arrow
109
+ @gr.successors.each_value{|pred|
110
+ if pred && pred.px1
111
+ cr.set_line_width(0.3).set_source_rgba(0.1,0.1,0.9,0.7).set_dash(100000)
112
+ xx1=[@gr.px1+10,@gr.px2].min
113
+ yy4=if @gr.py<pred.py1 then pred.py1-1 else pred.py2+1 end
114
+ yya=if @gr.py<pred.py then -2 else 2 end
115
+ cr.move_to(xx1,@gr.py)
116
+ cr.curve_to(pred.px,@gr.py,pred.px,@gr.py,pred.px,yy4)
117
+ #arrow
118
+ cr.move_to(pred.px,yy4).rel_line_to(-2,yya)
119
+ cr.move_to(pred.px,yy4).rel_line_to(2,yya)
120
+ cr.stroke
121
+ end
122
+ }
123
+ #start text
124
+ cr.set_source_rgba(0,0,0,0.9)
125
+ scell = cr.create_pango_layout.
126
+ set_font_description(Pango::FontDescription.new(pop.gantt_cell_font)).
127
+ set_text(@gr.fstart)
128
+ sheight = scell.size[1] / Pango::SCALE
129
+ swidth = scell.size[0] / Pango::SCALE
130
+ if @gr.px1-(swidth+2) > pop.column_pos[:gantt]
131
+ cr.move_to(@gr.px1-(swidth+2),@gr.py-sheight/2)
132
+ cr.show_pango_layout(scell)
133
+ cr.stroke
134
+ end
135
+ #finish text
136
+ fcell = cr.create_pango_layout.
137
+ set_font_description(Pango::FontDescription.new(pop.gantt_cell_font)).
138
+ set_text(@gr.ffinish)
139
+ fheight = scell.size[1] / Pango::SCALE
140
+ fwidth = scell.size[0] / Pango::SCALE
141
+ if @gr.px2+(fwidth+2) < pop.column_pos[:gantt] + pop.column_width[:gantt]
142
+ cr.move_to(@gr.px2+2,@gr.py-sheight/2)
143
+ cr.show_pango_layout(fcell)
144
+ cr.stroke
145
+ end
146
+ end
147
+
148
+ cr.set_source_rgba(0.1,0.1,0.1,0.7).set_dash(100000)
71
149
  if @line_above
72
150
  cr.set_line_width(@pop.sum_line_width)
73
151
  cr.move_to(min_x,y+@crlw)
@@ -16,7 +16,10 @@ class GanttHolder < Gtk::VBox
16
16
  set_size_request(0,0)
17
17
 
18
18
  list.signal_connect("cursor-changed"){|me| @gantt.update(self)}
19
- list.signal_connect("size-allocate"){|me,*a| @gantt.update(self)}
19
+ list.signal_connect("size-allocate"){|me,*a|
20
+ @scaler.update(self)
21
+ @gantt.update(self)
22
+ }
20
23
  end
21
24
  attr_reader :scaler, :gantt, :footer
22
25
 
@@ -28,7 +28,7 @@ class Gantt < Gtk::Viewport
28
28
  @points=Array.new
29
29
  @rectangles=Hash.new
30
30
  #time interval/pixel
31
- @min_time=0
31
+ @min_time=nil
32
32
  @res_idx=(list.gtk_attribute("gantt_res_idx") || '2').to_i
33
33
  @day0=(list.gtk_attribute("gantt_day0") || 'false') == 'true'
34
34
  @scaler_format=if @day0 then list.gtk_attribute("gantt_day0_header_format") || "%d %b\n%H:%M"
@@ -160,7 +160,7 @@ class Gantt < Gtk::Viewport
160
160
  attr_reader :gantt_holder, :res_idx, :min_time, :max_time, :points, :cursor_id
161
161
  attr_reader :start_column, :dur_column, :successors_column, :day0, :group_column, :group_color_column, :partial_column, :percentage_column
162
162
  attr_reader :start_editable, :successors_editable, :rectangles
163
- attr_reader :scaler_format, :time_format
163
+ attr_reader :scaler_format, :time_format, :min_coo, :max_coo
164
164
 
165
165
  def update(notifier)
166
166
  if list.model && model && list.list_model.column_of_gantt_start && list.list_model.column_of_gantt_duration
@@ -177,29 +177,31 @@ class Gantt < Gtk::Viewport
177
177
  @rectangles.clear
178
178
  create_rectangle(model.iter_first)
179
179
  #visible iters
180
- gmin=gmax=nil
180
+ @min_time=@max_time=nil
181
181
  @rectangles.each_value{|r|
182
- #initialize gmin,gmax
183
- gmin=gmax=r.x1 if gmin.nil?
184
- gmin=r.x1-scale_res if gmin>r.x1-scale_res
185
- gmax=r.x2+scale_res if gmax<r.x2+scale_res
182
+ @min_time=r.start if @min_time.nil? || @min_time>r.start
183
+ @max_time=r.finish if @max_time.nil? || @max_time<r.finish
186
184
  }
187
185
 
186
+ @min_time=0 if @min_time.nil?
187
+ @max_time=0 if @max_time.nil?
188
+ #extend min_time and max_time to fit resolution
189
+ @min_time=time_round_res(@min_time).to_i
190
+ @max_time=time_round_res(@max_time + scaler_step).to_i
188
191
  @points.clear
189
- @min_time=if day0 then 0 else gmin||0 end
190
- @max_time=gmax||0
192
+ @min_coo=if day0 then 0 else @min_time/res||0 end
193
+ @max_coo=@max_time/res||0
191
194
  #set our maximum width
192
- @widget.set_width_request(@max_time-@min_time)# if gmax && @widget.allocation.width < gmax-gmin
195
+ @widget.set_width_request(@max_coo-@min_coo)
193
196
  @cursor_id=list.get_cursor_id
194
- @rectangles.each{|rid,r|
195
- r.set_gantt_min_x(@min_time)
197
+ @rectangles.each_pair{|rid,r|
198
+ r.set_gantt_min_x(@min_coo)
196
199
  #center on selected
197
200
  hadjustment.clamp_page(r.x1-hadjustment.page_size/3,r.x2+hadjustment.page_size/3) if @cursor_id == rid
198
201
  #set up successors
199
202
  r.init_successors if successors_column
200
203
  #set up scaler points
201
- (r.x1-scale_res).step(r.x2+scale_res,scale_res){|i| @points.push(i.divmod(scale_res)[0])}
202
- }
204
+ time_round_res(r.start).to_i.step(time_round_res(r.finish+scaler_step).to_i,scaler_step){|i| @points.push(time_round_res(i).to_i)}}
203
205
  @points=@points.uniq.sort!
204
206
 
205
207
  #redraw
@@ -287,8 +289,19 @@ class Gantt < Gtk::Viewport
287
289
  def res
288
290
  Resolution[res_idx][0]
289
291
  end
290
- def scale_res
291
- Resolution[res_idx][1]
292
+ def scaler_step
293
+ if @scaler_format.include?("%H") then 60*24
294
+ elsif @scaler_format.include?("%d") then 60*60*24
295
+ elsif @scaler_format.include?("%W") then 60*60*24*7
296
+ else eerror("set gantt_header_format to a value which includes %W,%d or %H"); 60*24
297
+ end
298
+ end
299
+ def time_round_res(t)
300
+ Time.at(t.to_i).round(if @scaler_format.include?("%H") then "H"
301
+ elsif @scaler_format.include?("%d") then "d"
302
+ elsif @scaler_format.include?("%W") then "W"
303
+ else "d"
304
+ end)
292
305
  end
293
306
  def display_time(t)
294
307
  s=Time.at(t).strftime(@time_format)
@@ -38,9 +38,13 @@ class Rectangle
38
38
  @gantt_min_x=0
39
39
  iter_coordinates
40
40
  @visible=iter[gantt.list.list_model.column_of_visible]
41
+ @px1=nil
42
+ @pwidth=nil
43
+ @py=nil
44
+ @pheight=nil
41
45
  end
42
46
  attr_reader :iter, :iter_id, :height, :y1, :successors, :start, :dur, :group, :percentage
43
- attr_accessor :level
47
+ attr_accessor :level, :px1, :pwidth, :py1, :pheight
44
48
 
45
49
  def finish
46
50
  @start+@dur
@@ -101,17 +105,39 @@ class Rectangle
101
105
  def y
102
106
  y1+height/2
103
107
  end
108
+ def px
109
+ px1+pwidth/2 if px1 && pwidth
110
+ end
111
+ def py
112
+ py1+pheight/2 if py1 && pheight
113
+ end
114
+ def px2
115
+ px1+pwidth if px1 && pwidth
116
+ end
117
+ def py2
118
+ py1+pheight if py1 && pheight
119
+ end
120
+ def fstart #start formatted
121
+ if @gantt.list.column_by_id(@gantt.list.list_model.column_of_gantt_start['id'])
122
+ Time.at(start || 0).strftime(@gantt.list.column_by_id(@gantt.list.list_model.column_of_gantt_start['id']).timestamp_format)
123
+ end
124
+ end
125
+ def ffinish #finish formatted
126
+ if @gantt.list.column_by_id(@gantt.list.list_model.column_of_gantt_start['id'])
127
+ Time.at(finish || 0).strftime(@gantt.list.column_by_id(@gantt.list.list_model.column_of_gantt_start['id']).timestamp_format)
128
+ end
129
+ end
104
130
  def draw(cr,hilight=false)
105
131
  return self unless visible?
106
132
  #fill bar
107
- cr.set_source_rgba(@color.red.to_f/0x10000,@color.green.to_f/0x10000,@color.blue.to_f/0x10000,if @has_child then 0.05 else 0.7 end)
133
+ cr.set_source_rgba(@color.red.to_f/0x10000,@color.green.to_f/0x10000,@color.blue.to_f/0x10000,@has_child ? 0.05 : 0.7)
108
134
  cr.set_line_width(1).set_dash(100000)
109
135
  cr.rounded_rectangle(x1,y1,width,height,4)
110
136
  cr.fill
111
137
  cr.stroke
112
138
  #bar border
113
139
  if hilight
114
- cr.set_source_rgba(0.7,0.1,0.1,0.7)
140
+ cr.set_source_rgba(0.7,0.1,0.1,0.9)
115
141
  else
116
142
  cr.set_source_rgba(0,0,0,0.7)
117
143
  end
@@ -10,7 +10,7 @@ class GanttScaler < Gtk::Viewport
10
10
  # set_policy(Gtk::POLICY_NEVER,Gtk::POLICY_NEVER)
11
11
  # add_with_viewport(Gtk::EventBox.new.add(@widget=Gtk::Fixed.new))
12
12
  add(@widget=Gtk::Fixed.new)
13
- @widget.set_height_request(20)
13
+ @widget.set_height_request(gantt.list.columns_height)
14
14
  #set width the same as gantt's
15
15
  gantt.hadjustment.signal_connect("changed"){|vad|
16
16
  @widget.set_width_request(vad.upper)
@@ -21,23 +21,22 @@ class GanttScaler < Gtk::Viewport
21
21
  @widget.signal_connect("expose-event",font){|me,ev,font|
22
22
  cr=me.window.create_cairo_context
23
23
  pl=cr.create_pango_layout
24
- pl.set_font_description(Pango::FontDescription.new(font))#.set_width(@width*Pango::SCALE)
24
+ pl.set_font_description(Pango::FontDescription.new(font))
25
25
  pl.set_wrap(Pango::Layout::WRAP_WORD_CHAR).set_ellipsize(Pango::Layout::ELLIPSIZE_NONE)
26
26
 
27
27
  unless gantt.points.size == 0
28
- start=gantt.scale_res*gantt.points.first
28
+ start=gantt.points.first/gantt.res
29
29
 
30
30
  gantt.points.each{|point|
31
- x=point*gantt.scale_res-start
32
- cr.set_source_rgba(48.0/255,88.0/255,116.0/255,1)
33
- cr.set_line_width(0.5)
34
- cr.move_to(x,6)
35
- cr.rel_line_to(0,18)
31
+ x=point/gantt.res-start
32
+ cr.set_source_rgba(48.0/255,88.0/255,116.0/255,1).set_line_width(0.3)
33
+ cr.move_to(x,3)
34
+ cr.rel_line_to(0,@widget.allocation.height-6)
36
35
  cr.stroke
37
36
 
38
37
  cr.set_source_rgba(48.0/255,88.0/255,116.0/255,0.8)
39
38
 
40
- pl.set_text(Time.at((x+gantt.min_time)*gantt.res).strftime(gantt.scaler_format))
39
+ pl.set_text(Time.at(point).strftime_w(gantt.scaler_format))
41
40
  cr.move_to(x+2,1)
42
41
  cr.show_pango_layout(pl)
43
42
 
@@ -50,6 +49,10 @@ class GanttScaler < Gtk::Viewport
50
49
  def clear
51
50
  @widget.queue_draw_area(0, 0, @widget.allocation.width, @widget.allocation.height)
52
51
  end
52
+ def update(notifier)
53
+ @widget.set_height_request(gantt.list.columns_height)
54
+ clear
55
+ end
53
56
  def gantt
54
57
  gantt_holder.gantt
55
58
  end
@@ -14,7 +14,7 @@ class ListButtonHolder
14
14
  # list_buttons.set_layout_style(Gtk::ButtonBox::SPREAD)
15
15
  list_holder.list.add_observer(self)
16
16
  end
17
- attr_reader :holder, :list_buttons, :advanced_buttons, :list_holder, :advanced_filter, :sum_button, :archive_button, :groups
17
+ attr_reader :holder, :list_buttons, :advanced_buttons, :list_holder, :advanced_filter, :sum_button, :archive_button, :legends_button, :groups
18
18
 
19
19
  def update(notifier,reload=false)
20
20
  if notifier.list_id == @list_id && !reload
@@ -34,6 +34,7 @@ class ListButtonHolder
34
34
  @advanced_buttons=Gtk::HBox.new.set_homogeneous(false)
35
35
  advanced_buttons.pack_start(@advanced_filter=AdvancedFilterButton.new(@list_holder))
36
36
  advanced_buttons.pack_start(@sum_button=SumPanelButton.new(@list_holder))
37
+ advanced_buttons.pack_start(@legends_button=LegendsButton.new(@list_holder))
37
38
  advanced_buttons.pack_start(@archive_button=ArchiveButton.new(@list_holder))
38
39
  advanced_buttons.pack_start(@up_button=OrderingButton.new(@list_holder,Gtk::Stock::GO_UP))
39
40
  advanced_buttons.pack_start(@down_button=OrderingButton.new(@list_holder,Gtk::Stock::GO_DOWN))
@@ -67,6 +68,7 @@ class ListButtonHolder
67
68
  # admin_rows("select * from buttons where moditemid='#{list_holder.list.get_id}' and (grp_id in (-1,0) or (select count(id) from usergroups where userid='#{nick_id}' and groupid=grp_id)>0) order by oid"){|row|
68
69
  return if list_holder.list.list_model.drbmodel.nil?
69
70
  @archive_button.update
71
+ @legends_button.update
70
72
  @up_button.update
71
73
  @down_button.update
72
74
  list_holder.list.list_model.drbmodel.buttons(nick_id).each{|row|
@@ -0,0 +1,54 @@
1
+ #this file is part of manqod
2
+ #manqod is distributed under the CDDL licence
3
+ #the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
4
+
5
+ public
6
+ class LegendsButton < Gtk::ToggleButton
7
+ include Conf
8
+ def initialize(list_holder)
9
+ @list_holder=list_holder
10
+ @auto_update=false
11
+ super()
12
+ set_relief(Gtk::ReliefStyle::NONE)
13
+ set_image(Gtk::Image.new(Gtk::Stock::SELECT_COLOR,Gtk::IconSize.from_name(get_conf(0,0,"button-size"))))
14
+ signal_connect('toggled'){|me|
15
+ if me.active?
16
+ lmodel=Gtk::ListStore.new(String,String,String) #legend,foreground,background
17
+ column=Gtk::TreeViewColumn.new("Legend",Gtk::CellRendererText.new, {:text => 0, :foreground => 1, :background => 2})
18
+ @legend_window=Gtk::Window.new(Gtk::Window::POPUP).add(legend=Gtk::TreeView.new(lmodel))#.set_modal(true)
19
+ legend.selection.set_mode(Gtk::SelectionMode::NONE)
20
+ legend.append_column(column)
21
+ @list_holder.list.list_model.foreground_legend.each_pair{|color,legend|
22
+ iter=lmodel.append
23
+ iter[0]=legend
24
+ iter[1]=color
25
+ }
26
+ @list_holder.list.list_model.background_legend.each_pair{|color,legend|
27
+ iter=lmodel.append
28
+ iter[0]=legend
29
+ iter[2]=color
30
+ }
31
+ @legend_window.
32
+ realize.
33
+ set_transient_for(get_ancestor(Gtk::Window)).
34
+ move(get_ancestor(Gtk::Window).position[0] + allocation.x + allocation.width,
35
+ get_ancestor(Gtk::Window).position[1] + allocation.y + allocation.height - @legend_window.allocation.height).
36
+ show_all.
37
+ move(get_ancestor(Gtk::Window).position[0] + allocation.x + allocation.width,
38
+ get_ancestor(Gtk::Window).position[1] + allocation.y + allocation.height - @legend_window.allocation.height)
39
+
40
+ else
41
+ @legend_window.destroy unless @legend_window.nil? || @legend_window.destroyed?
42
+ end
43
+ }
44
+ end
45
+ attr_accessor :list_holder
46
+
47
+ def update
48
+ set_no_show_all(!(!@list_holder.list.list_model.foreground_legend.empty? || !@list_holder.list.list_model.background_legend.empty?))
49
+ set_visible(!@list_holder.list.list_model.foreground_legend.empty? || !@list_holder.list.list_model.background_legend.empty?)
50
+ end
51
+ def to_s
52
+ "LegendsButton of #{@list_holder}"
53
+ end
54
+ end