Class: PageLayout
- Inherits:
-
Gtk::ScrolledWindow
- Object
- Gtk::ScrolledWindow
- PageLayout
show all
- Includes:
- Conf, ManqodCommon
- Defined in:
- lib/PrintEditor/PageLayout.rb
Constant Summary
ManqodCommon::CRITICAL, ManqodCommon::DEBUG, ManqodCommon::ERROR, ManqodCommon::INFO, ManqodCommon::NORMAL, ManqodCommon::WARNING
Constants included
from Eprint
Eprint::DOMAIN, Eprint::LEVEL
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#clear ⇒ Object
-
#inc_size(w, h) ⇒ Object
-
#initialize(print_editor) ⇒ PageLayout
constructor
A new instance of PageLayout.
-
#move(ch) ⇒ Object
-
#put(page_num, gtk_type, id = nil, x = 0, y = 0, width = 100, height = 100, text = '', font = "", ta = "left") ⇒ Object
-
#remove(item) ⇒ Object
-
#to_mysql ⇒ Object
-
#to_s ⇒ Object
Methods included from Conf
#get_conf, #load_conf, #save_conf, #set_conf
#add_where, #admin, #admin_cache, #admin_qrow, #admin_rows, #backtrace_to_debug, #cache, #changed_ids_of_base, #client, #client_fields, #client_image_of_id, #client_qrow, #client_query, #client_rows, #eeval, #escape_string, #getBinding, #guess_base, #guess_table, #image_of_id, #lzero, #manqod_db, #measure, #myexec, #nick, #nick_id, #number_format, #qrow, #query, #reconnect_manqod_db, #rows, #run_events, #send_message, #sendmail, #set_manqod_db_uri, #set_nick
Methods included from Eprint
#ecode, #edebug, #eerror, #einfo, #enormal, #eprint, #ewarn, #gtk_set_edebug, #set_edebug, #tell_exception
Constructor Details
#initialize(print_editor) ⇒ PageLayout
Returns a new instance of PageLayout.
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
|
# File 'lib/PrintEditor/PageLayout.rb', line 10
def initialize(print_editor)
@print_editor=print_editor
super()
@widget=Gtk::Layout.new
@widget.set_size_request(
@print_editor.page_setup.get_page_width(Gtk::PaperSize::UNIT_POINTS).to_f*@print_editor.zoom,
@print_editor.page_setup.get_page_height(Gtk::PaperSize::UNIT_POINTS).to_f*@print_editor.zoom
)
add_with_viewport(@eb=Gtk::EventBox.new.add(@widget))
@eb.set_visible_window(false)
@eb.set_border_width(0)
@widget.signal_connect('expose-event'){|me,event|
return false if @print_editor.page_setup.nil?
cr=me.bin_window.create_cairo_context
cr.scale(@print_editor.zoom,@print_editor.zoom)
cr.set_line_width(0.2)
cr.set_source_rgba(0,0,1,1)
ps=@print_editor.page_setup
paper_height = ps.get_page_height(Gtk::PaperSize::UNIT_POINTS).to_f
paper_width = ps.get_page_width(Gtk::PaperSize::UNIT_POINTS).to_f
cr.rectangle(0,0,paper_width,paper_height)
cr.rectangle(
ps.get_left_margin(Gtk::PaperSize::UNIT_POINTS),
ps.get_top_margin(Gtk::PaperSize::UNIT_POINTS),
paper_width-ps.get_left_margin(Gtk::PaperSize::UNIT_POINTS)-ps.get_right_margin(Gtk::PaperSize::UNIT_POINTS),
paper_height-ps.get_top_margin(Gtk::PaperSize::UNIT_POINTS)-ps.get_bottom_margin(Gtk::PaperSize::UNIT_POINTS)
)
cr.stroke_preserve
cr.set_source_rgba(1,1,1,0.5)
cr.fill(true)
cr.stroke
}
@eb.signal_connect('button-press-event'){|me,event| @print_editor.set_focused_item(nil)}
end
|
Instance Attribute Details
#print_editor ⇒ Object
Returns the value of attribute print_editor.
52
53
54
|
# File 'lib/PrintEditor/PageLayout.rb', line 52
def print_editor
@print_editor
end
|
Instance Method Details
#clear ⇒ Object
80
81
82
83
84
85
|
# File 'lib/PrintEditor/PageLayout.rb', line 80
def clear
unless @widget.window.nil?
@widget.each{|ch| ch.zoomed}
@widget.window.invalidate(Gdk::Rectangle.new(0,0,@widget.allocation.width,@widget.allocation.height),true)
end
end
|
#inc_size(w, h) ⇒ Object
54
55
56
57
|
# File 'lib/PrintEditor/PageLayout.rb', line 54
def inc_size(w,h)
@widget.set_width_request(w.to_i*print_editor.zoom+10) if @widget.allocation.width < w.to_i*print_editor.zoom+10
@widget.set_height_request(h.to_i*print_editor.zoom+10) if @widget.allocation.height < h.to_i*print_editor.zoom+10
end
|
#move(ch) ⇒ Object
68
69
70
71
|
# File 'lib/PrintEditor/PageLayout.rb', line 68
def move(ch)
inc_size(ch.x+ch.width,ch.y+ch.height)
@widget.move(ch,ch.x*print_editor.zoom,ch.y*print_editor.zoom)
end
|
#put(page_num, gtk_type, id = nil, x = 0, y = 0, width = 100, height = 100, text = '', font = "", ta = "left") ⇒ Object
59
60
61
62
63
64
65
66
|
# File 'lib/PrintEditor/PageLayout.rb', line 59
def put(page_num,gtk_type,id=nil,x=0,y=0,width=100,height=100,text='',font="",ta="left")
l=PrintEditorItem.new(self,page_num,id,x,y,width,height,gtk_type,text,font,ta)
inc_size(x+width,y+height)
@widget.put(l,l.x*print_editor.zoom,l.y*print_editor.zoom)
l.text_from_mysql(text)
show_all
l
end
|
#remove(item) ⇒ Object
72
73
74
|
# File 'lib/PrintEditor/PageLayout.rb', line 72
def remove(item)
@widget.remove(item)
end
|
#to_mysql ⇒ Object
76
77
78
|
# File 'lib/PrintEditor/PageLayout.rb', line 76
def to_mysql
@widget.each{|ch| ch.to_mysql}
end
|
#to_s ⇒ Object
87
88
89
|
# File 'lib/PrintEditor/PageLayout.rb', line 87
def to_s
"Page of #{@print_editor}"
end
|