NCBI C++ ToolKit
undo_manager.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_CORE___UNDO_MANAGER__HPP
2 #define GUI_CORE___UNDO_MANAGER__HPP
3 
4 /* $Id: undo_manager.hpp 34312 2015-12-11 18:44:57Z katargir $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Roman Katargin
30  *
31  * File Description:
32  *
33  */
34 
35 #include <gui/gui_export.h>
36 #include <corelib/ncbimtx.hpp>
38 
40 
41 /////////////////////////////////////////////////////////////////////////////
42 
43 class CGBDocument;
44 
45 /////////////////////////////////////////////////////////////////////////////
46 
48 {
49 public:
50  CUndoManager(size_t maxBufferSize = 0, CGBDocument* document = 0)
51  : m_Document(document), m_MaxBufferSize(maxBufferSize), m_LockCounter(0), m_ExclusiveEdit() {}
52  virtual ~CUndoManager() {}
53 
54  virtual void Undo(wxWindow* window = 0);
55  virtual void Redo(wxWindow* window = 0);
56  virtual bool CanUndo();
57  virtual bool CanRedo();
58  virtual string GetUndoLabel();
59  virtual string GetRedoLabel();
60 
61  virtual bool RequestExclusiveEdit(wxWindow* window, const string& descr);
62  virtual bool ReleaseExclusiveEdit(wxWindow* window);
63 
64  // ICommandProccessor
65  virtual void Execute(IEditCommand* command, wxWindow* window = 0);
66  virtual bool ExecuteLock();
67  virtual void ExecuteUnlock();
68 
69  void Reset();
70 
71 protected:
73  {
74  public:
75  CWriteLockGuard(CUndoManager& undoManager) : m_UndoManager(undoManager) {}
76  ~CWriteLockGuard();
77  private:
79  };
80 
81  typedef list< CIRef<IEditCommand> > TCommands;
82 
83  void ShowErrorMsg (IEditCommand* pCommand, const string& errMsg);
84  void x_SendChangingEvent();
85  void x_SendChangedEvent();
86 
87  bool x_WriteLock();
88  bool x_LockDocument();
89 
90  void x_ShowExclusiveEditDlg();
91 
96 
99 
100  wxWindow* m_ExclusiveEdit;
102 };
103 
105 
106 #endif // GUI_CORE___UNDO_MANAGER__HPP
CFastMutex –.
Definition: ncbimtx.hpp:667
CGBDocument.
Definition: document.hpp:113
CObjectEx –.
Definition: ncbiobj.hpp:2531
CWriteLockGuard(CUndoManager &undoManager)
CUndoManager(size_t maxBufferSize=0, CGBDocument *document=0)
CGBDocument * m_Document
CFastMutex m_RWMutex
wxWindow * m_ExclusiveEdit
TCommands m_RedoBuffer
size_t m_MaxBufferSize
string m_ExclusiveDescr
list< CIRef< IEditCommand > > TCommands
TCommands m_UndoBuffer
virtual ~CUndoManager()
virtual void ExecuteUnlock()=0
virtual bool ExecuteLock()=0
Interface (functor) for object editing.
virtual bool RequestExclusiveEdit(wxWindow *window, const string &descr)=0
virtual bool CanUndo()=0
virtual bool ReleaseExclusiveEdit(wxWindow *window)=0
virtual void Undo(wxWindow *window=0)=0
virtual bool CanRedo()=0
virtual string GetRedoLabel()=0
virtual string GetUndoLabel()=0
virtual void Redo(wxWindow *window=0)=0
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUICORE_EXPORT
Definition: gui_export.h:508
Defines to provide correct exporting from DLLs in Windows.
string Execute(const string &cmmd, const vector< string > &args, const string &data=kEmptyStr)
Multi-threading – mutexes; rw-locks; semaphore.
const char * command
Modified on Fri Sep 20 14:57:07 2024 by modify_doxy.py rev. 669887