1 // frmSearch-contact.cpp - Search contact 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 "frmSearch.h"
20 #include "../frmMain.h"
21 #include "../frmContact.h"
23 void frmSearch::OpenContact( wxCommandEvent& event ){
25 // Check if a contact has been selected.
27 long intSelected = -1;
28 long intContactSeekNum = -1;
30 intSelected = lstResults->GetNextItem(intSelected,
32 wxLIST_STATE_SELECTED);
34 if (intSelected == -1){
38 intContactSeekNum = lstResults->GetItemData(intSelected);
40 if (SearchMode == TRUE){
42 wxMessageBox(SearchResultFilename[intContactSeekNum]);
46 Person.LoadFile(SearchResultFilename[intContactSeekNum]);
48 wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
49 wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
50 wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
52 contacticon.CopyFromBitmap(contacticonbmp);
54 frmContact *Contact = new frmContact( this );
56 Contact->SetupPointers(&SearchModeMemoryFSPtr);
57 Contact->SetupContactData(&Person);
59 Contact->SetIcon(contacticon);
64 UCNotif *uc = new UCNotif;
66 uc->ContactAccount = SearchResultAccount[intContactSeekNum];
67 uc->ContactFilename = SearchResultFilename[intContactSeekNum];
69 wxCommandEvent oc(CE_OPENCONTACT);
71 wxPostEvent(this->GetParent(), oc);
77 void frmSearch::EditContact( wxCommandEvent& event ){
79 // Check if a contact has been selected.
81 long intSelected = -1;
82 long intContactSeekNum = -1;
84 intSelected = lstResults->GetNextItem(intSelected,
86 wxLIST_STATE_SELECTED);
88 if (intSelected == -1){
92 intContactSeekNum = lstResults->GetItemData(intSelected);
94 UCNotif *uc = new UCNotif;
96 uc->ContactAccount = SearchResultAccount[intContactSeekNum];
97 uc->ContactFilename = SearchResultFilename[intContactSeekNum];
99 wxCommandEvent ec(CE_EDITCONTACT);
100 ec.SetClientData(uc);
102 wxPostEvent(this->GetParent(), ec);
106 void frmSearch::RevealContact( wxCommandEvent& event ){
108 // Check if a contact has been selected.
110 long intSelected = -1;
111 long intContactSeekNum = -1;
113 intSelected = lstResults->GetNextItem(intSelected,
115 wxLIST_STATE_SELECTED);
117 if (intSelected == -1){
121 intContactSeekNum = lstResults->GetItemData(intSelected);
123 UCNotif *uc = new UCNotif;
125 uc->ContactAccount = SearchResultAccount[intContactSeekNum];
126 uc->ContactFilename = SearchResultFilename[intContactSeekNum];
128 wxCommandEvent rc(CE_REVEALCONTACT);
129 rc.SetClientData(uc);
131 wxPostEvent(this->GetParent(), rc);
135 void frmSearch::ShowContactMenu( wxMouseEvent& event ){
137 // Show the contact menu.
139 ContactMenu->SetupPointersSearch(this, lstResults, SearchMode);
141 PopupMenu(ContactMenu->MenuPointer(), wxDefaultPosition);