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

« back to all changes in this revision

Viewing changes to ext/tk/sample/demos-jp/bind.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
# text (tag bindings) widget demo (called by 'widget')
 
3
#
 
4
 
 
5
# toplevel widget ��¸�ߤ���к������
 
6
if defined?($bind_demo) && $bind_demo
 
7
  $bind_demo.destroy 
 
8
  $bind_demo = nil
 
9
end
 
10
 
 
11
# demo �Ѥ� toplevel widget ������
 
12
$bind_demo = TkToplevel.new {|w|
 
13
  title("Text Demonstration - Tag Bindings")
 
14
  iconname("bind")
 
15
  positionWindow(w)
 
16
}
 
17
 
 
18
# frame ����
 
19
TkFrame.new($bind_demo) {|frame|
 
20
  TkButton.new(frame) {
 
21
    #text 'λ��'
 
22
    text '�Ĥ���'
 
23
    command proc{
 
24
      tmppath = $bind_demo
 
25
      $bind_demo = nil
 
26
      tmppath.destroy
 
27
    }
 
28
  }.pack('side'=>'left', 'expand'=>'yes')
 
29
 
 
30
  TkButton.new(frame) {
 
31
    text '�����ɻ���'
 
32
    command proc{showCode 'bind'}
 
33
  }.pack('side'=>'left', 'expand'=>'yes')
 
34
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
 
35
 
 
36
# bind �ѥ᥽�å�
 
37
def tag_binding_for_bind_demo(tag, enter_style, leave_style)
 
38
  tag.bind('Any-Enter', proc{tag.configure enter_style})
 
39
  tag.bind('Any-Leave', proc{tag.configure leave_style})
 
40
end
 
41
 
 
42
# text ����
 
43
TkText.new($bind_demo){|t|
 
44
  # ����
 
45
  setgrid 'true'
 
46
  width  60
 
47
  height 24
 
48
  font $font
 
49
  wrap 'word'
 
50
  TkScrollbar.new($bind_demo) {|s|
 
51
    pack('side'=>'right', 'fill'=>'y')
 
52
    command proc{|*args| t.yview(*args)}
 
53
    t.yscrollcommand proc{|first,last| s.set first,last}
 
54
  }
 
55
  pack('expand'=>'yes', 'fill'=>'both')
 
56
 
 
57
  # ������������
 
58
  if TkWinfo.depth($root).to_i > 1
 
59
    tagstyle_bold = {'background'=>'#43ce80', 'relief'=>'raised', 
 
60
                     'borderwidth'=>1}
 
61
    tagstyle_normal = {'background'=>'', 'relief'=>'flat'}
 
62
  else
 
63
    tagstyle_bold = {'foreground'=>'white', 'background'=>'black'}
 
64
    tagstyle_normal = {'foreground'=>'', 'background'=>''}
 
65
  end
 
66
 
 
67
  # �ƥ���������
 
68
  insert 'insert', "�ƥ�����widget��ɽ��������������椹��Τ�Ʊ�������Υᥫ�˥����Ȥäơ��ƥ����Ȥ�Tcl�Υ��ޥ�ɤ������Ƥ뤳�Ȥ��Ǥ��ޤ�������ˤ�ꡢ�ޥ����䥭���ܡ��ɤΥ��������������Tcl�Υ��ޥ�ɤ��¹Ԥ����褦�ˤʤ�ޤ����㤨�С����Υ����Х��Υǥ�ץ������ˤĤ��Ƥ�����ʸ�ˤϤ��Τ褦�ʥ������Ĥ��Ƥ��ޤ����ޥ���������ʸ�ξ�˻��äƤ���������ʸ�����ꡢ�ܥ���1�򲡤��Ȥ��������Υǥ⤬�Ϥޤ�ޤ���
 
69
 
 
70
"
 
71
  insert('end', '1. �����Х� widget �˺�뤳�ȤΤǤ��륢���ƥ�μ������Ƥ˴ؤ��륵��ץ롣', (d1 = TkTextTag.new(t)) )
 
72
  insert('end', "\n\n")
 
73
  insert('end', '2. ��ñ�� 2�����Υץ��åȡ��ǡ�����ɽ������ư�������Ȥ��Ǥ��롣', (d2 = TkTextTag.new(t)) )
 
74
  insert('end', "\n\n")
 
75
  insert('end', '3. �ƥ����ȥ����ƥ�Υ��󥫡��ȹ�·����', 
 
76
         (d3 = TkTextTag.new(t)) )
 
77
  insert('end', "\n\n")
 
78
  insert('end', '4. �饤�󥢥��ƥ�Τ���������Ƭ�η��Υ��ǥ�����', 
 
79
         (d4 = TkTextTag.new(t)) )
 
80
  insert('end', "\n\n")
 
81
  insert('end', '5. ���֥��ȥåפ��ѹ����뤿��ε�ǽ�Ĥ��Υ롼�顼��', 
 
82
         (d5 = TkTextTag.new(t)) )
 
83
  insert('end', "\n\n")
 
84
  insert('end', 
 
85
         '6. �����Х����ɤ���äƥ��������뤹��Τ��򼨤�����åɡ�', 
 
86
         (d6 = TkTextTag.new(t)) )
 
87
 
 
88
  # binding
 
89
  [d1, d2, d3, d4, d5, d6].each{|tag|
 
90
    tag_binding_for_bind_demo(tag, tagstyle_bold, tagstyle_normal)
 
91
  }
 
92
  d1.bind('1', 
 
93
          proc{
 
94
            eval(`cat #{[$demo_dir,'items.rb'].join(File::Separator)}`, 
 
95
                 _null_binding)
 
96
          })
 
97
  d2.bind('1', 
 
98
          proc{
 
99
            eval(`cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`, 
 
100
                 _null_binding)
 
101
          })
 
102
  d3.bind('1', 
 
103
          proc{
 
104
            eval(`cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`, 
 
105
                 _null_binding)
 
106
          })
 
107
  d4.bind('1', 
 
108
          proc{
 
109
            eval(`cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`, 
 
110
                 _null_binding)
 
111
          })
 
112
  d5.bind('1', 
 
113
          proc{
 
114
            eval(`cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`, 
 
115
                 _null_binding)
 
116
          })
 
117
  d6.bind('1', 
 
118
          proc{
 
119
            eval(`cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`, 
 
120
                 _null_binding)
 
121
          })
 
122
 
 
123
  TkTextMarkInsert.new(t, '0.0')
 
124
  configure('state','disabled')
 
125
}