Class: LayItemInfo

Inherits:
Gtk::Table
  • Object
show all
Includes:
Conf, ManqodCommon
Defined in:
lib/PrintEditor/ItemInfo.rb

Overview

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])

Constant Summary

Constants included from ManqodCommon

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

Methods included from ManqodCommon

#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

Methods included from Conf

#get_conf, #load_conf, #save_conf, #set_conf

Constructor Details

#initializeLayItemInfo

Returns a new instance of LayItemInfo.



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
# 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

Instance Attribute Details

#clone_xObject (readonly)

Returns the value of attribute clone_x.



95
96
97
# File 'lib/PrintEditor/ItemInfo.rb', line 95

def clone_x
  @clone_x
end

#clone_yObject (readonly)

Returns the value of attribute clone_y.



95
96
97
# File 'lib/PrintEditor/ItemInfo.rb', line 95

def clone_y
  @clone_y
end

#itemObject

Returns the value of attribute item.



94
95
96
# File 'lib/PrintEditor/ItemInfo.rb', line 94

def item
  @item
end

#item_fontObject

Returns the value of attribute item_font.



94
95
96
# File 'lib/PrintEditor/ItemInfo.rb', line 94

def item_font
  @item_font
end

#item_heightObject

Returns the value of attribute item_height.



94
95
96
# File 'lib/PrintEditor/ItemInfo.rb', line 94

def item_height
  @item_height
end

#item_imageObject

Returns the value of attribute item_image.



94
95
96
# File 'lib/PrintEditor/ItemInfo.rb', line 94

def item_image
  @item_image
end

#item_listObject

Returns the value of attribute item_list.



94
95
96
# File 'lib/PrintEditor/ItemInfo.rb', line 94

def item_list
  @item_list
end

#item_pagenumObject

Returns the value of attribute item_pagenum.



94
95
96
# File 'lib/PrintEditor/ItemInfo.rb', line 94

def item_pagenum
  @item_pagenum
end

#item_textObject

Returns the value of attribute item_text.



94
95
96
# File 'lib/PrintEditor/ItemInfo.rb', line 94

def item_text
  @item_text
end

#item_typeObject

Returns the value of attribute item_type.



94
95
96
# File 'lib/PrintEditor/ItemInfo.rb', line 94

def item_type
  @item_type
end

#item_widthObject

Returns the value of attribute item_width.



94
95
96
# File 'lib/PrintEditor/ItemInfo.rb', line 94

def item_width
  @item_width
end

#item_xObject

Returns the value of attribute item_x.



94
95
96
# File 'lib/PrintEditor/ItemInfo.rb', line 94

def item_x
  @item_x
end

#item_yObject

Returns the value of attribute item_y.



94
95
96
# File 'lib/PrintEditor/ItemInfo.rb', line 94

def item_y
  @item_y
end

Instance Method Details

#update(item) ⇒ Object



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
# 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