Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Move INSTALL, LICENSE, README, THANKS and TODO into root directory
[xestiaab/.git] / source / common / events.h
1 // events.h - Events subroutines.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include <wx/wx.h>
20 #include <wx/event.h>
21 #include "../vcard/vcard.h"
22 #include "../frmMain.h"
24 #ifndef EVENTS_H
25 #define EVENTS_H
27 /*
29 // Could have been DECLARE_EVENT_TYPE( MyFooCommandEvent, -1 )
30 // Not needed if you only use the event-type in one .cpp file
31 DECLARE_EVENT_TYPE(ContactConflictCmdEnv, 7000);
33 // A custom event that transports a whole wxString.
34 class ContactConflictEvent: public wxCommandEvent
35 {
36 public:
37         ContactConflictEvent( wxEventType commandType = ContactConflictCmdEnv, int id = 0 )
38         :  wxCommandEvent(commandType, id) { }
39  
40         // You *must* copy here the data to be transported
41         ContactConflictEvent( const ContactConflictEvent &event )
42         :  wxCommandEvent(event) { this->SetData( event.GetText(), event.GetLocalData(), event.GetServerData() ); }
43  
44         // Required for sending with wxPostEvent()
45         wxEvent* Clone() const { return new ContactConflictEvent(*this); }
46  
47         wxString GetText() const { return Filename; }
48         vCard GetLocalData() const { return LocalData; }
49         vCard GetServerData() const { return ServerData; }
50         void SetData( const wxString& text, vCard LocalDataInc, vCard ServerDataInc ) { 
51                 Filename = text; 
52                 LocalData = LocalDataInc; 
53                 ServerData = ServerDataInc;
54                 }
55  
56 private:
57         wxString Filename;
58         vCard LocalData;
59         vCard ServerData;
60 };
61  
62 typedef void (wxEvtHandler::*ContactConflictEventFunction)(ContactConflictEvent &);
63  
64 // This #define simplifies the one below, and makes the syntax less
65 // ugly if you want to use Connect() instead of an event table.
66 #define ContactConflictEventHandler(func)                                         \
67         (wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction)\\
68         wxStaticCastEvent(ContactConflictEventFunction, &func)                    
69  
70 // Define the event table entry. Yes, it really *does* end in a comma.
71 #define EVT_CONTACTCONFLICT(id, fn)                                            \
72         DECLARE_EVENT_TABLE_ENTRY( ContactConflictCmdEnv, id, wxID_ANY,  \\
73         (wxObjectEventFunction)(wxEventFunction)                     \\
74         (wxCommandEventFunction) wxStaticCastEvent(                  \\
75         ContactConflictEventFunction, &fn ), (wxObject*) NULL ),
76  
77 // Optionally, you can do a similar #define for EVT_MYFOO_RANGE.
78 #define EVT_CONTACTCONFLICT_RANGE(id1,id2, fn)                                 \
79         DECLARE_EVENT_TABLE_ENTRY( ContactConflictCmdEnv, id1, id2,      \\
80         ContactConflictEventHandler(fn), (wxObject*) NULL ),
81  
82 // If you want to use the custom event to send more than one sort
83 // of data, or to more than one place, make it easier by providing
84 // named IDs in an enumeration.
85 enum { Foo_DoFirstThing = 1, Foo_DoSecondThing, Foo_DoThirdThing };
87 */
89 #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