class LayItemInfo
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
clone_x[R]
clone_y[R]
item[RW]
item_font[RW]
item_height[RW]
item_image[RW]
item_list[RW]
item_pagenum[RW]
item_text[RW]
item_type[RW]
item_width[RW]
item_x[RW]
item_y[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/PrintEditor/ItemInfo.rb, line 10 def initialize super(3,10,false) set_border_width(1) attach(Gtk::Frame.new("type").add(@item_type=Gtk::Label.new("none")),0,3,0,1,Gtk::FILL,Gtk::SHRINK) attach(Gtk::Frame.new("left").add(@item_x=Gtk::SpinButton.new(0,5000,1)),0,1,1,2,Gtk::FILL,Gtk::SHRINK) attach(Gtk::Frame.new("width").add(@item_width=Gtk::SpinButton.new(0,5000,1)),1,2,1,2,Gtk::FILL,Gtk::SHRINK) attach(Gtk::Frame.new("right").add(@item_right=Gtk::SpinButton.new(0,5000,1)),2,3,1,2,Gtk::FILL,Gtk::SHRINK) attach(Gtk::Frame.new("top").add(@item_y=Gtk::SpinButton.new(0,5000,1)),0,1,2,3,Gtk::FILL,Gtk::SHRINK) attach(Gtk::Frame.new("height").add(@item_height=Gtk::SpinButton.new(0,5000,1)),1,2,2,3,Gtk::FILL,Gtk::SHRINK) attach(Gtk::Frame.new("bottom").add(@item_bottom=Gtk::SpinButton.new(0,5000,1)),2,3,2,3,Gtk::FILL,Gtk::SHRINK) attach(Gtk::Frame.new("page number").add(@item_pagenum=Gtk::SpinButton.new(0,10,1).set_sensitive(false)),0,3,3,4,Gtk::FILL,Gtk::SHRINK) attach(@font_frame=Gtk::Frame.new("font").add(@item_font=Gtk::FontButton.new("")),0,3,4,5,Gtk::FILL,Gtk::SHRINK) attach(@text_frame=Gtk::Frame.new("text").add(@item_text=Gtk::TextView.new(@buffer=Gtk::TextBuffer.new.set_text("none"))),0,3,5,6) attach(@image_frame=Gtk::Frame.new("image").add(@item_image=ItemImage.new),0,3,6,7,Gtk::FILL,Gtk::SHRINK) attach(@list_frame=Gtk::Frame.new("list").add(@item_list=ItemList.new),0,3,7,8,Gtk::FILL,Gtk::SHRINK) attach(@align_frame=Gtk::Frame.new("list").add(@item_align=ItemTextAlignment.new),0,3,8,9,Gtk::FILL,Gtk::SHRINK) attach(Gtk::Label.new("clone\r\nor move"),0,1,9,10,Gtk::FILL,Gtk::SHRINK) attach(Gtk::Frame.new("left+").add(@clone_x=Gtk::SpinButton.new(-5000,5000,1).set_value(0)),1,2,9,10,Gtk::FILL,Gtk::SHRINK) attach(Gtk::Frame.new("top+").add(@clone_y=Gtk::SpinButton.new(-5000,5000,1).set_value(0)),2,3,9,10,Gtk::FILL,Gtk::SHRINK) attach(Gtk::Label.new,0,3,10,11) @item_x.signal_connect('value-changed'){|me| unless item.nil? || @item_x.value == @item.x item.move_me(@item_x.value,@item.y) @item_right.set_value(@item_x.value+@item_width.value) end } @item_width.signal_connect('value-changed'){|me| unless item.nil? || @item_width.value == @item.width item.set_size_request(@item_width.value,@item.height) @item_right.set_value(@item_x.value+@item_width.value) end } @item_y.signal_connect('value-changed'){|me| unless item.nil? || @item_y.value == @item.y item.move_me(@item.x,@item_y.value) @item_bottom.set_value(@item_y.value+@item_height.value) end } @item_height.signal_connect('value-changed'){|me| unless item.nil? || @item_height.value == @item.height item.set_size_request(@item.width,@item_height.value) @item_bottom.set_value(@item_y.value+@item_height.value) end } @item_right.signal_connect('value-changed'){|me| @item_x.set_value(me.value-@item_width.value)} @item_bottom.signal_connect('value-changed'){|me| @item_y.set_value(me.value-@item_height.value)} @item_pagenum.signal_connect('value-changed'){|me| item.move_me(@item.x,@item.y,@item_pagenum.value) unless item.nil?} @item_font.signal_connect("font-set"){|me| @item.modify_font(me.font_name) unless @item.nil?} item_text.signal_connect('populate-popup'){|me,menu| m=Gtk::ImageMenuItem.new("Insert Mysql Data Source").set_image(Gtk::Image.new(Gtk::Stock::ADD,Gtk::IconSize::IconSize::MENU)) m.submenu=Gtk::Menu.new get_ancestor(WysiwygPrintEditor).mydata.sort.each{|h| mm=Gtk::ImageMenuItem.new("#{h[0]}(#{h[1]})",false).set_image(Gtk::Image.new(Gtk::Stock::ADD,Gtk::IconSize::IconSize::MENU)) mm.signal_connect('activate',me.buffer,h[0],h[1]){|me,buffer,key,data| data="N/A" if data.nil? || data == "" unless tag = buffer.tag_table.lookup(key) tag=Gtk::TextTag.new(key).set_foreground_gdk(Gdk::Color.new(65000,0,0)) buffer.tag_table.add(tag) end buffer.insert_at_cursor(data) bounds=buffer.selection_bounds bounds[0].backward_cursor_positions(data.length) buffer.apply_tag(tag,bounds[0],bounds[1]) } m.submenu.append(mm) } menu.append(m) menu.show_all } end
Public Instance Methods
update(item)
click to toggle source
# File lib/PrintEditor/ItemInfo.rb, line 97 def update(item) set_visible(!item.nil?) unless item.nil? @item=item @item_type.set_label(item.gtk_type) @item_x.set_value(item.x) @item_y.set_value(item.y) @item_width.set_value(item.width) @item_right.set_value(@item_x.value+@item_width.value) @item_height.set_value(item.height) @item_bottom.set_value(@item_y.value+@item_height.value) @item_pagenum.set_value(item.pagenum.to_f) @text_frame.set_visible(['text','list'].include?(item.gtk_type)) @font_frame.set_visible(item.gtk_type=="text") @align_frame.set_visible(item.gtk_type=="text") @image_frame.set_visible(item.gtk_type=="image") @list_frame.set_visible(item.gtk_type=="list") case item.gtk_type when "text" # item_text.set_label(item.text) item_text.set_buffer(item.child.buffer) item_font.set_font_name(item.font) @item_align.update(item) when "image" then item_image.update(item) when "list" then item_list.update(item) else # item_text.set_label("") item_text.set_buffer(@buffer) # item_font.set_label("") end end end