Class: CustomPageSetup

Inherits:
Gtk::Table
  • Object
show all
Defined in:
lib/ListHolder/EditableList/ListPrintOperation/CustomPageSetup.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])

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pop) ⇒ CustomPageSetup

Returns a new instance of CustomPageSetup.



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
# File 'lib/ListHolder/EditableList/ListPrintOperation/CustomPageSetup.rb', line 6

def initialize(pop)
	@pop=pop
	@page_setup=@pop.default_page_setup
	super(4,4,false)
	set_border_width(10)
	set_row_spacings(5)
	set_column_spacings(5)
	
	#orientation
	ochooser=Gtk::VBox.new(true)

	ochooser.pack_start(pch=Gtk::RadioButton.new(Gtk::Stock::ORIENTATION_PORTRAIT).set_active(page_setup.orientation==Gtk::PrintSettings::ORIENTATION_PORTRAIT))
	pch.signal_connect("toggled"){|me| page_setup.set_orientation(Gtk::PrintSettings::ORIENTATION_PORTRAIT) if me.active?}

	ochooser.pack_start(lch=Gtk::RadioButton.new(pch,Gtk::Stock::ORIENTATION_LANDSCAPE).set_active(page_setup.orientation==Gtk::PrintSettings::ORIENTATION_LANDSCAPE))
	lch.signal_connect("toggled"){|me| page_setup.set_orientation(Gtk::PrintSettings::ORIENTATION_LANDSCAPE) if me.active?}
	
	ochooser.pack_start(rlch=Gtk::RadioButton.new(pch,Gtk::Stock::ORIENTATION_REVERSE_LANDSCAPE).set_active(page_setup.orientation==Gtk::PrintSettings::ORIENTATION_REVERSE_LANDSCAPE))
	rlch.signal_connect("toggled"){|me| page_setup.set_orientation(Gtk::PrintSettings::ORIENTATION_REVERSE_LANDSCAPE) if me.active?}
	
	ochooser.pack_start(rpch=Gtk::RadioButton.new(pch,Gtk::Stock::ORIENTATION_REVERSE_PORTRAIT).set_active(page_setup.orientation==Gtk::PrintSettings::ORIENTATION_REVERSE_PORTRAIT))
	rpch.signal_connect("toggled"){|me| page_setup.set_orientation(Gtk::PrintSettings::ORIENTATION_REVERSE_PORTRAIT) if me.active?}

	#format
	pchooser=Gtk::VBox.new(true)
	pchooser.pack_start(a3=Gtk::RadioButton.new("A3").set_active(page_setup.paper_size.name==Gtk::PaperSize::A3))
	a3.signal_connect("toggled"){|me| page_setup.set_paper_size_and_default_margins(Gtk::PaperSize.new(Gtk::PaperSize::A3)) if me.active?}
	
	pchooser.pack_start(a4=Gtk::RadioButton.new(a3,"A4").set_active(page_setup.paper_size.name==Gtk::PaperSize::A4))
	a4.signal_connect("toggled"){|me| page_setup.set_paper_size_and_default_margins(Gtk::PaperSize.new(Gtk::PaperSize::A4)) if me.active?}
	
	pchooser.pack_start(a5=Gtk::RadioButton.new(a3,"A5").set_active(page_setup.paper_size.name==Gtk::PaperSize::A5))
	a5.signal_connect("toggled"){|me,ps| page_setup.set_paper_size_and_default_margins(Gtk::PaperSize.new(Gtk::PaperSize::A5)) if me.active?}

	pchooser.pack_start(b5=Gtk::RadioButton.new(a3,"B5").set_active(page_setup.paper_size.name==Gtk::PaperSize::B5))
	b5.signal_connect("toggled"){|me| page_setup.set_paper_size_and_default_margins(Gtk::PaperSize.new(Gtk::PaperSize::B5)) if me.active?}

	pchooser.pack_start(executive=Gtk::RadioButton.new(a3,"executive").set_active(page_setup.paper_size.name==Gtk::PaperSize::EXECUTIVE))
	executive.signal_connect("toggled"){|me| page_setup.set_paper_size_and_default_margins(Gtk::PaperSize.new(Gtk::PaperSize::EXECUTIVE)) if me.active?}

	pchooser.pack_start(legal=Gtk::RadioButton.new(a3,"legal").set_active(page_setup.paper_size.name==Gtk::PaperSize::LEGAL))
	legal.signal_connect("toggled"){|me| page_setup.set_paper_size_and_default_margins(Gtk::PaperSize.new(Gtk::PaperSize::LEGAL)) if me.active?}

	pchooser.pack_start(letter=Gtk::RadioButton.new(a3,"letter").set_active(page_setup.paper_size.name==Gtk::PaperSize::LETTER))
	letter.signal_connect("toggled"){|me| page_setup.set_paper_size_and_default_margins(Gtk::PaperSize.new(Gtk::PaperSize::LETTER)) if me.active?}

#				margins=Gtk::Table.new(2,2)
#				margins.attach(topm=Gtk::SpinButton.new(0,10,0.1),0,1,0,1,Gtk::FILL,Gtk::FILL)
#				topm.signal_connect("value-changed",@page_setup){|me,arg1,ps| ps.

	#page_setup
	page_setup_b=Gtk::Button.new("change")
	page_setup_b.signal_connect("clicked"){|b|
		@page_setup=Gtk::PrintOperation.run_page_setup_dialog(get_ancestor(Gtk::Window), @page_setup)
	}
	
	#custom print settings like line on header/footer
	csettings=Gtk::VBox.new(false)
	csettings.pack_start(draw_header_line=Gtk::CheckButton.new("draw header line").set_active(@pop.draw_header_line))
	draw_header_line.signal_connect("toggled"){|me| @pop.draw_header_line=me.active?}
	csettings.pack_start(draw_footer_line=Gtk::CheckButton.new("draw footer line").set_active(@pop.draw_footer_line))
	draw_footer_line.signal_connect("toggled"){|me| @pop.draw_footer_line=me.active?}
	csettings.pack_start(draw_header_background=Gtk::CheckButton.new("draw header background").set_active(@pop.draw_header_background))
	draw_header_background.signal_connect("toggled"){|me| @pop.draw_header_background=me.active?}
	csettings.pack_start(print_date=Gtk::CheckButton.new("print date").set_active(@pop.print_date))
	print_date.signal_connect("toggled"){|me| @pop.print_date=me.active?}
	
	csettings.pack_start(font_table=Gtk::Table.new(5,2,false))
	font_table.attach(Gtk::Label.new("header font"),0,1,0,1).attach(header_font=Gtk::FontButton.new(@pop.header_font),1,2,0,1)
	header_font.signal_connect("font-set"){|me| @pop.header_font=me.font_name}

	font_table.attach(Gtk::Label.new("date font"),0,1,1,2).attach(date_font=Gtk::FontButton.new(@pop.date_font),1,2,1,2)
	date_font.signal_connect("font-set"){|me| @pop.date_font=me.font_name}

	font_table.attach(Gtk::Label.new("footer font"),0,1,2,3).attach(header_font=Gtk::FontButton.new(@pop.footer_font),1,2,2,3)
	header_font.signal_connect("font-set"){|me| @pop.footer_font=me.font_name}

	font_table.attach(Gtk::Label.new("column header font"),0,1,3,4).attach(column_header_font=Gtk::FontButton.new(@pop.column_header_font),1,2,3,4)
	column_header_font.signal_connect("font-set"){|me| @pop.column_header_font=me.font_name}

	font_table.attach(Gtk::Label.new("cell font"),0,1,4,5).attach(cell_font=Gtk::FontButton.new(@pop.cell_font),1,2,4,5)
	cell_font.signal_connect("font-set"){|me| @pop.cell_font=me.font_name}
	
	

	attach(Gtk::Frame.new("Orientation").set_child(ochooser).set_shadow_type(Gtk::ShadowType::NONE),0,1,0,1,Gtk::FILL,Gtk::FILL)
	attach(Gtk::Frame.new("Paper size").set_child(pchooser).set_shadow_type(Gtk::ShadowType::NONE),1,2,0,1,Gtk::FILL,Gtk::FILL)
	attach(Gtk::Frame.new("Print setup").set_child(page_setup_b).set_shadow_type(Gtk::ShadowType::NONE),0,1,1,2,Gtk::FILL,Gtk::FILL)
	attach(Gtk::Frame.new("Custom settings").set_child(csettings).set_shadow_type(Gtk::ShadowType::NONE),1,2,1,2,Gtk::FILL,Gtk::FILL)
	show_all
end

Instance Attribute Details

#page_setupObject

Returns the value of attribute page_setup.



97
98
99
# File 'lib/ListHolder/EditableList/ListPrintOperation/CustomPageSetup.rb', line 97

def page_setup
  @page_setup
end