Class: WysiwygPrintEditor
- Inherits:
-
Gtk::Window
- Object
- Gtk::Window
- WysiwygPrintEditor
- Includes:
- Conf, ManqodCommon
- Defined in:
- lib/PrintEditor.rb
Constant Summary
Constants included from ManqodCommon
ManqodCommon::CRITICAL, ManqodCommon::DEBUG, ManqodCommon::ERROR, ManqodCommon::INFO, ManqodCommon::NORMAL, ManqodCommon::WARNING
Constants included from Eprint
Instance Attribute Summary collapse
-
#caller ⇒ Object
Returns the value of attribute caller.
-
#focused_item ⇒ Object
Returns the value of attribute focused_item.
-
#info ⇒ Object
Returns the value of attribute info.
-
#moditemid ⇒ Object
Returns the value of attribute moditemid.
-
#mydata ⇒ Object
Returns the value of attribute mydata.
-
#page_setup ⇒ Object
Returns the value of attribute page_setup.
-
#tabs ⇒ Object
Returns the value of attribute tabs.
-
#tips ⇒ Object
Returns the value of attribute tips.
-
#zoom ⇒ Object
Returns the value of attribute zoom.
Instance Method Summary collapse
-
#initialize(caller, moditemid) ⇒ WysiwygPrintEditor
constructor
A new instance of WysiwygPrintEditor.
- #inspect ⇒ Object
- #nth_page(page_no) ⇒ Object
- #run ⇒ Object
- #set_focused_item(item) ⇒ Object
- #to_mysql ⇒ Object
- #to_s ⇒ Object
Methods included from Conf
#get_conf, #load_conf, #save_conf, #set_conf
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
Constructor Details
#initialize(caller, moditemid) ⇒ WysiwygPrintEditor
Returns a new instance of WysiwygPrintEditor.
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 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 |
# File 'lib/PrintEditor.rb', line 10 def initialize(caller,moditemid) @zoom=1 @caller=caller @focused_item=nil @moditemid=moditemid @moditem=qrow("select moditems.*,gtkprintpages.*,queries.sql from moditems left join queries on moditems.query_sql_id = queries.id left join gtkprintpages on moditems.id = gtkprintpages.moditem_id where moditems.id='#{@moditemid}'") @sql=@moditem["sql"] @sql=@moditem["querysql"] if @moditem["querysql"].length>5 # [email protected]("where")-1 or @sql.length # @sql=@sql[0 .. lastwhere]+" order by id desc limit 1" @sql="#{@sql} limit 1" myres=client.query(@sql) @mydata=if myres then myres.fetch_hash(true) else Hash.new end @mydata=Hash.new if @mydata.nil? @page_setup=Gtk::PageSetup.new page_setup.paper_size=Gtk::PaperSize.new(@moditem["paper_size_name"]) page_setup.orientation=case @moditem["orientation"] when "portrait" then Gtk::PrintSettings::PageOrientation::PORTRAIT when "reverse_portrait" then Gtk::PrintSettings::PageOrientation::REVERSE_PORTRAIT when "landscape" then Gtk::PrintSettings::PageOrientation::LANDSCAPE when "reverse_landscape" then Gtk::PrintSettings::PageOrientation::REVERSE_LANDSCAPE else Gtk::PrintSettings::PageOrientation::PORTRAIT end page_setup.set_left_margin(@moditem["left_margin"].to_f,Gtk::PaperSize::UNIT_MM) if !@moditem["left_margin"].nil? page_setup.set_right_margin(@moditem["right_margin"].to_f,Gtk::PaperSize::UNIT_MM) if !@moditem["right_margin"].nil? page_setup.set_top_margin(@moditem["top_margin"].to_f,Gtk::PaperSize::UNIT_MM) if !@moditem["top_margin"].nil? page_setup.set_bottom_margin(@moditem["bottom_margin"].to_f,Gtk::PaperSize::UNIT_MM) if !@moditem["bottom_margin"].nil? super() realize @tips=Gtk::Tooltips.new.enable set_title("WYSIWYG Print Editor - "+@moditem["display"]) maximize @tabs=Gtk::Notebook.new is=Gtk::IconSize.from_name(get_conf(0,0,"button-size")) #item buttons =Gtk::Toolbar.new .append(Gtk::VSeparator.new) .append("text",nil,nil,Gtk::Image.new(Gtk::Stock::ADD,is)){set_focused_item(nth_page(tabs.page).put(@tabs.page,'text')) if tabs.page>-1} .append("line",nil,nil,Gtk::Image.new(Gtk::Stock::ADD,is)){set_focused_item(nth_page(tabs.page).put(@tabs.page,'line')) if tabs.page>-1} .append("rectangle",nil,nil,Gtk::Image.new(Gtk::Stock::ADD,is)){set_focused_item(nth_page(tabs.page).put(@tabs.page,'rectangle')) if tabs.page>-1} .append("list",nil,nil,Gtk::Image.new(Gtk::Stock::ADD,is)){set_focused_item(nth_page(tabs.page).put(@tabs.page,'list')) if tabs.page>-1} .append("image",nil,nil,Gtk::Image.new(Gtk::Stock::ADD,is)){set_focused_item(nth_page(tabs.page).put(@tabs.page,'image')) if tabs.page>-1} .append(Gtk::VSeparator.new) .append("clone",nil,nil,Gtk::Image.new(Gtk::Stock::COPY,is)){ set_focused_item(nth_page(tabs.page). put(@tabs.page,@focused_item.gtk_type,nil,@focused_item.x+@info.clone_x.value,@focused_item.y+@info.clone_y.value,@focused_item.width,@focused_item.height,@focused_item.text,@focused_item.font,@focused_item.text_alignment)) if tabs.page>-1 && @focused_item } .append("move",nil,nil,Gtk::Image.new(Gtk::Stock::MEDIA_FORWARD,is)){ @focused_item.move_me(@focused_item.x+@info.clone_x.value,@focused_item.y+@info.clone_y.value) if tabs.page>-1 && @focused_item } .append(Gtk::VSeparator.new) .append("remove",nil,nil,Gtk::Image.new(Gtk::Stock::DELETE,is)){ unless focused_item.nil? edebug("removing #{focused_item}","printing","info") focused_item.remove_from_mysql focused_item.page_layout.remove(focused_item) set_focused_item(nil) end } .append(Gtk::VSeparator.new) #page buttons .append("page",nil,nil,Gtk::Image.new(Gtk::Stock::ADD,is)){ tabs.append_page(lay=PageLayout.new(self),Gtk::Label.new("page "+(tabs.n_pages+1).to_s)) tabs.show_all } .append("page",nil,nil,Gtk::Image.new(Gtk::Stock::REMOVE,is)){ tabs.remove_page(tabs.page) } .append('setup',nil,nil,Gtk::Image.new(Gtk::Stock::PRINT,Gtk::IconSize.from_name(get_conf(0,0,"button-size")))){ @page_setup=Gtk::PrintOperation.run_page_setup_dialog(self.get_ancestor(Gtk::Window), page_setup) nth_page(tabs.page).clear } .append(Gtk::VSeparator.new) #common buttons .append("20%",nil,nil,Gtk::Image.new(Gtk::Stock::ZOOM_IN,is)){ @zoom+=0.2 unless @zoom>5 @tabs.each{|page| page.clear} } .append("100%",nil,nil,Gtk::Image.new(Gtk::Stock::ZOOM_100,is)){ @zoom=1 @tabs.each{|page| page.clear} } .append("20%",nil,nil,Gtk::Image.new(Gtk::Stock::ZOOM_OUT,is)){ @zoom-=0.2 unless @zoom<0.5 @tabs.each{|page| page.clear} } .append('preview',nil,nil,Gtk::Image.new(Gtk::Stock::PRINT,Gtk::IconSize.from_name(get_conf(0,0,"button-size")))){ to_mysql if testp=MyPrintOperation.new(self,moditemid) testp.run(Gtk::PrintOperation::ACTION_PREVIEW) end } .append('close',nil,nil,Gtk::Image.new(Gtk::Stock::CLOSE,Gtk::IconSize.from_name(get_conf(0,0,"button-size")))){ self.destroy } .append(Gtk::VSeparator.new) signal_connect("destroy"){|me,ev| to_mysql} @info=LayItemInfo.new.set_width_request(220) tab_holder=Gtk::HPaned.new#(false,0) tab_holder.pack1(tabs,true,true) tab_holder.pack2(info,false,false) holder=Gtk::VBox.new(false,1) holder.pack_start(tab_holder,true,true,0) holder.pack_end(,false,false,0) add(holder) self end |
Instance Attribute Details
#caller ⇒ Object
Returns the value of attribute caller.
127 128 129 |
# File 'lib/PrintEditor.rb', line 127 def caller @caller end |
#focused_item ⇒ Object
Returns the value of attribute focused_item.
129 130 131 |
# File 'lib/PrintEditor.rb', line 129 def focused_item @focused_item end |
#info ⇒ Object
Returns the value of attribute info.
133 134 135 |
# File 'lib/PrintEditor.rb', line 133 def info @info end |
#moditemid ⇒ Object
Returns the value of attribute moditemid.
131 132 133 |
# File 'lib/PrintEditor.rb', line 131 def moditemid @moditemid end |
#mydata ⇒ Object
Returns the value of attribute mydata.
130 131 132 |
# File 'lib/PrintEditor.rb', line 130 def mydata @mydata end |
#page_setup ⇒ Object
Returns the value of attribute page_setup.
132 133 134 |
# File 'lib/PrintEditor.rb', line 132 def page_setup @page_setup end |
#tabs ⇒ Object
Returns the value of attribute tabs.
128 129 130 |
# File 'lib/PrintEditor.rb', line 128 def tabs @tabs end |
#tips ⇒ Object
Returns the value of attribute tips.
133 134 135 |
# File 'lib/PrintEditor.rb', line 133 def tips @tips end |
#zoom ⇒ Object
Returns the value of attribute zoom.
133 134 135 |
# File 'lib/PrintEditor.rb', line 133 def zoom @zoom end |
Instance Method Details
#inspect ⇒ Object
196 197 198 |
# File 'lib/PrintEditor.rb', line 196 def inspect to_s end |
#nth_page(page_no) ⇒ Object
166 167 168 |
# File 'lib/PrintEditor.rb', line 166 def nth_page(page_no) ret=tabs.get_nth_page(page_no.to_i) end |
#run ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/PrintEditor.rb', line 152 def run item_res=query("select * from gtkprintitems where printid='#{@moditemid}' order by page_number,gtktype") page_num=0 while itemdata=item_res.fetch_hash() while nth_page(itemdata["page_number"].to_i).nil? page_num+=1 page=tabs.append_page(lay=PageLayout.new(self),Gtk::Label.new("page #{page_num}")) end nth_page(itemdata["page_number"].to_i).put(itemdata["page_number"],itemdata["gtktype"],itemdata["id"],itemdata["x"].to_i,itemdata["y"].to_i,itemdata["width"].to_i,itemdata["height"].to_i,itemdata["txt"],itemdata["font"],itemdata["text_alignment"]) end show_all info.update(focused_item) end |
#set_focused_item(item) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/PrintEditor.rb', line 135 def set_focused_item(item) return if focused_item == item focused_item.unfocus unless focused_item.nil? @focused_item=item if focused_item.nil? set_focus_child(nil) else focused_item.set_state(Gtk::STATE_PRELIGHT) focused_item.set_editable(true) focused_item.set_has_focus(true) set_focus_child(focused_item) edebug(focused_item.text+" selected","printing","info") end info.update(focused_item) focused_item end |
#to_mysql ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/PrintEditor.rb', line 170 def to_mysql #=Gtk::PaperSize.new(@moditem["paper_size_name"]) $sql="replace into gtkprintpages set moditem_id='#{moditemid}', paper_size_name='#{page_setup.paper_size.name}', orientation='#{ case page_setup.orientation when Gtk::PrintSettings::PageOrientation::PORTRAIT then "portrait" when Gtk::PrintSettings::PageOrientation::REVERSE_PORTRAIT then "reverse_portrait" when Gtk::PrintSettings::PageOrientation::LANDSCAPE then "landscape" when Gtk::PrintSettings::PageOrientation::REVERSE_LANDSCAPE then "reverse_landscape" else "portrait" end}', left_margin='#{page_setup.get_left_margin(Gtk::PaperSize::UNIT_MM)}',"+ "right_margin='#{page_setup.get_right_margin(Gtk::PaperSize::UNIT_MM)}',"+ "top_margin='#{page_setup.get_top_margin(Gtk::PaperSize::UNIT_MM)}',"+ "bottom_margin='#{page_setup.get_bottom_margin(Gtk::PaperSize::UNIT_MM)}'" query($sql) edebug("saved","printing","info") page_num=0 tabs.each{|tab| nth_page(page_num).to_mysql unless nth_page(page_num).nil? page_num+=1 } end |
#to_s ⇒ Object
193 194 195 |
# File 'lib/PrintEditor.rb', line 193 def to_s "WysiwygPrintEditor" end |