X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/47bc1060127d86222768789575295254a710f5a6..5d483828d77426eed11fa19c3f2f318383a118dc:/src/motif/scrolbar.cpp?ds=inline diff --git a/src/motif/scrolbar.cpp b/src/motif/scrolbar.cpp index 84fa92fe64..655353e458 100644 --- a/src/motif/scrolbar.cpp +++ b/src/motif/scrolbar.cpp @@ -6,7 +6,7 @@ // Created: 17/09/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -15,19 +15,23 @@ #include "wx/scrolbar.h" +#ifdef __VMS__ +#pragma message disable nosimpint +#endif #include #include #include #include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif -#include +#include "wx/motif/private.h" -void wxScrollBarCallback(Widget widget, XtPointer clientData, +static void wxScrollBarCallback(Widget widget, XtPointer clientData, XmScaleCallbackStruct *cbs); -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl) -#endif // Scrollbar bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, @@ -40,14 +44,16 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, return FALSE; parent->AddChild(this); SetName(name); - SetValidator(validator); - + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); + SetValidator(validator); + m_windowStyle = style; if ( id == -1 ) - m_windowId = (int)NewControlId(); + m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; int x = pos.x; int y = pos.y; @@ -79,8 +85,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, m_mainWidget = (Widget) scrollBarWidget; - // This will duplicate other events - // XtAddCallback(scrollBarWidget, XmNvalueChangedCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this); + XtAddCallback(scrollBarWidget, XmNvalueChangedCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this); XtAddCallback(scrollBarWidget, XmNdragCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this); XtAddCallback(scrollBarWidget, XmNdecrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this); XtAddCallback(scrollBarWidget, XmNincrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this); @@ -91,7 +96,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -100,7 +105,7 @@ wxScrollBar::~wxScrollBar() { } -void wxScrollBar::SetPosition(int pos) +void wxScrollBar::SetThumbPosition(int pos) { if (m_mainWidget) { @@ -110,7 +115,7 @@ void wxScrollBar::SetPosition(int pos) } } -int wxScrollBar::GetPosition() const +int wxScrollBar::GetThumbPosition() const { if (m_mainWidget) { @@ -124,7 +129,7 @@ int wxScrollBar::GetPosition() const } void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize, - bool refresh) + bool WXUNUSED(refresh)) { m_viewSize = pageSize; m_pageSize = thumbSize; @@ -146,16 +151,36 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS void wxScrollBar::Command(wxCommandEvent& event) { - SetPosition(event.m_commandInt); + SetThumbPosition(event.m_commandInt); ProcessCommand(event); } -void wxScrollBarCallback(Widget widget, XtPointer clientData, +void wxScrollBar::ChangeFont(bool WXUNUSED(keepOriginalSize)) +{ + // TODO + // Do anything for a scrollbar? A font will never be seen. +} + +void wxScrollBar::ChangeBackgroundColour() +{ + wxWindow::ChangeBackgroundColour(); + + XtVaSetValues ((Widget) GetMainWidget(), + XmNtroughColor, m_backgroundColour.AllocColour(XtDisplay((Widget) GetMainWidget())), + NULL); +} + +void wxScrollBar::ChangeForegroundColour() +{ + wxWindow::ChangeForegroundColour(); +} + +static void wxScrollBarCallback(Widget WXUNUSED(widget), XtPointer clientData, XmScaleCallbackStruct *cbs) { wxScrollBar *scrollBar = (wxScrollBar *)clientData; - wxEventType eventType = wxEVT_NULL; + switch (cbs->reason) { case XmCR_INCREMENT: @@ -175,9 +200,7 @@ void wxScrollBarCallback(Widget widget, XtPointer clientData, } case XmCR_VALUE_CHANGED: { - // TODO: Should this be intercepted too, or will it cause - // duplicate events? - eventType = wxEVT_SCROLL_THUMBTRACK; + eventType = wxEVT_SCROLL_THUMBRELEASE; break; } case XmCR_PAGE_INCREMENT: