Example #1
0
BOOL Board::canmove(int ipiece, int x, int y)
{
	if (x == 0 && y == 0) { return FALSE; }
	CRect candrect = piece(ipiece)->mPieceRect;
	candrect.OffsetRect(x,y);
	CRect intersection;
	// 1st check if moved piece is still on the board
	if (intersection.IntersectRect(mBoardRect, candrect)) {
		if (intersection != candrect) {
			return FALSE;
		}
	} else {
		return FALSE;
	}

	// now see if it's moving to a free space

	int i;
	for(i = 0 ; i < numpieces(); i++) {
		if (i != ipiece) {
			CRect prect = piece(i)->mPieceRect;
			BOOL r = intersection.IntersectRect(candrect, prect);
			if (r != 0) {
				return FALSE;
			}
		}
	}
	return TRUE;
}
Example #2
0
	void CSelectionPanel::OnSelected(const CRect&rect){//框選
		
		TRACE("CSelection::OnSelected\n");
		CPlayer* player = CPlayer::GetPlayer();
		set<CSprite*>::iterator it;
		//先清除容器內的東西
		panel->UnSelected();
		//所有的玩家
		int count=0;

		//如果物件跟選取框有交集,就算選取
		for(it = player->Sprites().begin();it!=player->Sprites().end();it++){
			CRect ans;
			if(ans.IntersectRect(rect,(*it)->ScreenRect())){
				selectedSprites.insert(*it);
				count++;
				if(count>=30){
					break;
				}
			}
		}
		for(it=selectedSprites.begin();it!=selectedSprites.end();it++){
			(*it)->OnSelected();
		}
		EraseSprites();
		if(selectedSprites.size()==0){
			CPlayer* npc = CPlayer::GetNPC();
			for(it = npc->Sprites().begin();it!=npc->Sprites().end();it++){
				CRect ans;
				CPoint gridPoint = (*it)->GridPoint();
				CMapTile* mapTile = CGameMap::GetMap()->GetMapTile((*it)->GridPoint());
				if(ans.IntersectRect(rect,(*it)->ScreenRect())){
					if(mapTile->IsExplored() && mapTile->VisionCount()!=0){
						selectedSprites.insert(*it);
						(*it)->OnSelected();
						break;
					}
				}
			}
			EraseSprites();
		}
		if(selectedSprites.size()==0){
			CPlayer* nature = CPlayer::GetNPC();
			for(it = nature->Sprites().begin();it!=nature->Sprites().end();it++){
				CRect ans;
				CPoint gridPoint = (*it)->GridPoint();
				CMapTile* mapTile = CGameMap::GetMap()->GetMapTile((*it)->GridPoint());
				if(ans.IntersectRect(rect,(*it)->ScreenRect())){
					if(mapTile->IsExplored() && mapTile->VisionCount()!=0){
						selectedSprites.insert(*it);
						(*it)->OnSelected();
						break;
					}
				}
			}
			EraseSprites();
		}
		//最後
	}
Example #3
0
// InvalidateRange is an overrideable function that is used to invalidate the view
// between two caret positions.  This is used to invalidate bits of the window
// when the selection is changed (using mouse selection or with SetSel()).
// The default behaviour invalidates the lines (whole width of document) from
// the top of start to the bottom of end (using the current character height).
void CScrView::InvalidateRange(CPointAp start, CPointAp end, bool f /*=false*/)
{
	if (start.y > scrollpos_.y + win_height_ || start.x > scrollpos_.x + win_width_ ||
		end.y < scrollpos_.y || end.x < scrollpos_.x)
	{
		// All outside display area so do nothing.  Note that this may appear to not be nec.
		// as Windows does this too but due to overflow problems is safer to do it here.
		return;
	}

	CSizeAp ss = caret_size();

	// Also invalidate a row above and up to 3 rows below (this is necessary for stacked mode)
	start.y -= ss.cy;
	end.y += 3*ss.cy;

	if (start.x < scrollpos_.x) start.x = scrollpos_.x;
	if (start.y < scrollpos_.y) start.y = scrollpos_.y;
	if (end.y > scrollpos_.y + win_height_)
		end.y = scrollpos_.y + win_height_;

	// Invalidate the full width of display from top of start to bottom of end
	CRectAp rr(0, start.y, total_.cx, end.y);

	// Convert to device coords
	CRect norm_rect = ConvertToDP(rr);

	CRect cli;
	GetDisplayRect(&cli);

	// Invalidate the previous selection so that it is drawn unselected
	CRect rct;
	if (rct.IntersectRect(&cli, &norm_rect))
		DoInvalidateRect(&norm_rect);
}
void CDrawTool::_CheckSelectPostion(IDrawCanvas* pView)
{
	if (pView->GetSelection().size() == 1)
	{
		CDrawObject* pObj = pView->GetSelection().front();
		if (dotSelectRect == pObj->GetDrawObjType())
		{
			CRect rcSelectPos = pObj->GetPosition();
			CRect rcOldSelectPos = rcSelectPos;
			rcSelectPos.NormalizeRect();

			CRect rcDrawTarget = pView->GetDrawTarget();
			rcDrawTarget.OffsetRect(-rcDrawTarget.TopLeft());

			rcSelectPos.IntersectRect(rcSelectPos, rcDrawTarget);
			if (rcSelectPos.IsRectEmpty())
			{
				pView->SetCurrentToolType(ttSelection);
				//pView->ReleaseSelectRect();
			}
			else if(rcOldSelectPos != rcSelectPos)
			{
				pObj->SetPosition(rcSelectPos, FALSE);
				pView->InvalObject(pObj);
			}
		}
	}
}
Example #5
0
DWORD CFrameWnd::CanDock(CRect rect, DWORD dwDockStyle, CDockBar** ppDockBar)
{
	// dwDockStyle -- allowable styles of bar
	// don't allow to dock to floating unless multi is specified
	dwDockStyle &= CBRS_ALIGN_ANY|CBRS_FLOAT_MULTI;

	if (ppDockBar != NULL)
		*ppDockBar = NULL;
	POSITION pos = m_listControlBars.GetHeadPosition();
	while (pos != NULL)
	{
		CDockBar* pDockBar = (CDockBar*)m_listControlBars.GetNext(pos);
		if (pDockBar->IsDockBar() && pDockBar->IsWindowVisible() &&
			(pDockBar->m_dwStyle & dwDockStyle & CBRS_ALIGN_ANY) &&
			(!pDockBar->m_bFloating ||
				(dwDockStyle & pDockBar->m_dwStyle & CBRS_FLOAT_MULTI)))
		{
			CRect rectBar;
			pDockBar->GetWindowRect(&rectBar);
			if (rectBar.Width() == 0)
				rectBar.right++;
			if (rectBar.Height() == 0)
				rectBar.bottom++;
			if (rectBar.IntersectRect(rectBar, rect))
			{
				if (ppDockBar != NULL)
					*ppDockBar = pDockBar;
				return pDockBar->m_dwStyle & dwDockStyle;
			}
		}
	}
	return 0;
}
HANDLE CNCaptureView::CopyRectToHandle(const CRect& rect)
{
	HANDLE hMem = NULL;
	if (m_pImage)
	{
		BOOL bRet = FALSE;
		CRect rcImage(0, 0, m_pImage->GetWidth(), m_pImage->GetHeight());
		CRect rcRealSrc;
		rcRealSrc.IntersectRect(&rect, rcImage);
		if (!rcRealSrc.IsRectEmpty())
		{
			CCanvas canvas;
			bRet = canvas.Create(NULL, rcRealSrc.Width(), rcRealSrc.Height());
			if (bRet)
			{
				for (DrawObjectList::iterator iter = m_allObjects.begin();
					iter != m_allObjects.end();
					++iter)
				{
					CDrawObject* pObj = *iter;
					if(pObj)
					{
						pObj->Draw(m_canvasImage, FALSE);
					}
				}
				BitBlt(canvas.GetMemoryDC(), 0, 0, rcRealSrc.Width(), rcRealSrc.Height(), 
					m_canvasImage.GetMemoryDC(), rcRealSrc.left, rcRealSrc.top, SRCCOPY);
				hMem = canvas.CopyToHandle();
			}
		}
	}
	return hMem;
}
Example #7
0
BOOL CMonitor::IsOnMonitor(const LPRECT lprc) const
{
    CRect rect;
    GetMonitorRect(rect);

    return rect.IntersectRect(rect, lprc);
}
void CScribbleView::OnDraw(CDC* pDC)
{
	CScribbleDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// Get the invalidated rectangle of the view, or in the case
	// of printing, the clipping region of the printer dc.
	CRect rectClip;
	CRect rectStroke;
	pDC->GetClipBox(&rectClip);
	pDC->LPtoDP(&rectClip);
	rectClip.InflateRect(1, 1); // avoid rounding to nothing

	// Note: CScrollView::OnPaint() will have already adjusted the
	// viewport origin before calling OnDraw(), to reflect the
	// currently scrolled position.

	// The view delegates the drawing of individual strokes to
	// CStroke::DrawStroke().
	CTypedPtrList<CObList,CStroke*>& strokeList = pDoc->m_strokeList;
	POSITION pos = strokeList.GetHeadPosition();
	while (pos != NULL)
	{
		CStroke* pStroke = strokeList.GetNext(pos);
		rectStroke = pStroke->GetBoundingRect();
		pDC->LPtoDP(&rectStroke);
		rectStroke.InflateRect(1, 1); // avoid rounding to nothing
		if (!rectStroke.IntersectRect(&rectStroke, &rectClip))
			continue;
		pStroke->DrawStroke(pDC);
	}
}
BOOL CDiagramEntity::BodyInRect( CRect rect ) const
/* ============================================================
	Function :		CDiagramEntity::BodyInRect
	Description :	Used to see if any part of the object lies 
					in rect.
					
	Return :		BOOL		-	TRUE if any part of the 
									object lies inside rect.
	Parameters :	CRect rect	-	The rect to check.
					
	Usage :			Call to see if the object overlaps - for 
					example - a selection rubberband.

   ============================================================*/
{

	BOOL result = FALSE;
	CRect rectEntity = GetRect();
	CRect rectIntersect;

	rect.NormalizeRect();
	rectEntity.NormalizeRect();

	rectIntersect.IntersectRect( rect, rectEntity );
	if( !rectIntersect.IsRectEmpty() )
		result = TRUE;

	return result;

}
void CFeedIcoItemListCtrl::DrawItems(CDC & dcMem, const CRect & rectClip, const CRect & rectClient)
{
	//CImageList* pImgList = GetImageList(LVSIL_NORMAL);

	CFont * pListFont = GetFont();
	dcMem.SelectObject(pListFont);
	dcMem.SetTextColor(RGB(0,0,0));

	CRect itemRect(0,0,0,0);

	CString strTaskName;

	int nItemCount  = GetItemCount() - 1;
	int nHoverIndex = GetHotItem();//Hover
	for ( ; nItemCount >= 0; nItemCount-- )
	{
		int nItemIndex = nItemCount;
		GetItemRect(nItemIndex, &itemRect, LVIR_BOUNDS);

		CRect rtIntersect;
		rtIntersect.IntersectRect(rectClip,itemRect);
		if (rtIntersect.IsRectEmpty())//判断此ITEM是否在重绘区域内,不在的话则直接continue
			continue;

		CRect rectPoster;//封面RECT
		GetItemRect(nItemIndex, &rectPoster, LVIR_ICON);

		//绘制海报
		if( nHoverIndex == nItemIndex || GetItemState(nItemIndex, ODA_SELECT) == ODA_SELECT )
		{//Hover
			if (m_imageRss_PosterSelBg)
				m_imageRss_PosterSelBg->Draw(dcMem.m_hDC, rectPoster.left + 11, rectPoster.top - 8);
		}
		else
		{//Normal
			if (m_imageRss_PosterBg)
				m_imageRss_PosterBg->Draw(dcMem.m_hDC, rectPoster.left + 15, rectPoster.top - 4);
		}

		CRssFeed* pFeed = (CRssFeed*)GetItemData(nItemIndex);

		if (pFeed->m_pPosterImage)//绘制海报
			pFeed->m_pPosterImage->Draw(dcMem.m_hDC, rectPoster.left + 20, rectPoster.top + 1);
		else if (m_imageRss_PosterDefault)//绘制默认海报
				m_imageRss_PosterDefault->Draw(dcMem.m_hDC, rectPoster.left + 20, rectPoster.top + 1);

		//strTaskName = pFeed->m_strTitle;
		strTaskName = GetItemText(nItemCount, 0);

		CRect rectNameStr;//宽度146
		GetItemRect(nItemIndex, &rectNameStr, LVIR_LABEL);
		rectNameStr.OffsetRect(0,5);//拉开标题和Poster的距离 

		dcMem.DrawText(strTaskName, -1, &rectNameStr, DT_CENTER | DT_WORDBREAK );

		//if (pImgList)
		//	pImgList->Draw(&MemDC,nItem,CPoint(itemRect.left+5,itemRect.top+5),ILD_TRANSPARENT);
	}
}
Example #11
0
void CLogo::SetPosition()
{
	if(!::IsWindow(m_hWnd))
		return;

	CDockBar* pTopDockBar = GetParentDockBar();
	if(!pTopDockBar)
		return;

	CRect TopDockBarRect;
	pTopDockBar->GetClientRect(TopDockBarRect);

	CRect LogoRect;
	GetWindowRect(LogoRect);
	pTopDockBar->ScreenToClient(LogoRect);	

	int nLeft = TopDockBarRect.right-LogoRect.Width()-::GetSystemMetrics(SM_CXEDGE);
	int nTop = TopDockBarRect.top;

	if(nLeft != LogoRect.left ||
	   nTop != LogoRect.top)
		SetWindowPos(NULL, 
					 nLeft,
					 nTop,
					 0,
					 0,
					 SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE);

	CRect UnionToolbarRect;

	for(int nI=0;nI<pTopDockBar->m_arrBars.GetSize();nI++)
	{
		CWnd* pWnd = static_cast<CWnd*>(pTopDockBar->m_arrBars[nI]);
		if(!pWnd ||
		   !AfxIsValidAddress(pWnd,sizeof(CWnd)) || 
		   !::IsWindow(*pWnd))
				continue;

		CRect ToolBarRect;
		pWnd->GetWindowRect(&ToolBarRect);
		UnionToolbarRect.UnionRect(UnionToolbarRect,ToolBarRect);
	}

	GetWindowRect(LogoRect);

	UnionToolbarRect.IntersectRect(UnionToolbarRect,LogoRect);
	if(UnionToolbarRect.IsRectEmpty())
	{
		if(!IsWindowVisible())
			ShowWindow(SW_SHOW);
	}
	else
	{
		if(IsWindowVisible())
			ShowWindow(SW_HIDE);
	}
}
void PostProcess(vector<CRect>& result,const int combine_min)
{
    vector<CRect> res1;
    vector<CRect> resmax;
    vector<int> res2;
    bool yet;
    CRect rectInter;

    for(unsigned int i=0,size_i=result.size(); i<size_i; i++)
    {
        yet = false;
        CRect& result_i = result[i];
        for(unsigned int j=0,size_r=res1.size(); j<size_r; j++)
        {
            CRect& resmax_j = resmax[j];
            if(rectInter.IntersectRect(result_i,resmax_j))
            {
                if(
                    SizeOfRect(rectInter)>0.6*SizeOfRect(result_i)
                    && SizeOfRect(rectInter)>0.6*SizeOfRect(resmax_j)
                )
                {
                    CRect& res1_j = res1[j];
                    resmax_j.UnionRect(resmax_j,result_i);
                    res1_j.bottom += result_i.bottom;
                    res1_j.top += result_i.top;
                    res1_j.left += result_i.left;
                    res1_j.right += result_i.right;
                    res2[j]++;
                    yet = true;
                    break;
                }
            }
        }
        if(yet==false)
        {
            res1.push_back(result_i);
            resmax.push_back(result_i);
            res2.push_back(1);
        }
    }

    for(unsigned int i=0,size=res1.size(); i<size; i++)
    {
        const int count = res2[i];
        CRect& res1_i = res1[i];
        res1_i.top /= count;
        res1_i.bottom /= count;
        res1_i.left /= count;
        res1_i.right /= count;
    }

    result.clear();
    for(unsigned int i=0,size=res1.size(); i<size; i++)
        if(res2[i]>combine_min)
            result.push_back(res1[i]);
}
void CIMDisplayView::OnLButtonDown(UINT nFlags, CPoint point) 
{
    CIMDisplayDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);

    CRect rectSave;
    m_tracker.GetTrueRect(rectSave);
    if (m_tracker.HitTest(point) < 0)
    {
		// just to demonstrate CRectTracker::TrackRubberBand
		CRectTracker tracker;
		if (tracker.TrackRubberBand(this, point, true))
		{
			// MessageBeep(0); // beep indicates TRUE

			// see if rubber band intersects with the doc's tracker
			CRect rectT;
			tracker.m_rect.NormalizeRect(); // so intersect rect works
			if (rectT.IntersectRect(tracker.m_rect, m_tracker.m_rect))
			{
				/*
				// dotted line for outline
				m_tracker.m_nStyle &= CRectTracker::dottedLine;

				// if so, put resize handles on it (ie. select it)
				if (m_tracker.m_nStyle & CRectTracker::resizeInside)
				{
					// swap from resize inside to resize outside for effect
					m_tracker.m_nStyle &= ~CRectTracker::resizeInside;
					m_tracker.m_nStyle |= CRectTracker::resizeOutside;
				}
				else
				{
					// just use inside resize handles on first time
					m_tracker.m_nStyle &= ~CRectTracker::resizeOutside;
					m_tracker.m_nStyle |= CRectTracker::resizeInside;
				}
				*/

				UpdateTheView( false );
			}

			m_tracker.m_rect = tracker.m_rect;
		} else {	// clear the selection!
			m_tracker.m_rect.left	= m_tracker.m_rect.right = 0;
			m_tracker.m_rect.top	= m_tracker.m_rect.bottom = 0;
		}

		UpdateTheView( false );
    }
    else if (m_tracker.Track(this, point, true))
    {
		UpdateTheView( false );
    }

    CScrollView::OnLButtonDown(nFlags, point);
}
Example #14
0
void MyBitmap::PaintCenter(CDC* pDC, const CRect& rect)
{
    int x = (rect.left+rect.right)/2 - m_width/2;
    int y = (rect.top+rect.bottom)/2 - m_height/2;
    CRect centered(x,y,x+m_width,y+m_height);
    CRect centeredopt;
    centeredopt.IntersectRect(&centered,&rect);
    if(centeredopt.left>rect.left || centeredopt.top>rect.top)
        pDC->FillSolidRect(&rect,m_clrbkg);
    Paint(pDC, centeredopt, false);
}
Example #15
0
	void CDuiWkeWebkit::OnPaint( CDCHandle dc )
	{
		CRect rcClip;
		dc.GetClipBox(&rcClip);
		CRect rcClient;
		GetClient(&rcClient);
		CRect rcInvalid;
		rcInvalid.IntersectRect(&rcClip,&rcClient);

		m_pWebView->paint(dc,rcInvalid.left,rcInvalid.top,rcInvalid.Width(),rcInvalid.Height(),rcInvalid.left-rcClient.left,rcInvalid.top-rcClient.top,true);
	}
