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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_WX___POPUP_EVENT__HPP
2 #define GUI_WIDGETS_WX___POPUP_EVENT__HPP
3 
4 /* $Id: popup_event.hpp 30858 2014-07-31 14:05:43Z 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 #include <corelib/ncbistd.hpp>
35 
36 #include <gui/gui.hpp>
37 
38 // This header must (at least indirectly) precede any wxWidgets headers.
40 
41 #include <wx/event.h>
42 
43 
45 
46 ///////////////////////////////////////////////////////////////////////////////
47 /// CPopupMenuEvent - an event that is sent when a popup menu needs to be shown.
48 /// The event allows to delegate one of the two functions - decorating popup menu
49 /// that is about to be shown or constructing and showing the menu.
50 /// For eDecorate event the reciever can add wxEvtHandlers to the event objects,
51 /// then menu sender should use these handler to handle the contributed commands.
52 
54 {
55 public:
56  typedef vector<wxEvtHandler*> THandlers;
57 
58  // TODO combine both types in one
59  enum EType {
60  eDecorate = eEvent_MinClientID, // the reciever should decorate the menu
61  eShow // the reciever shall construct and display popup menu
62  };
63 
64  CPopupMenuEvent(TEventSender* sender, wxMenu* menu)
65  : CEvent(eEvent_Message, eDecorate, sender),
66  m_Menu(menu)
67  {
68  }
70  : CEvent(eEvent_Message, eShow, sender),
71  m_Menu(NULL)
72  {
73  }
74 
75  wxMenu* GetMenu()
76  {
77  return m_Menu;
78  }
79  void SetMenu(wxMenu* menu)
80  {
81  m_Menu = menu;
82  }
83  void AddHandler(wxEvtHandler* handler)
84  {
86  m_Handlers.push_back(handler);
87  }
89  {
90  return m_Handlers;
91  }
92 
93 protected:
94  // the menu that sender is about to show; the reciever can modify the
95  // existing object or replace it with a new one
96  wxMenu* m_Menu;
97 
98  // a collection of wxEvtHandler-s that will handle commands contributed
99  // to the menu. The caller must add these handlers to its event processing
100  // chain. The caller assumes ownership of the handlers and must delete
101  // them after use
103 };
104 
106 
107 
108 #endif // GUI_WIDGETS_WX___POPUP_EVENT__HPP
CEventHandler.
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
CPopupMenuEvent - an event that is sent when a popup menu needs to be shown.
Definition: popup_event.hpp:54
wxMenu * GetMenu()
Definition: popup_event.hpp:75
THandlers m_Handlers
vector< wxEvtHandler * > THandlers
Definition: popup_event.hpp:56
CPopupMenuEvent(TEventSender *sender, wxMenu *menu)
Definition: popup_event.hpp:64
CPopupMenuEvent(TEventSender *sender)
Definition: popup_event.hpp:69
void AddHandler(wxEvtHandler *handler)
Definition: popup_event.hpp:83
void SetMenu(wxMenu *menu)
Definition: popup_event.hpp:79
THandlers & GetHandlers()
Definition: popup_event.hpp:88
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
Include a standard set of the NCBI C++ Toolkit most basic headers.
Workaround for wxWidgets header errors in certain configurations; MUST be included (at least indirect...
#define NULL
Definition: ncbistd.hpp:225
@ 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
#define NCBI_GUIWIDGETS_WX_EXPORT
Definition: gui_export.h:543
#define _ASSERT
Modified on Sat Mar 02 10:53:57 2024 by modify_doxy.py rev. 669887