]> git.saurik.com Git - wxWidgets.git/commitdiff
use wxIsSameDouble() and wxIsNullDouble() for warning-less double comparison of doubles
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 Sep 2005 23:27:27 +0000 (23:27 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 Sep 2005 23:27:27 +0000 (23:27 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35705 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

14 files changed:
include/wx/geometry.h
include/wx/matrix.h
src/common/dcbase.cpp
src/common/geometry.cpp
src/common/image.cpp
src/common/matrix.cpp
src/generic/dcpsg.cpp
src/generic/grid.cpp
src/gtk/dcclient.cpp
src/gtk/statbox.cpp
src/gtk/textctrl.cpp
src/gtk1/dcclient.cpp
src/gtk1/statbox.cpp
src/gtk1/textctrl.cpp

index d38e7ab21065eda9c41f04fa6ac6b791a5b6144e..92c2bcbc0d2ea5a1b07f19a4f836865ea96a48fd 100644 (file)
@@ -449,12 +449,12 @@ inline wxPoint2DDouble& wxPoint2DDouble::operator/=(const wxPoint2DDouble& pt)
 
 inline bool wxPoint2DDouble::operator==(const wxPoint2DDouble& pt) const
 {
-    return m_x == pt.m_x && m_y == pt.m_y;
+    return wxIsSameDouble(m_x, pt.m_x) && wxIsSameDouble(m_y, pt.m_y);
 }
 
 inline bool wxPoint2DDouble::operator!=(const wxPoint2DDouble& pt) const
 {
-    return m_x != pt.m_x || m_y != pt.m_y;
+    return !(*this == pt);
 }
 
 inline wxPoint2DDouble operator+(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2)
@@ -590,9 +590,9 @@ public:
         { return ( ( ( m_x <= rect.m_x ) && ( rect.m_x + rect.m_width <= m_x + m_width ) ) &&
                 ( ( m_y <= rect.m_y ) && ( rect.m_y + rect.m_height <= m_y + m_height ) ) ); }
     inline bool IsEmpty() const
-        { return ( m_width <= 0 || m_height <= 0 ); }
+        { return m_width <= 0 || m_height <= 0; }
     inline bool HaveEqualSize( const wxRect2DDouble &rect ) const
-        { return ( rect.m_width == m_width && rect.m_height == m_height ); }
+        { return wxIsSameDouble(rect.m_width, m_width) && wxIsSameDouble(rect.m_height, m_height); }
 
     inline void Inset( wxDouble x , wxDouble y )
         { m_x += x; m_y += y; m_width -= 2 * x; m_height -= 2 * y; }
@@ -628,7 +628,7 @@ public:
 
     wxRect2DDouble& operator = (const wxRect2DDouble& rect);
     inline bool operator == (const wxRect2DDouble& rect) const
-        { return (m_x==rect.m_x && m_y==rect.m_y && m_width==rect.m_width && m_height==rect.m_height); }
+        { return wxIsSameDouble(m_x, rect.m_x) && wxIsSameDouble(m_y, rect.m_y) && HaveEqualSize(rect); }
     inline bool operator != (const wxRect2DDouble& rect) const
         { return !(*this == rect); }
 
index 8061667a3a211fbc23f9cc7198be6ac1effa5c27..53e0beb3de9657afcb2a646fbb556243e1dd6489 100644 (file)
@@ -214,15 +214,15 @@ inline double wxTransformMatrix::TransformY(double y) const
 inline bool wxTransformMatrix::IsIdentity1(void) const
 {
     return
-     (m_matrix[0][0] == 1.0 &&
-      m_matrix[1][1] == 1.0 &&
-      m_matrix[2][2] == 1.0 &&
-      m_matrix[1][0] == 0.0 &&
-      m_matrix[2][0] == 0.0 &&
-      m_matrix[0][1] == 0.0 &&
-      m_matrix[2][1] == 0.0 &&
-      m_matrix[0][2] == 0.0 &&
-      m_matrix[1][2] == 0.0) ;
+    ( wxIsSameDouble(m_matrix[0][0], 1.0) &&
+      wxIsSameDouble(m_matrix[1][1], 1.0) &&
+      wxIsSameDouble(m_matrix[2][2], 1.0) &&
+      wxIsSameDouble(m_matrix[1][0], 0.0) &&
+      wxIsSameDouble(m_matrix[2][0], 0.0) &&
+      wxIsSameDouble(m_matrix[0][1], 0.0) &&
+      wxIsSameDouble(m_matrix[2][1], 0.0) &&
+      wxIsSameDouble(m_matrix[0][2], 0.0) &&
+      wxIsSameDouble(m_matrix[1][2], 0.0) );
 }
 
 // Calculates the determinant of a 2 x 2 matrix
@@ -231,5 +231,4 @@ inline double wxCalculateDet(double a11, double a21, double a12, double a22)
     return a11 * a22 - a12 * a21;
 }
 
-#endif
-    // _WX_MATRIXH__
+#endif // _WX_MATRIXH__
index 4d86eb2ca041c24bba12b6c0e71d041c37fcfe52..4cb7b53482e0247950bab08d318af520cefd5337 100644 (file)
@@ -25,6 +25,7 @@
 #endif
 
 #include "wx/dc.h"
+#include "wx/math.h"
 
 // bool wxDCBase::sm_cacheing = false;
 
@@ -401,15 +402,14 @@ bool wxDCBase::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths)
 {
     int totalWidth = 0;
 
-    size_t i, len = text.Length();
+    const size_t len = text.Length();
     widths.Empty();
     widths.Add(0, len);
-    int w, h;
 
     // reset the cache if font or horizontal scale have changed
-    if (!s_fontWidthCache.m_widths ||
-        (s_fontWidthCache.m_scaleX != m_scaleX) ||
-        (s_fontWidthCache.m_font != GetFont()))
+    if ( !s_fontWidthCache.m_widths ||
+         !wxIsSameDouble(s_fontWidthCache.m_scaleX, m_scaleX) ||
+         (s_fontWidthCache.m_font != GetFont()) )
     {
         s_fontWidthCache.Reset();
         s_fontWidthCache.m_font = GetFont();
@@ -418,7 +418,8 @@ bool wxDCBase::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths)
 
     // Calculate the position of each character based on the widths of
     // the previous characters
-    for (i=0; i<len; i++)
+    int w, h;
+    for ( size_t i = 0; i < len; i++ )
     {
         const wxChar c = text[i];
         unsigned int c_int = (unsigned int)c;
index a3c495925969422ae2b0706ae1ddd4a68c1447e8..db4ff7c671ab5e0215769b5f01bf34643de01452 100644 (file)
@@ -202,14 +202,14 @@ void wxPoint2DInt::SetVectorAngle( wxDouble degrees )
 
 wxDouble wxPoint2DDouble::GetVectorAngle() const
 {
-    if ( m_x == 0 )
+    if ( wxIsNullDouble(m_x) )
     {
         if ( m_y >= 0 )
             return 90;
         else
             return 270;
     }
-    if ( m_y == 0 )
+    if ( wxIsNullDouble(m_y) )
     {
         if ( m_x >= 0 )
             return 0;
index 43634787ce77bc783c6353a6e2fdd51613abc35b..d7e07b0dc01eafed18c462d308df838bc24ec33d 100644 (file)
@@ -1751,29 +1751,36 @@ wxString wxImage::GetImageExtWildcard()
 
 wxImage::HSVValue wxImage::RGBtoHSV(const RGBValue& rgb)
 {
-    double hue, saturation, value;
-
     const double red = rgb.red / 255.0,
                  green = rgb.green / 255.0,
                  blue = rgb.blue / 255.0;
 
+    // find the min and max intensity (and remember which one was it for the
+    // latter)
     double minimumRGB = red;
-    if (green < minimumRGB)
+    if ( green < minimumRGB )
         minimumRGB = green;
-
-    if (blue < minimumRGB)
+    if ( blue < minimumRGB )
         minimumRGB = blue;
 
+    enum { RED, GREEN, BLUE } chMax = RED;
     double maximumRGB = red;
-    if (green > maximumRGB)
+    if ( green > maximumRGB )
+    {
+        chMax = GREEN;
         maximumRGB = green;
-
-    if (blue > maximumRGB)
+    }
+    if ( blue > maximumRGB )
+    {
+        chMax = BLUE;
         maximumRGB = blue;
+    }
 
-    value = maximumRGB;
+    const double value = maximumRGB;
 
-    if (maximumRGB == minimumRGB)
+    double hue, saturation;
+    const double deltaRGB = maximumRGB - minimumRGB;
+    if ( wxIsNullDouble(deltaRGB) )
     {
         // Gray has no color
         hue = 0.0;
@@ -1781,21 +1788,27 @@ wxImage::HSVValue wxImage::RGBtoHSV(const RGBValue& rgb)
     }
     else
     {
-        double deltaRGB = maximumRGB - minimumRGB;
+        switch ( chMax )
+        {
+            case RED:
+                hue = (green - blue) / deltaRGB;
+                break;
 
-        saturation = deltaRGB / maximumRGB;
+            case GREEN:
+                hue = 2.0 + (blue - red) / deltaRGB;
+                break;
 
-        if ( red == maximumRGB )
-            hue = (green - blue) / deltaRGB;
-        else if (green == maximumRGB)
-            hue = 2.0 + (blue - red) / deltaRGB;
-        else
-            hue = 4.0 + (red - green) / deltaRGB;
+            case BLUE:
+                hue = 4.0 + (red - green) / deltaRGB;
+                break;
+        }
+
+        hue /= 6.0;
 
-        hue = hue / 6.0;
+        if ( hue < 0.0 )
+            hue += 1.0;
 
-        if (hue < 0.0)
-            hue = hue + 1.0;
+        saturation = deltaRGB / maximumRGB;
     }
 
     return HSVValue(hue, saturation, value);
@@ -1805,13 +1818,14 @@ wxImage::RGBValue wxImage::HSVtoRGB(const HSVValue& hsv)
 {
     double red, green, blue;
 
-    if ( hsv.saturation == 0.0 )
+    if ( wxIsNullDouble(hsv.saturation) )
     {
-        red = hsv.value; //Grey
+        // Grey
+        red = hsv.value;
         green = hsv.value;
-        blue = hsv.value; 
+        blue = hsv.value;
     }
-    else
+    else // not grey
     {
         double hue = hsv.hue * 6.0;      // sector 0 to 5
         int i = (int)floor(hue);
@@ -1877,7 +1891,7 @@ void wxImage::RotateHue(double angle)
 
     wxASSERT (angle >= -1.0 && angle <= 1.0);
     count = M_IMGDATA->m_width * M_IMGDATA->m_height;
-    if (count > 0 && angle != 0.0)
+    if ( count > 0 && !wxIsNullDouble(angle) )
     {
         srcBytePtr = M_IMGDATA->m_data;
         dstBytePtr = srcBytePtr;
index 72a72517e42f09303a58879c94c36097a09985c3..724b7a5827ca2c68669a66b80e5b20881451e199 100644 (file)
@@ -81,7 +81,7 @@ bool wxTransformMatrix::operator == (const wxTransformMatrix& mat) const
     {
         for (j = 0; j < 3; j++)
         {
-            if (m_matrix[i][j] != mat.m_matrix[i][j])
+            if ( !wxIsSameDouble(m_matrix[i][j], mat.m_matrix[i][j]) )
                 return false;
         }
     }
@@ -129,27 +129,22 @@ bool wxTransformMatrix::Invert(void)
 
     // now divide by the determinant
     double det = m_matrix[0][0] * inverseMatrix[0][0] + m_matrix[0][1] * inverseMatrix[1][0] + m_matrix[0][2] * inverseMatrix[2][0];
-    if (det != 0.0)
-    {
-        inverseMatrix[0][0] /= det; inverseMatrix[1][0] /= det; inverseMatrix[2][0] /= det;
-        inverseMatrix[0][1] /= det; inverseMatrix[1][1] /= det; inverseMatrix[2][1] /= det;
-        inverseMatrix[0][2] /= det; inverseMatrix[1][2] /= det; inverseMatrix[2][2] /= det;
+    if ( wxIsNullDouble(det) )
+        return false;
+
+    inverseMatrix[0][0] /= det; inverseMatrix[1][0] /= det; inverseMatrix[2][0] /= det;
+    inverseMatrix[0][1] /= det; inverseMatrix[1][1] /= det; inverseMatrix[2][1] /= det;
+    inverseMatrix[0][2] /= det; inverseMatrix[1][2] /= det; inverseMatrix[2][2] /= det;
 
-        int i, j;
-        for (i = 0; i < 3; i++)
+    for (int i = 0; i < 3; i++)
+    {
+        for (int j = 0; j < 3; j++)
         {
-            for (j = 0; j < 3; j++)
-            {
-                m_matrix[i][j] = inverseMatrix[i][j];
-            }
+            m_matrix[i][j] = inverseMatrix[i][j];
         }
-        m_isIdentity = IsIdentity1();
-        return true;
-    }
-    else
-    {
-        return false;
     }
+    m_isIdentity = IsIdentity1();
+    return true;
 }
 
 // Make into identity matrix
@@ -195,8 +190,8 @@ wxTransformMatrix&  wxTransformMatrix::Scale(const double &xs, const double &ys,
 
     if (m_isIdentity)
     {
-        double tx  =xc*(1-xs);
-        double ty  =yc*(1-ys);
+        double tx xc*(1-xs);
+        double ty yc*(1-ys);
         r00 = xs;
         r10 = 0;
         r20 = tx;
@@ -204,10 +199,10 @@ wxTransformMatrix&  wxTransformMatrix::Scale(const double &xs, const double &ys,
         r11 = ys;
         r21 = ty;
     }
-    else if (xc!=0 || yc!=0)
+    else if ( !wxIsNullDouble(xc) || !wxIsNullDouble(yc) )
     {
-        double tx  =xc*(1-xs);
-        double ty  =yc*(1-ys);
+        double tx xc*(1-xs);
+        double ty yc*(1-ys);
         r00 = xs * m_matrix[0][0];
         r10 = xs * m_matrix[1][0];
         r20 = xs * m_matrix[2][0] + tx;
@@ -320,8 +315,8 @@ wxTransformMatrix&  wxTransformMatrix::Rotate(const double &degrees, const doubl
 
     if (m_isIdentity)
     {
-        double tx  = x*(1-c)+y*s;
-        double ty  = y*(1-c)-x*s;
+        double tx = x*(1-c)+y*s;
+        double ty = y*(1-c)-x*s;
         r00 = c ;
         r10 = -s;
         r20 = tx;
@@ -329,10 +324,10 @@ wxTransformMatrix&  wxTransformMatrix::Rotate(const double &degrees, const doubl
         r11 = c;
         r21 = ty;
     }
-    else if (x!=0 || y!=0)
+    else if ( !wxIsNullDouble(x) || !wxIsNullDouble(y) )
     {
-        double tx  = x*(1-c)+y*s;
-        double ty  = y*(1-c)-x*s;
+        double tx = x*(1-c)+y*s;
+        double ty = y*(1-c)-x*s;
         r00 = c * m_matrix[0][0] - s * m_matrix[0][1] + tx * m_matrix[0][2];
         r10 = c * m_matrix[1][0] - s * m_matrix[1][1] + tx * m_matrix[1][2];
         r20 = c * m_matrix[2][0] - s * m_matrix[2][1] + tx;// * m_matrix[2][2];
@@ -404,15 +399,15 @@ bool wxTransformMatrix::InverseTransformPoint(double x, double y, double& tx, do
 {
     if (IsIdentity())
     {
-        tx = x; ty = y; return true;
+        tx = x;
+        ty = y;
+        return true;
     }
 
-    double z = (1.0 - m_matrix[0][2] * x - m_matrix[1][2] * y) / m_matrix[2][2];
-    if (z == 0.0)
-    {
-//      z = 0.0000001;
+    const double z = (1.0 - m_matrix[0][2] * x - m_matrix[1][2] * y) / m_matrix[2][2];
+    if ( wxIsNullDouble(z) )
         return false;
-    }
+
     tx = x * m_matrix[0][0] + y * m_matrix[1][0] + z * m_matrix[2][0];
     ty = x * m_matrix[0][1] + y * m_matrix[1][1] + z * m_matrix[2][1];
     return true;
@@ -556,7 +551,7 @@ double wxTransformMatrix::Get_scaleX()
 {
     double scale_factor;
     double rot_angle = CheckInt(atan2(m_matrix[1][0],m_matrix[0][0])*180/pi);
-    if (rot_angle != 90 && rot_angle != -90)
+    if ( !wxIsSameDouble(rot_angle, 90) && !wxIsSameDouble(rot_angle, -90) )
         scale_factor = m_matrix[0][0]/cos((rot_angle/180)*pi);
     else
         scale_factor = m_matrix[0][0]/sin((rot_angle/180)*pi);  // er kan nl. niet door 0 gedeeld worden !
@@ -572,7 +567,7 @@ double wxTransformMatrix::Get_scaleY()
 {
     double scale_factor;
     double rot_angle = CheckInt(atan2(m_matrix[1][0],m_matrix[0][0])*180/pi);
-    if (rot_angle != 90 && rot_angle != -90)
+    if ( !wxIsSameDouble(rot_angle, 90) && !wxIsSameDouble(rot_angle, -90) )
        scale_factor = m_matrix[1][1]/cos((rot_angle/180)*pi);
     else
        scale_factor = m_matrix[1][1]/sin((rot_angle/180)*pi);   // er kan nl. niet door 0 gedeeld worden !
index 75dd0dc5aeff14c439ef023afd3149cf9e932b57..63d3c4bbab4447e3e8fe25cb6250a1df8a5064df 100644 (file)
@@ -405,9 +405,10 @@ void wxPostScriptDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
         alpha1 = 0.0;
         alpha2 = 360.0;
     }
-    else if (radius == 0.0)
+    else if ( wxIsNullDouble(radius) )
     {
-        alpha1 = alpha2 = 0.0;
+        alpha1 =
+        alpha2 = 0.0;
     }
     else
     {
@@ -460,12 +461,16 @@ void wxPostScriptDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,d
 {
     wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
 
-    if (sa>=360 || sa<=-360) sa=sa-int(sa/360)*360;
-    if (ea>=360 || ea<=-360) ea=ea-int(ea/360)*360;
-    if (sa<0) sa+=360;
-    if (ea<0) ea+=360;
+    if ( sa >= 360 || sa <= -360 )
+        sa -= int(sa/360)*360;
+    if ( ea >= 360 || ea <=- 360 )
+        ea -= int(ea/360)*360;
+    if ( sa < 0 )
+        sa += 360;
+    if ( ea < 0 )
+        ea += 360;
 
-    if (sa==ea)
+    if ( wxIsSameDouble(sa, ea) )
     {
         DrawEllipse(x,y,w,h);
         return;
@@ -1247,7 +1252,7 @@ void wxPostScriptDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y )
 
 void wxPostScriptDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord y, double angle )
 {
-    if (angle == 0.0)
+    if ( wxIsNullDouble(angle) )
     {
         DoDrawText(text, x, y);
         return;
index 2ab4374312f47c528206bc5868b8d2827b083538..4a491aae1d6874681611430114a1c80ed5988824 100644 (file)
@@ -38,6 +38,7 @@
     #include "wx/combobox.h"
     #include "wx/valtext.h"
     #include "wx/intl.h"
+    #include "wx/math.h"
 #endif
 
 #include "wx/textfile.h"
@@ -1085,7 +1086,8 @@ bool wxGridCellFloatEditor::EndEdit(int row, int col,
     double value = 0.0;
     wxString text(Text()->GetValue());
 
-    if ( (text.empty() || text.ToDouble(&value)) && (value != m_valueOld) )
+    if ( (text.empty() || text.ToDouble(&value)) &&
+            !wxIsSameDouble(value, m_valueOld) )
     {
         if (grid->GetTable()->CanSetValueAs(row, col, wxGRID_VALUE_FLOAT))
             grid->GetTable()->SetValueAsDouble(row, col, value);
index 353ecd4501165dccf1ba71baac65ca25b5257c07..4a1ead4f1f6be3e0db2ddd900c8029802342060b 100644 (file)
@@ -538,10 +538,10 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
         radius1 = 0.0;
         radius2 = 360.0;
     }
-    else
-    if (radius == 0.0)
+    else if ( wxIsNullDouble(radius) )
     {
-        radius1 = radius2 = 0.0;
+        radius1 =
+        radius2 = 0.0;
     }
     else
     {
@@ -1606,7 +1606,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
 
 void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle )
 {
-    if (angle == 0.0)
+    if ( wxIsNullDouble(angle) )
     {
         DrawText(text, x, y);
         return;
@@ -2366,18 +2366,15 @@ void wxWindowDC::Destroy()
 
 void wxWindowDC::ComputeScaleAndOrigin()
 {
-    /* CMB: copy scale to see if it changes */
-    double origScaleX = m_scaleX;
-    double origScaleY = m_scaleY;
+    const wxRealPoint origScale(m_scaleX, m_scaleY);
 
     wxDC::ComputeScaleAndOrigin();
 
-    /* CMB: if scale has changed call SetPen to recalulate the line width */
-    if ((m_scaleX != origScaleX || m_scaleY != origScaleY) &&
-        (m_pen.Ok()))
+    // if scale has changed call SetPen to recalulate the line width
+    if ( wxRealPoint(m_scaleX, m_scaleY) != origScale && m_pen.Ok() )
     {
-        /* this is a bit artificial, but we need to force wxDC to think
-           the pen has changed */
+        // this is a bit artificial, but we need to force wxDC to think the pen
+        // has changed
         wxPen pen = m_pen;
         m_pen = wxNullPen;
         SetPen( pen );
index 313a7ab44f8b343989e803e1f29232964dc20eaa..1cdcca5073d3afd0495cb7762cfd333dd6d31c0a 100644 (file)
@@ -73,7 +73,7 @@ bool wxStaticBox::Create( wxWindow *parent,
     else // wxALIGN_LEFT
         xalign = 0.0;
 
-    if ( xalign )
+    if ( style & (wxALIGN_RIGHT | wxALIGN_CENTER) ) // left alignment is default
         gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.5);
 
     return TRUE;
index ea62e181859e8f271ae68f646a015a1de94b5927..a6dfa4b31d8ea355fa7eef3aba8aad31ed399b36 100644 (file)
@@ -14,6 +14,7 @@
 #include "wx/utils.h"
 #include "wx/intl.h"
 #include "wx/log.h"
+#include "wx/math.h"
 #include "wx/settings.h"
 #include "wx/panel.h"
 #include "wx/strconv.h"
@@ -1029,7 +1030,7 @@ void wxTextCtrl::WriteText( const wxString &text )
 
         GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(m_widget) );
         // Scroll to cursor, but only if scrollbar thumb is at the very bottom
-        if ( adj->value == adj->upper - adj->page_size )
+        if ( wxIsSameDouble(adj->value, adj->upper - adj->page_size) )
         {
             gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text),
                     gtk_text_buffer_get_insert( m_buffer ), 0.0, FALSE, 0.0, 1.0 );
index 353ecd4501165dccf1ba71baac65ca25b5257c07..4a1ead4f1f6be3e0db2ddd900c8029802342060b 100644 (file)
@@ -538,10 +538,10 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
         radius1 = 0.0;
         radius2 = 360.0;
     }
-    else
-    if (radius == 0.0)
+    else if ( wxIsNullDouble(radius) )
     {
-        radius1 = radius2 = 0.0;
+        radius1 =
+        radius2 = 0.0;
     }
     else
     {
@@ -1606,7 +1606,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
 
 void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle )
 {
-    if (angle == 0.0)
+    if ( wxIsNullDouble(angle) )
     {
         DrawText(text, x, y);
         return;
@@ -2366,18 +2366,15 @@ void wxWindowDC::Destroy()
 
 void wxWindowDC::ComputeScaleAndOrigin()
 {
-    /* CMB: copy scale to see if it changes */
-    double origScaleX = m_scaleX;
-    double origScaleY = m_scaleY;
+    const wxRealPoint origScale(m_scaleX, m_scaleY);
 
     wxDC::ComputeScaleAndOrigin();
 
-    /* CMB: if scale has changed call SetPen to recalulate the line width */
-    if ((m_scaleX != origScaleX || m_scaleY != origScaleY) &&
-        (m_pen.Ok()))
+    // if scale has changed call SetPen to recalulate the line width
+    if ( wxRealPoint(m_scaleX, m_scaleY) != origScale && m_pen.Ok() )
     {
-        /* this is a bit artificial, but we need to force wxDC to think
-           the pen has changed */
+        // this is a bit artificial, but we need to force wxDC to think the pen
+        // has changed
         wxPen pen = m_pen;
         m_pen = wxNullPen;
         SetPen( pen );
index 313a7ab44f8b343989e803e1f29232964dc20eaa..1cdcca5073d3afd0495cb7762cfd333dd6d31c0a 100644 (file)
@@ -73,7 +73,7 @@ bool wxStaticBox::Create( wxWindow *parent,
     else // wxALIGN_LEFT
         xalign = 0.0;
 
-    if ( xalign )
+    if ( style & (wxALIGN_RIGHT | wxALIGN_CENTER) ) // left alignment is default
         gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.5);
 
     return TRUE;
index ea62e181859e8f271ae68f646a015a1de94b5927..a6dfa4b31d8ea355fa7eef3aba8aad31ed399b36 100644 (file)
@@ -14,6 +14,7 @@
 #include "wx/utils.h"
 #include "wx/intl.h"
 #include "wx/log.h"
+#include "wx/math.h"
 #include "wx/settings.h"
 #include "wx/panel.h"
 #include "wx/strconv.h"
@@ -1029,7 +1030,7 @@ void wxTextCtrl::WriteText( const wxString &text )
 
         GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(m_widget) );
         // Scroll to cursor, but only if scrollbar thumb is at the very bottom
-        if ( adj->value == adj->upper - adj->page_size )
+        if ( wxIsSameDouble(adj->value, adj->upper - adj->page_size) )
         {
             gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text),
                     gtk_text_buffer_get_insert( m_buffer ), 0.0, FALSE, 0.0, 1.0 );