Example #16
0
BOOL CMonitor::IsOnMonitor(const CWnd* pWnd) const
{
    CRect rect;
    GetMonitorRect(rect);

    ASSERT(::IsWindow(pWnd->GetSafeHwnd()));
    CRect wndRect;
    pWnd->GetWindowRect(&wndRect);

    return rect.IntersectRect(rect, wndRect);
}
Example #17
0
 void SWkeWebkit::OnPaint(IRenderTarget *pRT)
 {
     CRect rcClip;
     pRT->GetClipBox(&rcClip);
     CRect rcClient;
     GetClientRect(&rcClient);
     CRect rcInvalid;
     rcInvalid.IntersectRect(&rcClip,&rcClient);
     HDC hdc=pRT->GetDC();
     m_pWebView->paint(hdc,rcInvalid.left,rcInvalid.top,rcInvalid.Width(),rcInvalid.Height(),rcInvalid.left-rcClient.left,rcInvalid.top-rcClient.top,true);
     pRT->ReleaseDC(hdc);
 }
static BOOL IsRectOnSingleMonitor(const CRect& rect)
{
	const HMONITOR monitor = MonitorFromPoint(rect.TopLeft(), MONITOR_DEFAULTTONULL);	// Find monitor from top left of rect
	MONITORINFO info;
	info.cbSize = sizeof(info);

	if (!monitor || !GetMonitorInfo(monitor, &info))		// Get monitor's info
		return false;										// fail if not on monitor or no info

	CRect intersection;
	intersection.IntersectRect(&info.rcMonitor, &rect);		// Calculate intersection between rect and monitor
	return intersection == rect;							// rect is fully on monitor iff intersection of rect and monitor is rect
}
Example #19
0
void COleIPFrameWnd::RecalcLayout(BOOL /*bNotify*/)
{
	ASSERT_VALID(this);

	// better have a parent window (only used for inplace)
	CWnd* pParentWnd = GetParent();
	ASSERT_VALID(pParentWnd);

	// first call reposition bars with arbitarily large rect just to
	//  see how much space the bars will take up
	CRect rectBig(0, 0, INT_MAX/2, INT_MAX/2);
	CRect rectLeft;
	RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, reposQuery,
		&rectLeft, &rectBig);

	// grow the rect by the size of the control bars
	CRect rect = m_rectPos;
	rect.left -= rectLeft.left;
	rect.top -= rectLeft.top;
	rect.right += INT_MAX/2 - rectLeft.right;
	rect.bottom += INT_MAX/2 - rectLeft.bottom;

	// see how much extra space for non-client areas (such as scrollbars)
	//  that the view needs.
	CWnd* pLeftOver = GetDlgItem(AFX_IDW_PANE_FIRST);
	if (pLeftOver != NULL)
	{
		rectBig = m_rectPos;
		pLeftOver->CalcWindowRect(&rectBig, CWnd::adjustOutside);
		rect.left -= m_rectPos.left - rectBig.left;
		rect.top -= m_rectPos.top - rectBig.top;
		rect.right += rectBig.right - m_rectPos.right;
		rect.bottom += rectBig.bottom - m_rectPos.bottom;
	}

	// adjust for non-client area on the frame window
	CalcWindowRect(&rect, CWnd::adjustOutside);

	// the frame window must be clipped to the visible part in the container
	CRect rectVis;
	rectVis.IntersectRect(&rect, &m_rectClip);

	// move the window
	AfxRepositionWindow(NULL, m_hWnd, &rectVis);

	// now resize the control bars relative to the (now moved) frame
	pParentWnd->ClientToScreen(&rect);
	ScreenToClient(&rect);
	RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST,
		CWnd::reposDefault, NULL, &rect);
}
Example #20
0
//-----------------------------------------------------------------------------
// Draws the chart
//-----------------------------------------------------------------------------
void	CXYChart::OnDraw( CDC *pDC, CRect destRect, CRect updateRect )
{
	CString			string;
	int				i;
	CAxis			*axis;
	CSize			axisDims;
	CSize			trim(0,0);
	CRect			plotRect, normalPlotRect, normalDestRect;
	double			xRange[] = {1e30, -1e30}, yRange[]={1e30,-1e30};

	updateRect.NormalizeRect();

	normalDestRect = destRect;

	// Check to see that we are even in the update region
	normalDestRect.NormalizeRect();
	normalDestRect.IntersectRect( normalDestRect, updateRect );
	if( normalDestRect.IsRectEmpty() ) return;

	// Make sure our ranges are set
	// Get ranges for plotting
	GetPlotRange( xRange, yRange );

	// Get the size of our plotting rectangle
	plotRect = GetPlotRect( pDC, destRect );

	// Draw the basic structures for the plot
	DrawPlotBasics( pDC, destRect, plotRect );

	// Draw the title
	DrawPlotTitle( pDC, destRect, plotRect );

	normalPlotRect = plotRect;
	normalPlotRect.NormalizeRect();
	updateRect.IntersectRect( updateRect, normalPlotRect );

	if( updateRect.IsRectEmpty() == FALSE )
	{
		// Draw each data set
		DrawDataSet( pDC, plotRect, xRange, yRange );
	}

	// Draw the axes
	for( i = 0; i < m_AxisCount; i++ )
	{
		axis = m_Axes[i];
		axis->OnDraw( pDC, destRect, plotRect );
	}

	CChart::OnDraw( pDC, destRect );
}
Example #21
0
void CWordPadApp::LoadOptions()
{
	BYTE* pb = NULL;
	UINT nLen = 0;

	HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
	if (hFont == NULL)
		hFont = (HFONT)GetStockObject(ANSI_VAR_FONT);
	VERIFY(::GetObject(hFont, sizeof(LOGFONT), &m_lf));

	m_bWordSel = GetProfileInt(szSection, szWordSel, TRUE);
	TCHAR buf[2];
	buf[0] = NULL;
	GetLocaleInfo(GetUserDefaultLCID(), LOCALE_IMEASURE, buf, 2);
	int nDefUnits = buf[0] == '1' ? 0 : 1;
	SetUnits(GetProfileInt(szSection, szUnits, nDefUnits));
	m_bMaximized = GetProfileInt(szSection, szMaximized, (int)FALSE);

	if (GetProfileBinary(szSection, szFrameRect, &pb, &nLen))
	{
		ASSERT(nLen == sizeof(CRect));
		memcpy(&m_rectInitialFrame, pb, sizeof(CRect));
		delete pb;
	}
	else
		m_rectInitialFrame.SetRect(0,0,0,0);

	CRect rectScreen(0, 0, GetSystemMetrics(SM_CXSCREEN),
		GetSystemMetrics(SM_CYSCREEN));
	CRect rectInt;
	rectInt.IntersectRect(&rectScreen, &m_rectInitialFrame);
	if (rectInt.Width() < 10 || rectInt.Height() < 10)
		m_rectInitialFrame.SetRect(0, 0, 0, 0);

	if (GetProfileBinary(szSection, szPageMargin, &pb, &nLen))
	{
		ASSERT(nLen == sizeof(CRect));
		memcpy(&m_rectPageMargin, pb, sizeof(CRect));
		delete pb;
	}
	else
		m_rectPageMargin.SetRect(1800, 1440, 1800, 1440);

	m_optionsText.LoadOptions(szTextSection);
	m_optionsRTF.LoadOptions(szRTFSection);
	m_optionsWord.LoadOptions(szWordSection);
	m_optionsWrite.LoadOptions(szWriteSection);
	m_optionsIP.LoadOptions(szIPSection);
}
Example #22
0
// ----------------------------------------------------------------------- //
//
//	ROUTINE:	CLTWnd::DrawToSurface
//
//	PURPOSE:	Does the dirty work for drawing a single window to a surface
//
// ----------------------------------------------------------------------- //
BOOL CLTWnd::DrawToSurface(HSURFACE hSurfDest)
{
	// We don't draw the main window (the only one without a parent)
	if (m_pParentWnd)
	{
		CRect	rcSurf;
		GetSurfaceRect(&rcSurf);

		CRect	rcClip;
		GetClipRect(&rcClip);

		CRect	rcSource;

		// check for intersection of the clip area and the surface
		if (rcSource.IntersectRect(rcSurf, rcClip))
		{
			// retain the absolute coordinates of the intersection relative to the main drawing window
			CPoint	ptIntersect = rcSource.TopLeft();

			// normalize coordinates relative to child surface
			rcSource -= rcSurf.TopLeft();

			// create a lithtech-compatible rect
            LTRect   drcSource;

			drcSource.left = rcSource.left;
			drcSource.top = rcSource.top;
			drcSource.right = rcSource.right;
			drcSource.bottom = rcSource.bottom;

			// draw the surface
			if (m_hSurf)
			{
				if (IsFlagSet(LTWF_TRANSPARENT))
				{
                    if(g_pLTClient->DrawSurfaceToSurfaceTransparent(hSurfDest,m_hSurf, &drcSource, ptIntersect.x, ptIntersect.y, m_hColorTransparent) != LT_OK)
						return FALSE;
				}
				else
				{
                    if(g_pLTClient->DrawSurfaceToSurface(hSurfDest, m_hSurf, &drcSource, ptIntersect.x, ptIntersect.y) != LT_OK)
						return FALSE;
				}
			}
		}
	}
	return TRUE;
}
void CTextObject::_OnTextRequestResizeNotify(REQRESIZE* pReqResize)
{
	if (m_pDrawCanvas->IsCapture())
	{
		return;
	}
	//want size is device unit
	FTLASSERT(pReqResize->rc.bottom > pReqResize->rc.top);
	CRect rcWantRect = pReqResize->rc;
	m_pDrawCanvas->ClientToDoc(&rcWantRect);
	int nWantHeight = rcWantRect.Height() + RTPANEL_MARGIN_TOP + RTPANEL_MARGIN_BOTTOM;

	CSize szMin = m_pShareEditPtr->GetMinBoundSize(RTPANEL_MIN_ROW_COUNT, RTPANEL_MIN_COL_COUNT);
	if (nWantHeight < szMin.cy )
	{
		nWantHeight = szMin.cy;
	}
	BOOL bWillSetBound = FALSE;
	CRect rcPosition = m_position;
	rcPosition.NormalizeRect();

	//if (!rcTarget.IsRectEmpty())
	{
		int nOldHeight = FTL_ABS(rcPosition.Height());
		if ( nWantHeight > nOldHeight)
		{
			rcPosition.bottom = rcPosition.top + nWantHeight;
			bWillSetBound = TRUE;
		}

		int nOldWidth = FTL_ABS(rcPosition.Width());
		if (szMin.cx > nOldWidth)
		{
			rcPosition.right = rcPosition.left + szMin.cx;
			bWillSetBound = TRUE;
		}
	}
	CRect rcDrawTarget = m_pDrawCanvas->GetDrawTarget();
	rcDrawTarget.OffsetRect(-rcDrawTarget.TopLeft());

	rcPosition.IntersectRect(rcPosition, rcDrawTarget);
	if (rcPosition != m_position && bWillSetBound)
	{
		m_position = rcPosition;
		m_pShareEditPtr->SetClientBound(m_position, NULL, TRUE);
		m_pDrawCanvas->InvalObject(this);
	}
}
Example #24
0
void SListBoxEx::RedrawItem(int iItem)
{
    if(!IsVisible(TRUE)) return;
    CRect rcClient;
    GetClientRect(&rcClient);
    CRect rcItem=GetItemRect(iItem);
    CRect rcInter;
    rcInter.IntersectRect(&rcClient,&rcItem);
    if(rcInter.IsRectEmpty()) return;

    IRenderTarget * pRT=GetRenderTarget(&rcItem,OLEDC_PAINTBKGND);

    SSendMessage(WM_ERASEBKGND,(WPARAM)pRT);
    DrawItem(pRT,rcItem,iItem);

    ReleaseRenderTarget(pRT);
}
Example #25
0
void CTrackerView::OnLButtonDown(UINT nFlags, CPoint point)
{
	CTrackerDoc* pDoc = GetDocument();
	CRect rectSave;
	pDoc->m_tracker.GetTrueRect(rectSave);
	if (pDoc->m_tracker.HitTest(point) < 0)
	{
		// just to demonstrate CRectTracker::TrackRubberBand
		CRectTracker tracker;
		if (tracker.TrackRubberBand(this, point, pDoc->m_bAllowInvert))
		{
			MessageBeep(0); // beep indicates TRUE

			// see if rubber band intersects with the doc's tracker
			CRect rectT;
			tracker.m_rect.NormalizeRect(); // so intersect rect works
			if (rectT.IntersectRect(tracker.m_rect, pDoc->m_tracker.m_rect))
			{
				// if so, put resize handles on it (ie. select it)
				if (pDoc->m_tracker.m_nStyle & CRectTracker::resizeInside)
				{
					// swap from resize inside to resize outside for effect
					pDoc->m_tracker.m_nStyle &= ~CRectTracker::resizeInside;
					pDoc->m_tracker.m_nStyle |= CRectTracker::resizeOutside;
				}
				else
				{
					// just use inside resize handles on first time
					pDoc->m_tracker.m_nStyle &= ~CRectTracker::resizeOutside;
					pDoc->m_tracker.m_nStyle |= CRectTracker::resizeInside;
				}
				pDoc->SetModifiedFlag();
				pDoc->UpdateAllViews(NULL, (LPARAM)(LPCRECT)rectSave);
				pDoc->UpdateAllViews(NULL);
			}
		}
	}
	else if (pDoc->m_tracker.Track(this, point, pDoc->m_bAllowInvert))
	{
		// normal tracking action, when tracker is "hit"
		pDoc->SetModifiedFlag();
		pDoc->UpdateAllViews(NULL, (LPARAM)(LPCRECT)rectSave);
		pDoc->UpdateAllViews(NULL);
	}
	CView::OnLButtonDown(nFlags, point);
}
Example #26
0
void SourceEdit::MoveShowSelect(CWnd* child)
{
  // Get the screen position of the selected word
  CRect wordR = GetSelectRect();

  // Get the size and position of the dialog
  CRect wndR;
  child->GetWindowRect(wndR);

  CRect extWndR;
  if (theOS.DwmGetWindowAttribute(child,
    DWMWA_EXTENDED_FRAME_BOUNDS,(LPRECT)extWndR,sizeof (RECT)))
  {
    // If Aero Glass or similar means that the windows frame extends
    // beyond the window bounds, work out by how much, and make sure that
    // the window is moved to avoid overlap by the extended frame.
    wordR.InflateRect(
      (extWndR.Width()-wndR.Width())/2,(extWndR.Height()-wndR.Height())/2);
  }

  // If the dialog is over the word, move it
  CRect intersectR;
  if (intersectR.IntersectRect(wordR,wndR))
  {
    // Get the size of the display
    MONITORINFO monInfo;
    ::ZeroMemory(&monInfo,sizeof monInfo);
    monInfo.cbSize = sizeof monInfo;
    HMONITOR mon = ::MonitorFromWindow(child->GetSafeHwnd(),MONITOR_DEFAULTTOPRIMARY);
    ::GetMonitorInfo(mon,&monInfo);

    // Try moving the dialog, but keep it on-screen
    if (wordR.top-wndR.Height() >= 0)
    {
      child->SetWindowPos(&CWnd::wndTop,wndR.left,wordR.top-wndR.Height(),0,0,
        SWP_NOOWNERZORDER|SWP_NOZORDER|SWP_NOSIZE);
    }
    else if (wordR.bottom+wndR.Height() < monInfo.rcWork.bottom)
    {
      child->SetWindowPos(&CWnd::wndTop,wndR.left,wordR.bottom,0,0,
        SWP_NOOWNERZORDER|SWP_NOZORDER|SWP_NOSIZE);
    }
  }
}
Example #27
0
 void SWkeWebkit::OnPaint(IRenderTarget *pRT)
 {
     CRect rcClip;
     pRT->GetClipBox(&rcClip);
     CRect rcClient;
     GetClientRect(&rcClient);
     CRect rcInvalid;
     rcInvalid.IntersectRect(&rcClip,&rcClient);
     HDC hdc=pRT->GetDC();
     if(GetStyle().m_byAlpha!=0xff)
     {
         BLENDFUNCTION bf={AC_SRC_OVER,0,GetStyle().m_byAlpha,AC_SRC_ALPHA };
         AlphaBlend(hdc,rcInvalid.left,rcInvalid.top,rcInvalid.Width(),rcInvalid.Height(),m_pWebView->getViewDC(),rcInvalid.left-rcClient.left,rcInvalid.top-rcClient.top,rcInvalid.Width(),rcInvalid.Height(),bf);
     }else
     {
         BitBlt(hdc,rcInvalid.left,rcInvalid.top,rcInvalid.Width(),rcInvalid.Height(),m_pWebView->getViewDC(),rcInvalid.left-rcClient.left,rcInvalid.top-rcClient.top,SRCCOPY);            
     }
     pRT->ReleaseDC(hdc);
 }
