Example #1
0
void tpanelscrollbar::OnScrollHandler(wxScrollEvent &event) {
	wxEventType type = event.GetEventType();
	bool upok = (type == wxEVT_SCROLL_TOP || type == wxEVT_SCROLL_LINEUP || type == wxEVT_SCROLL_PAGEUP || type == wxEVT_SCROLL_THUMBRELEASE || type == wxEVT_SCROLL_CHANGED);
	bool downok = (type == wxEVT_SCROLL_BOTTOM || type == wxEVT_SCROLL_LINEDOWN || type == wxEVT_SCROLL_PAGEDOWN || type == wxEVT_SCROLL_THUMBRELEASE || type == wxEVT_SCROLL_CHANGED);

	int y;
	if (type == wxEVT_SCROLL_LINEUP || type == wxEVT_SCROLL_LINEDOWN) {
		y = GetThumbPosition();
		if (type == wxEVT_SCROLL_LINEUP) {
			y -= gc.linescrollspeed;
		} else {
			y += gc.linescrollspeed;
		}
		SetThumbPosition(std::max(0, y));
		ScrollItems();
	} else {
		if (type == wxEVT_SCROLLWIN_THUMBRELEASE || type == wxEVT_SCROLL_CHANGED) {
			y = event.GetPosition();
			SetThumbPosition(y);
		} else {
			y = GetThumbPosition();
		}
		ScrollItemsForPosition(y);
		event.Skip();
	}

	OnScrollHandlerCommon(upok, downok, 0, y);
}
Example #2
0
void wxScrollBar::SetScrollbar(int position, int thumbSize,
                               int range, int pageSize,
                               bool refresh)
{
    // we only refresh everything when the range changes, thumb position
    // changes are handled in OnIdle
    bool needsRefresh = (range != m_range) ||
                        (thumbSize != m_thumbSize) ||
                        (pageSize != m_pageSize);

    // set all parameters
    m_range = range;
    m_thumbSize = thumbSize;
    SetThumbPosition(position);
    m_pageSize = pageSize;

    // ignore refresh parameter unless we really need to refresh everything -
    // there ir a lot of existing code which just calls SetScrollbar() without
    // specifying the last parameter even though it doesn't need at all to
    // refresh the window immediately
    if ( refresh && needsRefresh )
    {
        // and update the window
        Refresh();
        Update();
    }
}
void CTripleLinkageOpt::CalcThumbPosition()
{
    for (UINT i = 0; i < m_szThumb.size(); i++)
    {
        SetThumbPosition(i, m_szThumb[i]->GetPosition());
    }
}
void CMultiThumbOpt::CalcThumbPosition()
{
	for (UINT i = 0; i < m_szThumb.size(); i++)
	{
		SetThumbPosition(i, m_szThumb[i]->GetPosition());		
	}
}
Example #5
0
void tpanelscrollbar::OnScrollTrack(wxScrollEvent &event) {
	#if TPANEL_SCROLLING_COPIOUS_LOGGING
		LogMsgFormat(LOGT::TPANELTRACE, "TSCL: tpanelscrollbar::OnScrollTrack %s, %d", cstr(GetThisName()), event.GetPosition());
	#endif
	int y = event.GetPosition();
	ScrollItemsForPosition(y);
	SetThumbPosition(y);
	event.Skip();
}
Example #6
0
wxInt32 wxScrollBar::MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF mevent ) 
{
    int position = m_peer->GetValue() ;
    int minPos = m_peer->GetMinimum() ;
    int maxPos = m_peer->GetMaximum() ;
    
    wxEventType scrollEvent = wxEVT_NULL;
    int nScrollInc = 0;
    
    wxMacCarbonEvent cEvent( (EventRef) mevent ) ;
    ControlPartCode controlpart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart,typeControlPartCode) ;
    
    // all events have already been reported during mouse down, except for THUMBRELEASE
    if ( controlpart !=kControlIndicatorPart )
        return eventNotHandledErr ;
    
    switch( controlpart )
    {
    case kControlIndicatorPart :
        nScrollInc = 0 ;
        scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
        break ;
    default :
        wxFAIL_MSG(wxT("illegal scrollbar selector"));
        break ;
    }
    
    int new_pos = position + nScrollInc;
    
    if (new_pos < minPos)
        new_pos = minPos;
    if (new_pos > maxPos)
        new_pos = maxPos;
    if ( nScrollInc )
        SetThumbPosition(new_pos);
    
    wxScrollEvent event(scrollEvent, m_windowId);
    if ( m_windowStyle & wxHORIZONTAL )
    {
        event.SetOrientation( wxHORIZONTAL ) ;
    }
    else
    {
        event.SetOrientation( wxVERTICAL ) ;
    }
    event.SetPosition(new_pos);
    event.SetEventObject( this );
    wxWindow* window = GetParent() ;
    if (window && window->MacIsWindowScrollbar(this) )
    {
        // this is hardcoded
        window->MacOnScroll(event);
    }
    else
        GetEventHandler()->ProcessEvent(event);
    return noErr ;
}
void wxHugeScrollBar::SetScrollbar( int64_t Current_Position,int page_x, int64_t new_range, int pagesize, bool repaint ){
	m_range = new_range;
	if(new_range <= 2147483647){//if representable with 32 bit
		m_scrollbar->SetScrollbar( Current_Position, page_x, new_range, pagesize, repaint );
		}
	else{
#ifdef _DEBUG_SCROLL_
		std::cout << "new_range " << new_range << std::endl;
		std::cout << "Current_Position :" << (Current_Position*(2147483647/new_range)) << std::endl;
#endif
		m_scrollbar->SetScrollbar( (Current_Position*(2147483647/new_range)), page_x, 2147483647, pagesize, repaint );
		}
	SetThumbPosition( Current_Position );
	}
