Exemplo n.º 1
0
LRESULT CDComView::OnDocUpdate(WPARAM nNumNewLinesCleared, LPARAM)
{
    CRect rcClient;
    CPoint ptScroll;
    CDComDoc *pDoc;
    CMainFrame *pMainFrm = (CMainFrame *)AfxGetMainWnd();
    if (pMainFrm)
    {
        m_sizeCharDimensions = pMainFrm->GetLineDimentions("a", 1);
    }

    pDoc = GetDocument();
    if (pDoc)
    {
        pDoc->m_cLineBuffer.Enter();
        ptScroll = GetDeviceScrollPosition();

        if ((nNumNewLinesCleared) && (IsScrollBarAtBottom() == false))
        {
            ptScroll.y -= m_sizeCharDimensions.cy * nNumNewLinesCleared;
            ScrollToPosition(ptScroll);
        }
        GetClientRect(&rcClient);

        SetCaretPos(ptScroll, rcClient);
        SetScrollSizes();
        pDoc->m_cLineBuffer.Exit();
    }
    return 0;
}
Exemplo n.º 2
0
void CPrime95View::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
	CFrameWnd *parent;
	CSize	sz;
	CPoint	pos;
	int	new_scroll_height, new_scroll_width;

	parent = GetParentFrame();

	if (parent != NULL) {

		if (charHeight == 0) getCharSize ();

		sz = GetTotalSize ();

		new_scroll_height = NumLines * charHeight;
		new_scroll_width = MaxLineSize * charWidth;

		pos = GetScrollPosition ();
		pos.y += (new_scroll_height - sz.cy);
		if (pos.y < 0) pos.y = 0;
		sz.cx = new_scroll_width;
		sz.cy = new_scroll_height;
		SetScrollSizes (MM_TEXT, sz);
		ScrollToPosition (pos);
		parent->RecalcLayout ();
	}

	CScrollView::OnUpdate (pSender, lHint, pHint);
}
Exemplo n.º 3
0
void CEx29aView::OnUpdate(CView*, LPARAM lHint, CObject* pHint)
{
    // called when the user executes a new query
    // can't set m_pSet in OnInitialUpdate because it's NULL then
    ScrollToPosition(CPoint(0, 0));
    Invalidate(TRUE);
    m_nSelectedRow = -1;
    CEx29aDoc* pDoc = GetDocument();
    if((m_pSet = pDoc->m_pRecordset) != NULL) {
        UpdateScrollSizes();
    }
}
Exemplo n.º 4
0
/******************************************************************************
  Function Name    :  vGoToLine

  Input(s)         :  UINT unLineNo
  Output           :  -
  Functionality    :  Scrolls to the line number specified
  Member of        :  CFileView
  Friend of        :      -

  Author(s)        :  Amarnath Shastry
  Date Created     :  05.03.2002
******************************************************************************/
void CFileView::vGoToLine(UINT unLineNo)
{
    // calculate the x and y points relative to the line number
    POINT Point = {INT_INIT,INT_INIT};
    // Get client rectangle
    CRect Rectangle(INT_INIT,INT_INIT,INT_INIT,INT_INIT);
    GetClientRect(&Rectangle);
    // Update point specs
    Point.x = INT_INIT;
    Point.y = unLineNo * m_nCharHeight - Rectangle.Height() / 2;
    // Scroll to the postion
    ScrollToPosition(Point);
}
Exemplo n.º 5
0
void
CPhylogenView::SetSelected(int Selection, int CheckScroll )
{
    CGenedocDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    m_LastKeySelect = Selection;
    CPhyloGenBase * pPGB;

    POSITION Pos;
    Pos = pDoc->m_pPGBase->m_PhyloList.GetHeadPosition();
    while ( Pos != NULL ) {
        pPGB = (CPhyloGenBase *)pDoc->m_pPGBase->m_PhyloList.GetNext(Pos);
        if ( !Selection-- ) break;
    }
    CDC* pDC = GetDC();

    CRect fRect = pPGB->m_ClientRect;

    if ( CheckScroll ) {

        // Check if Scroll Call need to be made.
        CRect tRect ( m_ScrollPos, m_ViewSize );
        CPoint Position1 = fRect.TopLeft();
        Position1.x = 0;
        CPoint Position2 = fRect.BottomRight();
        Position2.x = 0;

        if ( (!tRect.PtInRect ( Position1 )) || (!tRect.PtInRect ( Position2 )) ) {
            CPoint tPos = m_ScrollPos;
            int YPos = Position1.y;
            if ( (YPos - (m_ViewSize.cy / 2)) < 0 ) {
                YPos = 0;
            } else {
                YPos = (YPos - (m_ViewSize.cy / 2));
            }
            tPos.y = YPos < (m_MaxScrolls.cy - m_ViewSize.cy) ? YPos: (m_MaxScrolls.cy - m_ViewSize.cy);
            tPos.x = Position1.x < (m_MaxScrolls.cx - m_ViewSize.cx) ? Position1.x: (m_MaxScrolls.cx - m_ViewSize.cx);
            ScrollToPosition ( tPos );
            m_ScrollPos = GetScrollPosition();
        }
    }

    CClientDC dc(this);
    OnPrepareDC(&dc);
    pPGB->m_Selected = 1;
    dc.LPtoDP( &fRect );
    pDC->DrawFocusRect( fRect );
    ReleaseDC( pDC );

}
Exemplo n.º 6
0
bool CMixereView::SetInfo(const CMixerInfo& Info)
{
	CWaitCursor	wc;
	m_MSFadeBar.SetInfo(Info.m_MSFade);	// before creating channels
	// set the column widths
	int	cols = Info.m_ColumnWidth.GetSize();
	for (int i = 0; i < cols; i++)
		SetColumnWidth(i, Info.m_ColumnWidth[i]);
	// set the channel count
	int	chans = Info.m_Chan.GetSize();
	if (SetItemCount(chans) < chans)	// if create failed, bail out
		return(FALSE);
	// set the mixer controls
	CStringArray	ErrPath;
	for (i = 0; i < chans; i++) {
		if (!GetChan(i)->OpenItem(&Info.m_Chan[i]))		// if can't load audio file
			AddStringUnique(ErrPath, Info.m_Chan[i].m_Path);	// add its path to list
	}
	// if audio files couldn't be loaded, display error message
	if (ErrPath.GetSize())
		MsgBoxStrList(LDS(CANT_LOAD_AUDIO), ErrPath);
	m_VolumeBar.SetInfo(Info.m_AutoVol);
	m_TempoBar.SetInfo(Info.m_AutoTempo);
	m_ChanDefaults = Info.m_ChanDefaults;
	m_ChanIDs = Info.m_ChanIDs;
	// redraw channels all at once, looks and sounds better
	for (i = 0; i < chans; i++)
		GetChan(i)->SetInfo(&Info.m_Chan[i]);
	ScrollToPosition(CPoint(0, 0));
	ClearSelection();
	SetCurPos(0);
	ClearUndoHistory();
	// restore our bar state
	if (CMainFrame::VerifyDockState(Info.m_DockState, m_ChildFrm))
		m_ChildFrm->SetDockState(Info.m_DockState);
	// restoring bar state enables bar tool tips; reapply our tip state
	for (i = 0; i < DLGBARS; i++)
		m_DlgBar[i]->EnableToolTips(m_HasToolTips);
	// attach to snapshot object and update our snapshot bar
	m_Snapshot = const_cast<CSnapshot *>(&Info.m_Snapshot);
	m_Snapshot->SetMixer(this);
	m_Snapshot->UpdateList();
	// enable status bar panes as needed; see note in CColorStatusBar::Reset
	CColorStatusBar	*csb = ((CMainFrame *)AfxGetMainWnd())->GetStatusBar();
	if (GetMuteCount())
		csb->EnablePane(CMainFrame::SBP_MUTE);
	if (GetSoloCount())
		csb->EnablePane(CMainFrame::SBP_SOLO);
	return(TRUE);
}
Exemplo n.º 7
0
void TextView::Smeg(BOOL fAdvancing)
{
	m_pTextDoc->init_linebuffer();

	m_nLineCount   = m_pTextDoc->linecount();

	UpdateMetrics();
	UpdateMarginWidth();
	SetupScrollbars();

	UpdateCaretOffset(m_nCursorOffset, fAdvancing, &m_nCaretPosX, &m_nCurrentLine);
	
	m_nAnchorPosX = m_nCaretPosX;
	ScrollToPosition(m_nCaretPosX, m_nCurrentLine);
	RepositionCaret();
}
Exemplo n.º 8
0
void CAutoPFAView::ZoomScrollSizes(const CRect &rc,BOOL bFit )//调整窗口可视区域使得大小和rc相当
{
	CRect rcView;
	GetClientRect(&rcView);
	CSize szTol(rc.Size());
	CPoint Org(rc.left,rc.top);
	CSize szDoc;
	double dDocX;
	double dDocY;
    szDoc = GetTotalSize();
    dDocX = szDoc.cx / m_Scale;
	dDocY = szDoc.cy / m_Scale;
	if(bFit)
	{
		if(szTol.cx<rcView.Size().cx)
		{
			szTol.cx = rcView.Size().cx;
		}
		if(szTol.cy<rcView.Size().cy)
		{
			szTol.cy = rcView.Size().cy;
		}
	}
    float x= float(rcView.Size().cx)/(szTol.cx);
    float y= float(rcView.Size().cy)/(szTol.cy);
	if(x>y)
		m_Scale = y;
	else
        m_Scale = x;
	
	szDoc.cx = m_Scale * dDocX;
	szDoc.cy = m_Scale * dDocY;
	if(szDoc.cx <= rcView.Size().cx)
	{
		Org.x = 0;
	}
	if(szDoc.cy <= rcView.Size().cy)
	{
		Org.y = 0;
	}
	Org.x = m_Scale* (Org.x);
    Org.y = m_Scale* (Org.y);
	SetScrollSizes(MM_TEXT,szDoc);
	ScrollToPosition(Org);
	Invalidate();
}
Exemplo n.º 9
0
void CTestTaskView::OnMouseMove(UINT flags, CPoint point)
{
	if (GetCapture() == this)
	{
		CPoint tmp = GetDeviceScrollPosition();
		CPoint buff = _end - tmp;
		_end = point;

		CRect rect;
		GetWindowRect(&rect);

		CPoint vec = CPoint(0, 0);
		if ((_end.x > (rect.right - rect.left) || _end.x < 0) || (_end.y >(rect.bottom - rect.top) || _end.y < 0))
		{
			CPoint the_line = _end - _previous;
			if (_end.x > (rect.right - rect.left) || _end.x < 0)
			{
				if (the_line.y < 0)
					vec = CPoint(0, -1);
				else
					vec = CPoint(0, 1);
			}
			else if (_end.y > (rect.bottom - rect.top) || _end.y < 0)
			{
				if (the_line.x > 0)
					vec = CPoint(1, 0);
				else
					vec = CPoint(-1, 0);
			}

			double alpha = acos((double)(walter::scalar_multiplication(the_line, vec) /
				(walter::length(the_line) * walter::length(vec))));

			CPoint shift_scroll = walter::const_multiplication(the_line, cos(alpha));

			if (shift_scroll != CPoint(0, 0))
			{
				walter::normalize(shift_scroll);
				ScrollToPosition(GetScrollPosition() + shift_scroll);
			}
		}
		
		_end += tmp;
		Invalidate();
	}
}
Exemplo n.º 10
0
/* 
 *	Handle mouse move
 */
