Esempio n. 1
0
bool ExGridCtrl::Key(dword key, int count)
{
	if (!_UseKeys && !IsEdit())
		return GridCtrl::Key(key, count);

	bool result;

	if (key == K_UP)
	{
		if (0 < curpos.y || curpos.y <= GetRowCount() + 1)
		{
			EndEdit();
			SetCursor(curpos.y - 1);
			result = GridCtrl::Key(key, count);
			StartEdit();
			return result;
		}
	}

	if (key == K_DOWN)
	{
		if (0 <= curpos.y || curpos.y < GetRowCount())
		{
			EndEdit();
			SetCursor(curpos.y - 1);
			result = GridCtrl::Key(key, count);
			StartEdit();
			return result;
		}
	}

	return GridCtrl::Key(key, count);
}
Esempio n. 2
0
void
BTextWidget::MouseUp(BRect bounds, BPoseView *view, BPose *pose, BPoint)
{
	// Start editing without delay if the pose was selected recently and this
	// click is not the second click of a doubleclick.
	// If the pose has been selected a long time ago, check again
	// for a double click (inducing a delay).

	// TODO: re-enable modifiers, one should be enough

	if (IsEditable() && pose->IsSelected()) {
		bigtime_t delta = system_time() - pose->SelectionTime();
		bigtime_t doubleClickSpeed;
		get_click_speed(&doubleClickSpeed);
		bigtime_t oldClickSpeed = 2 * doubleClickSpeed;

		// freshly selected and not a double click
		if (delta > doubleClickSpeed && delta < oldClickSpeed) {
			StartEdit(bounds, view, pose);
			return;
		}

		// TODO: reimplement asynchronous
		// selected a longer time ago, redo a double click detection
		if (delta > oldClickSpeed) {
			// check for double click
			bigtime_t doubleClickTime = system_time() + doubleClickSpeed;
			while (system_time() < doubleClickTime) {
				// loop for double-click time and watch the mouse and keyboard

				BPoint point;
				uint32 buttons;
				view->GetMouse(&point, &buttons, false);

				// double click
				if (buttons)
					return;

				// mouse moved too far
				if (!bounds.Contains(point))
					return;

				//if (modifiers() & (B_SHIFT_KEY | B_COMMAND_KEY
				//	| B_CONTROL_KEY | B_MENU_KEY))
				//	// watch the keyboard (ignoring standard locking keys)
				//	break;

				snooze(10000);
			}
			StartEdit(bounds, view, pose);
		}
	}
}
Esempio n. 3
0
void ExGridCtrl::OnLeftClick()
{
	if (!_UseKeys)
		return;
	SetCursor( Point(1, curpos.y - 1) );
	StartEdit();
}
void ProdRestartGridCtrl::FinishEdit(const char* szText, int nValue, int nLastChar)
{
  int index = m_cellActive.m_nRow - 1;

  UnitReal temp(productionRestartUnits, productionRestartTimes[index]);
  if (temp.IsWithinRange(szText, -1.0E+08, 1.0E+08))
  {
    productionRestartTimes[index] = temp.GetMetricVal();
    if (index > productionRestartTimes.UpperBound())
      productionRestartTimes.SetSize(index + 1);
  }
  StopEdit(false);

  UpdateAllRows();


  // if the right key continue editing on next cell
  switch (nLastChar) {
  case VK_TAB:
  case VK_DOWN:
  case VK_UP:
  case VK_RIGHT:
  case VK_LEFT:
  case VK_NEXT:
  case VK_PRIOR:
  case VK_HOME:
  case VK_END:
    OnKeyDown(nLastChar, 0, 0);
    UpdateWindow();
    if (m_cellActive != m_cellActiveOld)
      StartEdit(nLastChar);
    break;
  }
}
Esempio n. 5
0
void XYGridControl::FinishEdit(const char* szText, int nValue, int nLastChar)
{
    int nIndex = m_cellActive.m_nRow - 1;

    // Change values in Grid
    CGridCell* pCell = GetCell(m_cellActive.m_nRow, m_cellActive.m_nCol);
    double val;
    switch (m_cellActive.m_nCol) {
    case 1: // X
        if (!IsValidReal(szText, val))
        {
            val = nullReal;
        }
        if (nIndex < xyData.Size())
        {
            xyData[nIndex].x = val;
        }
        else
        {
            xyData.SetAtGrow(nIndex, XYItem(val, 0.0));
        }
        break;
    case 2: // Y
        if (!IsValidReal(szText, val))
        {
            val = nullReal;
        }
        if (nIndex < xyData.Size())
        {
            xyData[nIndex].y = val;
        }
        else
        {
            xyData.SetAtGrow(nIndex, XYItem(0.0, val));
        }
        break;
    }

    ResetCell(m_cellActive.m_nRow, m_cellActive.m_nCol);

    StopEdit(false);

    // if the right key continue editing on next cell
    switch (nLastChar) {
        case VK_TAB:
        case VK_DOWN:
        case VK_UP:
        case VK_RIGHT:
        case VK_LEFT:
        case VK_NEXT:
        case VK_PRIOR:
        case VK_HOME:
        case VK_END:
            OnKeyDown(nLastChar, 0, 0);
            UpdateWindow();
            if (m_cellActive != m_cellActiveOld)
                StartEdit(nLastChar);
            break;
    }
}
Esempio n. 6
0
/////////////////////////////////////////////////////////////////////////////
//	OnCharDown
//		Sent when grid received a WM_CHAR message, usually as a result
//		of a user pressing any key that represents a printable characrer.
//	Params:
//		vcKey		- virtual key code of the key user has pressed
//		processed	- indicates if current event was processed by other control in the grid.
//	Return:
//		<none>
void CDropDayCug::OnCharDown(UINT *vcKey,BOOL processed)
{
	UNREFERENCED_PARAMETER(*vcKey);
	UNREFERENCED_PARAMETER(processed);

	StartEdit( *vcKey );
}
Esempio n. 7
0
    void ColorMapGridControl::FinishEdit(const char* szText, int nValue, int nLastChar)
    {
        int rowIndex = m_cellActive.m_nRow - 1;
        int colIndex = m_cellActive.m_nCol - 1;

        double val;
        if ((!IsValidReal(szText, val)) || (val < 0.0) || (val > 1.0))
            val = 0.0;

        SC_ColorSpec& currSpec = gColorMap.colorMapColors[rowIndex];

        switch (colIndex )
            {
            case 0 : {currSpec.RH = val; break;}
            case 1 : {currSpec.GS = val; break;}
            case 2 : {currSpec.BV = val; break;}
            case 3 : {break;}
            }

        if (rowIndex >= gColorMap.ncolorMap)
            {
                for (int i = gColorMap.ncolorMap; i < rowIndex; i++)
                    gColorMap.colorMapColors[i] = SC_ColorSpec(0.0, 0.0, 0.0);
                m_nCurrRow = gColorMap.ncolorMap - 1;
                gColorMap.ncolorMap = rowIndex + 1;
                UpdateModifiedRows();
            }
        else
            {
                for (int j = 1; j < GetColCount(); j++)
                    {
                        CGridCell* pCell = GetCell(rowIndex + 1, j);
                        pCell->UpdateText();
                        InvalidateCell(rowIndex + 1, j);
                    }
            }

        ResetCell(m_cellActive.m_nRow, m_cellActive.m_nCol);

        StopEdit(false);

        // if the right key continue editing on next cell
        switch (nLastChar) {
        case VK_TAB:
        case VK_DOWN:
        case VK_UP:
        case VK_RIGHT:
        case VK_LEFT:
        case VK_NEXT:
        case VK_PRIOR:
        case VK_HOME:
        case VK_END:
            OnKeyDown(nLastChar, 0, 0);
            UpdateWindow();
            if (m_cellActive != m_cellActiveOld)
                StartEdit(nLastChar);
            break;
        }
    }
