Example #1
0
int SpectDisplay::ScrollToFrame(int frame, int centre)
{//===================================================
	int scrollx, scrolly;
	int x, y;
	int scrolled = 0;

	GetClientSize(&x,&y);
	GetViewStart(&scrollx,&scrolly);
	scrolly *= SCROLLUNITS;

	if(centre)
	{
		Scroll(-1, int(((frame+0.5)*FRAME_HEIGHT*zoomy - y/2) /SCROLLUNITS));
		return(1);
	}

	if(scrolly > frame * FRAME_HEIGHT * zoomy)
	{
		Scroll(-1, int((frame * FRAME_HEIGHT * zoomy) / SCROLLUNITS));
		scrolled = 1;
	}
	else
	{
		if(((frame+1) * FRAME_HEIGHT * zoomy) > (scrolly + y))
		{
			Scroll(-1, int(((frame+1)*FRAME_HEIGHT*zoomy - y) /SCROLLUNITS)+1);
			scrolled = 1;
		}
	}
	return(scrolled);
}  // end of SpectDisplay::ScrollToFrame
Example #2
0
void RXLCD_ScrollWindow_Prev(unsigned short x1,unsigned short y1 ,unsigned short x2 ,unsigned short y2, u8 Speed)
{
    u16 i=0;
    
    Scroll_Window(x1,x2,y1,y2);    
    if(g_u8LcdLayer==1)
    {
        Layer1_Visible();
        for(i= (x2-x1+2);i>0;i--) 
        {
            Scroll(i-1,0); 
            Delay2us(Speed*2000);
        }
        g_u8LcdLayer=0;
    }
    else if(g_u8LcdLayer==0)
    {
        Layer2_Visible();
        for(i= (x2-x1+2);i>0;i--) 
        {
            Scroll(i-1,0); 
            Delay2us(Speed*2000);
        }
        g_u8LcdLayer=1;
    }
}
Example #3
0
void RXLCD_ScrollWindow_Down(unsigned short x1,unsigned short y1 ,unsigned short x2 ,unsigned short y2,unsigned char Speed)
{
    u16 i=0;
    
    Scroll_Window(x1,x2,y1,y2);    
    if(g_u8LcdLayer==1)
    {
        Layer1_Visible();
        for(i= (y2-y1+2);i>0;i--) 
        {
            Scroll(0,i-1); 
            Delay2us(Speed*2000);
        }
        g_u8LcdLayer=0;
    }
    else if(g_u8LcdLayer==0)
    {
        Layer2_Visible();
        for(i= (y2-y1+2);i>0;i--) 
        {
            Scroll(0,i-1); 
            Delay2us(Speed*2000);
        }
        g_u8LcdLayer=1;
    }
}
bool wxBasePlayerGameListCtrl::OnDragOver(wxCoord x, wxCoord y, const Player&)
{
	// If they are within a few pixels from the top or bottom, scroll the
	// control.
	wxSize size = GetSize();

	wxInt32 range = GetScrollRange(wxVERTICAL);
	wxInt32 pos = GetScrollPos(wxVERTICAL);

	wxInt32 vX, vY;
	GetViewStart(&vX, &vY);

	if( (4 > y) && 
		(0 < pos))
	{
		Scroll(vX, --vY);
	}
	else if( (size.y - 8 <= y) &&
			 (range - 1 > pos))
	{
		Scroll(vX, ++vY);
	}
	else
	{
		wxInt32 index = HitTest(wxPoint(x, y));
		
		// Also clears the selection if they are not over anything.
		SetSelectedItem(index);
	}

	return true;
}
void wxListBox::DoEnsureVisible(int n)
{
    if ( !m_showScrollbarY )
    {
        // nothing to do - everything is shown anyhow
        return;
    }

    int first;
    GetViewStart(0, &first);
    if ( first > n )
    {
        // we need to scroll upwards, so make the current item appear on top
        // of the shown range
        Scroll(0, n);
    }
    else
    {
        int last = first + GetClientSize().y / GetLineHeight() - 1;
        if ( last < n )
        {
            // scroll down: the current item appears at the bottom of the
            // range
            Scroll(0, n - (last - first));
        }
    }
}
Example #6
0
void FieldBrowser::OnUpdate()
{
    auto size_of_one = SizeOfOneCell();
    SetVirtualSize(size_of_one.x, size_of_one.y * mDoc->GetNumSheets());

    SetScrollRate(0, size_of_one.y / 5);

    auto get_size = GetSize();
    auto scrolled_top = CalcUnscrolledPosition({ 0, 0 });
    auto scrolled_bottom = CalcUnscrolledPosition({ 0, get_size.y });

    // figure out what the view of cells would be.
    // let's print out where the current cell would be.
    //
    // if the upper part is above the view, move the view to contain it.
    if (size_of_one.y * mDoc->GetCurrentSheetNum() < scrolled_top.y) {
        Scroll(0, size_of_one.y * mDoc->GetCurrentSheetNum());
    }
    // if the lower part is below the view, move the view to contain it.
    if ((size_of_one.y * (mDoc->GetCurrentSheetNum() + 1)) > scrolled_bottom.y) {
        // we want to move to a place where the top amount we are over is the current top.
        auto how_much_we_are_over = (size_of_one.y * (mDoc->GetCurrentSheetNum() + 1)) - scrolled_bottom.y;
        Scroll(0, scrolled_top.y + how_much_we_are_over);
    }
}
Example #7
0
void CImageDisp::DisplayWithoutZoom(CDC *pDC)
{
    CRect client; GetClientRect(&client);

    m_ZoomX = m_ZoomY = 1.;
    m_Disp.SetRect(0, 0, min(m_pDib->Width(), client.Width()), min(m_pDib->Height(), client.Height()));

    if ((m_pDib->Width()>client.Width()) || (m_pDib->Height()>client.Height())) {
      CRect target;
      target.SetRect(0, 0, min(m_pDib->Width(), client.Width()), min(m_pDib->Height(), client.Height()));
      if (m_bCentering) {
        CPoint Scroll(0,0);
        if (client.Width()>m_pDib->Width()) Scroll.x = (client.Width()-m_pDib->Width())/2;
        if (client.Height()>m_pDib->Height()) Scroll.y = (client.Height()-m_pDib->Height())/2;
        target += Scroll;
      }
      m_Disp = target;

      CRect source;
      if (m_pDib->Height()>client.Height()) source.SetRect(0, m_pDib->Height()-client.Height(), min(m_pDib->Width(), client.Width()), m_pDib->Height());
      else source = target;
      m_pDib->LoadPaletteImage(pDC, &target, &source);
    }
    else {
      if (m_bCentering) {
        CPoint Scroll(0,0);
        Scroll.x = (client.Width()-m_pDib->Width())/2;
        Scroll.y = (client.Height()-m_pDib->Height())/2;
        m_Disp += Scroll;
        m_pDib->LoadPaletteImage(pDC, &m_Disp);
      }
      else m_pDib->LoadPaletteImage(pDC);
    }
}
Example #8
0
EVENT_RESULT CGUIBaseContainer::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
{
    if (event.m_id >= ACTION_MOUSE_LEFT_CLICK && event.m_id <= ACTION_MOUSE_DOUBLE_CLICK)
    {
        if (SelectItemFromPoint(point - CPoint(m_posX, m_posY)))
        {
            OnClick(event.m_id);
            return EVENT_RESULT_HANDLED;
        }
    }
    else if (event.m_id == ACTION_MOUSE_WHEEL_UP)
    {
        Scroll(-1);
        return EVENT_RESULT_HANDLED;
    }
    else if (event.m_id == ACTION_MOUSE_WHEEL_DOWN)
    {
        Scroll(1);
        return EVENT_RESULT_HANDLED;
    }
    else if (event.m_id == ACTION_GESTURE_NOTIFY)
    {
        return (m_orientation == HORIZONTAL) ? EVENT_RESULT_PAN_HORIZONTAL : EVENT_RESULT_PAN_VERTICAL;
    }
    else if (event.m_id == ACTION_GESTURE_BEGIN)
    {   // grab exclusive access
        CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, GetID(), GetParentID());
        SendWindowMessage(msg);
        return EVENT_RESULT_HANDLED;
    }
    else if (event.m_id == ACTION_GESTURE_PAN)
    {   // do the drag and validate our offset (corrects for end of scroll)
        m_scroller.SetValue(m_scroller.GetValue() - ((m_orientation == HORIZONTAL) ? event.m_offsetX : event.m_offsetY));
        float size = (m_layout) ? m_layout->Size(m_orientation) : 10.0f;
        int offset = (int)MathUtils::round_int(m_scroller.GetValue() / size);
        m_lastScrollStartTimer.Stop();
        m_scrollTimer.Start();
        SetOffset(offset);
        ValidateOffset();
        return EVENT_RESULT_HANDLED;
    }
    else if (event.m_id == ACTION_GESTURE_END)
    {   // release exclusive access
        CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, 0, GetParentID());
        SendWindowMessage(msg);
        m_scrollTimer.Stop();
        // and compute the nearest offset from this and scroll there
        float size = (m_layout) ? m_layout->Size(m_orientation) : 10.0f;
        float offset = m_scroller.GetValue() / size;
        int toOffset = (int)MathUtils::round_int(offset);
        if (toOffset < offset)
            SetOffset(toOffset+1);
        else
            SetOffset(toOffset-1);
        ScrollToOffset(toOffset);
        return EVENT_RESULT_HANDLED;
    }
    return EVENT_RESULT_UNHANDLED;
}
void CtrlRegisterList::ensureVisible(int index) {
	//scroll vertically to keep a logical position visible
	int x, y;
	GetViewStart(&x, &y);
	int visibleOffset = floor(float(GetClientSize().y) / rowHeight) - 1;
	if (index < y)
		Scroll(x, index);
	else if (index > y + visibleOffset)
		Scroll(x, index - visibleOffset);
}
Example #10
0
void CART2DImageViewer::wheelEvent(QWheelEvent *event){
	int numDegrees = event->delta() / 8;
	int numTicks = numDegrees / 15;

	if (event->orientation() == Qt::Horizontal){
		Scroll(1, 0);
	} else {
		Scroll(0, 1);
	}

	RefreshPixmap();
}
Example #11
0
void ctrlScrollBar::Msg_ButtonClick(const unsigned int ctrl_id)
{
    switch(ctrl_id)
    {
    case 0: // Upwards
        Scroll(-1);
        break;
    case 1: // Downwards
        Scroll(+1);
        break;
    }
}
Example #12
0
	bool ClientConsole::MouseWheelEvent( const struct MouseWheelEvent &ev ) {
		if ( !isVisible ) {
			return false;
		}

		if ( ev.up ) {
			Scroll( ev.amount );
		}
		else {
			Scroll ( ev.amount * -1 );
		}

		return true;
	}
Example #13
0
void
GraphCanvas::OnMotion(wxMouseEvent& evt)
{
	m_MouseX = evt.GetX() - m_BorderSize;
	m_MouseY = evt.GetY() - m_BorderSize;
	MouseToCanvas(m_MouseX, m_MouseY, &m_CanvasX, &m_CanvasY);
	if (evt.Dragging() && evt.LeftIsDown())
	{
		int dx = m_LeftX - m_MouseX;
		int dy = m_LeftY - m_MouseY;
		if (m_HasDragged || abs(dx) > 5 || abs(dy) > 5)
		{
			if (!m_HasDragged)
			{
				m_HasDragged = true;
				SetCursor(m_HandCursor);
			}
			m_LeftX = m_MouseX;
			m_LeftY = m_MouseY;
			int viewx, viewy;
			GetViewStart(&viewx, &viewy);
			Scroll(viewx + dx, viewy + dy);
		}
	}
	else
	{
		//SetCursor(*wxSTANDARD_CURSOR);
	}
	evt.Skip();
}
Example #14
0
void ctp2_TextBuffer::AddLine(MBCHAR *text, sint32 len, COLOR color)
{
	
	MBCHAR *lastLine = m_rowData[m_maxRows-1];
	memset(lastLine, 0, m_numDisplayedColumns);

	
	for (sint32 i=m_maxRows-1; i>0; i--) {
		m_rowData[i] = m_rowData[i-1];
	}

	
	m_rowData[0] = lastLine;

	if (m_numLines >= m_maxRows) {
		
	} else {
		
		m_numLines++;
	}

	if (len >= m_numDisplayedColumns)
		len = m_numDisplayedColumns - 1;

	memcpy(m_rowData[0], text, len);
	m_rowData[0][len] = '\0';

	
	if (m_topLine != (m_numDisplayedRows - 1)) {
		Redraw();
	} else {
		Scroll(1);
		DrawLine(0, color);
	}
}
Example #15
0
bool CGUITextBox::OnMessage(CGUIMessage& message)
{
  if (message.GetControlId() == GetID())
  {
    if (message.GetMessage() == GUI_MSG_LABEL_SET)
    {
      m_offset = 0;
      m_scrollOffset = 0;
      ResetAutoScrolling();
      CGUITextLayout::Reset();
      m_info.SetLabel(message.GetLabel(), "", GetParentID());
    }

    if (message.GetMessage() == GUI_MSG_LABEL_RESET)
    {
      m_offset = 0;
      m_scrollOffset = 0;
      ResetAutoScrolling();
      CGUITextLayout::Reset();
      UpdatePageControl();
      SetInvalid();
    }

    if (message.GetMessage() == GUI_MSG_PAGE_CHANGE)
    {
      if (message.GetSenderId() == m_pageControl)
      { // update our page
        Scroll(message.GetParam1());
        return true;
      }
    }
  }

  return CGUIControl::OnMessage(message);
}
Example #16
0
void HexView::ScrollToCaret()
{
	int x, y;
	int dx = 0, dy = 0;

	// first of all bring the view into view
	ScrollTo(m_nCursorOffset);

	if(m_nCursorOffset % m_nBytesPerLine != 0)
	{
		m_fCursorAdjustment = FALSE;
	}

	// now find cursor position
	CaretPosFromOffset(m_nCursorOffset, &x, &y);

	if(y < 0)
		dy = y;
	else if(y > m_nWindowLines - 1)
		dy = y - m_nWindowLines + 1;

	if(x < 0)
		dx = x;
	
	Scroll(dx, dy);

	CaretPosFromOffset(m_nCursorOffset, &x, &y);
	PositionCaret(x, y, m_nWhichPane);
}
Example #17
0
bool csBlobViewPort::Update (csTicks current)
{
  if (scroll_total_time > 0)
  {
    float dt = float (current-scroll_start_time);
    if (dt > scroll_total_time)
    {
      bool updated = Scroll (int (end_scrollx), int (end_scrolly));
      scroll_total_time = 0;
      return updated;
    }
    else
    {
      float factor = dt / scroll_total_time;
      float sx = start_scrollx + factor * (end_scrollx - start_scrollx);
      float sy = start_scrolly + factor * (end_scrolly - start_scrolly);
      int x = scrollx;
      int y = scrolly;
      scrollx = int (sx);
      scrolly = int (sy);
      return x != scrollx || y != scrolly;
    }
  }
  return false;
}
Example #18
0
void CD3DScrollBar::Update()
{
	if(m_Scrolling)
	{
		switch(m_ScrollStatus)
		{
		case SBSS_NONE:
			m_ScrollStartTime=CEasyTimer::GetTime();
			m_ScrollStatus=SBSS_READY;
			break;
		case SBSS_READY:
			if(CEasyTimer::GetTime()-m_ScrollStartTime>SCROLL_READY_TIME)
			{
				m_ScrollStatus=SBSS_SCROLLING;
				
			}
			break;
		case SBSS_SCROLLING:
			{
				DWORD time=CEasyTimer::GetTime();
				if(time-m_ScrollStartTime>SCROLL_TIME)
				{
					m_ScrollStartTime=time;
					Scroll(m_Scrolling,true);
				}
			}
			break;
		}
	}
}
Example #19
0
static void
endprompt(char flag)
{
    sc_hasprompt = 0;
    if (flag)
        Scroll();
}
Example #20
0
void BrushIconBox::EnsureVisible(BrushButton* btn)
{
	int windowSizeX, windowSizeY;
	GetVirtualSize(&windowSizeX, &windowSizeY);

	int scrollUnitX;
	int scrollUnitY;
	GetScrollPixelsPerUnit(&scrollUnitX, &scrollUnitY);

	wxRect rect = btn->GetRect();
	int y;
	CalcUnscrolledPosition(0, rect.y, nullptr, &y);

	int maxScrollPos = windowSizeY / scrollUnitY;
	int scrollPosY = std::min(maxScrollPos, (y / scrollUnitY));

	int startScrollPosY;
	GetViewStart(nullptr, &startScrollPosY);

	int clientSizeX, clientSizeY;
	GetClientSize(&clientSizeX, &clientSizeY);
	int endScrollPosY = startScrollPosY + clientSizeY / scrollUnitY;

	if(scrollPosY < startScrollPosY || scrollPosY > endScrollPosY){
		//only scroll if the button isnt visible
		Scroll(-1, scrollPosY);
	}
}
Example #21
0
	void Zoom(double zoomFactor)
	{
		if (zoomFactor < 0.05)
		{
			zoomFactor = 0.05;
		}
		if (zoomFactor > 5)
		{
			zoomFactor = 5;
		}
		m_zoomFactor = zoomFactor;

		wxRect currentImageRect = GetImageRect();

		wxSize clientSize = GetClientSize();
		int scrollX = currentImageRect.width + 10 > clientSize.x ?
			(currentImageRect.width - clientSize.x) : 0;
		int scrollY = currentImageRect.height + 10 > clientSize.y ?
			(currentImageRect.height - clientSize.y) : 0;

		SetVirtualSize(currentImageRect.width + 10, currentImageRect.height + 10);
		Scroll(scrollX / 2, scrollY / 2);

		Refresh();
	}
Example #22
0
// JumpTo /////////////////////////////////////////////////////////////////1.00
//		表示位置を変える。
	int
ClassABrowserView::JumpTo(long nLine)
{
	if (nLine < 0 || nLine > nLineViewMax)
		nLine = nLineViewMax;
	return Scroll(nLine - nLineView);
}
Example #23
0
// Scroll /////////////////////////////////////////////////////////////////2.00
//		スクロール専門の汎用メソッド。
//		スクロールバーは後でクラス化した方が良い。
//		それによりスクロール関数そのものは、単純な構造にしたい。
	int
ClassABrowserView::Scroll(int msg, unsigned short int nLine)
{
	LONG nScrollLine;

	switch(msg)
	{
		case SB_THUMBTRACK:
			return JumpTo((long)(nLine * dblScroll));
		case SB_LINEDOWN:
			nScrollLine =  1;
			break;
		case SB_LINEUP:
			nScrollLine = -1;
			break;
		case SB_PAGEDOWN:
			nScrollLine =  nLineViewPage;
			break;
		case SB_PAGEUP:
			nScrollLine	= -nLineViewPage;
			break;
		default:
			return 0;
	}

	return Scroll(nScrollLine);
}
Example #24
0
void CSHListCtrl::MakeColumnVisible(int nCol)
{
	if( nCol < 0 )
		return;
	// Get the order array to total the column offset.
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int colcount = pHeader->GetItemCount();
	ASSERT(nCol < colcount);
	int *orderarray = new int[colcount];
	Header_GetOrderArray(pHeader->m_hWnd, colcount, orderarray);
	// Get the column offset
	int offset = 0;
	for (int i = 0; orderarray[i] != nCol; i++)
		offset += GetColumnWidth(orderarray[i]);
	int colwidth = GetColumnWidth(nCol);
	delete[] orderarray;
	
	CRect rect;
	GetItemRect(0, &rect, LVIR_BOUNDS);
	
	// Now scroll if we need to expose the column
	CRect rcClient;
	GetClientRect(&rcClient);
	if (offset + rect.left < 0 || offset + colwidth + rect.left > rcClient.right)
	{
		CSize size;
		size.cx = offset + rect.left;
		size.cy = 0;
		Scroll(size);
		rect.left -= size.cx;
	}
}
Example #25
0
void PlayViewZone::moveView( int x,
                             int y )
{

  if ( x < 0 )
    Scroll( std::abs( x ),
            IMap::EAST );
  else if ( x > 0 ) Scroll( x,
                            IMap::WEST );

  if ( y < 0 )
    Scroll( std::abs( y ),
            IMap::SOUTH );
  else if ( y > 0 ) Scroll( y,
                            IMap::NORTH );

}
Example #26
0
void
ScrollZoomCanvas::ChangeOffset(wxPoint deltaOffset)
{
	mOffset += deltaOffset;
	Scroll(-mOffset);
	wxPoint start = GetViewStart();
	mOffset = -start - mOrigin;
}
Example #27
0
/*
 * Move to the beginning of the next line, scrolling
 * if necessary.
 */
static void Newline(void) {
    ++s_cons.row;
    s_cons.col = 0;
    if(s_cons.row == NUMROWS) {
        Scroll();
        s_cons.row = NUMROWS - 1;
    }
}
bool CGUIWrappingListContainer::OnAction(const CAction &action)
{
  switch (action.wID)
  {
  case ACTION_HOME:
    SelectItem(0);
    break;
  case ACTION_END:
    SelectItem(m_items.size()-1); 
    break;
  case ACTION_PAGE_UP:
    Scroll(-m_itemsPerPage);
    return true;
  case ACTION_PAGE_DOWN:
    Scroll(m_itemsPerPage);
    return true;
    // smooth scrolling (for analog controls)
  case ACTION_SCROLL_UP:
    {
      m_analogScrollCount += action.fAmount1 * action.fAmount1;
      bool handled = false;
      while (m_analogScrollCount > 0.4)
      {
        handled = true;
        m_analogScrollCount -= 0.4f;
        Scroll(-1);
      }
      return handled;
    }
    break;
  case ACTION_SCROLL_DOWN:
    {
      m_analogScrollCount += action.fAmount1 * action.fAmount1;
      bool handled = false;
      while (m_analogScrollCount > 0.4)
      {
        handled = true;
        m_analogScrollCount -= 0.4f;
        Scroll(1);
      }
      return handled;
    }
    break;
  }
  return CGUIBaseContainer::OnAction(action);
}
bool CGUIFixedListContainer::OnAction(const CAction &action)
{
  switch (action.GetID())
  {
  case ACTION_PAGE_UP:
    {
      Scroll(-m_itemsPerPage);
      return true;
    }
    break;
  case ACTION_PAGE_DOWN:
    {
      Scroll(m_itemsPerPage);
      return true;
    }
    break;
    // smooth scrolling (for analog controls)
  case ACTION_SCROLL_UP:
    {
      m_analogScrollCount += action.GetAmount() * action.GetAmount();
      bool handled = false;
      while (m_analogScrollCount > 0.4)
      {
        handled = true;
        m_analogScrollCount -= 0.4f;
        Scroll(-1);
      }
      return handled;
    }
    break;
  case ACTION_SCROLL_DOWN:
    {
      m_analogScrollCount += action.GetAmount() * action.GetAmount();
      bool handled = false;
      while (m_analogScrollCount > 0.4)
      {
        handled = true;
        m_analogScrollCount -= 0.4f;
        Scroll(1);
      }
      return handled;
    }
    break;
  }
  return CGUIBaseContainer::OnAction(action);
}
void CDragVirtualListCtrl::OnTimer(W64UINT nIDEvent) 
{
	if (nIDEvent == TIMER_ID) {
		if (m_ScrollDelta)
			Scroll(CSize(0, m_ScrollDelta));
	} else
		CListCtrl::OnTimer(nIDEvent);
}