Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial import of code already done for Xestia Address Book
[xestiaab/.git] / source / common / events.h
1 #include <wx/wx.h>
2 #include <wx/event.h>
3 #include "../vcard/vcard.h"
4 #include "../frmMain.h"
6 #ifndef EVENTS_H
7 #define EVENTS_H
9 /*
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
17 {
18 public:
19         ContactConflictEvent( wxEventType commandType = ContactConflictCmdEnv, int id = 0 )
20         :  wxCommandEvent(commandType, id) { }
21  
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() ); }
25  
26         // Required for sending with wxPostEvent()
27         wxEvent* Clone() const { return new ContactConflictEvent(*this); }
28  
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 ) { 
33                 Filename = text; 
34                 LocalData = LocalDataInc; 
35                 ServerData = ServerDataInc;
36                 }
37  
38 private:
39         wxString Filename;
40         vCard LocalData;
41         vCard ServerData;
42 };
43  
44 typedef void (wxEvtHandler::*ContactConflictEventFunction)(ContactConflictEvent &);
45  
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)                    
51  
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 ),
58  
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 ),
63  
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 };
69 */
71 #endif
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy