File indexing completed on 2025-04-27 03:51:01
0001 /*************************************************************************** 0002 * Copyright 2005-2007 Francesco Rossi <redsh@email.it> * 0003 * Copyright 2006-2007 Mick Kappenburg <ksudoku@kappendburg.net> * 0004 * Copyright 2006-2007 Johannes Bergmeier <johannes.bergmeier@gmx.net> * 0005 * Copyright 2012 Ian Wadham <iandw.au@gmail.com> * 0006 * Copyright 2015 Ian Wadham <iandw.au@gmail.com> * 0007 * * 0008 * This program is free software; you can redistribute it and/or modify * 0009 * it under the terms of the GNU General Public License as published by * 0010 * the Free Software Foundation; either version 2 of the License, or * 0011 * (at your option) any later version. * 0012 * * 0013 * This program is distributed in the hope that it will be useful, * 0014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0016 * GNU General Public License for more details. * 0017 * * 0018 * You should have received a copy of the GNU General Public License * 0019 * along with this program; if not, write to the * 0020 * Free Software Foundation, Inc., * 0021 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0022 ***************************************************************************/ 0023 0024 #ifndef _PUZZLEPRINTER_H_ 0025 #define _PUZZLEPRINTER_H_ 0026 0027 #include <QPen> 0028 #include <QPrinter> 0029 #include <QObject> 0030 0031 namespace ksudoku { 0032 class Game; 0033 class Puzzle; 0034 } 0035 0036 class SKGraph; 0037 class QWidget; 0038 0039 class PuzzlePrinter : public QObject 0040 { 0041 Q_OBJECT 0042 0043 public: 0044 /** 0045 * Default Constructor 0046 */ 0047 explicit PuzzlePrinter (QWidget * parent); 0048 0049 /** 0050 * Default Destructor 0051 */ 0052 ~PuzzlePrinter() override; 0053 0054 void print (const ksudoku::Game & game); 0055 void endPrint(); 0056 0057 private: 0058 enum Edge {Left = 0, Right, Above, Below, Detached}; 0059 0060 bool setupOutputDevices (int leastCellsToFit, int puzzleWidth); 0061 0062 void drawBlocks (const ksudoku::Puzzle * puzzle, 0063 const SKGraph * graph); 0064 void drawCages (const ksudoku::Puzzle * puzzle, 0065 const SKGraph * graph, bool killerStyle); 0066 void drawKillerSudokuCages (const SKGraph* graph, 0067 const QList<int> & edges); 0068 void markEdges (const QList<int> & cells, 0069 const ksudoku::Puzzle * puzzle, const SKGraph * graph, 0070 QList<int> & edges); 0071 void drawCell (int posX, int posY, int edge); 0072 void drawValues (const ksudoku::Game & game, const SKGraph * graph); 0073 void drawCageLabel (const SKGraph* graph, int n, bool killerStyle); 0074 0075 QWidget * m_parent; 0076 QPrinter * m_printer; 0077 QPainter * m_p; 0078 int m_quadrant; 0079 int m_across; 0080 int m_down; 0081 bool m_printMulti; 0082 int m_sCell; 0083 int m_topX; 0084 int m_topY; 0085 QPen m_heavy; 0086 QPen m_light; 0087 QPen m_dashes; 0088 }; 0089 0090 #endif // _PUZZLEPRINTER_H_