Esempio n. 8
0
void CReportCtrlEx2::_MouseClkMonitor(UINT nMsg, UINT nFlags, CPoint point, BOOL bTriggerEdit)
{
	LVHITTESTINFO hti;
	hti.pt = point;
	const int IDX = SubItemHitTest(&hti);
	const BOOL BEFORE = CListCtrl::GetCheck(IDX) > 0;
	const BOOL WAS_EDIT = _IsEditVisible();
	EndItem(TRUE);
	const BOOL WASACTIVE = bTriggerEdit ? ExamItemStates(IDX, RC_ITEM_FOCUSED | RC_ITEM_SELECTED) : FALSE;

	switch (nMsg)
	{
	case WM_LBUTTONDOWN:
		CListCtrl::OnLButtonDown(nFlags, point);
		break;

	case WM_LBUTTONDBLCLK:
		CListCtrl::OnLButtonDblClk(nFlags, point);
		break;

	case WM_MBUTTONDOWN:
		CListCtrl::OnMButtonDown(nFlags, point);
		break;

	case WM_MBUTTONDBLCLK:
		CListCtrl::OnMButtonDblClk(nFlags, point);
		break;

	case WM_RBUTTONDOWN:
		CListCtrl::OnRButtonDown(nFlags, point);
		break;

	case WM_RBUTTONDBLCLK:
		CListCtrl::OnRButtonDblClk(nFlags, point);
		break;

	default:
		break;		
	}
	
	const BOOL STATSCHANGED = _ItemCheckMonitor(IDX, BEFORE, CListCtrl::GetCheck(IDX) > 0, nMsg);

	if (bTriggerEdit && m_bAllowEdit && !STATSCHANGED && !WAS_EDIT && WASACTIVE)
	{
		if (hti.iSubItem == 4 || hti.iSubItem == 5)
		{
			m_bEdit = FALSE;
			StartDateTimeCtrl(IDX, hti.iSubItem);
		}
		else
		{
			m_bEdit = TRUE;
			StartEdit(IDX, hti.iSubItem);
		}
	}
}
Esempio n. 9
0
/////////////////////////////////////////////////////////////////////////////
//	OnDClicked
//		Sent whenever the user double clicks the left mouse button within the grid
//	Params:
//		col, row	- coordinates of a cell that received mouse click event
//		processed	- indicates if current event was processed by other control in the grid.
//		rect		- represents the CDC rectangle of cell in question
//		point		- represents the screen point where the mouse event was detected
//	Return:
//		<none>
void CDropDayCug::OnDClicked(int col,long row,RECT *rect,POINT *point,BOOL processed)
{
	UNREFERENCED_PARAMETER(col);
	UNREFERENCED_PARAMETER(row);
	UNREFERENCED_PARAMETER(*rect);
	UNREFERENCED_PARAMETER(*point);
	UNREFERENCED_PARAMETER(processed);

	StartEdit();
}	
Esempio n. 10
0
void ArpIntControl::MessageReceived(BMessage *msg)
{
	switch (msg->what) {
		case EDIT_START_MSG:
			StartEdit();
			break;
		case INLINE_FINALUPDATE_MSG:
			StopEdit();
			break;
		default:
			inherited::MessageReceived(msg);
			break;
	}
}
Esempio n. 11
0
void CDDBaseGrid::OnCharDown(UINT* vcKey, BOOL processed)
{ 
   // Save the current selection, starting edit will clear a multi-select but we want it.
   CaptureSelection();

   // Pressing a char key starts edit in cell.
   // Passing in a char will wipe out current cell contents, ie char replaces contents,
   // because edit starts with whole cell content selected.
   // If char is Enter then start edit but send no chars, i.e. do not update cell, just start editing.

   if (*vcKey == 13)
   {
      StartEdit( );
   }
   else if (*vcKey == 22) // ctrl-v, aka Paste
   {
      int col = this->GetCurrentCol();
      int row = this->GetCurrentRow();
      CWnd *peditctrl;
      if (this->OnEditStart(col, row, &peditctrl))   // dis-allows pasting into non-edit cells
      {
         this->Paste();
         this->BestFit(0, GetNumberCols()-1, myUG_FIT_ALL_ROWS, UG_BESTFIT_TOPHEADINGS);
         CString value;
         this->QuickGetText(col, row, &value);
         this->OnEditFinish(col, row, peditctrl, value, FALSE);
      }

      //StartEdit();
   }
   else
   {
      StartEdit(*vcKey);
   }

   RefreshSelection();
}
Esempio n. 12
0
/////////////////////////////////////////////////////////////////////////////
//	OnDClicked
//		Sent whenever the user double clicks the left mouse button within the grid
//	Params:
//		col, row	- coordinates of a cell that received mouse click event
//		processed	- indicates if current event was processed by other control in the grid.
//		rect		- represents the CDC rectangle of cell in question
//		point		- represents the screen point where the mouse event was detected
//	Return:
//		<none>
void CDDBaseGrid::OnDClicked(int col,long row,RECT *rect,POINT *point,BOOL processed)
{
	//UNREFERENCED_PARAMETER(col);
	//UNREFERENCED_PARAMETER(row);
	UNREFERENCED_PARAMETER(*rect);
	UNREFERENCED_PARAMETER(*point);
	UNREFERENCED_PARAMETER(processed);

   // Double click terminates/undoes any multi-select
   // Double click is always a single-cell edit

   this->ClearSelections();
   CaptureSelection();
 

   StartEdit(col, row, 0);
}
Esempio n. 13
0
void ArpIntControl::AddAscii(char byte)
{
	int32	newValue = Value();

	if (byte == B_UP_ARROW) newValue = Value() + mKeyStep;
	else if (byte == B_DOWN_ARROW) newValue = Value() - mKeyStep;
	else if (byte == '+') newValue = abs( Value() );
	else if (byte == '-') newValue = 0 - abs( Value() );
	else if (byte == B_SPACE) StartEdit();
	else return;

	if (newValue < Min()) newValue = Min();
	if (newValue > Max()) newValue = Max();
	if (newValue != Value()) {
		SetValue(newValue);
		NotifyHook(newValue);
	}
}
Esempio n. 14
0
void
BTextWidget::CheckExpiration()
{
	if (IsEditable() && fParams.pose->IsSelected() && fLastClickedTime) {
		bigtime_t doubleClickSpeed;
		get_click_speed(&doubleClickSpeed);

		bigtime_t delta = system_time() - fLastClickedTime;

		if (delta > doubleClickSpeed) {
			// at least 'doubleClickSpeed' microseconds ellapsed and no click
			// was registered since.
			fLastClickedTime = 0;
			StartEdit(fParams.bounds, fParams.poseView, fParams.pose);
		}
	} else {
		fLastClickedTime = 0;
		fParams.poseView->SetTextWidgetToCheck(NULL);
	}
}
Esempio n. 15
0
void SkeinWindow::OnContextMenu(CWnd* pWnd, CPoint point)
{
  // No menu if currently editing
  if (m_edit.IsWindowVisible())
    return;

  // No menu if running the game
  bool gameRunning = GetParentFrame()->SendMessage(WM_GAMERUNNING) != 0;
  bool gameWaiting = GetParentFrame()->SendMessage(WM_GAMEWAITING) != 0;
  if (gameRunning && !gameWaiting)
    return;

  // Find the node under the mouse, if any
  CPoint cp(point);
  ScreenToClient(&cp);
  Skein::Node* node = NodeAtPoint(cp);
  if (node == NULL)
    return;

  // Get the context menu
  CMenu popup;
  popup.LoadMenu(IDR_SKEIN);
  CMenu* menu = popup.GetSubMenu(0);

  // Update the state of the context menu items
  if (node->GetParent() == NULL)
  {
    menu->RemoveMenu(ID_SKEIN_EDIT,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_ADD_LABEL,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_EDIT_LABEL,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_INSERT_KNOT,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_DELETE,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_DELETE_BELOW,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_DELETE_THREAD,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_LOCK,MF_BYCOMMAND|MF_GRAYED);
    menu->RemoveMenu(ID_SKEIN_UNLOCK,MF_BYCOMMAND|MF_GRAYED);
    menu->RemoveMenu(ID_SKEIN_LOCK_THREAD,MF_BYCOMMAND|MF_GRAYED);
    menu->RemoveMenu(ID_SKEIN_UNLOCK_THREAD,MF_BYCOMMAND|MF_GRAYED);
  }
  else
  {
    if (gameRunning && m_skein->InCurrentThread(node))
    {
      menu->EnableMenuItem(ID_SKEIN_DELETE,MF_BYCOMMAND|MF_GRAYED);
      menu->EnableMenuItem(ID_SKEIN_DELETE_BELOW,MF_BYCOMMAND|MF_GRAYED);
    }
    if (gameRunning && m_skein->InCurrentThread(m_skein->GetThreadTop(node)))
      menu->EnableMenuItem(ID_SKEIN_DELETE_THREAD,MF_BYCOMMAND|MF_GRAYED);
    if (node->GetLabel().IsEmpty())
      menu->RemoveMenu(ID_SKEIN_EDIT_LABEL,MF_BYCOMMAND);
    else
      menu->RemoveMenu(ID_SKEIN_ADD_LABEL,MF_BYCOMMAND);
  }
  if (node->GetTemporary())
  {
    menu->RemoveMenu(ID_SKEIN_UNLOCK,MF_BYCOMMAND|MF_GRAYED);
    menu->RemoveMenu(ID_SKEIN_UNLOCK_THREAD,MF_BYCOMMAND|MF_GRAYED);
  }
  else
  {
    menu->RemoveMenu(ID_SKEIN_LOCK,MF_BYCOMMAND|MF_GRAYED);
    menu->RemoveMenu(ID_SKEIN_LOCK_THREAD,MF_BYCOMMAND|MF_GRAYED);
  }

  // Show the context menu
  int cmd = menu->TrackPopupMenuEx(TPM_LEFTALIGN|TPM_TOPALIGN|TPM_NONOTIFY|TPM_RETURNCMD,
    point.x,point.y,GetParentFrame(),NULL);

  // Act on the context menu choice
  switch (cmd)
  {
  case ID_SKEIN_PLAY:
    GetParentFrame()->SendMessage(WM_PLAYSKEIN,(WPARAM)node);
    break;
  case ID_SKEIN_EDIT:
    StartEdit(node,false);
    break;
  case ID_SKEIN_ADD_LABEL:
  case ID_SKEIN_EDIT_LABEL:
    // Make sure that the label background is visible
    Invalidate();
    StartEdit(node,true);
    break;
  case ID_SKEIN_TRANSCRIPT:
    GetParentFrame()->SendMessage(WM_SHOWTRANSCRIPT,(WPARAM)node,(LPARAM)GetSafeHwnd());
    break;
  case ID_SKEIN_LOCK:
    m_skein->Lock(node);
    break;
  case ID_SKEIN_UNLOCK:
    m_skein->Unlock(node);
    break;
  case ID_SKEIN_LOCK_THREAD:
    m_skein->Lock(m_skein->GetThreadBottom(node));
    break;
  case ID_SKEIN_UNLOCK_THREAD:
    m_skein->Unlock(m_skein->GetThreadTop(node));
    break;
  case ID_SKEIN_NEW_THREAD:
    {
      Skein::Node* newNode = m_skein->AddNew(node);

      // Force a repaint so that the new node is drawn and recorded
      Invalidate();
      UpdateWindow();
      StartEdit(newNode,false);
    }
    break;
  case ID_SKEIN_INSERT_KNOT:
    {
      Skein::Node* newNode = m_skein->AddNewParent(node);
      Invalidate();
      UpdateWindow();
      StartEdit(newNode,false);
    }
    break;
  case ID_SKEIN_DELETE:
    if (CanRemove(node))
      m_skein->RemoveSingle(node);
    break;
  case ID_SKEIN_DELETE_BELOW:
    if (CanRemove(node))
      m_skein->RemoveAll(node);
    break;
  case ID_SKEIN_DELETE_THREAD:
    {
      Skein::Node* topNode = m_skein->GetThreadTop(node);
      if (CanRemove(topNode))
        m_skein->RemoveAll(topNode);
    }
    break;
  case ID_SKEIN_SAVE_TRANSCRIPT:
    {
      SimpleFileDialog dialog(FALSE,"txt",NULL,OFN_HIDEREADONLY|OFN_ENABLESIZING,
        "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||",this);
      dialog.m_ofn.lpstrTitle = "Save the transcript up to this knot";
      if (dialog.DoModal() == IDOK)
        m_skein->SaveTranscript(node,dialog.GetPathName());
    }
    break;
  case 0:
    // Make sure this window still has the focus
    SetFocus();
    break;
  }
}
Esempio n. 16
0
/////////////////////////////////////////////////////////////////////////////
//	OnCharDown
//		Sent whenever the user types when the grid has focus. The keystroke can be 
//		modified here as well. (See WM_CHAR for more information)
void MyCug::OnCharDown(UINT *vcKey,BOOL processed)
{
	StartEdit( *vcKey );
}
Esempio n. 17
0
void CTWenUGCtrlEx::OnDClicked(int col,long row,RECT *rect,POINT *point,BOOL processed)
{
	CUGCell cell;
	GetCell(col, row, &cell);
	if(!cell.GetReadOnly()) StartEdit(col, row, 0);
}
Esempio n. 18
0
void MyCug::OnDClicked(int col,long row,RECT *rect,POINT *point,BOOL processed)
{
	StartEdit();
}
Esempio n. 19
0
void TestZoneCurveGridCtrl::FinishEdit(const char* szText, int nValue, int nLastChar)
{
    int tzcIndex = m_cellActive.m_nRow - 1;

    bool updateAll = (testZoneCurves.IsNotValid(tzcIndex));

    sequence.CheckAndAllocTestZoneCurve(tzcIndex);
    TestZoneCurve& currTZC = testZoneCurves.GetRef(tzcIndex);

    // Change values in Grid
    CGridCell* pCell = GetCell(m_cellActive.m_nRow, m_cellActive.m_nCol);
    switch (m_cellActive.m_nCol) {
    case 1: // Type
        {
            static_cast<CurveTypeGridCell*>(pCell)->SetTestZoneCurveType(nValue);
            break;

        }
    case 2: // ID
        {
            if (control.UseCurveFiles())
                static_cast<CurveDesigGridCell*>(pCell)->SetTestZoneCurveDesig(nValue);
            else
                static_cast<CurveFOGridCell*>(pCell)->SetTestZoneCurveFO(nValue);
            break;
        }
    case 3: // start seq
        {
            static_cast<StartSequenceDesigGridCell*>(pCell)->SetStartSequence(nValue);
            ResetCell(m_cellActive.m_nRow, 4);
            break;
        }
    case 4: // end seq
        {
            static_cast<EndSequenceDesigGridCell*>(pCell)->SetEndSequence(nValue);
            break;
        }
    case 5: // seq data or duration status
        {
        }
        break;
    }


    if (updateAll)
    {
        for (int i = 1; i < GetColCount(); i++)
            ResetCell(m_cellActive.m_nRow, i);
    }
    else
    {
        ResetCell(m_cellActive.m_nRow, m_cellActive.m_nCol);
        ResetCell(m_cellActive.m_nRow, 5);
    }


    StopEdit(false);

    // if the right key continue editing on next cell
    switch (nLastChar) {
        case VK_TAB:
        case VK_DOWN:
        case VK_UP:
        case VK_RIGHT:
        case VK_LEFT:
        case VK_NEXT:
        case VK_PRIOR:
        case VK_HOME:
        case VK_END:
            OnKeyDown(nLastChar, 0, 0);
            UpdateWindow();
            if (m_cellActive != m_cellActiveOld)
                StartEdit(nLastChar);
            break;
    }
}
Esempio n. 20
0
BOOL CReportCtrl::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if (pMsg->message == WM_KEYDOWN)
	{
		if (!_IsEditVisible())
		{
			// disable user from check/uncheck the checkboxes using space key
			// things get nasty if the user is HOLDING the space bar down
			if (pMsg->wParam == VK_SPACE)
				return TRUE;
		}
		else
		{
			POINT pt = m_ptEditting;
			switch (pMsg->wParam)
			{
			case VK_ESCAPE: // Cancel edit
				EndEdit(FALSE);
				return TRUE;

			case VK_RETURN: // Commit edit
				EndEdit(TRUE);
				return TRUE;

			case VK_TAB: // switch edit sub items
				if (pt.y == GetColumnCount() - 1)
					pt.y = 0;
				else
					pt.y++;
				EndEdit(TRUE);
				StartEdit(pt.x, pt.y);
				return TRUE;

			case VK_UP: // edit upper item
				if (pt.x > 0)
				{
					pt.x--;
					EndEdit(TRUE);
					StartEdit(pt.x, pt.y);
					EnsureVisible(pt.x, FALSE);
					return TRUE;
				}
				break;
				
			case VK_DOWN: // edit lower item
				if (pt.x < CListCtrl::GetItemCount() - 1)
				{
					pt.x++;
					EndEdit(TRUE);
					StartEdit(pt.x, pt.y);
					EnsureVisible(pt.x, FALSE);
					return TRUE;
				}
				break;			

			default:
				break;				
			}
		}
	}

	return CListCtrl::PreTranslateMessage(pMsg);
}
Esempio n. 21
0
/***************************************************
OnDClicked
	Sent whenever the user double clicks the left mouse
	button within the grid

	'col' and 'row' are negative if the area clicked
	in is not a valid cell
	'rect' the rectangle of the cell that was clicked in
	'point' the point where the mouse was clicked
****************************************************/
void MyCug::OnDClicked(int col,long row,RECT *rect,POINT *point,BOOL processed){
	// when mouse is double clicked on a individual cell, start editing mode
	StartEdit();
}				 
Esempio n. 22
0
void DataCaptureGridCtrl::FinishEdit(const char* szText, int nValue, int nLastChar)
{
  dataCaptureUIChange = true;

  int dCapIndex = m_cellActive.m_nRow - 1;

  bool wasInvalid  = (dataCaptureData.IsNotValid(dCapIndex));

  dataCapture.CheckAndAllocDataCapture(dCapIndex);
  DataCaptureSpec& currRef = dataCaptureData.GetRef(dCapIndex);

  // Change values in Grid
  CGridCell* pCell = GetCell(m_cellActive.m_nRow, m_cellActive.m_nCol);

  int currCol = m_cellActive.m_nCol;
  if ((!control.IsLayered()) && (currCol > 3))
    currCol++;

  if (control.Is2DRadial() && (currCol == 6))
    currCol = 7;

  switch (currCol) {
  case 1: // desig
  {
    if (!SameString(currRef.dataDesig, szText))
      currRef.makeDefaultDataDesig = false;

    CopyString(currRef.dataDesig, szText, DataCaptureSpec::dataDesigLen);

    if ((dCapIndex == 0) && (currRef.IsWell() && currRef.IsPressure()))
    {
      // changing main well name -- change for flow too
      if (dataCaptureData.IsValid(1))
      {
        DataCaptureSpec& flowRef = dataCaptureData.GetRef(1);
        if (flowRef.IsFlow() && flowRef.IsWell())
        {
          CopyString(flowRef.dataDesig, szText, DataCaptureSpec::dataDesigLen);
          ResetCell(2, 1);
        }
      }
    }
    // adding new -- assume obs well
    if (wasInvalid)
    {
      currRef.captureType = DataCaptureSpec::ctPressure;
      currRef.pressureCapType = DataCaptureSpec::pctRadius;
    }
    break;
  }
  case 2: // Type
  {
    static_cast<CaptureTypeGridCell*>(pCell)->SetDataCaptureType(nValue);
    break;

  }
  case 3: // sub-type
  {
    static_cast<CaptureSubTypeGridCell*>(pCell)->SetDataCaptureSubType(nValue);
    break;
  }
  case 4: // zone
  {
    static_cast<DcapWellboreZoneDesigGridCell*>(pCell)->SetWellboreZone(nValue);
    break;
  }
  case 5: // radii
  {
    if (currRef.UsesRadius())
    {
      if (currRef.IsPressure() && (control.Is2DRadial() || control.IsHorizontalAnisotropic()))
        ResetCell(m_cellActive.m_nRow, 5);
      else
        currRef.radiusData.IsWithinRange(szText, 0.001, 1.0E+05);
    }
    break;
  }
  case 6: // radii units
  {
    if (currRef.UsesRadiusUnits())
    {
      currRef.radiusData.SetConvIndex(nValue);
      if (currRef.UsesRadius())
        ResetCell(m_cellActive.m_nRow, 4);
    }
    break;
  }
  case 7: // output units
  {
    currRef.outputUnits.SetConvIndex(nValue);
    break;
  }

  }

  // update all
  for (int i = 1; i < GetColCount(); i++)
    ResetCell(m_cellActive.m_nRow, i);

  OutputUnitsGridCell* currCell = static_cast<OutputUnitsGridCell*>(GetCell(m_cellActive.m_nRow, GetColCount() - 1));
  currCell->SetUnitType(currRef.outputUnits.unitType);

  if (dataCapture.SetDataCaptureDesigs())
  {
    for (int i = m_cellActive.m_nRow; i < GetRowCount(); i++)
      ResetCell(i, 1);
  }

  StopEdit(false);

  // if the right key continue editing on next cell
  switch (nLastChar) {
  case VK_TAB:
  case VK_DOWN:
  case VK_UP:
  case VK_RIGHT:
  case VK_LEFT:
  case VK_NEXT:
  case VK_PRIOR:
  case VK_HOME:
  case VK_END:
    OnKeyDown(nLastChar, 0, 0);
    UpdateWindow();
    if (m_cellActive != m_cellActiveOld)
      StartEdit(nLastChar);
    break;
  }
}
Esempio n. 23
0
BOOL CReportCtrlEx2::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if (pMsg->message == WM_KEYDOWN)
	{	if (!_IsEditVisible())
		{
			// disable user from check/uncheck the checkboxes using space key
			// things get nasty if the user is HOLDING the space bar down
			if (pMsg->wParam == VK_SPACE)
				return TRUE;
		}
		else
		{
			POINT pt = m_ptEditting;
			switch (pMsg->wParam)
			{
			case VK_ESCAPE: // Cancel edit
				EndItem(FALSE);
				return TRUE;

			case VK_RETURN: // Commit edit
				EndItem(TRUE);
				return TRUE;

			case VK_TAB: // switch edit sub items

					if (pt.y == GetColumnCount() - 1)
					{
						pt.y = 0;
						if (pt.x < CListCtrl::GetItemCount() - 1)
							pt.x++;
						else
							pt.x = 0;						
					}
					else
						pt.y++;

					EndItem(TRUE);

					// Si es el primer elemento hacemos el scroll hacia la izquierda
					if (pt.y == 0)
						SendMessage( WM_HSCROLL, SB_LEFT, 0 );
					// Si llegamos al elemento no visible se hace scroll a la derecha
					if (pt.y == 8)
						SendMessage( WM_HSCROLL, SB_RIGHT, 0 );	

					EnsureVisible(pt.x, FALSE);

					if (pt.y == 4 || pt.y == 5)
					{
						m_bEdit = FALSE;
						StartDateTimeCtrl(pt.x, pt.y);
					}
					else
					{
						m_bEdit = TRUE;
						StartEdit(pt.x, pt.y);
					}

					//if (m_bEdit && !m_pWndEdit->IsWindowVisible())
					//	SendMessage( WM_HSCROLL, /*SB_LINERIGHT*/SB_RIGHT, 0 );
					return TRUE;

			case VK_UP: // edit upper item
				if (pt.x > 0)
				{
					pt.x--;

					EndItem(TRUE);
				
					EnsureVisible(pt.x, FALSE);

					if (pt.y == 4 || pt.y == 5)
					{
						m_bEdit = FALSE;
						StartDateTimeCtrl(pt.x, pt.y);
					}
					else
					{
						m_bEdit = TRUE;
						StartEdit(pt.x, pt.y);
					}

					//EnsureVisible(pt.x, FALSE);

					return TRUE;
				}
				break;
				
			case VK_DOWN: // edit lower item
				if (pt.x < CListCtrl::GetItemCount() - 1)
				{
					pt.x++;

					EndItem(TRUE);

					EnsureVisible(pt.x, FALSE);

					if (pt.y == 4 || pt.y == 5)
					{
						m_bEdit = FALSE;
						StartDateTimeCtrl(pt.x, pt.y);
					}
					else
					{
						m_bEdit = TRUE;
						StartEdit(pt.x, pt.y);
					}
					
					//EnsureVisible(pt.x, FALSE);

					return TRUE;
				}
				break;			

			case VK_RIGHT: // edit lower item

				// Si estamos en la columna de la descripcion no se puede navegar por el
				// liscontrol a la derecha puesto que nos movemos dentro del texto
				if (pt.y != 11)
				{
					if (pt.y < GetColumnCount() - 1)
					{
						pt.y++;
					}
					else
					{
						pt.y = 0;
						if (pt.x < CListCtrl::GetItemCount() - 1)
							pt.x++;
						else
							pt.x = 0;
					}

					EndItem(TRUE);

					// Si es el primer elemento hacemos el scroll hacia la izquierda
					if (pt.y == 0)
						SendMessage( WM_HSCROLL, SB_LEFT, 0);
					// Si llegamos al elemento no visible se hace scroll a la derecha
					if (pt.y == 8)
						SendMessage( WM_HSCROLL, SB_RIGHT, 0 );

					EnsureVisible(pt.x, FALSE);

					if (pt.y == 4 || pt.y == 5)
					{
						m_bEdit = FALSE;
						StartDateTimeCtrl(pt.x, pt.y);
					}
					else
					{
						m_bEdit = TRUE;
						StartEdit(pt.x, pt.y);
					}
					
					return TRUE;
				}

				break;			

			case VK_LEFT: // edit lower item

				// Si estamos en la columna de la descripcion no se puede navegar por el
				// liscontrol a la izquierda puesto que nos movemos dentro del texto
				if (pt.y != 11)
				{
					if (pt.y > 0)
					{
						pt.y--;
					}
					else
					{
						pt.y = GetColumnCount()-1;
						if (pt.x == 0)
						{
							pt.y = 0;
							pt.x = CListCtrl::GetItemCount()-1;						
						}
						else
							pt.x--;
					}					

					EndItem(TRUE);

					// Si estamos en el 3 elemento del CListCtrl se hace scroll a la izquierda
					// porque es el primero que deja de ser visible
					if (pt.y == 3)
						SendMessage( WM_HSCROLL, SB_LEFT, 0 );
					// Si es el último elemento hacemos el scroll hacia la derecha
					if (pt.y == GetColumnCount()-1)
						SendMessage( WM_HSCROLL, SB_RIGHT, 0);					

					EnsureVisible(pt.x, FALSE);

					if (pt.y == 4 || pt.y == 5)
					{
						m_bEdit = FALSE;
						StartDateTimeCtrl(pt.x, pt.y);
					}
					else
					{
						m_bEdit = TRUE;
						StartEdit(pt.x, pt.y);
					}

					return TRUE;
				}

				break;

			default:
				break;				
			}
		}
	}

	return CListCtrl::PreTranslateMessage(pMsg);
}
Esempio n. 24
0
/*
================
rvPropertyGrid::FinishEdit

Finish editing by copying the data in the edit control to the internal value
================
*/
void rvPropertyGrid::FinishEdit ( void )
{
	char				value[1024];
	rvPropertyGridItem* item;
	bool				update;
	
	if ( mState != STATE_EDIT )
	{
		return;
	}

	assert ( mEditItem >= 0 );
	
	mState = STATE_FINISHEDIT;
	
	update = false;
	item = (rvPropertyGridItem*)SendMessage ( mWindow, LB_GETITEMDATA, mEditItem, 0 );
	assert ( item );													
						
	GetWindowText ( mEdit, value, 1023 );
	
	if ( !value[0] )
	{
		mState = STATE_EDIT;
		MessageBeep ( MB_ICONASTERISK );
		return;
	}
	
	if ( !mEditLabel && item->mValue.Cmp ( value ) )
	{
		NMPROPGRID nmpg;
		nmpg.hdr.code = PGN_ITEMCHANGED;
		nmpg.hdr.hwndFrom = mWindow;
		nmpg.hdr.idFrom = GetWindowLong ( mWindow, GWL_ID );
		nmpg.mName  = item->mName;
		nmpg.mValue = value;										

		if ( !SendMessage ( GetParent ( mWindow ), WM_NOTIFY, 0, (LONG)&nmpg ) )
		{
			mState = STATE_EDIT;
			SetFocus ( mEdit );
			return;
		}

		// The item may have been destroyed and recreated in the notify call so get it again
		item = (rvPropertyGridItem*)SendMessage ( mWindow, LB_GETITEMDATA, mEditItem, 0 );
		if ( item )
		{
			item->mValue = value;						
			update = true;
		}
	}
	else if ( mEditLabel && item->mName.Cmp ( value ) )
	{
		int sel;
		sel = AddItem ( value, "", PGIT_STRING );
		SetCurSel ( sel );
		StartEdit ( sel, false );
		return;
	}	

	SetCurSel ( mEditItem );

	mState = STATE_NORMAL;
	mEditItem = -1;

	ShowWindow ( mEdit, SW_HIDE );	
	SetFocus ( mWindow );
}