+ if( m_timer )
+ {
+ m_timer->Stop();
+ m_timer->Reset();
+ }
+ else
+ m_timer = new wxArrowButtonTimer( this, m_increment );
+
+ return m_timer;
+}
+
+void wxArrowButton::SpinButtonCallback( Widget w, XtPointer clientData,
+ XtPointer WXUNUSED(ptr) )
+{
+ if( !wxGetWindowFromTable( w ) )
+ // Widget has been deleted!
+ return;
+
+ wxArrowButton* btn = (wxArrowButton*)clientData;
+
+ btn->GetSpinButton()->Increment( btn->m_increment );
+}
+
+void wxArrowButton::StartTimerCallback( Widget w, XtPointer clientData,
+ XtPointer WXUNUSED(ptr) )
+{
+ if( !wxGetWindowFromTable( w ) )
+ // Widget has been deleted!
+ return;
+
+ wxArrowButton* btn = (wxArrowButton*)clientData;
+ btn->GetFreshTimer()->Start( TICK_INTERVAL );
+}
+
+void wxArrowButton::StopTimerCallback( Widget w, XtPointer clientData,
+ XtPointer WXUNUSED(ptr) )
+{
+ if( !wxGetWindowFromTable( w ) )
+ // Widget has been deleted!
+ return;
+
+ wxArrowButton* btn = (wxArrowButton*)clientData;
+ delete btn->m_timer;
+ btn->m_timer = 0;
+}
+
+bool wxArrowButton::Create( wxSpinButton* parent, wxWindowID id,
+ ArrowDirection d,
+ const wxPoint& pos, const wxSize& size )
+{
+ int arrow_dir = XmARROW_UP;
+
+ switch( d )
+ {
+ case wxARROW_UP:
+ arrow_dir = XmARROW_UP;
+ break;
+ case wxARROW_DOWN:
+ arrow_dir = XmARROW_DOWN;
+ break;
+ case wxARROW_LEFT:
+ arrow_dir = XmARROW_LEFT;
+ break;
+ case wxARROW_RIGHT:
+ arrow_dir = XmARROW_RIGHT;
+ break;
+ }
+
+ if( parent ) parent->AddChild( this );
+
+ Widget parentWidget = (Widget) parent->GetClientWidget();
+ m_mainWidget = (WXWidget) XtVaCreateManagedWidget( "XmArrowButton",
+ xmArrowButtonWidgetClass,
+ parentWidget,
+ XmNarrowDirection, arrow_dir,
+ XmNborderWidth, 0,
+ XmNshadowThickness, 0,
+ NULL );
+
+ XtAddCallback( (Widget) m_mainWidget,
+ XmNactivateCallback, (XtCallbackProc) SpinButtonCallback,
+ (XtPointer) this );
+ XtAddCallback( (Widget) m_mainWidget,
+ XmNarmCallback, (XtCallbackProc) StartTimerCallback,
+ (XtPointer) this );
+ XtAddCallback( (Widget) m_mainWidget,
+ XmNactivateCallback, (XtCallbackProc) StopTimerCallback,
+ (XtPointer) this );
+
+ AttachWidget( parent, m_mainWidget, (WXWidget) NULL,
+ pos.x, pos.y, size.x, size.y );