aboutsummaryrefslogtreecommitdiffstats
path: root/ext/tk/sample/demos-jp/style.rb
blob: 50855a549aff1692f2f9ce5fc96d58e7b887970f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# -*- coding: euc-jp -*-
#
# text (display styles) widget demo (called by 'widget')
#

# toplevel widget ��¸�ߤ���к������
if defined?($style_demo) && $style_demo
  $style_demo.destroy 
  $style_demo = nil
end

# demo �Ѥ� toplevel widget ������
$style_demo = TkToplevel.new {|w|
  title("Text Demonstration - Display Styles")
  iconname("style")
  positionWindow(w)
}

# frame ����
TkFrame.new($style_demo) {|frame|
  TkButton.new(frame) {
    #text '�'
    text '�Ĥ���'
    command proc{
      tmppath = $style_demo
      $style_demo = nil
      tmppath.destroy
    }
  }.pack('side'=>'left', 'expand'=>'yes')

  TkButton.new(frame) {
    text '�����ɻ���'
    command proc{showCode 'style'}
  }.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')

# text ����
TkText.new($style_demo){|t|
  # ����
  setgrid 'true'
  width  70
  height 32
  wrap 'word'
  TkScrollbar.new($style_demo) {|s|
    pack('side'=>'right', 'fill'=>'y')
    command proc{|*args| t.yview(*args)}
    t.yscrollcommand proc{|first,last| s.set first,last}
  }
  pack('expand'=>'yes', 'fill'=>'both')

  # �ƥ����ȥ������� (�ե���ȴ�Ϣ)
  style_tag_bold = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*')
  style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
    style_tag_verybig = TkTextTag.new(t, 'font'=>'-*-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*')
#    style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
    style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*')
###
#  case($tk_version)
#  when /^4.*/
#    style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
#    style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
#  when /^8.*/
#    unless $style_demo_do_first
#      $style_demo_do_first = true
#      Tk.tk_call('font', 'create', '@bigascii', 
#                '-copy', '-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*')
#      Tk.tk_call('font', 'create', '@smallascii', 
#                '-copy', '-Adobe-Helvetica-Bold-R-Normal-*-100-*')
#      Tk.tk_call('font', 'create', '@cBigFont', 
#                '-compound', '@bigascii @msg_knj')
#      Tk.tk_call('font', 'create', '@cSmallFont', 
#                '-compound', '@smallascii @kanji')
#    end
#    style_tag_big = TkTextTag.new(t, 'font'=>'@cBigFont')
#    style_tag_small = TkTextTag.new(t, 'font'=>'@cSmallFont')
#  end

  # �ƥ����ȥ������� (������꡼�մ�Ϣ)
  if TkWinfo.depth($root).to_i > 1
    style_tag_color1 = TkTextTag.new(t, 'background'=>'#a0b7ce')
    style_tag_color2 = TkTextTag.new(t, 'foreground'=>'red')
    style_tag_raised = TkTextTag.new(t, 'relief'=>'raised', 'borderwidth'=>1)
    style_tag_sunken = TkTextTag.new(t, 'relief'=>'sunken', 'borderwidth'=>1)
  else
    style_tag_color1 = TkTextTag.new(t, 'background'=>'black', 
                                     'foreground'=>'white')
    style_tag_color2 = TkTextTag.new(t, 'background'=>'black', 
                                     'foreground'=>'white')
    style_tag_raised = TkTextTag.new(t, 'background'=>'white', 
                                     'relief'=>'raised', 'borderwidth'=>1)
    style_tag_sunken = TkTextTag.new(t, 'background'=>'white', 
                                     'relief'=>'sunken', 'borderwidth'=>1)
  end

  # �ƥ����ȥ������� (����¾)
  if $tk_version =~ /^4\.[01]/
    style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black', 
                                        'borderwidth'=>0, 
                                        'bgstipple'=>'gray25')
  else
    style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black', 
                                        'borderwidth'=>0, 
                                        'bgstipple'=>'gray12')
  end
  style_tag_fgstipple = TkTextTag.new(t, 'fgstipple'=>'gray50')
  style_tag_underline = TkTextTag.new(t, 'underline'=>'on')
  style_tag_overstrike = TkTextTag.new(t, 'overstrike'=>'on')
  style_tag_right  = TkTextTag.new(t, 'justify'=>'right')
  style_tag_center = TkTextTag.new(t, 'justify'=>'center')
  style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
  style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
  style_tag_margins = TkTextTag.new(t, 'lmargin1'=>'12m', 'lmargin2'=>'6m',
                                    'rmargin'=>'10m')
  style_tag_spacing = TkTextTag.new(t, 'spacing1'=>'10p', 'spacing2'=>'2p',
                                    'lmargin1'=>'12m', 'lmargin2'=>'6m',
                                    'rmargin'=>'10m')

  # �ƥ���������
  insert('end', '���Τ褦�˥ƥ����� widget �Ͼ�����͡��ʥ��������ɽ�����뤳��
���Ǥ��ޤ���')
  insert('end', '����', style_tag_big)
  insert('end', '�Ȥ����ᥫ�˥���ǥ���ȥ����뤵��ޤ���
�����Ȥϥƥ����� widget ��Τ���ʸ�� (���ϰ�)���Ф���Ŭ�ѤǤ���
ñ�ʤ�̾���Τ��ȤǤ����������͡���ɽ���������������Ǥ��ޤ���
���ꤹ��ȡ����Υ����ΤĤ���ʸ���ϻ��ꤷ�����������ɽ�������
�褦�ˤʤ�ޤ������ѤǤ���ɽ����������ϼ����̤�Ǥ���
')
  insert('end', '
1. �ե����', style_tag_big)
  insert('end', '    �ɤ�� X �Υե���ȤǤ�Ȥ��ޤ���')
  insert('end', 'large', style_tag_verybig)
  insert('end', '
�Ȥ�')
#  insert('end', '������', style_tag_small)
  insert('end', 'small', style_tag_small)
  insert('end', '�Ȥ���
')
  insert('end', '
2. ��', style_tag_big)
  insert('end', '  ')
  insert('end', '�طʿ�', style_tag_color1)
  insert('end', '��')
  insert('end', '���ʿ�', style_tag_color2)
  insert('end', '��')
  insert('end', '�', style_tag_color1, style_tag_color2)
  insert('end', '�Ȥ��Ѥ��뤳�Ȥ��Ǥ��ޤ���
')
  insert('end', '
3. �֤���', style_tag_big)
  insert('end', '  ���Τ褦������κݤ�')
  insert('end', '�طʤ�', style_tag_bgstipple)
  insert('end', 'ʸ����', style_tag_fgstipple)
  insert('end', 'ñ�ʤ��ɤ�Ĥ֤�
�Ǥʤ����֤�����Ȥ����Ȥ��Ǥ��ޤ���
')
  insert('end', '
4. ����', style_tag_big)
  insert('end', '  ���Τ褦��')
  insert('end', 'ʸ���˲��������', style_tag_underline)
  insert('end', '���Ȥ��Ǥ��ޤ���
')
  insert('end', '
5. �Ǥ��ä���', style_tag_big)
  insert('end', '  ���Τ褦��')
  insert('end', 'ʸ���˽Ťͤ��������', style_tag_overstrike)
  insert('end', '���Ȥ��Ǥ��ޤ���
')
  insert('end', '
6. 3D ����', style_tag_big)
  insert('end', '  �طʤ��Ȥ�Ĥ��ơ�ʸ����')
  insert('end', '���ӽФ�', style_tag_raised)
  insert('end', '�褦�ˤ�����')
  insert('end', '����', style_tag_sunken)
  insert('end', '
�褦�ˤǤ��ޤ���
')
  insert('end', '
7. ��·��', style_tag_big)
  insert('end', ' ���Τ褦�˹Ԥ�
')
  insert('end', '����·������
')
  insert('end', '����·������
', style_tag_right)
  insert('end', '�����·������Ǥ��ޤ���
', style_tag_center)
  insert('end', '
8. ���դ�ʸ����ź��', style_tag_big)
  insert('end', '  10')
  insert('end', 'n', style_tag_super)
  insert('end', ' �Τ褦�˸��դ�ʸ���θ��̤䡢')
  insert('end', '
X')
  insert('end', 'i', style_tag_sub)
  insert('end', '�Τ褦��ź���θ��̤�Ф����Ȥ��Ǥ��ޤ���
')
  insert('end', '
9. �ޡ�����', style_tag_big)
  insert('end', '�ƥ����Ȥκ�¦��;ʬ�ʶ�����֤����Ȥ��Ǥ��ޤ�:
')
  insert('end', '��������ϥޡ�����λ�����Ǥ��������꡼��', 
         style_tag_margins)
  insert('end', '����ޤ��֤����ɽ������Ƥ���1�ԤΥƥ����ȤǤ���', 
         style_tag_margins)
  insert('end', '��¦�ˤ�2����Υޡ����������ޤ���', style_tag_margins)
  insert('end', '1���ܤ��Ф����Τȡ�', style_tag_margins)
  insert('end', '2���ܰʹߤ�Ϣ³�����ޡ�����', style_tag_margins)
  insert('end', '�Ǥ����ޤ���¦�ˤ�ޡ����󤬤���ޤ���', style_tag_margins)
  insert('end', '�Ԥ��ޤ��֤����֤���뤿��˻��Ѥ��뤳�Ȥ��Ǥ��ޤ���
', style_tag_margins)
  insert('end', '
10. ���ڡ�����', style_tag_big)
  insert('end', '3�ĤΥѥ�᡼���ǹԤΥ��ڡ����󥰤�')
  insert('end', '���椹
�뤳�Ȥ��Ǥ��ޤ���Spacing1�ǡ��Ԥ�')
  insert('end', '��ˤɤΤ��餤�ζ��֤��֤�����
spacing3')
  insert('end', '�ǹԤβ��ˤɤΤ��餤�ζ��֤��֤�����')
  insert('end', '�Ԥ��ޤ��֤���Ƥ���ʤ�
�С�spacing2�ǡ�')
  insert('end', '�ƥ����ȹԤ��������Ƥ���Ԥδ֤ˤɤΤ��餤')
  insert('end', '�ζ��֤���
�����򼨤��ޤ���
')
  insert('end', '�����Υ���ǥ�Ȥ��줿����ϤɤΤ褦��', 
         style_tag_spacing)
  insert('end', '���ڡ����󥰤����Ԥ���Τ��򼨤��ޤ���', 
         style_tag_spacing)
  insert('end', '������ϼºݤϥƥ�����widget', style_tag_spacing)
  insert('end', '��1�Ԥǡ�widget�ˤ�ä��ޤ���ޤ�Ƥ��ޤ���
', style_tag_spacing)
  insert('end', 'Spacing1�Ϥ��Υƥ����ȤǤ�10point��', style_tag_spacing)
  insert('end', '���ꤵ��Ƥ��ޤ���', style_tag_spacing)
  insert('end', '����ˤ�ꡢ����δ֤��礭�ʴֳ֤�', style_tag_spacing)
  insert('end', '¸�ߤ��Ƥ��ޤ���', style_tag_spacing)
  insert('end', 'Spacing2��2point�����ꤵ��Ƥ��ޤ���', style_tag_spacing)
  insert('end', '������������ˤۤ�ξ����ֳ֤�¸�ߤ��Ƥ��ޤ���', 
         style_tag_spacing)
  insert('end', 'Spacing3�Ϥ�����Ǥϻ��Ѥ���Ƥ��ޤ���
', style_tag_spacing)
  insert('end', '�ֳ֤��ɤ��ˤ��뤫�򸫤�����С������������', 
         style_tag_spacing)
  insert('end', '�ʤ��ǥƥ����Ȥ����򤷤Ƥ��������������', style_tag_spacing)
  insert('end', 'ȿž������ʬ�ˤ�;ʬ�ˤȤ�줿�ֳ֤�', style_tag_spacing)
  insert('end', '�ޤޤ�Ƥ��ޤ���
', style_tag_spacing)

}