void CFMView::OnMouseMove(UINT nFlags, CPoint point)
{
	if (m_iViewSize == FIT_SCREEN)
		return;

	// Start the panning operation
	if (m_bMouseDown == true)
	{
		SetCursor(LoadCursor(NULL, IDC_SIZEALL));

		// Update the origin of the image
        m_xyOrigin.iX	= m_xyOrigin.iX + point.x - m_xyLCoord.iX;
		m_xyOrigin.iY	= m_xyOrigin.iY + point.y - m_xyLCoord.iY;

		// Handle the case that the coordinate beyond the valid value.
		if (m_xyOrigin.iX < 0)	m_xyOrigin.iX = 0;
		if (m_xyOrigin.iY < 0)	m_xyOrigin.iY = 0;

		// Get the pointer to the CLiDARImage object
		CFMDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);
		if (!pDoc)
			return;

		CFMImage * pImage = pDoc->GetImage();
		if (pImage == NULL)
			return;

		if (m_xyOrigin.iX > pImage->GetWidth())		m_xyOrigin.iX = pImage->GetWidth();
		if (m_xyOrigin.iY > pImage->GetHeight())	m_xyOrigin.iY = pImage->GetHeight();
	
		// Set the scroll bar position
		POINT ptOrigin;
		ptOrigin.x = m_xyOrigin.iX;
		ptOrigin.y = m_xyOrigin.iY;

		// Adjust the scroll bar to the new position
		ScrollToPosition(ptOrigin);
		SetScrollPos(SB_HORZ, ptOrigin.x, TRUE);
		SetScrollPos(SB_VERT, ptOrigin.y, TRUE);
	}
}
Exemplo n.º 11
0
void SkeinWindow::SkeinShowNode(Skein::Node* node, Skein::Show why)
{
  if (GetSafeHwnd() == 0)
    return;

  switch (why)
  {
  case Skein::JustShow:
  case Skein::ShowSelect:
  case Skein::ShowNewLine:
    {
      // Work out the position of the node
      int x = (GetTotalSize().cx/2)+node->GetX();
      int y = m_fontSize.cy*((5*node->GetDepth())-1);
      if (y < 0)
        y = 0;

      // Centre the node horizontally
      CRect client;
      GetClientRect(client);
      x -= client.Width()/2;

      // Only change the co-ordinates if there are scrollbars
      BOOL horiz, vert;
      CheckScrollBars(horiz,vert);
      if (horiz == FALSE)
        x = 0;
      if (vert == FALSE)
        y = 0;

      ScrollToPosition(CPoint(x,y));
    }
    break;
  case Skein::ShowNewTranscript:
    break;
  default:
    ASSERT(FALSE);
    break;
  }
}
Exemplo n.º 12
0
LRESULT CPredView::OnFindCompound(WPARAM wParam, LPARAM lParam)
{
	//lParam=0 means the message is sent from "Find" dialog lParam=1 means the message is sent from LButtonDown without CTRL pressed. 
	//lParam=2 means the message is sent from LBUttonDown and CTRL is pressed 
	CFCCDoc* pDoc=(CFCCDoc*)GetDocument();
	if(pDoc->list_CompoundTest.IsEmpty())
		return LRESULT();
	bool flag=false;
	if(wParam==FINDNEXT)
	{
		POSITION pos;
		CCompound* pTmpCompound=NULL;
		bool bFound=false;
		pos=pDoc->list_CompoundTest.GetTailPosition();
		while(pos)
		{
			pTmpCompound=(CCompound*)pDoc->list_CompoundTest.GetAt(pos);
			if(pTmpCompound->bSelect)
				break;
			pDoc->list_CompoundTest.GetPrev(pos);
		}
		if(pos)
			pDoc->list_CompoundTest.GetNext(pos);
		if(!pos)
			pos=pDoc->list_CompoundTest.GetHeadPosition();
		while(pos)
		{
			pTmpCompound=(CCompound*)pDoc->list_CompoundTest.GetAt(pos);
			if(pTmpCompound->strCompoundName.Find(dlg.strMessage)>=0)
			{
				bFound=true;
				break;
			}
			pDoc->list_CompoundTest.GetNext(pos);
		}
		if(bFound)
		{
			int index=1;
			POSITION posa=pDoc->list_CompoundTest.GetHeadPosition();
			while(posa)
			{
				if(posa==pos)
				{
					break;
				}
				pDoc->list_CompoundTest.GetNext(posa);
				index++;
			}
			dlg.nIndex=index;
			flag=true;
			pDoc->strMessage="Matching item is found.";
			pDoc->MessageCenter(IDS_MESSAGE_FINDCOMPOUND);
		}
		else
		{
			pDoc->strMessage="No matching item is found.";
			pDoc->MessageCenter(IDS_MESSAGE_FINDCOMPOUND);
		}
	}
	if(wParam==FINDPREV)
	{
		POSITION pos;
		CCompound* pTmpCompound=NULL;
		bool bFound=false;
		pos=pDoc->list_CompoundTest.GetHeadPosition();
		while(pos)
		{
			pTmpCompound=(CCompound*)pDoc->list_CompoundTest.GetAt(pos);
			if(pTmpCompound->bSelect)
				break;
			pDoc->list_CompoundTest.GetNext(pos);
		}
		if(pos)
			pDoc->list_CompoundTest.GetPrev(pos);
		if(!pos)
			pos=pDoc->list_CompoundTest.GetHeadPosition();
		while(pos)
		{
			pTmpCompound=(CCompound*)pDoc->list_CompoundTest.GetAt(pos);
			if(pTmpCompound->strCompoundName.Find(dlg.strMessage)>=0)
			{
				bFound=true;
				break;
			}
			pDoc->list_CompoundTest.GetPrev(pos);
		}
		if(bFound)
		{
			int index=1;
			POSITION posa=pDoc->list_CompoundTest.GetHeadPosition();
			while(posa)
			{
				if(posa==pos)
				{
					break;
				}
				pDoc->list_CompoundTest.GetNext(posa);
				index++;
			}
			dlg.nIndex=index;
			flag=true;
			pDoc->strMessage="Matching item is found.";
			pDoc->MessageCenter(IDS_MESSAGE_FINDCOMPOUND);
		}
		else
		{
			pDoc->strMessage="No matching item is found.";
			pDoc->MessageCenter(IDS_MESSAGE_FINDCOMPOUND);
		}
	}
	if(wParam==GOTOPAGE)
	{
		if(dlg.nIndex<1)
			dlg.nIndex=1;
		if(dlg.nIndex>wnd_navi.nTotalPage)
			dlg.nIndex=wnd_navi.nTotalPage;
		wnd_navi.nCurPage=dlg.nIndex;
		wnd_navi.Invalidate();
		Invalidate();
		pDoc->strMessage.Format("Page No. %d",dlg.nIndex);
		pDoc->MessageCenter(IDS_MESSAGE_FINDCOMPOUND);
	}
	if(wParam==GOTOLINE || flag)
	{
		int curCol;
		int curRow;
		int subLine;
		POSITION pos;
		int nTotalLine=pDoc->list_CompoundTest.GetCount();
		if(dlg.nIndex<1)
			dlg.nIndex=1;
		if(dlg.nIndex>nTotalLine)
			dlg.nIndex=nTotalLine;
		wnd_navi.nCurPage=(dlg.nIndex-1)/(nCol*nItemPage)+1;
		subLine=dlg.nIndex-(wnd_navi.nCurPage-1)*(nCol*nItemPage);
		curCol=(subLine-1)/nItemPage+1;
		curRow=subLine-(curCol-1)*nItemPage;
		if(lParam==0)
		{
			ScrollToPosition(CPoint((curCol-1)*(80+widthCompoundName+widthYhat+widthClassName+widthID),(curRow-1)*20));
			OnHScroll(SB_LINELEFT,0,0);
			OnHScroll(SB_LINERIGHT,0,0);
			OnVScroll(SB_LINEUP,0,0);
			OnVScroll(SB_LINEDOWN,0,0);
			wnd_navi.SetWindowPos(&CWnd::wndTop,1,1,0,0,SWP_NOSIZE|SWP_SHOWWINDOW);
			wnd_navi.Invalidate();
			pDoc->strMessage.Format("Line No. %d",dlg.nIndex);
			pDoc->MessageCenter(IDS_MESSAGE_FINDCOMPOUND);
		}
		if(lParam==0 || lParam==1)
		{
			pos=pDoc->list_CompoundTest.GetHeadPosition();
			while(pos)
			{
				pCompound=pDoc->list_CompoundTest.GetNext(pos);
				((CCompound*)pCompound)->bSelect=false;
			}
		}
		/*pos=pDoc->list_CompoundTest.Find(pCompound);
		if(pos)
			((CCompound*)pCompound)->bSelect=false;*/
		pos=pDoc->list_CompoundTest.FindIndex(dlg.nIndex-1);
		pCompound=pDoc->list_CompoundTest.GetAt(pos);
		((CCompound*)pCompound)->bSelect=true;
		if(wnd_navi.nCurPage==wnd_navi.nTotalPage)
			Invalidate(1);
		else
			Invalidate(0);
	}
	
	return LRESULT();
}
Exemplo n.º 13
0
BOOL CImageView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
	// TODO: Add your message handler code here and/or call default

	if (!m_pImage || m_pImage->empty() || m_bDragImg)
	{
		return FALSE;
	}

	if (zDelta > 0 && m_idxImgDisplayScale < MAXSCALENUM)
	{
		int preShowScale = m_idxImgDisplayScale;

		m_idxImgDisplayScale++;
		Invalidate(TRUE);
		CSize sz;
		sz.cx = m_pImage->cols * ImageDisplayScales[m_idxImgDisplayScale];
		sz.cy = m_pImage->rows * ImageDisplayScales[m_idxImgDisplayScale];

		CPoint scrollPos = GetScrollPosition();
		SetScrollSizes(MM_TEXT,sz);
		CRect rectClient;
		GetClientRect(&rectClient);

		if (rectClient.Width() < sz.cx && rectClient.Height() < sz.cy)
		{
			CPoint ptCenter;

			ptCenter.x = scrollPos.x + rectClient.Width() / 2;
			ptCenter.y = scrollPos.y + rectClient.Height() / 2;
			ptCenter.x = ptCenter.x * ImageDisplayScales[m_idxImgDisplayScale] / ImageDisplayScales[preShowScale];
			ptCenter.y = ptCenter.y * ImageDisplayScales[m_idxImgDisplayScale] / ImageDisplayScales[preShowScale];
			scrollPos.x = ptCenter.x - rectClient.Width() / 2;
			scrollPos.y = ptCenter.y - rectClient.Height() / 2;

			ScrollToPosition(scrollPos);
		}
	}
	else if (zDelta < 0 && m_idxImgDisplayScale > MINSCALENUM)
	{
		int preShowScale = m_idxImgDisplayScale;

		m_idxImgDisplayScale--;
		Invalidate(TRUE);
		CSize sz;
		sz.cx = m_pImage->cols * ImageDisplayScales[m_idxImgDisplayScale];
		sz.cy = m_pImage->rows * ImageDisplayScales[m_idxImgDisplayScale];

		CPoint scrollPos = GetScrollPosition();
		SetScrollSizes(MM_TEXT,sz);
		CRect rectClient;
		GetClientRect(&rectClient);

		if (rectClient.Width() < sz.cx && rectClient.Height() < sz.cy)
		{
			CPoint ptCenter;

			ptCenter.x = scrollPos.x + rectClient.Width() / 2;
			ptCenter.y = scrollPos.y + rectClient.Height() / 2;
			ptCenter.x = ptCenter.x * ImageDisplayScales[m_idxImgDisplayScale] / ImageDisplayScales[preShowScale];
			ptCenter.y = ptCenter.y * ImageDisplayScales[m_idxImgDisplayScale] / ImageDisplayScales[preShowScale];
			scrollPos.x = ptCenter.x - rectClient.Width() / 2;
			scrollPos.y = ptCenter.y - rectClient.Height() / 2;

			ScrollToPosition(scrollPos);
		}
	}

	CString strTmp;
	strTmp.Format("SCALE:%lf", ImageDisplayScales[m_idxImgDisplayScale]);
	CMFCStatusBar * pStaBar;
	pStaBar = (CMFCStatusBar *)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_STATUS_BAR);
	pStaBar->SetPaneText(1,strTmp);

	return TRUE;

	//return CScrollView::OnMouseWheel(nFlags, zDelta, pt);
}
DROPEFFECT EventSheetEditor::OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
    /// Update Key States
    m_CtrlDown = false;
    m_ShiftDown = false;

    if(dwKeyState & MK_CONTROL)
        m_CtrlDown = true;

    if(dwKeyState & MK_SHIFT)
        m_ShiftDown = true;

    m_Drag.CtrlDown = m_CtrlDown;

    DROPEFFECT de = m_pDDMgr->OnDragOver(pDataObject, dwKeyState, point);

    // DRAG INFO
    m_Drag.dragtype = -1;
    m_Drag.IsDragging = false;
    CString csF = m_pDDMgr->AvailableDataType(pDataObject);
    if (csF == "Construct Events") m_Drag.dragtype = EVENT;
    if (csF == "Construct Conditions") m_Drag.dragtype = CONDITION;
    if (csF == "Construct Actions") m_Drag.dragtype = ACTION;
    if (csF == "Construct Object") m_Drag.dragtype = OBJECT;
    if(m_Drag.dragtype != -1)
        m_Drag.IsDragging = true;
    // DRAG INFO END

    if(m_Mouse.y != point.y)
        m_Drag.GoingUp = point.y < m_Mouse.y ? true : false;

    m_Mouse = point;
    Invalidate();

    switch (m_Drag.dragtype)
    {
    case EVENT:
    {
        // Mouse is over an event
        CEditorEvent* tmpEvent = EventAt(m_Mouse);

        if(tmpEvent == 0 )
            return false;

        // If we arn't holding control, dont let them hover over something selected!
        if(!m_CtrlDown)
            if(tmpEvent->m_select(this))
                return false;

        //CRect Rect = tmpEvent->m_handle(this);
        //Rect.left = tmpEvent->m_rect(this).left;
        //Rect.bottom = tmpEvent->m_rect(this).bottom;
        //if(!Rect.PtInRect(point))
        //	return false;
    }
    break;

    case CONDITION:
    {
        CEditorEvent* tmpEvent = EventAt(m_Mouse);
        if(tmpEvent == 0 )
            return false;
        if(tmpEvent->m_type == 1 )
            return false; // Type doesn't accept draggin

        CEditorCondition* tmpCondition = tmpEvent->conditionAt(m_Mouse, this);

        // If we arn't holding control, dont let them hover over something selected!
        if(!m_CtrlDown)
            if(tmpCondition)
                if(tmpCondition->m_select(this))
                    return false;

        /*		CRect Rect = tmpEvent->m_handle;
        		Rect.bottom = tmpEvent->m_rect.bottom;
        		if(tmpCondition)
        		{
        			Rect = tmpCondition->m_rect;
        			if(!Rect.PtInRect(point))
        				return false;
        		}*/

    }
    break;

    case ACTION:
    {
        CEditorEvent* tmpEvent = EventAt(m_Mouse);
        if(tmpEvent == 0 )
            return false;
        if(tmpEvent->m_type == 1 )
            return false; // Type doesn't accept draggin

        CEditorAction* tmpAction = tmpEvent->actionAt(m_Mouse, this);

        // If we arn't holding control, dont let them hover over something selected!
        if(!m_CtrlDown)
            if(tmpAction)
                if(tmpAction->m_select(this))
                    return false;

        CRect Rect = tmpEvent->m_handle(this);
        Rect.bottom = tmpEvent->m_rect(this).bottom;
    }
    break;
    case OBJECT:
    {
        if(!m_pHeader->m_rect.PtInRect(m_Mouse))
        {
            return false;
        }
    }
    break;
    }

    // Auto scroll

    POINT pt;
    GetCursorPos( &pt );
    RECT rect;
    GetClientRect( &rect );
    ScreenToClient( &pt );


    if ((GetTickCount() - 25) > m_lastTick) {
        POINT pt;
        GetCursorPos( &pt );
        RECT rect;
        GetClientRect( &rect );
        ClientToScreen( &rect );

        SetRedraw(0);
        if( pt.y < rect.top + 10)
            ScrollToPosition(GetScrollPosition()+CPoint(0,-10));
        else if( pt.y > rect.bottom - 10)
            ScrollToPosition(GetScrollPosition()+CPoint(0,10));
        if( pt.x < rect.left + 10)
            ScrollToPosition(GetScrollPosition()+CPoint(-10,0));
        else if( pt.x > rect.right - 10)
            ScrollToPosition(GetScrollPosition()+CPoint(10,0));
        SetRedraw();

        m_lastTick = GetTickCount();
    }
    if (m_lastTick > GetTickCount())
        m_lastTick = GetTickCount();

    // end auto scroll

    return de;
}
/*
	DoImageOperation()
*/
UINT CWallBrowserStretchView::DoImageOperation(UINT nID)
{
	CWaitCursor cursor;

	UINT nRet = GDI_ERROR;

	m_nLastOperation = nID;

	CImage* pImage = NULL;
	CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument();
	if(pDoc)
		pImage = pDoc->GetImage();
	
	if(pImage && pImage->GetWidth() > 0 && pImage->GetHeight() > 0)
	{
		BOOL bModified = FALSE;
		
		if(!UndoPush(nID))
			if(::MessageBoxResource(this->m_hWnd,MB_ICONWARNING|MB_YESNO,WALLBROWSER_PROGRAM_NAME,IDS_ERROR_UNDOSTACKFULL)==IDNO)
				return(TRUE);

		m_ImageOperation.SetImage(pImage);	

		BOOL bEraseOnInvalidate = FALSE;

		switch(nID)
		{
			// Image->Mirror
			case ID_IMAGE_MIRROR_H:
				nRet = m_ImageOperation.MirrorHorizontal();
				break;
			case ID_IMAGE_MIRROR_V:
				nRet = m_ImageOperation.MirrorVertical();
				break;
			
			// Image->Rotate
			case ID_IMAGE_ROTATE_90_LEFT:
				nRet = m_ImageOperation.Rotate90Left();
				bEraseOnInvalidate = TRUE;
				break;
			case ID_IMAGE_ROTATE_90_RIGHT:
				nRet = m_ImageOperation.Rotate90Right();
				bEraseOnInvalidate = TRUE;
				break;
			case ID_IMAGE_ROTATE_180:
				nRet = m_ImageOperation.Rotate180();
				bEraseOnInvalidate = TRUE;
				break;
			
			// Image->Deskew
			case ID_IMAGE_DESKEW:
				nRet = m_ImageOperation.Deskew();
				break;
			
			// Image->Size
			case ID_IMAGE_SIZE:
				nRet = m_ImageOperation.Size();
				bEraseOnInvalidate = TRUE;
				break;
			
			// Image->Effects
			case ID_IMAGE_POSTERIZE:
				nRet = m_ImageOperation.Posterize();
				break;
			case ID_IMAGE_MOSAIC:
				nRet = m_ImageOperation.Mosaic();
				break;
			case ID_IMAGE_BLUR:
				nRet = m_ImageOperation.Blur();
				break;
			case ID_IMAGE_MEDIAN:
				nRet = m_ImageOperation.Median();
				break;
			case ID_IMAGE_SHARPEN:
				nRet = m_ImageOperation.Sharpen();
				break;
			case ID_IMAGE_DESPECKLE:
				nRet = m_ImageOperation.Despeckle();
				break;
			case ID_IMAGE_NOISE:
				nRet = m_ImageOperation.Noise();
				break;
			case ID_IMAGE_EMBOSS:
				nRet = m_ImageOperation.Emboss();
				break;
			case ID_IMAGE_EDGE_ENHANCE:
				nRet = m_ImageOperation.EdgeEnhance();
				break;
			case ID_IMAGE_FIND_EDGE:
				nRet = m_ImageOperation.FindEdge();
				break;
			case ID_IMAGE_EROSION:
				nRet = m_ImageOperation.Erosion();
				break;
			case ID_IMAGE_DILATE:
				nRet = m_ImageOperation.Dilate();
				break;

			case ID_COLOR_HALFTONE:
				nRet = m_ImageOperation.Halftone();
				m_bRebuildPalette = TRUE;
				break;
			case ID_COLOR_GRAYSCALE:
				nRet = m_ImageOperation.Grayscale();
				m_bRebuildPalette = TRUE;
				break;
			case ID_COLOR_INVERT:
				nRet = m_ImageOperation.Invert();
				m_bRebuildPalette = TRUE;
				break;
			case ID_COLOR_BRIGHTNESS:
				nRet = m_ImageOperation.Brightness();
				m_bRebuildPalette = TRUE;
				break;
			case ID_COLOR_CONTRAST:
				nRet = m_ImageOperation.Contrast();
				m_bRebuildPalette = TRUE;
				break;
			case ID_COLOR_HISTOGRAM_CONTRAST:
				nRet = m_ImageOperation.HistoContrast();
				m_bRebuildPalette = TRUE;
				break;
			case ID_COLOR_HUE:
				nRet = m_ImageOperation.Hue();
				m_bRebuildPalette = TRUE;
				break;
			case ID_COLOR_SATURATION_H:
				nRet = m_ImageOperation.SaturationHorizontal();
				m_bRebuildPalette = TRUE;
				break;
			case ID_COLOR_SATURATION_V:
				nRet = m_ImageOperation.SaturationVertical();
				m_bRebuildPalette = TRUE;
				break;
			case ID_COLOR_EQUALIZE:
				nRet = m_ImageOperation.Equalize();
				m_bRebuildPalette = TRUE;
				break;
			case ID_COLOR_INTENSITY:
				nRet = m_ImageOperation.Intensity();
				m_bRebuildPalette = TRUE;
				break;
			case ID_COLOR_INTENSITY_DETECT:
				nRet = m_ImageOperation.IntensityDetect();
				m_bRebuildPalette = TRUE;
				break;
			case ID_COLOR_GAMMA_CORRECTION:
				nRet = m_ImageOperation.GammaCorrection();
				m_bRebuildPalette = TRUE;
				break;
		}

		if(nRet==NO_ERROR)
		{
			bModified = TRUE;
			
			if(m_nViewType==VIEWTYPE_SCROLL)
			{
				POINT point = {0,0};
				ScrollToPosition(point);
				NotifyRanges();
			}

			Invalidate(bEraseOnInvalidate);
			
			((CWallBrowserDoc*)GetDocument())->SetModifiedFlag(TRUE);

			CWnd* pWnd = AfxGetMainWnd();
			if(pWnd)
			{
				pWnd->SendMessage(WM_FILE_SAVE_AS,TRUE,0L);
				pWnd->SendMessage(WM_FILE_SAVE,TRUE,0L);
				pWnd->SendMessage(WM_FILE_MOVE,TRUE,0L);
				pWnd->SendMessage(WM_FILE_DELETE,TRUE,0L);
			}
		}

		if(!bModified)
			UndoPop();
	}

	return(nRet);
}
Exemplo n.º 16
0
void CAutoScrollView::AutoScroll(UINT nRefMessage)
   {
   MSG   msg;             // dummmy message structure to process incoming
   // messages while autoscrolling.
   CPoint ptScrollPos,    // Current scroll position - logical units
   ptDevScrollPos, // Current scroll position - device units
   ptCursorPos;    // Current mouse cursor position
   CRect  rc; 			  // Client area
   long   dx, dy;         // Scrolling increment
   SIZE   sizeTotal,      // CScrollView scroll data
   sizePage,
   sizeLine;
   int    nMapMode,       // Mapping mode
   nMapFactor,     // Accounts for mapping mode
   xMin, xMax,
   yMin, yMax;   // Scroll range
   
   if (!m_bAutoScroll)
   return;
   
   msg.message = 0;   // forces at least one loop.
   SetCapture();
   GetDeviceScrollSizes(nMapMode, sizeTotal, sizePage, sizeLine);
   
   // We keep track of the scroll range because CScrollView::ScrollToPosition always
   // try to scroll even if the scroll limit has been reached. This results in screen
   // flickering when ScrollWindow is called.
   GetScrollRange(SB_HORZ, &xMin, &xMax);
   GetScrollRange(SB_VERT, &yMin, &yMax);
   
   // Process all messages until the relevant mouse button
   // has been released. nRefMessage depends on which button
   // has been used to trigger autoscrolling.
   //   while (msg.message != nRefMessage)
   BOOL bSawRefMessage = FALSE;
   
   while (!bSawRefMessage)
      {
      // Process incoming messages until autoscroll button is released
      
      // You cannot peek here because it may process an invalidate
      // due to the scrolling.
      
      /*
      if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
         {
         TranslateMessage(&msg);
         DispatchMessage(&msg);
         }
      */
      
      ptScrollPos = GetScrollPosition();
      ptDevScrollPos = GetDeviceScrollPosition();
      GetCursorPos(&ptCursorPos);
      ScreenToClient(&ptCursorPos);
      GetClientRect(&rc);
      dx = 0L;
      dy = 0L;
      
      if ((ptCursorPos.y < 0) && (ptDevScrollPos.y != yMin))
      // Cursor is above client area
      dy = min(-sizeLine.cy, max(-sizePage.cy, (ptCursorPos.y/10) * sizeLine.cy));
      else if ((ptCursorPos.y > rc.bottom) &&  (ptDevScrollPos.y != yMax))
      // Cursor is below client area
      dy = max(sizeLine.cy, min(sizePage.cy, ((ptCursorPos.y - rc.bottom)/10) * sizeLine.cy));
      // otherwise we can't scroll anyway
      
      if ((ptCursorPos.x < 0) && (ptDevScrollPos.x != xMin))
      // Cursor is on the left of the client area
      dx = min(-sizeLine.cx, max(-sizePage.cx, (ptCursorPos.x/10) * sizeLine.cx));
      else if ((ptCursorPos.x > rc.right) && (ptDevScrollPos.x != xMax))
      // Cursor is on the right of the client area
      dx = max(sizeLine.cx, min(sizePage.cx, ((ptCursorPos.x - rc.right)/10) * sizeLine.cx));
      // otherwise we can't scroll anyway
      
      // if mouse cursor is dragging outside the client area, scrolling occurs
      if ((dx != 0) || (dy != 0))
         {
         // Flip the Y coordinate if we're not in MM_TEXT
         nMapFactor = (nMapMode == MM_TEXT) ? 1 : -1;
         ptScrollPos.y += (int) dy * nMapFactor;
         ptScrollPos.x += (int) dx;
         m_bIsScrolling = TRUE;
         OnAutoScroll(ptCursorPos, TRUE);
         ScrollToPosition(ptScrollPos);
         
         while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
            {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
            
            //            if (msg.message == nRefMessage) break;
            if (msg.message == nRefMessage) bSawRefMessage = TRUE;
            }
         
         //         if (!bSawRefMessage)
         OnAutoScroll(ptCursorPos, FALSE);
         }
      else
         {
         
         while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
            {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
            
            //            if (msg.message == nRefMessage) break;
            if (msg.message == nRefMessage) bSawRefMessage = TRUE;
            }
         
         m_bIsScrolling = FALSE;
         }
      }
   ReleaseCapture();
   m_bIsScrolling = FALSE;
   }
/*
	OnUpdate()
*/
void CWallBrowserStretchView::OnUpdate(CView* pSender,LPARAM lHint,CObject* pHint)
{
	CWaitCursor cursor;
	BOOL bHint = FALSE;
	static BOOL bTreeExpandedEx = FALSE;

	if(lHint & ONUPDATE_FLAG_TREEEXPANDEDEX)
	{
		TRACE("%s(%d): receiving ONUPDATE_FLAG_TREEEXPANDEDEX\n",__FILE__,__LINE__);
		bTreeExpandedEx = TRUE;
	}

	if(!bTreeExpandedEx)
		goto done;

	// cambio immagine/libreria correnti
	if((lHint & ONUPDATE_FLAG_FILECHANGED) || (lHint & ONUPDATE_FLAG_DEFAULTLIBRARY))
	{
		TRACE("%s(%d): receiving ONUPDATE_FLAG_FILECHANGED || ONUPDATE_FLAG_DEFAULTLIBRARY\n",__FILE__,__LINE__);

		m_bLoaded = FALSE;
		CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument();
		CImage* pImage = NULL;

		memset(m_szStatus,'\0',sizeof(m_szStatus));

		if(pDoc)
		{
			// salva l'immagine se e' stata modificata
			if(pDoc->IsModified())
				pDoc->SaveModified(m_szFileName);

			pImage = pDoc->GetImage();
			if(pImage)
			{
				if(pDoc->HaveFileName())
				{
					// ricava il nome del file da caricare
					_snprintf(m_szFileName,
							sizeof(m_szFileName)-1,
							"%s%s",
							pDoc->GetPathName(),
							pDoc->GetFileName()
							);

					strcpyn(m_szStatus,"loading...",sizeof(m_szStatus));
					if(m_pMainFrameStatusBar)
						m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_FILENAME_ID,m_szStatus);
					pDoc->SetTitle(m_szStatus);
					
					// carica l'immagine
					m_bHavePicture = TRUE;

					if(pImage->Load(m_szFileName))
					{
						m_bLoaded = TRUE;
						strcpyn(m_szStatus,pDoc->GetFileName(),sizeof(m_szStatus));
					}
					else
					{
						m_bLoaded = FALSE;
						_snprintf(m_szStatus,sizeof(m_szStatus)-1,"load failed - %s",pDoc->GetFileName());
					}

					pDoc->SetTitle(m_szStatus);
					pDoc->SetPictureFlag(m_bLoaded);
					if(!m_bLoaded)
						pDoc->ResetFileName();
				}
			}
		}
		
		// caricamento dell'immagine riuscito
		if(m_bLoaded)
		{
			if(m_pMainFrameStatusBar)
			{
				EnableMenu();
				m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_FILENAME_ID,m_szStatus);
			}
		}
		else // caricamento fallito
		{
			if(m_pMainFrameStatusBar)
			{
				DisableMenu();
				m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_FILENAME_ID,"");
				//m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_FILES_ID,"");
				m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_INFO_ID,"");
				m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_LIBRARY_ID,"");
				m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_MEM_ID,"");
				//m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_PICTURES_ID,"");
				m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_RATIO_ID,"");
				m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_ZOOM_ID,"");
			}
		}
		
		// aggiorna la GUI
		CWnd* pWnd = AfxGetMainWnd();
		if(pWnd)
		{
			pWnd->SendMessage(WM_FILE_SAVE,FALSE,0L);
			pWnd->SendMessage(WM_FILE_SAVE_AS,m_bLoaded,0L);
			pWnd->SendMessage(WM_FILE_MOVE,m_bHavePicture,0L);
			pWnd->SendMessage(WM_FILE_DELETE,m_bHavePicture,0L);
			pWnd->SendMessage(WM_EDIT_COPY,m_bLoaded,0L);
			pWnd->SendMessage(WM_EDIT_PASTE,m_bLoaded ? ::IsClipboardFormatAvailable(CF_DIB) : FALSE,0L);
			pWnd->SendMessage(WM_EDIT_UNDO,FALSE,0L);
			pWnd->PostMessage(WM_EDIT_REDO,FALSE,0L);
			UndoEmpty();
			RedoEmpty();
		}

		// per evitare di cancellare il fondo se la nuova immagine e' piu' grande della precedente
		BOOL bEraseOnInvalidate = TRUE;

		// modalita' stretch, calcola la dimensione dello stretch
		if(m_nViewType==VIEWTYPE_STRETCH)
		{
			// modalita' visualizzazione (centrato/text)
			SetCenterMode(FALSE);
			SetMapMode(MM_TEXT);
			SetCursorZoomMode(CURSOR_MODE_NONE);

			// elimina le barre dello scroll
			CSize size(0,0);
			SetZoomSizes(size);

			bEraseOnInvalidate = m_bLoaded ? ((lHint & ONUPDATE_FLAG_DEFAULTLIBRARY) ? FALSE : TRUE) : TRUE;

			if(bEraseOnInvalidate && m_rcInvalid.right!=-1 && m_rcInvalid.bottom!=-1 && pImage)
			{
				double nRemains = 0.0;
				double nWidth   = (double)pImage->GetWidth();
				double nHeight  = (double)pImage->GetHeight();

				GetClientRect(&m_rcClient);

				if(nHeight > (double)m_rcClient.bottom)
				{
					nRemains = FDIV(nHeight,(double)m_rcClient.bottom);
					if(nRemains > 0.0)
					{
						nHeight = FDIV(nHeight,nRemains);
						nWidth  = FDIV(nWidth,nRemains);
					}
				}
				if(nWidth > (double)m_rcClient.right)
				{
					nRemains = FDIV(nWidth,(double)m_rcClient.right);
					if(nRemains > 0.0)
					{
						nHeight = FDIV(nHeight,nRemains);
						nWidth  = FDIV(nWidth,nRemains);
					}
				}

				if((int)nWidth >= m_rcInvalid.right && (int)nHeight >= m_rcInvalid.bottom)
					bEraseOnInvalidate = FALSE;
			}
		}
		// modalita' scroll
		else if(m_nViewType==VIEWTYPE_SCROLL)
		{
			// deve cancellare lo sfondo e riposizionare le barre dello scroll a 0,0
			bEraseOnInvalidate = TRUE;
			POINT point = {0,0};
			ScrollToPosition(point);
			NotifyRanges();
		}

		// (ri)disegna l'immagine
		Invalidate(bEraseOnInvalidate);

		bHint = TRUE;
	}
	// click sull'immagine gia' selezionata (ma non attiva)
	if(lHint & ONUPDATE_FLAG_FILESELECTED)
	{
		TRACE("%s(%d): receiving ONUPDATE_FLAG_FILESELECTED\n",__FILE__,__LINE__);

		CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument();
		if(pDoc)
		{
			CImage* pImage = pDoc->GetImage();
			if(pImage && pImage->GetWidth() > 0 && pImage->GetHeight() > 0)
			{
				// aggiorna la GUI
				CWnd* pWnd = AfxGetMainWnd();
				if(pWnd)
				{
					m_bLoaded = pDoc->GetPictureFlag();
					pWnd->SendMessage(WM_FILE_SAVE,pDoc->IsModified(),0L);
					pWnd->SendMessage(WM_FILE_SAVE_AS,m_bLoaded,0L);
					pWnd->SendMessage(WM_FILE_MOVE,m_bHavePicture,0L);
					pWnd->SendMessage(WM_FILE_DELETE,m_bHavePicture,0L);
					pWnd->SendMessage(WM_EDIT_COPY,m_bLoaded,0L);
					pWnd->SendMessage(WM_EDIT_PASTE,m_bLoaded ? ::IsClipboardFormatAvailable(CF_DIB) : FALSE,0L);
					pWnd->SendMessage(WM_EDIT_UNDO,UndoEnabled(),0L);
					pWnd->PostMessage(WM_EDIT_REDO,RedoEnabled(),0L);
				}
			}
		}

		//Invalidate(FALSE);

		bHint = TRUE;
	}
	// eliminazione dell'immagine corrente
	if(lHint & ONUPDATE_FLAG_FILEDELETED)
	{
		TRACE("%s(%d): receiving ONUPDATE_FLAG_FILEDELETED\n",__FILE__,__LINE__);

		// se l'immagine e' stata modificata resetta il flag
		CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument();
		if(pDoc->IsModified())
			pDoc->SetModifiedFlag(FALSE);

		// aggiorna la GUI
		CWnd* pWnd = AfxGetMainWnd();
		if(pWnd)
		{
			pWnd->SendMessage(WM_FILE_SAVE,FALSE,0L);
			pWnd->SendMessage(WM_FILE_SAVE_AS,FALSE,0L);
			pWnd->SendMessage(WM_FILE_MOVE,FALSE,0L);
			pWnd->SendMessage(WM_FILE_DELETE,FALSE,0L);
			pWnd->SendMessage(WM_EDIT_COPY,FALSE,0L);
			pWnd->SendMessage(WM_EDIT_PASTE,FALSE,0L);
			pWnd->SendMessage(WM_EDIT_UNDO,FALSE,0L);
			pWnd->PostMessage(WM_EDIT_REDO,FALSE,0L);
			UndoEmpty();
			RedoEmpty();
		}

		// deve disegnare il contenuto della nuova immagine o ripulire l'area client se era l'unica immagine della directory
		Invalidate(TRUE);

		// se il file era l'unico nella directory
		pDoc->SetTitle(pDoc->GetPathName());
		
		bHint = TRUE;
	}
	// cambio della directory corrente
	if(lHint & ONUPDATE_FLAG_DIRCHANGED || lHint & ONUPDATE_FLAG_DIRSELECTED)
	{
		TRACE("%s(%d): receiving ONUPDATE_FLAG_DIRCHANGED || ONUPDATE_FLAG_DIRSELECTED\n",__FILE__,__LINE__);

		m_bLoaded = FALSE;

		// salva l'immagine se e' stata modificata
		CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument();
		if(pDoc)
		{
			if(pDoc->IsModified())
				pDoc->SaveModified(m_szFileName);
			
			m_bLoaded = pDoc->GetPictureFlag();
		}

		// aggiorna la GUI
		CWnd* pWnd = AfxGetMainWnd();
		if(pWnd)
		{
			pWnd->SendMessage(WM_FILE_SAVE,FALSE,0L);
			pWnd->SendMessage(WM_FILE_SAVE_AS,m_bLoaded,0L);
			pWnd->SendMessage(WM_FILE_MOVE,m_bHavePicture,0L);
			pWnd->SendMessage(WM_FILE_DELETE,m_bHavePicture,0L);
			pWnd->SendMessage(WM_EDIT_COPY,m_bLoaded,0L);
			pWnd->SendMessage(WM_EDIT_PASTE,m_bLoaded ? ::IsClipboardFormatAvailable(CF_DIB) : FALSE,0L);
			pWnd->SendMessage(WM_EDIT_UNDO,FALSE,0L);
			pWnd->PostMessage(WM_EDIT_REDO,FALSE,0L);
			UndoEmpty();
			RedoEmpty();
		}

		// deve ripulire l'area client
		if(m_nViewType==VIEWTYPE_SCROLL)
			NotifyRanges();

		Invalidate(TRUE);
		
		bHint = TRUE;
	}
	// e' stato svuotato lo stack per l'undo/redo
	if(lHint & ONUPDATE_FLAG_EMPTYSTACK)
	{
		TRACE("%s(%d): receiving ONUPDATE_FLAG_EMPTYSTACK\n",__FILE__,__LINE__);

		CWnd* pWnd = AfxGetMainWnd();
		if(pWnd)
		{
			pWnd->SendMessage(WM_EDIT_UNDO,FALSE,0L);
			pWnd->PostMessage(WM_EDIT_REDO,FALSE,0L);
		}

		UndoEmpty();
		RedoEmpty();
		
		bHint = TRUE;
	}
	// e' stata cambiata la modalita' di visualizzazione (stretch/scroll)
	if(lHint & ONUPDATE_FLAG_VIEWTYPE)
	{
		TRACE("%s(%d): receiving ONUPDATE_FLAG_VIEWTYPE\n",__FILE__,__LINE__);

		m_nViewType = m_pWinAppEx->m_Config.GetNumber(WALLBROWSER_OPTIONS_KEY,WALLBROWSER_VIEWTYPE_KEY);
		
		if(m_nViewType==VIEWTYPE_SCROLL)
		{
			// modalita' visualizzazione (centrato/isotropic)
			SetCenterMode(TRUE);
			SetMapMode(MM_ANISOTROPIC);
			SetCursorZoomMode(CURSOR_MODE_BYCLICK);

			// risposiziona le barre dello scroll a 0,0
			POINT point = {0,0};
			ScrollToPosition(point);
			
			SetZoomMode(MODE_ZOOMOFF);
			NotifyRanges();
		}
		else if(m_nViewType==VIEWTYPE_STRETCH)
		{
			// modalita' visualizzazione (centrato/text)
			SetCenterMode(FALSE);
			SetMapMode(MM_TEXT);
			SetCursorZoomMode(CURSOR_MODE_NONE);

			// elimina le barre dello scroll
			CSize size(0,0);
			SetZoomSizes(size);
		}

		// deve ridisegnare l'immagine ripulendo l'area client (dato che passa da una modalita' all'altra)
		Invalidate(TRUE);

		bHint = TRUE;
	}
	// e' stata cambiata la modalita' di disegno
	if((lHint & ONUPDATE_FLAG_DRAWSTRETCHDIBITS) || (lHint & ONUPDATE_FLAG_DRAWSTRETCHBLT) || (lHint & ONUPDATE_FLAG_DRAWVFWDRAWDIB))
	{
		TRACE("%s(%d): receiving ONUPDATE_FLAG_DRAWSTRETCHDIBITS || ONUPDATE_FLAG_DRAWSTRETCHBLT || ONUPDATE_FLAG_DRAWVFWDRAWDIB\n",__FILE__,__LINE__);

		if(lHint & ONUPDATE_FLAG_DRAWSTRETCHDIBITS)
			m_nDrawMode = DRAW_STRETCHDIBITS;
		else if(lHint & ONUPDATE_FLAG_DRAWSTRETCHBLT)
			m_nDrawMode = DRAW_STRETCHBLT;
		else if (lHint & ONUPDATE_FLAG_DRAWVFWDRAWDIB)
			m_nDrawMode = DRAW_VFWDRAWDIB;
		else
			m_nDrawMode = DEFAULT_DRAWMODE;

		// deve ridisegnare l'immagine senza ripulire l'area client (cambia solo la modalita' di disegno, non quella di visualizzazione)
		Invalidate(FALSE);

		bHint = TRUE;
	}
	// e' stato cambiato il fattore di zoom
	if((lHint & ONUPDATE_FLAG_ZOOMIN) || (lHint & ONUPDATE_FLAG_ZOOMOUT) || (lHint & ONUPDATE_FLAG_ZOOMRESET))
	{
		TRACE("%s(%d): receiving ONUPDATE_FLAG_ZOOMIN || ONUPDATE_FLAG_ZOOMOUT || ONUPDATE_FLAG_ZOOMRESET\n",__FILE__,__LINE__);

		if(lHint & ONUPDATE_FLAG_ZOOMIN)
		{
			SetZoomMode(MODE_ZOOMIN);
			TRACE("zoom ratio: %.2f\n",GetZoomRatio());
			if(GetZoomRatio() <= 28.42)
				DoZoomIn();
		}
		else if(lHint & ONUPDATE_FLAG_ZOOMOUT)
		{
			SetZoomMode(MODE_ZOOMOUT);
			TRACE("zoom ratio: %.2f\n",GetZoomRatio());
			if(GetZoomRatio() >= 0.04)
				DoZoomOut();
		}
		else if(lHint & ONUPDATE_FLAG_ZOOMRESET)
		{
			SetZoomMode(MODE_ZOOMOFF);
			NotifyRanges();
			Invalidate(TRUE);
		}

		bHint = TRUE;
	}

