1 /************************************************************************* 2 ** PageSize.h ** 3 ** ** 4 ** This file is part of dvisvgm -- the DVI to SVG converter ** 5 ** Copyright (C) 2005-2015 Martin Gieseking <martin.gieseking@uos.de> ** 6 ** ** 7 ** This program is free software; you can redistribute it and/or ** 8 ** modify it under the terms of the GNU General Public License as ** 9 ** published by the Free Software Foundation; either version 3 of ** 10 ** the License, or (at your option) any later version. ** 11 ** ** 12 ** This program is distributed in the hope that it will be useful, but ** 13 ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 ** GNU General Public License for more details. ** 16 ** ** 17 ** You should have received a copy of the GNU General Public License ** 18 ** along with this program; if not, see <http://www.gnu.org/licenses/>. ** 19 *************************************************************************/ 20 21 #ifndef DVISVGM_PAGESIZE_H 22 #define DVISVGM_PAGESIZE_H 23 24 #include "MessageException.h" 25 26 struct PageSizeException : public MessageException 27 { PageSizeExceptionPageSizeException28 PageSizeException (const std::string &msg) : MessageException(msg) {} 29 }; 30 31 class PageSize 32 { 33 public: _width(w)34 PageSize (double w=0, double h=0) : _width(w), _height(h) {} 35 PageSize (std::string name); 36 void resize (std:: string name); 37 void resize (double w, double h); widthInBP()38 double widthInBP () const {return _width;} heightInBP()39 double heightInBP () const {return _height;} widthInMM()40 double widthInMM () const {return _width*25.4/72;} heightInMM()41 double heightInMM () const {return _height*25.4/72;} valid()42 bool valid () const {return _width > 0 && _height > 0;} 43 44 private: 45 double _width, _height; // in PS points 46 }; 47 48 #endif 49