#
# 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', 'Spacing22pointꤵƤޤ', 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)

}

