コード例 #1
0
void CXTPCoreTreeControl::EnsureVisible(CXTPCoreTreeItem* pItem)
{
	if (!pItem || !m_hWnd)
		return;

	CXTPCoreTreeItem* pParentItem = pItem->GetParentItem();

	while (pParentItem != NULL)
	{
		pParentItem->SetExpanded(TRUE);
		pParentItem = pParentItem->GetParentItem();
	}

	CXTPClientRect rcClient(this);
	CRect rc = pItem->GetRect();

	if (rc.bottom > rcClient.bottom + GetScrollOffset())
	{
		OnScrollChanged(min(rc.top, rc.bottom - rcClient.Height()));
	}
	else if (rc.top < GetScrollOffset())
	{
		OnScrollChanged(rc.top);
	}

}
コード例 #2
0
ファイル: smoothscroll.cpp プロジェクト: Apkawa/leechcraft
			void SmoothScroll::HandleMouseRelease (QMouseEvent *event)
			{
				event->ignore ();

				if (event->button () != Qt::LeftButton)
					return;

				if (IgnoreList_.removeAll (event))
					return;

				QPoint delta;
				switch (State_)
				{
					case SPressed:
						event->accept ();
						State_ = SSteady;
						if (Target_)
						{
							QMouseEvent *e1 = new QMouseEvent (QEvent::MouseButtonPress,
									PressPos_, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
							QMouseEvent *e2 = new QMouseEvent (*event);
							IgnoreList_ << e1 << e2;
							QApplication::postEvent (Target_, e1);
							QApplication::postEvent (Target_, e2);
						}
						break;
					case SManualScroll:
						event->accept ();
						delta = event->pos () - PressPos_;
						if (Timestamp_.elapsed () > 100)
						{
							Timestamp_ = QTime::currentTime ();
							Speed_ = delta - Delta_;
							Delta_ = delta;
						}
						Offset_ = GetScrollOffset ();
						PressPos_ = event->pos ();
						if (Speed_ == QPoint (0, 0))
							State_ = SSteady;
						else
						{
							Speed_ /= 4;
							State_ = SAutoScroll;
							Ticker_->Start (10);
						}
						break;
					case SStop:
						event->accept ();
						State_ = SSteady;
						Offset_ = GetScrollOffset ();
						break;
					default:
						break;
				}
			}
コード例 #3
0
ファイル: smoothscroll.cpp プロジェクト: Apkawa/leechcraft
			void SmoothScroll::HandleMousePress (QMouseEvent *event)
			{
				event->ignore ();

				if (event->button () != Qt::LeftButton)
					return;

				if (IgnoreList_.removeAll (event))
					return;

				switch (State_)
				{
					case SSteady:
						event->accept ();
						State_ = SPressed;
						PressPos_ = event->pos ();
						break;
					case SAutoScroll:
						event->accept ();
						State_ = SStop;
						Speed_ = QPoint (0, 0);
						PressPos_ = event->pos ();
						Offset_ = GetScrollOffset ();
						Ticker_->Stop ();
						break;
					default:
						break;
				}
			}
コード例 #4
0
ファイル: HTMLWidget.cpp プロジェクト: binji/drod-nacl
//*****************************************************************************
bool CHTMLWidget::GoForward(
//Go forward n pages.
//
//Params:
	UINT wCount)   //(in)   Number of pages to skip.
//
//Returns: true if the new page loaded/parsed successfully.
{
	if (this->swstrForwardLink.empty()) return false;

	GetScrollOffset(this->nOffsetX, this->nOffsetY);
	SHTMLPos sNewPage;
	sNewPage.wstrLink = this->wstrCurrentPage;
	sNewPage.wY = -this->nOffsetY;

	while (wCount-- && !this->swstrForwardLink.empty())
	{
		if (!sNewPage.wstrLink.empty())
			this->swstrBackLink.push(sNewPage);
		sNewPage = this->swstrForwardLink.top();
		this->swstrForwardLink.pop();
	}

	return LoadFile(sNewPage.wstrLink.c_str(), false, sNewPage.wY);
}
コード例 #5
0
ファイル: HTMLWidget.cpp プロジェクト: binji/drod-nacl
//*****************************************************************************
void CHTMLWidget::Paint(
//Paint text inside of the widget area.
//
//Params:
	bool bUpdateRect)       //(in)   If true (default) and destination
								//    surface is the screen, the screen
								//    will be immediately updated in
								//    the widget's rect.
{
	if (this->pHTMLSurface)
	{
		//Prepare for blitting the surface during idle animation.
		//Wait until entire page is painted before repainting it.
		if (this->wHeightDrawn >= (UINT)this->pHTMLSurface->h)
		{
			bNeedRepaint = false;
			this->wHeightDrawn = 0;
			GetScrollOffset(this->nOffsetX, this->nOffsetY);
		}
		else
			bNeedRepaint = true;
	} else {
		PaintChildren(); //No surface; slow render mode.
		if (bUpdateRect) UpdateRect();
	}
}
コード例 #6
0
ファイル: MouseTracker.cpp プロジェクト: adhawkins/SimpleLib
HDC CMouseTracker::GetDC()
{
	HDC hDC=GetDCEx(m_hWnd, NULL, DCX_PARENTCLIP|DCX_LOCKWINDOWUPDATE);
	POINT pt=GetScrollOffset();
	SetWindowOrgEx(hDC, pt.x, pt.y, NULL);
	return hDC;
}
コード例 #7
0
ファイル: HTMLWidget.cpp プロジェクト: binji/drod-nacl
//*****************************************************************************
void CHTMLWidget::HandleAnimate()
//Draw as much of page surface as can be done this frame without slowing animation.
{
	ASSERT(IsVisible());
	if (!this->pHTMLSurface)
		return;
	if (this->wHeightDrawn >= (UINT)this->pHTMLSurface->h)
		return; //all done
	SDL_Surface *pDestSurface = GetDestSurface();

	//Blit horizontal strips of HTML surface to screen until animation duration is up.
	static const UINT dwMaxTime = 30;  //30ms
	const UINT dwStopTime = SDL_GetTicks() + dwMaxTime;

	ASSERT(this->pParent);
	SDL_Rect clipRect;
	this->pParent->GetChildClippingRect(clipRect);
	SDL_SetClipRect(pDestSurface, &clipRect);
	do {
		static const UINT wStripHeight = 64;
		SDL_Rect src = {-this->nOffsetX, -this->nOffsetY + this->wHeightDrawn,
				this->pHTMLSurface->w, wStripHeight};
		SDL_Rect dest = {this->x, this->y + this->wHeightDrawn, this->pHTMLSurface->w, wStripHeight};

		//Bounds check on last row.
		if (this->wHeightDrawn + wStripHeight > (UINT)this->pHTMLSurface->h)
			src.h = dest.h = this->pHTMLSurface->h - this->wHeightDrawn;
		if (dest.y + dest.h >= clipRect.y + clipRect.h)
		{
			//Now rendering past the visible rect -- stop drawing the page after this,
			//or repaint if dirty flag is set.
			src.h = dest.h = (clipRect.y + clipRect.h) - dest.y;
			if (bNeedRepaint)
			{
				bNeedRepaint = false;
				this->wHeightDrawn = -dest.h;
				GetScrollOffset(this->nOffsetX, this->nOffsetY);
			}
			else
				this->wHeightDrawn = this->pHTMLSurface->h;
		}

		SDL_BlitSurface(this->pHTMLSurface, &src, pDestSurface, &dest);
		UpdateRect(dest);

		this->wHeightDrawn += dest.h;
		if (this->wHeightDrawn >= (UINT)this->pHTMLSurface->h) break; //all done
		if (this->wHeightDrawn >= this->h) break; //drawn entire visible area
	} while (SDL_GetTicks() < dwStopTime);
	SDL_SetClipRect(pDestSurface, NULL);
}
コード例 #8
0
ファイル: smoothscroll.cpp プロジェクト: Apkawa/leechcraft
			void SmoothScroll::Tick ()
			{
				if (State_ == SAutoScroll)
				{
					Speed_ = Deaccelerate (Speed_);
					SetScrollOffset (Offset_ - Speed_);
					Offset_ = GetScrollOffset ();
					if (Speed_ == QPoint (0, 0))
					{
						State_ == SSteady;
						Ticker_->Stop ();
					}
				}
				else
					Ticker_->Stop ();
			}
コード例 #9
0
ファイル: wtlist.cpp プロジェクト: peteratebs/webcwebbrowser
long WebListBox::OptionAt(DISPLAY_INT x, DISPLAY_INT y)
{
	DISPLAY_INT offsetX, offsetY;
	DISPLAY_INT offX = 0, offY = 0;

	if (mpParent)
	{
		mpParent->GetDisplayPosition(this, &offX, &offY);
	}

	WebRect box;
	GetOptionsRect(&box);
	y -= offY + box.top;
	GetScrollOffset(&offsetX, &offsetY);
	y += offsetY;
	return (y / (GetSpacing() + miTextHeight));
}
コード例 #10
0
nsIntPoint
WebBrowserChrome::GetScrollOffsetForElement(nsIDOMElement* aElement)
{
  nsCOMPtr<nsIDOMDocument> ownerDoc;
  aElement->GetOwnerDocument(getter_AddRefs(ownerDoc));
  nsCOMPtr<nsIDOMWindow> domWindow;
  nsCOMPtr<nsIDOMNode> parentNode;
  aElement->GetParentNode(getter_AddRefs(parentNode));
  if (parentNode == ownerDoc) {
    ownerDoc->GetDefaultView(getter_AddRefs(domWindow));
    return GetScrollOffset(domWindow);
  }

  nsIntPoint scrollOffset;
  aElement->GetScrollLeft(&scrollOffset.x);
  aElement->GetScrollTop(&scrollOffset.y);
  return scrollOffset;
}
コード例 #11
0
void CXTPCoreTreeControl::OnLButtonDblClk(UINT nFlags, CPoint point)
{
	CXTPCoreTreeItem* pItem = HitTest(point);

	if (pItem)
	{
		point.y += GetScrollOffset();

		if (pItem->GetCheckboxRect().PtInRect(point))
		{
			OnCheckClicked(pItem);
		}
		else if (pItem->HasChildren())
		{
			pItem->SetExpanded(!pItem->IsExpanded());
		}
	}

	CWnd::OnLButtonDblClk(nFlags, point);
}
コード例 #12
0
ファイル: wtlist.cpp プロジェクト: peteratebs/webcwebbrowser
void WebListBox::FitSelection(void)
{
	if (UseVScroll())
	{
		DISPLAY_INT offsetX, offsetY;
		WebRect r;

		GetScrollOffset(&offsetX, &offsetY);
		GetOptionsRect(&r);

		int pos = miSelected * (miTextHeight + GetSpacing());
		if (pos < offsetY)
		{
			mpVScroll->SetPosition(pos);
		}
		else if (pos > offsetY + r.Height() - miTextHeight - GetSpacing())
		{
			mpVScroll->SetPosition(pos - r.Height() + miTextHeight + GetSpacing());
		}
	}
}
コード例 #13
0
void CXTPCoreTreeControl::OnDraw(CDC* pDC, CRect rcClipBox)
{
	pDC->SetBkMode(TRANSPARENT);

	m_pPaintManager->FillTreeControl(pDC, this);

	int nScrollOffset = GetScrollOffset();

	CPoint pt = pDC->GetViewportOrg();
	pDC->SetViewportOrg(pt.x, pt.y - nScrollOffset);

	rcClipBox.OffsetRect(0, nScrollOffset);

	DrawTreeItems(m_pItems, pDC, rcClipBox);

	if (m_pDragOverItem)
	{
		m_pPaintManager->DrawDropRect(pDC, m_pDragOverItem);
	}

	pDC->SetViewportOrg(pt);
}
コード例 #14
0
void CXTPCoreTreeControl::OnLButtonDown(UINT nFlags, CPoint point)
{
	SetFocus();

	CXTPCoreTreeItem* pItem = HitTest(point);

	if (pItem != NULL)
	{
		m_ptPressed = point;

		point.y += GetScrollOffset();

		if (pItem->HasChildren() && pItem->GetButtonRect().PtInRect(point))
		{
			pItem->SetExpanded(!pItem->IsExpanded());

			if (pItem->IsParent(m_pFocusedItem))
			{
				SetFocusedItem(pItem);
			}
		}
		else if (pItem->GetCheckboxRect().PtInRect(point))
		{
			SetFocusedItem(pItem);
			OnCheckClicked(pItem);
		}
		else
		{
			SetFocusedItem(pItem);

			SetCapture();
			m_pPressedItem = pItem;
		}
	}

	CWnd::OnLButtonDown(nFlags, point);
}
コード例 #15
0
  aElement->GetParentNode(getter_AddRefs(parentNode));
  if (parentNode == ownerDoc) {
    ownerDoc->GetDefaultView(getter_AddRefs(domWindow));
    domWindow->ScrollTo(aLeft, aTop);
  } else {
    aElement->SetScrollLeft(aLeft);
    aElement->SetScrollTop(aTop);
  }
}

