Below are a number of functions/macros used with wxWidgets event-handling system.
Related class group: Events
#define wx__DECLARE_EVT0 | ( | evt, | |
fn | |||
) | wx__DECLARE_EVT1(evt, wxID_ANY, fn) |
Simplified version of the wx__DECLARE_EVT1() macro, to be used when the event type must be handled regardless of the ID associated with the specific event instances.
#define wx__DECLARE_EVT1 | ( | evt, | |
id, | |||
fn | |||
) | wx__DECLARE_EVT2(evt, id, wxID_ANY, fn) |
This macro is used to define event table macros for handling custom events.
Example of use:
class MyEvent : public wxEvent { ... }; // note that this is not necessary unless using old compilers: for the // reasonably new ones just use &func instead of MyEventHandler(func) typedef void (wxEvtHandler::*MyEventFunction)(MyEvent&); #define MyEventHandler(func) wxEVENT_HANDLER_CAST(MyEventFunction, func) wxDEFINE_EVENT(MY_EVENT_TYPE, MyEvent); #define EVT_MY(id, func) \ wx__DECLARE_EVT1(MY_EVENT_TYPE, id, MyEventHandler(func)) ... wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MY(wxID_ANY, MyFrame::OnMyEvent) wxEND_EVENT_TABLE()
evt | The event type to handle. |
id | The identifier of events to handle. |
fn | The event handler method. |
#define wx__DECLARE_EVT2 | ( | evt, | |
id1, | |||
id2, | |||
fn | |||
) | DECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, NULL), |
Generalized version of the wx__DECLARE_EVT1() macro taking a range of IDs instead of a single one.
Argument id1 is the first identifier of the range, id2 is the second identifier of the range.
#define wxBEGIN_EVENT_TABLE | ( | theClass, | |
baseClass | |||
) |
Use this macro in a source file to start listing static event handlers for a specific class.
Use wxEND_EVENT_TABLE() to terminate the event-declaration block.
#define wxDECLARE_EVENT | ( | name, | |
cls | |||
) | wxDECLARE_EXPORTED_EVENT(wxEMPTY_PARAMETER_VALUE, name, cls) |
カスタムイベント型を宣言します。
This macro declares a variable called name which must be defined elsewhere using wxDEFINE_EVENT().
The class cls must be the wxEvent-derived class associated with the events of this type and its full declaration must be visible from the point of use of this macro.
以下に例を示します:
wxDECLARE_EVENT(MY_COMMAND_EVENT, wxCommandEvent); class MyCustomEvent : public wxEvent { ... }; wxDECLARE_EVENT(MY_CUSTOM_EVENT, MyCustomEvent);
#define wxDECLARE_EVENT_TABLE | ( | ) |
Use this macro inside a class declaration to declare a static event table for that class.
In the implementation file you'll need to use the wxBEGIN_EVENT_TABLE() and the wxEND_EVENT_TABLE() macros, plus some additional EVT_xxx
macro to capture events.
Note that this macro requires a final semicolon.
#define wxDECLARE_EXPORTED_EVENT | ( | expdecl, | |
name, | |||
cls | |||
) | extern const expdecl wxEventTypeTag< cls > name; |
Variant of wxDECLARE_EVENT() used for event types defined inside a shared library.
This is mostly used by wxWidgets internally, e.g.
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEvent)
#define wxDEFINE_EVENT | ( | name, | |
cls | |||
) | const wxEventTypeTag< cls > name(wxNewEventType()) |
特定のイベントクラスに関連する新しいイベント型を定義します。
This macro defines a new unique event type name associated with the event class cls.
以下に例を示します:
wxDEFINE_EVENT(MY_COMMAND_EVENT, wxCommandEvent); class MyCustomEvent : public wxEvent { ... }; wxDEFINE_EVENT(MY_CUSTOM_EVENT, MyCustomEvent);
#define wxEND_EVENT_TABLE | ( | ) |
Use this macro in a source file to end listing static event handlers for a specific class.
Use wxBEGIN_EVENT_TABLE() to start the event-declaration block.
#define wxEVENT_HANDLER_CAST | ( | functype, | |
func | |||
) | (&func) |
Helper macro for definition of custom event table macros.
This macro must only be used if wxEVENTS_COMPATIBILITY_2_8 is 1, otherwise it is better and more clear to just use the address of the function directly as this is all this macro does in this case. However it needs to explicitly cast func to functype, which is the type of wxEvtHandler member function taking the custom event argument when wxEVENTS_COMPATIBILITY_2_8 is 0.
See wx__DECLARE_EVT0 for an example of use.
typedef int wxEventType |
イベントの型を一意に識別する値。
The values of this type should only be created using wxNewEventType().
See the macro DEFINE_EVENT_TYPE() for more info.
wxEventType wxNewEventType | ( | ) |
Generates a new unique event type.
Usually this function is only used by wxDEFINE_EVENT() and not called directly.
void wxPostEvent | ( | wxEvtHandler * | dest, |
const wxEvent & | event | ||
) |
In a GUI application, this function posts event to the specified dest object using wxEvtHandler::AddPendingEvent().
Otherwise, it dispatches event immediately using wxEvtHandler::ProcessEvent(). See the respective documentation for details (and caveats). Because of limitation of wxEvtHandler::AddPendingEvent() this function is not thread-safe for event objects having wxString fields, use wxQueueEvent() instead.
Include file:
#include <wx/event.h>
void wxQueueEvent | ( | wxEvtHandler * | dest, |
wxEvent * | event | ||
) |
特定のオブジェクトで処理するためにイベントをキューへ追加します。
This is a wrapper around wxEvtHandler::QueueEvent(), see its documentation for more details.
Include file:
#include <wx/event.h>
dest | The object to queue the event on, can't be NULL . |
event | The heap-allocated and non-NULL event to queue, the function takes ownership of it. |
A special event type usually used to indicate that some wxEvent has yet no type assigned.