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

Go to the SVN repository for this file.

1 #ifndef GUI_UTILS_UNIT_TEST___EVENTS_TOOLS__HPP
2 #define GUI_UTILS_UNIT_TEST___EVENTS_TOOLS__HPP
3 
4 /* $Id: events_tools.hpp 14565 2007-05-18 12:32:01Z dicuccio $
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 #include <corelib/ncbistd.hpp>
36 
38 #include <gui/utils/command.hpp>
39 
40 
42 
43 ///////////////////////////////////////////////////////////////////////////////
44 /// ETestCmds - test commands
45 enum ETestCmds {
51  eCmd_6
52 };
53 
54 ///////////////////////////////////////////////////////////////////////////////
55 /// CTraceEvent
56 class CTraceEvent : public CEvent
57 {
58 public:
59  typedef string TTrace;
60 
61  enum EType {
66  eType_F
67  };
68 
69  CTraceEvent(CEvent::TEventClass cls, CEvent::TEventID id);
70  CTraceEvent(TEventClass ecl, TEventID eid, IEventAttachment* att,
71  EOwnershipPolicy policy, TEventSender* sender);
72 
73  const TTrace& GetTrace() const;
74  void AddTrace(const TTrace& trace);
75 
76 protected:
78 };
79 
80 
81 ///////////////////////////////////////////////////////////////////////////////
82 /// CTracingHandler
83 
84 class CTracingHandler : public ncbi::CEventHandler
85 {
86 public:
88 
89  CTracingHandler(int id = -1);
90 
91  // creates a handler bound to the specific trace
92  CTracingHandler(int id, TTrace& trace);
93 
94  void ClearTrace();
95  const TTrace* GetTrace();
96 
97  void OnEvent_A(CEvent* evt);
98  void OnEvent_B(CEvent* evt);
99 
100  void OnMessage_A(CEvent* evt);
101  void OnMessage_B(CEvent* evt);
102 
103  void OnCommand_1();
104  void OnCommand_2();
105  void OnCommand_Range(TCmdID cmd);
106 
107  void OnUpdateCommand_1(ICmdUI* pCmdUI);
108  void OnUpdateCommand_2(ICmdUI* pCmdUI);
109  void OnUpdateCommand_Range(ICmdUI* pCmdUI);
110 
111 protected:
113 
114  string x_GetMethodTrace(const string& method) const;
115  void x_AddTrace(CEvent* evt, const string& method);
116  void x_AddTrace(const string& trace);
117 
118 protected:
119  int m_ID;
121 };
122 
123 
124 typedef void (CTracingHandler::*FOnEventHandler)(CEvent* evt);
125 typedef void (CTracingHandler::*FOnCommandHandler)(void);
127 
128 ///////////////////////////////////////////////////////////////////////////////
129 /// CTestCmdUI
130 class CTestCmdUI : public ICmdUI
131 {
132 public:
133  CTestCmdUI(TCmdID cmd, const string& label);
134  CTestCmdUI(TCmdID cmd, const string& label, bool en, bool check, bool radio);
135 
136  /// @name ICmdUI implementation
137  /// @{
138  virtual TCmdID GetCommand() const;
139  virtual void Enable(bool en);
140  virtual void SetCheck(bool set);
141  virtual void SetRadio(bool set);
142  virtual void SetLabel(const string& label);
143  /// @}
144 
145  /// "true" if at least one memeber was called
146  bool IsEnabled() const { return m_Enabled; }
147  bool IsChecked() const { return m_Checked; }
148  bool IsRadio() const { return m_Radio; }
149 
150  bool IsVisited() const { return m_Visited; }
151 
152 protected:
154  string m_Label;
155  bool m_Enabled;
156  bool m_Checked;
157  bool m_Radio;
158  bool m_Visited;
159 };
160 
161 
163 
164 #endif // GUI_UTILS_UNIT_TEST___EVENTS_TOOLS__HPP
CEventHandler.
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
CTestCmdUI.
CTestCmdUI(TCmdID cmd, const string &label)
CTestCmdUI.
bool IsVisited() const
bool IsRadio() const
virtual void Enable(bool en)
virtual TCmdID GetCommand() const
virtual void SetRadio(bool set)
string m_Label
bool IsChecked() const
bool IsEnabled() const
"true" if at least one memeber was called
virtual void SetLabel(const string &label)
virtual void SetCheck(bool set)
CTraceEvent.
const TTrace & GetTrace() const
CTraceEvent(CEvent::TEventClass cls, CEvent::TEventID id)
void AddTrace(const TTrace &trace)
TTrace m_Trace
CTracingHandler.
void OnEvent_A(CEvent *evt)
void OnUpdateCommand_2(ICmdUI *pCmdUI)
void OnUpdateCommand_Range(ICmdUI *pCmdUI)
const TTrace * GetTrace()
string x_GetMethodTrace(const string &method) const
void OnMessage_B(CEvent *evt)
void x_AddTrace(CEvent *evt, const string &method)
void OnEvent_B(CEvent *evt)
CTraceEvent::TTrace TTrace
void OnCommand_Range(TCmdID cmd)
CTracingHandler(int id=-1)
CTracingHandler.
void OnUpdateCommand_1(ICmdUI *pCmdUI)
void OnMessage_A(CEvent *evt)
object, that will be attached to event
Definition: event.hpp:51
Definition: set.hpp:45
GUI command routing and handling framework.
Include a standard set of the NCBI C++ Toolkit most basic headers.
ETestCmds
ETestCmds - test commands.
@ eCmd_6
@ eCmd_4
@ eCmd_3
@ eCmd_5
@ eCmd_1
@ eCmd_2
void(CTracingHandler::* FOnEventHandler)(CEvent *evt)
void(CTracingHandler::* FOnCommandRangeHandler)(TCmdID cmd)
void(CTracingHandler::* FOnCommandHandler)(void)
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define check(s)
Definition: describecol2.c:21
static bool trace
Int4 TEventID
Definition: event.hpp:90
EOwnershipPolicy
Definition: event.hpp:109
int TCmdID
@ eEvent_MinClientID
Definition: event.hpp:106
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static const char label[]
Modified on Fri Sep 20 14:58:07 2024 by modify_doxy.py rev. 669887