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
|
require "rghost/point"
require "rghost/ps_object"
require "rghost/point_with_command"
# It resposible to cursor manipulate. Use it to position objects on the page.
class RGhost::Cursor < RGhost::PsObject
# The class method goto positioned the cursor based on page row number. Example:
# d=Document.new
# d.goto_row 15
# d.show " You're on row 15"
# d.goto_row 3
# d.show "Now you're on row 3"
#
# #or without facade(**it's valid for all methods on this class**)
#
# d=Document.new
# d.set Cursor.goto_row(15)
# d.set Show.new(" You're on row 15")
# d.set Cursor.goto_row(3)
# d.set Show.new("Now you're on row 3")
def self.goto_row(row)
g = RGhost::PsObject.new(row.to_i)
g.call :goto_row
g.call :default_point
g
end
# Jump n rows relative to the current row
# d=Document.new
# d.jump_row 4 # jump four rows below
# d.jump_row -5 # backing five rows to up
def self.jump_rows(row)
j = RGhost::PsObject.new(row.to_i)
j.call :jump_rows
j.call :default_point
j
end
# Rotate all objects after execution it, passing the angle as argument.
# d=Document.new
# d.rotate 90
# #do something
# d.rotate -90 # backing to source angle
def self.rotate(angle)
r = RGhost::PsObject.new(angle.to_i)
r.call :rotate
r
end
# Move cursor to absolute point relative from default source point x=0 and y=0 of the page. It no interferes to the rows positions.
# doc=Document.new
# doc.moveto :x=> 10, :y=> 5
# doc.show "Hello Girls!!!"
def self.moveto(point = {})
RGhost::PointWithCommand.to(:moveto, point)
end
# It works the same way that moveto, the unique difference it's relative from current point.
# doc=Document.new
# doc.moveto :x=> 10, :y=> 5
# doc.show "Hello Girls!!!"
# doc.rmoveto :x => 5 # move to x=> 15 (10 plus 5) maintaining y => 5
def self.rmoveto(point = {})
RGhost::PointWithCommand.to(:rmoveto, point)
end
# It changes the default pont to a new point(dislocate)
# doc=Document.new
# doc.translate :x=> 2, :y=> 1
# doc.moveto :x => 0,:y => 0 # if it was default point(0,0) would be :x=> 2, :y=> 1
# doc.translate :x=> -2, :y=> -1 # return to default source point
def self.translate(point = {x: 0, y: 0})
p = {x: 0, y: 0}.merge(point)
RGhost::PointWithCommand.to(:translate, p)
end
# Jump one next row. It's same that jump_row(1).
# doc=Document.new
# doc.show "Row 1"
# doc.next_row
# doc.show "Row 2"
# doc.next_row
# doc.show "Row 3"
def self.next_row
RGhost::PsObject.new(:nrdp)
end
# It go to next page resetting the cursors.
# doc=Document.new
# doc.show "Page 1 row 1"
# doc.next_page
# doc.show "Page 2 row 1"
# doc.next_page
# doc.show "Page 3 row 1"
def next_page
RGhost::PsObject.new :next_page
end
# It go to next page without resetting the cursors. Often used for single page document.
# doc=Document.new
# doc.show "Page 1 row 1"
# doc.showpage # page 2, but internally
# doc.show "Page 1 row 1"
# doc.showpage # page 3
# doc.show "Page 1 row 1"
def showpage
RGhost::PsObject.new :showpage
end
# (Class method) It go to next page resetting the cursors.
# doc=Document.new
# doc.show "Page 1 row 1"
# doc.next_page
# doc.show "Page 2 row 1"
# doc.next_page
# doc.show "Page 3 row 1"
def self.next_page
RGhost::PsObject.new :next_page
end
# (Class method) It go to next page without resetting the cursors. Often used for single page document.
# doc=Document.new
# doc.show "Page 1 row 1"
# doc.showpage # page 2, but internally
# doc.show "Page 1 row 1"
# doc.showpage # page 3
# doc.show "Page 1 row 1"
def self.showpage
RGhost::PsObject.new :showpage
end
end
|