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

Go to the SVN repository for this file.

1 #ifndef GUI_CORE___PROJECT_VIEW_BASE_IMPL__HPP
2 #define GUI_CORE___PROJECT_VIEW_BASE_IMPL__HPP
3 
4 /* $Id: project_view_base_impl.hpp 47479 2023-05-02 13:24:02Z ucko $
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: Andrey Yazhuk, Mike DiCuccio
30  *
31  * File Description:
32  *
33  */
34 
36 
37 #include <gui/core/document.hpp>
38 
40 
41 #include <gui/objutils/objects.hpp>
42 
44 
45 
46 #include <wx/event.h>
47 
48 
50 
51 class CUICommandRegistry;
52 
53 
55  class CPluginMessage;
57 
58 
59 ///////////////////////////////////////////////////////////////////////////////
60 /// CProjectViewBase - default implementation of IProjectView, the base class
61 /// for CProjectView and CProjectViewComposite
62 
64  : public CObjectEx
65  , public CEventHandler
66  , public IProjectView
67  , public IToolBarContext
68 {
70 
71 public:
72 
74  virtual ~CProjectViewBase();
75 
76  /// @name IProjectView implementation
77  /// @{
78  virtual void DestroyView();
79 
80  virtual void InitialLayout();
81  virtual void Destroy();
82 
83  TId GetId() const;
84 
85  virtual TProjectId GetProjectId() const;
86 
87  virtual string GetLabel( ELabelType type ) const;
88 
89  virtual IServiceLocator* GetServiceLocator() const;
90  virtual CRef<objects::CScope> GetScope() const;
91 
92  /// @name IWMClient implementation
93  /// @{
94  virtual wxWindow* GetWindow() = 0;
95  virtual wxEvtHandler* GetCommandHandler();
96  virtual string GetClientLabel(IWMClient::ELabel ltype = IWMClient::eDefault) const;
97  virtual string GetIconAlias() const;
98  virtual const CRgbaColor* GetColor() const;
99  virtual void SetColor( const CRgbaColor& color );
100  virtual const wxMenu* GetMenu();
101  virtual CFingerprint GetFingerprint() const;
102  virtual void SetFingerprint(const string& fp);
103  /// @}
104 
105  /// @name IView implementation
106  /// @{
107  virtual const CViewTypeDescriptor& GetTypeDescriptor() const = 0;
108  virtual void SetWorkbench( IWorkbench* workbench );
109  virtual void CreateViewWindow( wxWindow* parent ) = 0;
110  virtual void DestroyViewWindow() = 0;
111  virtual void SetAsyncDestroy(bool reset_hist_async) { m_ResetHistAsync = reset_hist_async; }
112  /// @}
113 
114  virtual void RefreshViewWindow();
115 
116  /// @name ISelectionClient implementation (partial)
117  /// @{
118  virtual string GetSelClientLabel();
119  /// @}
120 
121  /// @name IToolBarContext implementation
122  /// @{
123  virtual void GetCompatibleToolBars( vector<string>& names );
124  /// @}
125 
126  /// overloadable hook for derived classes to customize the content aspect of
127  /// a view's title. This function is called from GetLabel() to present the
128  /// content portion of the label; derived classes can specialize this function
129  /// to provide a view-specific content label.
130  virtual string GetContentLabel() const;
131 
132  /// @name Event Handling
133  /// @{
134  virtual void OnSelectionChanged( const TConstScopedObjects& sels );
135  virtual void OnProjectChanged();
136  virtual void OnProjectChanged( CProjectViewEvent& evt );
137  virtual void OnViewAttached( IView& view );
138  virtual void OnViewReleased( IView& view );
139 
140 virtual void OnPrint();
141  /// @}
142 
143  static void SetLabelGenerator(IProjectViewLabel* labelGenerator);
144 
145  protected:
146  virtual objects::CScope* x_GetScope() const;
147 
148  virtual const CObject* x_GetOrigObject() const;
149 
150  virtual bool x_HasProject() const;
151 
152  virtual void x_UpdateContentLabel();
153 
154  virtual void x_AttachToProject(CGBDocument& doc);
155  virtual void x_DetachFromProject();
156 
157  /// use this function to report incompatible data in InitView()
158  virtual void x_ReportInvalidInputData( TConstScopedObjects& objects );
159 
160  /// initializes m_MenuBarMenu; override in derived classes
161  virtual void x_CreateMenuBarMenu();
162 
163  /// private, non-virtual event handlers. These functions are the
164  /// primary direct handlers for the event handling mechanism and will
165  /// forward event requests to public virtual functions on receipt
166  void eh_OnProjectChanged( CEvent* event );
167  void eh_OnViewAttached( CEvent* event );
168  void eh_OnViewReleased( CEvent* event );
169 
170 protected:
171  const size_t m_ViewId;
172 
174 
175  // the menu that view supplies to the application Menu Bar
176  unique_ptr<const wxMenu> m_MenuBarMenu;
177 
178 
179  //TODOCIRef<IGBDocument> m_Project; /// The document
182 
183  // cached project name (caching limits access to the project that requires
184  // locking).
187 
188  ISelectionService* m_SelectionService; /// the selection service we speak to
189 
190  CRgbaColor m_Color; /// this view's private color
191 
192  /// enum defining how we broadcast our selections
196 
198 };
199 
200 
201 ///////////////////////////////////////////////////////////////////////////////
202 /// CProjectViewToolBatFactory - provides standard toolbars for Project Views.
203 
205  public IToolBarContributor
206 {
207 public:
208  static const string sm_NavTBName;
209  static const string sm_SelTBName;
210 
211  /// @name IToolBarContributor implementation
212  /// @{
213  virtual void GetToolBarNames(vector<string>& names);
214  virtual wxAuiToolBar* CreateToolBar(const string& name, wxWindow* parent);
215  /// @}
216 
217 protected:
218  wxAuiToolBar* x_CreateNavigationToolbar(wxWindow* parent);
219  wxAuiToolBar* x_CreateSelectionToolbar(wxWindow* parent);
220 };
221 
223 
224 #endif /// GUI_CORE___PROJECT_VIEW_BASE_IMPL__HPP
CEventHandler.
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
CGBDocument.
Definition: document.hpp:113
CObjectEx –.
Definition: ncbiobj.hpp:2531
CObject –.
Definition: ncbiobj.hpp:180
CProjectViewBase - default implementation of IProjectView, the base class for CProjectView and CProje...
bool m_VisibleRangeChangeAllowed
this view's private color
static CIRef< IProjectViewLabel > m_LabelGenerator
CRef< objects::CScope > m_Scope
CRgbaColor m_Color
the selection service we speak to
unique_ptr< const wxMenu > m_MenuBarMenu
virtual void DestroyViewWindow()=0
destroy Window corresponding to the view
virtual const CViewTypeDescriptor & GetTypeDescriptor() const =0
return an object providing meta information about thei view type
ISelectionService * m_SelectionService
virtual void CreateViewWindow(wxWindow *parent)=0
create Window corresponding to the view
virtual wxWindow * GetWindow()=0
returns a pointer to the wxWindow representing the client
virtual void SetAsyncDestroy(bool reset_hist_async)
Set async destruction mode.
CProjectViewEvent.
Definition: document.hpp:62
CProjectViewToolBatFactory - provides standard toolbars for Project Views.
static const string sm_NavTBName
CProjectViewToolBatFactory.
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CUICommandRegistry is a centralized registry where all application commands should be registered.
Definition: ui_command.hpp:146
CViewTypeDescriptor - holds description of a view type.
Definition: view.hpp:98
class IProjectView defines the abstract interface for views observing projects.
ELabelType
Retrieve a label for this view. The label has several different.
objects::CGBProjectHandle::TId TProjectId
ISelectionService - an interface.
IServiceLocator - an abstract mechanism for locating services.
Definition: service.hpp:71
IToolBarContext - represent a UI object that requires toolbars.
IToolBarContributor - a factory that produces toolbars.
Definition: ui_command.hpp:395
virtual void GetToolBarNames(vector< string > &names)=0
returns the names of toolbars produced
virtual wxAuiToolBar * CreateToolBar(const string &name, wxWindow *parent)=0
creates a toolbar with the given name (must be deleted by the caller)
IView - represents a standard visual part of Workbench UI.
Definition: view.hpp:73
CFingerprint identifies an instance of IWMClient and is used for labeling layout positions.
Definition: wm_client.hpp:58
ELabel
Different flavors of label types for different GUI aspects.
Definition: wm_client.hpp:80
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
static const char fp[]
Definition: des.c:87
CRgbaColor & GetColor(CSeqFeatData::ESubtype subtype)
static const struct name_t names[]
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
string GetLabel(const CSeq_id &id)
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define NCBI_GUICORE_EXPORT
Definition: gui_export.h:508
n background color
objects::CGBProjectHandle::TId GetProjectId(wxTreeCtrl &treeCtrl, const CItem &item)
Definition: pt_utils.cpp:67
Definition: type.c:6
CScope & GetScope()
Modified on Wed May 15 15:06:52 2024 by modify_doxy.py rev. 669887