wxRound() workaround to avoid unexpected compile and link errors on incomplete environments (Tinderbox build fix).
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40024 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -77,9 +77,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#ifdef __INTELC__
|
|
||||||
inline bool wxIsSameDouble(double x, double y)
|
#ifdef __INTELC__
|
||||||
{
|
|
||||||
|
inline bool wxIsSameDouble(double x, double y)
|
||||||
|
{
|
||||||
// VZ: this warning, given for operators==() and !=() is not wrong, as ==
|
// VZ: this warning, given for operators==() and !=() is not wrong, as ==
|
||||||
// shouldn't be used with doubles, but we get too many of them and
|
// shouldn't be used with doubles, but we get too many of them and
|
||||||
// removing these operators is probably not a good idea
|
// removing these operators is probably not a good idea
|
||||||
@@ -93,12 +95,28 @@ inline bool wxIsSameDouble(double x, double y)
|
|||||||
return x == y;
|
return x == y;
|
||||||
|
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
}
|
}
|
||||||
#else /* !__INTELC__ */
|
|
||||||
inline bool wxIsSameDouble(double x, double y) { return x == y; }
|
|
||||||
#endif /* __INTELC__/!__INTELC__ */
|
|
||||||
|
|
||||||
inline bool wxIsNullDouble(double x) { return wxIsSameDouble(x, 0.); }
|
#else /* !__INTELC__ */
|
||||||
|
|
||||||
|
inline bool wxIsSameDouble(double x, double y) { return x == y; }
|
||||||
|
|
||||||
|
#endif /* __INTELC__/!__INTELC__ */
|
||||||
|
|
||||||
|
inline bool wxIsNullDouble(double x) { return wxIsSameDouble(x, 0.); }
|
||||||
|
|
||||||
|
#ifdef __VMS
|
||||||
|
//Missing definition in OpenVMS C++ header files.
|
||||||
|
double round(double __x);
|
||||||
|
#endif
|
||||||
|
inline int wxRound(double x)
|
||||||
|
{
|
||||||
|
#ifdef __VMS
|
||||||
|
return int(round(x));
|
||||||
|
#else
|
||||||
|
return (int)(x < 0 ? x - 0.5 : x + 0.5);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
@@ -12,15 +12,11 @@
|
|||||||
|
|
||||||
#if wxUSE_SLIDER
|
#if wxUSE_SLIDER
|
||||||
|
|
||||||
#ifdef __VMS
|
|
||||||
//Missing definition in OpenVMS C++ header files.
|
|
||||||
double round(double __x);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/slider.h"
|
#include "wx/slider.h"
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
|
#include "wx/math.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/gtk/private.h"
|
#include "wx/gtk/private.h"
|
||||||
@@ -134,7 +130,7 @@ gtk_value_changed(GtkRange* range, wxSlider* win)
|
|||||||
if (g_blockEventsOnDrag) return;
|
if (g_blockEventsOnDrag) return;
|
||||||
|
|
||||||
GtkAdjustment* adj = range->adjustment;
|
GtkAdjustment* adj = range->adjustment;
|
||||||
const int pos = int(round(adj->value));
|
const int pos = wxRound(adj->value);
|
||||||
const double oldPos = win->m_pos;
|
const double oldPos = win->m_pos;
|
||||||
win->m_pos = adj->value;
|
win->m_pos = adj->value;
|
||||||
if (win->m_blockScrollEvent)
|
if (win->m_blockScrollEvent)
|
||||||
@@ -183,7 +179,7 @@ gtk_value_changed(GtkRange* range, wxSlider* win)
|
|||||||
win->m_scrollEventType = GTK_SCROLL_NONE;
|
win->m_scrollEventType = GTK_SCROLL_NONE;
|
||||||
|
|
||||||
// If integral position has changed
|
// If integral position has changed
|
||||||
if (int(round(oldPos)) != pos)
|
if (wxRound(oldPos) != pos)
|
||||||
{
|
{
|
||||||
wxCHECK_RET(eventType != wxEVT_NULL, _T("Unknown slider scroll event type"));
|
wxCHECK_RET(eventType != wxEVT_NULL, _T("Unknown slider scroll event type"));
|
||||||
ProcessScrollEvent(win, eventType);
|
ProcessScrollEvent(win, eventType);
|
||||||
@@ -270,7 +266,7 @@ extern "C" {
|
|||||||
static gchar* gtk_format_value(GtkScale*, double value, void*)
|
static gchar* gtk_format_value(GtkScale*, double value, void*)
|
||||||
{
|
{
|
||||||
// Format value as nearest integer
|
// Format value as nearest integer
|
||||||
return g_strdup_printf("%d", int(round(value)));
|
return g_strdup_printf("%d", wxRound(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,7 +336,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
int wxSlider::GetValue() const
|
int wxSlider::GetValue() const
|
||||||
{
|
{
|
||||||
return int(round(m_pos));
|
return wxRound(m_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSlider::SetValue( int value )
|
void wxSlider::SetValue( int value )
|
||||||
|
@@ -44,13 +44,6 @@ static inline bool AreSameAdjustValues(double x, double y)
|
|||||||
return fabs(x - y) < 0.02;
|
return fabs(x - y) < 0.02;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int AdjustValueToInt(double x)
|
|
||||||
{
|
|
||||||
// we want to round to the nearest integer, i.e. 0.9 is rounded to 1 and
|
|
||||||
// -0.9 is rounded to -1
|
|
||||||
return (int)(x < 0 ? x - 0.5 : x + 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
// process a scroll event
|
// process a scroll event
|
||||||
static void
|
static void
|
||||||
ProcessScrollEvent(wxSlider *win, wxEventType evtType, double dvalue)
|
ProcessScrollEvent(wxSlider *win, wxEventType evtType, double dvalue)
|
||||||
@@ -209,7 +202,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
int wxSlider::GetValue() const
|
int wxSlider::GetValue() const
|
||||||
{
|
{
|
||||||
return AdjustValueToInt(m_adjust->value);
|
return wxRound(m_adjust->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSlider::SetValue( int value )
|
void wxSlider::SetValue( int value )
|
||||||
|
@@ -22,7 +22,11 @@
|
|||||||
#undef XtClass
|
#undef XtClass
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "wx/gauge.h"
|
#include "wx/gauge.h"
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/math.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __OS2__
|
#ifdef __OS2__
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
@@ -673,8 +677,6 @@ GaugePick(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardi
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define round(x) ( (x) > 0 ? ((x) + 0.5) : -(-(x) + 0.5) )
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GaugeDrag(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardinal *WXUNUSED(num_args))
|
GaugeDrag(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardinal *WXUNUSED(num_args))
|
||||||
{
|
{
|
||||||
@@ -720,7 +722,7 @@ GaugeDrag(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardi
|
|||||||
|
|
||||||
fvalue = (int)((float)THIS.maximum -
|
fvalue = (int)((float)THIS.maximum -
|
||||||
(float)THIS.minimum) * (float)nsize / (float)max;
|
(float)THIS.minimum) * (float)nsize / (float)max;
|
||||||
value = round(fvalue);
|
value = wxRound(fvalue);
|
||||||
|
|
||||||
THIS.value = value;
|
THIS.value = value;
|
||||||
THIS.oldx = x;
|
THIS.oldx = x;
|
||||||
|
Reference in New Issue
Block a user