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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___LAYOUT_TRACK_HANDLER__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___LAYOUT_TRACK_HANDLER__HPP
3 
4 /* $Id: layout_track_handler.hpp 40803 2018-04-12 15:25:55Z 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: Liangshou Wu
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbiobj.hpp>
36 #include <gui/gui_export.h>
38 #include <gui/opengl/glpane.hpp>
41 
42 
44 
45 ///////////////////////////////////////////////////////////////////////////////
46 /// ITrackHandlerHost
47 /// ITrackHandlerHost represents a context for handling the user interactions
48 /// on a layout track.
49 ///
51 {
52 public:
53  virtual ~ITrackHandlerHost() {};
54 
55  /// Get the layout track under the current mouse position.
56  /// @param pos the mouse pos in window coord. sys.
58  virtual TModelPoint THH_GetModelByWindow(const wxPoint& pt) = 0;
59 };
60 
61 ////////////////////////////////////////////////////////////////////////////////
62 /// CLayoutTrackHandler - is the handler for handling the user interactions
63 /// on layout tracks. The interactions include repositioning a track, collapsing
64 /// a track, expanding a track , closing a track and other events resulting from
65 /// clicking on an icon or button.
66 ///
67 /// TODO: The declaration is not completed.
68 
70  public wxEvtHandler,
71  public IGlEventHandler
72 {
73  DECLARE_EVENT_TABLE()
74 public:
75  enum EState {
78  eIdle
79  };
80 
81  typedef EState TState;
82 
84  : m_DropTarget(0)
85  , m_Host(NULL)
86  , m_Pane(NULL)
87  , m_State(eIdle)
88  {}
89 
90  void SetHost(ITrackHandlerHost* host);
91  IGenericHandlerHost* GetGenericHost();
92  void Render(CGlPane& pane);
93 
94  /// @name IGlEventHandler implementaion
95  /// @{
96  virtual void SetPane(CGlPane* pane);
97  virtual wxEvtHandler* GetEvtHandler();
98  /// @}
99 
100  void OnKeyEvent(wxKeyEvent& event);
101  void OnOtherMouseEvents(wxMouseEvent& event);
102  void OnLeftDown(wxMouseEvent& event);
103  void OnLeftUp(wxMouseEvent& event);
104  void OnLeftDblClick(wxMouseEvent& event);
105  void OnMotion(wxMouseEvent& event);
106  void OnMouseCaptureLost(wxMouseCaptureLostEvent& event);
107 
108  // Drag&drop control
109  void SetDraggable(bool draggable);
110 private:
111  void x_StartMoving();
112  void x_StopMoving();
113  void x_Move(const TModelPoint& pos);
114  void x_MoveTrackUpRecursive(TModelUnit delta_y, TModelUnit& top);
115  void x_MoveTrackDownRecursive(TModelUnit delta_y, TModelUnit& top);
116 
117 private:
126  bool m_Draggable = true; // supports darg&drop operation
127 };
128 
129 ///////////////////////////////////////////////////////////////////////////////
130 /// CLayoutTrackHandler inline methods
131 ///
132 inline
134 { m_Host = host; }
135 
136 inline /*virutal*/
138 { m_Pane = pane; }
139 
140 inline
142 { return this; }
143 
144 inline
146 { return dynamic_cast<IGenericHandlerHost*>(m_Host); }
147 
148 inline
150 {
151  m_Draggable = draggable;
152 }
153 
155 
156 
157 #endif // GUI_WIDGETS_SEQ_GRAPHIC___LAYOUT_TRACK_HANDLER__HPP
158 
class CGlPane
Definition: glpane.hpp:62
CLayoutTrackHandler - is the handler for handling the user interactions on layout tracks.
virtual wxEvtHandler * GetEvtHandler()
void SetDraggable(bool draggable)
void SetHost(ITrackHandlerHost *host)
CLayoutTrackHandler inline methods.
CRef< CLayoutTrack > m_Delegate
IGenericHandlerHost * GetGenericHost()
CRef< CLayoutTrack > m_LastHitTrack
ITrackHandlerHost * m_Host
virtual void SetPane(CGlPane *pane)
IDroppable The interface for tracks that support drag&drop.
IGenericHandlerHost.
IGlEventHandler.
virtual void SetPane(CGlPane *)
virtual wxEvtHandler * GetEvtHandler()=0
ITrackHandlerHost ITrackHandlerHost represents a context for handling the user interactions on a layo...
virtual TModelPoint THH_GetModelByWindow(const wxPoint &pt)=0
virtual CRef< CLayoutTrack > THH_GetLayoutTrack()=0
Get the layout track under the current mouse position.
#define NULL
Definition: ncbistd.hpp:225
GLdouble TModelUnit
Definition: gltypes.hpp:48
#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_GUIWIDGETS_SEQGRAPHIC_EXPORT
Definition: gui_export.h:536
Defines to provide correct exporting from DLLs in Windows.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
@ eIdle
Modified on Thu Feb 22 17:10:48 2024 by modify_doxy.py rev. 669887