From e2bcbdfbc798cccc134c192a4a0185035cd9303c Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Tue, 21 Dec 2004 16:25:59 +0000 Subject: [PATCH] Metric conversion constants not doubled in each port code. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31101 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/include/wx/svg/dcsvg.h | 11 ----------- include/wx/dcsvg.h | 11 ----------- include/wx/math.h | 30 ++++++++++++++++++++++++++++++ include/wx/msw/private.h | 13 ------------- include/wx/os2/private.h | 13 ------------- src/gtk/dc.cpp | 13 +------------ src/gtk1/dc.cpp | 13 +------------ src/mac/carbon/dc.cpp | 7 ------- src/mac/classic/dc.cpp | 7 ------- src/mgl/dc.cpp | 6 ------ src/motif/dc.cpp | 11 ----------- src/msw/textctrl.cpp | 1 + src/x11/dc.cpp | 11 ----------- 13 files changed, 33 insertions(+), 114 deletions(-) diff --git a/contrib/include/wx/svg/dcsvg.h b/contrib/include/wx/svg/dcsvg.h index e6e19364da..ce5b4a2218 100644 --- a/contrib/include/wx/svg/dcsvg.h +++ b/contrib/include/wx/svg/dcsvg.h @@ -17,17 +17,6 @@ #pragma warn -ccc #endif -//----------------------------------------------------------------------------- -// constants -//----------------------------------------------------------------------------- - -#define mm2inches 0.0393700787402 -#define inches2mm 25.4 -#define mm2twips 56.6929133859 -#define twips2mm 0.0176388888889 -#define mm2pt 2.83464566929 -#define pt2mm 0.352777777778 - class WXDLLIMPEXP_SVG wxSVGFileDC : public wxDC { diff --git a/include/wx/dcsvg.h b/include/wx/dcsvg.h index e6e19364da..ce5b4a2218 100644 --- a/include/wx/dcsvg.h +++ b/include/wx/dcsvg.h @@ -17,17 +17,6 @@ #pragma warn -ccc #endif -//----------------------------------------------------------------------------- -// constants -//----------------------------------------------------------------------------- - -#define mm2inches 0.0393700787402 -#define inches2mm 25.4 -#define mm2twips 56.6929133859 -#define twips2mm 0.0176388888889 -#define mm2pt 2.83464566929 -#define pt2mm 0.352777777778 - class WXDLLIMPEXP_SVG wxSVGFileDC : public wxDC { diff --git a/include/wx/math.h b/include/wx/math.h index cd96cd6bee..7a8651f7e0 100644 --- a/include/wx/math.h +++ b/include/wx/math.h @@ -26,6 +26,36 @@ #define M_PI 3.1415926535897932384626433832795 #endif +// Scaling factors for various unit conversions +#ifndef METRIC_CONVERSION_CONSTANT + #define METRIC_CONVERSION_CONSTANT 0.0393700787 +#endif + +#ifndef mm2inches + #define mm2inches (METRIC_CONVERSION_CONSTANT) +#endif + +#ifndef inches2mm + #define inches2mm (1/(mm2inches)) +#endif + +#ifndef mm2twips + #define mm2twips (METRIC_CONVERSION_CONSTANT*1440) +#endif + +#ifndef twips2mm + #define twips2mm (1/(mm2twips)) +#endif + +#ifndef mm2pt + #define mm2pt (METRIC_CONVERSION_CONSTANT*72) +#endif + +#ifndef pt2mm + #define pt2mm (1/(mm2pt)) +#endif + + /* unknown __VISAGECC__, __SYMANTECCC__ */ #if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__) diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index 6ddf2d4c5b..a7b41605a0 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -33,19 +33,6 @@ class WXDLLEXPORT wxWindow; // private constants // --------------------------------------------------------------------------- -// Conversion -static const double METRIC_CONVERSION_CONSTANT = 0.0393700787; - -// Scaling factors for various unit conversions -static const double mm2inches = (METRIC_CONVERSION_CONSTANT); -static const double inches2mm = (1/METRIC_CONVERSION_CONSTANT); - -static const double mm2twips = (METRIC_CONVERSION_CONSTANT*1440); -static const double twips2mm = (1/(METRIC_CONVERSION_CONSTANT*1440)); - -static const double mm2pt = (METRIC_CONVERSION_CONSTANT*72); -static const double pt2mm = (1/(METRIC_CONVERSION_CONSTANT*72)); - // 260 was taken from windef.h #ifndef MAX_PATH #define MAX_PATH 260 diff --git a/include/wx/os2/private.h b/include/wx/os2/private.h index 6654816b58..024663695b 100644 --- a/include/wx/os2/private.h +++ b/include/wx/os2/private.h @@ -46,19 +46,6 @@ class WXDLLEXPORT wxBitmap; // private constants // --------------------------------------------------------------------------- -// Conversion -static const double METRIC_CONVERSION_CONSTANT = 0.0393700787; - -// Scaling factors for various unit conversions -static const double mm2inches = (METRIC_CONVERSION_CONSTANT); -static const double inches2mm = (1/METRIC_CONVERSION_CONSTANT); - -static const double mm2twips = (METRIC_CONVERSION_CONSTANT*1440); -static const double twips2mm = (1/(METRIC_CONVERSION_CONSTANT*1440)); - -static const double mm2pt = (METRIC_CONVERSION_CONSTANT*72); -static const double pt2mm = (1/(METRIC_CONVERSION_CONSTANT*72)); - // // Constant strings for control names and classes // diff --git a/src/gtk/dc.cpp b/src/gtk/dc.cpp index c74bbc81bb..00b3fafcb5 100644 --- a/src/gtk/dc.cpp +++ b/src/gtk/dc.cpp @@ -20,17 +20,6 @@ #include #include -//----------------------------------------------------------------------------- -// constants -//----------------------------------------------------------------------------- - -#define mm2inches 0.0393700787402 -#define inches2mm 25.4 -#define mm2twips 56.6929133859 -#define twips2mm 0.0176388888889 -#define mm2pt 2.83464566929 -#define pt2mm 0.352777777778 - //----------------------------------------------------------------------------- // wxDC //----------------------------------------------------------------------------- @@ -117,7 +106,7 @@ void wxDC::SetMapMode( int mode ) break; } m_mappingMode = mode; - + /* we don't do this mega optimisation if (mode != wxMM_TEXT) { diff --git a/src/gtk1/dc.cpp b/src/gtk1/dc.cpp index c74bbc81bb..00b3fafcb5 100644 --- a/src/gtk1/dc.cpp +++ b/src/gtk1/dc.cpp @@ -20,17 +20,6 @@ #include #include -//----------------------------------------------------------------------------- -// constants -//----------------------------------------------------------------------------- - -#define mm2inches 0.0393700787402 -#define inches2mm 25.4 -#define mm2twips 56.6929133859 -#define twips2mm 0.0176388888889 -#define mm2pt 2.83464566929 -#define pt2mm 0.352777777778 - //----------------------------------------------------------------------------- // wxDC //----------------------------------------------------------------------------- @@ -117,7 +106,7 @@ void wxDC::SetMapMode( int mode ) break; } m_mappingMode = mode; - + /* we don't do this mega optimisation if (mode != wxMM_TEXT) { diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 028c3cd0fc..6485dc81e5 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -40,13 +40,6 @@ IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) // constants //----------------------------------------------------------------------------- -#define mm2inches 0.0393700787402 -#define inches2mm 25.4 -#define mm2twips 56.6929133859 -#define twips2mm 0.0176388888889 -#define mm2pt 2.83464566929 -#define pt2mm 0.352777777778 - const double RAD2DEG = 180.0 / M_PI; const short kEmulatedMode = -1 ; const short kUnsupportedMode = -2 ; diff --git a/src/mac/classic/dc.cpp b/src/mac/classic/dc.cpp index 5be3660fc2..ae7936dd6c 100644 --- a/src/mac/classic/dc.cpp +++ b/src/mac/classic/dc.cpp @@ -40,13 +40,6 @@ IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) // constants //----------------------------------------------------------------------------- -#define mm2inches 0.0393700787402 -#define inches2mm 25.4 -#define mm2twips 56.6929133859 -#define twips2mm 0.0176388888889 -#define mm2pt 2.83464566929 -#define pt2mm 0.352777777778 - const double RAD2DEG = 180.0 / M_PI; const short kEmulatedMode = -1 ; const short kUnsupportedMode = -2 ; diff --git a/src/mgl/dc.cpp b/src/mgl/dc.cpp index 3fb64cab40..37fee41ab7 100644 --- a/src/mgl/dc.cpp +++ b/src/mgl/dc.cpp @@ -47,12 +47,6 @@ // constants //----------------------------------------------------------------------------- -const double mm2inches = 0.0393700787402; -const double inches2mm = 25.4; -const double mm2twips = 56.6929133859; -const double twips2mm = 0.0176388888889; -const double mm2pt = 2.83464566929; -const double pt2mm = 0.352777777778; const double RAD2DEG = 180.0 / M_PI; diff --git a/src/motif/dc.cpp b/src/motif/dc.cpp index 187bf9f018..f4d0e3f56d 100644 --- a/src/motif/dc.cpp +++ b/src/motif/dc.cpp @@ -22,17 +22,6 @@ IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) -//----------------------------------------------------------------------------- -// constants -//----------------------------------------------------------------------------- - -#define mm2inches 0.0393700787402 -#define inches2mm 25.4 -#define mm2twips 56.6929133859 -#define twips2mm 0.0176388888889 -#define mm2pt 2.83464566929 -#define pt2mm 0.352777777778 - //----------------------------------------------------------------------------- // wxDC //----------------------------------------------------------------------------- diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index bf6b78b836..ef70b6f9e3 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -39,6 +39,7 @@ #include "wx/log.h" #include "wx/app.h" #include "wx/menu.h" + #include "wx/math.h" #endif #include "wx/module.h" diff --git a/src/x11/dc.cpp b/src/x11/dc.cpp index 4b82e09a70..cecac15863 100644 --- a/src/x11/dc.cpp +++ b/src/x11/dc.cpp @@ -19,17 +19,6 @@ IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) -//----------------------------------------------------------------------------- -// constants -//----------------------------------------------------------------------------- - -#define mm2inches 0.0393700787402 -#define inches2mm 25.4 -#define mm2twips 56.6929133859 -#define twips2mm 0.0176388888889 -#define mm2pt 2.83464566929 -#define pt2mm 0.352777777778 - //----------------------------------------------------------------------------- // wxDC //----------------------------------------------------------------------------- -- 2.45.2