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 // Process the cut/copy/paste events.
26 // This section has been taken from the wxWidgets sample code of richtext.cpp
27 // so that simple Cut/Copy/Paste code can be made.
29 // As this code comes from the samples of the wxWidgets library, this is licenced
30 // under the wxWindows Library Licence and is compatable with the LGPL and is
31 // compatable with Xestia Address Book's licence.
33 if (event.IsCommandEvent() && !event.IsKindOf(CLASSINFO(wxChildFocusEvent))){
34 // Problem: we can get infinite recursion because the events
35 // climb back up to this frame, and repeat.
36 // Assume that command events don't cause another command event
37 // to be called, so we can rely on inCommand not being overwritten
39 static int s_eventType = 0;
40 static wxWindowID s_id = 0;
42 if (s_id != event.GetId() && s_eventType != event.GetEventType()){
44 s_eventType = event.GetEventType();
47 wxWindow* focusWin = wxFindFocusDescendant(this);
48 if (focusWin && focusWin->GetEventHandler()->ProcessEvent(event)){
64 return wxFrame::ProcessEvent(event);
68 void frmContactEditor::UpdateDisplayAs( wxCommandEvent &event ){
70 // Generate a drop down list of common names to
71 // use for the display as drop down box.
73 wxString SetValue = cmbDisplayAs->GetValue();
75 cmbDisplayAs->Clear();
76 cmbDisplayAs->Append(txtForename->GetValue() + wxT(" ") + txtSurname->GetValue());
77 if (!txtOtherNames->GetValue().IsEmpty()){
79 cmbDisplayAs->Append(txtForename->GetValue() + wxT(" ") + txtOtherNames->GetValue() + wxT(" ") + txtForename->GetValue());
82 cmbDisplayAs->Append(txtSurname->GetValue() + wxT(", ") + txtForename->GetValue());
83 if (!txtOtherNames->GetValue().IsEmpty()){
85 cmbDisplayAs->Append(txtForename->GetValue() + wxT(", ") + wxT(" ") + txtForename->GetValue() + wxT(" ") + txtOtherNames->GetValue());
88 if (!txtTitle->GetValue().IsEmpty()){
89 cmbDisplayAs->Append(txtTitle->GetValue() + wxT(" ") + txtForename->GetValue() + wxT(" ") + txtSurname->GetValue());
91 cmbDisplayAs->SetValue(SetValue);
93 this->SetTitle(cmbDisplayAs->GetValue());
97 void frmContactEditor::UpdateName( wxCommandEvent &event ){
99 // Update the window title and main window menu item
100 // with the new name.
102 this->SetTitle(cmbDisplayAs->GetValue());
104 WindowData *WData = new WindowData;
106 if (StartupEditMode == FALSE){
109 WData->WindowPointer = this;
110 WData->WindowID = ContactEditorUID;
112 wxCommandEvent editevent(WINDOW_EDIT);
113 editevent.SetClientData(WData);
114 wxPostEvent(GetParent(), editevent);