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

« back to all changes in this revision

Viewing changes to ext/tk/sample/tkmenubutton.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:
7
7
TkLabel.new(:text=>'Sample of TkMenubutton').pack(:side=>:top)
8
8
 
9
9
TkFrame.new{|f|
10
 
  pack(:side=>:top) 
11
 
 
12
 
 
13
 
  TkMenubutton.new(:parent=>f, :text=>'Right', :underline=>0, 
 
10
  pack(:side=>:top)
 
11
 
 
12
 
 
13
  TkMenubutton.new(:parent=>f, :text=>'Right', :underline=>0,
14
14
                   :direction=>:right, :relief=>:raised){|mb|
15
15
    menu TkMenu.new(:parent=>mb, :tearoff=>0){
16
 
      add(:command, :label=>'Right menu: first item', 
17
 
                    :command=>proc{print 'You have selected the first item' + 
 
16
      add(:command, :label=>'Right menu: first item',
 
17
                    :command=>proc{print 'You have selected the first item' +
18
18
                                         " from the Right menu.\n"})
19
 
      add(:command, :label=>'Right menu: second item', 
20
 
                    :command=>proc{print 'You have selected the second item' + 
 
19
      add(:command, :label=>'Right menu: second item',
 
20
                    :command=>proc{print 'You have selected the second item' +
21
21
                                         " from the Right menu.\n"})
22
22
    }
23
23
    pack(:side=>:left, :padx=>25, :pady=>25)
24
24
  }
25
25
 
26
 
  TkMenubutton.new(:parent=>f, :text=>'Below', :underline=>0, 
 
26
  TkMenubutton.new(:parent=>f, :text=>'Below', :underline=>0,
27
27
                   :direction=>:below, :relief=>:raised){|mb|
28
28
    menu(TkMenu.new(:parent=>mb, :tearoff=>0){
29
 
      add(:command, :label=>'Below menu: first item', 
30
 
                    :command=>proc{print 'You have selected the first item' + 
 
29
      add(:command, :label=>'Below menu: first item',
 
30
                    :command=>proc{print 'You have selected the first item' +
31
31
                                         " from the Below menu.\n"})
32
 
      add(:command, :label=>'Below menu: second item', 
33
 
                    :command=>proc{print 'You have selected the second item' + 
 
32
      add(:command, :label=>'Below menu: second item',
 
33
                    :command=>proc{print 'You have selected the second item' +
34
34
                                         " from the Below menu.\n"})
35
35
    })
36
36
    pack(:side=>:left, :padx=>25, :pady=>25)
37
37
  }
38
38
 
39
 
  TkMenubutton.new(:parent=>f, :text=>'Above', :underline=>0, 
 
39
  TkMenubutton.new(:parent=>f, :text=>'Above', :underline=>0,
40
40
                   :direction=>:above, :relief=>:raised){|mb|
41
41
    menu TkMenu.new(:parent=>mb, :tearoff=>0){
42
 
      add(:command, :label=>'Above menu: first item', 
43
 
                    :command=>proc{print 'You have selected the first item' + 
 
42
      add(:command, :label=>'Above menu: first item',
 
43
                    :command=>proc{print 'You have selected the first item' +
44
44
                                         " from the Above menu.\n"})
45
 
      add(:command, :label=>'Above menu: second item', 
46
 
                    :command=>proc{print 'You have selected the second item' + 
 
45
      add(:command, :label=>'Above menu: second item',
 
46
                    :command=>proc{print 'You have selected the second item' +
47
47
                                         " from the Above menu.\n"})
48
48
    }
49
49
    pack(:side=>:left, :padx=>25, :pady=>25)
50
50
  }
51
51
 
52
 
  TkMenubutton.new(:parent=>f, :text=>'Left', :underline=>0, 
 
52
  TkMenubutton.new(:parent=>f, :text=>'Left', :underline=>0,
53
53
                   :direction=>:left, :relief=>:raised){|mb|
54
54
    menu(TkMenu.new(:parent=>mb, :tearoff=>0){
55
 
      add(:command, :label=>'Left menu: first item', 
56
 
                    :command=>proc{print 'You have selected the first item' + 
 
55
      add(:command, :label=>'Left menu: first item',
 
56
                    :command=>proc{print 'You have selected the first item' +
57
57
                                         " from the Left menu.\n"})
58
 
      add(:command, :label=>'Left menu: second item', 
59
 
                    :command=>proc{print 'You have selected the second item' + 
 
58
      add(:command, :label=>'Left menu: second item',
 
59
                    :command=>proc{print 'You have selected the second item' +
60
60
                                         " from the Left menu.\n"})
61
61
    })
62
62
    pack(:side=>:left, :padx=>25, :pady=>25)
64
64
}
65
65
 
66
66
############################
67
 
TkFrame.new(:borderwidth=>2, :relief=>:sunken, 
 
67
TkFrame.new(:borderwidth=>2, :relief=>:sunken,
68
68
            :height=>5).pack(:side=>:top, :fill=>:x, :padx=>20)
69
69
############################
70
70
 
71
71
TkLabel.new(:text=>'Sample of TkOptionMenu').pack(:side=>:top)
72
72
 
73
 
colors = %w(Black red4 DarkGreen NavyBlue gray75 Red Green Blue gray50 
 
73
colors = %w(Black red4 DarkGreen NavyBlue gray75 Red Green Blue gray50
74
74
            Yellow Cyan Magenta White Brown DarkSeaGreen DarkViolet)
75
75
 
76
76
TkFrame.new{|f|
77
 
  pack(:side=>:top) 
 
77
  pack(:side=>:top)
78
78
 
79
 
  b1 = TkOptionMenubutton . 
80
 
    new(:parent=>f, :values=>%w(one two three)) . 
 
79
  b1 = TkOptionMenubutton .
 
80
    new(:parent=>f, :values=>%w(one two three)) .
81
81
    pack(:side=>:left, :padx=>25, :pady=>25)
82
82
 
83
83
  b2 = TkOptionMenubutton.new(:parent=>f, :values=>colors) {|optMB|
96
96
        put 'Black',  *[14,  2, 16, 14]
97
97
        put color,    *[ 2,  2, 14, 14]
98
98
      }
99
 
      optMB.entryconfigure(color, :hidemargin=>1, 
 
99
      optMB.entryconfigure(color, :hidemargin=>1,
100
100
                           :image=>no_sel, :selectimage=>sel)
101
101
    }
102
102
    optMB.menuconfigure(:tearoff, 1)
114
114
}
115
115
 
116
116
############################
117
 
TkFrame.new(:borderwidth=>2, :relief=>:sunken, 
 
117
TkFrame.new(:borderwidth=>2, :relief=>:sunken,
118
118
            :height=>5).pack(:side=>:top, :fill=>:x, :padx=>20)
119
119
############################
120
120