X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0d57be459406c2830f6abc9d99ae99166c6d133b..6433f6d3165a3f8633f42c59694a9104a7b37a93:/src/motif/slider.cpp diff --git a/src/motif/slider.cpp b/src/motif/slider.cpp index 20a1b07711..369cecc720 100644 --- a/src/motif/slider.cpp +++ b/src/motif/slider.cpp @@ -16,42 +16,49 @@ #include "wx/slider.h" #include "wx/utils.h" +#ifdef __VMS__ +#pragma message disable nosimpint +#endif #include #include #include #include #include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif -#include +#include "wx/motif/private.h" void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruct * cbs); -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl) BEGIN_EVENT_TABLE(wxSlider, wxControl) END_EVENT_TABLE() -#endif // Slider wxSlider::wxSlider() { - m_pageSize = 1; - m_lineSize = 1; - m_rangeMax = 0; - m_rangeMin = 0; - m_tickFreq = 0; + m_pageSize = 1; + m_lineSize = 1; + m_rangeMax = 0; + m_rangeMin = 0; + m_tickFreq = 0; } bool wxSlider::Create(wxWindow *parent, wxWindowID id, - int value, int minValue, int maxValue, - const wxPoint& pos, - const wxSize& size, long style, - const wxValidator& validator, - const wxString& name) -{ + int value, int minValue, int maxValue, + const wxPoint& pos, + const wxSize& size, long style, + const wxValidator& validator, + const wxString& name) +{ + if ( !((style & wxSL_HORIZONTAL) || (style & wxSL_VERTICAL)) ) + style |= wxSL_HORIZONTAL; + SetName(name); SetValidator(validator); m_backgroundColour = parent->GetBackgroundColour(); @@ -64,9 +71,9 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, m_tickFreq = 0; if ( id == -1 ) - m_windowId = (int)NewControlId(); + m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; m_rangeMax = maxValue; m_rangeMin = minValue; @@ -77,32 +84,42 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, Widget parentWidget = (Widget) parent->GetClientWidget(); Widget sliderWidget = XtVaCreateManagedWidget ("sliderWidget", - xmScaleWidgetClass, parentWidget, - XmNorientation, - (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmVERTICAL : XmHORIZONTAL), - XmNprocessingDirection, - (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmMAX_ON_TOP : XmMAX_ON_RIGHT), - XmNmaximum, maxValue, - XmNminimum, minValue, - XmNvalue, value, - XmNshowValue, True, - NULL); + xmScaleWidgetClass, parentWidget, + XmNorientation, + (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmVERTICAL : XmHORIZONTAL), + XmNprocessingDirection, + (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmMAX_ON_TOP : XmMAX_ON_RIGHT), + XmNmaximum, maxValue, + XmNminimum, minValue, + XmNvalue, value, + XmNshowValue, True, + NULL); m_mainWidget = (WXWidget) sliderWidget; +#ifdef __VMS__ +#pragma message disable codcauunr + // VMS gives here the compiler warning : + // statement either is unreachable or causes unreachable code +#endif if(style & wxSL_NOTIFY_DRAG) XtAddCallback (sliderWidget, XmNdragCallback, - (XtCallbackProc) wxSliderCallback, (XtPointer) this); + (XtCallbackProc) wxSliderCallback, (XtPointer) this); else XtAddCallback (sliderWidget, XmNvalueChangedCallback, - (XtCallbackProc) wxSliderCallback, (XtPointer) this); + (XtCallbackProc) wxSliderCallback, (XtPointer) this); +#ifdef __VMS__ +#pragma message enable codcauunr +#endif XtAddCallback (sliderWidget, XmNdragCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this); + m_font = parent->GetFont(); + + ChangeFont(FALSE); SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); - SetFont(* parent->GetFont()); ChangeBackgroundColour(); return TRUE; @@ -129,35 +146,35 @@ void wxSlider::GetSize(int *width, int *height) const wxControl::GetSize(width, height); } -void wxSlider::SetSize(int x, int y, int width, int height, int sizeFlags) +void wxSlider::DoSetSize(int x, int y, int width, int height, int sizeFlags) { - Widget widget = (Widget) m_mainWidget; + Widget widget = (Widget) m_mainWidget; - bool managed = XtIsManaged(widget); + bool managed = XtIsManaged(widget); - if (managed) - XtUnmanageChild (widget); + if (managed) + XtUnmanageChild (widget); - if (((m_windowStyle & wxHORIZONTAL) == wxHORIZONTAL) && (width > -1)) - { - XtVaSetValues (widget, XmNscaleWidth, wxMax (width, 10), NULL); - } + if (((m_windowStyle & wxHORIZONTAL) == wxHORIZONTAL) && (width > -1)) + { + XtVaSetValues (widget, XmNscaleWidth, wxMax (width, 10), NULL); + } - if (((m_windowStyle & wxVERTICAL) == wxVERTICAL) && (height > -1)) - { - XtVaSetValues (widget, XmNscaleHeight, wxMax (height, 10), NULL); - } + if (((m_windowStyle & wxVERTICAL) == wxVERTICAL) && (height > -1)) + { + XtVaSetValues (widget, XmNscaleHeight, wxMax (height, 10), NULL); + } - int xx = x; int yy = y; - AdjustForParentClientOrigin(xx, yy, sizeFlags); + int xx = x; int yy = y; + AdjustForParentClientOrigin(xx, yy, sizeFlags); - if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - XtVaSetValues (widget, XmNx, xx, NULL); - if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - XtVaSetValues (widget, XmNy, yy, NULL); + if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + XtVaSetValues (widget, XmNx, xx, NULL); + if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + XtVaSetValues (widget, XmNy, yy, NULL); - if (managed) - XtManageChild (widget); + if (managed) + XtManageChild (widget); } void wxSlider::SetRange(int minValue, int maxValue) @@ -169,7 +186,7 @@ void wxSlider::SetRange(int minValue, int maxValue) } // For trackbars only -void wxSlider::SetTickFreq(int n, int pos) +void wxSlider::SetTickFreq(int n, int WXUNUSED(pos)) { // Not implemented in Motif m_tickFreq = n; @@ -243,23 +260,23 @@ void wxSlider::SetTick(int WXUNUSED(tickPos)) void wxSlider::Command (wxCommandEvent & event) { - SetValue (event.GetInt()); - ProcessCommand (event); + SetValue (event.GetInt()); + ProcessCommand (event); } -void wxSlider::ChangeFont() +void wxSlider::ChangeFont(bool keepOriginalSize) { - // TODO + wxWindow::ChangeFont(keepOriginalSize); } void wxSlider::ChangeBackgroundColour() { - // TODO + wxWindow::ChangeBackgroundColour(); } void wxSlider::ChangeForegroundColour() { - // TODO + wxWindow::ChangeForegroundColour(); } void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruct * cbs) @@ -267,9 +284,9 @@ void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruc wxSlider *slider = (wxSlider *) clientData; switch (cbs->reason) { - case XmCR_VALUE_CHANGED: - case XmCR_DRAG: - default: + case XmCR_VALUE_CHANGED: + case XmCR_DRAG: + default: { // TODO: the XmCR_VALUE_CHANGED case should be handled // differently (it's not sent continually as the slider moves). @@ -279,6 +296,12 @@ void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruc XtVaGetValues (widget, XmNvalue, &event.m_commandInt, NULL); event.SetEventObject(slider); slider->ProcessCommand(event); + + // Also send a wxCommandEvent for compatibility. + wxCommandEvent event2(wxEVT_COMMAND_SLIDER_UPDATED, slider->GetId()); + event2.SetEventObject(slider); + event2.SetInt( event.GetInt() ); + slider->ProcessCommand(event2); break; } }