Beispiel #1
0
void nuiKnob::SetSequencePath(const nglPath& rPath)
{
  mSequencePath = rPath;
  mSequenceNeedRefresh = true;
  nuiEvent event;
  DoInvalidate(event);
}
Beispiel #2
0
void nuiKnob::SetNbFrames(uint32 nbFrames)
{
  mSequenceNbFrames = nbFrames;
  mSequenceNeedRefresh = true;
  nuiEvent event;
  DoInvalidate(event);
}
Beispiel #3
0
void nuiKnob::SetOrientation(nuiOrientation orientation)
{
  mSequenceOrientation = orientation;
  mSequenceNeedRefresh = true;
  nuiEvent event;
  DoInvalidate(event);
}
Beispiel #4
0
// update_bars() is called if anything changes that will cause the scroll
// bars to change (move/resize etc).  This will happen if total_, page_
// or line_ sizes change, the window is resized, font changed, etc.
// If the parameter 'newpos' is not null_point then the display position
// will be moved to that position.  Note that the display may be redrawn.
void CScrView::update_bars(CPointAp newpos)
{
	if (in_update_ || m_hWnd == NULL)
		return;
	in_update_ = TRUE;

//    TRACE0("--- update_bars\n");
	check_coords();                 // Check that mapping mode not changed
	caret_hide();

	// Get info needed in later calcs
	TEXTMETRIC tm;
	{
		CClientDC dc(this);
		OnPrepareDC(&dc);
		dc.GetTextMetrics(&tm);
	}

	// Get display area and convert to logical units (but with +ve values)
	CRect cli;
	GetDisplayRect(&cli);
	//CRectAp doc_rect = ConvertFromDP(cli) - GetScroll();

	// If newpos not specified use old pos
	if (newpos == null_point)
		newpos = scrollpos_;
	ASSERT(newpos.x >= 0 && newpos.y >= 0);

	if (!page_specified_ || !line_specified_)
	{
		// Calculate amount of line and page scroll based on size of font
		if (!page_specified_)
		{
			// Recalc page size
			int lines = cli.Height()/tm.tmHeight + tm.tmExternalLeading - 1;
			if (lines < 1)
				lines = 1;
			page_.cx = cli.Width() - tm.tmAveCharWidth;
			page_.cy = lines * (tm.tmHeight + tm.tmExternalLeading);
		}

		if (!line_specified_)
		{
			// Recalc line size
			line_.cx = tm.tmAveCharWidth;
			line_.cy = tm.tmHeight + tm.tmExternalLeading;
		}
	}

	// Update display and scroll bars.
	ASSERT(total_.cx >= 0 && total_.cy >= 0);

	// If display position has changed redraw/scroll to it
	if (newpos != scrollpos_)
	{
		scroll_up_ = newpos.y < scrollpos_.y;

		// Get scroll & new positions in real logical coords
		CPointAp t_scroll = scrollpos_;
		if (negx()) t_scroll.x = -t_scroll.x;
		if (negy()) t_scroll.y = -t_scroll.y;
		CPointAp t_newpos = newpos;
		if (negx()) t_newpos.x = -t_newpos.x;
		if (negy()) t_newpos.y = -t_newpos.y;

//      // For OWNDC window and mapping mode != MM_TEXT ScrollWindow
//      // does not move caret properly!?!? - so we do it ourselves!

		__int64 tmp = t_scroll.y < t_newpos.y ? t_newpos.y - t_scroll.y : t_scroll.y - t_newpos.y;
		if (abs(int(t_scroll.x - t_newpos.x)) > cli.Width() || tmp > __int64(cli.Height()))
			DoInvalidate();     // ScrollWindow() can't handle big numbers
		else
		{
			// Work out scroll amount in device coordinates
			// LPtoDP can't handle more than 16 bits (signed)
			CPoint dev_scroll, dev_newpos;
			dev_scroll.x = t_scroll.x;
			dev_scroll.y = int(t_scroll.y);
			dev_newpos.x = t_newpos.x;
			dev_newpos.y = int(t_newpos.y);
			{
				// Put in compound statement so DC released ASAP
				CClientDC dc(this);
				OnPrepareDC(&dc);
				dc.LPtoDP(&dev_scroll);
				dc.LPtoDP(&dev_newpos);
			}
			DoScrollWindow(dev_scroll.x - dev_newpos.x, dev_scroll.y - dev_newpos.y);
		}
	}

	if (total_.cx <= 0)
		DoHScroll(0, 0, 0);                     // disable scroll bar
	else if (newpos.x > total_.cx - cli.Width())
	{
		// Handle scroll position past right edge
		DoHScroll(int(((__int64)(newpos.x + cli.Width()) * maxbar_.cx) / total_.cx),
				  (cli.Width() * maxbar_.cx) / total_.cx + 1,
				  int(((__int64)newpos.x * maxbar_.cx) / total_.cx) );
	}
	else
	{
		DoHScroll(maxbar_.cx,
				  (cli.Width() * maxbar_.cx) / total_.cx + 1,
				  int(((__int64)newpos.x * maxbar_.cx) / total_.cx) );
	}

	if (total_.cy <= 0)
		DoVScroll(0, 0, 0);                     // disable scroll bar
	else if (newpos.y > total_.cy - cli.Height())
	{
		// Handle scroll position if (somehow) moved past end
		DoVScroll(int(((__int64)(newpos.y + cli.Height()) * maxbar_.cy) / total_.cy),
				  int((cli.Height() * maxbar_.cy) / total_.cy + 1),
				  int(((__int64)newpos.y * maxbar_.cy) / total_.cy) );
	}
	else
	{
		DoVScroll(int(maxbar_.cy),
				  int((cli.Height() * maxbar_.cy) / total_.cy + 1),
				  int(((__int64)newpos.y * maxbar_.cy) / total_.cy) );
	}

	// Store new position and force redraw before restore of scroll_up_
	scrollpos_ = newpos;        // Keep track of where we moved to
	ASSERT(scrollpos_.x >= 0 && scrollpos_.y >= 0);
//    if (GetFocus() == this)
	caret_show();
	DoUpdateWindow();           // Force redraw before changing scroll_up_
	scroll_up_ = FALSE; // Make sure redraw defaults to downwards

	// Get client window again as changing the scroll bars may have changed it
	// (and nested size event was blocked by in_update_ flag)
	GetDisplayRect(&cli);
	CRectAp doc_rect = ConvertFromDP(cli);

	win_height_ = doc_rect.bottom - doc_rect.top;
	win_width_ = doc_rect.right - doc_rect.left;

	AfterScroll(newpos);
	in_update_ = FALSE;
}
Beispiel #5
0
BOOL CScrView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
{
	CPointAp newpos = scrollpos_;

	switch (LOBYTE(nScrollCode))
	{
	case SB_TOP:
		newpos.x = 0;
		break;
	case SB_BOTTOM:
		newpos.x = total_.cx - win_width_;
		break;
	case SB_LINEUP:
		newpos.x -= line_.cx;
		break;
	case SB_LINEDOWN:
		newpos.x += line_.cx;
		break;
	case SB_PAGEUP:
		newpos.x -= page_.cx;
		break;
	case SB_PAGEDOWN:
		newpos.x += page_.cx;
		break;
	case SB_THUMBPOSITION:
		// DoInvalidate here as this event sent after mouse released after
		// all SB_THUMBTRACK events.  This removes any bits of the scroll-
		// bar left after tracking caused the scroll bar to "evaporate".
		DoInvalidate();
		// fall through
	case SB_THUMBTRACK:
		newpos.x = (int)(((__int64)nPos * total_.cx) / maxbar_.cx);
		if (total_.cx > maxbar_.cx && newpos.x > total_.cx - win_width_)
			newpos.x = total_.cx - win_width_;
		break;
	}

	switch (HIBYTE(nScrollCode))
	{
	case SB_TOP:
		newpos.y = 0;
		break;
	case SB_BOTTOM:
		newpos.y = total_.cy - win_height_;
		break;
	case SB_LINEUP:
		newpos.y -= line_.cy;
		break;
	case SB_LINEDOWN:
		newpos.y += line_.cy;
		break;
	case SB_PAGEUP:
		newpos.y -= page_.cy;
		break;
	case SB_PAGEDOWN:
		newpos.y += page_.cy;
		break;
	case SB_THUMBPOSITION:
		// Invalidate here as this event sent after mouse released after
		// SB_THUMBTRACK events finished.  This removes any bits of the
		// scrollbar left after tracking caused the scroll bar to "evaporate".
		DoInvalidate();
		// fall through
	case SB_THUMBTRACK:
		newpos.y = ((__int64)nPos * total_.cy) / maxbar_.cy;
		if (total_.cy > maxbar_.cy && newpos.y > total_.cy - win_height_)
			newpos.y = total_.cy - win_height_;
		break;
	}

#if 0
	if (bDoScroll)
		ValidateScroll(newpos);
	// Work out amount to scroll (in device coordinates)
	{
		CClientDC dc(this);
		OnPrepareDC(&dc);
		CSize amt = CSize(newpos - scrollpos_); // This won't work
		dc.LPtoDP(&amt);
	}
	BOOL retval = OnScrollBy(amt, bDoScroll);
	if (retval && bDoScroll)
		DoUpdateWindow();

	return retval;
#else
	if (bDoScroll)
	{
		ValidateScroll(newpos);
		update_bars(newpos);
		DoUpdateWindow();
	}
	return TRUE;
#endif
}