~ubuntu-branches/ubuntu/intrepid/ruby1.8/intrepid-updates

« back to all changes in this revision

Viewing changes to ext/tk/sample/demos-jp/sayings.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# listbox widget demo 'sayings' (called by 'widget')
 
3
#
 
4
 
 
5
# toplevel widget ��¸�ߤ���к������
 
6
if defined?($sayings_demo) && $sayings_demo
 
7
  $sayings_demo.destroy 
 
8
  $sayings_demo = nil
 
9
end
 
10
 
 
11
# demo �Ѥ� toplevel widget ������
 
12
$sayings_demo = TkToplevel.new {|w|
 
13
  title("Listbox Demonstration (well-known sayings)")
 
14
  iconname("sayings")
 
15
  positionWindow(w)
 
16
}
 
17
 
 
18
# label ����
 
19
msg = TkLabel.new($sayings_demo) {
 
20
  font $font
 
21
  wraplength '4i'
 
22
  justify 'left'
 
23
  text "���Υꥹ�ȥܥå����ˤϤ��������ʳʸ������äƤ��ޤ����ꥹ�Ȥ򥹥������뤵����Τϥ���������С��Ǥ�Ǥ��ޤ������ꥹ�ȥܥå�������ǥޥ����Υܥ���2(��ܥ���)�򲡤����ޤޥɥ�å����Ƥ�Ǥ��ޤ���"
 
24
}
 
25
msg.pack('side'=>'top')
 
26
 
 
27
# frame ����
 
28
TkFrame.new($sayings_demo) {|frame|
 
29
  TkButton.new(frame) {
 
30
    #text 'λ��'
 
31
    text '�Ĥ���'
 
32
    command proc{
 
33
      tmppath = $sayings_demo
 
34
      $sayings_demo = nil
 
35
      tmppath.destroy
 
36
    }
 
37
  }.pack('side'=>'left', 'expand'=>'yes')
 
38
 
 
39
  TkButton.new(frame) {
 
40
    text '�����ɻ���'
 
41
    command proc{showCode 'sayings'}
 
42
  }.pack('side'=>'left', 'expand'=>'yes')
 
43
 
 
44
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
 
45
 
 
46
# frame ����
 
47
sayings_lbox = nil
 
48
TkFrame.new($sayings_demo, 'borderwidth'=>10) {|w|
 
49
  sv = TkScrollbar.new(w)
 
50
  sh = TkScrollbar.new(w, 'orient'=>'horizontal')
 
51
  sayings_lbox = TkListbox.new(w) {
 
52
    setgrid 1
 
53
    width  20
 
54
    height 10
 
55
    yscrollcommand proc{|first,last| sv.set first,last}
 
56
    xscrollcommand proc{|first,last| sh.set first,last}
 
57
  }
 
58
  sv.command(proc{|*args| sayings_lbox.yview(*args)})
 
59
  sh.command(proc{|*args| sayings_lbox.xview(*args)})
 
60
 
 
61
  if $tk_version =~ /^4\.[01]/
 
62
    sv.pack('side'=>'right', 'fill'=>'y')
 
63
    sh.pack('side'=>'bottom', 'fill'=>'x')
 
64
    sayings_lbox.pack('expand'=>'yes', 'fill'=>'y')
 
65
 
 
66
  else
 
67
    sayings_lbox.grid('row'=>0, 'column'=>0, 
 
68
                      'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
 
69
    sv.grid('row'=>0, 'column'=>1, 
 
70
            'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
 
71
    sh.grid('row'=>1, 'column'=>0, 
 
72
            'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
 
73
    TkGrid.rowconfigure(w, 0, 'weight'=>1, 'minsize'=>0)
 
74
    TkGrid.columnconfigure(w, 0, 'weight'=>1, 'minsize'=>0)
 
75
  end
 
76
 
 
77
}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
 
78
 
 
79
sayings_lbox.insert(0,
 
80
"Waste not, want not",
 
81
"Early to bed and early to rise makes a man healthy, wealthy, and wise",
 
82
"Ask not what your country can do for you, ask what you can do for your country",
 
83
"I shall return",
 
84
"NOT",
 
85
"A picture is worth a thousand words",
 
86
"User interfaces are hard to build",
 
87
"Thou shalt not steal",
 
88
"A penny for your thoughts",
 
89
"Fool me once, shame on you;  fool me twice, shame on me",
 
90
"Every cloud has a silver lining",
 
91
"Where there's smoke there's fire",
 
92
"It takes one to know one",
 
93
"Curiosity killed the cat",
 
94
"Take this job and shove it",
 
95
"Up a creek without a paddle",
 
96
"I'm mad as hell and I'm not going to take it any more",
 
97
"An apple a day keeps the doctor away",
 
98
"Don't look a gift horse in the mouth"
 
99
)
 
100