1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/tk/sample/tkextlib/vu/canvSticker2.rb
akr f1b7e60cb9 * encoding.c (rb_enc_mbclen): make it never fail.
(rb_enc_nth): don't check the return value of rb_enc_mbclen.
  (rb_enc_strlen): ditto.
  (rb_enc_precise_mbclen): return needmore(1) if e <= p.
  (rb_enc_get_ascii): new function for extracting ASCII character.

* include/ruby/encoding.h (rb_enc_get_ascii): declared.

* include/ruby/regex.h (ismbchar): removed.

* re.c (rb_reg_expr_str): use rb_enc_get_ascii.
  (unescape_escaped_nonascii): use rb_enc_precise_mbclen to determine
  the termination of escaped non-ASCII character.
  (unescape_nonascii): use rb_enc_precise_mbclen.
  (rb_reg_quote): use rb_enc_get_ascii.
  (rb_reg_regsub): use rb_enc_get_ascii.

* string.c (rb_str_reverse) don't check the return value of
  rb_enc_mbclen.
  (rb_str_split_m): don't call rb_enc_mbclen with e <= p.

* parse.y (is_identchar): use ISASCII.
  (parser_ismbchar): removed.
  (parser_precise_mbclen): new macro.
  (parser_isascii): new macro.
  (parser_tokadd_mbchar): use parser_precise_mbclen to check invalid
  character precisely.
  (parser_tokadd_string): use parser_isascii.
  (parser_yylex): ditto.
  (is_special_global_name): don't call is_identchar with e <= p.
  (rb_enc_symname_p): ditto.

  [ruby-dev:32455]

* ext/tk/sample/tkextlib/vu/canvSticker2.rb: remove coding cookie
  because the encoding is not UTF-8.  [ruby-dev:32475]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-08 02:50:43 +00:00

99 lines
2 KiB
Ruby

#!/usr/bin/env ruby
require 'tk'
require 'tkextlib/vu/charts'
#######################################
c = TkCanvas.new.pack
begin
st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10)
rescue
Tk.messageBox(:type=>'ok', :title=>"No sticker Item",
:message=>"This build of vu does not include the sticker item")
exit
end
c.destroy
#---
#--- set STRING {{x0 y0 x1 y1} {...text...} {resize point: center}
#sti_conf = [ [10, 10, 180, 180], "Sticker äöüß@²³¼½¾", :center ]
#txt_conf = [ [210, 210], "Text äöüß@²³¼½¾", :center ]
sti_conf = [ [10, 10, 350, 350],
Tk::UTF8_String("Sticker äöüß@²³¼½¾"), :center ]
txt_conf = [ [250, 250],
Tk::UTF8_String("Text äöüß@²³¼½¾"), :center ]
p sti_conf
fnt = TkFont.new('Helvetica 24 bold')
#---GUI
c = TkCanvas.new(:width=>500, :height=>500, :bg=>'aquamarine3').pack
#---CRRW Use the technique of eval the coord ...
sti = Tk::Vu::TkcSticker.new(c, sti_conf[0]){
anchor sti_conf[2]
bar 'black'
color 'red'
fill ''
font fnt
lefttrunc 0
outline ''
relheight 0.0
relwidth 0.0
relx 0.0
rely 0.0
space 0
stipple ''
tags 'sti'
text sti_conf[1]
width 0
orient :vertical
minwidth 0
minheight 0
maxwidth 32767
maxheight 32767
}
txt = TkcText.new(c, txt_conf[0]){
activefill ''
activestipple ''
anchor txt_conf[2]
disabledfill ''
disabledstipple ''
fill 'blue'
font fnt
justify :left
offset '0,0'
state ''
stipple ''
tags ['tex']
text txt_conf[1]
width 0
}
#---BINDINGS
c.bind('2', proc{
sti[:orient] = :horizontal
txt[:width] = 0 # horizontal
})
c.bind('3', proc{
sti[:orient] = :vertical
txt[:width] = 1 # top down
})
Tk.root.bind('p', proc{
c.postscript(:file=>'DEMO.ps')
puts "DEMO.ps printed"
})
Tk.root.bind('q', proc{exit})
#####################
Tk.mainloop