extract-curves 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +21 -0
- data/bin/ec_rect2polar +22 -0
- data/bin/ec_rect2polar.rb +22 -0
- data/bin/ec_rev_lines +5 -0
- data/bin/ec_rev_lines.rb +5 -0
- data/bin/ec_sph_area +30 -0
- data/bin/ec_sph_area.rb +30 -0
- data/bin/extract_curves +1670 -0
- data/bin/extract_curves.rb +1670 -0
- data/ruby_ext/pav/cstr.c +82 -0
- data/ruby_ext/pav/cstr.h +17 -0
- data/ruby_ext/pav/extconf.rb +22 -0
- data/ruby_ext/pav/pav.c +162 -0
- data/ruby_ext/pav/pgtk.c +40 -0
- data/ruby_ext/pav/pgtk.h +14 -0
- data/ruby_ext/pav/pix.c +806 -0
- data/ruby_ext/pav/pix.h +236 -0
- data/ruby_ext/pav/t.rb +35 -0
- data/ruby_ext/pav/t1.rb +35 -0
- data/ruby_libs/pav/attr_cache.rb +211 -0
- data/ruby_libs/pav/attr_cache.t1.rb +32 -0
- data/ruby_libs/pav/cache.rb +31 -0
- data/ruby_libs/pav/collection/std.rb +58 -0
- data/ruby_libs/pav/dbg_log.rb +458 -0
- data/ruby_libs/pav/floatsio.rb +53 -0
- data/ruby_libs/pav/generator_cache.rb +165 -0
- data/ruby_libs/pav/graph/node.rb +602 -0
- data/ruby_libs/pav/graph/node_grp.rb +865 -0
- data/ruby_libs/pav/gtk.rb +6 -0
- data/ruby_libs/pav/gtk/button.rb +118 -0
- data/ruby_libs/pav/gtk/dialog.rb +29 -0
- data/ruby_libs/pav/gtk/guiobj.rb +772 -0
- data/ruby_libs/pav/gtk/icons.rb +124 -0
- data/ruby_libs/pav/gtk/rulers.rb +264 -0
- data/ruby_libs/pav/gtk/toolbar.rb +189 -0
- data/ruby_libs/pav/guiobj.rb +2 -0
- data/ruby_libs/pav/guiobj/info_asm.rb +41 -0
- data/ruby_libs/pav/guiobj/method.rb +211 -0
- data/ruby_libs/pav/guiobj/obj.rb +134 -0
- data/ruby_libs/pav/guiobj/signals.rb +9 -0
- data/ruby_libs/pav/heap.rb +54 -0
- data/ruby_libs/pav/icons/alt_handle.xcf +0 -0
- data/ruby_libs/pav/icons/alt_handle.xpm +3832 -0
- data/ruby_libs/pav/icons/alt_handle_hover.xcf +0 -0
- data/ruby_libs/pav/icons/alt_handle_hover.xpm +3368 -0
- data/ruby_libs/pav/icons/alt_handle_pressed.xcf +0 -0
- data/ruby_libs/pav/icons/alt_handle_pressed.xpm +3828 -0
- data/ruby_libs/pav/icons/blob.gif +0 -0
- data/ruby_libs/pav/icons/clover_base.xcf +0 -0
- data/ruby_libs/pav/icons/contour.gif +0 -0
- data/ruby_libs/pav/icons/contour.xcf +0 -0
- data/ruby_libs/pav/icons/contour_carpet.gif +0 -0
- data/ruby_libs/pav/icons/contour_carpet.xcf +0 -0
- data/ruby_libs/pav/icons/curve.gif +0 -0
- data/ruby_libs/pav/icons/curve.xcf +0 -0
- data/ruby_libs/pav/icons/curve_carpet.gif +0 -0
- data/ruby_libs/pav/icons/curve_carpet.xcf +0 -0
- data/ruby_libs/pav/icons/expand_base.xcf +0 -0
- data/ruby_libs/pav/icons/expand_closed.xpm +1791 -0
- data/ruby_libs/pav/icons/expand_closed_hover.xpm +1775 -0
- data/ruby_libs/pav/icons/expand_open.xpm +1788 -0
- data/ruby_libs/pav/icons/expand_open_hover.xpm +1752 -0
- data/ruby_libs/pav/icons/extract_curves/extract_curves-icon-rgb.ppm +14 -0
- data/ruby_libs/pav/icons/extract_curves/extract_curves-logo-rgb.gif +0 -0
- data/ruby_libs/pav/icons/extract_curves/extract_curves-logo-rgb.xcf +0 -0
- data/ruby_libs/pav/icons/extract_curves/trace_mark.xcf +0 -0
- data/ruby_libs/pav/icons/extract_curves/trace_mark.xpm +38 -0
- data/ruby_libs/pav/icons/handle.xcf +0 -0
- data/ruby_libs/pav/icons/handle.xpm +213 -0
- data/ruby_libs/pav/icons/loop.gif +0 -0
- data/ruby_libs/pav/icons/loop.xcf +0 -0
- data/ruby_libs/pav/icons/loop_carpet.gif +0 -0
- data/ruby_libs/pav/icons/loop_carpet.xcf +0 -0
- data/ruby_libs/pav/icons/next.xpm +29 -0
- data/ruby_libs/pav/icons/next_hover.xpm +315 -0
- data/ruby_libs/pav/icons/next_pressed.xpm +144 -0
- data/ruby_libs/pav/icons/prev.xpm +29 -0
- data/ruby_libs/pav/icons/prev_hover.xpm +315 -0
- data/ruby_libs/pav/icons/prev_pressed.xpm +144 -0
- data/ruby_libs/pav/icons/shaved-core.gif +0 -0
- data/ruby_libs/pav/icons/vnext.xpm +29 -0
- data/ruby_libs/pav/icons/vprev.xpm +29 -0
- data/ruby_libs/pav/numeric/ext.rb +21 -0
- data/ruby_libs/pav/patterns/hsep.gif +0 -0
- data/ruby_libs/pav/patterns/tnode.gif +0 -0
- data/ruby_libs/pav/patterns/tnode_w_link.gif +0 -0
- data/ruby_libs/pav/patterns/vlink.gif +0 -0
- data/ruby_libs/pav/patterns/vsep.gif +0 -0
- data/ruby_libs/pav/patterns/yg_hrope.xpm +492 -0
- data/ruby_libs/pav/patterns/yg_hrope_thick.xpm +1904 -0
- data/ruby_libs/pav/patterns/yg_hrope_thin.xpm +130 -0
- data/ruby_libs/pav/patterns/yg_tnode.xpm +180 -0
- data/ruby_libs/pav/patterns/yg_tnode_thick.xpm +615 -0
- data/ruby_libs/pav/patterns/yg_tnode_thin.xpm +55 -0
- data/ruby_libs/pav/patterns/yg_tnode_w_link.xpm +190 -0
- data/ruby_libs/pav/patterns/yg_tnode_w_link_thick.xpm +676 -0
- data/ruby_libs/pav/patterns/yg_tnode_w_link_thin.xpm +62 -0
- data/ruby_libs/pav/patterns/yg_vrope.xpm +563 -0
- data/ruby_libs/pav/patterns/yg_vrope_thick.xpm +2047 -0
- data/ruby_libs/pav/patterns/yg_vrope_thin.xpm +166 -0
- data/ruby_libs/pav/pav_find.rb +90 -0
- data/ruby_libs/pav/pix.rb +402 -0
- data/ruby_libs/pav/pix/aapix.rb +378 -0
- data/ruby_libs/pav/pix/blob.rb +678 -0
- data/ruby_libs/pav/pix/circle.rb +73 -0
- data/ruby_libs/pav/pix/contour.rb +676 -0
- data/ruby_libs/pav/pix/contour/calc_situations.rb +9 -0
- data/ruby_libs/pav/pix/contour/carp_calc.rb +212 -0
- data/ruby_libs/pav/pix/contour/situations.dmp +0 -0
- data/ruby_libs/pav/pix/contour/situations.rb +21 -0
- data/ruby_libs/pav/pix/curve.rb +1544 -0
- data/ruby_libs/pav/pix/img_obj.rb +865 -0
- data/ruby_libs/pav/pix/node.rb +159 -0
- data/ruby_libs/pav/pix/shaved_core.rb +697 -0
- data/ruby_libs/pav/pix/subpix.rb +212 -0
- data/ruby_libs/pav/rand_accessible.rb +16 -0
- data/ruby_libs/pav/rangeset.rb +63 -0
- data/ruby_libs/pav/search.rb +210 -0
- data/ruby_libs/pav/set.rb +130 -0
- data/ruby_libs/pav/string/bits.rb +523 -0
- data/ruby_libs/pav/string/ext.rb +58 -0
- data/ruby_libs/pav/string/observable.rb +155 -0
- data/ruby_libs/pav/string/text.rb +79 -0
- data/ruby_libs/pav/string/words.rb +42 -0
- data/ruby_libs/pav/sub_arr.rb +56 -0
- data/ruby_libs/pav/traced_obj.rb +79 -0
- data/web/index.html +280 -0
- data/web/media/icons/alt_handle.xcf +0 -0
- data/web/media/icons/alt_handle.xpm +3832 -0
- data/web/media/icons/alt_handle_hover.xcf +0 -0
- data/web/media/icons/alt_handle_hover.xpm +3368 -0
- data/web/media/icons/alt_handle_pressed.xcf +0 -0
- data/web/media/icons/alt_handle_pressed.xpm +3828 -0
- data/web/media/icons/blob.gif +0 -0
- data/web/media/icons/clover_base.xcf +0 -0
- data/web/media/icons/contour.gif +0 -0
- data/web/media/icons/contour.xcf +0 -0
- data/web/media/icons/contour_carpet.gif +0 -0
- data/web/media/icons/contour_carpet.xcf +0 -0
- data/web/media/icons/curve.gif +0 -0
- data/web/media/icons/curve.xcf +0 -0
- data/web/media/icons/curve_carpet.gif +0 -0
- data/web/media/icons/curve_carpet.xcf +0 -0
- data/web/media/icons/expand_base.xcf +0 -0
- data/web/media/icons/expand_closed.xpm +1791 -0
- data/web/media/icons/expand_closed_hover.xpm +1775 -0
- data/web/media/icons/expand_open.xpm +1788 -0
- data/web/media/icons/expand_open_hover.xpm +1752 -0
- data/web/media/icons/extract_curves/extract_curves-icon-rgb.ppm +14 -0
- data/web/media/icons/extract_curves/extract_curves-logo-rgb.gif +0 -0
- data/web/media/icons/extract_curves/extract_curves-logo-rgb.xcf +0 -0
- data/web/media/icons/extract_curves/trace_mark.xcf +0 -0
- data/web/media/icons/extract_curves/trace_mark.xpm +38 -0
- data/web/media/icons/handle.xcf +0 -0
- data/web/media/icons/handle.xpm +213 -0
- data/web/media/icons/loop.gif +0 -0
- data/web/media/icons/loop.xcf +0 -0
- data/web/media/icons/loop_carpet.gif +0 -0
- data/web/media/icons/loop_carpet.xcf +0 -0
- data/web/media/icons/next.xpm +29 -0
- data/web/media/icons/next_hover.xpm +315 -0
- data/web/media/icons/next_pressed.xpm +144 -0
- data/web/media/icons/prev.xpm +29 -0
- data/web/media/icons/prev_hover.xpm +315 -0
- data/web/media/icons/prev_pressed.xpm +144 -0
- data/web/media/icons/shaved-core.gif +0 -0
- data/web/media/icons/vnext.xpm +29 -0
- data/web/media/icons/vprev.xpm +29 -0
- data/web/media/title.jpeg +0 -0
- data/web/media/title.xcf +0 -0
- data/web/stylesheets/default.css +20 -0
- metadata +229 -0
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'gtk2'
|
2
|
+
require 'pav/pav_find'
|
3
|
+
require 'pav/string/ext'
|
4
|
+
|
5
|
+
module PGtk
|
6
|
+
|
7
|
+
pgtk_symbs = [[:"pgtk-handle", 'Handle', 'alt_handle.xpm'],
|
8
|
+
[:"pgtk-handle-hover", 'Handle', 'alt_handle_hover.xpm'],
|
9
|
+
[:"pgtk-handle-pressed", 'Handle', 'alt_handle_pressed.xpm'],
|
10
|
+
[:"pgtk-previous", 'Previous', 'prev.xpm'],
|
11
|
+
[:"pgtk-previous-hover", 'Previous', 'prev_hover.xpm'],
|
12
|
+
[:"pgtk-previous-pressed", 'Previous', 'prev_pressed.xpm'],
|
13
|
+
[:"pgtk-next", 'Next', 'next.xpm'],
|
14
|
+
[:"pgtk-next-hover", 'Next', 'next_hover.xpm'],
|
15
|
+
[:"pgtk-next-pressed", 'Next', 'next_pressed.xpm'],
|
16
|
+
[:"pgtk-vertical-previous", 'Vertical previous', 'vprev.xpm'],
|
17
|
+
[:"pgtk-vertical-next", 'Vertical next', 'vnext.xpm'],
|
18
|
+
[:"pgtk-blob", 'Blob', 'blob.gif'],
|
19
|
+
[:"pgtk-contour", 'Contour', 'contour.gif'],
|
20
|
+
[:"pgtk-contour-carpet", 'Contour carpet', 'contour_carpet.gif'],
|
21
|
+
[:"pgtk-curve", 'Curve', 'curve.gif'],
|
22
|
+
[:"pgtk-curve-carpet", 'Curve carpet', 'curve_carpet.gif'],
|
23
|
+
[:"pgtk-loop", 'Loop', 'loop.gif'],
|
24
|
+
[:"pgtk-loop-carpet", 'Loop carpet', 'loop_carpet.gif'],
|
25
|
+
[:"pgtk-shaved-core", 'Shaved core', 'shaved_core.gif'],
|
26
|
+
[:"pgtk-collapse", 'Collapse', 'expand_open.xpm'],
|
27
|
+
[:"pgtk-collapse-hover", 'Collapse', 'expand_open_hover.xpm'],
|
28
|
+
[:"pgtk-expand", 'Expand', 'expand_closed.xpm'],
|
29
|
+
[:"pgtk-expand-hover", 'Expand', 'expand_closed_hover.xpm']]
|
30
|
+
pgtk_symbs.each { |s| Gtk::Stock.add(s[0], s[1]) }
|
31
|
+
ifactory = Gtk::IconFactory.new
|
32
|
+
ifactory.add_default
|
33
|
+
pb_handle = pb_vhandle = nil
|
34
|
+
found_cnt = 0
|
35
|
+
PavFind.pfind($:) { |path|
|
36
|
+
pgtk_symbs.each { |s|
|
37
|
+
if path.ends_with("pav/icons/" + s[2]) && !s[3]
|
38
|
+
s[3] = Gdk::Pixbuf.new(path)
|
39
|
+
break if (found_cnt += 1) >= pgtk_symbs.length
|
40
|
+
end
|
41
|
+
}
|
42
|
+
break if found_cnt >= pgtk_symbs.length
|
43
|
+
}
|
44
|
+
pgtk_symbs.each { |s| ifactory.add(s[0].to_s, Gtk::IconSet.new(s[3])) }
|
45
|
+
|
46
|
+
@icon_cache = {}
|
47
|
+
|
48
|
+
def self.find_icon_file(fpath)
|
49
|
+
PavFind.pfind($:) { |path|
|
50
|
+
return path if path.ends_with(fpath)
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.image_from_file(fpath)
|
55
|
+
Gtk::Image.new(self.find_icon_file(fpath))
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.stock_pixbuf_of_size(stock_id, w, h)
|
59
|
+
if (tmp = @icon_cache[[stock_id, w, h]])
|
60
|
+
return tmp if tmp.kind_of?(Gdk::Pixbuf)
|
61
|
+
end
|
62
|
+
icon_set = Gtk::IconFactory.lookup_default(stock_id.to_s) ||
|
63
|
+
Gtk::IcontFactory.lookup_default("gtk-missing-image")
|
64
|
+
max_size = nil
|
65
|
+
max_sz = [0,0]
|
66
|
+
found_size = nil
|
67
|
+
icon_set.sizes.each { |size|
|
68
|
+
if (sz=Gtk::IconSize.lookup(size)) == [w, h]
|
69
|
+
found_size = size
|
70
|
+
end
|
71
|
+
if sz[0]*sz[1] > max_sz[0]*max_sz[1]
|
72
|
+
max_size = size
|
73
|
+
max_sz = Gtk::IconSize.lookup(max_size)
|
74
|
+
end
|
75
|
+
}
|
76
|
+
if found_size
|
77
|
+
wd = Gtk::Window.new
|
78
|
+
pb=wd.render_icon(stock_id, found_size,
|
79
|
+
stock_id.to_s + ":#{w}x#{h}")
|
80
|
+
wd.destroy
|
81
|
+
@icon_cache[[stock_id, w, h]] = pb
|
82
|
+
else
|
83
|
+
wd = Gtk::Window.new
|
84
|
+
pb=wd.render_icon(stock_id,max_size,stock_id.to_s+":#{w}x#{h}").
|
85
|
+
scale(w, h, Gdk::Pixbuf::INTERP_BILINEAR)
|
86
|
+
wd.destroy
|
87
|
+
(@icon_cache[[stock_id, w, h]] = pb)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.stock_image_of_size(stock_id, w, h)
|
92
|
+
Gtk::Image.new(self.stock_pixbuf_of_size(stock_id, w, h))
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.stock_icon_btn_of_size(window, stock_id, w, h)
|
96
|
+
res = Gtk::Button.new << self.stock_image_of_size(stock_id, w-10, h-10)
|
97
|
+
res.set_size_request(w, h)
|
98
|
+
res
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.stock_icon_tool_btn_of_size(window, stock_id, w, h)
|
102
|
+
res = Gtk::ToolButton.new("")
|
103
|
+
res.icon_widget = self.stock_image_of_size(stock_id, w-10, h-10)
|
104
|
+
res.set_size_request(w, h)
|
105
|
+
res
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.image_new(spec, deflt_size=Gtk::IconSize::BUTTON, deflt_padding_x=3,
|
109
|
+
deflt_padding_y=3)
|
110
|
+
if spec.kind_of?(Gtk::Image)
|
111
|
+
return spec
|
112
|
+
elsif spec.kind_of?(Gdk::Pixbuf)
|
113
|
+
img = Gtk::Image.new(icon)
|
114
|
+
img.set_padding(deflt_padding_x, deflt_padding_y)
|
115
|
+
return img
|
116
|
+
elsif spec.kind_of?(String) || spec.kind_of?(Symbol)
|
117
|
+
img = Gtk::Image.new(spec, deflt_size)
|
118
|
+
img.set_padding(deflt_padding_x, deflt_padding_y)
|
119
|
+
return img
|
120
|
+
end
|
121
|
+
nil
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,264 @@
|
|
1
|
+
require 'pav/gtk/icons'
|
2
|
+
|
3
|
+
module PGtk
|
4
|
+
|
5
|
+
module MHSep
|
6
|
+
@@hpat_pixbuf = Gdk::Pixbuf.new(PGtk.find_icon_file(
|
7
|
+
'patterns/yg_hrope_thin.xpm'))
|
8
|
+
|
9
|
+
def hsep_pixbuf=(pixbuf)
|
10
|
+
@hsep_pixbuf = pixbuf
|
11
|
+
@hsep_pb_width = @hsep_pixbuf.width
|
12
|
+
@hsep_pb_height = @hsep_pixbuf.height
|
13
|
+
self.set_size_request(-1, @hsep_pb_height)
|
14
|
+
end
|
15
|
+
|
16
|
+
def hsep_init(pixbuf=@@hpat_pixbuf)
|
17
|
+
self.hsep_pixbuf = pixbuf
|
18
|
+
@hsep_expose_cb = proc { |wgt, event|
|
19
|
+
x = event.area.x
|
20
|
+
((x / @hsep_pb_width) * @hsep_pb_width).
|
21
|
+
step(x+event.area.width, @hsep_pb_width) { |x0|
|
22
|
+
wgt.window.draw_pixbuf(wgt.style.black_gc,
|
23
|
+
@hsep_pixbuf, 0, 0, x0, 0,
|
24
|
+
@hsep_pb_width, @hsep_pb_height,
|
25
|
+
Gdk::RGB::Dither::NORMAL, 0, 0)
|
26
|
+
}
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class HSep < Gtk::DrawingArea
|
32
|
+
include MHSep
|
33
|
+
|
34
|
+
def initialize
|
35
|
+
super()
|
36
|
+
self.hsep_init
|
37
|
+
self.signal_connect('expose_event', &@hsep_expose_cb)
|
38
|
+
end
|
39
|
+
|
40
|
+
def pixbuf=(pixbuf)
|
41
|
+
self.hsep_pixbuf = pixbuf
|
42
|
+
self.queue_draw
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
module MVSep
|
47
|
+
@@vpat_pixbuf = Gdk::Pixbuf.new(PGtk.find_icon_file(
|
48
|
+
'patterns/yg_vrope_thin.xpm'))
|
49
|
+
|
50
|
+
def vsep_pixbuf=(pixbuf)
|
51
|
+
@vsep_pixbuf = pixbuf
|
52
|
+
@vsep_pb_width = @vsep_pixbuf.width
|
53
|
+
@vsep_pb_height = @vsep_pixbuf.height
|
54
|
+
self.set_size_request(@vsep_pb_width, -1)
|
55
|
+
end
|
56
|
+
|
57
|
+
def vsep_init(pixbuf=@@vpat_pixbuf)
|
58
|
+
self.vsep_pixbuf = pixbuf
|
59
|
+
@vsep_expose_cb = proc { |wgt, event|
|
60
|
+
y = event.area.y
|
61
|
+
((y / @vsep_pb_height) * @vsep_pb_height).
|
62
|
+
step(y+event.area.height, @vsep_pb_height) { |y0|
|
63
|
+
wgt.window.draw_pixbuf(wgt.style.black_gc,
|
64
|
+
@vsep_pixbuf, 0, 0, 0, y0,
|
65
|
+
@vsep_pb_width, @vsep_pb_height,
|
66
|
+
Gdk::RGB::Dither::NORMAL, 0, 0)
|
67
|
+
}
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class VSep < Gtk::DrawingArea
|
73
|
+
include MVSep
|
74
|
+
|
75
|
+
def initialize
|
76
|
+
super()
|
77
|
+
self.vsep_init
|
78
|
+
self.signal_connect('expose_event', &@vsep_expose_cb)
|
79
|
+
end
|
80
|
+
|
81
|
+
def pixbuf=(pixbuf)
|
82
|
+
self.vsep_pixbuf = pixbuf
|
83
|
+
self.queue_draw
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
class Sep < Gtk::DrawingArea
|
88
|
+
attr_reader :orientation
|
89
|
+
include MHSep
|
90
|
+
include MVSep
|
91
|
+
|
92
|
+
def initialize(orient=Gtk::Orientation::HORIZONTAL)
|
93
|
+
@orientation = orient
|
94
|
+
super()
|
95
|
+
self.hsep_init
|
96
|
+
self.vsep_init
|
97
|
+
if orient == Gtk::Orientation::HORIZONTAL
|
98
|
+
@expose_cb_id = self.signal_connect('expose_event',
|
99
|
+
&@hsep_expose_cb)
|
100
|
+
else
|
101
|
+
@expose_cb_id = self.signal_connect('expose_event',
|
102
|
+
&@vsep_expose_cb)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def orientation=(orient)
|
107
|
+
if orient == Gtk::Orientation::HORIZONTAL
|
108
|
+
return if @orientation == Gtk::Orientation::HORIZONTAL
|
109
|
+
self.signal_handler_disconnect(@expose_cb_id)
|
110
|
+
@expose_cb_id = self.signal_connect('expose_event',
|
111
|
+
&@hsep_expose_cb)
|
112
|
+
@orientation = Gtk::Orientation::HORIZONTAL
|
113
|
+
else
|
114
|
+
return if @orientation == Gtk::Orientation::VERTICAL
|
115
|
+
self.signal_handler_disconnect(@expose_cb_id)
|
116
|
+
@expose_cb_id = self.signal_connect('expose_event',
|
117
|
+
&@vsep_expose_cb)
|
118
|
+
@orientation = Gtk::Orientation::VERTICAL
|
119
|
+
end
|
120
|
+
self.queue_draw
|
121
|
+
end
|
122
|
+
|
123
|
+
def pixbuf=(pixbuf)
|
124
|
+
if @orientation == Gtk::Orientation::HORIZONTAL
|
125
|
+
self.hsep_pixbuf = pixbuf
|
126
|
+
else
|
127
|
+
self.vsep_pixbuf = pixbuf
|
128
|
+
end
|
129
|
+
self.queue_draw
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
module MTreeLink
|
134
|
+
@@tlink_pixbuf = Gdk::Pixbuf.new(PGtk.find_icon_file(
|
135
|
+
'patterns/yg_vrope.xpm'))
|
136
|
+
|
137
|
+
def tlink_pixbuf=(pixbuf)
|
138
|
+
@tlink_pixbuf = pixbuf
|
139
|
+
@tlink_pb_width = @tlink_pixbuf.width
|
140
|
+
@tlink_pb_height = @tlink_pixbuf.height
|
141
|
+
self.set_size_request(@tlink_pb_width, -1)
|
142
|
+
end
|
143
|
+
|
144
|
+
def tlink_init(pixbuf=@@tlink_pixbuf)
|
145
|
+
self.tlink_pixbuf = pixbuf
|
146
|
+
@tlink_expose_cb = proc { |wgt, event|
|
147
|
+
y = event.area.y
|
148
|
+
((y / @tlink_pb_height) * @tlink_pb_height).
|
149
|
+
step(y+event.area.height, @tlink_pb_height) { |y0|
|
150
|
+
wgt.window.draw_pixbuf(wgt.style.black_gc,
|
151
|
+
@tlink_pixbuf, 0, 0, 0, y0,
|
152
|
+
@tlink_pb_width, @tlink_pb_height,
|
153
|
+
Gdk::RGB::Dither::NORMAL, 0, 0)
|
154
|
+
}
|
155
|
+
}
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
module MTreeEndNode
|
160
|
+
@@tend_node_pixbuf = Gdk::Pixbuf.new(
|
161
|
+
PGtk.find_icon_file('patterns/yg_tnode.xpm'))
|
162
|
+
end
|
163
|
+
|
164
|
+
module MTreeLinkNode
|
165
|
+
@@tlink_node_pixbuf = Gdk::Pixbuf.new(
|
166
|
+
PGtk.find_icon_file('patterns/yg_tnode_w_link.xpm'))
|
167
|
+
end
|
168
|
+
|
169
|
+
class TreeLink < Gtk::DrawingArea
|
170
|
+
include MTreeLink
|
171
|
+
|
172
|
+
def initialize
|
173
|
+
super()
|
174
|
+
self.tlink_init
|
175
|
+
@expose_cb_id =
|
176
|
+
self.signal_connect('expose_event', &@tlink_expose_cb)
|
177
|
+
@enabled = true
|
178
|
+
end
|
179
|
+
|
180
|
+
def disable
|
181
|
+
return unless @enabled
|
182
|
+
self.signal_handler_disconnect(@expose_cb_id)
|
183
|
+
@enabled = false
|
184
|
+
self.queue_draw
|
185
|
+
end
|
186
|
+
|
187
|
+
def enable
|
188
|
+
return if @enabled
|
189
|
+
@expose_cb_id =
|
190
|
+
self.signal_connect('expose_event', &@tlink_expose_cb)
|
191
|
+
@enabled = true
|
192
|
+
self.queue_draw
|
193
|
+
end
|
194
|
+
|
195
|
+
def pixbuf=(pixbuf)
|
196
|
+
self.tlink_pixbuf = pixbuf
|
197
|
+
self.signal_handler_disconnect(@expose_cb_id)
|
198
|
+
@expose_cb_id =
|
199
|
+
self.signal_connect('expose_event', &@tlink_expose_cb)
|
200
|
+
self.queue_draw
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
class TreeNodePadding < Gtk::VBox
|
205
|
+
include MTreeEndNode
|
206
|
+
include MTreeLinkNode
|
207
|
+
|
208
|
+
attr_reader :end_node, :expand_btn, :title_box, :end_node_pixbuf,
|
209
|
+
:link_node_pixbuf
|
210
|
+
|
211
|
+
def initialize(end_node=false)
|
212
|
+
super(false, 0)
|
213
|
+
self.pack_start(@title_box=Gtk::HBox.new(false,0),false,false,0)
|
214
|
+
@end_node_pixbuf = @@tend_node_pixbuf
|
215
|
+
@link_node_pixbuf = @@tlink_node_pixbuf
|
216
|
+
@title_box.pack_start(@node_img=Gtk::Image.new(
|
217
|
+
end_node ? @end_node_pixbuf : @link_node_pixbuf),
|
218
|
+
false, false, 0)
|
219
|
+
self.pack_start(@link_wgt=TreeLink.new, true, true, 0)
|
220
|
+
@link_wgt.hide
|
221
|
+
if end_node
|
222
|
+
@link_wgt.disable
|
223
|
+
end
|
224
|
+
self.end_node = end_node
|
225
|
+
end
|
226
|
+
|
227
|
+
def end_node=(end_node)
|
228
|
+
if end_node
|
229
|
+
return if @end_node
|
230
|
+
@node_img.set_pixbuf(@end_node_pixbuf)
|
231
|
+
@link_wgt.disable
|
232
|
+
@end_node = true
|
233
|
+
else
|
234
|
+
return unless @end_node
|
235
|
+
@node_img.set_pixbuf(@link_node_pixbuf)
|
236
|
+
@link_wgt.enable
|
237
|
+
@end_node = false
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def end_node?
|
242
|
+
@end_node
|
243
|
+
end
|
244
|
+
|
245
|
+
def add_title_widget(wgt)
|
246
|
+
@title_box.pack_start(wgt, false, 0)
|
247
|
+
end
|
248
|
+
|
249
|
+
def end_node_pixbuf=(pixbuf)
|
250
|
+
@end_node_pixbuf = pixbuf
|
251
|
+
if @end_node
|
252
|
+
@node_img.set_pixbuf(@end_node_pixbuf)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def link_node_pixbuf=(pixbuf)
|
257
|
+
@link_node_pixbuf = pixbuf
|
258
|
+
unless @end_node
|
259
|
+
@node_img.set_pixbuf(@link_node_pixbuf)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
@@ -0,0 +1,189 @@
|
|
1
|
+
require 'gtk2'
|
2
|
+
require 'find'
|
3
|
+
require 'pav/gtk/button'
|
4
|
+
|
5
|
+
module PGtk
|
6
|
+
|
7
|
+
class Toolbar < Gtk::Table
|
8
|
+
attr_reader :toolbar, :ctrl_bar, :spaces_at, :iconized
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@toolbar = Gtk::Toolbar.new
|
12
|
+
@ctrl_bar = Gtk::Toolbar.new
|
13
|
+
btn_sz = Gtk::IconSize.lookup(Gtk::IconSize::MENU)
|
14
|
+
btn_sz[0] = (btn_sz[0])/2.3; btn_sz[1] = (btn_sz[1])/2.3
|
15
|
+
#@handle_btn = Toolbar.stock_icon_tool_btn_of_size(@toolbar,
|
16
|
+
# :"pgtk-handle", btn_sz[0], btn_sz[1])
|
17
|
+
@handle_btn = Button.new(:"pgtk-handle", btn_sz[0], btn_sz[1],
|
18
|
+
:"pgtk-handle-hover", :"pgtk-handle-pressed") { |wgt,ev|
|
19
|
+
self.iconized ^= true }
|
20
|
+
@l_fwd_btn = Button.new(:"pgtk-next", btn_sz[0], btn_sz[1],
|
21
|
+
:"pgtk-next-hover", :"pgtk-next-pressed") { |wgt, ev|
|
22
|
+
self.scroll_fwd; false }
|
23
|
+
@l_bck_btn = Button.new(:"pgtk-previous", btn_sz[0], btn_sz[1],
|
24
|
+
:"pgtk-previous-hover", :"pgtk-previous-pressed") {
|
25
|
+
|wgt, ev| self.scroll_back; false }
|
26
|
+
@ctrl_bar.append(Gtk::HBox.new << @handle_btn)
|
27
|
+
@ctrl_bar.append(Gtk::HBox.new << @l_bck_btn)
|
28
|
+
@ctrl_bar.append(Gtk::HBox.new << @l_fwd_btn)
|
29
|
+
@ctrl_bar.orientation = 1
|
30
|
+
@hadj = Gtk::Adjustment.new(0,0,1.0,1,10,0)
|
31
|
+
@vadj = Gtk::Adjustment.new(0,0,1.0,1,10,0)
|
32
|
+
@viewport = Gtk::Viewport.new(@hadj, @vadj)
|
33
|
+
@viewport.add(@toolbar)
|
34
|
+
@viewport.shadow_type = Gtk::SHADOW_NONE
|
35
|
+
super(2, 2)
|
36
|
+
self.attach(@ctrl_bar, 0,1, 0,1, 0, 0, 0,0)
|
37
|
+
self.attach(@viewport, 1,2, 0,1, Gtk::FILL|Gtk::EXPAND, 0, 0,0)
|
38
|
+
@spaces_at = []
|
39
|
+
end
|
40
|
+
|
41
|
+
def iconized?
|
42
|
+
@iconized
|
43
|
+
end
|
44
|
+
|
45
|
+
def iconized=(val)
|
46
|
+
if val
|
47
|
+
return if @iconized
|
48
|
+
@iconized = true
|
49
|
+
self.remove(@viewport)
|
50
|
+
@l_fwd_btn.hide
|
51
|
+
@l_bck_btn.hide
|
52
|
+
else
|
53
|
+
return unless @iconized
|
54
|
+
@iconized = false
|
55
|
+
@l_fwd_btn.show
|
56
|
+
@l_bck_btn.show
|
57
|
+
if @toolbar.orientation == Gtk::ORIENTATION_HORIZONTAL
|
58
|
+
self.attach(@viewport, 1,2, 0,1,
|
59
|
+
Gtk::FILL|Gtk::EXPAND,0, 0,0)
|
60
|
+
else
|
61
|
+
self.attach(@viewport, 0,1, 1,2,0,
|
62
|
+
Gtk::FILL|Gtk::EXPAND,0, 0)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def dir_size_request=(val)
|
68
|
+
if @toolbar.orientation==Gtk::ORIENTATION_HORIZONTAL
|
69
|
+
@viewport.width_request = val-@ctrl_bar.allocation.width
|
70
|
+
else
|
71
|
+
@viewport.height_request=val-@ctrl_bar.allocation.height
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def method_missing(id, *args, &block)
|
76
|
+
@toolbar.send(id, *args, &block)
|
77
|
+
end
|
78
|
+
|
79
|
+
def append_space(*args, &block)
|
80
|
+
@spaces_at << @toolbar.children.length + @spaces_at.length
|
81
|
+
@toolbar.append_space(*args, &block)
|
82
|
+
end
|
83
|
+
|
84
|
+
def insert_space(i)
|
85
|
+
@spaces_at << i
|
86
|
+
@spaces_at.sort!
|
87
|
+
@toolbar.insert_space(i)
|
88
|
+
end
|
89
|
+
|
90
|
+
def set_orientation(o)
|
91
|
+
@toolbar.set_orientation(o)
|
92
|
+
if o == Gtk::ORIENTATION_HORIZONTAL
|
93
|
+
@ctrl_bar.set_orientation(Gtk::ORIENTATION_VERTICAL)
|
94
|
+
h = @ctrl_bar.allocation.height
|
95
|
+
self.get_tool_sizes.each { |s| h = s if s > h }
|
96
|
+
self.remove(@viewport)
|
97
|
+
self.attach(@viewport, 1,2, 0,1,
|
98
|
+
Gtk::FILL|Gtk::EXPAND,0, 0,0)
|
99
|
+
self.height_request = h
|
100
|
+
else
|
101
|
+
@ctrl_bar.set_orientation(Gtk::ORIENTATION_HORIZONTAL)
|
102
|
+
w = @ctrl_bar.allocation.width
|
103
|
+
self.get_tool_sizes.each { |s| w = s if s > w }
|
104
|
+
self.remove(@viewport)
|
105
|
+
self.attach(@viewport, 0,1, 1,2, 0,
|
106
|
+
Gtk::FILL|Gtk::EXPAND, 0,0)
|
107
|
+
self.width_request = w
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
alias_method :orientation=, :set_orientation
|
112
|
+
|
113
|
+
def get_tool_sizes
|
114
|
+
if @toolbar.orientation == Gtk::ORIENTATION_HORIZONTAL
|
115
|
+
@toolbar.children.collect { |c| c.allocation.width }
|
116
|
+
else
|
117
|
+
@toolbar.children.collect { |c| c.allocation.height }
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def get_scroll_adj
|
122
|
+
@toolbar.orientation == Gtk::ORIENTATION_HORIZONTAL ? @hadj :
|
123
|
+
@vadj
|
124
|
+
end
|
125
|
+
|
126
|
+
def get_win_size
|
127
|
+
if @toolbar.orientation == Gtk::ORIENTATION_HORIZONTAL
|
128
|
+
@viewport.allocation.width
|
129
|
+
else
|
130
|
+
@viewport.allocation.height
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def get_toolbar_size
|
135
|
+
@toolbar.orientation == Gtk::ORIENTATION_HORIZONTAL ?
|
136
|
+
@toolbar.allocation.width : @toolbar.allocation.height
|
137
|
+
#size = 14*@spaces_at.length
|
138
|
+
#self.get_tool_sizes.each { |s| size += s }
|
139
|
+
#size
|
140
|
+
end
|
141
|
+
|
142
|
+
def scroll_fwd(*args)
|
143
|
+
adj = self.get_scroll_adj
|
144
|
+
sizes = self.get_tool_sizes
|
145
|
+
size = self.get_toolbar_size
|
146
|
+
win_size = self.get_win_size
|
147
|
+
start_x = adj.value
|
148
|
+
end_x = start_x + win_size
|
149
|
+
dspc_i = spc_i = size_i = 0
|
150
|
+
new_end_x = 0
|
151
|
+
while new_end_x <= end_x && size_i < sizes.length
|
152
|
+
while spc_i < @spaces_at.length &&
|
153
|
+
@spaces_at[spc_i] - dspc_i <= size_i
|
154
|
+
new_end_x += 14
|
155
|
+
spc_i += 1; dspc_i += 1
|
156
|
+
end
|
157
|
+
new_end_x += sizes[size_i]
|
158
|
+
size_i += 1
|
159
|
+
end
|
160
|
+
new_end_x = size if new_end_x > size
|
161
|
+
start_x = new_end_x - win_size
|
162
|
+
adj.value = start_x >= 0 ? start_x : 0
|
163
|
+
end
|
164
|
+
|
165
|
+
def scroll_back(*args)
|
166
|
+
adj = self.get_scroll_adj
|
167
|
+
sizes = self.get_tool_sizes
|
168
|
+
size = self.get_toolbar_size
|
169
|
+
win_size = self.get_win_size
|
170
|
+
start_x = adj.value
|
171
|
+
end_x = start_x + win_size
|
172
|
+
dspc_i = spc_i = size_i = 0
|
173
|
+
o_new_start_x = new_start_x = 0
|
174
|
+
while size_i < sizes.length
|
175
|
+
while spc_i < @spaces_at.length &&
|
176
|
+
@spaces_at[spc_i] - dspc_i <= size_i
|
177
|
+
new_start_x += 14
|
178
|
+
spc_i += 1; dspc_i += 1
|
179
|
+
end
|
180
|
+
break if new_start_x + sizes[size_i] >= start_x
|
181
|
+
o_new_start_x = new_start_x
|
182
|
+
new_start_x += sizes[size_i]
|
183
|
+
size_i += 1
|
184
|
+
end
|
185
|
+
adj.value = o_new_start_x
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|