35
35
base_frame = TkFrame.new($ruler_demo).pack(:fill=>:both, :expand=>true)
38
TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
38
TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
39
39
'text'=>"This canvas widget shows a mock-up of a ruler. You can create tab stops by dragging them out of the well to the right of the ruler. You can also drag existing tab stops. If you drag a tab stop far enough up or down so that it turns dim, it will be deleted when you release the mouse button."){
40
40
pack('side'=>'top')
59
59
$ruler_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
62
62
$ruler_canvas = TkCanvas.new(base_frame, 'width'=>'14.8c', 'height'=>'2.5c')
63
63
$ruler_canvas.pack('side'=>'top', 'fill'=>'x')
66
66
unless Struct.const_defined?("RulerInfo")
67
$demo_rulerInfo = Struct.new("RulerInfo", :grid, :left, :right, :x, :y,
68
:top, :bottom, :size, :normalStyle,
67
$demo_rulerInfo = Struct.new("RulerInfo", :grid, :left, :right, :x, :y,
68
:top, :bottom, :size, :normalStyle,
69
69
:activeStyle, :deleteStyle).new
71
71
$demo_rulerInfo.grid = '.25c'
77
77
$demo_rulerInfo.normalStyle = {'fill'=>'black'}
78
78
if TkWinfo.depth($ruler_canvas) > 1
79
79
$demo_rulerInfo.activeStyle = {'fill'=>'red', 'stipple'=>''}
80
$demo_rulerInfo.deleteStyle = {'fill'=>'red',
81
'stipple'=>'@'+[$demo_dir, '..',
80
$demo_rulerInfo.deleteStyle = {'fill'=>'red',
81
'stipple'=>'@'+[$demo_dir, '..',
82
82
'images', 'gray25.xbm'].join(File::Separator)}
84
84
$demo_rulerInfo.activeStyle = {'fill'=>'black', 'stipple'=>''}
85
$demo_rulerInfo.deleteStyle = {'fill'=>'black',
86
'stipple'=>'@'+[$demo_dir, '..',
85
$demo_rulerInfo.deleteStyle = {'fill'=>'black',
86
'stipple'=>'@'+[$demo_dir, '..',
87
87
'images', 'gray25.xbm'].join(File::Separator)}
90
TkcLine.new($ruler_canvas,
90
TkcLine.new($ruler_canvas,
91
91
'1c', '0.5c', '1c', '1c', '13c', '1c', '13c', '0.5c', 'width'=>1)
101
101
$rulerTag_well = TkcTag.new($ruler_canvas)
103
103
.addtag_withtag($rulerTag_well,
104
TkcRectangle.new($ruler_canvas,
105
'13.2c', '1c', '13.8c', '0.5c',
104
TkcRectangle.new($ruler_canvas,
105
'13.2c', '1c', '13.8c', '0.5c',
107
107
'fill'=>($ruler_canvas\
108
108
.configinfo('background'))[4]) )
110
110
.addtag_withtag($rulerTag_well,
111
rulerMkTab($ruler_canvas,
112
TkWinfo.pixels($ruler_canvas, '13.5c'),
111
rulerMkTab($ruler_canvas,
112
TkWinfo.pixels($ruler_canvas, '13.5c'),
113
113
TkWinfo.pixels($ruler_canvas, '.65c') ) )
115
115
$rulerTag_well.bind('1', proc{|x,y| rulerNewTab($ruler_canvas,x,y)}, '%x %y')
116
$ruler_canvas.itembind('tab', '1',
116
$ruler_canvas.itembind('tab', '1',
117
117
proc{|x,y| rulerSelectTab($ruler_canvas,x,y)}, '%x %y')
118
$ruler_canvas.bind('B1-Motion',
118
$ruler_canvas.bind('B1-Motion',
119
119
proc{|x,y| rulerMoveTab($ruler_canvas,x,y)}, '%x %y')
120
120
$ruler_canvas.bind('Any-ButtonRelease-1', proc{rulerReleaseTab($ruler_canvas)})