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

Go to the SVN repository for this file.

1 #ifndef GUI_FRAMEWORK___TASK_VIEW__HPP
2 #define GUI_FRAMEWORK___TASK_VIEW__HPP
3 
4 /* $Id: task_view.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
30  *
31  * File Description:
32  *
33  */
34 
35 /** @addtogroup GUI_FRAMEWORK
36 *
37 * @{
38 */
39 
40 #include <corelib/ncbistd.hpp>
41 #include <corelib/ncbitime.hpp>
42 
43 #include <gui/gui_export.h>
44 
45 #include <gui/framework/view.hpp>
47 
50 
52 
53 #include <gui/utils/command.hpp>
54 #include <gui/utils/extension.hpp>
55 
56 #include <deque>
57 
58 #include <wx/panel.h>
59 #include <wx/timer.h>
60 
62 
63 class CwxTableListCtrl;
64 
65 
66 ///////////////////////////////////////////////////////////////////////////////
67 /// CTaskViewModel - table model for Task View.
68 
70 {
71 public:
75 
76  enum EColumns {
77  eNone = -1,
82  eMaxCols /// this must be the last!
83  };
84 
85 public:
87 
88  virtual int GetNumRows() const;
89  virtual int GetNumColumns() const;
90  virtual wxVariant GetValueAt(int row, int col) const;
91  virtual wxString GetColumnType(int col) const;
92  virtual wxString GetColumnName(int col) const;
93 
94  void ShowTasksByState(IAppTask::ETaskState state, bool show, bool up = true);
96 
97  TTaskRef GetTask(int row);
98 
99  void UpdateTable();
100 
101 protected:
102  typedef vector<TTaskRef> TTaskRefVec;
103 
104  void x_AddTasks(TRecRefVec& tasks);
105 
106 protected:
107  string m_Names[eMaxCols];
109 
111  vector<bool> m_Filter;
112  vector<TRecordRef> m_Records;
113 };
114 
115 
116 ///////////////////////////////////////////////////////////////////////////////
117 /// CTaskTablePanel - panel that owns a Table and a Table Model, this is the
118 /// window for CTaskView.
120  public wxPanel,
121  public IRegSettings
122 {
123  DECLARE_EVENT_TABLE()
124 public:
126 
127  enum ECommands {
128  eCmdDetails = 20000, //TODO use Actions,
129  eCmdCancel
130  };
131 
132  CTaskTablePanel();
133  virtual ~CTaskTablePanel();
134 
135  /// Initializes member variables
136  virtual void Init();
137 
138  /// Creates the controls and sizers
139  virtual void CreateControls();
140 
141 
142  virtual void Create(wxWindow* parent,
143  wxWindowID id = wxID_ANY,
144  const wxPoint& pos = wxDefaultPosition,
145  const wxSize& size = wxDefaultSize);
146 
147  virtual void CreateModel(CAppTaskService* task_srv);
148  virtual void DestroyModel();
149  virtual void UpdateTable();
150 
151  /// @name IRegSettings interface implementation
152  /// @{
153  virtual void SetRegistryPath(const string& path);
154  virtual void LoadSettings();
155  virtual void SaveSettings() const;
156  /// @}
157 
158  virtual void AppendMenuItems( wxMenu& aMenu );
159 
160  /// @name Event handers
161  /// @{
162  void OnContextMenu(wxContextMenuEvent& event);
163  void OnItemActivated(wxListEvent& event);
164  void OnShowDetailsDialog(long vis_index);
165 
166  void OnCancel(wxCommandEvent& event);
167  void OnDetails(wxCommandEvent& event);
168 
169  void OnUpdateCancel(wxUpdateUIEvent& event);
170  void OnUpdateDetails(wxUpdateUIEvent& event);
171 
172  void OnEventTimer(wxTimerEvent& event);
173  /// @}
174 
175 protected:
176  void x_GetSelectedTasks(vector<TTaskRef>& tasks);
177  void x_SetSelectedTasks(vector<TTaskRef>& tasks);
178 
179 protected:
181  string m_RegPath;
182  wxTimer m_EventTimer;
183 
186 };
187 
188 ///////////////////////////////////////////////////////////////////////////////
189 /// CTaskView - IView, that uses CTaskTablePanel as its window.
190 /// Displays tasks executing in CAppTaskService.
191 
193  public CObjectEx,
194  public IView,
195  public IWMClient,
196  public CEventHandler,
197  public IRegSettings
198 {
199  friend class CTaskViewFactory;
201 public:
202  CTaskView();
203  virtual ~CTaskView();
204 
205  /// @name IView interface implementation
206  /// @{
207  virtual const CViewTypeDescriptor& GetTypeDescriptor() const;
208  virtual void SetWorkbench(IWorkbench* workbench);
209  virtual void CreateViewWindow(wxWindow* parent);
210  virtual void DestroyViewWindow();
211  /// @}
212 
213  /// @name IWMClient interface implementation
214  /// @{
215  virtual wxWindow* GetWindow();
216  virtual wxEvtHandler* GetCommandHandler() { return GetWindow()->GetEventHandler(); }
217  virtual string GetClientLabel(IWMClient::ELabel ltype = IWMClient::eDefault) const;
218  virtual string GetIconAlias() const;
219  virtual const CRgbaColor* GetColor() const;
220  virtual void SetColor(const CRgbaColor& color);
221  virtual const wxMenu* GetMenu();
222  virtual void UpdateMenu(wxMenu& root_menu);
223  virtual CFingerprint GetFingerprint() const;
224  /// @}
225 
226  /// @name IRegSettings interface implementation
227  /// @{
228  virtual void SetRegistryPath(const string& path);
229  virtual void LoadSettings();
230  virtual void SaveSettings() const;
231  /// @}
232 
233 protected:
234  void x_OnUpdate(CEvent*);
235 
237 
239  string m_RegPath;
240 
242 };
243 
244 ///////////////////////////////////////////////////////////////////////////////
245 /// CTaskViewFactory
247  public CObject,
248  public IExtension,
249  public IViewFactory
250 {
251 public:
252  /// @name IExtension interface implementation
253  /// @{
254  virtual string GetExtensionIdentifier() const;
255  virtual string GetExtensionLabel() const;
256  /// @}
257 
258  /// @name IViewFactory interface implementation
259  /// @{
260  virtual void RegisterIconAliases(wxFileArtProvider& provider);
261  virtual const CViewTypeDescriptor& GetViewTypeDescriptor() const;
262  virtual IView* CreateInstance() const;
263  virtual IView* CreateInstanceByFingerprint(const TFingerprint& fingerprint) const;
264  /// @}
265 };
266 
267 
269 
270 /* @} */
271 
272 #endif // GUI_FRAMEWORK___TASK_VIEW__HPP
CAppTaskService - Application Task Service.
CEventHandler.
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
CObjectEx –.
Definition: ncbiobj.hpp:2531
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CTaskTablePanel - panel that owns a Table and a Table Model, this is the window for CTaskView.
Definition: task_view.hpp:122
CTaskViewFactory.
Definition: task_view.hpp:250
CTaskViewModel - table model for Task View.
Definition: task_view.hpp:70
CTaskView - IView, that uses CTaskTablePanel as its window.
Definition: task_view.hpp:198
CTimeFormat –.
Definition: ncbitime.hpp:131
CViewTypeDescriptor - holds description of a view type.
Definition: view.hpp:98
CwxAbstractTableModel - simple TableModel implementation.
CwxTableListCtrl - generic wxListCtrl-based Table Control.
IExtension IExtension interface represents an abstract pluggable component.
Definition: extension.hpp:57
IRegSettings An interface for objects that save / restore settings using CGuiRegistry.
virtual void SaveSettings() const =0
virtual void LoadSettings()=0
virtual void SetRegistryPath(const string &path)=0
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
IWClient - abstract Window Manager client.
Definition: wm_client.hpp:50
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
GUI command routing and handling framework.
Include a standard set of the NCBI C++ Toolkit most basic headers.
CRgbaColor & GetColor(CSeqFeatData::ESubtype subtype)
static void Init(void)
Definition: cursor6.c:76
CAppTaskService * m_TaskService
Definition: task_view.hpp:110
string m_Names[eMaxCols]
Definition: task_view.hpp:107
virtual wxString GetColumnName(int col) const
Returns a default name for the column using spreadsheet conventions: A, B, C, ...
Definition: task_view.cpp:155
virtual wxString GetColumnType(int col) const
Tries to extract actual type from row 0 value if it exists.
Definition: task_view.cpp:149
CAppTaskService * m_TaskService
Definition: task_view.hpp:180
CTaskTablePanel * m_Panel
Definition: task_view.hpp:241
virtual wxEvtHandler * GetCommandHandler()
returns a pointer to the command handler (for menu commands and updates)
Definition: task_view.hpp:216
virtual int GetNumRows() const
Returns the number of rows in the model.
Definition: task_view.cpp:81
void ShowTasksByState(IAppTask::ETaskState state, bool show, bool up=true)
Definition: task_view.cpp:161
CwxTableListCtrl * m_Table
Definition: task_view.hpp:185
CAppTaskService::TRecRefVec TRecRefVec
Definition: task_view.hpp:74
virtual wxVariant GetValueAt(int row, int col) const
Definition: task_view.cpp:110
void x_AddTasks(TRecRefVec &tasks)
Definition: task_view.cpp:199
CAppTaskService * m_TaskService
Definition: task_view.hpp:238
string m_RegPath
Definition: task_view.hpp:239
CTimeFormat m_TimeFormat
Definition: task_view.hpp:108
vector< TRecordRef > m_Records
Definition: task_view.hpp:112
wxTimer m_EventTimer
Definition: task_view.hpp:182
DECLARE_EVENT_MAP()
vector< TRecordRef > TRecRefVec
ETaskState
List of task states defining the task management FSM.
Definition: app_task.hpp:87
CAppTaskService::TTaskRef TTaskRef
Definition: task_view.hpp:125
bool IsStateShown(IAppTask::ETaskState state)
Definition: task_view.cpp:170
static CViewTypeDescriptor m_TypeDescr
CTaskView.
Definition: task_view.hpp:236
TTaskRef GetTask(int row)
Definition: task_view.cpp:176
CTaskViewModel(CAppTaskService *task_srv)
CTaskView.
Definition: task_view.cpp:67
vector< TTaskRef > TTaskRefVec
Definition: task_view.hpp:102
void UpdateTable()
Definition: task_view.cpp:182
virtual int GetNumColumns() const
Returns the number of columns in the model.
Definition: task_view.cpp:87
CAppTaskService::TTaskRef TTaskRef
Definition: task_view.hpp:72
vector< bool > m_Filter
Definition: task_view.hpp:111
CTaskViewModel * m_Model
Definition: task_view.hpp:184
CAppTaskService::TRecordRef TRecordRef
Definition: task_view.hpp:73
@ eMaxCols
this must be the last!
Definition: task_view.hpp:82
#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
Defines to provide correct exporting from DLLs in Windows.
n background color
const struct ncbi::grid::netcache::search::fields::SIZE size
Defines: CTimeFormat - storage class for time format.
static static static wxID_ANY
#define row(bind, expected)
Definition: string_bind.c:73
Modified on Wed May 29 18:37:21 2024 by modify_doxy.py rev. 669887