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

Go to the SVN repository for this file.

1 #ifndef GUI_CORE___VIEW__HPP
2 #define GUI_CORE___VIEW__HPP
3 
4 /* $Id: project_view_impl.hpp 40879 2018-04-25 20:05:11Z 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: Mike DiCuccio, Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
35 // TODO Migrate
36 // TODO Refactoring for the new framework is required
37 
39 
40 #include <gui/core/commands.hpp>
43 
46 
47 
49 
50 class CPopupMenuEvent;
52 
53 /////////////////////////////////////////////////////////////////////////////
54 /// CProjectView
55 
57  public CProjectViewBase,
58  public IVisibleRangeClient
59 {
60 public:
61  CProjectView();
62  virtual ~CProjectView(void);
63 
64  /// @name IView implementation
65  /// @{
66  /// overriding CProjectViewBase implementation
67  virtual void SetWorkbench(IWorkbench* workbench);
68  /// @}
69 
70  void SetVisibleRangeService(IVisibleRangeService* service) { m_VisibleRangeService = service; }
71 
72  /// @name IProjectView implementation
73  /// @{
74  /// implementation through pre & post Attach functions
75  virtual bool InitView( TConstScopedObjects& objects, const objects::CUser_object* params );
76  /// @}
77 
78  /// @name ISelectionClient Implementation
79  /// @{
80  virtual void GetSelection(TConstScopedObjects& buf) const;
81  virtual void SetSelectionService(ISelectionService* service);
82  virtual void GetSelection(CSelectionEvent& evt) const;
83  virtual void SetSelection(CSelectionEvent& evt);
84  virtual void GetMainObject(TConstScopedObjects& buf) const;
85  virtual void BroadcastSelection();
86  /// @}
87 
88  /// @name IVisibleRangeClient interface implementation
89  /// @{
90  virtual void OnVisibleRangeChanged (const CVisibleRange&,
91  IVisibleRangeClient* /*source*/) {}
92  /// @}
93 
94  /// populate a visible range event for broadcasting
95  virtual void GetVisibleRanges(CVisibleRange& vrange) const;
96 
97  /// Retrieve all information relevant to showing view reflection - that is,
98  /// displaying the location of sibling views. This function will retrieve
99  /// information about the current view's currently displayed locations, as well
100  /// as a uniquely identifying color and label for this view.
101  void GetReflectionInfo(const objects::CSeq_id& id, list<TSeqRange>& visible_ranges,
102  CRgbaColor& color, string& label) const;
103 
104  /// @name View Callbacks and Event Handlers
105  /// @{
107  void SetVisibleRangeChangeAllowed( bool flag ){ m_VisibleRangeChangeAllowed = flag; }
108 
109  void OnVRCAllowedChanged();
110  void OnBroadcastVisibleRange( wxCommandEvent& event );
111 
112  // Undo/Redo stuff
113  virtual void OnUndo();
114  virtual void OnRedo();
115  virtual bool CanUndo();
116  virtual bool CanRedo();
117 
118  virtual void OnWidgetRangeChanged();
119  virtual void OnWidgetSelChanged();
120 
121  void OnDecoratePopupMenu(CEvent *event);
122  void OnShowPopupMenu(CEvent *event);
123  /// @}
124 
125  /// fire a non-recursive visible range changed event
126  void BroadcastVisibleRange(CVisibleRange::EBasicPolicy bp);
127 
128 protected:
130 
131  virtual objects::CScope* x_PreAttachToProject( TConstScopedObjects& objects );
132  virtual void x_PostAttachToProject();
133 
134  /// override in derived classes in order to handle selection broadcast
135  virtual void x_OnSetSelection(CSelectionEvent& evt);
136 
137  // override these functions in derived classes
138  virtual void x_OnDecoratePopupMenu(CPopupMenuEvent& event);
139  virtual void x_OnShowPopupMenu();
140 
141  /// creates vew event handler for using in window event propagation hierarchy
142  virtual wxEvtHandler* x_CreateEventHandler();
143 
144  /// creates the template of the context menu
145  virtual wxMenu* x_CreateContextMenuBackbone();
146 
147  /// gets undo manager
148  virtual CUndoManager* x_GetUndoManager();
149 
150 protected:
151  /// private, non-virtual event handlers. These functions are the
152  /// primary direct handlers for the event handling mechanism and will
153  /// forward event requests to public virtual functions on receipt
154  void x_OnWidgetRangeChanged (CEvent* event);
155  void x_OnWidgetSelChanged (CEvent* event);
156  void x_OnWidgetItemActivated (CEvent* event);
157 
159 
160 private:
161  /// Prohibit copying!
164 };
165 
166 
167 /////////////////////////////////////////////////////////////////////////////
168 /// CProjectViewEvtHandler - wxEvtHandler that is attached to view window.
169 /// CProjectView cannot inherit from wxEvtHandler, because it already inherit
170 /// from CObject (the two bases are incompatible). So, in order to handle
171 /// wxWidgets commands we create a separate handler that will forward calls
172 /// to the view.
173 /// Derived classes may install their own handlers.
174 
175 class CProjectViewEvtHandler : public wxEvtHandler
176 {
177 public:
179 
180  // Redefined hooks for post-stack processing
181  virtual bool ProcessEvent( wxEvent& event );
182  virtual bool TryAfter( wxEvent& event );
183 
184 
185  void OnBroadcastSelection( wxCommandEvent& )
186  {
188  }
189 
190  void OnEnableCmdUpdate( wxUpdateUIEvent& event )
191  {
192  event.Enable( true );
193  }
194 
195  void OnBroadcastVisibleRange( wxCommandEvent& event )
196  {
198  }
199 
200  void OnVRCAllowedChanged( wxCommandEvent& )
201  {
203  }
204 
205  void OnUpdateVRCAllowedChanged( wxUpdateUIEvent& event )
206  {
207  bool en = m_View->IsVisibleRangeChangeAllowed();
208  event.Check( en );
209  }
210 
211  void OnEditRedo( wxCommandEvent& )
212  {
213  m_View->OnRedo();
214  }
215 
216 
217  void OnEditUndo( wxCommandEvent& )
218  {
219  m_View->OnUndo();
220  }
221 
222 
223  void OnUpdateEditUndo(wxUpdateUIEvent& event)
224  {
225  event.Enable(m_View->CanUndo());
226  }
227 
228 
229  void OnUpdateEditRedo(wxUpdateUIEvent& event)
230  {
231  event.Enable(m_View->CanRedo());
232  }
233 
234 protected:
235 
237 
239 };
240 
241 
243 
244 #endif /// GUI_CORE___VIEW__HPP
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
CPopupMenuEvent - an event that is sent when a popup menu needs to be shown.
Definition: popup_event.hpp:54
CProjectViewBase - default implementation of IProjectView, the base class for CProjectView and CProje...
bool m_VisibleRangeChangeAllowed
this view's private color
virtual void SetWorkbench(IWorkbench *workbench)
IView implementation.
CProjectViewEvtHandler - wxEvtHandler that is attached to view window.
void OnEditUndo(wxCommandEvent &)
CProjectViewEvtHandler(CProjectView *view)
void OnUpdateEditUndo(wxUpdateUIEvent &event)
virtual bool TryAfter(wxEvent &event)
virtual bool ProcessEvent(wxEvent &event)
void OnEnableCmdUpdate(wxUpdateUIEvent &event)
void OnEditRedo(wxCommandEvent &)
void OnBroadcastSelection(wxCommandEvent &)
void OnVRCAllowedChanged(wxCommandEvent &)
void OnUpdateEditRedo(wxUpdateUIEvent &event)
void OnBroadcastVisibleRange(wxCommandEvent &event)
void OnUpdateVRCAllowedChanged(wxUpdateUIEvent &event)
CProjectView.
virtual bool CanUndo()
CProjectView(const CProjectView &)
Prohibit copying!
void SetVisibleRangeChangeAllowed(bool flag)
virtual void OnVisibleRangeChanged(const CVisibleRange &, IVisibleRangeClient *)
void SetVisibleRangeService(IVisibleRangeService *service)
bool IsVisibleRangeChangeAllowed()
IVisibleRangeService * m_VisibleRangeService
virtual void OnUndo()
virtual void OnRedo()
virtual bool CanRedo()
virtual void BroadcastSelection()
void OnBroadcastVisibleRange(wxCommandEvent &event)
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CSelectionEvent CSelectionEvent is used for broadcasting selection between views.
Definition: obj_event.hpp:68
virtual bool InitView(TConstScopedObjects &objects, const objects::CUser_object *params)=0
initialize view with data, inside this function the view must call CProjectService::AttachView to con...
virtual void GetMainObject(TConstScopedObjects &objects) const =0
Adds the main data objects represented by the client to "objects".
virtual void SetSelection(CSelectionEvent &evt)=0
set broadcasted selection
virtual void GetSelection(TConstScopedObjects &objects) const =0
shall return data objects representing selected things, return one data object for every selected thi...
virtual void BroadcastSelection()
virtual void SetSelectionService(ISelectionService *service)=0
ISelectionService - an interface.
IVisibleRangeClient - represents an object that wants notifications about visible range changes.
IVisibleRangeService - an interface.
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
CObject & operator=(const CObject &src) THROWS_NONE
Assignment operator.
Definition: ncbiobj.hpp:482
#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
static const char label[]
n background color
char * buf
Modified on Wed Apr 17 13:10:45 2024 by modify_doxy.py rev. 669887