Пример #1
0
void ME_EnsureVisible(ME_TextEditor *editor, ME_DisplayItem *pRun)
{
  ME_DisplayItem *pRow = ME_FindItemBack(pRun, diStartRow);
  ME_DisplayItem *pPara = ME_FindItemBack(pRun, diParagraph);
  int y, yrel, yheight, yold;
  HWND hWnd = editor->hWnd;
  
  assert(pRow);
  assert(pPara);
  
  y = pPara->member.para.nYPos+pRow->member.row.nYPos;
  yheight = pRow->member.row.nHeight;
  yold = ME_GetYScrollPos(editor);
  yrel = y - yold;
  if (yrel < 0) {
    editor->nScrollPosY = y;
    SetScrollPos(hWnd, SB_VERT, y, TRUE);
    if (editor->bRedraw)
    {
      ScrollWindow(hWnd, 0, -yrel, NULL, NULL);
      UpdateWindow(hWnd);
    }
  } else if (yrel + yheight > editor->sizeWindow.cy) {
    int newy = y+yheight-editor->sizeWindow.cy;
    editor->nScrollPosY = newy;
    SetScrollPos(hWnd, SB_VERT, newy, TRUE);
    if (editor->bRedraw)
    {
      ScrollWindow(hWnd, 0, -(newy-yold), NULL, NULL);
      UpdateWindow(hWnd);
    }
  }
}
Пример #2
0
// WM_VSCROLL
BOOL Window::VScroll(TMSG &Msg)
{
if (!(Flags & W_SCROLLBARS)) return TRUE;

int nScrollCode = LOWORD(Msg.wParam);   /* scroll bar value     */
int nPos = LLHW(Msg);   /* scroll box position  */

long newPos=yPos;
switch (nScrollCode) {
	case SB_LINEUP:
		newPos-=yStep; break;
	case SB_PAGEUP:
		newPos-=yPageSize; break;
	case SB_LINEDOWN:
		newPos+=yStep; break;
	case SB_PAGEDOWN:
		newPos+=yPageSize; break;
	case SB_THUMBTRACK:
	case SB_THUMBPOSITION:
		newPos=(long) nPos; break;
	case SB_BOTTOM:
		newPos=yMax; break;
	case SB_TOP:
		newPos=0; break;
	case SB_ENDSCROLL:
		break;
	}
#ifdef WIN32
	if (newPos != yPos)
	{
		if (StatBar) StatBar->Invalidate();
		SCROLLINFO si;
		si.cbSize=sizeof(si);
		si.fMask=SIF_POS;
		si.nPos=newPos;
		SetScrollInfo(hWnd,SB_VERT,&si,TRUE);
		GetScrollInfo(hWnd,SB_VERT,&si);

		ScrollWindow(hWnd, 0, yPos-si.nPos , NULL, NULL);
		yPos=si.nPos;
		UpdateWindow(hWnd);
	}

#else
	RECT rc;
	GetClientRect(hWnd,&rc);
	if (StatBar) rc.bottom-=StatBar->dyStatbar;
	if ( (newPos = max( min( newPos, yMax-rc.bottom ), 0L)) != yPos)
	{
		if (StatBar) StatBar->Invalidate();
		ScrollWindow(hWnd, 0, (int) (yPos-newPos) , NULL, NULL);
		SetScrollPos(hWnd, SB_VERT, (int) newPos, TRUE);
		yPos=newPos;
		UpdateWindow(hWnd);
	}
#endif

return TRUE;
}
Пример #3
0
BOOL  Window::HScroll(TMSG &Msg)
{
if (!(Flags & W_SCROLLBARS)) return TRUE;

int nScrollCode = LOWORD(Msg.wParam);   /* scroll bar value     */
int nPos = LLHW(Msg);   /* scroll box position  */

long newPos=xPos;
switch (nScrollCode) {
	case SB_LINELEFT:
		newPos-=xStep; break;
	case SB_PAGELEFT:
		newPos-=xPageSize; break; // page??
	case SB_LINERIGHT:
		newPos+=xStep; break;
	case SB_PAGERIGHT:
		newPos+=xPageSize; break;
	case SB_THUMBTRACK:
	case SB_THUMBPOSITION:
		newPos=(long) nPos; break;
	case SB_LEFT:
		newPos=0; break;
	case SB_RIGHT:
		newPos=xMax; break;
	case SB_ENDSCROLL:
		break;
	}

#ifdef WIN32
	if (newPos != xPos)
	{
		if (StatBar) StatBar->Invalidate();
		SCROLLINFO si;
		si.cbSize=sizeof(si);
		si.fMask=SIF_POS;
		si.nPos=newPos;
		SetScrollInfo(hWnd,SB_HORZ,&si,TRUE);
		GetScrollInfo(hWnd,SB_HORZ,&si);

		ScrollWindow(hWnd, xPos-si.nPos ,0, NULL, NULL);
		xPos=si.nPos;
		UpdateWindow(hWnd);
	}
#else

	RECT rc;
	GetClientRect(hWnd,&rc);
	if ( (newPos = max( min( newPos , xMax-rc.right ), 0L)) !=xPos)
	{
		if (StatBar) StatBar->Invalidate();
		ScrollWindow(hWnd, (int) (xPos-newPos), 0 , NULL, NULL);
		SetScrollPos(hWnd, SB_HORZ, (int) newPos, TRUE);
		xPos=newPos;
		UpdateWindow(hWnd);
	}
#endif

return TRUE;
}
Пример #4
0
void CListSide::Scroll(/*HWND hWnd, */int nMore)
{
	if (false == m_bScrollEnabled) return;

	int add, scrollpos = GetScrollPos(m_hWnd, SB_VERT);

	int actual = scrollpos + nMore;
	if (actual < 0) 
	{
		ScrollTo(0);
		return;
	}
	if (actual > m_dMaxScroll - m_dPage + 1)
	{
		ScrollTo(m_dMaxScroll - m_dPage + 1);
		return;
	}
	
	SetScrollPos(m_hWnd, SB_VERT, actual, 1);
	m_dScrollPos = actual;
	add = nMore;

	RECT client;
	GetClientRect(m_hWnd, &client);

	ScrollWindow(m_hWnd, 0, -add, NULL, &client);
}
Пример #5
0
static Void local setOffset_Classes(HWND hWnd, INT x, INT y)
{
  Node n;
  INT dx, dy;

  x  = clamp(-cBrowse.width, 0,x);
  y  = clamp(-cBrowse.height,0,y);
  dx = x - cBrowse.XOffset;
  dy = y - cBrowse.YOffset;

  for (n=0; n<LastNode; n++) {
    Nodes[n].Pos.left   += dx;
    Nodes[n].Pos.right  += dx;
    Nodes[n].Pos.top    += dy;
    Nodes[n].Pos.bottom += dy;
  }

  cBrowse.XOffset = x;
  cBrowse.YOffset = y;
  SetScrollPos(hWnd, SB_HORZ, -x, TRUE);
  SetScrollPos(hWnd, SB_VERT, -y, TRUE);

  ScrollWindow(hWnd, dx, dy, NULL, NULL);
  InvalidateRect(hWnd,NULL,TRUE);
  UpdateWindow(hWnd);
}
Пример #6
0
//设置视图桌子
bool __cdecl CTableFrame::EnsureVisibleTable(WORD wTableID)
{
	//效验参数
	ASSERT(wTableID<m_wTableCount);
	if (wTableID>=m_wTableCount) return false;

	//计算位置
	int iLastPos=m_iCurrentPos;
	int iXPos=(wTableID%m_iCountRow)*m_TableResource.m_wWidth+m_iXExcursion;
	int iYPos=(wTableID/m_iCountRow)*m_TableResource.m_wHeight-m_iCurrentPos;

	//构造位置
	CRect rcTable,rcClient;
	GetClientRect(&rcClient);
	rcTable.SetRect(iXPos,iYPos,iXPos+m_TableResource.m_wWidth,iYPos+m_TableResource.m_wHeight);
	if ((rcTable.bottom>rcClient.bottom)||(rcTable.top<0)) m_iCurrentPos+=rcTable.bottom-rcClient.bottom;
	m_iCurrentPos=__max(0,__min(m_iCurrentPos,m_iMaxScrollPos-m_iCountVisibleLine*m_TableResource.m_wHeight));

	//滚动视图
	if (iLastPos!=m_iCurrentPos)
	{
		SetScrollPos(SB_VERT,m_iCurrentPos);
		ScrollWindow(0,iLastPos-m_iCurrentPos,NULL,NULL);
	}

	return true;
}
Пример #7
0
void CAnimMixer::processScroll(sInt cursorX, sBool scrollDirect)
{
	sInt oldStartPixel = m_startPixel;

	if (scrollDirect)
		m_startPixel = fr::maximum(0, m_startPixel + cursorX);
	else
	{
		sInt scrollDelta = m_scrlPoint.x - cursorX;
		if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
			scrollDelta *= 8;

		m_startPixel = fr::maximum(0, m_startPixel + scrollDelta);
		m_scrlPoint.x = cursorX;
	}

  RECT rc;
  GetClientRect(&rc);
	rc.top = 24; // where the buttons end

  ScrollWindow(oldStartPixel - m_startPixel, 0, &rc, &rc);
	m_timeBarPos += oldStartPixel - m_startPixel;

  UpdateWindow();
}
Пример #8
0
LRESULT CWindow::OnMouseWheel(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    INT16 iScroll = HIWORD(wParam);
    SCROLLINFO si;

    si.cbSize = sizeof(si);
    si.fMask  = SIF_ALL;
    GetScrollInfo(hWnd, SB_VERT, &si);
    si.nPos -= iScroll / (INT16)WHEEL_DELTA * 3;
    if (si.nPos < 0)
    {
        si.nPos = 0;
    }
    si.fMask = SIF_POS;
    SetScrollInfo(hWnd, SB_VERT, &si, True);

    if (iVScrollPos != si.nPos)
    {
        ScrollWindow(hWnd, 0, cyChar * (iVScrollPos - si.nPos), NULL, NULL);
        iVScrollPos = si.nPos;
        UpdateWindow(hWnd);
    }

    return ERROR_SUCCESS;
}
Пример #9
0
/* Bring Cursor into text window */
void
text_to_cursor(TW *tw)
{
int nXinc=0;
int nYinc=0;
int cxCursor;
int cyCursor;
        cyCursor = tw->CursorPos.y * tw->CharSize.y;
        if ( (cyCursor + tw->CharSize.y > tw->ScrollPos.y + tw->ClientSize.y)
/*	  || (cyCursor < tw->ScrollPos.y) ) { */
/* change to scroll to end of window instead of just making visible */
/* so that ALL of error message can be seen */
          || (cyCursor < tw->ScrollPos.y+tw->ClientSize.y) ) {
                nYinc = max(0, cyCursor + tw->CharSize.y
                        - tw->ClientSize.y) - tw->ScrollPos.y;
                nYinc = min(nYinc, tw->ScrollMax.y - tw->ScrollPos.y);
        }
        cxCursor = tw->CursorPos.x * tw->CharSize.x;
        if ( (cxCursor + tw->CharSize.x > tw->ScrollPos.x + tw->ClientSize.x)
          || (cxCursor < tw->ScrollPos.x) ) {
                nXinc = max(0, cxCursor + tw->CharSize.x
                        - tw->ClientSize.x/2) - tw->ScrollPos.x;
                nXinc = min(nXinc, tw->ScrollMax.x - tw->ScrollPos.x);
        }
        if (nYinc || nXinc) {
                tw->ScrollPos.y += nYinc;
                tw->ScrollPos.x += nXinc;
                ScrollWindow(tw->hwnd,-nXinc,-nYinc,NULL,NULL);
                UpdateScrollBarX(tw);
                UpdateScrollBarY(tw);
                UpdateWindow(tw->hwnd);
        }
}
Пример #10
0
BOOL CZhfPalette::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	int curpos = GetScrollPos(SB_VERT);
	int minpos = 0;
	int maxpos = 0;
	GetScrollRange(SB_VERT, &minpos, &maxpos); 
	maxpos = GetScrollLimit(SB_VERT);

	if (zDelta<0)
	{
		if (curpos < maxpos)
			curpos++;
	}
	else 
	{
		if (curpos > minpos)
			curpos-- ;
	}
	SetScrollPos(SB_VERT, curpos);
	ScrollWindow(0, (m_iOldPosY-curpos)*(m_iCtrlHeight+m_iMarginY));

	m_iOldPosY = curpos;

	return CAdUiPalette::OnMouseWheel(nFlags, zDelta, pt);
}
Пример #11
0
static void DoScroll( HWND wnd, int dx, int dy, BOOL lock )
/*********************************************************/
{
    /* scroll 'wnd' by 'dx' and 'dy'. 'lock' says to lock the scrolling on the */
    /* bottom and right into the scrolling rectangle */
    POINT   offset;
    RECT    srect;

    GetOffset( &offset );
    GetScrollBounds( &srect, lock );

    dx = AdjustScroll( offset.x, srect.left, srect.right, dx );
    dy = AdjustScroll( offset.y, srect.top, srect.bottom, dy );
    if( dx != 0 || dy != 0 ) {
        offset.x += dx;
        offset.y += dy;
        SetOffset( offset );
        ScrollWindow( wnd, -dx, -dy, NULL, NULL );
        if( GetScrollConfig() & SCROLL_HORZ ) {
            SetScrollPos( wnd, SB_HORZ, offset.x, TRUE );
        }
        if( GetScrollConfig() & SCROLL_VERT ) {
            SetScrollPos( wnd, SB_VERT, offset.y, TRUE );
        }
    }
}
Пример #12
0
void CZhfPalette::OnSize(UINT nType, int cx, int cy)
{
	CAdUiPalette::OnSize(nType, cx, cy);
	// TODO: 在此添加消息处理程序代码
	if (cx<m_iCtrlWidth+m_iMarginX||cy<m_iCtrlHeight+m_iMarginY)
	{
		return ;
	}
	int iCtrlNum = m_pArrayPreviewCtrl.GetCount() ;
	int iCol = cx/(m_iCtrlWidth+m_iMarginX) ;
	int iRow = iCtrlNum/iCol + (iCtrlNum%iCol==0?0:1);

	SCROLLINFO si;
	si.cbSize = sizeof(si);
	si.fMask = SIF_RANGE | SIF_PAGE;
	si.nMin = 0;
	si.nMax = iRow-1 ;
	si.nPage = cy/(m_iCtrlHeight+m_iMarginY) ;
	SetScrollInfo(SB_VERT,&si,TRUE);
	ScrollWindow(0,0);

	m_iOldPosY = 0;

	Invalidate(TRUE);

	if (m_pArrayPreviewCtrl.GetCount()>0&&cx>(m_iCtrlWidth+m_iMarginX))
	{
		TRACE(_T("\ncx:%d, cy:%d"),cx, cy) ;
		ResizeCtrl(cx, cy) ;
	}
}
Пример #13
0
void TrackPanel::FastScroll(int hoffset, int voffset)
{
#ifdef __WXMSW__
  REDRAW(this);
  return;
#endif

  int labelWidth = view->labelWidth;

  wxRect r;
  GetSize(&r.width, &r.height);
  r.width -= labelWidth;

  if (hoffset && voffset) {
    // Tricks don't work if we scroll horizontally AND vertically
    // at the same time
    REDRAW(this);
    return;
  }
  
  if (r.width != bitWidth || r.height != bitHeight || !bitmap) {
    // Don't try any tricks if we got resized, too
    REDRAW(this);
    return;
  }
  
  r.x = 0;
  r.y = 0;

  if (hoffset > 0)
    r.width = hoffset;
  else if (hoffset < 0) {
    r.x = (r.width + hoffset);
    r.width = -hoffset;
  }
  else if (voffset > 0)
    r.height = voffset;
  else if (voffset < 0) {
    r.y = (r.height + voffset);
    r.height = -voffset;
  }
  else
    return;

  r.x += labelWidth;
  r.y += 4;
  r.height -= 16;

  wxPaintDC dc(this);

  wxMemoryDC memDC;

  memDC.SelectObject(*bitmap);

  view->DrawTracks(&memDC, &r);

  ScrollWindow(hoffset, voffset);
  dc.Blit(r.x, r.y, r.width, r.height, &memDC, r.x, r.y, wxCOPY, FALSE);
    
}
Пример #14
0
/*
void StatsFrame::addTick(int64_t bdiff, uint64_t tdiff, StatList& lst, AvgList& avg, int scroll)
{
    int64_t bspeed = calcSpeed(bdiff, tdiff);

    avg.push_front(bspeed);

    bspeed = 0;

    for (auto ai = avg.cbegin(); ai != avg.cend(); ++ai)
    {
        bspeed += *ai;
    }

    bspeed /= avg.size();

    updateStatList(bspeed, lst, scroll);

    while (avg.size() > SPEED_APPROXIMATION_INTERVAL_S)
    {
        avg.pop_back();
    }
}
*/
LRESULT StatsFrame::onTimer(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	const uint64_t tick = MainFrame::getLastUpdateTick();
	const uint64_t tdiff = tick - lastTick;
	if (tdiff == 0)
		return 0;
		
	const uint64_t scrollms = (tdiff + scrollTick) * PIX_PER_SEC;
	const uint64_t scroll = scrollms / 1000;
	
	if (scroll == 0)
		return 0;
		
	scrollTick = scrollms - (scroll * 1000);
	
	CRect rc;
	GetClientRect(rc);
	rc.left = twidth;
	ScrollWindow(-((int)scroll), 0, rc, rc);
	
	const int64_t d = MainFrame::getLastDownloadSpeed();
	//const int64_t ddiff = d - m_lastSocketsDown;
	
	const int64_t u = MainFrame::getLastUploadSpeed();
	//const int64_t udiff = u - m_lastSocketsUp;
	
	const int64_t dt = DownloadManager::getRunningAverage();
	
	const int64_t ut = UploadManager::getRunningAverage();
	// [~]IRainman
	
	//addTick(ddiff, tdiff, m_DownSockets, m_DownSocketsAvg, (int)scroll);
	//addTick(udiff, tdiff, m_UpSockets, m_UpSocketsAvg, (int)scroll);
	addAproximatedSpeedTick(d, m_DownSockets, (int)scroll);
	addAproximatedSpeedTick(u, m_UpSockets, (int)scroll);
	addAproximatedSpeedTick(dt, m_Downloads, (int)scroll);
	addAproximatedSpeedTick(ut, m_Uploads, (int)scroll);
	
	StatIter i;
	int64_t mspeed = 0;
	findMax(m_DownSockets, i, mspeed);
	findMax(m_UpSockets, i, mspeed);
	// [+]IRainman
	findMax(m_Downloads, i, mspeed);
	findMax(m_Uploads, i, mspeed);
	// [~]IRainman
	
	if (mspeed > m_max || ((m_max * 3 / 4) > mspeed))
	{
		m_max = mspeed + 1;// [!] IRainman fix: +1
		Invalidate();
	}
	
	lastTick = tick;
	//m_lastSocketsUp = u;
	//m_lastSocketsDown = d;
	doTimerTask();
	return 0;
}
Пример #15
0
void ME_UpdateScrollBar(ME_TextEditor *editor)
{
  HWND hWnd = editor->hWnd;
  SCROLLINFO si;
  BOOL bUpdateScrollBars;
  si.cbSize = sizeof(si);
  si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
  GetScrollInfo(hWnd, SB_VERT, &si);
  bUpdateScrollBars = (editor->bScrollY)&& ((si.nMax != editor->nTotalLength) || (si.nPage != editor->sizeWindow.cy));
	
  if (editor->bScrollY != (si.nMax > 0))
  { /* The scroll bar needs to be shown or hidden */
    si.fMask = SIF_RANGE | SIF_PAGE;
    if (GetWindowLongW(hWnd, GWL_STYLE) & ES_DISABLENOSCROLL)
      si.fMask |= SIF_DISABLENOSCROLL;
  
    si.nMin = 0;
    si.nPage = editor->sizeWindow.cy;
	  
    if (editor->bScrollY)
      si.nMax = editor->nTotalLength;
    else
      si.nMax = 0;
    
    SetScrollInfo(hWnd, SB_VERT, &si, FALSE);
    ME_MarkAllForWrapping(editor);
    ME_WrapMarkedParagraphs(editor);
    
    bUpdateScrollBars = TRUE;
  }
  if (bUpdateScrollBars) 
  {
    int nScroll = 0;
    si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
    if (GetWindowLongW(hWnd, GWL_STYLE) & ES_DISABLENOSCROLL)
      si.fMask |= SIF_DISABLENOSCROLL;
    if (editor->bScrollY)
    {
      si.nMax = editor->nTotalLength;
      si.nPage = editor->sizeWindow.cy;
      if (si.nPos > si.nMax-si.nPage) 
      {
        nScroll = (si.nMax-si.nPage)-si.nPos;
        si.nPos = si.nMax-si.nPage;
      }
    }
    else 
    {
      si.nMax = 0;
      si.nPage = 0;
      si.nPos = 0;
    }
    TRACE("min=%d max=%d page=%d pos=%d shift=%d\n", si.nMin, si.nMax, si.nPage, si.nPos, nScroll);
    editor->nScrollPosY = si.nPos;
    SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
    if (nScroll)
      ScrollWindow(hWnd, 0, -nScroll, NULL, NULL);
  }
}
Пример #16
0
//滚动消息
VOID CFaceItemSelectWnd::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar * pScrollBar)
{
	__super::OnVScroll(nSBCode,nPos,pScrollBar);

	INT nLastPos=m_nCurrentPos;
	switch (nSBCode)
	{
	case SB_TOP:
		{
			m_nCurrentPos=0;
			break;
		}
	case SB_BOTTOM:
		{
			m_nCurrentPos=m_nMaxPels;
			break;
		}
	case SB_LINEUP:
		{
			m_nCurrentPos-=LINE_PELS;
			break;
		}
	case SB_PAGEUP:
		{
			m_nCurrentPos-=m_nPagePels;
			break;
		}
	case SB_LINEDOWN:
		{
			m_nCurrentPos+=LINE_PELS;
			break;
		}
	case SB_PAGEDOWN:
		{
			m_nCurrentPos+=m_nPagePels;
			break;
		}
	case SB_THUMBTRACK:
		{
			m_nCurrentPos=nPos;
			break;
		}
	}
	
	//设置焦点
	SetFocus();

	//调整位置
	m_nCurrentPos=__max(0,__min(m_nCurrentPos,m_nMaxPels-m_nPagePels));

	//设置滚动
	if (nLastPos!=m_nCurrentPos)
	{
		SetScrollPos(SB_VERT,m_nCurrentPos);
		ScrollWindow(0,nLastPos-m_nCurrentPos,NULL,NULL);
	}
	
	return;
}
Пример #17
0
//滚动消息
void CTableFrame::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar * pScrollBar)
{
	//获取参数
	RECT rcClientRect;
	int iLastPos=m_iCurrentPos;
	GetClientRect(&rcClientRect);

	//移动坐标
	switch (nSBCode)
	{
	case SB_TOP:
		{
			m_iCurrentPos=0;
			break;
		}
	case SB_BOTTOM:
		{
			m_iCurrentPos=m_iMaxScrollPos-m_iCountVisibleLine*m_TableResource.m_wHeight;
			break;
		}
	case SB_LINEUP:
		{
			m_iCurrentPos-=m_iScrollPos;
			break;
		}
	case SB_PAGEUP:
		{
			m_iCurrentPos-=rcClientRect.bottom;
			break;
		}
	case SB_LINEDOWN:
		{
			m_iCurrentPos+=m_iScrollPos;
			break;
		}
	case SB_PAGEDOWN:
		{
			m_iCurrentPos+=rcClientRect.bottom;
			break;
		}
	case SB_THUMBTRACK:
		{
			m_iCurrentPos=nPos;
			break;
		}
	}
	
	//调整位置
	SetFocus();
	m_iCurrentPos=__min(m_iCurrentPos,m_iMaxScrollPos-rcClientRect.bottom);
	if (m_iCurrentPos<0) m_iCurrentPos=0;
	if (iLastPos!=m_iCurrentPos)
	{
		SetScrollPos(SB_VERT,m_iCurrentPos);
		ScrollWindow(0,iLastPos-m_iCurrentPos,NULL,NULL);
	}

	return;
}
Пример #18
0
void WindowScrollDown (PCONINFO con, int scroll, int color)
{
    RECT rcScroll;

    if ((con->ymin != 0)
            || (con->dispxmax != con->xmax)
            || (con->dispymax != con->ymax)) {
        rcScroll.left = 0;
        rcScroll.top  = 0;
        rcScroll.right = con->xmax * GetCharWidth ();
        rcScroll.bottom = con->ymax * GetCharHeight ();
        ScrollWindow (con->hWnd, 0, scroll * GetCharHeight (), 
            &rcScroll, NULL);
    }
    else
        ScrollWindow (con->hWnd, 0, scroll * GetCharHeight (), NULL, NULL);
}
Пример #19
0
/*
	BOOL NEAR ScrollHorz(HWND, WORD, WORD)

	PURPOSE: Scrolls the window horizontally

	PARAMETERS:
		hWnd		- Handle to the terminal window
		wScrollCmd	- The type of scrolling we're doing
		wScrollPos	- The scroll bar's position
*/
BOOL NEAR ScrollHorz(HWND hWnd, WORD wScrollCmd, WORD wScrollPos) {
	SCROLLINFO	si;
	int			iScrollPos;

	si.cbSize	= sizeof(si);
	si.fMask	= SIF_ALL;
	GetScrollInfo(ghWndMain, SB_HORZ, &si);

	// Save the current position for comparison
	iScrollPos = si.nPos;

	switch (wScrollCmd) {
		case SB_TOP: // moved to the top
			si.nPos = si.nMin;
			break;

		case SB_BOTTOM: // moved to the bottom
			si.nPos = si.nMax;
			break;

		case SB_PAGEUP: // moved up by a page
			si.nPos -= si.nPage;
			break;

		case SB_PAGEDOWN: // moved down by a page
			si.nPos += si.nPage;
			break;

		case SB_LINEUP:	// move up a line
			si.nPos -= 10;
			break;

		case SB_LINEDOWN: // move down a line
			si.nPos += 10;
			break;

		case SB_THUMBTRACK: // manually positioned
			si.nPos = si.nTrackPos;
			break;

		default:
			return FALSE;
	}

	// Set the position and then retrieve it. Due to adjustments
	// by Windows, it may not be the same as the value set.
	si.fMask = SIF_POS;
	SetScrollInfo(ghWndMain, SB_HORZ, &si, TRUE);
	GetScrollInfo(ghWndMain, SB_HORZ, &si);

	// If the position has changed, scroll the window and update it
	if (si.nPos != iScrollPos) {
		ScrollWindow(ghWndMain, iScrollPos - si.nPos, 0, NULL, NULL);
		UpdateWindow(hWnd);
	}

	return TRUE;
}
Пример #20
0
/***********************************************************************
 *          NOTEPAD_OnVScroll
 *
 *  WM_VSCROLL window message handle function
 *
 *  ARGUMENTS:
 *    - handle of window:
 *         HWND hWnd
 *    - (not used):
 *         HWND hWndCtl
 *    - scroll code:
 *         uint Code
 *    - (not used):
 *         int Pos
 *  RETURNS: none
 */
static void NOTEPAD_OnVScroll(HWND hWnd, HWND hWndCtl, uint Code, int Pos)
{
    SCROLLINFO scroll_info;
    int vert_pos;

    scroll_info.cbSize = sizeof(scroll_info);
    scroll_info.fMask = SIF_ALL;
    GetScrollInfo(hWnd, SB_VERT, &scroll_info);

    vert_pos = scroll_info.nPos;

    switch (Code) {
        case SB_TOP:
            scroll_info.nPos = scroll_info.nMin;
            break;

        case SB_BOTTOM:
            scroll_info.nPos = scroll_info.nMax;
            break;

        case SB_LINEUP:
            scroll_info.nPos--;
            break;

        case SB_LINEDOWN:
            scroll_info.nPos++;
            break;

        case SB_PAGEUP:
            scroll_info.nPos -= scroll_info.nPage;
            break;

        case SB_PAGEDOWN:
            scroll_info.nPos += scroll_info.nPage;
            break;

        case SB_THUMBTRACK:
            scroll_info.nPos = scroll_info.nTrackPos;
            break;

        case SB_THUMBPOSITION:
            scroll_info.nPos = scroll_info.nTrackPos;
            break;
    }

    scroll_info.fMask = SIF_POS;
    SetScrollInfo(hWnd, SB_VERT, &scroll_info, true);

    GetScrollInfo(hWnd, SB_VERT, &scroll_info);
    if (scroll_info.nPos != vert_pos) {
        ScrollWindow(hWnd,
                     0, Globals.CharH * (vert_pos - scroll_info.nPos),
                     NULL, NULL);
        UpdateWindow(hWnd);

        UpdateStuff(false);
    }
}
Пример #21
0
//    鼠标滚轮转动
BOOL COptions::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) 
{
	// TODO: Add your message handler code here and/or call default
	
       SCROLLINFO siInfo;                       //定义滚动信息对象
 
       GetScrollInfo(SB_VERT,&siInfo);          //获取滚动信息
 
       int nMin,nMax,nThumbWidth;                           

       nMin = siInfo.nMin;                     //获取滚动最小值
 
       nMax = siInfo.nMax;
 
       nThumbWidth = siInfo.nPage;             //获取滚动块大小
 
       int nPos = GetScrollPos(SB_VERT);       //获取垂直滚动条的当前位置
 
       if (zDelta > 0)                         //向上滚动
 
       {
 
              if (nPos == 0)
 
                     return TRUE;
 
              SetScrollPos(SB_VERT,nPos-7);        //设置滚动条位置
 
              ScrollWindow(0,7);                   //向上滚动窗口
 
       }
       else
       {
              if ((nPos+nThumbWidth >= nMax))
 
                     return TRUE;
 
              SetScrollPos(SB_VERT,nPos+7);
 
              ScrollWindow(0,-7);

       }

	return CDialog::OnMouseWheel(nFlags, zDelta, pt);
}
Пример #22
0
//-------------------------------------------------------------------//
// OnVScroll()																			//
//-------------------------------------------------------------------//
void CScrollDialog::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	if ( pScrollBar == 0 )
	{
		// The current client rect		= the page size.
		// The provided client size	= the max size.
		CRect tempRect;
		GetClientRect(&tempRect);

		// Handle vertical scrollbar messages
		int nInc;
		switch (nSBCode)
		{
			/*
			// These can be tweaked to better fit the implementation
			case SB_TOP:        nInc = -m_nVscrollPos;               break;
			case SB_BOTTOM:     nInc = m_nVscrollMax-m_nVscrollPos;  break;
			case SB_LINEUP:     nInc = -1;                           break;
			case SB_LINEDOWN:   nInc = 1;                            break;
			case SB_PAGEUP:     nInc = __min(-1, -m_nVertInc);       break;
			case SB_PAGEDOWN:   nInc = __max(1, m_nVertInc);         break;
			case SB_THUMBTRACK: nInc = nPos - m_nVscrollPos;         break;
			default:            nInc = 0;
			*/

			case SB_TOP:        nInc = -m_nVscrollPos;								break;
			case SB_BOTTOM:     nInc = m_ClientRect.Height()-m_nVscrollPos;	break;
			case SB_LINEUP:     nInc = -10;												break;
			case SB_LINEDOWN:   nInc = 10;												break;
			case SB_PAGEUP:     nInc = __min(-1, -tempRect.Height() );			break;
			case SB_PAGEDOWN:   nInc = __max(1, tempRect.Height() );				break;
			case SB_THUMBTRACK: nInc = nPos - m_nVscrollPos;						break;
			default:            nInc = 0;
		}

		#pragma _TODO("Fix this so we can't scroll the dlg off the top of the screen")
		nInc = __max( -m_nVscrollPos, __min( nInc, m_ClientRect.Height() - m_nVscrollPos) );

		if (nInc)
		{
			// We are about to scroll, time to invalidate
			// so the backgrounds get updated.
			InvalidateTransparency();
			
			m_nVscrollPos += nInc;
			// int iMove = -tempRect.Height() * nInc;
			int iMove = -nInc;
			ScrollWindow(0, iMove, NULL, NULL);
			SetScrollPos(SB_VERT, m_nVscrollPos, TRUE);

		}

	}

	inherited::OnVScroll(nSBCode, nPos, pScrollBar);

}
Пример #23
0
void __stdcall CAutoListMembersWindow::OnVertScroll(long code, long pos)
{
	long oldPos; m_vert->get_pos(&oldPos);

	CRect	rect = m_areaRect;
	
	m_vert->put_pos(pos);
	ScrollWindow(0, (oldPos-pos)*16, &rect, &rect);
}
Пример #24
0
BOOL CScrollWnd::OnScrollBy(CSize sizeScroll, BOOL bDoScroll)
{
	int xOrig, x;
	int yOrig, y;
	
	// don't scroll if there is no valid scroll range (ie. no scroll bar)
	CScrollBar* pBar;
	DWORD dwStyle = GetStyle();
	pBar = GetScrollBarCtrl(SB_VERT);
	if ((pBar != NULL && !pBar->IsWindowEnabled()) ||
		(pBar == NULL && !(dwStyle & WS_VSCROLL)))
	{
		// vertical scroll bar not enabled
		sizeScroll.cy = 0;
	}
	pBar = GetScrollBarCtrl(SB_HORZ);
	if ((pBar != NULL && !pBar->IsWindowEnabled()) ||
		(pBar == NULL && !(dwStyle & WS_HSCROLL)))
	{
		// horizontal scroll bar not enabled
		sizeScroll.cx = 0;
	}
	
	// adjust current x position
	xOrig = x = GetScrollPos(SB_HORZ);
	int xMax = GetScrollLimit(SB_HORZ);
	x += sizeScroll.cx;
	if (x < 0)
		x = 0;
	else if (x > xMax)
		x = xMax;
	
	// adjust current y position
	yOrig = y = GetScrollPos(SB_VERT);
	int yMax = GetScrollLimit(SB_VERT);
	y += sizeScroll.cy;
	if (y < 0)
		y = 0;
	else if (y > yMax)
		y = yMax;
	
	// did anything change?
	if (x == xOrig && y == yOrig)
		return FALSE;
	
	if (bDoScroll)
	{
		// do scroll and update scroll positions
		ScrollWindow(-(x-xOrig), -(y-yOrig));
		//Invalidate();
		if (x != xOrig)
			SetScrollPos(SB_HORZ, x);
		if (y != yOrig)
			SetScrollPos(SB_VERT, y);
	}
	return TRUE;
}
Пример #25
0
HRESULT __stdcall CSwatchesList::OnVertScroll(long code, long pos)
{
	long oldPos; m_vert->get_pos(&oldPos);

	m_vert->put_pos(pos);
	ScrollWindow(0, oldPos-pos, &m_areaRect, &m_areaRect);

	return S_OK;
}
Пример #26
0
void BContainer::OnVScroll(UINT nSBCode,UINT nPos, CScrollBar* pScrollBar)
{
	// Handle vertical scrollbar messages
	// These can be tweaked to better fit the implementation
	int nInc;
	int yPos;
	SCROLLINFO si;


	GetScrollInfo(SB_VERT,&si,SIF_POS | SIF_RANGE | SIF_PAGE);
	yPos = si.nPos;
	nInc = 0;
	switch (nSBCode)
	{
	case SB_TOP: nInc = -si.nPos; break;
	case SB_BOTTOM: nInc = si.nMax-si.nPos; break;
	case SB_LINEUP: 
		if(si.nPos > 0)
			nInc = -1; 
		else 
			nInc = 0;
		break;
	case SB_LINEDOWN:
		if(si.nPage+si.nPos < si.nMax+1)
			nInc = 1; 
		else
			nInc = 0;
		break;
//	case SB_PAGEUP: nInc = min(-1, -m_nVertInc); break;
//	case SB_PAGEDOWN: nInc = max(1, m_nVertInc); break;
	case SB_THUMBTRACK: nInc = nPos - si.nPos; break;
	default: nInc = 0;
	}

//	nInc = max(-si.nPos, min(nInc, si.nMax - si.nPos));

	if (nInc)
	{
		si.nPos += nInc;
		int iMove = (yPos - si.nPos)*(ELEMENT_HEIGHT+ELEMENT_SIZE_BETWEEN);

		si.cbSize = sizeof(SCROLLINFO);
		si.fMask = SIF_POS ;
		SetScrollInfo(SB_VERT,&si,true);

		ScrollWindow(0, iMove, NULL, NULL);
	//	CWnd::UpdateWindow();
		//SetScrollPos(SB_VERT, m_nVscrollPos, TRUE);
		
	}
	

	
	CWnd::OnVScroll(nSBCode, nPos, pScrollBar);

}
Пример #27
0
void CTerrainEditorDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
	SCROLLINFO si;
	si.cbSize=sizeof(si);
	GetScrollInfo(SB_HORZ,&si);
	int pos;
	switch(nSBCode)
	{
	case SB_LEFT:
		ScrollWindow(si.nPos-si.nMin,0);
		si.nPos=si.nMin;
		SetScrollInfo(SB_HORZ,&si);
		break;
	case SB_RIGHT:
		ScrollWindow(si.nPos-si.nMax+si.nPage,0);
		si.nPos=si.nMax-si.nPage;
		SetScrollInfo(SB_HORZ,&si);
		break;
	case SB_LINELEFT:
		pos=si.nPos;
		si.nPos-=10;
		if(si.nPos<si.nMin) si.nPos=si.nMin;
		ScrollWindow(pos-si.nPos,0);
		SetScrollInfo(SB_HORZ,&si);
		break;
	case SB_LINERIGHT:
		pos=si.nPos;
		si.nPos+=si.nPage;
		if(si.nPos>si.nMax-(int)si.nPage) si.nPos=si.nMax-si.nPage;
		ScrollWindow(pos-si.nPos,0);
		SetScrollInfo(SB_HORZ,&si);
		break;
	case SB_PAGELEFT:
		pos=si.nPos;
		si.nPos-=si.nPage;
		if(si.nPos<si.nMin) si.nPos=si.nMin;
		ScrollWindow(pos-si.nPos,0);
		SetScrollInfo(SB_HORZ,&si);
		break;
	case SB_PAGERIGHT:
		pos=si.nPos;
		si.nPos+=10;
		if(si.nPos>si.nMax-(int)si.nPage) si.nPos=si.nMax-si.nPage;
		ScrollWindow(pos-si.nPos,0);
		SetScrollInfo(SB_HORZ,&si);
		break;
	case SB_THUMBPOSITION:
	case SB_THUMBTRACK:
		ScrollWindow(si.nPos-nPos,0);
		si.nPos=nPos;
		SetScrollInfo(SB_HORZ,&si);
		break;
	default:
		break;
	}

	CDialogEx::OnHScroll(nSBCode, nPos, pScrollBar);
}
Пример #28
0
void CScrollDlg::ResetScrollbars()
{
	//Scroll the Window to its initial Position
	ScrollWindow(0, m_nVscrollPos*VERT_PTS, NULL, NULL);
    m_nVscrollPos = 0;

	//Setup and Initialize a Vertical Scroll bar
	//You can do the same for Horizontal Scroll bar
    SetScrollPos(SB_VERT, m_nVscrollPos, TRUE);
}
Пример #29
0
bool wxVScrolledWindow::ScrollToLine(size_t line)
{
    if ( !m_lineMax )
    {
        // we're empty, code below doesn't make sense in this case
        return false;
    }

    // determine the real first line to scroll to: we shouldn't scroll beyond
    // the end
    size_t lineFirstLast = FindFirstFromBottom(m_lineMax - 1, true);
    if ( line > lineFirstLast )
        line = lineFirstLast;

    // anything to do?
    if ( line == m_lineFirst )
    {
        // no
        return false;
    }


    // remember the currently shown lines for the refresh code below
    size_t lineFirstOld = GetVisibleBegin(),
           lineLastOld = GetVisibleEnd();

    m_lineFirst = line;


    // the size of scrollbar thumb could have changed
    UpdateScrollbar();


    // finally refresh the display -- but only redraw as few lines as possible
    // to avoid flicker
    if ( GetChildren().empty() &&
         (GetVisibleBegin() >= lineLastOld || GetVisibleEnd() <= lineFirstOld ) )
    {
        // the simplest case: we don't have any old lines left, just redraw
        // everything
        Refresh();
    }
    else // overlap between the lines we showed before and should show now
    {
        // Avoid scrolling visible parts of the screen on Mac
#ifdef __WXMAC__
        if (!IsShownOnScreen())
            Refresh();
        else
#endif
        ScrollWindow(0, GetLinesHeight(GetVisibleBegin(), lineFirstOld));
    }

    return true;
}
Пример #30
0
/*
 * _ShiftWindow - move current window up/down
*/
void _ShiftWindow( LPWDATA w, int diff )
{
    HWND        hwnd;
    int         amt;
    LPSTR       txt_s,txt_d;
    int         i,sline,eline,add;

    hwnd = w->hwnd;
    amt = -diff*w->ychar;

#if defined( __OS2__ )
    {
        RECTL       rcl;

        WinQueryWindowRect( hwnd, &rcl );
        WinScrollWindow( hwnd, 0, -amt, NULL, &rcl, NULL, NULL, SW_INVALIDATERGN );
    }
#else
    {
        RECT        rect;

        GetClientRect( hwnd, &rect );
        i = (rect.bottom + 1) / w->ychar;
        rect.bottom = i * w->ychar;
        ScrollWindow( hwnd, 0, amt, NULL, &rect );
    }
#endif

    if( diff < 0 ) {
        sline = w->height - 3 + diff;
        if( sline < 0 )
            sline = 0;
        eline = 0;
        add = -1;
    } else {
        sline = diff;
        eline = w->height - 1;
        if( eline < sline )
            eline = sline;
        add = 1;
    }
    i = sline;
    while( i != eline ) {
        txt_s = (LPSTR)&w->image[i * w->width];
        txt_d = (LPSTR)&w->image[(i - diff) * w->width];
#ifdef _MBCS
        FARmemcpy( txt_d, txt_s, sizeof( mb_char ) * w->width );
#else
        FARmemcpy( txt_d, txt_s, w->width );
#endif
        i += add;
    }

} /* _ShiftWindow */