• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kviewshell

simplePageSize.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // simplePageSize.h
00004 //
00005 // Part of KVIEWSHELL - A framework for multipage text/gfx viewers
00006 //
00007 // (C) 2002-2004 Stefan Kebekus
00008 // Distributed under the GPL
00009 
00010 
00011 #ifndef SIMPLEPAGESIZE_H
00012 #define SIMPLEPAGESIZE_H
00013 
00014 #include "length.h"
00015 
00016 #include <qsize.h>
00017 
00018 class QString;
00019 class QStringList;
00020 
00021 
00035 class SimplePageSize
00036 {
00037  public:
00039   SimplePageSize() { pageWidth.setLength_in_mm(0.0); pageHeight.setLength_in_mm(0.0); }
00040 
00049   SimplePageSize(const Length& width, const Length& height) { pageWidth = width; pageHeight = height; }
00050 
00059   virtual void setPageSize(const Length& width, const Length& height) { pageWidth = width; pageHeight = height; }
00060 
00062   Length width() const { return pageWidth; }
00063 
00065   Length height() const { return pageHeight; }
00066 
00071   double      aspectRatio() const { return isValid() ? (pageWidth/pageHeight) : 1.0; }
00072 
00079   QSize       sizeInPixel(double resolution) const {return QSize( (int)(resolution*pageWidth.getLength_in_inch() + 0.5), 
00080                                   (int)(resolution*pageHeight.getLength_in_inch() + 0.5)); }
00081 
00096   double      zoomForHeight(Q_UINT32 height) const;
00097   
00112   double      zoomForWidth(Q_UINT32 width) const;
00113 
00122   double      zoomToFitInto(const SimplePageSize &target) const;
00123   
00128   bool isValid() const { return ( (pageWidth.getLength_in_mm() > 1.0) && (pageHeight.getLength_in_mm() > 1.0) ); }
00129 
00134   bool isSmall() const { return (pageWidth.getLength_in_mm()*pageHeight.getLength_in_mm() < 1.0); }
00135   
00143   bool isNearlyEqual(const SimplePageSize &size) const {return (pageWidth.isNearlyEqual(size.pageWidth) && pageHeight.isNearlyEqual(size.pageHeight)); }
00144 
00149   bool isPortrait() const { return (pageHeight >= pageWidth);}
00150 
00156   SimplePageSize rotate90() const { return  SimplePageSize(pageHeight, pageWidth);}
00157   
00158  protected:
00159   Length pageWidth;
00160   Length pageHeight;
00161 };
00162 
00163 
00164 #endif

kviewshell

Skip menu "kviewshell"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kviewshell
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal