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

Go to the SVN repository for this file.

1 #ifndef GUI_FRAMEWORK___VIEW__HPP
2 #define GUI_FRAMEWORK___VIEW__HPP
3 
4 /* $Id: view.hpp 24057 2011-07-15 15:37:02Z 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: Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
35 /** @addtogroup GUI_FRAMEWORK
36 *
37 * @{
38 */
39 
40 #include <corelib/ncbistd.hpp>
41 
42 #include <gui/gui_export.h>
43 
45 
46 #include <gui/utils/ui_object.hpp>
47 
48 class wxFileArtProvider;
49 class wxWindow;
50 
51 
53 
54 class IWorkbench;
56 class CUICommandRegistry;
57 
58 ///////////////////////////////////////////////////////////////////////////////
59 /// IView - represents a standard visual part of Workbench UI.
60 /// IView usually implements other UI-related interfaces such as IWMClient,
61 /// IMenuContributor, IToolBarContext, IHelpContext etc.
62 ///
63 /// IView lifetime shall be managed using CIRef and CRef smart pointers.
64 /// Because of this classes that implement IView shall not derive from
65 /// wxWindow. wxWindow has its own lifetime management policy that is not
66 /// compatible with smart pointers.
67 ///
68 /// It is recommended that all classes inherited from IView implement
69 /// IRegSettings interface, this will allow the framework to save / restore
70 /// view's settings automatically.
71 
72 class IView
73 {
74 public:
75  virtual ~IView() {}
76 
77  /// return an object providing meta information about thei view type
78  virtual const CViewTypeDescriptor& GetTypeDescriptor() const = 0;
79 
80  /// connect / disconnect this view with / from Workbench
81  virtual void SetWorkbench(IWorkbench* workbench) = 0;
82 
83  /// create Window corresponding to the view
84  virtual void CreateViewWindow(wxWindow* parent) = 0;
85 
86  /// destroy Window corresponding to the view
87  virtual void DestroyViewWindow() = 0;
88 };
89 
90 
91 ///////////////////////////////////////////////////////////////////////////////
92 /// CViewTypeDescriptor - holds description of a view type.
93 /// CViewTypeDescriptor is used for declaring view types and presenting the
94 /// information about available types in the UI.
95 
97  : public CUIObject
98 {
99 public:
103  eMultiple
104  };
105 
106 public:
108  const string& label,
109  const string& icon_alias,
110  const string& hint,
111  const string& description,
112  const string& help_id,
113  const string& category,
114  bool singleton
115  );
116 
117  virtual ~CViewTypeDescriptor();
118 
119  /// get view category (used for view grouping in UI)
120  virtual string GetCategory() const;
121 
122  /// true if only one instance of this type can be created
123  virtual bool IsSingleton() const;
124 
125  virtual void SetCategory( const string& category );
126  virtual void SetSingleton( bool singleton );
127 
128 protected:
129  string m_Category;
131 };
132 
133 
134 ///////////////////////////////////////////////////////////////////////////////
135 /// IViewFactory - view factory for use with IViewManagerService.
136 /// IViewFactory correspond to one specific view type and used by View Manager
137 /// Service to produce instances of this type.
138 
140 {
141 public:
143 
144  /// called by the framework to give Factory a chance to register images
145  /// used by view
146  virtual void RegisterIconAliases(wxFileArtProvider& provider) = 0;
147 
148  /// called by the framework to give Factory a chance to register commands
149  /// used by view
151 
152  /// returns a Descriptor for the View Type supported by the Factory
153  virtual const CViewTypeDescriptor& GetViewTypeDescriptor() const = 0;
154 
155  /// creates a view instance
156  virtual IView* CreateInstance() const = 0;
157 
158  /// if fingerprint is recognized - creates and returns a new instance
159  virtual IView*
160  CreateInstanceByFingerprint(const TFingerprint& fingerprint) const = 0;
161 
162  virtual ~IViewFactory() {};
163 };
164 
165 
167 
168 /* @} */
169 
170 #endif // GUI_FRAMEWORK___VIEW__HPP
171 
CUICommandRegistry is a centralized registry where all application commands should be registered.
Definition: ui_command.hpp:146
CUIObject - default mix-in implementation of IUIObject.
Definition: ui_object.hpp:81
CViewTypeDescriptor - holds description of a view type.
Definition: view.hpp:98
IViewFactory - view factory for use with IViewManagerService.
Definition: view.hpp:140
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
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
Include a standard set of the NCBI C++ Toolkit most basic headers.
virtual IView * CreateInstanceByFingerprint(const TFingerprint &fingerprint) const =0
if fingerprint is recognized - creates and returns a new instance
virtual const CViewTypeDescriptor & GetViewTypeDescriptor() const =0
returns a Descriptor for the View Type supported by the Factory
virtual ~IView()
Definition: view.hpp:75
virtual ~IViewFactory()
Definition: view.hpp:162
virtual void SetWorkbench(IWorkbench *workbench)=0
connect / disconnect this view with / from Workbench
string m_Category
Definition: view.hpp:129
virtual void DestroyViewWindow()=0
destroy Window corresponding to the view
virtual IView * CreateInstance() const =0
creates a view instance
virtual void CreateViewWindow(wxWindow *parent)=0
create Window corresponding to the view
virtual void RegisterCommands(CUICommandRegistry &, wxFileArtProvider &)
called by the framework to give Factory a chance to register commands used by view
Definition: view.hpp:150
IWMClient::CFingerprint TFingerprint
Definition: view.hpp:142
virtual const CViewTypeDescriptor & GetTypeDescriptor() const =0
return an object providing meta information about thei view type
virtual void RegisterIconAliases(wxFileArtProvider &provider)=0
called by the framework to give Factory a chance to register images used by view
#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_GUIFRAMEWORK_EXPORT
Definition: gui_export.h:509
static const char label[]
Defines to provide correct exporting from DLLs in Windows.
Modified on Sat Mar 02 10:54:25 2024 by modify_doxy.py rev. 669887