Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

units.h File Reference

#include "scribusapi.h"
#include <QString>
#include <QStringList>

Include dependency graph for units.h:

Go to the source code of this file.

Defines

#define UNITMIN   0
#define UNITMAX   7

Enumerations

enum  scUnit {
  SC_POINTS = 0, SC_PT = 0, SC_MILLIMETERS = 1, SC_MM = 1,
  SC_INCHES = 2, SC_IN = 2, SC_PICAS = 3, SC_P = 3,
  SC_CENTIMETERS = 4, SC_CM = 4, SC_CICERO = 5, SC_C = 5,
  SC_DEGREES = 6, SC_DEG = 6, SC_PERCENT = 7, SC_PCT = 7
}

Functions

double SCRIBUS_API unitGetRatioFromIndex (const int index)
 Returns the ratio to points for the selected unit of measure. Ratios are for: PT, MM, IN, P, CM, C. DEG and PCT return 1.0 as they will never convert.
int SCRIBUS_API unitGetBaseFromIndex (const int index)
const QString SCRIBUS_API unitGetStrFromIndex (const int index)
 Returns a general suffix for each of the units.
const QString SCRIBUS_API unitGetUntranslatedStrFromIndex (const int index)
 Returns a general untranslated suffix for each of the units.
const QString SCRIBUS_API unitGetSuffixFromIndex (const int index)
 Returns the suffix used in GUI widgets.
int SCRIBUS_API unitGetDecimalsFromIndex (const int index)
 Returns the decimals for the units.
int SCRIBUS_API unitGetPrecisionFromIndex (const int index)
 Returns the precision for the units.
double SCRIBUS_API unitValueFromString (const QString &value)
 Strip the text from a value and return the double value for the unit.
scUnit SCRIBUS_API unitIndexFromString (const QString &value)
 Strip the text from a value and return the Unit index for the value.
const QStringList SCRIBUS_API unitGetTextUnitList ()
 Returns a QStringList of the units for use in QComboBoxes etc.
int SCRIBUS_API unitGetMaxIndex ()
 Returns the maximum index of the units we have now.
double SCRIBUS_API mm2pts (double mm)
 Returns the pts value from the mm value supplied.
double SCRIBUS_API in2pts (double in)
 Returns the pts value from the in value supplied.
double SCRIBUS_API p2pts (double p)
 Returns the pts value from the pica value supplied.
double SCRIBUS_API cm2pts (double cm)
 Returns the pts value from the cm value supplied.
double SCRIBUS_API c2pts (double c)
 Returns the pts value from the cm value supplied.
double SCRIBUS_API pts2mm (double pts)
 Returns the mm value from the pt value supplied.
double SCRIBUS_API pts2in (double pts)
 Returns the in value from the pt value supplied.
double SCRIBUS_API pts2p (double pts)
 Returns the pica value from the pt value supplied.
double SCRIBUS_API pts2cm (double pts)
 Returns the cm value from the pt value supplied.
double SCRIBUS_API pts2c (double pts)
 Returns the c value from the pt value supplied.
double SCRIBUS_API pts2value (double Val, int unit)
 Returns the value from the pt value supplied based on unit index.
double SCRIBUS_API value2pts (double unitValue, int unit)
 Returns the pt value from the value supplied based on unit index.
double SCRIBUS_API value2value (double unitValue, int primaryUnit, int secondaryUnit)
 Returns the secondary unit value from the value supplied based on primary unit.
double SCRIBUS_API unitRulerGetIter1FromIndex (const int index)
 Sets up iteration value 1 for vruler, hruler and tabruler.
double SCRIBUS_API unitRulerGetIter2FromIndex (const int index)
 Sets up iteration value 2 for vruler, hruler and tabruler.
bool SCRIBUS_API unitValidForDocUnit (const int index)


Define Documentation

#define UNITMAX   7

#define UNITMIN   0

Definition at line 29 of file units.h.


Enumeration Type Documentation

enum scUnit

Enumerator:
SC_POINTS 
SC_PT 
SC_MILLIMETERS 
SC_MM 
SC_INCHES 
SC_IN 
SC_PICAS 
SC_P 
SC_CENTIMETERS 
SC_CM 
SC_CICERO 
SC_C 
SC_DEGREES 
SC_DEG 
SC_PERCENT 
SC_PCT 

