use wxIsSameDouble() and wxIsNullDouble() for warning-less double comparison of doubles

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35705 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-09-25 23:27:27 +00:00
parent f1afd2e066
commit c77a67962c
14 changed files with 139 additions and 127 deletions

View File

@@ -449,12 +449,12 @@ inline wxPoint2DDouble& wxPoint2DDouble::operator/=(const wxPoint2DDouble& pt)
inline bool wxPoint2DDouble::operator==(const wxPoint2DDouble& pt) const 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 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) 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 ) ) && { 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 ) ) ); } ( ( m_y <= rect.m_y ) && ( rect.m_y + rect.m_height <= m_y + m_height ) ) ); }
inline bool IsEmpty() const 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 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 ) inline void Inset( wxDouble x , wxDouble y )
{ m_x += x; m_y += y; m_width -= 2 * x; m_height -= 2 * 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); wxRect2DDouble& operator = (const wxRect2DDouble& rect);
inline bool operator == (const wxRect2DDouble& rect) const 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 inline bool operator != (const wxRect2DDouble& rect) const
{ return !(*this == rect); } { return !(*this == rect); }

View File

@@ -214,15 +214,15 @@ inline double wxTransformMatrix::TransformY(double y) const
inline bool wxTransformMatrix::IsIdentity1(void) const inline bool wxTransformMatrix::IsIdentity1(void) const
{ {
return return
(m_matrix[0][0] == 1.0 && ( wxIsSameDouble(m_matrix[0][0], 1.0) &&
m_matrix[1][1] == 1.0 && wxIsSameDouble(m_matrix[1][1], 1.0) &&
m_matrix[2][2] == 1.0 && wxIsSameDouble(m_matrix[2][2], 1.0) &&
m_matrix[1][0] == 0.0 && wxIsSameDouble(m_matrix[1][0], 0.0) &&
m_matrix[2][0] == 0.0 && wxIsSameDouble(m_matrix[2][0], 0.0) &&
m_matrix[0][1] == 0.0 && wxIsSameDouble(m_matrix[0][1], 0.0) &&
m_matrix[2][1] == 0.0 && wxIsSameDouble(m_matrix[2][1], 0.0) &&
m_matrix[0][2] == 0.0 && wxIsSameDouble(m_matrix[0][2], 0.0) &&
m_matrix[1][2] == 0.0) ; wxIsSameDouble(m_matrix[1][2], 0.0) );
} }
// Calculates the determinant of a 2 x 2 matrix // 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; return a11 * a22 - a12 * a21;
} }
#endif #endif // _WX_MATRIXH__
// _WX_MATRIXH__

View File

