3 #include "../vcard/vcard.h"
4 #include "../frmMain.h"
11 // Could have been DECLARE_EVENT_TYPE( MyFooCommandEvent, -1 )
12 // Not needed if you only use the event-type in one .cpp file
13 DECLARE_EVENT_TYPE(ContactConflictCmdEnv, 7000);
15 // A custom event that transports a whole wxString.
16 class ContactConflictEvent: public wxCommandEvent
19 ContactConflictEvent( wxEventType commandType = ContactConflictCmdEnv, int id = 0 )
20 : wxCommandEvent(commandType, id) { }
22 // You *must* copy here the data to be transported
23 ContactConflictEvent( const ContactConflictEvent &event )
24 : wxCommandEvent(event) { this->SetData( event.GetText(), event.GetLocalData(), event.GetServerData() ); }
26 // Required for sending with wxPostEvent()
27 wxEvent* Clone() const { return new ContactConflictEvent(*this); }
29 wxString GetText() const { return Filename; }
30 vCard GetLocalData() const { return LocalData; }
31 vCard GetServerData() const { return ServerData; }
32 void SetData( const wxString& text, vCard LocalDataInc, vCard ServerDataInc ) {
34 LocalData = LocalDataInc;
35 ServerData = ServerDataInc;
44 typedef void (wxEvtHandler::*ContactConflictEventFunction)(ContactConflictEvent &);
46 // This #define simplifies the one below, and makes the syntax less
47 // ugly if you want to use Connect() instead of an event table.
48 #define ContactConflictEventHandler(func) \
49 (wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction)\\
50 wxStaticCastEvent(ContactConflictEventFunction, &func)
52 // Define the event table entry. Yes, it really *does* end in a comma.
53 #define EVT_CONTACTCONFLICT(id, fn) \
54 DECLARE_EVENT_TABLE_ENTRY( ContactConflictCmdEnv, id, wxID_ANY, \\
55 (wxObjectEventFunction)(wxEventFunction) \\
56 (wxCommandEventFunction) wxStaticCastEvent( \\
57 ContactConflictEventFunction, &fn ), (wxObject*) NULL ),
59 // Optionally, you can do a similar #define for EVT_MYFOO_RANGE.
60 #define EVT_CONTACTCONFLICT_RANGE(id1,id2, fn) \
61 DECLARE_EVENT_TABLE_ENTRY( ContactConflictCmdEnv, id1, id2, \\
62 ContactConflictEventHandler(fn), (wxObject*) NULL ),
64 // If you want to use the custom event to send more than one sort
65 // of data, or to more than one place, make it easier by providing
66 // named IDs in an enumeration.
67 enum { Foo_DoFirstThing = 1, Foo_DoSecondThing, Foo_DoThirdThing };