void
WebBrowserChrome::SendScroll()
{
  NS_ENSURE_TRUE(mListener, );
  nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mWebBrowser);
  nsIntPoint offset = GetScrollOffset(window);
  if (mScrollOffset.x == offset.x && mScrollOffset.y == offset.y) {
    return;
  }
  mScrollOffset = offset;
  mListener->OnScrollChanged(offset.x, offset.y);
}


// ----- Embedding Site Window
NS_IMETHODIMP WebBrowserChrome::SetDimensions(uint32_t aFlags,
                                              int32_t aX, int32_t aY,
                                              int32_t aCx, int32_t aCy)
{
  // TODO: currently only does size
  LOGNI("flags:%u, pt[%i,%i] sz[%i,%i]\n", aFlags, aX, aY, aCx, aCy);
コード例 #16
0
CXTPCoreTreeItem* CXTPCoreTreeControl::HitTest(CPoint point) const
{
	point.y += GetScrollOffset();

	return HitTestTreeItems(m_pItems, point);
}
コード例 #17
0
void CNCaptureView::GetCurrentOffsetPoint(LPPOINT lpPoint)
{
	GetScrollOffset(*lpPoint);
}
コード例 #18
0
ファイル: scrcamvw.cpp プロジェクト: Amadiro/xara-cairo
void ScreenCamView::OnSize( wxSizeEvent &event )
{
	// This is called early, so if pDocView is null do nothing
	if( NULL == pDocView )
		return;

	SetCurrentStates();

	Document* pCurDoc = Document::GetCurrent();
	DocView* pCurView = DocView::GetCurrent();
	
	// these lines are here to stop very strange things happening on exit under Win32s
	// when this fn gets called when it really shouldn't. I would like to really know
	// just what on earth os going on under Win32s but it iss something strange in message
	// handling as far as I can tell.

	wxSize	size( event.GetSize() );

	// Check for irrelevant or potty messages.
	if (size.x <= 0 || size.y <= 0)
	{
//		TRACEUSER( "JustinF", _T("Strange size msg in ScreenView::OnSize(0x%X, %d, %d)\n"), 
//					nType, cx, cy);
		return;
	}

	// Handle OLE 2.0 in-place activation stuff.
#if (_OLE_VER >= 0x200)
	if(GetDocument())
	{
		COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
		if (pActiveItem) pActiveItem->SetItemRects();
	}	
#endif

	if (Status->ScrollersVisible)
	{
PORTNOTETRACE( "other", "ScreenCamView::OnSize - Removed scroller usage" );
#if !defined(EXCLUDE_FROM_XARALX)
		// Resize and reposition the proportional scrollers.
		wxRect hrect, vrect;
		HScrollBar->CalcPosFromParentClient(&hrect);

		UINT32 RulerWidth = OILRuler::GetWidth();
		//if rulers are switched on the scroll bars are made
		// smaller to accomodate them
		if (Status->RulersVisible)
			hrect.left += RulerWidth;
		if (RULER_BORDERS)
			hrect.left-=2;

		HScrollBar->MoveWindow(&hrect, TRUE);
		VScrollBar->CalcPosFromParentClient(&vrect);

		if (Status->RulersVisible)
			vrect.top += RulerWidth;
		if (RULER_BORDERS)
			vrect.top-=2;

		VScrollBar->MoveWindow(&vrect, TRUE);

 		// Reposition the corner window at the bottom-right.
		Corner->MoveWindow(vrect.left, hrect.top, vrect.Width(), hrect.Height());
	 
		// Resize/reposition the rendering window.
		CurrentSize.left = CurrentSize.top = 0;
		CurrentSize.right = cx - vrect.Width() + 1;
		CurrentSize.bottom = cy - hrect.Height() + 1;
#endif
	}
	else
	{	
		CurrentSize.x = CurrentSize.y = 0;
		CurrentSize.width  = size.x;
		CurrentSize.height = size.y;
	}

	if (Status->RulersVisible)
	{
PORTNOTETRACE( "other", "ScreenCamView::OnSize - Removed scroller / ruler usage" );
#if !defined(EXCLUDE_FROM_XARALX)
	 	wxRect hRect, vRect, oRect;

	 	HRuler->CalcPosFromParentClient(&hRect);
		HRuler->MoveWindow(&hRect, TRUE);
		HRuler->PositionLegend();
		
		CurrentSize.top = 0 + hRect.Height() ;
			
	 	VRuler->CalcPosFromParentClient(&vRect);
		VRuler->MoveWindow(&vRect, TRUE);
		CurrentSize.left = 0 + vRect.Width(); 

	 	OGadget->CalcPosFromParentClient(&oRect);
		OGadget->MoveWindow(&oRect, TRUE);
		if (RULER_BORDERS)
		{
			CurrentSize.top --;
			CurrentSize.left--; 
		}
#endif
	}

PORTNOTE( "other", "ScreenCamView::OnSize - Removed RenderWindow usage -not sure if needed" )
#ifndef EXCLUDE_FROM_XARALX
	RenderWindow->MoveWindow(&CurrentSize, TRUE);
#endif
	// Update the rest of the window placement information.
	UpdateViewPosition();

	// Calculate the work area, page & line sizes etc etc.
	FIXED16 PixelWidth, PixelHeight;
	pDocView->GetPixelSize(&PixelWidth, &PixelHeight);

PORTNOTE( "other", "ScreenCamView::OnSize - Removed scroller usage" )
#if !defined(EXCLUDE_FROM_XARALX)
	XLONG x1 = CurrentSize.GetWidth() * PixelWidth;
	XLONG x2 = CurrentSize.GetHeight() * PixelHeight;
	HScrollBar->SetPageSize(x1);
	VScrollBar->SetPageSize(x2);
	HScrollBar->SetLineSize(x1 / xlong(10) + xlong(1));	
	VScrollBar->SetLineSize(x2 / xlong(10) + xlong(1));
#endif
	SetWorkAreaExtent(Status->WorkAreaExtent, FALSE);

	// Make sure the scroll offsets are valid - if we resize the bottom of the window
	// when at the extreme bottom of the view, then the scroll offsets should be
	// changed - we use the scrollers' own integrity checks to do this automatically.
	// Don't do this until the setup flag is TRUE, so we don't overwrite scroll offsets
	// that have been reloaded.
	if (fSetupDone)
	{
		WorkCoord CurrScrollPos;
		GetScrollOffset(&CurrScrollPos);
		SetScrollOffset(CurrScrollPos, TRUE);
	}	

	// Inform the associated DocView object that something has happened.
	pDocView->ViewStateChanged();
	pCurDoc->SetCurrent();
	pCurView->SetCurrent();
}
コード例 #19
0
ファイル: MouseTracker.cpp プロジェクト: adhawkins/SimpleLib
// Track mouse
bool CMouseTracker::Track(HWND hWnd, POINT& pt)
{
	// Capture mouse
	SetCapture(hWnd);

	// Constrain to bounds
	SnapMouse(pt);
	ConstrainMouse(pt);

	// Store attributes
	m_hWnd=hWnd;
	m_ptStart=pt;

	if (m_bLockWindowUpdate)
		{
		// Update the window
		RedrawWindow(hWnd, NULL, NULL, RDW_UPDATENOW|RDW_ALLCHILDREN);
		LockWindowUpdate(m_hWnd);
		}

	// Call start handler
	OnStarting(m_ptStart);

	if (m_bAutoScroll)
		{
		m_dwLastScrollAt=GetTickCount();
		SetTimer(m_hWnd, AUTOSCROLL_TIMER_ID, AUTOSCROLL_TIMER_PERIOD, NULL);
		}

	if (m_bHoverDetect)
		{
		m_dwHoverStart=GetTickCount();
		SetTimer(m_hWnd, HOVER_TIMER_ID, HOVER_TIMER_PERIOD, NULL);
		}


	// Spin message loop
	bool bCancelled=true;
	bool bMoved=false;
	while (true)
		{
		// Get a message
		MSG msg;
		if (!GetMessage(&msg, NULL, 0, 0))
			break;

		// Dispatch all non-input messages
		if (!IsInputMessage(msg.message) && 
				!(msg.message==WM_TIMER && (msg.wParam==AUTOSCROLL_TIMER_ID || msg.wParam==HOVER_TIMER_ID)))
			{
			DispatchMessage(&msg);
			continue;
			}

		// Quit if lost capture
		if (GetCapture()!=m_hWnd)
			break;

		// Handle message
		switch (msg.message)
			{
			case WM_TIMER:
				if (m_bHoverDetect && m_dwHoverStart && msg.wParam==HOVER_TIMER_ID)
					{
					if (GetTickCount() > m_dwHoverStart+HOVER_TIMEOUT)
						{
						POINT pt;
						GetCursorPos(&pt);
						ScreenToClient(m_hWnd, &pt);
						m_dwHoverStart=0;
						OnHover(pt);
						}

					break;
					}


				if (msg.wParam!=AUTOSCROLL_TIMER_ID)
					break;
				{
				POINT pt;
				GetCursorPos(&pt);
				ScreenToClient(m_hWnd, &pt);
				msg.lParam=MAKELPARAM(pt.x, pt.y);
				// Fall throught to fake a WM_MOUSEMOVE
				}

			case WM_MOUSEMOVE:
				{
				// Get new point
				POINT ptNew;
				ptNew.x=(int)(short)LOWORD(msg.lParam);
				ptNew.y=(int)(short)HIWORD(msg.lParam);

				if (ptNew.x!=m_ptStart.x || ptNew.y!=m_ptStart.y)
					bMoved=true;

				// Get client rectangle
				if (m_bAutoScroll)
					{
					// Outside client area?
					RECT rcClient;
					GetClientRect(m_hWnd, &rcClient);
					if (!PtInRect(&rcClient, ptNew) && GetTickCount()>m_dwLastScrollAt + AUTOSCROLL_FREQUENCY)
						{
						// Kill old feedback 
						DrawFeedback();

						// Release DC
						if (m_bLockWindowUpdate)	
							{
							LockWindowUpdate(NULL);
							}

						// Do scrolling
						if (ptNew.x<rcClient.left)
							SendMessage(m_hWnd, WM_HSCROLL, SB_LINEUP, 0);
						if (ptNew.x>rcClient.right)
							SendMessage(m_hWnd, WM_HSCROLL, SB_LINEDOWN, 0);
						if (ptNew.y<rcClient.top)
							SendMessage(m_hWnd, WM_VSCROLL, SB_LINEUP, 0);
						if (ptNew.y>rcClient.bottom)
							SendMessage(m_hWnd, WM_VSCROLL, SB_LINEDOWN, 0);
						UpdateWindow(m_hWnd);

						// Get a newly clipped DC
						if (m_bLockWindowUpdate)
							{
							RedrawWindow(hWnd, NULL, NULL, RDW_UPDATENOW|RDW_ALLCHILDREN);
							LockWindowUpdate(m_hWnd);
							}

						// Redraw feedback
						DrawFeedback();

						m_dwLastScrollAt=GetTickCount();
						}
					}

				// Adjust for scrolling
				POINT ptScrollOffset=GetScrollOffset();
				ptNew.x+=ptScrollOffset.x;
				ptNew.y+=ptScrollOffset.y;

				// Constrain to bounds
				SnapMouse(ptNew);
				ConstrainMouse(ptNew);

				// Only handle if still moved after constraining
				if (ptNew.x!=pt.x || ptNew.y!=pt.y || msg.message==WM_TIMER)
					{
					if (msg.message!=WM_TIMER)	
						{
						m_dwHoverStart=GetTickCount();
						}
			
					// Call handler
					OnMove(pt, ptNew);

					// Store new point
					pt=ptNew;
					}
				}
				break;

			case WM_LBUTTONUP:
			case WM_RBUTTONUP:
				bCancelled=false;
				ReleaseCapture();
				break;
			
			case WM_RBUTTONDOWN:
				ReleaseCapture();
				break;

			case WM_KEYDOWN:
				if (msg.wParam==VK_ESCAPE)
					{
					ReleaseCapture();
					break;
					}
				// Fall through

			case WM_KEYUP:
			case WM_SYSKEYDOWN:
			case WM_SYSKEYUP:
				// Call handler
				OnMove(pt, pt);
				break;
			}

		// Quit if lost capture
		if (GetCapture()!=m_hWnd)
			break;
		}

	if (m_bAutoScroll)
		{
		KillTimer(m_hWnd, AUTOSCROLL_TIMER_ID);
		}

	if (m_bHoverDetect)
		{
		KillTimer(m_hWnd, HOVER_TIMER_ID);
		}

	// Finished
	OnFinished(pt, bCancelled);

	// Clean up
	if (m_bLockWindowUpdate)
		{
		LockWindowUpdate(NULL);
		}

	return bMoved && !bCancelled;


}
コード例 #20
0
ファイル: wtlist.cpp プロジェクト: peteratebs/webcwebbrowser
void WebListBox::DrawThisOnly (DISPLAY_INT x, DISPLAY_INT y, WebGraphics *gc)
{
	WebRect visibleRegion, oldClip, frame(mRect);

	CalculateTextMetrics(gc);
	SetupScrollBars(gc);

	WebColor hilite, lolite, black, blue, white;
	hilite = white = gc->RGBToColor(0xff, 0xff, 0xff);
	lolite = black = gc->RGBToColor(0, 0, 0);
	blue = gc->RGBToColor(0, 0, 0xff);

	frame.MoveTo(x,y);

	if (mFlags & DISPLAY_FLAG_FOCUS && !(mStyle & LISTBOX_STYLE_NOFOCUSFRAME))
	{
		gc->Rectangle(&frame, black, black, WEBC_FALSE);
	}
	if (mStyle & LISTBOX_STYLE_NOT3D)
	{
		hilite = lolite = black;
	}

	frame.top += GetMargin();
	frame.left += GetMargin();
	frame.bottom -= GetMargin();
	frame.right -= GetMargin();

//	gc->StartBuffer();

	gc->Rectangle(&frame, GetBgColor(gc), GetBgColor(gc), WEBC_TRUE);
	DrawFrame(&frame, gc);

	DISPLAY_INT windowX, windowY;
	GetScrollOffset(&windowX, &windowY);
	long firstVisible = windowY / (miTextHeight + GetSpacing()) - 1;
	if (firstVisible < 0)
		firstVisible = 0;

	gc->GetClip(&oldClip);

	GetOptionsRect(&visibleRegion);
	visibleRegion.Shift(x,y);

	WebRect clip(visibleRegion);
	clip.And(&oldClip);
	gc->SetClip(&clip);

	WEBC_BOOL invert;
	int offset = firstVisible * (miTextHeight + GetSpacing());
	for (int t = firstVisible; t < miNumOptions; t++)
	{
		invert = ( ((t == GetSelected()) && !(mStyle & LISTBOX_STYLE_FOLLOW_MOUSE)) ||
		           ((t == miMouseOver)   &&  (mStyle & LISTBOX_STYLE_FOLLOW_MOUSE)) );

		if (invert)
		{
			PresetWebRect r (visibleRegion.left - windowX,  visibleRegion.top + offset - windowY,
			                 visibleRegion.right - windowX, visibleRegion.top + offset - windowY + miTextHeight - 1);
			gc->Rectangle(&r, GetSelectColor(gc), GetSelectColor(gc), WEBC_TRUE);
		}
		gc->Text(visibleRegion.left - windowX, visibleRegion.top + offset - windowY,
			 mppOption[t], (invert? GetBgColor(gc) : GetTextColor(gc)),
			 blue, WEBC_FALSE, mFont.GetFont());

		offset += miTextHeight + GetSpacing();
	}

	gc->SetClip(&oldClip);
//	gc->EndBuffer();
}
コード例 #21
0
ファイル: HTMLWidget.cpp プロジェクト: binji/drod-nacl
//*****************************************************************************
bool CHTMLWidget::LoadFile(
//Load a file and parse it.
//
//Params:
	const WCHAR *pwczFileName,    //(in)   File to load, or NULL to load index.
	bool bNewLink,                //(in)   Whether page is new (not from the
	                              //       forward/back lists).
	UINT wScrollY)                //(in)   Pixels to scroll down page initially
	                              //       (ignored if the filename contains a
	                              //        valid in-page anchor reference)
//
//Returns: whether page load was successful.
{
	bool bFullPath = false;

	if (!pwczFileName)
		pwczFileName = this->wstrIndexPage.c_str();  //default = index page
	if (!WCSlen(pwczFileName)) return false;  //empty name

	WSTRING wNewPage = pwczFileName;
	WSTRING wGoToId;
	UINT refpos = (UINT)-1;

	//Very simple path finder
	for (UINT i = WCSlen(pwczFileName); i--;)
	{
		if (pwczFileName[i] == SLASH)
		{
			bFullPath = true;
			this->wstrBasePath = wNewPage.substr(0, i);
			break;
		}
		else if (pwczFileName[i] == '#')
		{
			refpos = i;
			wGoToId = &pwczFileName[i+1];
		}
	}

	if (refpos != (UINT)-1)
		wNewPage = refpos ? wNewPage.substr(0, refpos) : this->wstrCurrentPage;
	if (refpos && !bFullPath)
		wNewPage = this->wstrBasePath + wszSlash + wNewPage;

	if (bNewLink)
	{
		//Add previous page to back list.  Clear forward history.
		GetScrollOffset(this->nOffsetX, this->nOffsetY);
		SHTMLPos prev;
		prev.wstrLink = this->wstrCurrentPage;
		prev.wY = -this->nOffsetY;
		if (!this->wstrCurrentPage.empty())
			this->swstrBackLink.push(prev);
		while (!swstrForwardLink.empty())
			this->swstrForwardLink.pop();
	}

	//Only load if page requested isn't already being shown.
	if (WCScmp(wNewPage.c_str(), this->wstrCurrentPage.c_str()))
	{
		CStretchyBuffer text;
		CFiles files;
		if (!files.ReadFileIntoBuffer(wNewPage.c_str(), text))
			return false;

		this->wstrCurrentPage = wNewPage;
		this->wstrCurrentId = wGoToId;

		VERIFY(Parse(text));  //parse should be successful, but return true in any case
	}

	//Scroll to id or specified Y-position, if possible
	if (this->pParent && this->pParent->GetType() == WT_Scrollable)
	{
		if (!wGoToId.empty())
		{
			HTMLIDMAP::const_iterator idit = mIdmap.find(wGoToId);
			if (idit != mIdmap.end())
				wScrollY = (*idit).second;
		}

		CScrollableWidget *pContainer = DYN_CAST(CScrollableWidget*, CWidget*, this->pParent);
		pContainer->ScrollAbsolute(0, 0);
		pContainer->ScrollDownPixels(wScrollY);
	}

	return true;
}
コード例 #22
0
NS_IMETHODIMP
WebBrowserChrome::HandleEvent(nsIDOMEvent* aEvent)
{
  NS_ENSURE_TRUE(mListener, NS_ERROR_FAILURE);

  nsString type;
  if (aEvent) {
    aEvent->GetType(type);
  }

  LOGT("Event:'%s'", NS_ConvertUTF16toUTF8(type).get());

  nsCOMPtr<nsIDOMWindow> docWin = do_GetInterface(mWebBrowser);
  nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mWebBrowser);
  nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(window);
  if (type.EqualsLiteral(MOZ_MozScrolledAreaChanged)) {
    nsCOMPtr<nsIDOMEventTarget> origTarget;
    aEvent->GetOriginalTarget(getter_AddRefs(origTarget));
    nsCOMPtr<nsIDOMDocument> ctDoc = do_QueryInterface(origTarget);
    nsCOMPtr<nsIDOMWindow> targetWin;
    ctDoc->GetDefaultView(getter_AddRefs(targetWin));
    nsCOMPtr<nsIDOMWindow> docWin = do_GetInterface(mWebBrowser);
    if (targetWin != docWin) {
      return NS_OK; // We are only interested in root scroll pane changes
    }

    // Adjust width and height from the incoming event properties so that we
    // ignore changes to width and height contributed by growth in page
    // quadrants other than x > 0 && y > 0.
    nsIntPoint scrollOffset = GetScrollOffset(docWin);
    nsCOMPtr<nsIDOMScrollAreaEvent> scrollEvent = do_QueryInterface(aEvent);
    float evX, evY, evW, evH;
    scrollEvent->GetX(&evX);
    scrollEvent->GetY(&evY);
    scrollEvent->GetWidth(&evW);
    scrollEvent->GetHeight(&evH);
    float x = evX + scrollOffset.x;
    float y = evY + scrollOffset.y;
    uint32_t width = evW + (x < 0 ? x : 0);
    uint32_t height = evH + (y < 0 ? y : 0);
    mListener->OnScrolledAreaChanged(width, height);

    nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(window->GetChromeEventHandler());
    target->AddEventListener(NS_LITERAL_STRING(MOZ_AFTER_PAINT_LITERAL), this,  PR_FALSE);
  } else if (type.EqualsLiteral("pagehide")) {
    mScrollOffset = nsIntPoint();
  } else if (type.EqualsLiteral(MOZ_AFTER_PAINT_LITERAL)) {
    nsCOMPtr<nsPIDOMWindow> pidomWindow = do_QueryInterface(docWin);
    nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(pidomWindow->GetChromeEventHandler());
    target->RemoveEventListener(NS_LITERAL_STRING(MOZ_AFTER_PAINT_LITERAL), this,  PR_FALSE);
    if (mFirstPaint) {
      mListener->OnUpdateDisplayPort();
      return NS_OK;
    }
    mFirstPaint = true;
    nsIntPoint offset = GetScrollOffset(docWin);
    mListener->OnFirstPaint(offset.x, offset.y);
  } else if (type.EqualsLiteral(MOZ_scroll)) {
    nsCOMPtr<nsIDOMEventTarget> target;
    aEvent->GetTarget(getter_AddRefs(target));
    nsCOMPtr<nsIDOMDocument> eventDoc = do_QueryInterface(target);
    nsCOMPtr<nsIDOMWindow> docWin = do_GetInterface(mWebBrowser);
    nsCOMPtr<nsIDOMDocument> ctDoc;
    docWin->GetDocument(getter_AddRefs(ctDoc));
    if (eventDoc != ctDoc) {
      return NS_OK;
    }
    SendScroll();
  }

  return NS_OK;
}