Commit 111264d7 authored by twanvl's avatar twanvl

Added option to disable spacing between printed cards

parent 59c6ab4c
...@@ -152,6 +152,13 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(StyleSheetSettings) { ...@@ -152,6 +152,13 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(StyleSheetSettings) {
REFLECT(card_spellcheck_enabled); REFLECT(card_spellcheck_enabled);
} }
// ----------------------------------------------------------------------------- : Printing
IMPLEMENT_REFLECTION_ENUM(PageLayoutType) {
VALUE_N("no space", LAYOUT_NO_SPACE);
VALUE_N("equal space", LAYOUT_EQUAL_SPACE);
}
// ----------------------------------------------------------------------------- : Settings // ----------------------------------------------------------------------------- : Settings
Settings settings; Settings settings;
...@@ -166,6 +173,7 @@ Settings::Settings() ...@@ -166,6 +173,7 @@ Settings::Settings()
, symbol_grid_size (30) , symbol_grid_size (30)
, symbol_grid (true) , symbol_grid (true)
, symbol_grid_snap (false) , symbol_grid_snap (false)
, print_layout (LAYOUT_NO_SPACE)
#if USE_OLD_STYLE_UPDATE_CHECKER #if USE_OLD_STYLE_UPDATE_CHECKER
, updates_url (_("http://magicseteditor.sourceforge.net/updates")) , updates_url (_("http://magicseteditor.sourceforge.net/updates"))
#endif #endif
...@@ -253,6 +261,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) { ...@@ -253,6 +261,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
REFLECT(symbol_grid); REFLECT(symbol_grid);
REFLECT(symbol_grid_snap); REFLECT(symbol_grid_snap);
REFLECT(default_game); REFLECT(default_game);
REFLECT(print_layout);
REFLECT(apprentice_location); REFLECT(apprentice_location);
#if USE_OLD_STYLE_UPDATE_CHECKER #if USE_OLD_STYLE_UPDATE_CHECKER
REFLECT(updates_url); REFLECT(updates_url);
......
...@@ -112,6 +112,14 @@ class StyleSheetSettings : public IntrusivePtrBase<StyleSheetSettings> { ...@@ -112,6 +112,14 @@ class StyleSheetSettings : public IntrusivePtrBase<StyleSheetSettings> {
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
// ----------------------------------------------------------------------------- : Printing settings
enum PageLayoutType
{ LAYOUT_NO_SPACE
, LAYOUT_EQUAL_SPACE
//, LAYOUT_CUSTOM
};
// ----------------------------------------------------------------------------- : Settings // ----------------------------------------------------------------------------- : Settings
/// Class that holds MSE settings. /// Class that holds MSE settings.
...@@ -178,6 +186,10 @@ class Settings { ...@@ -178,6 +186,10 @@ class Settings {
/// Get the options for an export template /// Get the options for an export template
IndexMap<FieldP,ValueP>& exportOptionsFor(const ExportTemplate& export_template); IndexMap<FieldP,ValueP>& exportOptionsFor(const ExportTemplate& export_template);
// --------------------------------------------------- : Printing
PageLayoutType print_layout;
// --------------------------------------------------- : Special game stuff // --------------------------------------------------- : Special game stuff
String apprentice_location; String apprentice_location;
......
This diff is collapsed.
...@@ -12,27 +12,19 @@ ...@@ -12,27 +12,19 @@
#include <util/prec.hpp> #include <util/prec.hpp>
#include <util/reflect.hpp> #include <util/reflect.hpp>
#include <util/real_point.hpp> #include <util/real_point.hpp>
#include <data/settings.hpp>
#include <gui/card_select_window.hpp> #include <gui/card_select_window.hpp>
DECLARE_POINTER_TYPE(Set); DECLARE_POINTER_TYPE(Set);
DECLARE_POINTER_TYPE(PrintJob);
class StyleSheet; class StyleSheet;
// ----------------------------------------------------------------------------- : Printing
/// Show a print preview for the given set
void print_preview(Window* parent, const SetP& set, const ExportCardSelectionChoices& choices);
/// Print the given set
void print_set(Window* parent, const SetP& set, const ExportCardSelectionChoices& choices);
// ----------------------------------------------------------------------------- : Layout // ----------------------------------------------------------------------------- : Layout
/// Layout of a page of cards /// Layout of a page of cards
class PageLayout : public IntrusivePtrBase<PageLayout> { class PageLayout {
public: public:
PageLayout(); // layout
PageLayout(const StyleSheet& stylesheet, const RealSize& page_size);
RealSize page_size; ///< Size of a page (in millimetres) RealSize page_size; ///< Size of a page (in millimetres)
RealSize card_size; ///< Size of a card (in millimetres) RealSize card_size; ///< Size of a card (in millimetres)
RealSize card_spacing; ///< Spacing between cards (in millimetres) RealSize card_spacing; ///< Spacing between cards (in millimetres)
...@@ -40,12 +32,45 @@ class PageLayout : public IntrusivePtrBase<PageLayout> { ...@@ -40,12 +32,45 @@ class PageLayout : public IntrusivePtrBase<PageLayout> {
int rows, cols; ///< Number of rows/columns of cards int rows, cols; ///< Number of rows/columns of cards
bool card_landscape; ///< Are cards rotated to landscape orientation? bool card_landscape; ///< Are cards rotated to landscape orientation?
PageLayout();
void init(const StyleSheet& stylesheet, PageLayoutType layout_type, const RealSize& page_size);
/// Is this layout uninitialized?
inline bool empty() const { return cards_per_page() == 0; }
/// The number of cards per page /// The number of cards per page
inline int cardsPerPage() const { return rows * cols; } inline int cards_per_page() const { return rows * cols; }
};
class PrintJob : public IntrusivePtrBase<PrintJob> {
public:
PrintJob(SetP const& set) : set(set) {}
// set and cards to print
SetP set;
vector<CardP> cards;
// printing options
PageLayoutType layout_type;
PageLayout layout;
private: inline int num_pages() const {
DECLARE_REFLECTION(); int cards_per_page = max(1,layout.cards_per_page());
return (cards.size() + cards_per_page - 1) / cards_per_page;
}
}; };
// ----------------------------------------------------------------------------- : Printing
/// Make a print job, by asking the user for options, and card selection
PrintJobP make_print_job(Window* parent, const SetP& set, const ExportCardSelectionChoices& choices);
/// Show a print preview for the given set
void print_preview(Window* parent, const PrintJobP& job);
void print_preview(Window* parent, const SetP& set, const ExportCardSelectionChoices& choices);
/// Print the given set
void print_set(Window* parent, const PrintJobP& job);
void print_set(Window* parent, const SetP& set, const ExportCardSelectionChoices& choices);
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment