00001 /* 00002 00003 This file is part of Kitlist, a program to maintain a simple list 00004 of items and assign items to one or more categories. 00005 00006 Copyright (C) 2008,2009 Frank Dean 00007 00008 Kitlist is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation, either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 Kitlist is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with Kitlist. If not, see <http://www.gnu.org/licenses/>. 00020 00021 */ 00022 00023 #ifndef PRINTING_H 00024 #define PRINTING_H 00025 00026 #include "item.hpp" 00027 #include <gtkmm/printcontext.h> 00028 #include <gtkmm/printoperation.h> 00029 00030 typedef Glib::RefPtr<Pango::Layout> layout_refptr; 00031 00035 class KitPrintOperation : public Gtk::PrintOperation { 00036 ItemContainer* m_items; 00037 Glib::ustring m_page_title; 00038 public: 00039 static Glib::RefPtr<KitPrintOperation> create(); 00041 void set_items(ItemContainer* items) {m_items = items;} 00042 void set_page_title(const Glib::ustring page_title) {m_page_title = page_title;} 00043 ~KitPrintOperation(); 00044 protected: 00045 layout_refptr new_header(const Glib::RefPtr<Gtk::PrintContext>& context); 00046 layout_refptr new_footer(const Glib::RefPtr<Gtk::PrintContext>& context); 00047 virtual void on_begin_print(const Glib::RefPtr<Gtk::PrintContext>& context); 00048 virtual void on_draw_page(const Glib::RefPtr<Gtk::PrintContext>& context, int page_number); 00050 layout_refptr m_ref_layout; 00052 std::vector<int> m_page_breaks; 00054 std::vector<layout_refptr> m_ref_headers; 00056 std::vector<layout_refptr> m_ref_footers; 00057 }; 00058 00059 #endif //PRINTING_H