Class: RGhost::TextArea

Inherits:
PsObject show all
Includes:
ParseText, RubyToPs
Defined in:
lib/rghost/textarea.rb

Overview

PS: It not jumps pages.

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :width => :area_x,
  :row_height => :row_height,
  :x=> :limit_left,
  :y=> :current_row,
  :text_align => :left
 
}

Constants included from RubyToPs

RubyToPs::UTF8_ENCODINGS

Instance Method Summary collapse

Methods included from ParseText

#ta_entry, #text_to_ps

Methods included from RubyToPs

#array_to_stack, #hash_to_array, #pack_string, #ps_escape, #string_eval, #to_array, #to_bool, #to_string, #to_string_array

Methods inherited from PsObject

#<<, #call, #graphic_scope, #raw, #set, #to_s

Constructor Details

#initialize(text, options = {}, tag_parse = true) ⇒ TextArea

Options

  • :x and :y - Initial position.

  • :row_height - Row height :)

  • :with - Max wide of the text

  • :text_align - Align of the text in the virtual box using :left, :right and :center.

Examples

doc=RGhost::Document.new my_text=“<font1>foo, bar, baz</font1><font2>qux, quux</font2>, corge, grault, garply, waldo, <font3>fred, plugh,</font3> xyzzy,<br/> thud, bing” doc.text_area my_text

doc.text_area my_text, :width =>3

doc.text_area my_text, :width =>3, :text_align => :center

doc.text_area my_text, :width =>3, :text_align => :right

doc.text_area my_text, :width =>3, :text_align => :right, :x => 3

doc.text_area my_text, :width =>3, :text_align => :right, :x => 3, :row_height => 0.6



57
58
59
60
61
62
63
64
# File 'lib/rghost/textarea.rb', line 57

def initialize(text,options={},tag_parse=true)
  super("")
  @text=text
  @tag_parse=tag_parse
  options||={}
  @options=DEFAULT_OPTIONS.dup.merge(options)
  
end

Instance Method Details

#psObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/rghost/textarea.rb', line 66

def ps
  bw=RGhost::Units::parse(@options[:width])
  ta=@options[:text_align]
  rh=RGhost::Units::parse(@options[:row_height])
  
  graph=RGhost::Graphic.new do
    set RGhost::Variable.new(':bw',bw)
    set RGhost::Variable.new('text_align',"/#{ta}")
    #      set Variable.new(':rp',rp)
    set RGhost::Variable.new(':rh',rh)
  end
  graph.set RGhost::Cursor.translate(@options) 
  graph.set RGhost::Cursor.moveto(:x => 0, :y =>0) 
  #graph.raw ":text_area #{text_to_ps} :text_proc"
  graph.raw text_to_ps
  graph
  #final_text=text_to_ps
  
end