Example #8
0
void wxScrollBar::TriggerScrollEvent( wxEventType scrollEvent )
{
    int position = GetPeer()->GetValue();
    int minPos = 0 ;
    int maxPos = GetPeer()->GetMaximum();
    int nScrollInc = 0;

    if ( scrollEvent == wxEVT_SCROLL_LINEUP )
    {
        nScrollInc = -1;
    }
    else if ( scrollEvent == wxEVT_SCROLL_LINEDOWN )
    {
        nScrollInc = 1;
    }
    else if ( scrollEvent == wxEVT_SCROLL_PAGEUP )
    {
        nScrollInc = -m_pageSize;
    }
    else if ( scrollEvent == wxEVT_SCROLL_PAGEDOWN )
    {
        nScrollInc = m_pageSize;
    }

    int new_pos = position + nScrollInc;

    if (new_pos < minPos)
        new_pos = minPos;
    else if (new_pos > maxPos)
        new_pos = maxPos;

    if ( nScrollInc )
        SetThumbPosition( new_pos );

    wxScrollEvent event( scrollEvent, m_windowId );
    if ( m_windowStyle & wxHORIZONTAL )
        event.SetOrientation( wxHORIZONTAL );
    else
        event.SetOrientation( wxVERTICAL );

    event.SetPosition( new_pos );
    event.SetEventObject( this );

    wxWindow* window = GetParent();
    if (window && window->MacIsWindowScrollbar( this ))
        // this is hardcoded
        window->MacOnScroll( event );
    else
        HandleWindowEvent( event );
}
Example #9
0
void tpanelscrollbar::mousewheelhandler(wxMouseEvent &event) {
	int pxdelta = -event.GetWheelRotation() * gc.mousewheelscrollspeed / event.GetWheelDelta();

	#if TPANEL_SCROLLING_COPIOUS_LOGGING
		LogMsgFormat(LOGT::TPANELTRACE, "TSCL: tpanelscrollbar::mousewheelhandler %s, %d %d %d", cstr(GetThisName()),
				GetScrollPos(wxVERTICAL), event.GetWheelRotation(), pxdelta);
	#endif

	int y = GetThumbPosition();
	SetThumbPosition(std::max(0, y + pxdelta));
	ScrollItems();

	// Use gc.mousewheelscrollspeed as the threshold, this is to try and make mousewheel scrolling smooth across pages
	OnScrollHandlerCommon(pxdelta < 0, pxdelta > 0, std::abs(gc.mousewheelscrollspeed), GetScrollPos(wxVERTICAL));
}
Example #10
0
void tpanelscrollbar::ScrollToIndex(unsigned int index, int offset) {
	int scroll_offset = 0;

	for (auto &disp : parent->GetCurrentDisp()) {
		if (index == 0) {
			SetThumbPosition(scroll_offset - offset);
			ScrollItems();
			return;
		} else {
			index--;
		}

		wxSize s = disp.item->GetSize();
		scroll_offset += s.y;
	}
}
Example #11
0
void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize, bool)
{
    if (range == 0)
    {
        // GtkRange requires upper > lower
        range =
        thumbSize = 1;
    }
    if (position > range - thumbSize)
        position = range - thumbSize;
    if (position < 0)
        position = 0;
    GtkAdjustment* adj = ((GtkRange*)m_widget)->adjustment;
    adj->step_increment = 1;
    adj->page_increment = pageSize;
    adj->page_size = thumbSize;
    adj->upper = range;
    SetThumbPosition(position);
    gtk_adjustment_changed(adj);
}
Example #12
0
void wxScrollBar::Command( wxCommandEvent& event )
{
    SetThumbPosition( event.GetInt() );
    ProcessCommand( event );
}
Example #13
0
bool wxScrollBar::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam,
                              WXWORD WXUNUSED(pos), WXHWND WXUNUSED(control))
{
    // don't use pos parameter because it is limited to 16 bits, get the full
    // 32 bit position from the control itself instead
    WinStruct<SCROLLINFO> scrollInfo;
    scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_TRACKPOS;

    if ( !::GetScrollInfo(GetHwnd(), SB_CTL, &scrollInfo) )
    {
        wxLogLastError(wxT("GetScrollInfo"));
        return false;
    }

    int maxPos = scrollInfo.nMax;

    // A page size greater than one has the effect of reducing the effective
    // range, therefore the range has already been boosted artificially - so
    // reduce it again.
    if ( m_pageSize > 1 )
        maxPos -= (m_pageSize - 1);

    int position = scrollInfo.nPos;
    wxEventType scrollEvent = wxEVT_NULL;
    switch ( wParam )
    {
        case SB_TOP:
            position = 0;
            scrollEvent = wxEVT_SCROLL_TOP;
            break;

        case SB_BOTTOM:
            position = maxPos;
            scrollEvent = wxEVT_SCROLL_BOTTOM;
            break;

        case SB_LINEUP:
            position--;
            scrollEvent = wxEVT_SCROLL_LINEUP;
            break;

        case SB_LINEDOWN:
            position++;
            scrollEvent = wxEVT_SCROLL_LINEDOWN;
            break;

        case SB_PAGEUP:
            position -= GetPageSize();
            scrollEvent = wxEVT_SCROLL_PAGEUP;
            break;

        case SB_PAGEDOWN:
            position += GetPageSize();
            scrollEvent = wxEVT_SCROLL_PAGEDOWN;
            break;

        case SB_THUMBPOSITION:
        case SB_THUMBTRACK:
            position = scrollInfo.nTrackPos;
            scrollEvent = wParam == SB_THUMBPOSITION ? wxEVT_SCROLL_THUMBRELEASE
                                                     : wxEVT_SCROLL_THUMBTRACK;
            break;

        case SB_ENDSCROLL:
            scrollEvent = wxEVT_SCROLL_CHANGED;
            break;
    }

    if ( position != scrollInfo.nPos )
    {
        if ( position < 0 )
            position = 0;
        if ( position > maxPos )
            position = maxPos;

        SetThumbPosition(position);
    }
    else if ( scrollEvent != wxEVT_SCROLL_THUMBRELEASE &&
                scrollEvent != wxEVT_SCROLL_CHANGED )
    {
        // don't process the event if there is no displacement,
        // unless this is a thumb release or end scroll event.
        return false;
    }

    wxScrollEvent event(scrollEvent, m_windowId);
    event.SetOrientation(IsVertical() ? wxVERTICAL : wxHORIZONTAL);
    event.SetPosition(position);
    event.SetEventObject( this );

    return HandleWindowEvent(event);
}
Example #14
0
void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) 
{
    int position = m_peer->GetValue() ;
    int minPos = m_peer->GetMinimum() ;
    int maxPos = m_peer->GetMaximum() ;
    
    wxEventType scrollEvent = wxEVT_NULL;
    int nScrollInc = 0;
    
    // all events have already been reported during mouse down, except for THUMBRELEASE
    if ( !mouseStillDown && controlpart !=kControlIndicatorPart )
        return ;
    
    switch( controlpart )
    {
    case kControlUpButtonPart :
        nScrollInc = -1;
        scrollEvent = wxEVT_SCROLL_LINEUP;
        break ;
    case kControlDownButtonPart :
        nScrollInc = 1;
        scrollEvent = wxEVT_SCROLL_LINEDOWN;
        break ;
    case kControlPageUpPart :
        nScrollInc = -m_pageSize;
        scrollEvent = wxEVT_SCROLL_PAGEUP;
        break ;
    case kControlPageDownPart :
        nScrollInc = m_pageSize;
        scrollEvent = wxEVT_SCROLL_PAGEDOWN;
        break ;
    case kControlIndicatorPart :
        nScrollInc = 0 ;
        if ( mouseStillDown )
            scrollEvent = wxEVT_SCROLL_THUMBTRACK;
        else
            scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
        break ;
    default :
        wxFAIL_MSG(wxT("illegal scrollbar selector"));
        break ;
    }
    
    int new_pos = position + nScrollInc;
    
    if (new_pos < minPos)
        new_pos = minPos;
    if (new_pos > maxPos)
        new_pos = maxPos;
    if ( nScrollInc )
        SetThumbPosition(new_pos);
    
    wxScrollEvent event(scrollEvent, m_windowId);
    if ( m_windowStyle & wxHORIZONTAL )
    {
        event.SetOrientation( wxHORIZONTAL ) ;
    }
    else
    {
        event.SetOrientation( wxVERTICAL ) ;
    }
    event.SetPosition(new_pos);
    event.SetEventObject( this );
    wxWindow* window = GetParent() ;
    if (window && window->MacIsWindowScrollbar(this) )
    {
        // this is hardcoded
        window->MacOnScroll(event);
    }
    else
        GetEventHandler()->ProcessEvent(event);
}
Example #15
0
void BigScrollBar::SetBigThumbPosition(gg_tl_dat position)
{
	int sbPosition = (int) ( (position*SCROLLBAR_LENGTH)/m_BigRange );
	SetThumbPosition(sbPosition);
}