Example #1
0
DepCompDistributeLoop::Result DepCompDistributeLoop ::
operator()( LoopTreeDepComp& tc, LoopTreeNode *l, LoopTreeNodeIterator stmts)
{
  typedef PtrSetWrap<LoopTreeNode> LoopTreeNodeList;
  LoopTreeNodeList stmts1, stmts2;

  LoopTreeDepCompSubtree loopComp( tc, l);
#ifdef DEBUG
std::cerr << "***************From sub tree *******\n";
loopComp.DumpTree();
loopComp.DumpDep();
std::cerr << "***************end sub tree *******\n";
#endif
  DepLinkedNodes( loopComp, stmts, GraphAccess::EdgeIn, stmts1);
  DepLinkedNodes( loopComp, stmts, GraphAccess::EdgeOut, stmts2);

  stmts2 &= stmts1;
  stmts1 -= stmts2;

  if (stmts1.NumberOfEntries()) {
    SelectPtrSet<LoopTreeNode> sel(stmts1);
    LoopTreeDistributeNode()(l,sel);
  }
  SelectPtrSet<LoopTreeNode> sel2(stmts2);
  return Result( LoopTreeDistributeNode()(l, sel2), stmts2);
}
void CBCGPPlannerViewMonth::OnActivate(CBCGPPlannerManagerCtrl* pPlanner, const CBCGPPlannerView* pOldView)
{
	ASSERT_VALID(pPlanner);

	if (pOldView != NULL)
	{
		m_Date = pOldView->GetDate ();
	}

	m_nDuration = 35;
	m_DateStart = CalculateDateStart (
		COleDateTime(m_Date.GetYear (), m_Date.GetMonth (), m_Date.GetDay (), 0, 0, 0));
	m_DateEnd   = m_DateStart + COleDateTimeSpan (m_nDuration - 1, 23, 59, 59);

	if (m_Date > m_DateEnd || m_Date < m_DateStart)
	{
		m_Date = m_DateStart;
	}

	COleDateTime sel1 (m_Date);
	COleDateTime sel2 (m_Date);

	if (pOldView != NULL)
	{
		sel1 = pOldView->GetSelectionStart ();
		sel2 = pOldView->GetSelectionEnd ();
	}

	SetSelection (sel1, sel2, FALSE);

	CBCGPPlannerView::OnActivate (pPlanner, NULL);
}
void CBCGPPlannerViewWorkWeek::OnActivate(CBCGPPlannerManagerCtrl* pPlanner, const CBCGPPlannerView* pOldView)
{
	ASSERT_VALID(pPlanner);

	if (pOldView != NULL)
	{
		m_Date = pOldView->GetDate ();
	}

	m_DateStart = CalculateDateStart (
		COleDateTime(m_Date.GetYear (), m_Date.GetMonth (), m_Date.GetDay (), 0, 0, 0));
	m_DateEnd   = m_DateStart + COleDateTimeSpan (pPlanner->GetWorkWeekInterval () - 1, 23, 59, 59);

	COleDateTime sel1 (m_Date);
	COleDateTime sel2 (m_Date);

	if (pOldView != NULL)
	{
		sel1 = pOldView->GetSelectionStart ();
		sel2 = pOldView->GetSelectionEnd ();
	}

	const int nMinuts = CBCGPPlannerView::GetTimeDeltaInMinuts (pPlanner->GetTimeDelta ());

	sel1 = COleDateTime (m_DateStart.GetYear (), m_DateStart.GetMonth (), m_DateStart.GetDay (),
		pPlanner->GetFirstSelectionHour (), (int)(pPlanner->GetFirstSelectionMinute () / nMinuts) * nMinuts, 0);
	sel2 = sel1 + COleDateTimeSpan (0, 0, nMinuts - 1, 59);

	//SetSelection (sel1, sel2, FALSE);

	CBCGPPlannerView::OnActivate (pPlanner, NULL);

	SetSelection (sel1, sel2);
}
Example #4
0
void cGUIEdit::SelectionCut()
{
	if(m_sel1==m_sel2) return; // no selection
	int s1 = sel1(), s2 = sel2();
	ShiftLeft(s2,s2-s1);
	m_sel1 = m_sel2 = s1;
}
void
nsCaretAccessible::ProcessSelectionChanged(nsISelection* aSelection)
{
  nsCOMPtr<nsISelection2> sel2(do_QueryInterface(aSelection));

  PRInt16 type = 0;
  sel2->GetType(&type);

  if (type == nsISelectionController::SELECTION_NORMAL)
    NormalSelectionChanged(aSelection);

  else if (type == nsISelectionController::SELECTION_SPELLCHECK)
    SpellcheckSelectionChanged(aSelection);
}
Example #6
0
//////////////////////////////////////////////////////////////////////////////////////////////////
// clipboard
//////////////////////////////////////////////////////////////////////////////////////////////////
void cGUIEdit::ClipboardCopy()
{
	int s1 = sel1(), s2 = sel2();
	int size = s2-s1;
	if(size==0) return; // no selection

	if(!OpenClipboard(NULL)) return;
	if(EmptyClipboard())
	{
		HGLOBAL handler = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,size+1); assert(handler!=NULL);
		void* data = GlobalLock(handler); assert(data!=NULL);
		memcpy(data,txt.c_str() + s1,size);
		((LPWSTR)data)[size]=0;
		GlobalUnlock(handler);
		SetClipboardData(CF_UNICODETEXT,handler);
	}
	CloseClipboard();
}
NS_IMETHODIMP
nsCaretAccessible::NotifySelectionChanged(nsIDOMDocument* aDOMDocument,
                                          nsISelection* aSelection,
                                          PRInt16 aReason)
{
  NS_ENSURE_ARG(aDOMDocument);
  NS_ENSURE_STATE(mRootAccessible);

  nsCOMPtr<nsIDocument> documentNode(do_QueryInterface(aDOMDocument));
  nsDocAccessible* document = GetAccService()->GetDocAccessible(documentNode);

#ifdef DEBUG_NOTIFICATIONS
  nsCOMPtr<nsISelection2> sel2(do_QueryInterface(aSelection));

  PRInt16 type = 0;
  sel2->GetType(&type);

  if (type == nsISelectionController::SELECTION_NORMAL ||
      type == nsISelectionController::SELECTION_SPELLCHECK) {

    bool isNormalSelection =
      (type == nsISelectionController::SELECTION_NORMAL);

    bool isIgnored = !document || !document->IsContentLoaded();
    printf("\nSelection changed, selection type: %s, notification %s\n",
           (isNormalSelection ? "normal" : "spellcheck"),
           (isIgnored ? "ignored" : "pending"));
  }
#endif

  // Don't fire events until document is loaded.
  if (document && document->IsContentLoaded()) {
    // The caret accessible has the same lifetime as the root accessible, and
    // this outlives all its descendant document accessibles, so that we are
    // guaranteed that the notification is processed before the caret accessible
    // is destroyed.
    document->HandleNotification<nsCaretAccessible, nsISelection>
      (this, &nsCaretAccessible::ProcessSelectionChanged, aSelection);
  }

  return NS_OK;
}
void CBCGPPlannerViewMulti::AdjustLayout (CDC* /*pDC*/, const CRect& rectClient)
{
	if (IsCurrentTimeVisible ())
	{
		StartTimer (FALSE);
	}
	else
	{
		StopTimer (FALSE);
	}

	m_nHeaderHeight       = 2;
	m_nHeaderAllDayHeight = 1;

	const int nMinuts = CBCGPPlannerView::GetTimeDeltaInMinuts (GetTimeDelta ());
	const int nCount = GetViewHours() * 60 / nMinuts;

	m_rectTimeBar = rectClient;
	m_rectTimeBar.right = m_rectTimeBar.left + (long)(m_nRowHeight * (nMinuts == 60 ? 2.5 : 3.0)) + 5;

	m_rectApps.left = m_rectTimeBar.right;

	{
		// finding allday or multiday events
		const int nDays = GetViewDuration ();

		CDWordArray arDays;
		arDays.SetSize (nDays);

		COleDateTime dtS = GetDateStart ();

		XBCGPAppointmentArray& arQueryApps = GetQueryedAppointments ();
		XBCGPAppointmentArray& arDragApps  = GetDragedAppointments ();

		BOOL bDragDrop        = IsDragDrop ();
		DROPEFFECT dragEffect = GetDragEffect ();
		BOOL bDragMatch       = IsCaptureMatched ();

		bDragDrop = !bDragDrop || 
			(bDragDrop && ((dragEffect & DROPEFFECT_COPY) == DROPEFFECT_COPY && bDragMatch) || 
			!bDragMatch);
		bDragDrop = bDragDrop && arDragApps.GetSize ();

		DWORD maxCount = 0;

		for (int nRes = 0; nRes < m_Resources.GetSize (); nRes++)
		{
			UINT nResourceID = m_Resources[nRes].m_ResourceID;

			for (int nApp = 0; nApp < 2; nApp++)
			{
				if (!bDragDrop && nApp == 0)
				{
					continue;
				}

				XBCGPAppointmentArray& arApps = nApp == 0 ? arDragApps : arQueryApps;

				int nStartIndex = 0;
				int i = 0;
				for (i = 0; i < arApps.GetSize (); i++)
				{
					const CBCGPAppointment* pApp = arApps[i];
					if (pApp != NULL && pApp->GetResourceID () == nResourceID)
					{
						nStartIndex = i;
						break;
					}
				}

				for (i = nStartIndex; i < (int)arApps.GetSize (); i++)
				{
					const CBCGPAppointment* pApp = arApps[i];
					if (pApp == NULL)
					{
						continue;
					}

					ASSERT_VALID (pApp);

					if (pApp->GetResourceID () != nResourceID)
					{
						break;
					}

					if (pApp->IsAllDay () || pApp->IsMultiDay ())
					{
						if (nDays > 1)
						{
							COleDateTime dtStart  = pApp->GetStart ();
							COleDateTime dtFinish = pApp->GetFinish ();

							dtStart = COleDateTime (dtStart.GetYear (), dtStart.GetMonth (), dtStart.GetDay (),
								0, 0, 0);

							if (pApp->IsAllDay ())
							{
								dtFinish += COleDateTimeSpan (1, 0, 0, 0);
							}
							else if (pApp->GetFinish ().GetHour () != 0 ||
									 pApp->GetFinish ().GetMinute () != 0)
							{
								dtFinish = COleDateTime (dtFinish.GetYear (), dtFinish.GetMonth (), dtFinish.GetDay (),
									0, 0, 0);
								dtFinish += COleDateTimeSpan (1, 0, 0, 0);
							}

							if (dtStart < dtS)
							{
								dtStart = dtS;
							}

							COleDateTimeSpan span (dtFinish - dtStart);

							int nStart = (dtStart - dtS).GetDays ();
							int nEnd   = nStart + span.GetDays ();

							if (nEnd > (int) nDays)
							{
								nEnd = (int) nDays;
							}

							for (int j = nStart; j < nEnd; j++)
							{
								arDays[j] = arDays[j] + 1;
							}
						}
						else
						{
							arDays[0] = arDays[0] + 1;
						}
					}
				}
			}

			for (int i = 0; i < nDays; i++)
			{
				if (maxCount < arDays[i])
				{
					maxCount = arDays[i];
				}

				arDays[i] = 0;
			}
		}	

		if (maxCount > 0)
		{
			m_nHeaderAllDayHeight = maxCount;
		}
	}

	int nRow = rectClient.Height () / 
		(nCount + m_nHeaderHeight + m_nHeaderAllDayHeight);

	int nOldRowHeight = m_nRowHeight;

	if (nRow > m_nRowHeight)
	{
		m_nRowHeight = nRow;
	}

	const int nRowHeightPadding = m_nRowHeight + s_HeaderAllDayPadding;
	int nHeaderAllDayCount = m_nHeaderAllDayHeight;
	m_nHeaderHeight       *= m_nRowHeight;
	m_nHeaderAllDayHeight *= nRowHeightPadding;

	m_rectApps.top += m_nHeaderHeight;

	m_nHeaderScrollTotal = 0;
	m_nHeaderScrollPage  = 1;

	if (GetPlanner()->IsHeaderScrollingEnabled() && 
		nHeaderAllDayCount > 0 && m_nHeaderAllDayHeight > m_rectApps.Height () / 2)
	{
		m_nHeaderAllDayHeight = min(m_rectApps.Height () / (nRowHeightPadding * 2), nHeaderAllDayCount);
		if (m_nHeaderAllDayHeight == 0)
		{
			m_nHeaderAllDayHeight = 1;
		}

		if (m_nHeaderAllDayHeight != nHeaderAllDayCount)
		{
			m_nHeaderScrollTotal = nHeaderAllDayCount - 1;
			m_nHeaderScrollPage  = m_nHeaderAllDayHeight;
		}

		m_nHeaderAllDayHeight *= nRowHeightPadding;
	}

	nRow = (m_rectApps.Height () - m_nHeaderAllDayHeight) / nCount;

	if (nRow > nOldRowHeight)
	{
		m_nRowHeight = nRow;
	}

	int delta = m_rectApps.Height () - m_nHeaderAllDayHeight;

	if (delta < 0)
	{
		m_nHeaderAllDayHeight = m_rectApps.Height ();
	}
	else
	{
		int nc = (int)(delta / m_nRowHeight);

		if (nc >= nCount)
		{
			m_nHeaderAllDayHeight = m_rectApps.Height () - nCount * m_nRowHeight;
		}
		else
		{
			m_nHeaderAllDayHeight += delta - nc * m_nRowHeight;
		}
	}

	m_rectApps.top += m_nHeaderAllDayHeight;

	AdjustScrollSizes ();
	
	// correct selection
	COleDateTime sel1 (GetSelectionStart ());
	COleDateTime sel2 (GetSelectionEnd ());

	SetSelection (sel1, sel2, FALSE);
}
Example #9
0
void cGUIEdit::OnUpdate()
{
	iRect rc = scrRect();
	int mx = g_gui->m_mouse.x - rc.p1.x;
	bool shift = einput->shift();
	bool ctrl = einput->ctrl();
	bool enter = einput->isKeyDown(DIK_RETURN) || einput->isKeyDown(DIK_NUMPADENTER);
	
	int width = rect.Width();
	int height = rect.Height();
	int cursorx = Chr2Pos(m_sel2);
	int deltax = 0;
	if(cursorx>width-height/2) deltax = -(cursorx-(width-height/2));

	BOOL captured = (g_gui->m_capture == this);
	BOOL clicked = einput->isMouseDown(0);
	BOOL clickedin = clicked && m_mousein;

	if(clicked)
	{
		if(clickedin)
		{
			if(!m_edit) m_bktxt = txt;
			Capture(true);
			m_edit = true;
			m_sel1 = m_sel2 = Pos2Chr(mx-deltax);
		
			// double click
			static int dblclicktick = 0;
			int tick = GetTickCount();
			if(tick-dblclicktick<500) // select all
			{
				m_sel1=0; m_sel2=txt.size();
				Capture(false);
			}
			dblclicktick = tick;
		}
		else
		{
			if(m_edit)
			{
				Action(0);
				m_edit = false;
				m_sel1 = m_sel2 = 0;
			}
		}
	}
	else
	if(captured)
	{
		m_sel2 = Pos2Chr(mx-deltax);
		if( !einput->mouseValue(0) ) // for selections
		{
			Capture(false);
		}
	}

	int s1 = sel1(), s2 = sel2();

	if(m_edit)
	{
		if(einput->isKeyDown(DIK_ESCAPE))
		{
			if(!m_bktxt.empty()) txt = m_bktxt; // restore
			m_edit = false;
			m_sel1 = m_sel2 = 0;
			return;
		}

		if(enter || einput->isKeyDown(DIK_TAB))
		{
			Action(enter ? 1 : 3);
			m_edit = false;
			m_sel1 = m_sel2 = 0;
			return;
		}

		if(einput->isKeyDown(DIK_DELETE))
		{
			if(s1!=s2)
				ShiftLeft(s2,s2-s1); // selection cut
			else
				ShiftLeft(s1+1,1);
			m_sel2 = m_sel1 = s1;
			return;
		}	

		if(einput->isKeyDown(DIK_BACK))
		{
			if(s1!=s2)
				ShiftLeft(s2,s2-s1); // selection cut
			else
				ShiftLeft(s1,1);
			s1--;
			if(s1<0) s1 = 0;
			m_sel2 = m_sel1 = s1;
			return;
		}	
		
		if(einput->isKeyDown(DIK_HOME))
		{
			m_sel2 = 0;
			if(!shift) m_sel1 = m_sel2;
			return;
		}
		
		if(einput->isKeyDown(DIK_END))
		{
			m_sel2 = txt.size();
			if(!shift) m_sel1 = m_sel2;
			return;
		}
		
		if(einput->isKeyDown(DIK_LEFT))
		{
			if(m_sel1==m_sel2 || shift)
			{
				m_sel2--;
				if(m_sel2<0) m_sel2 = 0;
				if(!shift) m_sel1 = m_sel2;
			}
			else // break selection
			{
				if(m_sel2<m_sel1) 
					m_sel1 = m_sel2;
				else 
					m_sel2 = m_sel1;
			}
			return;
		}
		
		if(einput->isKeyDown(DIK_RIGHT))
		{
			if(m_sel1==m_sel2 || shift)
			{
				m_sel2++;
				if(m_sel2>txt.size()) m_sel2 = txt.size();
				if(!shift) m_sel1 = m_sel2;
			}
			else // break selection
			{
				if(m_sel2<m_sel1) 
					m_sel2 = m_sel1;
				else 
					m_sel1 = m_sel2;
			}
			return;
		}

		if(ctrl && einput->isKeyDown(DIK_C))
		{
			ClipboardCopy();
			return;
		}
		
		if(ctrl && einput->isKeyDown(DIK_V))
		{
			ClipboardPaste();
			return;
		}

		if(ctrl && einput->isKeyDown(DIK_X))
		{
			ClipboardCopy();
			SelectionCut();
			return;
		}

		if(!einput->keyQueue.empty())
		{
			for(auto ch: einput->keyQueue)
			{
				if(std::isprint(ch))
				{
					if(s1!=s2)
						ShiftLeft(s2,s2-s1); // selection cut
					m_sel2 = m_sel1 = s1;
					txt = txt.substr(0, s1) + ch + txt.substr(s1);
					m_sel1++;
					s1 = s2 = m_sel2 = m_sel1;
				}
			}
			einput->keyQueue.clear();
		}
	}

	// right click action
	if(!IsCaptured() && m_mousein && einput->isMouseDown(1))
		Action(2);
}