done:

	// classe base
	if(!bHint)
		CZoomView::OnUpdate(pSender,lHint,pHint);
}
Exemplo n.º 18
0
void CMapView::OnMouseMove(UINT, CPoint point)
{
    if (m_HandDown && m_Tracking)
    {
        CPoint Delta = m_LastPoint - point;
        CPoint NewPoint = GetScrollPosition() + Delta;
        ScrollToPosition(NewPoint);
        m_LastPoint = point;
    }
    else
    {
        point += GetScrollPosition();

        int x  = point.x / 40;
        int y  = point.y / 40;
        int xe = (point.x % 40) / 10;
        int ye = (point.y % 40) / 10;

        CMapDoc* pDoc = GetDocument();
        ASSERT_VALID(pDoc);
        int w = pDoc->GetWidth();
        int h = pDoc->GetHeight();

        CString str;
        if (w > 0 && h > 0 && x >= 0 && y >= 0 && x < w && y < h && xe >= 0 && xe < 4 && ye >= 0 && ye < 4)
        {
            int r = y*w + x;
            int e = ye*4 + xe;

            CTile Tile = pDoc->GetTile(r);
            int Elevation = Tile.Elevation;
            CElement Element = g_App.m_Elements[Tile.E[e]];

            str.Format("%s (%d)", Element.Name, Element.Type);
            g_App.PrintStatus(str,1);

            str.Format("%dm", Elevation);
            g_App.PrintStatus(str,2);

            str.Format("%d,%d (%d,%d)", x,y, xe,ye);
            g_App.PrintStatus(str,3);

            str.Format("%d E%d", r,e);
            g_App.PrintStatus(str,4);

            if (m_Tracking)
            {
                if (m_ViewMode == VIEW_MODE_ELEVATION)
                {
                    pDoc->SetTileElevation(r, g_Elevation);
                    CString str;
                    str.Format("Change %d to %dm", r, g_Elevation);
                    g_App.PrintStatus(str);


                    CRect rect(CPoint(x*40, y*40), CSize(40,40));
                    rect.OffsetRect(-GetScrollPosition());
                    InvalidateRect(rect, FALSE);
                }
                else
                {
                    pDoc->SetTile(r,e, g_Tile);
                    CString str;
                    str.Format("Change %d [%d] to %s", r,e, g_App.m_Elements[g_Tile].Name);
                    g_App.PrintStatus(str);

                    CRect rect(CPoint(x*40 + xe*10, y*40 + ye*10), CSize(10,10));
                    rect.OffsetRect(-GetScrollPosition());
                    InvalidateRect(rect, FALSE);
                }
            }
        }
        else
        {
            str.Empty();
            g_App.PrintStatus(str,1);
            g_App.PrintStatus(str,2);
            g_App.PrintStatus(str,3);
            g_App.PrintStatus(str,4);
        }
        str.Format("%d,%d", point.x,point.y);
        g_App.PrintStatus(str,5,true);
    }
}