예제 #1
0
파일: Table.cpp 프로젝트: ultimatepp/mirror
void RichEdit::DestroyTable()
{
	AddUndo(new UndoDestroyTable(text, cursorp.table));
	int c = text.GetCellPos(cursorp.table, 0, 0).pos;
	text.DestroyTable(cursorp.table);
	Move(c);
}
예제 #2
0
파일: Table.cpp 프로젝트: ultimatepp/mirror
bool RichEdit::RemoveSpecial(int ll, int hh, bool back)
{
	NextUndo();
	int l = min(ll, hh);
	int h = max(ll, hh);
	RichPos p1 = text.GetRichPos(l);
	RichPos p2 = text.GetRichPos(h);
	if(InSameTxt(p1, p2))
		return false;
	if(p1.paralen == 0 && p2.posintab == 0 && text.CanRemoveParaSpecial(p2.table, true)) {
		AddUndo(new UndoRemoveParaSpecial(text, p2.table, true));
		text.RemoveParaSpecial(p2.table, true);
		Move(cursor - back);
	}
	else
	if(p2.paralen == 0 && p1.posintab == p1.tablen && text.CanRemoveParaSpecial(p1.table, false)) {
		AddUndo(new UndoRemoveParaSpecial(text, p1.table, false));
		text.RemoveParaSpecial(p1.table, false);
		Move(cursor - back);
	}
	return true;
}
예제 #3
0
파일: Table.cpp 프로젝트: ultimatepp/mirror
bool RichEdit::InsertLineSpecial()
{
	NextUndo();
	if(cursorp.table) {
		RichPara::Format fmt;
		fmt = formatinfo;
		fmt.newpage = false;
		fmt.label.Clear();
		if(cursorp.posintab == 0 && text.ShouldInsertParaSpecial(cursorp.table, true)) {
			AddUndo(new UndoInsertParaSpecial(cursorp.table, true));
			text.InsertParaSpecial(cursorp.table, true, fmt);
			Move(cursor + 1);
			return true;
		}
		if(cursorp.posintab == cursorp.tablen && text.ShouldInsertParaSpecial(cursorp.table, false)) {
			AddUndo(new UndoInsertParaSpecial(cursorp.table, false));
			text.InsertParaSpecial(cursorp.table, false, fmt);
			Move(cursor + 1);
			return true;
		}
	}
	return false;
}
void CommandManager::Redo(){
	std::string feedback;
	if (CanRedo()){
		UndoRedoCount++;
		Command* pCommand = getLastRedoCommand();
		redoList.pop_back();
		if (pCommand->execute(_taskList,feedback)){
			AddUndo(pCommand);
		} else {
			delete pCommand;
			pCommand = NULL;
		}
	}
}
예제 #5
0
int SetTowersSpotValue(TowersLib api, int nX, int nY, int nValue)
{
   DEBUG_FUNC_NAME;

   struct Towers* pT = (struct Towers*)api;

   ClearRedos(api);

   int nOldValue = GetAt(pT->m_pBoard, nX, nY)->m_nValue;
   AddUndo(api, nX, nY, nOldValue);
   GetAt(pT->m_pBoard, nX, nY)->m_nValue = nValue;

   return TOWERSLIB_OK;
}
예제 #6
0
파일: Table.cpp 프로젝트: ultimatepp/mirror
void RichEdit::InsertTable()
{
	if(IsSelection())
		return;
	WithCreateTableLayout<TopWindow> dlg;
	CtrlLayoutOKCancel(dlg, t_("Insert table"));
	dlg.header = false;
	dlg.columns <<= 2;
	dlg.columns.MinMax(1, 20);
	dlg.ActiveFocus(dlg.columns);
	if(dlg.Run() != IDOK)
		return;
	RichTable::Format fmt;
	int nx = minmax((int)~dlg.columns, 1, 20);
	for(int q = nx; q--;)
		fmt.column.Add(1);
	if(dlg.header)
		fmt.header = 1;
	RichTable table;
	table.SetFormat(fmt);
	for(int i = 0; i < (dlg.header ? 2 : 1); i++)
		for(int j = 0; j < nx; j++) {
			RichText h;
			h.SetStyles(text.GetStyles());
			RichPara p;
			p.format = formatinfo;
			p.format.newpage = false;
			p.format.label.Clear();
			h.Cat(p);
			table.SetPick(i, j, pick(h));
		}
	NextUndo();
	if(cursorp.posinpara)
		InsertLine();
	if(text.GetRichPos(cursor).paralen) {
		InsertLine();
		cursor = anchor = cursor - 1;
		begtabsel = false;
	}
	SaveFormat(cursor, 0);
	AddUndo(new UndoCreateTable(text.SetTable(cursor, table)));
	Finish();
}
예제 #7
0
int TowersRedo(TowersLib api)
{
   DEBUG_FUNC_NAME;

   struct Towers* pT = (struct Towers*)api;
   struct TowersBoard* pBoard = pT->m_pBoard;

   struct TowersAction* pRoot = pT->m_pRedoActions;
   if( pRoot == NULL )
      return TOWERSLIB_CANNOT_REDO;

   pT->m_pRedoActions = pRoot->m_pNext;
   AddUndo(api, pRoot->m_nX, pRoot->m_nY, GetTowersSpotValue(api, pRoot->m_nX, pRoot->m_nY));
   GetAt(pBoard, pRoot->m_nX, pRoot->m_nY)->m_nValue = pRoot->m_nValue;

   free(pRoot);
   pRoot = NULL;

   return TOWERSLIB_OK;
}
void CommandManager::DoCommand(Command* pCommand, std::string& feedback){
	if(pCommand->getType() == UNDO){
		Undo(feedback);
	} else if(pCommand->getType() == REDO){
		Redo();
	} else {
		// Clear redo list
		if(pCommand->getType() != DISPLAY){
			ClearRedoList();
		}
		// Execute the command and add it to undo list if succeeded
		if (pCommand->execute(_taskList,feedback)){
			if(undoable(pCommand)){
				AddUndo(pCommand);
			} else {
				delete pCommand;
				pCommand = NULL;
			}
		}
	}
}
예제 #9
0
파일: undo.cpp 프로젝트: Anonic/Meridian59
/*

	Add an UNDO entry only if the level data were modified after
	the prvious call to StartUndoRecording()

*/
void StopUndoRecording()
{
	assert_bound (NbUndo, 0, MaxUndo);
	assert_bound (NextUndo, -1, NbUndo - 1);

	assert(RecordingUndo);
	if ( !RecordingUndo )
	{
		Notify ("Progam bug in UNDO recording (stop)");
		return;
	}

	// Add UNDO struct or forget it if no changes since last
	// call to StartUndoRecord
	if ( CompareUndo (&UndoRecord) != 0 )
		AddUndo (&UndoRecord);
	else
		FreeUndo (&UndoRecord);

	RecordingUndo = FALSE;
}
예제 #10
0
void aui_Region::MouseLGrabEditMode( aui_MouseEvent *mouseData )
{
	if ( this == g_ui->TheEditRegion() ) {
		RECT grabRect = g_ui->TheEditRect();

		AddUndo();

		m_editGrabPoint = mouseData->position;

		if ( m_parent != g_ui )
			( ( aui_Control * )this)->ToScreen( &m_editGrabPoint );

		m_editGrabPointAttributes = k_REGION_GRAB_NONE;

		s_editModeStatus = AUI_EDIT_MODE_MODIFY;

		if ( ( ( m_editGrabPoint.x - grabRect.left ) < k_REGION_GRAB_SIZE ) &&
			( ( m_editGrabPoint.x - grabRect.left ) > 0 ) )
			m_editGrabPointAttributes |= k_REGION_GRAB_LEFT;
		else if ( ( ( grabRect.right - m_editGrabPoint.x ) < k_REGION_GRAB_SIZE ) &&
			( ( grabRect.right - m_editGrabPoint.x ) > 0 ) )
			m_editGrabPointAttributes |= k_REGION_GRAB_RIGHT;

		if ( ( ( m_editGrabPoint.y - grabRect.top ) < k_REGION_GRAB_SIZE ) &&
			( ( m_editGrabPoint.y - grabRect.top ) > 0 ) )
			m_editGrabPointAttributes |= k_REGION_GRAB_TOP;
		else if ( ( ( grabRect.bottom - m_editGrabPoint.y ) < k_REGION_GRAB_SIZE ) &&
			( ( grabRect.bottom - m_editGrabPoint.y ) > 0 ) )
			m_editGrabPointAttributes |= k_REGION_GRAB_BOTTOM;

		if ( ( m_editGrabPointAttributes == k_REGION_GRAB_NONE ) &&
			( ( m_editGrabPoint.x - grabRect.left ) > 0 ) &&
			( ( grabRect.right - m_editGrabPoint.x ) > 0 ) &&
			( ( m_editGrabPoint.y - grabRect.top ) > 0 ) &&
			( ( grabRect.bottom - m_editGrabPoint.y ) > 0 ) )
			m_editGrabPointAttributes |= k_REGION_GRAB_INSIDE;
	}
}
예제 #11
0
파일: Table.cpp 프로젝트: ultimatepp/mirror
void RichEdit::SaveTable(int table)
{
	AddUndo(new UndoTable(text, table));
}