Definition at line 32 of file units.h.


Function Documentation

double SCRIBUS_API c2pts ( double  c  ) 

Returns the pts value from the cm value supplied.

Definition at line 262 of file units.cpp.

References SC_C, and unitGetRatioFromIndex().

double SCRIBUS_API cm2pts ( double  cm  ) 

Returns the pts value from the cm value supplied.

Definition at line 254 of file units.cpp.

References SC_CM, and unitGetRatioFromIndex().

Referenced by StencilReader::parseUnit().

double SCRIBUS_API in2pts ( double  in  ) 

Returns the pts value from the in value supplied.

Definition at line 238 of file units.cpp.

References SC_IN, and unitGetRatioFromIndex().

Referenced by PageSize::generateSizeList(), and StencilReader::parseUnit().

double SCRIBUS_API mm2pts ( double  mm  ) 

Returns the pts value from the mm value supplied.

Definition at line 230 of file units.cpp.

References SC_MM, and unitGetRatioFromIndex().

Referenced by PageSize::generateSizeList(), and StencilReader::parseUnit().

double SCRIBUS_API p2pts ( double  p  ) 

Returns the pts value from the pica value supplied.

Definition at line 246 of file units.cpp.

References SC_P, and unitGetRatioFromIndex().

double SCRIBUS_API pts2c ( double  pts  ) 

Returns the c value from the pt value supplied.

Definition at line 302 of file units.cpp.

References SC_C, and unitGetRatioFromIndex().

double SCRIBUS_API pts2cm ( double  pts  ) 

Returns the cm value from the pt value supplied.

Definition at line 294 of file units.cpp.

References SC_CM, and unitGetRatioFromIndex().

double SCRIBUS_API pts2in ( double  pts  ) 

Returns the in value from the pt value supplied.

Definition at line 278 of file units.cpp.

References SC_IN, and unitGetRatioFromIndex().

double SCRIBUS_API pts2mm ( double  pts  ) 

Returns the mm value from the pt value supplied.

Definition at line 270 of file units.cpp.

References SC_MM, and unitGetRatioFromIndex().

double SCRIBUS_API pts2p ( double  pts  ) 

Returns the pica value from the pt value supplied.

Definition at line 286 of file units.cpp.

References SC_P, and unitGetRatioFromIndex().

double SCRIBUS_API pts2value ( double  Val,
int  unit 
)

Returns the value from the pt value supplied based on unit index.

Definition at line 310 of file units.cpp.

References unitGetRatioFromIndex().

Referenced by GuidesModel::data(), PointToValue(), and GuideManager::setupGui().

int SCRIBUS_API unitGetBaseFromIndex ( const int  index  ) 

Definition at line 42 of file units.cpp.

References SC_P.

Referenced by ScrSpinBox::valueFromText().

int SCRIBUS_API unitGetDecimalsFromIndex ( const int  index  ) 

Returns the decimals for the units.

Definition at line 180 of file units.cpp.

References UNITMAX.

Referenced by ReformDoc::ReformDoc(), MSpinBox::setNewUnit(), ScribusMainWindow::setStatusBarMousePosition(), and Measurements::setValues().

int SCRIBUS_API unitGetMaxIndex (  ) 

Returns the maximum index of the units we have now.

Definition at line 222 of file units.cpp.

References UNITMAX.

Referenced by initscribus(), ScribusView::ScribusView(), ScrSpinBox::setParameters(), and MSpinBox::setParameters().

int SCRIBUS_API unitGetPrecisionFromIndex ( const int  index  ) 

double SCRIBUS_API unitGetRatioFromIndex ( const int  index  ) 

Returns the ratio to points for the selected unit of measure. Ratios are for: PT, MM, IN, P, CM, C. DEG and PCT return 1.0 as they will never convert.

Definition at line 29 of file units.cpp.

References UNITMAX.

Referenced by CreateMode::activate(), c2pts(), cm2pts(), NodePalette::doEnlarge(), NodePalette::doReduce(), AlignDistributePalette::enableGuideButtons(), ScrSpinBox::getValue(), Imposition::Imposition(), in2pts(), gtMeasure::init(), initscribus(), ScribusMainWindow::keyPressEvent(), MarginWidget::MarginWidget(), mm2pts(), LegacyMode::mouseReleaseEvent(), FreehandMode::mouseReleaseEvent(), CreateMode::mouseReleaseEvent(), NewDoc::NewDoc(), OneClick::OneClick(), PageSize::originalHeight(), PageSize::originalWidth(), p2pts(), StencilReader::parseUnit(), Preferences::Preferences(), PrintDialog::PrintDialog(), PageSize::printSizeList(), pts2c(), pts2cm(), pts2in(), pts2mm(), pts2p(), pts2value(), TabTools::restoreDefaults(), TabPrinter::restoreDefaults(), TabGuides::restoreDefaults(), TabDocument::restoreDefaults(), TabDisplay::restoreDefaults(), MarginWidget::setMarginsToPrinterMargins(), ScrSpinBox::setNewUnit(), MarginWidget::setNewUnit(), Tabruler::setTabs(), NewDoc::setUnit(), ScribusDoc::setUnitIndex(), Measurements::setValues(), SMPStyleWidget::show(), SMPStyleWidget::showDropCap(), SMPStyleWidget::showTabs(), TabDocument::TabDocument(), TabGuides::TabGuides(), TabManager::TabManager(), Tabruler::Tabruler(), TabDocument::unitChange(), ReformDoc::unitChange(), Preferences::unitChange(), AlignDistributePalette::unitChange(), Preferences::updatePreferences(), value2pts(), and value2value().

const QString SCRIBUS_API unitGetStrFromIndex ( const int  index  ) 

const QString SCRIBUS_API unitGetSuffixFromIndex ( const int  index  ) 

const QStringList SCRIBUS_API unitGetTextUnitList (  ) 

Returns a QStringList of the units for use in QComboBoxes etc.

Definition at line 204 of file units.cpp.

References tr().

Referenced by NewDoc::createNewDocPage(), TabDisplay::restoreDefaults(), and TabDocument::TabDocument().

const QString SCRIBUS_API unitGetUntranslatedStrFromIndex ( const int  index  ) 

Returns a general untranslated suffix for each of the units.

Definition at line 170 of file units.cpp.

References UNITMAX.

Referenced by MSpinBox::mapTextToValue(), StencilReader::parseUnit(), and ScrSpinBox::valueFromText().

scUnit SCRIBUS_API unitIndexFromString ( const QString &  value  ) 

Strip the text from a value and return the Unit index for the value.

Definition at line 94 of file units.cpp.

References SC_C, SC_CM, SC_DEGREES, SC_IN, SC_MM, SC_P, SC_PERCENT, and SC_PT.

Referenced by initscribus(), MSpinBox::mapTextToValue(), gtMeasure::parse(), and ScrSpinBox::valueFromText().

double SCRIBUS_API unitRulerGetIter1FromIndex ( const int  index  ) 

Sets up iteration value 1 for vruler, hruler and tabruler.

Definition at line 367 of file units.cpp.

References unitValidForDocUnit().

Referenced by TabDisplay::drawRuler(), RulerT::RulerT(), RulerT::setTabs(), Vruler::unitChange(), and Hruler::unitChange().

double SCRIBUS_API unitRulerGetIter2FromIndex ( const int  index  ) 

Sets up iteration value 2 for vruler, hruler and tabruler.

Definition at line 379 of file units.cpp.

References unitValidForDocUnit().

Referenced by TabDisplay::drawRuler(), RulerT::RulerT(), RulerT::setTabs(), Vruler::unitChange(), and Hruler::unitChange().

bool SCRIBUS_API unitValidForDocUnit ( const int  index  ) 

Definition at line 388 of file units.cpp.

References UNITMAX.

Referenced by unitRulerGetIter1FromIndex(), and unitRulerGetIter2FromIndex().

double SCRIBUS_API unitValueFromString ( const QString &  value  ) 

Strip the text from a value and return the double value for the unit.

Definition at line 52 of file units.cpp.

Referenced by gtMeasure::parse().

double SCRIBUS_API value2pts ( double  unitValue,
int  unit 
)

double SCRIBUS_API value2value ( double  unitValue,
int  primaryUnit,
int  secondaryUnit 
)

Returns the secondary unit value from the value supplied based on primary unit.

Definition at line 352 of file units.cpp.

References unitGetRatioFromIndex().

Referenced by MSpinBox::mapTextToValue(), and ScrSpinBox::valueFromText().

Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.