class PageLayout
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
Attributes
print_editor[RW]
Public Class Methods
new(print_editor)
click to toggle source
Calls superclass method
# 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)) #.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC) # @widget.modify_bg(Gtk::StateType::NORMAL,Gdk::Color.parse("#0FFFFF")) @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.move_to(paper_width/2,paper_height/2) # cr.fill cr.stroke } @eb.signal_connect('button-press-event'){|me,event| @print_editor.set_focused_item(nil)} end
Public Instance Methods
clear()
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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")
click to toggle source
# 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)
click to toggle source
# File lib/PrintEditor/PageLayout.rb, line 72 def remove(item) @widget.remove(item) end
to_mysql()
click to toggle source
# File lib/PrintEditor/PageLayout.rb, line 76 def to_mysql @widget.each{|ch| ch.to_mysql} end
to_s()
click to toggle source
# File lib/PrintEditor/PageLayout.rb, line 87 def to_s "Page of #{@print_editor}" end