X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6380910c1fcd57f06c82d3d0d3c796a5af9f3ac7..2b2edbedb47a54bea26df1bede371bf761e3a233:/src/gtk/spinbutt.cpp diff --git a/src/gtk/spinbutt.cpp b/src/gtk/spinbutt.cpp index 044f6270e3..66f5af6bc3 100644 --- a/src/gtk/spinbutt.cpp +++ b/src/gtk/spinbutt.cpp @@ -13,12 +13,22 @@ #endif #include "wx/spinbutt.h" + +#ifdef wxUSE_SPINBTN + #include "wx/utils.h" #include #include "gdk/gdk.h" #include "gtk/gtk.h" +//----------------------------------------------------------------------------- +// idle system +//----------------------------------------------------------------------------- + +extern void wxapp_install_idle_handler(); +extern bool g_isIdle; + //----------------------------------------------------------------------------- // data //----------------------------------------------------------------------------- @@ -33,7 +43,9 @@ static const float sensitivity = 0.2; static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *win ) { - if (!win->HasVMT()) return; + if (g_isIdle) wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return; if (g_blockEventsOnDrag) return; float diff = win->m_adjust->value - win->m_oldPos; @@ -51,7 +63,7 @@ static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *wi else if (fabs(diff+page_step) < sensitivity) command = wxEVT_SCROLL_PAGEUP; else command = wxEVT_SCROLL_THUMBTRACK; - int value = ceil(win->m_adjust->value); + int value = (int)ceil(win->m_adjust->value); wxSpinEvent event( command, win->GetId()); event.SetPosition( value ); @@ -81,7 +93,7 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c m_needParent = TRUE; wxSize new_size = size; - new_size.x = 16; + new_size.x = 15; if (new_size.y == -1) new_size.y = 30; @@ -102,9 +114,7 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c (GtkSignalFunc) gtk_spinbutt_callback, (gpointer) this ); - m_parent->AddChild( this ); - - (m_parent->m_insertCallback)( m_parent, this ); + m_parent->DoAddChild( this ); PostCreation(); @@ -121,28 +131,28 @@ wxSpinButton::~wxSpinButton() int wxSpinButton::GetMin() const { - wxCHECK_MSG( (m_widget != NULL), 0, "invalid spin button" ); + wxCHECK_MSG( (m_widget != NULL), 0, _T("invalid spin button") ); - return ceil(m_adjust->lower); + return (int)ceil(m_adjust->lower); } int wxSpinButton::GetMax() const { - wxCHECK_MSG( (m_widget != NULL), 0, "invalid spin button" ); + wxCHECK_MSG( (m_widget != NULL), 0, _T("invalid spin button") ); - return ceil(m_adjust->upper); + return (int)ceil(m_adjust->upper); } int wxSpinButton::GetValue() const { - wxCHECK_MSG( (m_widget != NULL), 0, "invalid spin button" ); + wxCHECK_MSG( (m_widget != NULL), 0, _T("invalid spin button") ); - return ceil(m_adjust->value); + return (int)ceil(m_adjust->value); } void wxSpinButton::SetValue( int value ) { - wxCHECK_RET( (m_widget != NULL), "invalid spin button" ); + wxCHECK_RET( (m_widget != NULL), _T("invalid spin button") ); float fpos = (float)value; m_oldPos = fpos; @@ -155,7 +165,7 @@ void wxSpinButton::SetValue( int value ) void wxSpinButton::SetRange(int minVal, int maxVal) { - wxCHECK_RET( (m_widget != NULL), "invalid spin button" ); + wxCHECK_RET( (m_widget != NULL), _T("invalid spin button") ); float fmin = (float)minVal; float fmax = (float)maxVal; @@ -174,9 +184,9 @@ void wxSpinButton::SetRange(int minVal, int maxVal) void wxSpinButton::OnSize( wxSizeEvent &WXUNUSED(event) ) { - wxCHECK_RET( (m_widget != NULL), "invalid spin button" ); + wxCHECK_RET( (m_widget != NULL), _T("invalid spin button") ); - m_width = 16; + m_width = 15; gtk_widget_set_usize( m_widget, m_width, m_height ); } @@ -202,4 +212,4 @@ wxSpinEvent::wxSpinEvent(wxEventType commandType, int id): { } - +#endif \ No newline at end of file