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

Go to the SVN repository for this file.

1 #ifndef GUI_FRAMEWORK___STATUS_BAR_SERVICE_IMPL__HPP
2 #define GUI_FRAMEWORK___STATUS_BAR_SERVICE_IMPL__HPP
3 
4 /* $Id: status_bar_service_impl.hpp 45899 2021-01-08 03:55:09Z asztalos $
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  * CStatusBarService - standard implementation of IStatusBarService.
33  */
34 
35 /** @addtogroup GUI_FRAMEWORK
36 *
37 * @{
38 */
39 
40 #include <corelib/ncbiobj.hpp>
41 
42 #include <gui/gui_export.h>
43 
46 
48 
49 // This header must (at least indirectly) precede any wxWidgets headers.
51 
52 #include <wx/event.h>
53 #include <wx/panel.h>
54 #include <wx/frame.h>
55 #include <wx/timer.h>
56 #include <wx/bitmap.h>
57 
58 
59 class wxBoxSizer;
60 class wxFileArtProvider;
61 class wxTimerEvent;
62 class wxGauge;
63 class wxHyperlinkEvent;
64 
65 
67 
68 class CStatusBar;
69 class CMessageSlot;
71 class CEventLogService;
72 
73 ///////////////////////////////////////////////////////////////////////////////
74 /// CStatusBarService - the standard implementation of IStatusBarService
75 /// interface. (see IStatusBarService declaration for information)
76 
78  public CObjectEx,
79  public IStatusBarService,
80  public IService,
82  public CEventHandler
83 {
86 public:
88  virtual ~CStatusBarService();
89 
90  /// @name IService interface implementation
91  /// @{
92  virtual void InitService();
93  virtual void ShutDownService();
94  /// @}
95 
96  /// @name IServiceLocatorConsumer implementation
97  /// @{
98  virtual void SetServiceLocator(IServiceLocator* locator);
99  /// @}
100 
101  virtual wxStatusBar* CreateStatusBar(wxFrame* frame);
102  virtual void SetEventDisplayTime(int sec);
103 
104  /// @name IStatusBarService implementation
105  /// @{
106  virtual void SetStatusMessage(const string& msg);
107  virtual void AddEventMessage(const IEventRecord& record);
108  virtual void ShowHintMessage(const string& msg);
109  virtual void HideHintMessage();
110  virtual void ShowStatusProgress(int value, int range);
111  virtual void ShowStatusProgress();
112  virtual void HideStatusProgress();
113 
114  virtual void InsertSlot(int index, wxWindow* slot, int width = 50);
115  virtual wxWindow* RemoveSlot(int index);
116  virtual void SetStatusText(const wxString& text, int index);
117  /// @}
118 
119 protected:
121  eInvalid = -1,
124  eHint
125  };
126 
127  bool x_HasEvent() const
128  {
129  return m_LastEventRecord.GetPointer() != NULL;
130  }
131 
132  void x_TerminateEventMode();
133  void x_TerminateHintMode();
134 
135  void x_UpdateMessageField();
136 
137  void x_OnNewRecord(CEvent*);
138 
139 protected:
141 
142  CStatusBar* m_StatusBar; /// The Status Bar associated with the service
143 
144  EMessageMode m_MessageMode; /// current mode for Message Slot
145 
147 
148  int m_EventDisplayTime; // seconds
149 
152  wxTimer m_EventTimer;
153  wxTimer m_PulseTimer;
154 
156 
158 
160 };
161 
162 
163 ///////////////////////////////////////////////////////////////////////////////
164 /// CStatusBarServiceEvtHandler
166  public wxEvtHandler
167 {
169 public:
171 
172  void OnEventTimer(wxTimerEvent& event);
173  void OnPulseTimer(wxTimerEvent& event);
174 
175 protected:
177 };
178 
179 
180 ///////////////////////////////////////////////////////////////////////////////
181 /// CMessageSlot
183 
185  public wxPanel
186 {
187  DECLARE_EVENT_TABLE()
188 public:
189  typedef wxPanel TParent;
190 
191  CMessageSlot(wxStatusBar* parent);
192  virtual ~CMessageSlot();
193 
194  virtual void Reset();
195  virtual void SetText(const string& text);
196  virtual void SetRecord(const IEventRecord& record);
197 
198  virtual void ShowStatusProgress(int value, int range);
199  virtual void ShowStatusProgress();
200  virtual void HideStatusProgress();
201 
202  virtual void RefreshWithParent();
203 
204  void OnPaint(wxPaintEvent& event);
205  void OnMouseEnter(wxMouseEvent& event);
206  void OnMouseLeave(wxMouseEvent& event);
207  void OnLeftDown(wxMouseEvent& event);
208 
209  /// Callbacks
210  void OnPopupClosed();
211 
212 protected:
213  void x_CreateGaugeIfNeeded();
214  void x_DestroyGauge();
215 
216  void x_SetText(const string& text);
217 
218  bool x_CanShowPopup();
219  bool x_IsPopupShown();
220  void x_ShowPopup();
221  void x_HidePopup();
222 
223 protected:
224  wxBitmap m_Icon;
225  string m_Text;
226  wxString m_TooltipStr;
228 
229  bool m_Hot; // true if slot is displaying "hot track"
230  int m_PaintWidth; // width of the graphics drawn in OnPaint()
231 
232  wxGauge* m_Gauge;
234 };
235 
236 
237 ///////////////////////////////////////////////////////////////////////////////
238 /// CMessageSlotPopupWindow
240  public wxFrame
241 {
242  typedef wxFrame TParent;
243 
244  DECLARE_EVENT_TABLE()
245 public:
246  /// set text and command for the link shown at the bottom of the window
247  static void SetExtraLink(const string& label, int cmd);
248 
250  wxRect slot_rect,
251  const IEventRecord& record,
252  int show_event_view_cmd);
253 
254  void OnActivate(wxActivateEvent& event);
255  void OnLink(wxHyperlinkEvent& event);
256 
257 protected:
258  void x_CreateMessageSlotPanel();
259 
260 protected:
261  static string m_ExtraLabel;
262  static int m_ExtraCmd;
263 
264  CMessageSlot* m_Slot;
265  CConstIRef<IEventRecord> m_EventRecord;
266  int m_ShowEventViewCmd;
267 };
268 
269 
271 
272 /* @} */
273 
274 #endif // GUI_FRAMEWORK___STATUS_BAR_SERVICE_IMPL__HPP
275 
#define static
CEventHandler.
CEventLogService - the standard implementation of IEventLogService.
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
CMessageSlotPopupWindow.
CObjectEx –.
Definition: ncbiobj.hpp:2531
CStatusBarServiceEvtHandler.
CStatusBarService - the standard implementation of IStatusBarService interface.
CStatusBar CStatusBar provides basic support for adding windows to status bar slots when status bar i...
IEventRecord.
IServiceLocatorConsumer - classes that need IServiceLocator should implement this interface.
Definition: service.hpp:103
IServiceLocator - an abstract mechanism for locating services.
Definition: service.hpp:71
IService an abstraction that represents an application component providing specific functional capa...
Definition: service.hpp:56
Workaround for wxWidgets header errors in certain configurations; MUST be included (at least indirect...
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define NULL
Definition: ncbistd.hpp:225
virtual void HideStatusProgress()=0
virtual void ShowHintMessage(const string &msg)=0
virtual wxWindow * RemoveSlot(int index)=0
EMessageMode m_MessageMode
The Status Bar associated with the service.
CConstIRef< IEventRecord > m_EventRecord
virtual void SetStatusMessage(const string &msg)=0
CStatusBarServiceEvtHandler * m_Handler
string m_StatusMessage
current mode for Message Slot
CConstIRef< IEventRecord > TEventRecRef
CMessageSlotPopupWindow * m_Popup
virtual void SetServiceLocator(IServiceLocator *locator)=0
virtual void SetStatusText(const wxString &text, int index)=0
virtual void InitService()=0
void OnEventTimer(wxTimerEvent &event)
CEventLogService * m_EventLogService
virtual void ShutDownService()=0
virtual void HideHintMessage()=0
virtual void ShowStatusProgress()=0
virtual void AddEventMessage(const IEventRecord &record)=0
virtual void InsertSlot(int index, wxWindow *slot, int width=50)=0
CStatusBarServiceEvtHandler(CStatusBarService &service)
CStatusBarServiceEvtHandler.
void OnPulseTimer(wxTimerEvent &event)
#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.
static void text(MDB_val *v)
Definition: mdb_dump.c:62
range(_Ty, _Ty) -> range< _Ty >
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
#define const
Definition: zconf.h:232
Modified on Sun Jun 23 05:17:26 2024 by modify_doxy.py rev. 669887