kviewshell
SimplePageSize Class Reference
This class represents phyiscal page sizes. More...
#include <simplePageSize.h>
Public Member Functions | |
double | aspectRatio () const |
Length | height () const |
bool | isNearlyEqual (const SimplePageSize &size) const |
bool | isPortrait () const |
bool | isSmall () const |
bool | isValid () const |
SimplePageSize | rotate90 () const |
virtual void | setPageSize (const Length &width, const Length &height) |
SimplePageSize (const Length &width, const Length &height) | |
SimplePageSize () | |
QSize | sizeInPixel (double resolution) const |
Length | width () const |
double | zoomForHeight (Q_UINT32 height) const |
double | zoomForWidth (Q_UINT32 width) const |
double | zoomToFitInto (const SimplePageSize &target) const |
Protected Attributes | |
Length | pageHeight |
Length | pageWidth |
Detailed Description
This class represents phyiscal page sizes.This class represents page sizes. It contains nothing but two numbers, the page width, and page height, and a few utility functions that convert page sizes to pixel sizes and to compute the aspect ratio. A page with width<=1mm or height<=1mm is considered invalid. pageSize is a more elaborate class that is derived from SimplePageSize and knows about standard paper sizes.
- Version:
- 1.0 0
Definition at line 35 of file simplePageSize.h.
Constructor & Destructor Documentation
SimplePageSize::SimplePageSize | ( | ) | [inline] |
Constructs an invalid SimplePageSize, with size 0x0mm.
Definition at line 39 of file simplePageSize.h.
Constructs a SimplePagesize with given page width and height in mm.
Recall that if width or height is less or equal than 1mm, the page size is considered 'invalid' by the isValid() method.
- Parameters:
-
width height
Definition at line 49 of file simplePageSize.h.
Member Function Documentation
double SimplePageSize::aspectRatio | ( | ) | const [inline] |
Aspect ratio.
- Returns:
- if the paper size is valid, this method returns the ratio width/height. Returns 1.0 otherwise.
Definition at line 71 of file simplePageSize.h.
Length SimplePageSize::height | ( | ) | const [inline] |
bool SimplePageSize::isNearlyEqual | ( | const SimplePageSize & | size | ) | const [inline] |
Approximate equality.
- Parameters:
-
size pageSize object to compare this object with
- Returns:
- 'True' if height and width of the two obejcts differ by at most 2mm, 'false' otherwise
Definition at line 143 of file simplePageSize.h.
bool SimplePageSize::isPortrait | ( | ) | const [inline] |
Test if paper size is higher than wide.
- Returns:
- 'True' if the paper size is higher than wide
Definition at line 149 of file simplePageSize.h.
bool SimplePageSize::isSmall | ( | ) | const [inline] |
Validity check:.
- Returns:
- 'True' if the page ares is less than 1.0 square mm
Definition at line 134 of file simplePageSize.h.
bool SimplePageSize::isValid | ( | ) | const [inline] |
Validity check.
- Returns:
- 'True' if the page width and height are both larger than 1mm
Definition at line 128 of file simplePageSize.h.
SimplePageSize SimplePageSize::rotate90 | ( | ) | const [inline] |
Rotates by 90 degrees.
- Returns:
- a SimplePageSize with height and width swapped. The original instance is unchanged.
Definition at line 156 of file simplePageSize.h.
virtual void SimplePageSize::setPageSize | ( | const Length & | width, | |
const Length & | height | |||
) | [inline, virtual] |
Sets the page width and height.
If width or height is less or equal than 1mm, the page size is considered 'invalid' by the isValid() method.
- Parameters:
-
width height
Definition at line 59 of file simplePageSize.h.
QSize SimplePageSize::sizeInPixel | ( | double | resolution | ) | const [inline] |
Converts the physical page size to a pixel size.
- Parameters:
-
resolution in dots per inch
- Returns:
- the pixel size, represented by a QSize. If the page size is invalid, the result is undefined.
Definition at line 79 of file simplePageSize.h.
Length SimplePageSize::width | ( | ) | const [inline] |
double SimplePageSize::zoomForHeight | ( | Q_UINT32 | height | ) | const |
Zoom value required to scale to a certain height.
If the pageSize is valid, this method returns the zoom value required to scale the page size down to 'height' pixels on the currently used display. The method uses QPaintDevice::x11AppDpiY() to find the resolution of the display. If the pageSize is invalid, an error message is printed, and an undefined value is returned.
- Parameters:
-
height target height in pixels
- Returns:
- the zoom value required to scale the page size down to 'height' pixels. If the pageSize is invalid, an undefined value is returned.
Definition at line 18 of file simplePageSize.cpp.
double SimplePageSize::zoomForWidth | ( | Q_UINT32 | width | ) | const |
Zoom value required to scale to a certain height.
If the pageSize is valid, this method returns the zoom value required to scale the page size down to 'width' pixels on the currently used display. The method uses QPaintDevice::x11AppDpiX() to find the resolution of the display. If the pageSize is invalid, an error message is printed, and an undefined value is returned.
- Parameters:
-
width target width in pixels
- Returns:
- the zoom value required to scale the page size down to 'width' pixels. If the pageSize is invalid, an undefined value is returned.
Definition at line 28 of file simplePageSize.cpp.
double SimplePageSize::zoomToFitInto | ( | const SimplePageSize & | target | ) | const |
Returns a zoom to fit into a certain page size.
This method computes the larget zoom value such that *this, zoomed by the computed values fits into the page size 'target'. If *this or if target are invalid, or is this->isSmall() is true, an undefined value is returned. If height or width of this is nearly 0.0, a floating point exception may occur.
Definition at line 38 of file simplePageSize.cpp.
Member Data Documentation
Length SimplePageSize::pageHeight [protected] |
Definition at line 160 of file simplePageSize.h.
Length SimplePageSize::pageWidth [protected] |
Definition at line 159 of file simplePageSize.h.
The documentation for this class was generated from the following files: