CLibraryFolder* CLibraryFolderCtrl::GetNextSelectedFolder(POSITION& pos) const
{
	CLibraryFolder* pFolder = NULL;

	do
	{
		if ( pos == NULL ) return NULL;

		HTREEITEM hItem = (HTREEITEM)pos;
		pos = (POSITION)GetNextSelectedItem( hItem );

		if ( hItem == m_hRoot ) continue;

		CPtrList pTree;

		while ( hItem != m_hRoot )
		{
			pTree.AddHead( (LPVOID)hItem );
			hItem = GetParentItem( hItem );
		}

		CLibraryFolder* pLastFolder = NULL;

		for ( POSITION posTree = pTree.GetHeadPosition() ; posTree ; pLastFolder = pFolder )
		{
			hItem = (HTREEITEM)pTree.GetNext( posTree );
			pFolder = (CLibraryFolder*)GetItemData( hItem );

			if ( pLastFolder )
			{
				if ( pLastFolder->CheckFolder( pFolder ) ) continue;
			}
			else
			{
				if ( LibraryFolders.CheckFolder( pFolder ) ) continue;
			}

			pFolder = NULL;
			break;
		}
	}
	while ( pFolder == NULL );

	return pFolder;
}
Beispiel #2
0
BOOL CVecPolygon::Track(CDPoint point, UINT uiTool, CUndoManager* pUndoMan, CSnapper* pSnapper)
{
   if(m_bTrackAsShape)
   {
      CPtrList list;
      list.AddHead(this);
      CSuperTracker st(list);
      if(HasPicture())
         st.SetTrackRetainProportions();
      if(st.Track(GetTopContainer()->GetWnd(), point, 
         HitTest(point) == HT_ON_POINT ? CSuperTracker::Style_Size: CSuperTracker::Style_Move, pSnapper))
      {
         pUndoMan->AddToStack(this, UAT_RESTORE_OB_FROM_LIGHT_DUMP);
         SetRectScaleAndOffsetByScreen(st.m_rect, st.m_rectOrigianl);
         return TRUE;
      }
   }
   else
   {
      CPolygonTracker rt(m_t_lpPoints, m_uiNumOfPoints, TRACKER_STYLE);
      int iHit = rt.HitTestPoints(point);
      BOOL bTrackResoult;
      if(iHit >= CPolygonTracker::hitDot)
      {//track only the selected point and the points next to it
         ASSERT(m_uiNumOfPoints>=3);
         int aPointLocation[3];
         CDPOINT aPointsData[3];
         if(iHit == 0)
         {  
            aPointLocation[0] = m_uiNumOfPoints-1;
            aPointLocation[1] = 0;
            aPointLocation[2] = 1;
         }
         else if(iHit == (int)m_uiNumOfPoints-1)
         {
            aPointLocation[0] = m_uiNumOfPoints-2;
            aPointLocation[1] = m_uiNumOfPoints-1;
            aPointLocation[2] = 0;
         }
         else
         {
            aPointLocation[0] = iHit-1;
            aPointLocation[1] = iHit;
            aPointLocation[2] = iHit+1;
         }

         for(int i=0; i<3; i++)
            aPointsData[i] = m_t_lpPoints[aPointLocation[i]];

         CLineTracker localTracker(aPointsData, 3);
         bTrackResoult = localTracker.Track(GetTopContainer()->GetWnd(), point, pSnapper);
         if(bTrackResoult)
         {
            for(int i=0; i<3; i++)
               m_t_lpPoints[aPointLocation[i]] = aPointsData[i];
         }
      }
      else
      {
         if(HasPicture())
            rt.SetTrackRetainProportions();
         bTrackResoult = rt.Track(GetTopContainer()->GetWnd(), point, pSnapper);
      }

      if(bTrackResoult)
      {
         pUndoMan->AddToStack(this, UAT_RESTORE_OB_FROM_LIGHT_DUMP);
         LPCDPOINT dpoints = new CDPOINT[m_uiNumOfPoints];
         for(UINT ui = 0; ui < m_uiNumOfPoints; ui++)
         {
            dpoints[ui].x = m_t_lpPoints[ui].x;
            dpoints[ui].y = m_t_lpPoints[ui].y;
            dpoints[ui] -= m_t_Offset;
            dpoints[ui] /= m_t_Scaler;
         }
         SetPoints(dpoints, m_uiNumOfPoints);

         delete []dpoints;

         return TRUE;
      }
   }

   return FALSE;
}