예제 #1
0
void CSimpleReport::RowDownMulti()
{
	CXTPReportSelectedRows* pRows = GetSelectedRows();
	if (!pRows)
		return;

	int total = GetRows()->GetCount() - 1;
	int cnt = pRows->GetCount();

	CXTPReportRow* pRow = pRows->GetAt(cnt-1);	// 선택 영역의 마지막 row
	if (!pRow)
		return;
	int n = pRow->GetIndex();
	if (n >= total)					// 더이상 내려갈 수 없음
		return;

	// 마지막 row 뒤에 paste하기 위해 m_bAdd를 true로 만듬.
	// 그럼 cut후 add가 됨

	if (n+1 >= total)
		m_bAdd = true;

	// focus는 cut된 시점에서 첫번째로 잡음.
	pRow = pRows->GetAt(0);
	n = pRow->GetIndex();

	Cut();			// 컷하면 선택된 갯수는 제거되므로 total-cnt가 
	RowSetFocused(n+1);
	Paste();
	SetFocus();
}
예제 #2
0
void DataGrid::onKeyDown(wxKeyEvent &event)
{
	bool modified = false;
	if (event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER) {
		if (event.ControlDown()) {
			if (!IsCellEditControlEnabled()) {
				insertRowToDataUp(GetGridCursorRow());
				modified = true;
			}
		} else {
			insertRowToData(GetGridCursorRow());
			modified = true;
		}
	} else if (event.GetKeyCode() == WXK_DELETE) {
		if (IsSelection()) {
			wxArrayInt rows = GetSelectedRows();
			if (rows.Count() > 0) {
				modified = deleteRowsFromData(rows);
			} else {
				unsigned int i;
				int row, col;
				wxGridCellCoordsArray cells = GetSelectedCells();
				for (i = 0; i < cells.Count(); i++) {
					clearCellData(cells[i].GetRow(), cells[i].GetCol());
				}
				wxGridCellCoordsArray topLeft = GetSelectionBlockTopLeft();
				wxGridCellCoordsArray bottomRight = GetSelectionBlockBottomRight();
				for (i = 0; i < topLeft.Count(); i++) {
					for (row = topLeft[i].GetRow(); row <= bottomRight[i].GetRow(); row++) {
						for (col = topLeft[i].GetCol(); col <= bottomRight[i].GetCol(); col++) {
							clearCellData(row, col);
						}
					}
				}
				wxArrayInt cols = GetSelectedCols();
				for (i = 0; i < cols.Count(); i++) {
					for (row = 1; row < GetNumberRows(); row++) {
						clearCellData(row, cols[i]);
					}
				}
			}
			ClearSelection();
		} else {
			clearCellData(GetGridCursorRow(), GetGridCursorCol());
		}
	}
	wxGrid::OnKeyDown(event);
	if (modified) updateData(true);
}
예제 #3
0
void CSimpleReport::RowUpMulti()
{
	// 한꺼번에 여러개를 올림

	CXTPReportSelectedRows* pRows = GetSelectedRows();
	if (!pRows)
		return;
	CXTPReportRow* pRow = pRows->GetAt(0);
	if (!pRow)
		return;
	int n = pRow->GetIndex();
	if (n == 0)	// 더이상 올라갈 수 없음
		return;

	Cut();
	RowSetFocused(n-1);
	Paste();
	SetFocus();
}
예제 #4
0
void ctlSQLGrid::OnLabelClick(wxGridEvent &event)
{
	int row = event.GetRow();
	int col = event.GetCol();

	// add support for (de)selecting multiple rows and cols with Control pressed
	if ( row >= 0 && (event.ControlDown() || event.CmdDown()) )
	{
		if (GetSelectedRows().Index(row) == wxNOT_FOUND)
			SelectRow(row, true);
		else
			DeselectRow(row);
	}
	else if ( col >= 0 && (event.ControlDown() || event.CmdDown()) )
	{
		if (GetSelectedCols().Index(col) == wxNOT_FOUND)
			SelectCol(col, true);
		else
			DeselectCol(col);
	}
	else
		event.Skip();
}
예제 #5
0
int ctlSQLGrid::Copy()
{
	wxString str;
	int copied = 0;
	size_t i;



	if (GetSelectedRows().GetCount())
	{
		AppendColumnHeader(str, 0, (GetNumberCols() - 1));

		wxArrayInt rows = GetSelectedRows();

		for (i = 0 ; i < rows.GetCount() ; i++)
		{
			str.Append(GetExportLine(rows.Item(i)));

			if (rows.GetCount() > 1)
				str.Append(END_OF_LINE);
		}

		copied = rows.GetCount();
	}
	else if (GetSelectedCols().GetCount())
	{
		wxArrayInt cols = GetSelectedCols();
		size_t numRows = GetNumberRows();

		AppendColumnHeader(str, cols);

		for (i = 0 ; i < numRows ; i++)
		{
			str.Append(GetExportLine(i, cols));

			if (numRows > 1)
				str.Append(END_OF_LINE);
		}

		copied = numRows;
	}
	else if (GetSelectionBlockTopLeft().GetCount() > 0 &&
	         GetSelectionBlockBottomRight().GetCount() > 0)
	{
		unsigned int x1, x2, y1, y2;

		x1 = GetSelectionBlockTopLeft()[0].GetCol();
		x2 = GetSelectionBlockBottomRight()[0].GetCol();
		y1 = GetSelectionBlockTopLeft()[0].GetRow();
		y2 = GetSelectionBlockBottomRight()[0].GetRow();

		AppendColumnHeader(str, x1, x2);

		for (i = y1; i <= y2; i++)
		{
			str.Append(GetExportLine(i, x1, x2));

			if (y2 > y1)
				str.Append(END_OF_LINE);
		}

		copied = y2 - y1 + 1;
	}
	else
	{
		int row, col;

		row = GetGridCursorRow();
		col = GetGridCursorCol();

		AppendColumnHeader(str, col, col);

		str.Append(GetExportLine(row, col, col));
		copied = 1;
	}

	if (copied && wxTheClipboard->Open())
	{
		wxTheClipboard->SetData(new wxTextDataObject(str));
		wxTheClipboard->Close();
	}
	else
	{
		copied = 0;
	}

	return copied;
}
예제 #6
0
/** GetSelectedRow
  *
  * Gets the first selected row
  */
int MemoryGrid::GetSelectedRow() const
{
    if (!IsSelection()) return -1;

    return GetSelectedRows()[0];
}
예제 #7
0
bool CSimpleReport::doCutPaste(CPoint pt, int op)
{
	CXTPReportSelectedRows* pRows = GetSelectedRows();
	if (pRows == NULL)
		return false;

	CXTPReportRow* pRow = pRows->GetAt(0);
	int nRow = 0;
	if (pRow)
		nRow = pRows->GetAt(0)->GetIndex();

	int n;
	CMenu menu;
	if (!menu.CreatePopupMenu())
		return false;

	if ((op & DO_ADD) != 0)	{
		menu.AppendMenu(MF_STRING, 10, "Add New");
		menu.AppendMenu(MF_STRING, 13, "Insert");
	}
	if (CanCopy() && (op & DO_COPY) != 0)
		menu.AppendMenu(MF_STRING, 11, "Copy");
	if (CanCut() && (op & DO_CUT) != 0)
		menu.AppendMenu(MF_STRING, 12, "Delete");

	n = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD, pt.x, pt.y, this);
	menu.DestroyMenu();

	switch (n) {
		case 10:	// add
		case 13:	// insert
			{
				CXTPReportRecord* pRec = newRec();
				if (callback_add) {
					if (!callback_add(this, pRec)) {
						delete pRec;
						return false;
					}
				}
				RowInsert(pRec, (n == 10));
			}
			break;

		case 11:	// copy
			{
				pRow = GetFocusedRow();
				if (!pRow)
					return false;

				CXTPReportRecord* pSource = pRow->GetRecord();
				CXTPReportRecord* pTarget  = newRec();
		
				if (callback_copy) {
					if (!callback_copy(this, pSource, pTarget)) {
						delete pTarget;
						return false;
					}
				}
				RowInsert(pTarget);
			}
			break;
		case 12:	// delete
			{
				n = pRows->GetCount();
				for (int i = 0; i < n; i++) {
					if (callback_del) {
						CXTPReportRecord* pRec = pRows->GetAt(i)->GetRecord();
						if (!callback_del(this, pRec)) {
							return false;
						}
					}
				}

				for (int i = n - 1; i >= 0; i--) {
					pRow = pRows->GetAt(i);
					GetRecords()->RemoveAt(pRow->GetRecord()->GetIndex());
				}
				Populate();
				RowSetFocused(nRow);
			}
			break;
		default:
			return false;
	}
	return true;
}