Example #28
0
void RichEditBkImg::DrawObject(IRenderTarget * pRT)
{
    if (m_bDirty)
    {
        // 等所依赖的前一个/后一个兄弟节点先更新位置信息完毕
        CalcPosition(m_itemPos, m_nPosCount);
    }

    CRect rcHost = m_pObjectHost->GetHostRect();
    CRect rcTemp = rcHost;
    if (rcHost.IntersectRect(m_rcObj,rcTemp))
    {    
        SSkinImgFrame * pSkin = ImageProvider::GetImage(m_strSource);
        if (pSkin)
        { 
            pSkin->Draw(pRT, m_rcObj, 0);
        }
    }
}
void CXTPCustomizeToolbarsPageCheckListBox::PreDrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	DRAWITEMSTRUCT drawItem;
	memcpy(&drawItem, lpDrawItemStruct, sizeof(DRAWITEMSTRUCT));

	if ((((LONG)drawItem.itemID) >= 0) &&
		((drawItem.itemAction & (ODA_DRAWENTIRE | ODA_SELECT)) != 0))
	{
		int cyItem = GetItemHeight(drawItem.itemID);

		CDC* pDC = CDC::FromHandle(drawItem.hDC);

		int nCheck = GetCheck(drawItem.itemID);

		CRect rectCheck = drawItem.rcItem;
		rectCheck.left += 1;
		rectCheck.top += 1 + max(0, (cyItem - m_sizeCheck.cy) / 2);
		rectCheck.right = rectCheck.left + m_sizeCheck.cx;
		rectCheck.bottom = rectCheck.top + m_sizeCheck.cy;

		CRect rectItem = drawItem.rcItem;
		rectItem.right = rectItem.left + m_sizeCheck.cx + 2;
		CRect rectCheckBox = OnGetCheckPosition(rectItem, rectCheck);

		if (m_themeHelper.IsAppThemeReady())
		{
			m_themeHelper.DrawThemeBackground(pDC->m_hDC, BP_CHECKBOX,
				nCheck ? CBS_CHECKEDNORMAL : CBS_UNCHECKEDNORMAL, &rectCheckBox, NULL);
		}
		else
		{
			ASSERT(rectCheck.IntersectRect(rectItem, rectCheckBox));
			ASSERT((rectCheck == rectCheckBox) && (rectCheckBox.Size() == m_sizeCheck));

			pDC->DrawFrameControl(rectCheckBox, DFC_BUTTON, DFCS_BUTTONCHECK | (nCheck ? DFCS_CHECKED : 0));
		}
	}

	drawItem.rcItem.left = drawItem.rcItem.left + m_sizeCheck.cx + 3;

	DrawItem(&drawItem);
}
Example #30
0
BOOL COleClientItem::OnChangeItemPosition(const CRect& rectPos)
{
	if (!IsInPlaceActive())
		return FALSE;

	ASSERT_VALID(this);
	ASSERT(AfxIsValidAddress(&rectPos, sizeof(CRect), FALSE));
	ASSERT_VALID(m_pView);

	// determine the visible rect based on intersection between client rect
	CRect clipRect;
	OnGetClipRect(clipRect);
	CRect visRect;
	visRect.IntersectRect(clipRect, rectPos);

	// advise the server of the new visible rectangle
	if (!visRect.IsRectEmpty())
		return SetItemRects(&rectPos, &clipRect);

	return FALSE;
}