Example #1
0
		/*=============================================================================
		-- Updates the ScrollBar.
		=============================================================================*/
		void ScrollBar::_Update()
		{
			double oldScrollPosition = GetScrollPosition();

			//update the scroll position
			int knobLength = (mSpanDirection == SpanDirection::HORIZONTAL) ? mKnobButton.lock()->GetWidth() : mKnobButton.lock()->GetHeight();
			int knobMin = SCROLL_BAR_BUTTON_SIZE;
			int knobMax = ((mSpanDirection == SpanDirection::HORIZONTAL) ? GetWidth() : GetHeight()) - SCROLL_BAR_BUTTON_SIZE - knobLength;
			int innerRange = knobMax - knobMin;

			Vector2D<int> knobRelPos = mKnobButton.lock()->GetRelPos();
			int knobOffset = ((mSpanDirection == SpanDirection::HORIZONTAL) ? knobRelPos.x : knobRelPos.y) - SCROLL_BAR_BUTTON_SIZE;

			mScrollPosition = DivideD((double)knobOffset,(double)innerRange);

			//check if either increase/decrease button were pressed
			if (mAdjustTimer.GetTimeAndEnd() > SCROLL_BAR_ADJUST_DELAY)
			{
				if (mButtonDecrease.lock()->GetState() == State::DOWN)
					SetScrollPosition(GetScrollPosition() + 0.01);
				else if (mButtonIncrease.lock()->GetState() == State::DOWN)
					SetScrollPosition(GetScrollPosition() - 0.01);

				mAdjustTimer.Start();
			}

			if (GetScrollPosition() != oldScrollPosition)
				_SendElementMessageToListeners(ElementEvent::VALUE_CHANGED);
		}
void CChannelRulerCtrl::UpdateZoom(int Height)
{
	double	NominalZoom = CChannelBar::GetNominalZoom();
	// manipulate height to match view as precisely as possible
	SetScrollPosition((Height - 1) / NominalZoom - m_Origin * Height);
	SetZoom(NominalZoom / (Height - 1) / m_Amplitude);
}
Example #3
0
/*============================================================================*/
        void WScrollBars::
Serialize(CArchive &ar)                                               /*

        Serialize or deserialize the toolbars to and  from the archive ar,
	depending on the sense of IsStoring(). 
*-----------------------------------------------------------------------------*/
{
	  // perform loading or storing
        if (ar.IsStoring())
        {
                  // save scrollbars state
  		ar << m_hscroll_visible;
		ar << m_vscroll_visible;
		ar << m_increments;
		ar << m_limits;
		ar << m_scroll_position;
	}
        else
        {
                  // recover toolbars parameters:
  		ar >> m_hscroll_visible;
		ar >> m_vscroll_visible;
		ar >> m_increments;
		ar >> m_limits;
		ar >> m_scroll_position;
		SetScrollPosition(m_scroll_position);
      	}
}
Example #4
0
/*============================================================================*/
        LRESULT WScrollBars::
OnMouseWheel(WPARAM wParam, LPARAM lParam)        			/*

        Processes mouse wheel rotation when made in the focus window having
	a vertical scrollbar.  LOWORD(wParam) contains the key flags,
	HIWORD(wParam) gives the (signed) wheel rotation, GET_X_LPARAM(lParam)
	is the horizontal position of the pointer, and  GET_Y_LPARAM(lParam)
	is the vertical position of pointer.  The flags and  position parameters
	are unused here.  The incoming rotation parameter will be a multiple
	of the WHEEL_DELTA value, which is set at 120. Each such unit here
	scrolls one virtical increment. The function returns 0.
*-----------------------------------------------------------------------------*/
{
	UNREFERENCED_PARAMETER(lParam);

	if (!m_vscroll_visible)
		return 0;

	  // set the new position: first get (signed) rotation units
	int wheelunits = (int)(short)HIWORD(wParam),
	  // convert to line increments, maintaining sign
	rotation = ::MulDiv(-wheelunits, m_increments.m_v_line, WHEEL_DELTA);
	m_scroll_position.y += rotation;
	SetScrollPosition(m_scroll_position);
	return 0;
}
Example #5
0
fresult TextField::ScrollDown()
{
	Position pos;
	pos.data = _ScrollPositionTx.data;
	pos.Top++;
	return SetScrollPosition(pos);
}
Example #6
0
float UIScrollBarHandle::Move(float distance)
{
	float alignmentPre = alignmentY;
    alignmentY += distance;
	SetScrollPosition(alignmentY);
	float moved = alignmentY - alignmentPre;
	return moved;
}
Example #7
0
fresult TextField::ScrollUp()
{
	Position pos;
	pos.data = _ScrollPositionTx.data;
	if (pos.Top!=0)
	{
		pos.Top--;
	}
	return SetScrollPosition(pos);
}
Example #8
0
    void RemoveItemByIdx(int iItem)
    {
        int numRemoved = 0;

        if (iItem != -1) {
            // find the first matching item

            while (iItem > 1 && m_vItems[iItem-1] == m_vItems[iItem]) {
                iItem--;
            }

            // now remove all the matching items

            TRef<ListItem> pListItem = m_vItems[iItem];
            while (iItem < m_vItems.GetCount() && m_vItems[iItem] == pListItem) {
                m_vItems.Remove(iItem);
                numRemoved++;
            }
                
            if (iItem <= m_iSelItem) {
                SetSelItemByIdx(m_iSelItem - numRemoved);
            } else {
                SetSelItemByIdx(m_iSelItem);
            }

            if (m_pScrollPane) {
                // save the old top item, because shrinking the scroll pane could change it
                int iOldTopItem = m_iTopItem;

                m_pScrollPane->SetSize(m_vItems.GetCount());
                
                if (iItem < iOldTopItem) {
                    SetScrollPosition(max(iOldTopItem - numRemoved, 0));
                } else {
                    SetScrollPosition(min(iOldTopItem, 
                        max(m_vItems.GetCount() - m_cVisibleItems, 0)));
                }
            }
            NeedPaint();
        }
    }
Example #9
0
void wxMacDataBrowserListControl::ListScrollTo( unsigned int n )
{
    UInt32 top , left ;
    GetScrollPosition( &top , &left ) ;
    wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );

    // there is a bug in RevealItem that leads to situations
    // in large lists, where the item does not get scrolled
    // into sight, so we do a pre-scroll if necessary
    UInt16 height ;
    GetRowHeight( (DataBrowserItemID) item , &height ) ;
    UInt32 linetop = n * ((UInt32) height );
    UInt32 linebottom = linetop + height;
    Rect rect ;
    GetControlBounds( m_controlRef, &rect );

    if ( linetop < top || linebottom > (top + rect.bottom - rect.top ) )
        SetScrollPosition( wxMax( n-2, 0 ) * ((UInt32)height) , left ) ;

    RevealItem( item , kDataBrowserRevealWithoutSelecting );
}
Example #10
0
void UIList::ScrollToElement(int32 index)
{
    DVASSERT(delegate)
    DVASSERT(0<=index && index<delegate->ElementsCount(this))
    float32 newScrollPos = 0.0f;
    if(orientation == ORIENTATION_HORIZONTAL)
	{
        for(int32 i=0; i<index; ++i)
        {
            newScrollPos += delegate->CellWidth(this,i);
        }
	}
	else 
	{
        for(int32 i=0; i<index; ++i)
        {
            newScrollPos += delegate->CellHeight(this,i);
        }
	}
    SetScrollPosition(newScrollPos);
}
Example #11
0
/*============================================================================*/
        LRESULT WScrollBars::
OnHScroll(WPARAM wParam, LPARAM lParam)      	 			/*

        Processes horizontal scrolling requests. The scroll code is given in
	LOWORD(wParam).  HIWORD(wParam) specifies the current position of
	the scroll box if the scroll code is SB_THUMBPOSITION or SB_THUMBTRACK;
	but here it is not used. The lParam is the handle to the scroll bar
	control if the message was sent by the scroll bar; otherwise, it is
	NULL. Thererfore, since we have messages coming from the keyboard
	as well as the scrollbar, only the scroll code is used here. The
	function returns 0.
*-----------------------------------------------------------------------------*/
{
	UNREFERENCED_PARAMETER(lParam);
	if (!m_hscroll_visible)
		return 0;

	if (!m_theView)
		return 0;

	  // respond to the scroll event:
	UINT nPos = m_scroll_position.x;
	  // need horizontal scroll bar position and thumb track position
	SCROLLINFO si;
	si.cbSize = sizeof (si);
	si.fMask  = SIF_ALL;
	m_theView->GetScrollInfo(SB_HORZ, si);
	switch (LOWORD(wParam)) // scroll command
	{
	    case SB_LEFT:		//   Scroll to far left.
		nPos = m_limits.m_h_min;
		break;

	    case SB_RIGHT:		//   Scroll to far right.
		nPos = m_limits.m_h_max;
		break;

	    case SB_LINELEFT:           // scroll left one column-unit
		nPos -= m_increments.m_h_line;
		break;

	    case SB_LINERIGHT:           // scroll right one column-unit
		nPos += m_increments.m_h_line;
		break;

	    case SB_PAGELEFT:           // scroll left one column-page-unit
		nPos -= m_increments.m_h_page;
		break;

	    case SB_PAGERIGHT:           // scroll right one column-page-unit
		nPos += m_increments.m_h_page;
		break;

	    case SB_THUMBTRACK:		// h-thumb is moving
	    case SB_THUMBPOSITION:      // or has stopped
		nPos = si.nTrackPos; // was HIWORD(wParam);
		break;

	    default:	// the rest are immaterial
		break;
	}
 	  // Reset new horizontal scroll position (automatically puts
	  // m_state.nPos within the specified limits).
	m_scroll_position.x = nPos;
	SetScrollPosition(m_scroll_position);
	return 0;
}
Example #12
0
// Return: false if deleted
bool CItem::StartRefresh() 
{
	ASSERT(GetType() != IT_FREESPACE);
	ASSERT(GetType() != IT_UNKNOWN);

	m_ticksWorked = 0;

	// Special case IT_MYCOMPUTER
	if (GetType() == IT_MYCOMPUTER)
	{
		ZeroMemory(&m_lastChange, sizeof(m_lastChange));

		for (int i=0; i < GetChildrenCount(); i++)
			GetChild(i)->StartRefresh();

		return true;
	}
	ASSERT(GetType() == IT_FILE || GetType() == IT_DRIVE || GetType() == IT_DIRECTORY || GetType() == IT_FILESFOLDER);

	bool wasExpanded = IsVisible() && IsExpanded();
	int oldScrollPosition = 0;
	if (IsVisible())
		oldScrollPosition = GetScrollPosition();

	UncacheImage();

	// Upward clear data
	UpdateLastChange();

	UpwardSetUndone();

	UpwardAddReadJobs(-GetReadJobs());
	ASSERT(GetReadJobs() == 0);

	if (GetType() == IT_FILE)
		GetParent()->UpwardAddFiles(-1);
	else
		UpwardAddFiles(-GetFilesCount());
	ASSERT(GetFilesCount() == 0);

	if (GetType() == IT_DIRECTORY || GetType() == IT_DRIVE)
		UpwardAddSubdirs(-GetSubdirsCount());
	ASSERT(GetSubdirsCount() == 0);

	UpwardAddSize(-GetSize());
	ASSERT(GetSize() == 0);

	RemoveAllChildren();
	UpwardRecalcLastChange();

	// Special case IT_FILESFOLDER
	if (GetType() == IT_FILESFOLDER)
	{
		CFileFindWDS finder;
		BOOL b = finder.FindFile(GetFindPattern());
		while (b)
		{
			b = finder.FindNextFile();
			if (finder.IsDirectory())
				continue;

			FILEINFO fi;
			fi.name = finder.GetFileName();
			fi.attributes = finder.GetAttributes();
			// Retrieve file size
			fi.length = finder.GetCompressedLength();
			finder.GetLastWriteTime(&fi.lastWriteTime);

			AddFile(fi);
			UpwardAddFiles(1);
		}
		SetDone();

		if (wasExpanded)
			GetTreeListControl()->ExpandItem(this);
		return true;
	}
	ASSERT(GetType() == IT_FILE || GetType() == IT_DRIVE || GetType() == IT_DIRECTORY);

	// The item may have been deleted.
	bool deleted = false;
	if (GetType() == IT_DRIVE)
		deleted = !DriveExists(GetPath());
	else if (GetType() == IT_FILE)
		deleted = !FileExists(GetPath());
	else if (GetType() == IT_DIRECTORY)
		deleted = !FolderExists(GetPath());

	if (deleted)
	{
		if (GetParent() == NULL)
		{
			GetDocument()->UnlinkRoot();
		}
		else
		{
			GetParent()->UpwardRecalcLastChange();
			GetParent()->RemoveChild(GetParent()->FindChildIndex(this)); // --> delete this
		}
		return false;
	}

	// Case IT_FILE
	if (GetType() == IT_FILE)
	{
		CFileFindWDS finder;
		BOOL b = finder.FindFile(GetPath());
		if (b)
		{
			finder.FindNextFile();
			if (!finder.IsDirectory())
			{
				FILEINFO fi;
				fi.name = finder.GetFileName();
				fi.attributes = finder.GetAttributes();
				// Retrieve file size
				fi.length = finder.GetCompressedLength();
				finder.GetLastWriteTime(&fi.lastWriteTime);

				SetLastChange(fi.lastWriteTime);

				UpwardAddSize(fi.length);
				UpwardUpdateLastChange(GetLastChange());
				GetParent()->UpwardAddFiles(1);
			}
		}
		SetDone();
		return true;
	}

	ASSERT(GetType() == IT_DRIVE || GetType() == IT_DIRECTORY);

	if (GetType() == IT_DIRECTORY && !IsRootItem() && GetApp()->IsMountPoint(GetPath()) && !GetOptions()->IsFollowMountPoints())
		return true;

	if (GetType() == IT_DIRECTORY && !IsRootItem() && GetApp()->IsJunctionPoint(GetPath()) && !GetOptions()->IsFollowJunctionPoints())
		return true;

	// Initiate re-read
	SetReadJobDone(false);

	// Re-create <free space> and <unknown>
	if (GetType() == IT_DRIVE)
	{
		if (GetDocument()->OptionShowFreeSpace())
			CreateFreeSpaceItem();
		if (GetDocument()->OptionShowUnknown())
			CreateUnknownItem();
	}

	DoSomeWork(0);

	if (wasExpanded)
		GetTreeListControl()->ExpandItem(this);

	if (IsVisible())
		SetScrollPosition(oldScrollPosition);

	return true;
}
Example #13
0
 void ScrollBottom()
 {
     SetScrollPosition(m_vItems.GetCount() - m_cVisibleItems);
 }
Example #14
0
 void ScrollTop()
 {
     SetScrollPosition(0);
 }
Example #15
0
 void ScrollPageDown()
 {
     SetScrollPosition(m_iTopItem + m_cVisibleItems);
 }
Example #16
0
 void ScrollPageUp()
 {
     SetScrollPosition(m_iTopItem - m_cVisibleItems);
 }
Example #17
0
void wxMacDataItemBrowserControl::RemoveAllItems(wxMacDataItem *container)
{
    SetScrollPosition(0, 0);
    OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, 0 , NULL , kDataBrowserItemNoProperty );
    verify_noerr( err );
}
Example #18
0
/*============================================================================*/
        LRESULT WScrollBars::
OnVScroll(WPARAM wParam, LPARAM lParam)        				/*

        This function processes vertical scrolling requests. The scroll code
	is given in LOWORD(wParam). HIWORD(wParam) specifies the current
	scroll box if the scroll code is SB_THUMBPOSITION or SB_THUMBTRACK;
	but here it is not used. lParam is the handle to the scroll bar
	control if the message was sent by the scroll bar; otherwise,
	it is NULL. Thererfore, since we have messages coming from the
	keyboard as well as the scrollbar, only the scroll code is used here.
	The function returns 0.
*-----------------------------------------------------------------------------*/
{
	UNREFERENCED_PARAMETER(lParam);

	if (!m_vscroll_visible)
		return 0;

	  // respond to the scroll event:
	UINT nPos = m_scroll_position.y;
	  // need THE thumb track position
	SCROLLINFO si;
	si.cbSize = sizeof (si);
	si.fMask  = SIF_ALL;
	m_theView->GetScrollInfo(SB_VERT, si);
	switch (LOWORD(wParam))  // the scroll code
	{
	    case SB_TOP:                // top of scroll
		nPos = m_limits.m_v_min;
		break;

	    case SB_BOTTOM:             // bottom of scroll
		nPos = m_limits.m_v_max;
		break;

	    case SB_LINEUP:             // up one line-unit
		nPos -= m_increments.m_v_line;
		break;

	    case SB_LINEDOWN:           // down one line-unit
		nPos += m_increments.m_v_line;
		break;

	    case SB_PAGEUP:             // up one page-unit
		nPos -= m_increments.m_v_page;
		break;

	    case SB_PAGEDOWN:           // down one page-unit
		nPos += m_increments.m_v_page;
		break;

	    case SB_THUMBTRACK:         // the thumb is moving
	    case SB_THUMBPOSITION:      // or has stopped
		nPos = si.nTrackPos; // was HIWORD(wParam);
		break;

	    default:
		break;
	}
	  // Reset new vertical scroll position (automatically puts
	  // nPos within the specified limits).
	m_scroll_position.y = nPos;
	SetScrollPosition(m_scroll_position);
	return 0;
}