kviewshell
pageSize Class Reference
#include <pageSize.h>
Public Slots | |
void | setOrientation (int orient) |
Signals | |
void | sizeChanged (const SimplePageSize &t) |
Public Member Functions | |
QString | formatName () const |
int | formatNumber () const |
int | getOrientation () const |
QString | heightString (const QString &unit) const |
pageSize & | operator= (const pageSize &src) |
pageSize (const SimplePageSize &) | |
pageSize () | |
QStringList | pageSizeNames () |
QString | preferredUnit () const |
QString | serialize () const |
virtual void | setPageSize (double width_in_mm, double height_in_mm) |
void | setPageSize (const QString &width, const QString &widthUnits, const QString &height, const QString &heightUnits) |
bool | setPageSize (const QString &name) |
QString | widthString (const QString &unit) const |
Detailed Description
Definition at line 41 of file pageSize.h.
Constructor & Destructor Documentation
pageSize::pageSize | ( | ) |
Default constructor, initializes the pageSize with a reasonable default.
The default chosen depends on the locale. At the moment, A4 size is chosen for countries with metric measurement system, and US letter otherwise.
Definition at line 46 of file pageSize.cpp.
pageSize::pageSize | ( | const SimplePageSize & | s | ) |
Member Function Documentation
QString pageSize::formatName | ( | ) | const |
Returns a name for the page size, if this is a standard size.
- Warning:
- This method does not take care of orientation, e.g. it will return "DIN A4" if the page size is either 210x297 or 297x210.
- Returns:
- A name for the current page size, if the format has a name, or QString::null otherwise. If the result is not QString::null, it is guaranteed to be one of the strings returned by the pageSizeNames() method.
Definition at line 261 of file pageSize.cpp.
int pageSize::formatNumber | ( | ) | const [inline] |
Returns an number for the page size, if this is a standard size.
- Warning:
- This method does not take care of orientation, e.g. it will return the same value if the page size is either 210x297 or 297x210.
- Returns:
- If the current format is one of the standard sizes, a non-negative integer is returned, which is an index to the QStringList returned by the pageSizeNames() method. If the current format is none of the standard sizes, -1 is returned.
Definition at line 209 of file pageSize.h.
int pageSize::getOrientation | ( | ) | const |
Gets orientation for standard sizes.
If the pageSize is one of the standard sizes, i.e. formatNumber() != -1, this method can be used to get the orientation. If the pageSize is not a standard size, this method prints an error message stderr using kdError().
- Returns:
- 0 for 'portrait', or 1 for 'landscape'. If the size is none of the standard sizes, an undefined value is returned.
Definition at line 270 of file pageSize.cpp.
Returns the page height as a string.
- Parameters:
-
unit The unit in height the page width shall be returned. This must be one of "cm", "mm" or "in".
- Returns:
- a string containing a number which gives the page height in the given unit. If the unit is not recognized, the string "--" is returned.
Definition at line 235 of file pageSize.cpp.
Copy operator.
This operator will emit the signal sizeChanged() if one of the dimensions of *this and src differ by more than two millimeters.
Definition at line 177 of file pageSize.cpp.
QStringList pageSize::pageSizeNames | ( | ) |
List of standard pageSizes.
This method returns the names of standard pageSizes, e.g. "A4". These can be used, e.g., by a QComboBox to let the user choose known sizes. The returned list is also a list of all possible return values of the formatName() method explained below. If you call pageSizeNames() more than once, it is guaranteed that the same list of strings will be returned.
- Returns:
- QStringList that contains
Definition at line 250 of file pageSize.cpp.
QString pageSize::preferredUnit | ( | ) | const |
Preferred unit for the current page size.
- Returns:
- The name of the unit, one of "cm", "mm" or "in", which is most commonly used with the current page format. For instance, US Letter and US Legal are best given in inches, to avoid very odd numbers. If the page format is unknown, returns a guess based on the current locale.
Definition at line 207 of file pageSize.cpp.
QString pageSize::serialize | ( | ) | const |
Returns a string that can be read by setPageSize(QString).
- Returns:
- This method returns a string like "210x297". The numbers are page width and height in millimeters. The setPageSize(QString) method will understand this output.
Definition at line 302 of file pageSize.cpp.
void pageSize::setOrientation | ( | int | orient | ) | [slot] |
Sets orientation.
If the pageSize is one of the standard sizes, i.e. formatNumber() != -1, this method can be used to set the orientation. If the pageSize is not a standard size, this method prints an error message stderr using kdError() and does nothing.
- Parameters:
-
orient 0 sets 'portrait orientation', 1 sets 'landscape'
Definition at line 284 of file pageSize.cpp.
void pageSize::setPageSize | ( | double | width_in_mm, | |
double | height_in_mm | |||
) | [virtual] |
Set page size.
Sets the page size to "width" and "height", given in millimeter. If the page size set matches one of the standard sizes by an error of no more than 2mm, the standard page size will be set. Values are trimmed so that both width and height are between the minimal and maximal possible values, i.e. in the range 5..50 cm. If the newly set value differs from the old value by more that 2mm for width or height, the signal sizeChanged() will be emitted
- Parameters:
-
width_in_mm page width in mm height_in_mm page height in mm
Definition at line 127 of file pageSize.cpp.
void pageSize::setPageSize | ( | const QString & | width, | |
const QString & | widthUnits, | |||
const QString & | height, | |||
const QString & | heightUnits | |||
) |
Set page size from width and height strings.
Sets the page size to "width" and "height", given in the associated units. Currently, "mm", "cm" and "in" are supported. If a unit is not recognized, "mm" is siliently assumed, and error message is printed to stderr using kdError(). If the page size set matches one of the standard sizes by an error of no more than 2mm, the standard page size will be set. If width or height does not contain a number, the result is an undefined value. However, it is guaranteed in any case that both width and height are between the minimal and maximal possible values, i.e. in the range 5..50 cm. If the newly set value differs from the old value by more that 2mm for width or height, the signal sizeChanged() will be emitted
- Parameters:
-
width string that represents the page width as a number, e.g., " 300 " widthUnits units for the width string. Currently "mm", "cm" and "in" are allowed. height string that represents the page height as a number, e.g., " 300 " heightUnits units for the height string. Currently "mm", "cm" and "in" are allowed.
Definition at line 141 of file pageSize.cpp.
bool pageSize::setPageSize | ( | const QString & | name | ) |
Set page size by name.
Acceptable strings are
(1) a name from the list retured by pageSizeNames(), such as "DIN A4"
(2) a string like "500x300", which describes a page of width 500mm and height 300mm.
(3) a string like "3in, 4 cm". A number of different units, including "in", "mm" and "cm", and a few typographical units are recognized
If the name is not of these types, and error message is printed to stderr using kdError() and a default value, which depends on the locale, is set.
In any case, the values will be trimmed so as not to exceed the minima/maxima of 5cm and 50cm, respectively. If the page size found matches one of the standard sizes by an error of no more than 2mm, the standard page size will be set. The signal sizeChanged() will always be emitted.
- Parameters:
-
name string that represents the page size
- Returns:
- 'True', if the parameter could be parsed, and 'false' otherwise.
Definition at line 64 of file pageSize.cpp.
void pageSize::sizeChanged | ( | const SimplePageSize & | t | ) | [signal] |
Signal emitted when the page sizes changes.
emitted to indicate that the size changed. Not emitted immediately after construction, when the constructor sets the default size.
- Parameters:
-
t a pointer to this
Returns the page width as a string.
- Parameters:
-
unit The unit in which the page width shall be returned. This must be one of "cm", "mm" or "in".
- Returns:
- a string containing a number, e.g. "3.1415", which gives the page width in the given unit. If the unit is not recognized, the string "--" is returned.
Definition at line 220 of file pageSize.cpp.
The documentation for this class was generated from the following files: