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

Go to the SVN repository for this file.

1 #ifndef GUI_UTILS___COMMAND_PROCESSOR__HPP
2 #define GUI_UTILS___COMMAND_PROCESSOR__HPP
3 
4 /* $Id: command_processor.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 <corelib/ncbistd.hpp>
36 
37 class wxWindow;
38 
40 
41 
42 /// Interface (functor) for object editing
43 ///
44 /// All functions except Execute are engaged from UI elements (main menu)
45 /// Implementation of an IEditObject works as a class factory for IEditCommand
46 ///
47 /// @sa IEditObject, ICommandProccessor
49 {
50 public:
51  virtual ~IEditCommand() {}
52 
53  /// Do the editing action
54  virtual void Execute() = 0;
55  /// Undo (opposite to Execute())
56  virtual void Unexecute() = 0;
57  virtual string GetLabel() = 0;
58 
59  virtual bool CanMerge(IEditCommand*) { return false; }
60  virtual void Merge(IEditCommand*) {}
61 };
62 
63 /// Undo/Redo interface for editing operations
64 ///
65 /// We associate with every GBench project/document Undo manager object.
66 /// Implementation of this service holds the list of commands (see IEditCommand).
67 /// All actual data changing work is supposed to be delegated to IEditCommand::Execute()
68 ///
69 /// @sa IEditObject, IEditCommand
70 
72 {
73 public:
74  virtual ~ICommandProccessor() {}
75 
76  // his member should be called on the main thread only
77  virtual void Execute(IEditCommand* command, wxWindow* window = 0) = 0;
78 
79  //
80  // these functions can be called on the main thread or worker threads
81  // Successful call to ExecuteLock() will prevent Execute()
82  // to finish or succeed until ExecuteUnlock() is called
83  // Successful call to ExecuteLock() must be followed by ExecuteUnlock() in the same code
84  //
85 
86  virtual bool ExecuteLock() = 0;
87  virtual void ExecuteUnlock() = 0;
88 };
89 
91 {
92 public:
93  virtual void Undo(wxWindow* window = 0) = 0;
94  virtual void Redo(wxWindow* window = 0) = 0;
95  virtual bool CanUndo() = 0;
96  virtual bool CanRedo() = 0;
97  virtual string GetUndoLabel() = 0;
98  virtual string GetRedoLabel() = 0;
99 
100  virtual bool RequestExclusiveEdit(wxWindow* window, const string& descr) = 0;
101  virtual bool ReleaseExclusiveEdit(wxWindow* window) = 0;
102 };
103 
105 
106 #endif // GUI_UTILS___COMMAND_PROCESSOR__HPP
Undo/Redo interface for editing operations.
virtual void ExecuteUnlock()=0
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
virtual bool ExecuteLock()=0
Interface (functor) for object editing.
virtual void Unexecute()=0
Undo (opposite to Execute())
virtual string GetLabel()=0
virtual void Merge(IEditCommand *)
virtual void Execute()=0
Do the editing action.
virtual bool CanMerge(IEditCommand *)
virtual ~IEditCommand()
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
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
const char * command
Modified on Fri Sep 20 14:57:09 2024 by modify_doxy.py rev. 669887