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

Go to the SVN repository for this file.

1 #ifndef GUI_CORE___PROJECT_TREE_PANEL__HPP
2 #define GUI_CORE___PROJECT_TREE_PANEL__HPP
3 
4 /* $Id: project_tree_panel.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  * Project Tree Panel class.
34  */
35 
36 #include <corelib/ncbistd.hpp>
37 
38 #include <gui/core/pt_item.hpp>
40 
43 
45 
46 #include <wx/panel.h>
47 #include <wx/treectrl.h>
48 #include <wx/dnd.h>
49 
51 
53 class IWorkbench;
54 class CGBDocument;
55 class IProjectView;
56 
57 namespace PT
58 {
59 class CRoot;
60 class CWorkspace;
61 }
62 
63 //////////////////////////////////////////////////////////////////////////////
64 /// CProjectTreeCtrl - subclass of wxTreeCtrl to allow functions to be
65 /// overridden for application-specific behavior.
66 
67 class CProjectTreeCtrl: public wxTreeCtrl
68 {
69  DECLARE_EVENT_TABLE()
70 public:
72  CProjectTreeCtrl(wxWindow *parent,
73  wxWindowID id = wxID_ANY,
74  const wxPoint& pos = wxDefaultPosition,
75  const wxSize& size = wxDefaultSize,
76  long style = wxTR_DEFAULT_STYLE,
77  const wxValidator &validator = wxDefaultValidator,
78  const wxString& name = wxTreeCtrlNameStr);
79 
80  virtual ~CProjectTreeCtrl() {};
81 
82  virtual wxTextCtrl *EditLabel(const wxTreeItemId& item,
83  wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl));
84 
85  void OnLeftDown(wxMouseEvent& event);
86  void OnKeyUp(wxKeyEvent& event);
87  void OnMove(wxMouseEvent& event);
88 };
89 
90 ///////////////////////////////////////////////////////////////////////////////
91 /// CProjectTreePanel - a window that represents Project View.
92 
94  public wxPanel,
95  public CEventHandler
96 {
97  DECLARE_EVENT_TABLE()
98 
99 public:
101  friend class CProjectTreeView;
102 
103  using TProjectId = objects::CGBProjectHandle::TId;
104  typedef vector<TProjectId> TProjectIdVector;
105 
106 public:
108  virtual ~CProjectTreePanel();
109 
110  /// Initializes member variables
111  void Init();
112 
113  /// Creates the controls and sizers
114  void CreateControls();
115 
116  void Create(wxWindow* parent,
117  wxWindowID id = wxID_ANY,
118  const wxPoint& pos = wxDefaultPosition,
119  const wxSize& size = wxDefaultSize);
120 
121  void SetWorkbench(IWorkbench* workbench);
122 
123  void GetSelectedItems(PT::TItems& items);
124  void GetAllItems(PT::TItems& items);
125  void GetSelectedProjectIds(TProjectIdVector& ids);
126 
127  /// @name Event handlers
128  /// @{
129  void OnContextMenu(wxContextMenuEvent& event);
130 
131  void OnItemExpandedCollapsed(wxTreeEvent& event);
132  void OnItemActivated(wxTreeEvent& event);
133  void OnSelectionChanged(wxTreeEvent& event);
134  void OnBeginDrag(wxTreeEvent& event);
135  void OnEndDrag(wxTreeEvent& event);
136  void OnTreeKeyDown(wxTreeEvent& event);
137  void OnBeginLabelEdit(wxTreeEvent& event);
138  void OnEndLabelEdit(wxTreeEvent& event);
139 
140  void OnLeftDown(wxMouseEvent& event);
141 
142  void OnCut(wxCommandEvent& event);
143  void OnUpdateCut(wxUpdateUIEvent& event);
144  void OnCopy(wxCommandEvent& event);
145  void OnUpdateCopy(wxUpdateUIEvent& event);
146  void OnPaste(wxCommandEvent& event);
147  void OnUpdatePaste(wxUpdateUIEvent& event);
148 
149  void OnRemove(wxCommandEvent& event);
150  void OnUpdateRemove(wxUpdateUIEvent& event);
151 
152  void OnShowHideDisabledItems(wxCommandEvent& event);
153  void OnUpdateShowHideDisabledItems(wxUpdateUIEvent& event);
154 
155  void OnEnableDisable(wxCommandEvent& event);
156  void OnUpdateEnableDisable(wxUpdateUIEvent& event);
157  void OnNewFolder(wxCommandEvent& event);
158  void OnUpdateNewFolder(wxUpdateUIEvent& event);
159 
160  void OnCloseView(wxCommandEvent& event);
161  void OnUpdateCloseView(wxUpdateUIEvent& event);
162  void OnActivateClients(wxCommandEvent& event);
163  void OnUpdateActivateClients(wxUpdateUIEvent& event);
164  void OnProperties(wxCommandEvent& event);
165  void OnUpdateProperties(wxUpdateUIEvent& event);
166 
167  void OnUpdateUnLoadProject(wxUpdateUIEvent& event);
168  void OnUnLoadProject(wxCommandEvent& event);
169 
170  void OnLoadProject(wxCommandEvent& event);
171  void OnUpdateLoadProject(wxUpdateUIEvent& event);
172 
173  void OnRemoveProject(wxCommandEvent& event);
174  void OnUpdateRemoveProject(wxUpdateUIEvent& event);
175 
176  void OnProjectTableView(wxCommandEvent& event);
177  void OnUpdateProjectTableView(wxUpdateUIEvent& event);
178  /// @}
179 
180  void ProjectStateChanged(CGBDocument& doc);
181  void ProjectViewsChanged(CGBDocument& doc);
182  void ProjectAdded(CGBDocument& doc);
183  void ProjectUpdateItems(CGBDocument& doc);
184  void ProjectUpdateLabel(CGBDocument& doc);
185  void UpdateViewLabel(CGBDocument& doc, IProjectView& view);
186  void ProjectRemoved(size_t id);
187  void UpdateDisabledItems();
188  void UpdateWorkspaceLabel();
189 
190  /// @name Command handlers
191  /// @{
192  /// @}
193 
194  /// @name D&D support - interface for Drop Target
195  /// @{
196  wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
197  wxDragResult OnDrop(wxCoord x, wxCoord y, wxDragResult def, CAppExplorerDataObject& data);
198  /// @}
199 
200  /// Drag and drop support for OSX Cocoa (generic dnd path not working in OSX cocoa 2.9.3
201  /// so we use dnd specific to the tree in this case).
202  void SetCopyMode(bool b) { m_CopyMode = b; }
203 
204  void ReloadProjectTree();
205 
206 protected:
207  void x_SetSelections(wxArrayTreeItemIds& ids);
208  void x_GetItemsFromIds(const wxArrayTreeItemIds& ids, PT::TItems& items);
209  void x_CollectItemIds( wxTreeItemId root, wxArrayTreeItemIds &ids );
210 
211  PT::CItem* x_GetExplorerItem(const wxTreeItemId& id);
212  PT::CItem* x_GetSingleSelectedItem();
213 
216 
217  void x_LoadUnloadProject(bool load);
218 
219  void x_RefreshProjectTables(TProjectId projectId);
220 
221  CAppExplorerDataObject* x_CreateDataObject(bool cut);
222  void x_CutOrCopyToClipboard(bool cut);
223  void x_ClearClipboardData();
224 
226 
227  PT::CRoot* x_GetRootItem();
228  PT::CWorkspace* x_GetWorkspaceItem();
229 
230 protected:
231  /// Data object used for drag and drop (this is the data being dragged)
233  string m_RegPath;
234 
237 
239 
240  vector<wxEvtHandler*> m_ContributedHandlers;
241 
242  /// D&D state
243  wxTreeItemId m_DropItemId; // current D&D target
246 
247  // D&D copy (vs move) state for D&D implemented with tree-functions (osx cocoa)
248  bool m_CopyMode;
249 };
250 
251 
252 ///////////////////////////////////////////////////////////////////////////////
253 /// CProjectTreeViewDropTarget - a drop target associated with CProjectTreeView.
254 class CProjectTreeViewDropTarget : public wxDropTarget
255 {
256 public:
258 
259  /// @name wxDropTarget virtual functions
260  /// @{
261  virtual wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def);
262  virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
263  virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
264  /// @}
265 
266 protected:
269 };
270 
271 
273 
274 #endif // GUI_CORE___PROJECT_TREE_PANEL__HPP
User-defined methods of the data storage class.
CAppExplorerDataObject - wxDataObject for use with CAppExplorerService.
CEventHandler.
CGBDocument.
Definition: document.hpp:113
CProjectTreeCtrl - subclass of wxTreeCtrl to allow functions to be overridden for application-specifi...
void OnMove(wxMouseEvent &event)
void OnLeftDown(wxMouseEvent &event)
void OnKeyUp(wxKeyEvent &event)
CProjectTreeCtrl()
CProjectTreeCtrl.
virtual wxTextCtrl * EditLabel(const wxTreeItemId &item, wxClassInfo *textCtrlClass=CLASSINFO(wxTextCtrl))
CProjectTreePanel - a window that represents Project View.
void x_LoadUnloadProject(bool load)
CRef< objects::CGBWorkspace > m_WS
objects::CGBProjectHandle::TId TProjectId
CAppExplorerDataObject * m_DataObject
Data object used for drag and drop (this is the data being dragged)
bool x_AtLeastOneProjectLoaded()
wxTreeItemId m_DropItemId
D&D state.
void SetCopyMode(bool b)
Drag and drop support for OSX Cocoa (generic dnd path not working in OSX cocoa 2.9....
vector< TProjectId > TProjectIdVector
vector< wxEvtHandler * > m_ContributedHandlers
CProjectTreeCtrl * m_Tree
bool x_AllViewsItemSelected(PT::TItems &items)
CProjectTreeViewDropTarget - a drop target associated with CProjectTreeView.
virtual wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def)
CProjectTreeViewDropTarget(CProjectTreePanel *panel)
CProjectTreeViewDropTarget.
virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def)
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def)
CProjectTreeView - a system view that displays Project Tree.
void GetSelectedItems(PT::TItems &items)
END of ISelectionClient ///////////////////////////////////////////////////.
virtual void SetWorkbench(IWorkbench *workbench)
connect / disconnect this view with / from Workbench
CStopWatch –.
Definition: ncbitime.hpp:1938
pair< wxMenu *, wxEvtHandler * > TContribution
Contribution consists of a Menu object and event handler.
Definition: pt_item.hpp:152
class IProjectView defines the abstract interface for views observing projects.
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.
static void Init(void)
Definition: cursor6.c:76
#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
vector< CItem * > TItems
Definition: pt_item.hpp:113
const struct ncbi::grid::netcache::search::fields::SIZE size
static static static wxID_ANY
Modified on Fri Mar 01 10:05:35 2024 by modify_doxy.py rev. 669887