~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to ext/tk/sample/demos-en/ruler.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2010-07-31 17:08:39 UTC
  • mfrom: (1.1.4 upstream) (8.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100731170839-j034dmpdqt1cc4p6
Tags: 1.9.2~svn28788-1
* New release based on upstream snapshot from the 1.9.2 branch,
  after 1.9.2 RC2. That branch is (supposed to be) binary-compatible
  with the 1.9.1 branch.
  + Builds fine on i386. Closes: #580852.
* Upgrade to Standards-Version: 3.9.1. No changes needed.
* Updated generated incs.
* Patches that still need work:
  + Unclear status, need more investigation:
   090729_fix_Makefile_deps.dpatch
   090803_exclude_rdoc.dpatch
   203_adjust_base_of_search_path.dpatch
   902_define_YAML_in_yaml_stringio.rb.dpatch
   919_common.mk_tweaks.dpatch
   931_libruby_suffix.dpatch
   940_test_thread_mutex_sync_shorter.dpatch
  + Maybe not needed anymore, keeping but not applying.
   102_skip_test_copy_stream.dpatch (test doesn't block anymore?)
   104_skip_btest_io.dpatch (test doesn't block anymore?)
   201_gem_prelude.dpatch (we don't use that rubygems anyway?)
   202_gem_default_dir.dpatch (we don't use that rubygems anyway?)
   940_test_file_exhaustive_fails_as_root.dpatch
   940_test_priority_fails.dpatch
   100518_load_libc_libm.dpatch
* Add disable-tests.diff: disable some tests that cause failures on FreeBSD.
  Closes: #590002, #543805, #542927.
* However, many new failures on FreeBSD. Since that version is still an
  improvement, add the check that makes test suite failures non-fatal on
  FreeBSD again. That still needs to be investigated.
* Re-add 903_skip_base_ruby_check.dpatch
* Add build-dependency on ruby1.8 and drop all pre-generated files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
# toplevel widget
23
23
if defined?($ruler_demo) && $ruler_demo
24
 
  $ruler_demo.destroy 
 
24
  $ruler_demo.destroy
25
25
  $ruler_demo = nil
26
26
end
27
27
 
35
35
base_frame = TkFrame.new($ruler_demo).pack(:fill=>:both, :expand=>true)
36
36
 
37
37
# label
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')
41
41
}
58
58
}
59
59
$ruler_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
60
60
 
61
 
# canvas 
 
61
# canvas
62
62
$ruler_canvas = TkCanvas.new(base_frame, 'width'=>'14.8c', 'height'=>'2.5c')
63
63
$ruler_canvas.pack('side'=>'top', 'fill'=>'x')
64
64
 
65
 
 
65
#
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
70
70
end
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)}
83
83
else
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)}
88
88
end
89
89
 
90
 
TkcLine.new($ruler_canvas, 
 
90
TkcLine.new($ruler_canvas,
91
91
            '1c', '0.5c', '1c', '1c', '13c', '1c', '13c', '0.5c', 'width'=>1)
92
92
(0..11).each{|i|
93
93
  x = i+1
101
101
$rulerTag_well = TkcTag.new($ruler_canvas)
102
102
$ruler_canvas\
103
103
.addtag_withtag($rulerTag_well,
104
 
                TkcRectangle.new($ruler_canvas, 
105
 
                                 '13.2c', '1c', '13.8c', '0.5c', 
106
 
                                 'outline'=>'black', 
 
104
                TkcRectangle.new($ruler_canvas,
 
105
                                 '13.2c', '1c', '13.8c', '0.5c',
 
106
                                 'outline'=>'black',
107
107
                                 'fill'=>($ruler_canvas\
108
108
                                          .configinfo('background'))[4]) )
109
109
$ruler_canvas\
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') ) )
114
114
 
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)})
121
121