added generation of wxEVT_SCROLL_XXX (patch 1424698)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37470 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -202,6 +202,10 @@ wxWinCE:
|
|||||||
is reccommended that you use wxMEDIABACKEND_WMP10 on this platform
|
is reccommended that you use wxMEDIABACKEND_WMP10 on this platform
|
||||||
directly, however.
|
directly, however.
|
||||||
|
|
||||||
|
wxUniv:
|
||||||
|
|
||||||
|
- Send wxEVT_SCROLL_XXX events from wxSlider (Danny Raynor)
|
||||||
|
|
||||||
wxX11:
|
wxX11:
|
||||||
|
|
||||||
- Invisible text problem fixed.
|
- Invisible text problem fixed.
|
||||||
|
@@ -180,7 +180,8 @@ bool wxSlider::ChangeValueBy(int inc)
|
|||||||
bool wxSlider::ChangeValueTo(int value)
|
bool wxSlider::ChangeValueTo(int value)
|
||||||
{
|
{
|
||||||
// check if the value is going to change at all
|
// check if the value is going to change at all
|
||||||
if (value == m_value) return false;
|
if (value == m_value)
|
||||||
|
return false;
|
||||||
|
|
||||||
// this method is protected and we should only call it with normalized
|
// this method is protected and we should only call it with normalized
|
||||||
// value!
|
// value!
|
||||||
@@ -190,11 +191,15 @@ bool wxSlider::ChangeValueTo(int value)
|
|||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
|
|
||||||
// generate the event
|
// generate the events: both a specific scroll event and a command event
|
||||||
|
wxScrollEvent eventScroll(wxEVT_SCROLL_CHANGED, GetId());
|
||||||
|
eventScroll.SetPosition(m_value);
|
||||||
|
eventScroll.SetEventObject( this );
|
||||||
|
(void)GetEventHandler()->ProcessEvent(eventScroll);
|
||||||
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_SLIDER_UPDATED, GetId());
|
wxCommandEvent event(wxEVT_COMMAND_SLIDER_UPDATED, GetId());
|
||||||
event.SetInt(m_value);
|
event.SetInt(m_value);
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
|
|
||||||
(void)GetEventHandler()->ProcessEvent(event);
|
(void)GetEventHandler()->ProcessEvent(event);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -739,49 +744,80 @@ bool wxSlider::PerformAction(const wxControlAction& action,
|
|||||||
long numArg,
|
long numArg,
|
||||||
const wxString& strArg)
|
const wxString& strArg)
|
||||||
{
|
{
|
||||||
|
wxEventType scrollEvent = wxEVT_NULL;
|
||||||
|
int value;
|
||||||
|
bool valueChanged = true;
|
||||||
|
|
||||||
if ( action == wxACTION_SLIDER_START )
|
if ( action == wxACTION_SLIDER_START )
|
||||||
{
|
{
|
||||||
ChangeValueTo(m_min);
|
scrollEvent = wxEVT_SCROLL_TOP;
|
||||||
|
value = m_min;
|
||||||
}
|
}
|
||||||
else if ( action == wxACTION_SLIDER_END )
|
else if ( action == wxACTION_SLIDER_END )
|
||||||
{
|
{
|
||||||
ChangeValueTo(m_max);
|
scrollEvent = wxEVT_SCROLL_BOTTOM;
|
||||||
|
value = m_max;
|
||||||
}
|
}
|
||||||
else if ( action == wxACTION_SLIDER_PAGE_CHANGE )
|
else if ( action == wxACTION_SLIDER_PAGE_CHANGE )
|
||||||
{
|
{
|
||||||
ChangeValueBy(numArg * GetPageSize());
|
value = NormalizeValue(m_value + numArg * GetPageSize());
|
||||||
}
|
}
|
||||||
else if ( action == wxACTION_SLIDER_LINE_UP )
|
else if ( action == wxACTION_SLIDER_LINE_UP )
|
||||||
{
|
{
|
||||||
ChangeValueBy(+GetLineSize());
|
scrollEvent = wxEVT_SCROLL_LINEUP;
|
||||||
|
value = NormalizeValue(m_value + +GetLineSize());
|
||||||
}
|
}
|
||||||
else if ( action == wxACTION_SLIDER_LINE_DOWN )
|
else if ( action == wxACTION_SLIDER_LINE_DOWN )
|
||||||
{
|
{
|
||||||
ChangeValueBy(-GetLineSize());
|
scrollEvent = wxEVT_SCROLL_LINEDOWN;
|
||||||
|
value = NormalizeValue(m_value + -GetLineSize());
|
||||||
}
|
}
|
||||||
else if ( action == wxACTION_SLIDER_PAGE_UP )
|
else if ( action == wxACTION_SLIDER_PAGE_UP )
|
||||||
{
|
{
|
||||||
ChangeValueBy(+GetPageSize());
|
scrollEvent = wxEVT_SCROLL_PAGEUP;
|
||||||
|
value = NormalizeValue(m_value + +GetPageSize());
|
||||||
}
|
}
|
||||||
else if ( action == wxACTION_SLIDER_PAGE_DOWN )
|
else if ( action == wxACTION_SLIDER_PAGE_DOWN )
|
||||||
{
|
{
|
||||||
ChangeValueBy(-GetPageSize());
|
scrollEvent = wxEVT_SCROLL_PAGEDOWN;
|
||||||
|
value = NormalizeValue(m_value + -GetPageSize());
|
||||||
}
|
}
|
||||||
else if ( action == wxACTION_SLIDER_THUMB_DRAG )
|
else if ( action == wxACTION_SLIDER_THUMB_DRAG ||
|
||||||
|
action == wxACTION_SLIDER_THUMB_MOVE )
|
||||||
{
|
{
|
||||||
// no special processing for it
|
scrollEvent = wxEVT_SCROLL_THUMBTRACK;
|
||||||
return true;
|
|
||||||
|
// we shouldn't generate a command event about this change but we still
|
||||||
|
// should update our value and the slider appearance
|
||||||
|
valueChanged = false;
|
||||||
|
m_value =
|
||||||
|
value = (int)numArg;
|
||||||
|
Refresh();
|
||||||
}
|
}
|
||||||
else if ( action == wxACTION_SLIDER_THUMB_MOVE ||
|
else if ( action == wxACTION_SLIDER_THUMB_RELEASE )
|
||||||
action == wxACTION_SLIDER_THUMB_RELEASE )
|
|
||||||
{
|
{
|
||||||
ChangeValueTo((int)numArg);
|
scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
|
||||||
|
value = (int)numArg;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return wxControl::PerformAction(action, numArg, strArg);
|
return wxControl::PerformAction(action, numArg, strArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update wxSlider current value and generate wxCommandEvent, except while
|
||||||
|
// dragging the thumb
|
||||||
|
if ( valueChanged )
|
||||||
|
ChangeValueTo(value);
|
||||||
|
|
||||||
|
// also generate more precise wxScrollEvent if applicable
|
||||||
|
if ( scrollEvent != wxEVT_NULL )
|
||||||
|
{
|
||||||
|
wxScrollEvent event(scrollEvent, GetId());
|
||||||
|
event.SetPosition(value);
|
||||||
|
event.SetEventObject( this );
|
||||||
|
GetEventHandler()->ProcessEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user