@@ -25,6 +25,7 @@
#endif #endif
#include "wx/dc.h" #include "wx/dc.h"
#include "wx/math.h"
// bool wxDCBase::sm_cacheing = false; // bool wxDCBase::sm_cacheing = false;
@@ -401,15 +402,14 @@ bool wxDCBase::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths)
{ {
int totalWidth = 0; int totalWidth = 0;
size_t i, len = text.Length(); const size_t len = text.Length();
widths.Empty(); widths.Empty();
widths.Add(0, len); widths.Add(0, len);
int w, h;
// reset the cache if font or horizontal scale have changed // reset the cache if font or horizontal scale have changed
if (!s_fontWidthCache.m_widths || if ( !s_fontWidthCache.m_widths ||
(s_fontWidthCache.m_scaleX != m_scaleX) || !wxIsSameDouble(s_fontWidthCache.m_scaleX, m_scaleX) ||
(s_fontWidthCache.m_font != GetFont())) (s_fontWidthCache.m_font != GetFont()) )
{ {
s_fontWidthCache.Reset(); s_fontWidthCache.Reset();
s_fontWidthCache.m_font = GetFont(); 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 // Calculate the position of each character based on the widths of
// the previous characters // 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]; const wxChar c = text[i];
unsigned int c_int = (unsigned int)c; unsigned int c_int = (unsigned int)c;

View File

@@ -202,14 +202,14 @@ void wxPoint2DInt::SetVectorAngle( wxDouble degrees )
wxDouble wxPoint2DDouble::GetVectorAngle() const wxDouble wxPoint2DDouble::GetVectorAngle() const
{ {
if ( m_x == 0 ) if ( wxIsNullDouble(m_x) )
{ {
if ( m_y >= 0 ) if ( m_y >= 0 )
return 90; return 90;
else else
return 270; return 270;
} }
if ( m_y == 0 ) if ( wxIsNullDouble(m_y) )
{ {
if ( m_x >= 0 ) if ( m_x >= 0 )
return 0; return 0;

View File

@@ -1751,29 +1751,36 @@ wxString wxImage::GetImageExtWildcard()
wxImage::HSVValue wxImage::RGBtoHSV(const RGBValue& rgb) wxImage::HSVValue wxImage::RGBtoHSV(const RGBValue& rgb)
{ {
double hue, saturation, value;
const double red = rgb.red / 255.0, const double red = rgb.red / 255.0,
green = rgb.green / 255.0, green = rgb.green / 255.0,
blue = rgb.blue / 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; double minimumRGB = red;
if (green < minimumRGB) if ( green < minimumRGB )
minimumRGB = green; minimumRGB = green;
if ( blue < minimumRGB )
if (blue < minimumRGB)
minimumRGB = blue; minimumRGB = blue;
enum { RED, GREEN, BLUE } chMax = RED;
double maximumRGB = red; double maximumRGB = red;
if (green > maximumRGB) if ( green > maximumRGB )
{
chMax = GREEN;
maximumRGB = green; maximumRGB = green;
}
if (blue > maximumRGB) if ( blue > maximumRGB )
{
chMax = BLUE;
maximumRGB = 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 // Gray has no color
hue = 0.0; hue = 0.0;
@@ -1781,21 +1788,27 @@ wxImage::HSVValue wxImage::RGBtoHSV(const RGBValue& rgb)
} }
else else
{ {
double deltaRGB = maximumRGB - minimumRGB; switch ( chMax )
{
case RED:
hue = (green - blue) / deltaRGB;
break;
case GREEN:
hue = 2.0 + (blue - red) / deltaRGB;
break;
case BLUE:
hue = 4.0 + (red - green) / deltaRGB;
break;
}
hue /= 6.0;
if ( hue < 0.0 )
hue += 1.0;
saturation = deltaRGB / maximumRGB; saturation = deltaRGB / maximumRGB;
if ( red == maximumRGB )
hue = (green - blue) / deltaRGB;
else if (green == maximumRGB)
hue = 2.0 + (blue - red) / deltaRGB;
else
hue = 4.0 + (red - green) / deltaRGB;
hue = hue / 6.0;
if (hue < 0.0)
hue = hue + 1.0;
} }
return HSVValue(hue, saturation, value); return HSVValue(hue, saturation, value);
@@ -1805,13 +1818,14 @@ wxImage::RGBValue wxImage::HSVtoRGB(const HSVValue& hsv)
{ {
double red, green, blue; double red, green, blue;
if ( hsv.saturation == 0.0 ) if ( wxIsNullDouble(hsv.saturation) )
{ {
red = hsv.value; //Grey // Grey
red = hsv.value;
green = 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 double hue = hsv.hue * 6.0; // sector 0 to 5
int i = (int)floor(hue); int i = (int)floor(hue);
@@ -1877,7 +1891,7 @@ void wxImage::RotateHue(double angle)
wxASSERT (angle >= -1.0 && angle <= 1.0); wxASSERT (angle >= -1.0 && angle <= 1.0);
count = M_IMGDATA->m_width * M_IMGDATA->m_height; 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; srcBytePtr = M_IMGDATA->m_data;
dstBytePtr = srcBytePtr; dstBytePtr = srcBytePtr;

View File

@@ -81,7 +81,7 @@ bool wxTransformMatrix::operator == (const wxTransformMatrix& mat) const
{ {
for (j = 0; j < 3; j++) 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; return false;
} }
} }
@@ -129,27 +129,22 @@ bool wxTransformMatrix::Invert(void)
// now divide by the determinant // 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]; 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) if ( wxIsNullDouble(det) )
{ return false;
inverseMatrix[0][0] /= det; inverseMatrix[1][0] /= det; inverseMatrix[2][0] /= det; 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][1] /= det; inverseMatrix[1][1] /= det; inverseMatrix[2][1] /= det;
inverseMatrix[0][2] /= det; inverseMatrix[1][2] /= det; inverseMatrix[2][2] /= det; inverseMatrix[0][2] /= det; inverseMatrix[1][2] /= det; inverseMatrix[2][2] /= det;
int i, j; for (int i = 0; i < 3; i++)
for (i = 0; i < 3; i++)
{ {
for (j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
{ {
m_matrix[i][j] = inverseMatrix[i][j]; m_matrix[i][j] = inverseMatrix[i][j];
} }
} }
m_isIdentity = IsIdentity1(); m_isIdentity = IsIdentity1();
return true; return true;
}
else
{
return false;
}
} }
// Make into identity matrix // Make into identity matrix
@@ -195,8 +190,8 @@ wxTransformMatrix& wxTransformMatrix::Scale(const double &xs, const double &ys,
if (m_isIdentity) if (m_isIdentity)
{ {
double tx =xc*(1-xs); double tx = xc*(1-xs);
double ty =yc*(1-ys); double ty = yc*(1-ys);
r00 = xs; r00 = xs;
r10 = 0; r10 = 0;
r20 = tx; r20 = tx;
@@ -204,10 +199,10 @@ wxTransformMatrix& wxTransformMatrix::Scale(const double &xs, const double &ys,
r11 = ys; r11 = ys;
r21 = ty; r21 = ty;
} }
else if (xc!=0 || yc!=0) else if ( !wxIsNullDouble(xc) || !wxIsNullDouble(yc) )
{ {
double tx =xc*(1-xs); double tx = xc*(1-xs);
double ty =yc*(1-ys); double ty = yc*(1-ys);
r00 = xs * m_matrix[0][0]; r00 = xs * m_matrix[0][0];
r10 = xs * m_matrix[1][0]; r10 = xs * m_matrix[1][0];
r20 = xs * m_matrix[2][0] + tx; r20 = xs * m_matrix[2][0] + tx;
@@ -329,7 +324,7 @@ wxTransformMatrix& wxTransformMatrix::Rotate(const double &degrees, const doubl
r11 = c; r11 = c;
r21 = ty; r21 = ty;
} }
else if (x!=0 || y!=0) else if ( !wxIsNullDouble(x) || !wxIsNullDouble(y) )
{ {
double tx = x*(1-c)+y*s; double tx = x*(1-c)+y*s;
double ty = y*(1-c)-x*s; double ty = y*(1-c)-x*s;
@@ -404,15 +399,15 @@ bool wxTransformMatrix::InverseTransformPoint(double x, double y, double& tx, do
{ {
if (IsIdentity()) 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]; const double z = (1.0 - m_matrix[0][2] * x - m_matrix[1][2] * y) / m_matrix[2][2];
if (z == 0.0) if ( wxIsNullDouble(z) )
{
// z = 0.0000001;
return false; return false;
}
tx = x * m_matrix[0][0] + y * m_matrix[1][0] + z * m_matrix[2][0]; 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]; ty = x * m_matrix[0][1] + y * m_matrix[1][1] + z * m_matrix[2][1];
return true; return true;
@@ -556,7 +551,7 @@ double wxTransformMatrix::Get_scaleX()
{ {
double scale_factor; double scale_factor;
double rot_angle = CheckInt(atan2(m_matrix[1][0],m_matrix[0][0])*180/pi); 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); scale_factor = m_matrix[0][0]/cos((rot_angle/180)*pi);
else else
scale_factor = m_matrix[0][0]/sin((rot_angle/180)*pi); // er kan nl. niet door 0 gedeeld worden ! 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 scale_factor;
double rot_angle = CheckInt(atan2(m_matrix[1][0],m_matrix[0][0])*180/pi); 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); scale_factor = m_matrix[1][1]/cos((rot_angle/180)*pi);
else else
scale_factor = m_matrix[1][1]/sin((rot_angle/180)*pi); // er kan nl. niet door 0 gedeeld worden ! scale_factor = m_matrix[1][1]/sin((rot_angle/180)*pi); // er kan nl. niet door 0 gedeeld worden !

View File

@@ -405,9 +405,10 @@ void wxPostScriptDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
alpha1 = 0.0; alpha1 = 0.0;
alpha2 = 360.0; alpha2 = 360.0;
} }
else if (radius == 0.0) else if ( wxIsNullDouble(radius) )
{ {
alpha1 = alpha2 = 0.0; alpha1 =
alpha2 = 0.0;
} }
else 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") ); wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
if (sa>=360 || sa<=-360) sa=sa-int(sa/360)*360; if ( sa >= 360 || sa <= -360 )
if (ea>=360 || ea<=-360) ea=ea-int(ea/360)*360; sa -= int(sa/360)*360;
if (sa<0) sa+=360; if ( ea >= 360 || ea <=- 360 )
if (ea<0) 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); DrawEllipse(x,y,w,h);
return; 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 ) void wxPostScriptDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord y, double angle )
{ {
if (angle == 0.0) if ( wxIsNullDouble(angle) )
{ {
DoDrawText(text, x, y); DoDrawText(text, x, y);
return; return;

View File

@@ -38,6 +38,7 @@
#include "wx/combobox.h" #include "wx/combobox.h"
#include "wx/valtext.h" #include "wx/valtext.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/math.h"
#endif #endif
#include "wx/textfile.h" #include "wx/textfile.h"
@@ -1085,7 +1086,8 @@ bool wxGridCellFloatEditor::EndEdit(int row, int col,
double value = 0.0; double value = 0.0;
wxString text(Text()->GetValue()); 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)) if (grid->GetTable()->CanSetValueAs(row, col, wxGRID_VALUE_FLOAT))
grid->GetTable()->SetValueAsDouble(row, col, value); grid->GetTable()->SetValueAsDouble(row, col, value);

View File

@@ -538,10 +538,10 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
radius1 = 0.0; radius1 = 0.0;
radius2 = 360.0; radius2 = 360.0;
} }
else else if ( wxIsNullDouble(radius) )
if (radius == 0.0)
{ {
radius1 = radius2 = 0.0; radius1 =
radius2 = 0.0;
} }
else 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 ) void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle )
{ {
if (angle == 0.0) if ( wxIsNullDouble(angle) )
{ {
DrawText(text, x, y); DrawText(text, x, y);
return; return;
@@ -2366,18 +2366,15 @@ void wxWindowDC::Destroy()
void wxWindowDC::ComputeScaleAndOrigin() void wxWindowDC::ComputeScaleAndOrigin()
{ {
/* CMB: copy scale to see if it changes */ const wxRealPoint origScale(m_scaleX, m_scaleY);
double origScaleX = m_scaleX;
double origScaleY = m_scaleY;
wxDC::ComputeScaleAndOrigin(); wxDC::ComputeScaleAndOrigin();
/* CMB: if scale has changed call SetPen to recalulate the line width */ // if scale has changed call SetPen to recalulate the line width
if ((m_scaleX != origScaleX || m_scaleY != origScaleY) && if ( wxRealPoint(m_scaleX, m_scaleY) != origScale && m_pen.Ok() )
(m_pen.Ok()))
{ {
/* this is a bit artificial, but we need to force wxDC to think // this is a bit artificial, but we need to force wxDC to think the pen
the pen has changed */ // has changed
wxPen pen = m_pen; wxPen pen = m_pen;
m_pen = wxNullPen; m_pen = wxNullPen;
SetPen( pen ); SetPen( pen );

View File

@@ -73,7 +73,7 @@ bool wxStaticBox::Create( wxWindow *parent,
else // wxALIGN_LEFT else // wxALIGN_LEFT
xalign = 0.0; 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); gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.5);
return TRUE; return TRUE;

View File

@@ -14,6 +14,7 @@
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/math.h"
#include "wx/settings.h" #include "wx/settings.h"
#include "wx/panel.h" #include "wx/panel.h"
#include "wx/strconv.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) ); 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 // 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_view_scroll_to_mark( GTK_TEXT_VIEW(m_text),
gtk_text_buffer_get_insert( m_buffer ), 0.0, FALSE, 0.0, 1.0 ); gtk_text_buffer_get_insert( m_buffer ), 0.0, FALSE, 0.0, 1.0 );

View File

@@ -538,10 +538,10 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
radius1 = 0.0; radius1 = 0.0;
radius2 = 360.0; radius2 = 360.0;
} }
else else if ( wxIsNullDouble(radius) )
if (radius == 0.0)
{ {
radius1 = radius2 = 0.0; radius1 =
radius2 = 0.0;
} }
else 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 ) void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle )
{ {
if (angle == 0.0) if ( wxIsNullDouble(angle) )
{ {
DrawText(text, x, y); DrawText(text, x, y);
return; return;
@@ -2366,18 +2366,15 @@ void wxWindowDC::Destroy()
void wxWindowDC::ComputeScaleAndOrigin() void wxWindowDC::ComputeScaleAndOrigin()
{ {
/* CMB: copy scale to see if it changes */ const wxRealPoint origScale(m_scaleX, m_scaleY);
double origScaleX = m_scaleX;
double origScaleY = m_scaleY;
wxDC::ComputeScaleAndOrigin(); wxDC::ComputeScaleAndOrigin();
/* CMB: if scale has changed call SetPen to recalulate the line width */ // if scale has changed call SetPen to recalulate the line width
if ((m_scaleX != origScaleX || m_scaleY != origScaleY) && if ( wxRealPoint(m_scaleX, m_scaleY) != origScale && m_pen.Ok() )
(m_pen.Ok()))
{ {
/* this is a bit artificial, but we need to force wxDC to think // this is a bit artificial, but we need to force wxDC to think the pen
the pen has changed */ // has changed
wxPen pen = m_pen; wxPen pen = m_pen;
m_pen = wxNullPen; m_pen = wxNullPen;
SetPen( pen ); SetPen( pen );

View File

@@ -73,7 +73,7 @@ bool wxStaticBox::Create( wxWindow *parent,
else // wxALIGN_LEFT else // wxALIGN_LEFT
xalign = 0.0; 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); gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.5);
return TRUE; return TRUE;

View File

@@ -14,6 +14,7 @@
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/math.h"
#include "wx/settings.h" #include "wx/settings.h"
#include "wx/panel.h" #include "wx/panel.h"
#include "wx/strconv.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) ); 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 // 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_view_scroll_to_mark( GTK_TEXT_VIEW(m_text),
gtk_text_buffer_get_insert( m_buffer ), 0.0, FALSE, 0.0, 1.0 ); gtk_text_buffer_get_insert( m_buffer ), 0.0, FALSE, 0.0, 1.0 );