1 // frmContactEditor-Events.cpp - frmContactEditor Events subroutines.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
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.
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.
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 "frmContactEditor.h"
21 bool frmContactEditor::ProcessEvent(wxEvent& event)
24 // This section has been taken from the wxWidgets sample code of richtext.cpp
25 // so that simple Cut/Copy/Paste code can be made.
27 // As this code comes from the samples of the wxWidgets library, this is licenced
28 // under the wxWindows Library Licence and is compatable with the LGPL and is
29 // compatable with Xestia Address Book's licence.
31 if (event.IsCommandEvent() && !event.IsKindOf(CLASSINFO(wxChildFocusEvent)))
33 // Problem: we can get infinite recursion because the events
34 // climb back up to this frame, and repeat.
35 // Assume that command events don't cause another command event
36 // to be called, so we can rely on inCommand not being overwritten
38 static int s_eventType = 0;
39 static wxWindowID s_id = 0;
41 if (s_id != event.GetId() && s_eventType != event.GetEventType())
43 s_eventType = event.GetEventType();
46 wxWindow* focusWin = wxFindFocusDescendant(this);
47 if (focusWin && focusWin->GetEventHandler()->ProcessEvent(event))
63 return wxFrame::ProcessEvent(event);
66 void frmContactEditor::UpdateDisplayAs( wxCommandEvent &event ){
68 // Generate a drop down list of common names to use for the display as drop down box.
70 wxString SetValue = cmbDisplayAs->GetValue();
72 cmbDisplayAs->Clear();
73 cmbDisplayAs->Append(txtForename->GetValue() + wxT(" ") + txtSurname->GetValue());
74 if (!txtOtherNames->GetValue().IsEmpty()){
76 cmbDisplayAs->Append(txtForename->GetValue() + wxT(" ") + txtOtherNames->GetValue() + wxT(" ") + txtForename->GetValue());
79 cmbDisplayAs->Append(txtSurname->GetValue() + wxT(", ") + txtForename->GetValue());
80 if (!txtOtherNames->GetValue().IsEmpty()){
82 cmbDisplayAs->Append(txtForename->GetValue() + wxT(", ") + wxT(" ") + txtForename->GetValue() + wxT(" ") + txtOtherNames->GetValue());
85 if (!txtTitle->GetValue().IsEmpty()){
86 cmbDisplayAs->Append(txtTitle->GetValue() + wxT(" ") + txtForename->GetValue() + wxT(" ") + txtSurname->GetValue());
89 cmbDisplayAs->SetValue(SetValue);
91 this->SetTitle(cmbDisplayAs->GetValue());
95 void frmContactEditor::UpdateName( wxCommandEvent &event ){
97 this->SetTitle(cmbDisplayAs->GetValue());
99 WindowData *WData = new WindowData;
102 WData->WindowPointer = this;
103 WData->WindowID = ContactEditorUID;
105 wxCommandEvent editevent(WINDOW_EDIT);
106 editevent.SetClientData(WData);
107 wxPostEvent(GetParent(), editevent);