2
* This file is part of wxSmith plugin for Code::Blocks Studio
3
* Copyright (C) 2006-2007 Bartlomiej Swiecki
5
* wxSmith is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 3 of the License, or
8
* (at your option) any later version.
10
* wxSmith is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with wxSmith. If not, see <http://www.gnu.org/licenses/>.
19
* $Id: wxsitemundobuffer.cpp 4850 2008-01-29 21:45:49Z byo $
20
* $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/plugins/contrib/wxSmith/wxwidgets/wxsitemundobuffer.cpp $
23
#include "wxsitemundobuffer.h"
27
wxString Empty = wxEmptyString;
30
wxsItemUndoBuffer::wxsItemUndoBuffer(int MaxEnteries):
33
m_MaxEnteries(MaxEnteries)
37
wxsItemUndoBuffer::~wxsItemUndoBuffer()
41
void wxsItemUndoBuffer::StoreChange(const wxString& XmlData)
43
// Removing all undo points after current one
44
if ( m_CurrentPos < GetCount()-1 )
46
m_Enteries.RemoveAt(m_CurrentPos+1,GetCount()-m_CurrentPos-1);
49
// Removing all outdated undos
50
if ( m_MaxEnteries > 0 )
52
int ToRemove = GetCount()-m_MaxEnteries;
55
m_Enteries.RemoveAt(0,ToRemove);
56
m_CurrentPos -= ToRemove;
57
m_SavedPos -= ToRemove;
61
m_Enteries.Add(XmlData);
62
m_CurrentPos = GetCount()-1;
65
const wxString& wxsItemUndoBuffer::Undo()
67
if ( m_CurrentPos == 0 ) return Empty;
68
return m_Enteries[--m_CurrentPos];
71
const wxString& wxsItemUndoBuffer::Redo()
73
if ( m_CurrentPos >= GetCount() - 1 ) return Empty;
74
return m_Enteries[++m_CurrentPos];