Esempio n. 1
0
bool C4Menu::RefillInternal()
{
	// Reset flag
	NeedRefill=false;

	// do the refill in frozen window (no scrolling update)
	int32_t iLastItemCount=ItemCount;
	bool fRefilled = false;
	pClientWindow->Freeze();
	bool fSuccess = DoRefillInternal(fRefilled);
	pClientWindow->UnFreeze();
	UpdateElementPositions();
	if (!fSuccess) return false;

	// menu contents may have changed: Adjust menu size and selection
	if (fRefilled)
	{
		// Adjust selection
		AdjustSelection();
		// Item count increased: resize
		if (ItemCount > iLastItemCount) LocationSet = false;
		// Item count decreased: resize if we are a context menu
		if ((ItemCount < iLastItemCount) && IsContextMenu()) LocationSet = false;
	}
	// Success
	return true;
}
Esempio n. 2
0
void CCalendarCtrl::OnMouseMove(UINT nFlags, CPoint point) 
{
	if(m_bSelectionStarted)
	{
		int nRow, nCol;
		if(GetGridCellFromPoint(point, nRow, nCol))
		{
			if( (m_dayCells[nRow][nCol].date < m_BoundUp) && 
				(m_dayCells[nRow][nCol].date > m_BoundDown) )	
			{
				m_RandomSelection.RemoveAll();
				m_SelectionRange[1] = DateToSeconds(m_dayCells[nRow][nCol].date);
				AdjustSelection();
				Invalidate(true);
			}
		}
	}	
	CWnd::OnMouseMove(nFlags, point);
}
Esempio n. 3
0
/*****************************************************************************
 * Function:	_DtCanvasProcessSelection()
 *
 * Purpose:	Indicate an new point for a selection.
 *
 *****************************************************************************/
void
_DtCanvasProcessSelection (
    _DtCvHandle		canvas_handle,
    _DtCvUnit		x,
    _DtCvUnit		y,
    _DtCvSelectMode	mode)
{
    int			 i;
    _DtCanvasStruct	*canvas = (_DtCanvasStruct *) canvas_handle;
    _DtCvSelectData	 temp;

    switch (mode)
	  {
	case _DtCvSELECTION_CLEAR:
		CheckAndSwitchPoints(&(canvas->select_start),
							&(canvas->select_end));

	case _DtCvSELECTION_START:
		_DtCvDrawAreaWithFlags(canvas, canvas->select_start,
				canvas->select_end,
				_DtCvSELECTED_FLAG, 0,
				_DtCvBAD_TYPE, NULL);

		canvas->select_start = defaultSelect;
		if (mode == _DtCvSELECTION_START)
		    SearchForClosestLine(canvas, x, y, &(canvas->select_start));

		canvas->select_end   = canvas->select_start;
		break;

	case _DtCvSELECTION_END:
	case _DtCvSELECTION_UPDATE:
		SearchForClosestLine(canvas, x, y, &temp);

		AdjustSelection (canvas, temp);
		if (mode == _DtCvSELECTION_END)
		    CheckAndSwitchPoints(&(canvas->select_start),
							&(canvas->select_end));
		break;
      }
}
Esempio n. 4
0
BOOL CCalendarCtrl::PreTranslateMessage(MSG* pMsg) 
{		
	if( pMsg->message == WM_KEYDOWN )
	{
		COleDateTime newDate = m_DateCurrent;
		bool bHold = (GetKeyState(VK_SHIFT)>>8 == -1)?true:false;
		bool bCtrl = (GetKeyState(VK_CONTROL)>>8 == -1)?true:false;
		if(bHold) bCtrl = false; // allow one combination

		switch(pMsg->wParam)
		{
		case VK_SPACE:
			{
				if(bCtrl)
				{
					int nRow, nCol;
					GetLastSelectedGridCell(nRow, nCol);
					if( (m_dayCells[nRow][nCol].date < m_BoundUp) && 
						(m_dayCells[nRow][nCol].date > m_BoundDown) )	
					{
						void*p; time_t t = DateToSeconds(m_dayCells[nRow][nCol].date);
						if(m_RandomSelection.Lookup((void*)t ,p))
							m_RandomSelection.RemoveKey((void*)t);
						else{
							if(m_RandomSelection.GetCount() < m_nMaxSel)
								m_RandomSelection.SetAt((void*)t, 0);
						}
						Invalidate(true);
						return TRUE;
					}
				}
				break;
			}
		case VK_UP:
			{
				int nRow, nCol;
				GetLastSelectedGridCell(nRow, nCol);
				if( (m_dayCells[nRow][nCol].date < m_BoundUp) && 
					(m_dayCells[nRow][nCol].date > m_BoundDown) )	
				{
					if(!bCtrl){
						m_RandomSelection.RemoveAll();
						m_SelectionRange[2] = 0;
					}
					else{
						if(m_RandomSelection.GetCount() == 0)
							m_RandomSelection.SetAt((void*)m_SelectionRange[0], 0);
					}

					if(nRow == 0){
						newDate -= COleDateTimeSpan(7,0,0,0);
						if((m_BoundUp > newDate) && (newDate > m_BoundDown))
						{
							m_nVscrollPos--;
							SetScrollPos(SB_VERT, m_nVscrollPos, TRUE);
							Goto(newDate);
						}
					}
					else
						nRow--;	
					
					if( (m_dayCells[nRow][nCol].date < m_BoundUp) && 
						(m_dayCells[nRow][nCol].date > m_BoundDown) )	
					{
						m_SelectionRange[1] = DateToSeconds(m_dayCells[nRow][nCol].date);
						if(bCtrl)
							m_SelectionRange[2] = m_SelectionRange[1];

						if(!bHold)
							m_SelectionRange[0] = m_SelectionRange[1];

						AdjustSelection();
						Invalidate(true);
					}
				}
				return TRUE;
			}
		case VK_DOWN:
			{
				int nRow, nCol;
				GetLastSelectedGridCell(nRow, nCol);
				if( (m_dayCells[nRow][nCol].date < m_BoundUp) && 
					(m_dayCells[nRow][nCol].date > m_BoundDown) )	
				{
					if(!bCtrl){
						m_RandomSelection.RemoveAll();
						m_SelectionRange[2] = 0;
					}
					else{
						if(m_RandomSelection.GetCount() == 0)
							m_RandomSelection.SetAt((void*)m_SelectionRange[0], 0);
					}

					if(nRow == CALENDAR_ROWS-1){
						newDate += COleDateTimeSpan(7,0,0,0);
						if((m_BoundUp > newDate) && (newDate > m_BoundDown))
						{
							m_nVscrollPos++;
							SetScrollPos(SB_VERT, m_nVscrollPos, TRUE);
							Goto(newDate);
						}
					}
					else
						nRow++;

					if( (m_dayCells[nRow][nCol].date < m_BoundUp) && 
						(m_dayCells[nRow][nCol].date > m_BoundDown) )	
					{	
						m_SelectionRange[1] = DateToSeconds(m_dayCells[nRow][nCol].date);
						if(bCtrl)
							m_SelectionRange[2] = m_SelectionRange[1];

						if(!bHold)
							m_SelectionRange[0] = m_SelectionRange[1];

						AdjustSelection();
						Invalidate(true);
					}
				}
				return TRUE;
			}
		case VK_LEFT:
			{
				int nRow, nCol;
				GetLastSelectedGridCell(nRow, nCol);
				if( (m_dayCells[nRow][nCol].date < m_BoundUp) && 
					(m_dayCells[nRow][nCol].date > m_BoundDown) )	
				{
					if(!bCtrl){
						m_RandomSelection.RemoveAll();
						m_SelectionRange[2] = 0;
					}
					else{
						if(m_RandomSelection.GetCount() == 0)
							m_RandomSelection.SetAt((void*)m_SelectionRange[0], 0);
					}
					if(nCol > 0) nCol--;
					else
					{
						nCol = CALENDAR_COLUMNS-1;
						if(nRow == 0){
							newDate -= COleDateTimeSpan(7,0,0,0);
							if((m_BoundUp > newDate) && (newDate > m_BoundDown))
							{
								m_nVscrollPos--;
								SetScrollPos(SB_VERT, m_nVscrollPos, TRUE);
								Goto(newDate);
							}
							else
								nCol = 0;
						}
						else
							nRow--;
					}

					if( (m_dayCells[nRow][nCol].date < m_BoundUp) && 
						(m_dayCells[nRow][nCol].date > m_BoundDown) )	
					{					
						m_SelectionRange[1] = DateToSeconds(m_dayCells[nRow][nCol].date);
						if(bCtrl)
							m_SelectionRange[2] = m_SelectionRange[1];

						if(!bHold)
							m_SelectionRange[0] = m_SelectionRange[1];

						AdjustSelection();
						Invalidate(true);
					}
				}
				return TRUE;
			}
		case VK_RIGHT:
			{
				int nRow, nCol;
				GetLastSelectedGridCell(nRow, nCol);
				if( (m_dayCells[nRow][nCol].date < m_BoundUp) && 
					(m_dayCells[nRow][nCol].date > m_BoundDown) )	
				{
					if(!bCtrl){
						m_RandomSelection.RemoveAll();
						m_SelectionRange[2] = 0;
					}
					else{
						if(m_RandomSelection.GetCount() == 0)
							m_RandomSelection.SetAt((void*)m_SelectionRange[0], 0);
					}
					if(nCol < CALENDAR_COLUMNS-1)	nCol++;
					else
					{
						nCol = 0;
						if(nRow == CALENDAR_ROWS-1){
							newDate += COleDateTimeSpan(7,0,0,0);
							if((m_BoundUp > newDate) && (newDate > m_BoundDown))
							{
								m_nVscrollPos++;
								SetScrollPos(SB_VERT, m_nVscrollPos, TRUE);
								Goto(newDate);
							}
							else
								nCol = CALENDAR_COLUMNS-1;
						}
						else
							nRow++;
					}
					
					if( (m_dayCells[nRow][nCol].date < m_BoundUp) && 
						(m_dayCells[nRow][nCol].date > m_BoundDown) )	
					{
						m_SelectionRange[1] = DateToSeconds(m_dayCells[nRow][nCol].date);
						if(bCtrl)
							m_SelectionRange[2] = m_SelectionRange[1];

						if(!bHold)
							m_SelectionRange[0] = m_SelectionRange[1];

						AdjustSelection();
						Invalidate(true);
					}
				}
				return TRUE;
			}
		}
	}
Esempio n. 5
0
void CCalendarCtrl::OnLButtonUp(UINT nFlags, CPoint point) 
{
	bool bHold = (GetKeyState(VK_SHIFT)>>8 == -1)?true:false;
	bool bCtrl = (GetKeyState(VK_CONTROL)>>8 == -1)?true:false;
	if(bHold) bCtrl = false; // allow one combination
	if(m_bSelectionStarted && !bCtrl)
	{
		m_RandomSelection.RemoveAll();
		m_bSelectionStarted = false;

		int nRow, nCol;
		if(GetGridCellFromPoint(point, nRow, nCol))
		{
			if( (m_dayCells[nRow][nCol].date < m_BoundUp) && 
				(m_dayCells[nRow][nCol].date > m_BoundDown) )			
				m_SelectionRange[1] = DateToSeconds(m_dayCells[nRow][nCol].date);
			else
				m_SelectionRange[1]=m_SelectionRange[0];
		}
		else
			m_SelectionRange[1]=m_SelectionRange[0];		
		ReleaseCapture();
		AdjustSelection();
		Invalidate(true);
	}

	if(bCtrl){
		int nRow, nCol;
		if(GetGridCellFromPoint(point, nRow, nCol))
		{
			if( (m_dayCells[nRow][nCol].date < m_BoundUp) && 
				(m_dayCells[nRow][nCol].date > m_BoundDown) )	
			{
				if(m_SelectionRange[2])
				{				
						m_SelectionRange[1] = DateToSeconds(m_dayCells[nRow][nCol].date);
						m_SelectionRange[0] = m_SelectionRange[1];

						void*p;
						if(m_RandomSelection.Lookup((void*)m_SelectionRange[1], p))
							m_RandomSelection.RemoveKey((void*)m_SelectionRange[1]);
						else{
							if(m_RandomSelection.GetCount() < m_nMaxSel)
								m_RandomSelection.SetAt((void*)m_SelectionRange[1], 0);
						}
						m_SelectionRange[2] = m_SelectionRange[1];
				}
				else{
					if(m_RandomSelection.GetCount() < m_nMaxSel)
						m_RandomSelection.SetAt((void*)m_SelectionRange[1], 0);
					m_SelectionRange[1] = DateToSeconds(m_dayCells[nRow][nCol].date);
					m_SelectionRange[0] = m_SelectionRange[1];
					if(m_RandomSelection.GetCount() < m_nMaxSel)
						m_RandomSelection.SetAt((void*)m_SelectionRange[1], 0);
					m_SelectionRange[2] = m_SelectionRange[1];
				}			
				Invalidate(true);
			}
		}
	}
	else{
		m_RandomSelection.RemoveAll();
		m_SelectionRange[2] = 0;
		Invalidate(true);
	}
	CWnd::OnLButtonUp(nFlags, point);
}