void
JX2DCurveNameList::HandleKeyPress
	(
	const int				key,
	const JXKeyModifiers&	modifiers
	)
{
	JPoint cell;
	JTableSelection& s = GetTableSelection();
	const JBoolean ok  = s.GetFirstSelectedCell(&cell);
	assert( ok );

	if (key == kJUpArrow)
		{
		cell.y--;
		if (CellValid(cell))
			{
			BeginEditing(cell);
			}
		}
	else if (key == kJDownArrow)
		{
		cell.y++;
		if (CellValid(cell))
			{
			BeginEditing(cell);
			}
		}

	else
		{
		JXEditTable::HandleKeyPress(key, modifiers);
		}
}
void
GLFitParameterTable::HandleKeyPress
	(
	const int 				key,
	const JXKeyModifiers&	modifiers
	)
{
	JPoint cell;
	if (key == kJReturnKey && GetEditedCell(&cell))
		{
		if (EndEditing())
			{
			if (!modifiers.shift() && cell.y < (JCoordinate)GetRowCount())
				{
				BeginEditing(JPoint(cell.x, cell.y + 1));
				}
			else if (modifiers.shift() && cell.y > 1)
				{
				BeginEditing(JPoint(cell.x, cell.y - 1));
				}
			}
		}
	else if (key == kJTabKey)
		{
		// do nothing
		}

	else
		{
		JXEditTable::HandleKeyPress(key, modifiers);
		}
}
void
GMAccountList::HandleMouseDown
	(
	const JPoint&			pt,
	const JXMouseButton	button,
	const JSize			clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	JPoint cell;
	if (button == kJXLeftButton && clickCount == 1 &&
		GetCell(pt, &cell))
		{
		JTableSelection& s = GetTableSelection();
		if (!s.IsSelected(cell) && itsDialog->OKToSwitchAccounts())
			{
			s.ClearSelection();
			s.SelectRow(cell.y);
			Broadcast(NameSelected(cell.y));
			BeginEditing(cell);
			}
		else if (s.IsSelected(cell) && !IsEditing())
			{
			BeginEditing(cell);
			}
		}
	else if (button > kJXRightButton)
		{
		ScrollForWheel(button, modifiers);
		}
}
void
CBCommandTable::HandleMouseDown
	(
	const JPoint&			pt,
	const JXMouseButton		button,
	const JSize				clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	JPoint cell;
	if (ScrollForWheel(button, modifiers) ||
		!GetCell(pt, &cell))
		{
		return;
		}

	itsStartPt = pt;
	if (cell.x == kOptionsColumn)
		{
		SelectSingleCell(cell);
		itsOptionsMenu->PopUp(this, pt, buttonStates, modifiers);
		}
	else if (button == kJXLeftButton)
		{
		SelectSingleCell(cell);
		if (clickCount == 2)
			{
			BeginEditing(cell);
			}
		}
}
示例#5
0
void ecValueWindow::OnMouseEvent(wxMouseEvent& event)
{
    if (event.LeftDown() && (event.GetX() > 2))
    {
        // Find if this corresponds to a tree item
        int flags = 0;
        wxTreeItemId item = m_treeCtrl->HitTest(wxPoint(4, event.GetY()), flags);
        if (item.IsOk())
        {
            m_treeCtrl->SelectItem(item);
            ecConfigItem* configItem = ((ecTreeItemData*) m_treeCtrl->GetItemData(item))->GetConfigItem();
            if (configItem->CanEdit())
                BeginEditing(configItem);            
        }
    }
    else if (event.RightDown())
    {
        // Find if this corresponds to a tree item
        int flags = 0;
        wxTreeItemId item = m_treeCtrl->HitTest(wxPoint(4, event.GetY()), flags);
        if (item != 0)
        {
            ecConfigItem* configItem = ((ecTreeItemData*) m_treeCtrl->GetItemData(item))->GetConfigItem();
            m_treeCtrl->SelectItem(item);
            ((ecConfigTreeCtrl*) m_treeCtrl)->GetPropertiesMenu()->SetClientData((void*) TRUE);
            PopupMenu(((ecConfigTreeCtrl*) m_treeCtrl)->GetPropertiesMenu(), event.GetX(), event.GetY());
        }
        else
        {
            wxGetApp().GetWhatsThisMenu()->SetClientData((void*) FALSE);
            PopupMenu(wxGetApp().GetWhatsThisMenu(), event.GetX(), event.GetY());
        }
    }
}
void
THXVarTable::NewConstant()
{
	const JIndex rowIndex = itsVarList->NewFunction() - THXVarList::kUserFnOffset;
	InsertRows(rowIndex, 1);
	BeginEditing(JPoint(1,rowIndex));
}
示例#7
0
bool
WndProperty::on_mouse_down(int x, int y)
{
  if (mDialogStyle) {
    BeginEditing();
  } else {
    if (!edit.has_focus()) {
      if (!edit.is_read_only())
        edit.set_focus();

      return true;
    }

    RasterPoint Pos;
    Pos.x = x;
    Pos.y = y;
    //POINTSTOPOINT(Pos, MAKEPOINTS(lParam));

    mDownDown = (PtInRect(&mHitRectDown, Pos) != 0);
    if (mDownDown) {
      DecValue();
      invalidate(mHitRectDown);
    }

    mUpDown = (PtInRect(&mHitRectUp, Pos) != 0);
    if (mUpDown) {
      IncValue();
      invalidate(mHitRectUp);
    }

    set_capture();
  }

  return true;
}
void
CMArray2DTable::HandleKeyPress
	(
	const int				key,
	const JXKeyModifiers&	modifiers
	)
{
	if (key == kJReturnKey)
		{
		JPoint cell;
		if (!IsEditing() && (GetTableSelection()).GetSingleSelectedCell(&cell))
			{
			BeginEditing(cell);
			}
		else
			{
			EndEditing();
			}
		}

	else if (!IsEditing() && HandleSelectionKeyPress(key, modifiers))
		{
		// work has been done
		}

	else
		{
		JXStringTable::HandleKeyPress(key, modifiers);
		}
}
void
CBCommandTable::DuplicateCommand()
{
	JPoint cell;
	if ((GetTableSelection()).GetFirstSelectedCell(&cell) && EndEditing())
		{
		itsCmdList->AppendElement((itsCmdList->GetElement(cell.y)).Copy());
		AppendRows(1);
		BeginEditing(JPoint(kCommandColumn, itsCmdList->GetElementCount()));
		}
}
JBoolean
GLFitParameterTable::BeginEditingStartValues()
{
	if (itsHasStartValues && itsStartValues->GetElement(1) == 0)
		{
		JPoint cell((JCoordinate)kStartColIndex, 1);
		BeginEditing(cell);
		return kJTrue;
		}
	return kJFalse;
}
void
CBMacroTable::ReadData
	(
	const JCharacter*	fileName,
	const JBoolean		replace
	)
{
	JStringTableData* data = GetStringData();
	if (replace)
		{
		data->RemoveAllRows();
		}

	JIndex firstNewRow = 0;

	ifstream input(fileName);
	JString macro, script;
	JIndex state = 1;
	while (!input.eof() && !input.fail())
		{
		if (state == 1)
			{
			macro = JReadLine(input);
			if (!macro.IsEmpty())
				{
				state = 2;
				}
			}
		else if (state == 2)
			{
			script = JReadLine(input);
			if (!script.IsEmpty())
				{
				data->AppendRows(1);
				const JSize rowCount = data->GetRowCount();
				data->SetString(rowCount,kMacroColumn,  macro);
				data->SetString(rowCount,kScriptColumn, script);
				if (firstNewRow == 0)
					{
					firstNewRow = rowCount;
					}
				state = 1;
				}
			}
		}

	if (firstNewRow != 0)
		{
		ScrollTo((GetBounds()).bottomLeft());
		BeginEditing(JPoint(kMacroColumn, firstNewRow));
		}
}
JX2DCurveNameList::JX2DCurveNameList
	(
	const JArray<J2DCurveInfo>&	curveInfo,
	const JIndex				startIndex,
	JXScrollbarSet*				scrollbarSet,
	JXContainer*				enclosure,
	const HSizingOption			hSizing,
	const VSizingOption			vSizing,
	const JCoordinate			x,
	const JCoordinate			y,
	const JCoordinate			w,
	const JCoordinate			h
	)
	:
	JXEditTable(1, kDefColWidth, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h),
	itsInput(NULL)
{
	itsMinColWidth = 1;

	const JFontManager* fontMgr = GetFontManager();
	const JSize rowHeight = 2*kVMarginWidth +
		fontMgr->GetDefaultFont().GetLineHeight();
	SetDefaultRowHeight(rowHeight);

	const JSize count = curveInfo.GetElementCount();

	itsNameList = jnew JPtrArray<JString>(JPtrArrayT::kForgetAll, count);
	assert(itsNameList != NULL);

	AppendRows(count);
	for (JIndex i=1; i<=count; i++)
		{
		const J2DCurveInfo info = curveInfo.GetElement(i);
		itsNameList->Append(info.name);

		const JCoordinate width = 2*kHMarginWidth +
			fontMgr->GetDefaultFont().GetStringWidth(*(info.name));
		if (width > itsMinColWidth)
			{
			itsMinColWidth = width;
			}
		}

	AppendCols(1);
	AdjustColWidth();

	JXColormap* colormap = GetColormap();
	SetRowBorderInfo(0, colormap->GetBlackColor());
	SetColBorderInfo(0, colormap->GetBlackColor());

	BeginEditing(JPoint(1, startIndex));
}
void
CBCommandTable::AddCommand()
{
	if (EndEditing())
		{
		CBCommandManager::CmdInfo info(new JString("./"), new JString, new JString,
									   new JString, new JString, new JString);
		assert( info.path != NULL && info.cmd != NULL && info.name != NULL &&
				info.menuText != NULL && info.menuShortcut != NULL );
		itsCmdList->AppendElement(info);
		AppendRows(1);
		BeginEditing(JPoint(kCommandColumn, itsCmdList->GetElementCount()));
		}
}
void
GLFitDescriptionList::HandleKeyPress
	(
	const int 				key,
	const JXKeyModifiers&	modifiers
	)
{
	JPoint cell;
	JTableSelection& s = GetTableSelection();
	if (!s.GetFirstSelectedCell(&cell))
		{
		return;
		}

	if (key == kJUpArrow)
		{
		cell.y--;
		if (CellValid(cell))
			{
			BeginEditing(cell);
			}
		}
	else if (key == kJDownArrow)
		{
		cell.y++;
		if (CellValid(cell))
			{
			BeginEditing(cell);
			}
		}

	else
		{
		JXEditTable::HandleKeyPress(key, modifiers);
		}
}
void
JXFSBindingTable::AddPattern()
{
	if (EndEditing())
		{
		const JFSBinding* b = itsBindingList->GetDefaultCommand();
		JFSBinding::CommandType type;
		JBoolean singleFile;
		const JString& cmd = b->GetCommand(&type, &singleFile);

		const JIndex rowIndex =
			itsBindingList->AddBinding("", cmd, type, singleFile);
		InsertRows(rowIndex, 1);
		BeginEditing(JPoint(kPatternColumn, rowIndex));
		Broadcast(DataChanged());
		}
}
void
GMFilterNameTable::HandleMouseUp
	(
	const JPoint&			pt,
	const JXMouseButton	button,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	JPoint cell;
	if (!GetCell(pt, &cell))
		{
		return;
		}
	if (cell == itsCurrentCell && itsIsWaitingForDrag)
		{
		BeginEditing(cell);
		}
}
void
JXFSBindingTable::DuplicatePattern()
{
	JPoint cell;
	if ((GetTableSelection()).GetFirstSelectedCell(&cell) && EndEditing())
		{
		const JFSBinding* b = itsBindingList->GetBinding(cell.y);

		JFSBinding::CommandType type;
		JBoolean singleFile;
		const JString& cmd = b->GetCommand(&type, &singleFile);

		const JIndex rowIndex =
			itsBindingList->AddBinding("", cmd, type, singleFile);
		InsertRows(rowIndex, 1);
		BeginEditing(JPoint(kPatternColumn, rowIndex));
		Broadcast(DataChanged());
		}
}
void
CBMacroSetTable::HandleMouseDown
	(
	const JPoint&			pt,
	const JXMouseButton		button,
	const JSize				clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	JPoint cell;
	if (button == kJXLeftButton && GetCell(pt, &cell))
		{
		BeginEditing(cell);
		}
	else
		{
		ScrollForWheel(button, modifiers);
		}
}
void
CMArray2DTable::HandleMouseDown
	(
	const JPoint&			pt,
	const JXMouseButton		button,
	const JSize				clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	JTableSelection& s = GetTableSelection();

	JPoint cell;
	if (ScrollForWheel(button, modifiers))
		{
		// work has been done
		}
	else if (!GetCell(pt, &cell))
		{
		s.ClearSelection();
		}
	else if (button == kJXLeftButton && modifiers.meta())
		{
		if (!s.IsSelected(cell))
			{
			SelectSingleCell(cell, kJFalse);
			}

		const JString expr = itsArrayDir->GetExpression(cell);
		itsCmdDir->DisplayExpression(expr);
		}
	else if (button == kJXLeftButton && clickCount == 2)
		{
		BeginEditing(cell);
		}
	else if (button == kJXLeftButton && clickCount == 1)
		{
		SelectSingleCell(cell, kJFalse);
		}
}
void
CBMacroSetTable::AddRow()
{
	if (ContentsValid())
		{
		itsLastNewID++;
		CBPrefsManager::MacroSetInfo info(itsLastNewID, new JString("New"),
										  new CBCharActionManager,
										  new CBMacroManager);
		assert( info.name   != NULL &&
				info.action != NULL &&
				info.macro  != NULL );
		itsMacroList->AppendElement(info);

		JStringTableData* data = GetStringData();
		data->AppendRows(1);

		const JPoint newCell(1, GetRowCount());
		data->SetString(newCell, *(info.name));
		BeginEditing(newCell);
		}
}
void
JXFSBindingTable::HandleMouseDown
	(
	const JPoint& pt,
	const JXMouseButton button,
	const JSize clickCount,
	const JXButtonStates& buttonStates,
	const JXKeyModifiers& modifiers
	)
{
	JTableSelection& s = GetTableSelection();
	s.ClearSelection();

	JPoint cell;
	if (button == kJXLeftButton && GetCell(pt, &cell))
		{
		s.SelectCell(cell);
		TableScrollToCell(cell);

		if (cell.x == kPatternColumn || cell.x == kCommandColumn)
			{
			BeginEditing(cell);
			}
		else if (cell.x == kTypeColumn)
			{
			itsTypeMenu->PopUp(this, pt, buttonStates, modifiers);
			}
		else if (cell.x == kSingleFileColumn)
			{
			itsBindingList->ToggleSingleFile(cell.y);
			TableRefreshRow(cell.y);
			Broadcast(DataChanged());
			}
		}
	else
		{
		ScrollForWheel(button, modifiers);
		}
}
void
JXFSBindingTable::HandleKeyPress
	(
	const int				key,
	const JXKeyModifiers&	modifiers
	)
{
	JPoint cell;
	if (GetEditedCell(&cell) && cell.x == kPatternColumn &&
		(key == kJTabKey ||
		 (modifiers.meta() && (key == kJRightArrow || key == '6'))))
		{
		if (EndEditing() &&
			(GetTableSelection()).GetSingleSelectedCell(&cell))
			{
			BeginEditing(JPoint(kCommandColumn, cell.y));
			}
		}

	else
		{
		JXEditTable::HandleKeyPress(key, modifiers);
		}
}
void
GLFitParameterTable::HandleMouseDown
	(
	const JPoint& 			pt,
	const JXMouseButton 	button,
	const JSize 			clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	JPoint cell;
	if (button == kJXLeftButton && clickCount == 1 &&
		GetCell(pt, &cell))
		{
		if (itsHasStartValues && cell.x == (JCoordinate)kStartColIndex)
			{
			BeginEditing(cell);
			}
		}
	else
		{
		ScrollForWheel(button, modifiers);
		}
}
void
TestFloatTable::HandleMouseDown
	(
	const JPoint&			pt,
	const JXMouseButton		button,
	const JSize				clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	JPoint cell;
	if (button > kJXRightButton)
		{
		ScrollForWheel(button, modifiers);
		return;
		}
	else if (!GetCell(pt, &cell))
		{
		return;
		}

	JFloatTableData* data = GetFloatData();

	if (button == kJXMiddleButton)
		{
		BeginEditing(cell);
		}

	// row manipulations

	else if (button == kJXLeftButton && itsMouseAction == kInsertRow)
		{
		data->InsertRows(cell.y, 1);
		}
	else if (button == kJXRightButton && itsMouseAction == kInsertRow)
		{
		data->InsertRows(cell.y+1, 1);
		}

	else if (button == kJXLeftButton && itsMouseAction == kDuplicateRow)
		{
		data->DuplicateRow(cell.y, cell.y);
		}
	else if (button == kJXRightButton && itsMouseAction == kDuplicateRow)
		{
		data->DuplicateRow(cell.y, cell.y+1);
		}

	else if (button == kJXLeftButton && itsMouseAction == kMoveRow &&
			 cell.y > 1)
		{
		data->MoveRow(cell.y, cell.y-1);
		}
	else if (button == kJXRightButton && itsMouseAction == kMoveRow &&
			 ((JIndex) cell.y) < GetRowCount())
		{
		data->MoveRow(cell.y, cell.y+1);
		}

	else if (itsMouseAction == kRemoveRow)
		{
		data->RemoveRow(cell.y);
		}

	// column manipulations

	else if (button == kJXLeftButton && itsMouseAction == kInsertCol)
		{
		data->InsertCols(cell.x, 1);
		}
	else if (button == kJXRightButton && itsMouseAction == kInsertCol)
		{
		data->InsertCols(cell.x+1, 1);
		}

	else if (button == kJXLeftButton && itsMouseAction == kDuplicateCol)
		{
		data->DuplicateCol(cell.x, cell.x);
		}
	else if (button == kJXRightButton && itsMouseAction == kDuplicateCol)
		{
		data->DuplicateCol(cell.x, cell.x+1);
		}

	else if (button == kJXLeftButton && itsMouseAction == kMoveCol &&
			 cell.x > 1)
		{
		data->MoveCol(cell.x, cell.x-1);
		}
	else if (button == kJXRightButton && itsMouseAction == kMoveCol &&
			 ((JIndex) cell.x) < GetColCount())
		{
		data->MoveCol(cell.x, cell.x+1);
		}

	else if (itsMouseAction == kRemoveCol)
		{
		data->RemoveCol(cell.x);
		}
}
示例#25
0
文件: Edit.cpp 项目: macsux/XCSoar
bool
WndProperty::on_mouse_down(int x, int y)
{
  BeginEditing();
  return true;
}
void
TestStringTable::HandleMouseDown
	(
	const JPoint&			pt,
	const JXMouseButton		button,
	const JSize				clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	itsIsDraggingFlag = kJFalse;
	if (button > kJXRightButton)
		{
		ScrollForWheel(button, modifiers);
		return;
		}

	JPoint cell;
	if (!GetCell(pt, &cell))
		{
		return;
		}

	JStringTableData* data = GetStringData();
	JTableSelection& s     = GetTableSelection();

	if (button == kJXMiddleButton)
		{
		BeginEditing(cell);
		}

	else if (itsMouseAction == kSelectCells)
		{
		if (button == kJXLeftButton && !modifiers.shift())
			{
			s.ClearSelection();
			s.SetBoat(cell);
			s.SetAnchor(cell);
			s.SelectCell(cell);
			itsIsDraggingFlag = kJTrue;
			}
		else
			{
			itsIsDraggingFlag = s.ExtendSelection(cell);
			}
		}

	else if (itsMouseAction == kSelectRows)
		{
		if (button == kJXLeftButton && !modifiers.shift())
			{
			s.ClearSelection();
			}
		s.SetBoat(JPoint(1, cell.y));
		s.SetAnchor(JPoint(GetColCount(), cell.y));
		s.SelectRow(cell.y);
		}

	else if (itsMouseAction == kSelectCols)
		{
		if (button == kJXLeftButton && !modifiers.shift())
			{
			s.ClearSelection();
			}
		s.SetBoat(JPoint(cell.x, 1));
		s.SetAnchor(JPoint(cell.x, GetRowCount()));
		s.SelectCol(cell.x);
		}

	// row manipulations

	else if (button == kJXLeftButton && itsMouseAction == kInsertRow)
		{
		data->InsertRows(cell.y, 1);
		}
	else if (button == kJXRightButton && itsMouseAction == kInsertRow)
		{
		data->InsertRows(cell.y+1, 1);
		}

	else if (button == kJXLeftButton && itsMouseAction == kDuplicateRow)
		{
		data->DuplicateRow(cell.y, cell.y);
		}
	else if (button == kJXRightButton && itsMouseAction == kDuplicateRow)
		{
		data->DuplicateRow(cell.y, cell.y+1);
		}

	else if (button == kJXLeftButton && itsMouseAction == kMoveRow &&
			 cell.y > 1)
		{
		data->MoveRow(cell.y, cell.y-1);
		}
	else if (button == kJXRightButton && itsMouseAction == kMoveRow &&
			 ((JIndex) cell.y) < GetRowCount())
		{
		data->MoveRow(cell.y, cell.y+1);
		}

	else if (itsMouseAction == kRemoveRow)
		{
		data->RemoveRow(cell.y);
		}

	// column manipulations

	else if (button == kJXLeftButton && itsMouseAction == kInsertCol)
		{
		data->InsertCols(cell.x, 1);
		}
	else if (button == kJXRightButton && itsMouseAction == kInsertCol)
		{
		data->InsertCols(cell.x+1, 1);
		}

	else if (button == kJXLeftButton && itsMouseAction == kDuplicateCol)
		{
		data->DuplicateCol(cell.x, cell.x);
		}
	else if (button == kJXRightButton && itsMouseAction == kDuplicateCol)
		{
		data->DuplicateCol(cell.x, cell.x+1);
		}

	else if (button == kJXLeftButton && itsMouseAction == kMoveCol &&
			 cell.x > 1)
		{
		data->MoveCol(cell.x, cell.x-1);
		}
	else if (button == kJXRightButton && itsMouseAction == kMoveCol &&
			 ((JIndex) cell.x) < GetColCount())
		{
		data->MoveCol(cell.x, cell.x+1);
		}

	else if (itsMouseAction == kRemoveCol)
		{
		data->RemoveCol(cell.x);
		}
}
示例#27
0
bool
WndProperty::OnMouseDown(PixelScalar x, PixelScalar y)
{
  return BeginEditing();
}