Kitlist  1.1.0
printing.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of Kitlist, a program to maintain a simple list
4  of items and assign items to one or more categories.
5 
6  Copyright (C) 2008,2009 Frank Dean
7 
8  Kitlist is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  Kitlist is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Kitlist. If not, see <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifndef PRINTING_H
24 #define PRINTING_H
25 
26 #include "item.hpp"
27 #include <gtkmm/printcontext.h>
28 #include <gtkmm/printoperation.h>
29 
30 typedef Glib::RefPtr<Pango::Layout> layout_refptr;
31 
35 class KitPrintOperation : public Gtk::PrintOperation {
37  Glib::ustring m_page_title;
38 public:
39  static Glib::RefPtr<KitPrintOperation> create();
41  void set_items(ItemContainer* items) {m_items = items;}
42  void set_page_title(const Glib::ustring page_title) {m_page_title = page_title;}
44 protected:
45  layout_refptr new_header(const Glib::RefPtr<Gtk::PrintContext>& context);
46  layout_refptr new_footer(const Glib::RefPtr<Gtk::PrintContext>& context);
47  virtual void on_begin_print(const Glib::RefPtr<Gtk::PrintContext>& context);
48  virtual void on_draw_page(const Glib::RefPtr<Gtk::PrintContext>& context, int page_number);
52  std::vector<int> m_page_breaks;
54  std::vector<layout_refptr> m_ref_headers;
56  std::vector<layout_refptr> m_ref_footers;
57 };
58 
59 #endif //PRINTING_H
Prints the kitlist.
Definition: printing.hpp:35
virtual void on_begin_print(const Glib::RefPtr< Gtk::PrintContext > &context)
Definition: printing.cpp:93
void set_items(ItemContainer *items)
Sets the list of items to be printed.
Definition: printing.hpp:41
layout_refptr new_header(const Glib::RefPtr< Gtk::PrintContext > &context)
Definition: printing.cpp:60
std::vector< int > m_page_breaks
A list of line numbers where a page break is required.
Definition: printing.hpp:52
std::vector< Item * > ItemContainer
Definition: item.hpp:91
std::vector< layout_refptr > m_ref_footers
A list of footers, one for each page.
Definition: printing.hpp:56
layout_refptr new_footer(const Glib::RefPtr< Gtk::PrintContext > &context)
Definition: printing.cpp:76
std::vector< layout_refptr > m_ref_headers
A list of headers, one for each page.
Definition: printing.hpp:54
virtual void on_draw_page(const Glib::RefPtr< Gtk::PrintContext > &context, int page_number)
Definition: printing.cpp:159
void set_page_title(const Glib::ustring page_title)
Definition: printing.hpp:42
static Glib::RefPtr< KitPrintOperation > create()
Factory to create instances.
Definition: printing.cpp:51
Glib::RefPtr< Pango::Layout > layout_refptr
Definition: printing.hpp:30
layout_refptr m_ref_layout
A layout to hold the body of the entire kitlist to be printed.
Definition: printing.hpp:50
Glib::ustring m_page_title
Definition: printing.hpp:37
ItemContainer * m_items
Definition: printing.hpp:36
~KitPrintOperation()
Destructor.
Definition: printing.cpp:44

Copyright 2008-2021 Frank Dean